Skip to content

Commit

Permalink
Merge pull request #488 from Jlu18/makePushable
Browse files Browse the repository at this point in the history
Fixed makePushable not able to push the entity
  • Loading branch information
kdvalin authored May 12, 2021
2 parents ac6f035 + f72f3fd commit 00e92b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/structural/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class View extends Component {
if (ent.tube) {
return <a-tube path={ent.path} radius={ent.radius} material={ent.material} shadow={shadow} shadowcustomsetting></a-tube>;
}
return <a-entity key={ent.id} {...flattened} shadow={shadow} shadowcustomsetting ></a-entity>;
return <a-entity class="raycastable" key={ent.id} {...flattened} shadow={shadow} shadowcustomsetting ></a-entity>;
}
}
//return elements that contains necessary configuration for light indicator based on light's type and properties
Expand Down
10 changes: 6 additions & 4 deletions src/utils/AFramePhysics.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ const THREE = AFRAME.THREE;

AFRAME.registerComponent("force-pushable", {
schema: {
force: { default: 10 }
force: {
type: "number",
default: 10
}
},
init: function () {
this.pStart = new THREE.Vector3();
Expand All @@ -13,12 +16,11 @@ AFRAME.registerComponent("force-pushable", {
forcePush: function () {
let force,
el = this.el,
pStart = this.pStart.copy(this.sourceEl.getAttribute("position"));

pStart = this.pStart.copy(this.sourceEl.children[0].getAttribute("position"));
// Compute direction of force, normalize, then scale.
force = el.body.position.vsub(pStart);
force.normalize();
force.scale(this.data.force, force);
force.scale(this.nextData.force, force);

el.body.applyImpulse(force, el.body.position);
}
Expand Down

0 comments on commit 00e92b8

Please sign in to comment.