Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Commit

Permalink
Replace setAttribute call in velocity.js (#121)
Browse files Browse the repository at this point in the history
* don't use get/setAttribute; read/set object3D.posiiton directly

* merge better

* whitespace
  • Loading branch information
InfiniteLee authored and donmccurdy committed Dec 13, 2018
1 parent fd54a21 commit cbe574c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/components/math/velocity.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ module.exports = AFRAME.registerComponent('velocity', {

var physics = this.el.sceneEl.systems.physics || {data: {maxInterval: 1 / 60}},

// TODO - There's definitely a bug with getComputedAttribute and el.data.
velocity = this.el.getAttribute('velocity') || {x: 0, y: 0, z: 0},
position = this.el.getAttribute('position') || {x: 0, y: 0, z: 0};
// TODO - There's definitely a bug with getComputedAttribute and el.data.
velocity = this.el.getAttribute('velocity') || {x: 0, y: 0, z: 0},
position = this.el.object3D.position || {x: 0, y: 0, z: 0};

dt = Math.min(dt, physics.data.maxInterval * 1000);

this.el.setAttribute('position', {
x: position.x + velocity.x * dt / 1000,
y: position.y + velocity.y * dt / 1000,
z: position.z + velocity.z * dt / 1000
});
this.el.object3D.position.set(
position.x + velocity.x * dt / 1000,
position.y + velocity.y * dt / 1000,
position.z + velocity.z * dt / 1000
);
}
});

0 comments on commit cbe574c

Please sign in to comment.