named teleporter example

teleport
Fabien Benetou 7 months ago
parent 92793dbebf
commit 820457a255
  1. 4
      index.html

@ -240,6 +240,8 @@ function onHoveredTeleport(){
AFRAME.registerComponent('teleporter', { AFRAME.registerComponent('teleporter', {
init: function(){ init: function(){
this.el.setAttribute("opacity", .5) this.el.setAttribute("opacity", .5)
if (window.location.hash && document.querySelector(window.location.hash+"[teleporter]"))
document.getElementById('rig').setAttribute('position', document.querySelector(window.location.hash+"[teleporter]").getAttribute("position") )
}, },
events: { events: {
mouseenter: function (e) { this.el.setAttribute("opacity", .8) }, mouseenter: function (e) { this.el.setAttribute("opacity", .8) },
@ -348,6 +350,8 @@ setTimeout( _ => {
</a-box> </a-box>
<a-box teleporter height=".1" class="teleportable" material="color: cyan" position="0 0 0" ></a-box> <a-box teleporter height=".1" class="teleportable" material="color: cyan" position="0 0 0" ></a-box>
<a-box id="namedteleporter" teleporter height=".1" class="teleportable" material="color: cyan" position="2 0 2" ></a-box>
<a-box target teleporter height=".1" depth=".1" width=".1" class="teleportable" material="color: red" position="0 1 -.5" ></a-box> <a-box target teleporter height=".1" depth=".1" width=".1" class="teleportable" material="color: red" position="0 1 -.5" ></a-box>
</a-scene> </a-scene>
</body> </body>

Loading…
Cancel
Save