Skip to content

Commit 525fc08

Browse files
authored
WebXR Input Sources: retrieve most relevant transforms of the parent (playcanvas#2395)
* retrieve most relevant transforms of the parent * fix
1 parent d96a75e commit 525fc08

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

src/xr/xr-input-source.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -188,18 +188,14 @@ XrInputSource.prototype.update = function (frame) {
188188
};
189189

190190
XrInputSource.prototype._updateTransforms = function () {
191-
var dirty;
192-
193191
if (this._dirtyLocal) {
194-
dirty = true;
195192
this._dirtyLocal = false;
196193
this._localTransform.setTRS(this._localPosition, this._localRotation, Vec3.ONE);
197194
}
198195

199196
var parent = this._manager.camera.parent;
200197
if (parent) {
201-
dirty = dirty || parent._dirtyLocal || parent._dirtyWorld;
202-
if (dirty) this._worldTransform.mul2(parent.getWorldTransform(), this._localTransform);
198+
this._worldTransform.mul2(parent.getWorldTransform(), this._localTransform);
203199
} else {
204200
this._worldTransform.copy(this._localTransform);
205201
}
@@ -211,18 +207,14 @@ XrInputSource.prototype._updateRayTransforms = function () {
211207

212208
var parent = this._manager.camera.parent;
213209
if (parent) {
214-
dirty = dirty || parent._dirtyLocal || parent._dirtyWorld;
215-
216-
if (dirty) {
217-
var parentTransform = this._manager.camera.parent.getWorldTransform();
210+
var parentTransform = this._manager.camera.parent.getWorldTransform();
218211

219-
parentTransform.getTranslation(this._position);
220-
this._rotation.setFromMat4(parentTransform);
212+
parentTransform.getTranslation(this._position);
213+
this._rotation.setFromMat4(parentTransform);
221214

222-
this._rotation.transformVector(this._rayLocal.origin, this._ray.origin);
223-
this._ray.origin.add(this._position);
224-
this._rotation.transformVector(this._rayLocal.direction, this._ray.direction);
225-
}
215+
this._rotation.transformVector(this._rayLocal.origin, this._ray.origin);
216+
this._ray.origin.add(this._position);
217+
this._rotation.transformVector(this._rayLocal.direction, this._ray.direction);
226218
} else if (dirty) {
227219
this._ray.origin.copy(this._rayLocal.origin);
228220
this._ray.direction.copy(this._rayLocal.direction);

src/xr/xr-joint.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ XrJoint.prototype.update = function (pose) {
7474
};
7575

7676
XrJoint.prototype._updateTransforms = function () {
77-
var dirty;
78-
7977
if (this._dirtyLocal) {
80-
dirty = true;
8178
this._dirtyLocal = false;
8279
this._localTransform.setTRS(this._localPosition, this._localRotation, Vec3.ONE);
8380
}
@@ -86,8 +83,7 @@ XrJoint.prototype._updateTransforms = function () {
8683
var parent = manager.camera.parent;
8784

8885
if (parent) {
89-
dirty = dirty || parent._dirtyLocal || parent._dirtyWorld;
90-
if (dirty) this._worldTransform.mul2(parent.getWorldTransform(), this._localTransform);
86+
this._worldTransform.mul2(parent.getWorldTransform(), this._localTransform);
9187
} else {
9288
this._worldTransform.copy(this._localTransform);
9389
}

0 commit comments

Comments
 (0)