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

Fix web proto issues related to vehicles #5811

Merged
merged 95 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
aa83e9e
Progress
ad-daniel Jan 13, 2023
6fb68f9
Progress
ad-daniel Jan 17, 2023
beaeb97
Progress
ad-daniel Jan 18, 2023
20c8651
Minimal functionality
ad-daniel Jan 18, 2023
5e028e8
Fix encoder
ad-daniel Jan 18, 2023
229df57
Fix simple updates
ad-daniel Jan 18, 2023
f6f98f7
Fix SFNode insertion
ad-daniel Jan 18, 2023
913f710
Fix sfnode reset
ad-daniel Jan 18, 2023
9c157dd
Restore regeneration
ad-daniel Jan 18, 2023
94f9963
Functional derived PROTO
ad-daniel Jan 18, 2023
b0fd31f
Restore restrictions
ad-daniel Jan 18, 2023
7f05090
Potential basetype structure
ad-daniel Jan 18, 2023
6d9a137
Fix IS poses
ad-daniel Jan 18, 2023
efdc5ed
Revert "Potential basetype structure"
ad-daniel Jan 19, 2023
d7402a1
Fix grass
ad-daniel Jan 19, 2023
5b70867
Derived tests
ad-daniel Jan 19, 2023
bbd0111
Rework parameter links
ad-daniel Jan 19, 2023
f57650d
Progress
ad-daniel Jan 20, 2023
4ac0827
Reintroduce baseType instance
ad-daniel Jan 20, 2023
65063d4
Fix regeneration
ad-daniel Jan 20, 2023
5e56b2b
Rework how derived nodes are stored and fix issues with change propag…
ad-daniel Jan 20, 2023
fd68680
Implement DEF-USE
ad-daniel Jan 20, 2023
8234ccb
Fix SFRotation
ad-daniel Jan 20, 2023
36bd027
Fix some issues with MFNode
ad-daniel Jan 20, 2023
2a262ab
Fix issues with SFNode
ad-daniel Jan 20, 2023
c8a7f62
Fix more issues
ad-daniel Jan 20, 2023
1687ddb
Progress in delinking instances
ad-daniel Jan 20, 2023
2977e4a
Progress in delinking instances
ad-daniel Jan 20, 2023
42ecd6f
Merge branch 'rework-node' of github.com:cyberbotics/webots into rewo…
ad-daniel Jan 20, 2023
445188f
Fix id flagging
ad-daniel Jan 25, 2023
05e65a0
Rework webotsjs notification of node changes
ad-daniel Jan 25, 2023
6411d6a
Rework regeneration
ad-daniel Jan 25, 2023
dae2c76
Rework MFNode insertion/removal
ad-daniel Jan 25, 2023
cba9d8b
Fix MF insertion & finalization issues
ad-daniel Jan 25, 2023
8557288
Rework Parameter class
ad-daniel Jan 25, 2023
65327f3
Cleanup
ad-daniel Jan 25, 2023
d4da129
Fix MF removing too many nodes
ad-daniel Jan 25, 2023
8908662
Fix unfinalization of sfnodes
ad-daniel Jan 25, 2023
6d29b41
Cleanup
ad-daniel Jan 25, 2023
74c90e2
Progress on default initializer
ad-daniel Jan 25, 2023
2d761ad
functional proof of concept for default complex fields
ad-daniel Jan 26, 2023
3006a71
Debug asyncronicity
ad-daniel Jan 26, 2023
5bf5309
Fix node generation in PROTO with special fields
ad-daniel Jan 26, 2023
4ecf9b3
Fix sfnode reset
ad-daniel Jan 26, 2023
b188407
replace default value with tokenizer in all proto models
ad-daniel Jan 26, 2023
3a18df8
Status
ad-daniel Jan 26, 2023
fb0c2fb
Fix grass
ad-daniel Jan 26, 2023
8f2945f
Debug templating issue
ad-daniel Jan 26, 2023
26b0e4d
Fix templating
ad-daniel Jan 26, 2023
18ae4ac
Fix tokenizer consumption
ad-daniel Jan 26, 2023
565a7f9
Debug
ad-daniel Jan 27, 2023
8cad8f6
Fix derived node parameters not propagating
ad-daniel Jan 27, 2023
7ab8bec
Cleanup Node
ad-daniel Jan 27, 2023
2fc4695
Cleanup vrml
ad-daniel Jan 27, 2023
6718aa0
Cleanup Parameters
ad-daniel Jan 27, 2023
60a87fc
Cleanup ProtoManager
ad-daniel Jan 27, 2023
58b8af8
Merge branch 'feature-web-proto' into rework-node
ad-daniel Jan 27, 2023
3a3c485
Remove isUse
ad-daniel Jan 27, 2023
7ae415b
Fix mfnode reset
ad-daniel Jan 27, 2023
7d7a17a
Cleanup
ad-daniel Jan 27, 2023
291e6e7
Fix MFNode restrictions
ad-daniel Jan 27, 2023
98b561a
Rename parameter linksg
ad-daniel Jan 27, 2023
60aecad
improve rewind
ad-daniel Jan 27, 2023
cf7969c
Merge methods
ad-daniel Jan 27, 2023
c3f0fdb
Cleanup
ad-daniel Jan 27, 2023
3c117f9
Cleanup
ad-daniel Jan 27, 2023
ffc27c4
Fix slot issues
ad-daniel Jan 27, 2023
2cffdc4
Finalize
ad-daniel Jan 27, 2023
b81b13a
Fix MFFields
ad-daniel Jan 30, 2023
9bc14ad
Fix basenode
ad-daniel Jan 30, 2023
3b11df9
Improve
ad-daniel Jan 30, 2023
2fb7a45
Minor
ad-daniel Jan 30, 2023
b6ab747
Fix moose
ad-daniel Jan 30, 2023
78e27ea
Fix slots
ad-daniel Jan 30, 2023
b090eed
Debug
ad-daniel Jan 30, 2023
d4ba759
Fix Tesla
ad-daniel Jan 30, 2023
1712d7c
Progress proto rework
ad-daniel Jan 30, 2023
dc48363
improve wheel proto
ad-daniel Jan 31, 2023
58084f0
Cleanup
ad-daniel Jan 31, 2023
43a9c96
Fix texture url update
ad-daniel Jan 31, 2023
91d23ac
Fix texture update
ad-daniel Jan 31, 2023
a3f8fd5
Merge branch 'feature-web-proto' into fix-web-proto-issues
ad-daniel Jan 31, 2023
fe66aae
Fix Tesla PROTO
ad-daniel Feb 1, 2023
e060dfa
Merge branch 'fix-web-proto-issues' of github.com:cyberbotics/webots …
ad-daniel Feb 1, 2023
125de8c
Fix
ad-daniel Feb 1, 2023
f9969f6
Fix tesla lights
ad-daniel Feb 1, 2023
31b6442
Cleanup
ad-daniel Feb 1, 2023
b0a36e1
Finalize
ad-daniel Feb 1, 2023
77913a6
Fix
ad-daniel Feb 1, 2023
7278c99
Fix
ad-daniel Feb 1, 2023
c8cb58d
Fix disappering joints
ad-daniel Feb 2, 2023
a4b8f50
Fix joints tab on tesla
ad-daniel Feb 2, 2023
7e87904
actually commit BO fix
ad-daniel Feb 2, 2023
fba174e
Fix exporter
ad-daniel Feb 2, 2023
f6d2c15
Fix Nao hand slot
ad-daniel Feb 2, 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
358 changes: 186 additions & 172 deletions projects/vehicles/protos/abstract/VehicleWheel.proto

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions projects/vehicles/protos/tesla/TeslaModel3.proto
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,18 @@ PROTO TeslaModel3 [
attenuation 0 0 1
beamWidth 0.3
cutOffAngle 0.6
direction -0.05 -1 -0.5
direction -1 -0.5 -0.05
intensity 60
location -0.72 -2.03 0.72
location -2.03 0.72 -0.72
radius 40
}
SpotLight {
attenuation 0 0 1
beamWidth 0.3
cutOffAngle 0.6
direction 0.05 -1 -0.5
direction -1 -0.5 0.05
intensity 60
location 0.72 -2.03 0.72
location -2.03 0.72 0.72
radius 40
}
%< } >%
Expand Down
2 changes: 1 addition & 1 deletion resources/web/wwi/FloatingProtoParameterWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,7 @@ export default class FloatingProtoParameterWindow extends FloatingWindow {
let div = document.createElement('div');
div.className = 'proto-joint';

const endPointName = joint.endPoint ? joint.endPoint.name : numberOfJoint;
const endPointName = joint.solidEndPoint() ? joint.solidEndPoint().name : numberOfJoint;
let jointType;
if (joint instanceof WbBallJoint)
jointType = 'BallJoint 1: ';
Expand Down
11 changes: 9 additions & 2 deletions resources/web/wwi/NodeSelectorWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,15 @@ export default class NodeSelectorWindow {
throw new Error('The parameter has no IS.');

let baseType = [];
const fieldName = this.parameter.aliasLinks[0].name;
const parentNode = this.parameter.aliasLinks[0].node;
// get the field name linked to the parameter (full-depth)
let p = this.parameter;
while (p instanceof Parameter && p.aliasLinks.length > 0)
p = p.aliasLinks[0];
const fieldName = p.name;
const parentNode = p.node;

const ff = this.parameter.aliasLinks;
console.log(fieldName, parentNode.name, ff)
if (fieldName === 'appearance')
baseType = ['Appearance', 'PBRAppearance'];
else if (fieldName === 'geometry') {
Expand Down
3 changes: 1 addition & 2 deletions resources/web/wwi/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1086,11 +1086,10 @@ export default class Parser {
const radius = parseFloat(getNodeAttribute(node, 'radius', '100'));
const ambientIntensity = parseFloat(getNodeAttribute(node, 'ambientIntensity', '0'));
const castShadows = getNodeAttribute(node, 'castShadows', 'false').toLowerCase() === 'true';

const spotLight = new WbSpotLight(id, on, attenuation, beamWidth, color, cutOffAngle, direction, intensity, location,
radius, ambientIntensity, castShadows, parentNode);

if (typeof parentNode !== 'undefined' && typeof spotLight !== 'undefined')
if (typeof parentNode !== 'undefined')
parentNode.children.push(spotLight);

WbWorld.instance.nodes.set(spotLight.id, spotLight);
Expand Down
2 changes: 2 additions & 0 deletions resources/web/wwi/ProtoManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export default class ProtoManager {

function listExternProto(node, list) {
for (const parameter of node.parameters.values()) {
if (parameter.isDefault())
continue;
const currentValue = parameter.value;
if (currentValue instanceof SFNode && currentValue.value !== null) {
if (currentValue.value.isProto && !list.includes(currentValue.value.url)) {
Expand Down
12 changes: 10 additions & 2 deletions resources/web/wwi/X3dScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,16 @@ export default class X3dScene {
if (object instanceof WbMesh)
object.materialIndex = parseInt(update[key]);
} else if (key === 'url') {
if (object instanceof WbMesh || object instanceof WbCadShape)
object.url = update[key][0];
if (object instanceof WbMesh || object instanceof WbCadShape || object instanceof WbImageTexture) {
let urlString = update[key];
if (urlString === '[]') {
object.url = undefined;
return;
}
if (urlString.startsWith('[') && urlString.endsWith(']'))
urlString = urlString.substring(1, urlString.length - 1);
object.url = urlString.split('"').filter(element => { if (element !== ' ') return element; })[0];
}
} else if (key === 'point') {
if (object instanceof WbCoordinate)
object.point = convertStringToVec3Array(update[key]);
Expand Down
14 changes: 8 additions & 6 deletions resources/web/wwi/nodes/WbBallJoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,12 @@ export default class WbBallJoint extends WbHinge2Joint {
}

_updateEndPointZeroTranslationAndRotation() {
if (typeof this.endPoint === 'undefined')
if (typeof this.solidEndPoint() === 'undefined')
return;

const ir = this.endPoint.rotation;
const it = this.endPoint.translation;
const solid = this.solidEndPoint();
const ir = solid.rotation;
const it = solid.translation;

let qp = new WbQuaternion();
if (isZeroAngle(this.position) && isZeroAngle(this.position2) && isZeroAngle(this.#position3))
Expand Down Expand Up @@ -152,9 +153,10 @@ export default class WbBallJoint extends WbHinge2Joint {
this.#position3 = position3;
let rotation = new WbVector4();
const translation = this.#computeEndPointSolidPositionFromParameters(rotation);
if (!translation.almostEquals(this.endPoint.translation) || !rotation.almostEquals(this.endPoint.rotation)) {
this.endPoint.translation = translation;
this.endPoint.rotation = rotation;
const solid = this.solidEndPoint();
if (!translation.almostEquals(solid.translation) || !rotation.almostEquals(solid.rotation)) {
solid.translation = translation;
solid.rotation = rotation;
}
}

Expand Down
14 changes: 8 additions & 6 deletions resources/web/wwi/nodes/WbHinge2Joint.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ export default class WbHinge2Joint extends WbHingeJoint {
}

_updateEndPointZeroTranslationAndRotation() {
if (typeof this.endPoint === 'undefined')
if (typeof this.solidEndPoint() === 'undefined')
return;

const ir = this.endPoint.rotation;
const it = this.endPoint.translation;
const solid = this.solidEndPoint();
const ir = solid.rotation;
const it = solid.translation;

let qp = new WbQuaternion();
if (isZeroAngle(this.position) && isZeroAngle(this.#position2))
Expand Down Expand Up @@ -119,9 +120,10 @@ export default class WbHinge2Joint extends WbHingeJoint {

let rotation = new WbVector4();
const translation = this.#computeEndPointSolidPositionFromParameters(rotation);
if (!translation.almostEquals(this.endPoint.translation) || !rotation.almostEquals(this.endPoint.rotation)) {
this.endPoint.translation = translation;
this.endPoint.rotation = rotation;
const solid = this.solidEndPoint();
if (!translation.almostEquals(solid.translation) || !rotation.almostEquals(solid.rotation)) {
solid.translation = translation;
solid.rotation = rotation;
}
}

Expand Down
36 changes: 12 additions & 24 deletions resources/web/wwi/nodes/WbHingeJoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {isZeroAngle} from './utils/math_utilities.js';

export default class WbHingeJoint extends WbJoint {
#device;
#position;
constructor(id) {
super(id);
this.#device = [];
Expand All @@ -20,19 +19,6 @@ export default class WbHingeJoint extends WbJoint {
this.#device = device;
}

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

set position(newPosition) {
if (this.#position === newPosition)
return;

this.#position = newPosition;
if (typeof this.jointParameters === 'undefined')
this._updatePosition();
}

preFinalize() {
super.preFinalize();
this.#device.forEach(child => child.preFinalize());
Expand All @@ -56,24 +42,25 @@ export default class WbHingeJoint extends WbJoint {

_updatePosition() {
if (typeof this.endPoint !== 'undefined')
this.#updatePosition(typeof this.jointParameters !== 'undefined' ? this.jointParameters.position : this.#position);
this.#updatePosition(typeof this.jointParameters !== 'undefined' ? this.jointParameters.position : this.position);
}

#updatePosition(position) {
// called after an artificial move
this.#position = position;
this.position = position;
let rotation = new WbVector4();
const translation = this.#computeEndPointSolidPositionFromParameters(rotation);
if (!translation.almostEquals(this.endPoint.translation) || !rotation.almostEquals(this.endPoint.rotation)) {
this.endPoint.translation = translation;
this.endPoint.rotation = rotation;
const solid = this.solidEndPoint();
if (!translation.almostEquals(solid.translation) || !rotation.almostEquals(solid.rotation)) {
solid.translation = translation;
solid.rotation = rotation;
}
}

#computeEndPointSolidPositionFromParameters(rotation) {
const axis = this.axis().normalized();
const q = new WbQuaternion();
q.fromAxisAngle(axis.x, axis.y, axis.z, this.#position);
q.fromAxisAngle(axis.x, axis.y, axis.z, this.position);
const iq = this._endPointZeroRotation.toQuaternion();
const qp = q.mul(iq);
if (qp.w !== 1)
Expand All @@ -87,14 +74,15 @@ export default class WbHingeJoint extends WbJoint {
}

_updateEndPointZeroTranslationAndRotation() {
if (typeof this.endPoint === 'undefined')
if (typeof this.solidEndPoint() === 'undefined')
return;

const ir = this.endPoint.rotation;
const it = this.endPoint.translation;
const solid = this.solidEndPoint();
const ir = solid.rotation;
const it = solid.translation;

let qMinus;
const angle = this.#position;
const angle = this.position;
if (isZeroAngle(angle)) {
// In case of a zero angle, the quaternion axis is undefined, so we keep track of the original one
this._endPointZeroRotation = ir;
Expand Down
7 changes: 6 additions & 1 deletion resources/web/wwi/nodes/WbImageTexture.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default class WbImageTexture extends WbBaseNode {
this.#updateWrenTexture();
}

// Private fonctions
// Private functions

#destroyWrenTexture() {
_wr_texture_delete(this.wrenTexture);
Expand Down Expand Up @@ -194,6 +194,11 @@ export default class WbImageTexture extends WbBaseNode {
}

#updateUrl() {
if (typeof this.#url === 'undefined') {
this.#destroyWrenTexture();
return;
}

ImageLoader.loadImageTextureInWren(this, WbWorld.instance.prefix, this.#url)
.then(() => {
this.#updateWrenTexture();
Expand Down
37 changes: 33 additions & 4 deletions resources/web/wwi/nodes/WbJoint.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import WbBaseNode from './WbBaseNode.js';
import WbSlot from './WbSlot.js';
import WbSolid from './WbSolid.js';
import WbWorld from './WbWorld.js';

export default class WbJoint extends WbBaseNode {
#endPoint;
#jointParameters;
#position;

get endPoint() {
return this.#endPoint;
Expand All @@ -24,8 +27,22 @@ export default class WbJoint extends WbBaseNode {
this.#jointParameters.onChange = () => this._updatePosition();
}

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

set position(newPosition) {
if (this.#position === newPosition)
return;

this.#position = newPosition;
if (typeof this.jointParameters !== 'undefined')
this._updatePosition();
}

boundingSphere() {
return this.#endPoint?.boundingSphere();
const solid = this.solidEndPoint();
return solid?.boundingSphere();
}

createWrenObjects() {
Expand Down Expand Up @@ -53,11 +70,12 @@ export default class WbJoint extends WbBaseNode {

preFinalize() {
super.preFinalize();
this.#jointParameters?.preFinalize();
this.#endPoint?.preFinalize();

this.position = typeof this.jointParameters === 'undefined' ? 0 : this.jointParameters.position;
this.#position = typeof this.jointParameters === 'undefined' ? 0 : this.jointParameters.position;
this._updateEndPointZeroTranslationAndRotation();

this.#jointParameters?.preFinalize();
this.#endPoint?.preFinalize();
}

postFinalize() {
Expand All @@ -67,6 +85,17 @@ export default class WbJoint extends WbBaseNode {
this.#endPoint?.postFinalize();
}

solidEndPoint() {
if (typeof this.endPoint === 'undefined')
return;

if (this.endPoint instanceof WbSlot) {
const childrenSlot = this.endPoint.slotEndPoint();
return childrenSlot?.solidEndPoint();
} else if (this.endPoint instanceof WbSolid)
return this.endPoint;
}

updateBoundingObjectVisibility() {
this.#endPoint?.updateBoundingObjectVisibility();
}
Expand Down
10 changes: 6 additions & 4 deletions resources/web/wwi/nodes/WbSliderJoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ export default class WbSliderJoint extends WbJoint {
}

_updateEndPointZeroTranslationAndRotation() {
if (typeof this.endPoint === 'undefined')
if (typeof this.solidEndPoint() === 'undefined')
return;

this.#endPointZeroTranslation = this.endPoint.translation.sub(this.#axis().mul(this.position));
const solid = this.solidEndPoint();
this.#endPointZeroTranslation = solid.translation.sub(this.#axis().mul(this.position));
}

#axis() {
Expand All @@ -58,8 +59,9 @@ export default class WbSliderJoint extends WbJoint {
// called after an artificial move
this.position = position;
const translation = this.#computeEndPointSolidPositionFromParameters();
if (!translation.almostEquals(this.endPoint.translation))
this.endPoint.translation = translation;
const solid = this.solidEndPoint();
if (!translation.almostEquals(solid.translation))
solid.translation = translation;
}

#computeEndPointSolidPositionFromParameters() {
Expand Down
11 changes: 11 additions & 0 deletions resources/web/wwi/nodes/WbSlot.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import WbBaseNode from './WbBaseNode.js';
import WbSolid from './WbSolid.js';
import WbWorld from './WbWorld.js';
import {getAnId} from './utils/id_provider.js';

Expand Down Expand Up @@ -59,6 +60,16 @@ export default class WbSlot extends WbBaseNode {
this.endPoint?.postFinalize();
}

solidEndPoint() {
if (typeof this.endPoint !== 'undefined' && this.endPoint instanceof WbSolid)
return this.endPoint;
}

slotEndPoint() {
if (typeof this.endPoint !== 'undefined' && this.endPoint instanceof WbSlot)
return this.endPoint;
}

updateBoundingObjectVisibility() {
this.endPoint?.updateBoundingObjectVisibility();
}
Expand Down
12 changes: 12 additions & 0 deletions resources/web/wwi/nodes/WbTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export default class WbTransform extends WbGroup {
#upperTransformFirstTimeSearch;
#vrmlMatrix;
#vrmlMatrixNeedUpdate;
#boundingObjectFirstTimeSearch;
#isInBoundingObject;
constructor(id, translation, scale, rotation) {
super(id);
this.#translation = translation;
Expand Down Expand Up @@ -142,6 +144,16 @@ export default class WbTransform extends WbGroup {
return this.#vrmlMatrix;
}

isInBoundingObject() {
if (this.#boundingObjectFirstTimeSearch) {
this.#isInBoundingObject = nodeIsInBoundingObject(this);
if (this.wrenObjectsCreatedCalled)
this.#boundingObjectFirstTimeSearch = false;
}

return this.#isInBoundingObject;
}

#applyRotationToWren() {
const rotation = _wrjs_array4(this.#rotation.w, this.#rotation.x, this.#rotation.y, this.#rotation.z);
_wr_transform_set_orientation(this.wrenNode, rotation);
Expand Down
Loading