Skip to content

Commit c76944a

Browse files
committed
Trackedcontrols 'position' support
1 parent 95fa677 commit c76944a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

‎src/components/tracked-controls.js‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ module.exports.Component = registerComponent('tracked-controls', {
4343
var controllerEuler = new THREE.Euler();
4444
var controllerPosition = new THREE.Vector3();
4545
var controllerQuaternion = new THREE.Quaternion();
46+
var deltaControllerPosition = new THREE.Vector3();
4647
var dolly = new THREE.Object3D();
4748
var standingMatrix = new THREE.Matrix4();
49+
var previousControllerPosition = new THREE.Vector3();
4850
controllerEuler.order = 'YXZ';
4951
return function () {
5052
var controller;
@@ -74,10 +76,15 @@ module.exports.Component = registerComponent('tracked-controls', {
7476
y: THREE.Math.radToDeg(controllerEuler.y),
7577
z: THREE.Math.radToDeg(controllerEuler.z)
7678
});
79+
80+
deltaControllerPosition.copy(controllerPosition).sub(previousControllerPosition);
81+
previousControllerPosition.copy(controllerPosition);
82+
var currentPosition = el.getAttribute('position');
83+
7784
el.setAttribute('position', {
78-
x: controllerPosition.x,
79-
y: controllerPosition.y,
80-
z: controllerPosition.z
85+
x: currentPosition.x + deltaControllerPosition.x,
86+
y: currentPosition.x + deltaControllerPosition.y,
87+
z: currentPosition.x + deltaControllerPosition.z
8188
});
8289
};
8390
})(),

0 commit comments

Comments
 (0)