diff --git a/index.html b/index.html index 1527232..e389797 100644 --- a/index.html +++ b/index.html @@ -3053,6 +3053,26 @@ AFRAME.registerComponent('gate-through', { } }); +function shoot(){ + s = document.createElement("a-sphere"); + s.setAttribute("radius", .01); + AFRAME.scenes[0].appendChild(s); + v = new THREE.Vector3(); + p = new THREE.Vector3(); + t = new THREE.Vector3(); + cam = AFRAME.scenes[0].object3D.getObjectByProperty("type", "PerspectiveCamera"); + cam.getWorldDirection(v); + cam.getWorldPosition(p); + r = new THREE.Ray( p, v ); + d=0; + shot = setInterval( _ => { + d+=.1; + r.at(d, t); + s.setAttribute("position", AFRAME.utils.coordinates.stringify( t )); + if (d>100) clearInterval(shot) + }, 10) +} + // used for testing AFRAME.registerComponent('startfunctions', { init: function () {