diff --git a/assets/img/stepback.png b/assets/img/stepback.png new file mode 100644 index 0000000..2d4394a Binary files /dev/null and b/assets/img/stepback.png differ diff --git a/src/components/stepback.js b/src/components/stepback.js new file mode 100644 index 0000000..82cf1b6 --- /dev/null +++ b/src/components/stepback.js @@ -0,0 +1,31 @@ +AFRAME.registerComponent('stepback', { + init: function () { + this.message = document.getElementById('stepback'); + this.camera = document.getElementById('camera'); + this.lastTime = 0; + this.limit = - (this.el.getAttribute('geometry').height / 2 - 0.6); + this.throttling = 300; + }, + + tick: function (time, delta) { + if (time - this.lastTime < this.throttling) { return; } + + var camPos = this.camera.object3D.position; + var msgPos = this.message.object3D.position; + + if (camPos.z < this.limit) { + this.throttling = 20; + this.message.object3D.visible = true; + this.message.getObject3D('mesh').material.opacity = 1 - Math.abs(camPos.z - msgPos.z); + msgPos.x = camPos.x; + msgPos.y = camPos.y; + } + else { + this.message.object3D.visible = false; + this.throttling = 300; + } + + this.lastTime = time; + } + +}); diff --git a/src/index.html b/src/index.html index 87fd7e6..ffb022f 100644 --- a/src/index.html +++ b/src/index.html @@ -28,7 +28,7 @@ effect-bloom="strength: 1" gpu-preloader loading-screen="backgroundColor: #000;" - overlay="objects: #menu, #keyboard, #rightHand, #leftHand, [mixin~='cursorMesh'], #inGameMenu" + overlay="objects: #menu, #keyboard, #rightHand, #leftHand, [mixin~='cursorMesh'], #inGameMenu, #stepback" pool__beat-arrow-blue="mixin: arrowBlueBeat; size: 5; container: #beatContainer" pool__beat-arrow-red="mixin: arrowRedBeat; size: 10; container: #beatContainer" pool__beat-dot-blue="mixin: dotBlueBeat; size: 10; container: #beatContainer" @@ -79,6 +79,7 @@ + @@ -231,12 +232,15 @@ {{ saber('right', 'left', '#78AAFF', 'cyan') }} + + {% if not IS_PRODUCTION %} {% endif %} + diff --git a/src/templates/stage.html b/src/templates/stage.html index b60716d..6207564 100644 --- a/src/templates/stage.html +++ b/src/templates/stage.html @@ -152,5 +152,6 @@ id="floor" mixin="neonAnimation" geometry="primitive: plane; width: 3; height: 3" material="color: #AAF; shader: flat; src: #floorImg" - rotation="-90 0 0"> + rotation="-90 0 0" + stepback>