fix dashboard position in XR mode
This commit is contained in:
+13
-3
@@ -116,10 +116,18 @@ class DashBoard extends EventManager {
|
|||||||
pointsText.position.set(0.86 * dashWidth/2, 0.47 * dashHeight, -0.001);
|
pointsText.position.set(0.86 * dashWidth/2, 0.47 * dashHeight, -0.001);
|
||||||
dash.add(pointsText);
|
dash.add(pointsText);
|
||||||
|
|
||||||
|
engine.renderer.xr.addEventListener('sessionstart', this.orient)
|
||||||
|
|
||||||
this.orient = function(){
|
this.orient = function(){
|
||||||
dash.quaternion.copy(engine.camera.quaternion)
|
let object = engine.camera, dk = 1;
|
||||||
dash.position.copy(engine.camera.position)
|
if (engine.renderer.xr.isPresenting){
|
||||||
dash.translateZ(-dashDistance -(dashHeight/2)/Math.tan(engine.camera.fov/2 * Math.PI/180) * engine.camera.zoom);
|
dk = 17;
|
||||||
|
}
|
||||||
|
// dash.quaternion.copy(object.quaternion)
|
||||||
|
dash.rotation.y = object.rotation.y;
|
||||||
|
dash.position.copy(object.position)
|
||||||
|
//dash.position.set(0,0,0);
|
||||||
|
dash.translateZ(-dashDistance * dk -(dashHeight/2)/Math.tan(engine.camera.fov/2 * Math.PI/180) * engine.camera.zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.orient();
|
this.orient();
|
||||||
@@ -142,6 +150,7 @@ class DashBoard extends EventManager {
|
|||||||
this.updateText = async function(t, params = {}){
|
this.updateText = async function(t, params = {}){
|
||||||
if (!textPlane) return;
|
if (!textPlane) return;
|
||||||
await Utils.killWait(this.#textTimeout);
|
await Utils.killWait(this.#textTimeout);
|
||||||
|
if (!!t) this.orient();
|
||||||
textPlane.visible = !!t;
|
textPlane.visible = !!t;
|
||||||
engine.motionQueue.clear(text);
|
engine.motionQueue.clear(text);
|
||||||
text.text = t;
|
text.text = t;
|
||||||
@@ -231,6 +240,7 @@ class DashBoard extends EventManager {
|
|||||||
|
|
||||||
//dashPlacement, rotate = false, plane = false
|
//dashPlacement, rotate = false, plane = false
|
||||||
this.attach = (object, opts = {})=>{
|
this.attach = (object, opts = {})=>{
|
||||||
|
this.orient();
|
||||||
this.cameraFix = engine.hero.cameraZ;
|
this.cameraFix = engine.hero.cameraZ;
|
||||||
engine.hero.cameraZ = 6;
|
engine.hero.cameraZ = 6;
|
||||||
hud.visible = true;
|
hud.visible = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user