Closed NickPax closed 6 years ago
Suggested text after "Add an event handler to run when the scene fires the loaded event.":
We need the help of JavaScript again. Near the bottom of the file you should see this code within a couple of <script> </script> tags:
on($('a-scene'),'loaded',()=>{ })
Add these lines between the curly braces:
const pos = ball.getComputedAttribute('position') //start the ball moving ball.body.applyImpulse( new CANNON.Vec3(0, 0, -50), new CANNON.Vec3().copy(pos) )
That script code should now look something like this:
<script> const $ = (sel) => document.querySelector(sel) const on = (el,type,cb) => el.addEventListener(type,cb) on($('a-scene'),'loaded',()=>{ const pos = ball.getComputedAttribute('position') //start the ball moving ball.body.applyImpulse( new CANNON.Vec3(0, 0, -50), new CANNON.Vec3().copy(pos) ) }) </script>
Note: Josh, I'm loving this! Learning about physics and A-Frame here. I appreciate your style. Glitch is great for this! Thank you
good point. updated.
Suggested text after "Add an event handler to run when the scene fires the loaded event.":
We need the help of JavaScript again. Near the bottom of the file you should see this code within a couple of <script> </script> tags:
Add these lines between the curly braces:
That script code should now look something like this:
Note: Josh, I'm loving this! Learning about physics and A-Frame here. I appreciate your style. Glitch is great for this! Thank you