diff --git a/src/components/duck.js b/src/components/duck.js index 7045949bd8aadd4eb3cf38d33595c953da6b43a0..59172942074173c393c7d86e9fd9e121737ae128 100644 --- a/src/components/duck.js +++ b/src/components/duck.js @@ -1,3 +1,4 @@ +/* global CANNON */ AFRAME.registerComponent("duck", { schema: { initialForce: { default: 0 }, @@ -8,8 +9,8 @@ AFRAME.registerComponent("duck", { init: function() { this.physicsSystem = this.el.sceneEl.systems.physics; this.hasBody = false; - this.position = new THREE.Vector3(); - this.force = new THREE.Vector3(0, this.data.initialForce, 0); + this.position = new CANNON.Vec3(); + this.force = new CANNON.Vec3(0, this.data.initialForce, 0); this.initialScale = this.el.object3D.scale.x; this.maxScale = this.data.maxScale * this.initialScale; }, @@ -23,7 +24,7 @@ AFRAME.registerComponent("duck", { }, beforeStep: function() { - if (this.el.body) { + if (this.el.body && NAF.utils.isMine(this.el)) { const currentScale = this.el.object3D.scale.x; const ratio = Math.min(1, (currentScale - this.initialScale) / (this.maxScale - this.initialScale)); const force = ratio * this.data.maxForce;