Skip to content

Commit

Permalink
Fix devices scale (#5751)
Browse files Browse the repository at this point in the history
* Fix devices scale

* solve todos
  • Loading branch information
Benjamin Délèze authored Jan 18, 2023
1 parent dcd6835 commit a87767a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 20 deletions.
2 changes: 1 addition & 1 deletion resources/web/wwi/ProtoManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class ProtoManager {
// generate list of exposed parameters (that will be tied to interface elements)
for (const [parameterName, parameter] of this.proto.parameters) {
parameter._view = this.#view;
this.exposedParameters.set(parameterName, parameter); // TODO: change key to parameter id ?
this.exposedParameters.set(parameterName, parameter);
}
});
}
Expand Down
3 changes: 1 addition & 2 deletions resources/web/wwi/nodes/WbDevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ export default class WbDevice extends WbSolid {
}

#applyOptionalRenderingToWren() {
// TODO adapt with the new structure Introduce in SFNODE
let currentNode = this;
let parentId = this.parent;
while (typeof parentId !== 'undefined') {
while (typeof parentId !== 'undefined' && parentId !== WbWorld.instance.root.id) {
let parent = WbWorld.instance.nodes.get(parentId);
if (typeof parent !== 'undefined') {
parentId = parent.parent;
Expand Down
16 changes: 3 additions & 13 deletions resources/web/wwi/protoVisualizer/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default class Node {
}
}

copy.def = new Map(this.def); // TODO: probably wrong, need to clone nodes?
copy.def = new Map(this.def);
copy.externProto = new Map(this.externProto);
return copy;
}
Expand Down Expand Up @@ -274,18 +274,9 @@ export default class Node {
return this.baseType.toX3d();

const nodeElement = this.xml.createElement(this.name);
if (isUse) {
// console.log('is USE! Will reference id: ' + this.id);
if (isUse)
nodeElement.setAttribute('USE', this.id);
// TODO: needed here as well or sufficient in vrml.js?
if (['Shape', 'Group', 'Transform', 'Solid', 'Robot'].includes(this.name)) {
if (parameterReference === 'boundingObject')
nodeElement.setAttribute('role', 'boundingObject');
} else if (['BallJointParameters', 'JointParameters', 'HingeJointParameters'].includes(this.name))
nodeElement.setAttribute('role', parameterReference); // identifies which jointParameter slot the node belongs to
else if (['Brake', 'PositionSensor', 'Motor'].includes(this.name))
nodeElement.setAttribute('role', parameterReference); // identifies which device slot the node belongs to
} else {
else {
nodeElement.setAttribute('id', this.id);
// console.log('ENCODE ' + this.name, ', id: ', this.id)
for (const [parameterName, parameter] of this.parameters) {
Expand Down Expand Up @@ -446,7 +437,6 @@ export default class Node {
}
};

// TODO: move to utility?
function combinePaths(url, parentUrl) {
if (url.startsWith('http://') || url.startsWith('https://'))
return url; // url is already resolved
Expand Down
1 change: 0 additions & 1 deletion resources/web/wwi/protoVisualizer/Parameter.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ export default class Parameter {
view.x3dScene.render();
}

// TODO: find better approach rather than propagating the view to subsequent parameters
setValueFromJavaScript(view, v, index) {
// notify linked parameters of the change
for (const link of this.parameterLinks)
Expand Down
4 changes: 1 addition & 3 deletions resources/web/wwi/protoVisualizer/Vrml.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ export class SFNode extends SingleValue {

// handle exceptions
if (this.value.name === 'ImageTexture')
nodeX3d.setAttribute('role', parameterName.slice(0, -3)); // TODO: rename on the JS side so it matches the field name?
nodeX3d.setAttribute('role', parameterName.slice(0, -3));
else if (['Shape', 'Group', 'Transform', 'Solid', 'Robot'].includes(this.value.name)) {
if (parameterName === 'boundingObject')
nodeX3d.setAttribute('role', 'boundingObject');
Expand Down Expand Up @@ -812,8 +812,6 @@ export class MFNode extends MultipleValue {
set value(v) {
if (!Array.isArray(v)) {
if (v instanceof Node) {
// TODO: can we avoid doing this here and ensure it's sent as SFNode already?
// TODO: still needed?
const sf = new SFNode();
sf.value = v;
this.insert(sf);
Expand Down

0 comments on commit a87767a

Please sign in to comment.