Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement led support #5850

Merged
merged 157 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
5839466
init
Sep 27, 2022
72aaa2a
path
Sep 28, 2022
f6052d3
Merge branch 'develop' into feature-web-proto
Sep 30, 2022
465ac02
remove a circular dependency
Sep 30, 2022
f5e3276
fix dependency loop and first working exemple
Sep 30, 2022
3925cb3
quick cleanup
Sep 30, 2022
e61d99a
cleanup
Sep 30, 2022
75d460b
cleanup
Sep 30, 2022
726c6a5
progress mesh
Sep 30, 2022
455700d
meshes and loading
Sep 30, 2022
2d8a1ed
cleanup
Sep 30, 2022
13d48c3
mfint32
Oct 3, 2022
a0dc657
idfs and sfnode
Oct 3, 2022
366f396
mffloat
Oct 3, 2022
2738de7
cleanup
Oct 3, 2022
26126db
fix elevation grid bug
Oct 3, 2022
1fbbf19
elevation grid in body
Oct 3, 2022
365459a
improvements
Oct 4, 2022
4e149b8
better initial scene
Oct 4, 2022
217bdcc
support PointSet in body
Oct 4, 2022
f5c21e6
pbr and cleanup
Oct 4, 2022
506868e
parse pbr but broke ifs/ils
Oct 4, 2022
e1cb1c2
fix MFVec3 parsing in parameter
Oct 4, 2022
35163d6
fix imageTexture parsing for appearance
Oct 5, 2022
115e59b
authorize robot node
Oct 5, 2022
475c70e
slot.js
Oct 5, 2022
516bf7c
add fieldmodels for for sliderjoints and jointparameters
Oct 5, 2022
bd383aa
fix appearance in header
Oct 5, 2022
f24803d
print externproto
Oct 5, 2022
d8f4c69
default open
Oct 6, 2022
2b60b03
merge develop
Oct 7, 2022
ca4bef0
webots://
Oct 10, 2022
beebd44
style
Oct 10, 2022
0dd69c0
protos example
Oct 10, 2022
1367d00
fix conflicts
Oct 10, 2022
4c60a7a
move template js
Oct 10, 2022
8ef2b4d
fix buggy private variables
Oct 10, 2022
8fd3bb2
private variable
Oct 10, 2022
e118b46
fix missing import (#5322)
Oct 11, 2022
5a35050
Merge develop in feature-web-proto (#5321)
Oct 11, 2022
8c5568c
Add CadShape fieldModel (#5323)
Oct 11, 2022
b84f955
Feature web tesselator (#5320)
Oct 12, 2022
efcbab3
Enhancement add new web nodes (#5328)
Oct 14, 2022
187283a
merge develop
Oct 18, 2022
c2e46dd
Merge pull request #5344 from cyberbotics/merge-dev-in-feature-web-proto
Oct 18, 2022
e1f7ace
Fix ccw indexed faceset web (#5354)
Oct 20, 2022
97c634d
Improve PROTO web loader (#5314)
ad-daniel Oct 26, 2022
4d12a63
WebotsJS: add support for updates (#5333)
Oct 26, 2022
187cb6c
Extend proto visualizer (#5370)
ad-daniel Oct 27, 2022
fe23053
Add support for 5+ vertices polygon (#5375)
Oct 27, 2022
6493f9b
Fix deletion bug (#5382)
Oct 31, 2022
14b1cbe
Implement first use case of webots.cloud/proto (#5376)
Oct 31, 2022
8aba348
Merge develop in feature-web-proto (#5400)
Oct 31, 2022
c6ea86d
Fix js template files in files_core.txt (#5429)
Nov 7, 2022
fa45e73
Merge `develop` into `feature-web-proto` (#5434)
ad-daniel Nov 8, 2022
b00b63f
Web proto: second usecase: joints (#5404)
Nov 8, 2022
a418118
Merge branch 'develop' into merge-develop-into-feature-web-proto3
ad-daniel Nov 9, 2022
5384433
Merge pull request #5443 from cyberbotics/merge-develop-into-feature-…
ad-daniel Nov 9, 2022
9a415de
Merge `develop` into `feature-web-proto` (#5526)
ad-daniel Nov 21, 2022
f34812b
Merge develop feature web proto (#5564)
Nov 24, 2022
0bfe392
fix conflicts
Nov 29, 2022
6c17cac
Update WebotsView.js
Nov 29, 2022
0aad203
Merge pull request #5602 from cyberbotics/try-sync-develop-in-web-proto
Nov 30, 2022
cfdc184
Add libtess (#5605)
Nov 30, 2022
3c154a5
Fix two bugs in feature-web-proto (#5613)
Dec 1, 2022
ae398af
Reset button is grey when there is nothing to reset (#5614)
Dec 1, 2022
29e72cb
Enhancement display camera (#5612)
Dec 2, 2022
a164e80
Merge pull request #5623 from cyberbotics/develop
Dec 2, 2022
6cceb4f
Merge branch 'develop' into feature-web-proto
Dec 5, 2022
b16ab81
Web Proto Viewer: RangeFinder and Lidar (#5628)
Dec 5, 2022
9970684
Radar frustum web (#5631)
Dec 6, 2022
985f50b
Add light sensor optional rendering to the web proto viewer (#5634)
Dec 6, 2022
1388cf2
fix conflicts
Dec 7, 2022
15360f2
Merge pull request #5637 from cyberbotics/merge-develop-in-featureweb…
Dec 7, 2022
fcab6e4
Add pen optional rendering to the web proto viewer (#5635)
Dec 7, 2022
104173e
Add delete function in devices (#5644)
Dec 8, 2022
467391e
display connector (#5645)
Dec 8, 2022
c7d02ee
Merge pull request #5652 from cyberbotics/develop
Dec 13, 2022
6d33596
Display distance sensor in web proto viewer (#5641)
Dec 13, 2022
3f312c7
Slider joint in web proto viewer (#5660)
Dec 14, 2022
50167f4
Enhancement hinge2joints slider (#5664)
Dec 14, 2022
9d040a4
Ball joint slider (#5668)
Dec 15, 2022
df336be
Merge pull request #5681 from cyberbotics/develop
Dec 20, 2022
c9e3af4
Enhancement display axis system for other devices (#5684)
Dec 23, 2022
992c706
Merge develop in feature-web-proto (#5693)
Dec 23, 2022
5b4c176
fix conflict
Jan 4, 2023
160a26c
Merge pull request #5710 from cyberbotics/merge-develop-into-feature-…
Jan 4, 2023
9cec40b
Merge branch 'develop' into feature-web-proto
Jan 4, 2023
140851d
Support coupled motors on slider update (#5711)
Jan 5, 2023
94dd670
Add support for SFNode editing in Web PROTO (#5435)
ad-daniel Jan 6, 2023
e9a7e7b
Add support for field restrictions to web proto (#5720)
ad-daniel Jan 9, 2023
005a289
Web proto viewer: add support for missing parameters type (#5718)
Jan 11, 2023
7c02f93
Add support for MFNode in web proto (#5728)
ad-daniel Jan 11, 2023
4a2eecb
handle blank field (#5730)
Jan 12, 2023
5eb8a32
Enhancement sphere for appearances (#5731)
Jan 12, 2023
84689d5
Fix notification after regeneration (#5733)
ad-daniel Jan 13, 2023
18f3efa
Fix transparency in webotsjs (#5735)
ad-daniel Jan 13, 2023
b06d250
Enhancement tab (#5737)
Jan 13, 2023
9dc162a
Merge pull request #5743 from cyberbotics/develop
Jan 16, 2023
c060103
Add documentation to webots.cloud (#5734)
Jan 17, 2023
eaa04d3
Enhancement get rid of proto list for webotsjs (#5749)
Jan 18, 2023
6883a31
Cleanup web proto viewer (#5750)
Jan 18, 2023
a542d17
cleanup
Jan 19, 2023
0c16a72
let to const
Jan 19, 2023
7af7a92
let
Jan 19, 2023
bce403c
log
Jan 19, 2023
6943ebf
Update resources/web/wwi/nodes/WbAbstractAppearance.js
Jan 19, 2023
10b28c8
Update resources/web/wwi/nodes/WbIndexedFaceSet.js
Jan 19, 2023
08145e3
Update resources/web/wwi/ProtoManager.js
Jan 19, 2023
f542918
remove translatioN
Jan 19, 2023
2b05694
Merge branch 'develop' into feature-web-proto
Jan 19, 2023
4257575
doc
Jan 19, 2023
bb49ed8
wrong branch
Jan 19, 2023
7a1869f
Add multiplier support for web protos (#5756)
Jan 20, 2023
11581ed
Fix conflicts
Jan 20, 2023
aa4e71c
Merge pull request #5760 from cyberbotics/merge-develop-in-feature-web
Jan 20, 2023
3ff4611
Add description to basenode_encode.py
ad-daniel Jan 20, 2023
a6050c3
Update scripts/packaging/files_core.txt
ad-daniel Jan 20, 2023
cee2fef
Fix template engine
ad-daniel Jan 20, 2023
bc3d631
Merge branch 'feature-web-proto' of github.com:cyberbotics/webots int…
ad-daniel Jan 20, 2023
72b93a0
tolerance lower
Jan 20, 2023
4e1559c
comment html
Jan 20, 2023
279cc32
Merge branch 'develop' into feature-web-proto
Jan 20, 2023
dc4a34b
fix hinge2 and balljoint
Jan 20, 2023
d456934
Merge branch 'feature-web-proto' of https://github.com/cyberbotics/we…
Jan 20, 2023
d3c53d3
add a add button for mf field (#5764)
Jan 20, 2023
caaff12
fix import
Jan 23, 2023
46cece0
new fieldModel
Jan 23, 2023
7e58b4c
css scroll
Jan 23, 2023
1ff87ed
fix bug
Jan 23, 2023
9bf5513
Fix floating window resize (#5772)
Jan 23, 2023
6c76235
fix conflicts
Jan 23, 2023
483b33f
z-index
Jan 23, 2023
0e9f5a2
Merge branch 'develop' into feature-web-proto
Jan 27, 2023
c588778
Merge branch 'develop' into feature-web-proto
Jan 27, 2023
8a38b5a
Merge branch 'develop' into feature-web-proto
Jan 30, 2023
4acb318
Rework node building logic, remove node cloning & fix several issues …
ad-daniel Jan 30, 2023
36703d2
Remove unused material references (#5800)
ad-daniel Jan 30, 2023
c3132f7
Fix missing mtl import (#5802)
Jan 30, 2023
5464ce2
Merge branch 'develop' into feature-web-proto
Jan 31, 2023
35352fd
Fix web proto issues related to vehicles (#5811)
ad-daniel Feb 2, 2023
e781a5c
Merge branch 'develop' into feature-web-proto
Feb 3, 2023
9ce0422
Fix link (#5830)
ad-daniel Feb 3, 2023
62b712f
Merge branch 'develop' into feature-web-proto
Feb 3, 2023
413c8de
Enhancement display of vectors (#5831)
Feb 3, 2023
cdb1fa8
start
Feb 3, 2023
45fc4ee
Merge branch 'develop' into feature-web-proto
Feb 6, 2023
9bf5ca7
reset value
Feb 6, 2023
96d6c1d
implementation
Feb 6, 2023
94257a4
replace urls
Feb 7, 2023
998df0d
Merge branch 'develop' into feature-web-proto
Feb 7, 2023
edb10a4
Merge branch 'feature-web-proto' into enhancement-led-support
Feb 7, 2023
46242ca
fix conflicts
Feb 7, 2023
553c71d
reset
Feb 7, 2023
df27596
released
Feb 7, 2023
75ec237
Merge branch 'develop' into enhancement-led-support
Feb 7, 2023
f31a82e
default empty list color
Feb 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions resources/web/wwi/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,18 @@ export default class Parser {
newNode = new WbGyro(id, translation, scale, rotation, name === '' ? 'gyro' : name);
else if (node.tagName === 'InertialUnit')
newNode = new WbInertialUnit(id, translation, scale, rotation, name === '' ? 'inertial unit' : name);
else if (node.tagName === 'LED')
newNode = new WbLed(id, translation, scale, rotation, name === '' ? 'led' : name);
else if (node.tagName === 'Lidar') {
else if (node.tagName === 'LED') {
let tempColor = getNodeAttribute(node, 'color', '1 0 0');
tempColor = convertStringToFloatArray(tempColor);
const color = [];
if (tempColor.length % 3 === 0) {
for (let i = 0; i < tempColor.length; i += 3)
color.push(new WbVector3(tempColor[i], tempColor[i + 1], tempColor[i + 2]));
} else
console.error('Wrong number of colors in LED');

newNode = new WbLed(id, translation, scale, rotation, name === '' ? 'led' : name, color);
} else if (node.tagName === 'Lidar') {
const fieldOfView = parseFloat(getNodeAttribute(node, 'fieldOfView', Math.PI / 2));
const horizontalResolution = parseInt(getNodeAttribute(node, 'horizontalResolution', '512'));
const maxRange = parseFloat(getNodeAttribute(node, 'maxRange', '1'));
Expand Down
3 changes: 3 additions & 0 deletions resources/web/wwi/nodes/WbAppearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export default class WbAppearance extends WbAbstractAppearance {
this.#material.onChange = () => this.#update();

this.#update();

if (typeof this.notifyLed !== 'undefined')
this.notifyLed();
}

get texture() {
Expand Down
155 changes: 155 additions & 0 deletions resources/web/wwi/nodes/WbLed.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,160 @@
import WbAppearance from './WbAppearance.js';
import WbDevice from './WbDevice.js';
import WbGroup from './WbGroup.js';
import WbLight from './WbLight.js';
import WbShape from './WbShape.js';
import WbVector3 from './utils/WbVector3.js';
import {clampValuesIfNeeded} from './utils/WbFieldChecker.js';

// This class is used to retrieve the type of device
export default class WbLed extends WbDevice {
#color;
#lights;
#materials;
#pbrAppearances;
#value;
constructor(id, translation, scale, rotation, name, color) {
super(id, translation, scale, rotation, name);
this.#lights = [];
this.#materials = [];
this.#pbrAppearances = [];
this.#color = color;
this.#value = 0;
}

get value() {
return this.#value;
}

set value(newValue) {
if (this.#value === newValue)
return;
this.#value = newValue;

this.#setMaterialsAndLightsColor();
}

postFinalize() {
super.postFinalize();

this._updateChildren();

// disable WREN lights if not on
const on = this.#value !== 0;
for (const light of this.#lights)
light.on = on;
}

applyOptionalRendering(enable) {
this.value = enable ? 1 : 0;
}

_updateChildren() {
if (!this.isPostFinalizedCalled)
return;

this.#findMaterialsAndLights(this);

// update color of lights and materials
this.#setMaterialsAndLightsColor();
}

#clearMaterialsAndLights() {
this.#materials = [];
this.#lights = [];
this.#pbrAppearances = [];
}

#findMaterialsAndLights(group) {
let size = group.children.length;
if (size < 1)
return;

if (group === this) {
this.#clearMaterialsAndLights();
size = 1; // we look only into the first child of the WbLed node
}

for (const child of group.children) {
if (child instanceof WbShape && typeof child.appearance !== 'undefined') {
const appearance = child.appearance;
if (appearance instanceof WbAppearance) {
const material = appearance.material;
if (typeof material !== 'undefined')
this.#materials.push(material);

appearance.notifyLed = () => this._updateChildren();
child.notifyLed = () => this._updateChildren();
} else if (typeof appearance !== 'undefined') {
this.#pbrAppearances.push(appearance);
child.notifyLed = () => this._updateChildren();
}
} else if (child instanceof WbLight)
this.#lights.push(child);
else if (child instanceof WbGroup) {
this.#findMaterialsAndLights(child);
const proxy = new Proxy(child.children, {
deleteProperty: (target, property) => {
delete target[property];
this._updateChildren();
return true;
},
set: (target, property, value, receiver) => {
target[property] = value;
this._updateChildren();
return true;
}
});
child.children = proxy;
}
}

if (group === this && !this.#isAnyMaterialOrLightFound())
console.warn(`No PBRAppearance, Material and no Light found.
The first child of a LED should be either a Shape, a Light or a Group containing Shape and Light nodes.`);
}

#isAnyMaterialOrLightFound() {
return (this.#materials.length > 0 || this.#lights.length > 0 || this.#pbrAppearances.length > 0);
}

#setMaterialsAndLightsColor() {
// compute the new color
let r, g, b;
if (this.#value > 0) {
if (this.#value - 1 < this.#color.length) {
const c = this.#color[this.value - 1];
r = c.x;
g = c.y;
b = c.z;
} else {
r = 1;
g = 1;
b = 1;
}
} else {
r = 0;
g = 0;
b = 0;
}

let color = new WbVector3(r, g, b);
color = clampValuesIfNeeded(color);

// update every material
for (const material of this.#materials)
material.emissiveColor = color;

// same for PbrAppearances
for (const pbrAppearance of this.#pbrAppearances)
pbrAppearance.emissiveColor = color;

// update every lights
const on = this.#value !== 0;
for (const light of this.#lights) {
light.color = color;
// disable WREN lights if not on
light.on = on;
}
}
}
3 changes: 3 additions & 0 deletions resources/web/wwi/nodes/WbShape.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export default class WbShape extends WbBaseNode {
useNode.appearance.parent = useNode.id;
}
}

if (typeof this.notifyLed !== 'undefined')
this.notifyLed();
}

applyMaterialToGeometry() {
Expand Down
2 changes: 1 addition & 1 deletion resources/web/wwi/nodes/utils/WbFieldChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@ function clampValue(value) {
return value;
}

export {resetIfNegative, resetIfNonPositive, resetVector2IfNonPositive, resetVector3IfNonPositive,
export {resetIfNegative, resetIfNonPositive, resetVector2IfNonPositive, resetVector3IfNonPositive, clampValuesIfNeeded,
resetIfNotInRangeWithIncludedBounds, resetColorIfInvalid, resetMultipleColorIfInvalid, resetVector3IfNegative};
2 changes: 1 addition & 1 deletion resources/web/wwi/protoVisualizer/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export default class Node {
if (line.indexOf('EXTERNPROTO') !== -1) { // get only the text after 'EXTERNPROTO'
let address = line.split('EXTERNPROTO')[1].trim().replaceAll('"', '');
if (address.startsWith('webots://'))
address = 'https://raw.githubusercontent.com/cyberbotics/webots/released/' + address.substring(9);
address = 'https://raw.githubusercontent.com/cyberbotics/webots/develop/' + address.substring(9); // TODO change to released once a new version is published
else
address = combinePaths(address, protoUrl);

Expand Down
3 changes: 3 additions & 0 deletions resources/web/wwi/protoVisualizer/Vrml.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,9 @@ export class MFVec3f extends MultipleValue {

export class MFColor extends MultipleValue {
setValueFromTokenizer(tokenizer) {
// If we reach this function it means that the MFColor does not have the default value.
// Thus we should reset the value because it already contains the default one: [1 0 0].
this.value = [];
if (tokenizer.peekWord() === '[') {
tokenizer.skipToken('[');

Expand Down