diff --git a/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/Map.js b/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/Map.js index 5e49ca7..1b62f3f 100644 --- a/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/Map.js +++ b/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/Map.js @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* Map.js :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: hubourge +#+ +:+ +#+ */ +/* By: edbernar +#+ +:+ +#+ */ +/* By: edbernar { - this.object.position.x = lerp(this.object.position.x, content.pos, speedFactor); - if (Math.abs(this.object.position.x - content.pos) < 0.01) - this.object.position.x = content.pos; - else - thisClass.animationFrame = requestAnimationFrame(animate); - }; + if (isInVrMode) + { + if (thisClass.animationFrame) + clearInterval(thisClass.animationFrame); + const animate = () => { + this.object.position.x = lerp(this.object.position.x, content.pos, speedFactor); + if (Math.abs(this.object.position.x - content.pos) < 0.01) + { + this.object.position.x = content.pos; + clearInterval(thisClass.animationFrame); + thisClass.animationFrame = null; + } + }; + + thisClass.animationFrame = setInterval(animate, 5); + } + else + { + if (thisClass.animationFrame) + cancelAnimationFrame(thisClass.animationFrame); + const animate = () => { + this.object.position.x = lerp(this.object.position.x, content.pos, speedFactor); + if (Math.abs(this.object.position.x - content.pos) < 0.01) + this.object.position.x = content.pos; + else + thisClass.animationFrame = requestAnimationFrame(animate); + }; + + thisClass.animationFrame = requestAnimationFrame(animate); + } + - thisClass.animationFrame = requestAnimationFrame(animate); if (content.up && thisClass.object.position.y < thisClass.limits.up) { diff --git a/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/Player.js b/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/Player.js index 91a2cb8..7c26228 100644 --- a/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/Player.js +++ b/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/Player.js @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* Player.js :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: hubourge +#+ +:+ +#+ */ +/* By: edbernar { VrButton.click(); - scene.add(cameraGroup); - scene.remove(player.camera); player.configureVrController(); - cameraGroup.add(player.camera); - cameraGroup.position.set(0, 0.5, 7.5); + let interval2 = setInterval(() => { + const xrSession = renderer.xr.getSession(); + if (!xrSession) + return ; + clearInterval(interval2); + interval2 = null; + xrSession.requestReferenceSpace('local').then((refSpace) => { + xrReferenceSpace = refSpace; + }); + }, 16); + if (isOnPointAnim) + { + interval = setInterval(() => { + if (isOnPointAnim) + return ; + scene.add(cameraGroup); + scene.remove(player.camera); + cameraGroup.add(player.camera); + cameraGroup.position.set(0, 0.5, 7.5); + clearInterval(interval); + }, 10); + } + else + { + scene.add(cameraGroup); + scene.remove(player.camera); + cameraGroup.add(player.camera); + cameraGroup.position.set(0, 0.5, 7.5); + } isInVrMode = true; }); return (newButton);