Fixes for desktop/cardboard use
This commit is contained in:
parent
a36f696389
commit
0e6ae0b958
|
@ -73,7 +73,7 @@ export async function startEngine(
|
|||
const { scene, floorMeshes } = await createScene(canvas, engine);
|
||||
|
||||
const xr = await scene.createDefaultXRExperienceAsync({});
|
||||
const xrAvailable = xr.baseExperience !== void 0;
|
||||
const xrAvailable = xr?.baseExperience !== void 0;
|
||||
|
||||
let camera: FreeCamera;
|
||||
if (xrAvailable) {
|
||||
|
@ -120,6 +120,7 @@ export async function startEngine(
|
|||
|
||||
for (const gp of Array.from(navigator.getGamepads())) {
|
||||
if (gp !== null) {
|
||||
if (sm) {
|
||||
const pos = new Vector3((gp.axes[0]), (-gp.axes[1]), (-gp.axes[3]));
|
||||
if (pos.length() > 0.0625) {
|
||||
if (leanBase === null) {
|
||||
|
@ -135,6 +136,7 @@ export async function startEngine(
|
|||
}
|
||||
leanBase = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (sm && latch(gp, 0)) {
|
||||
const ray = xr.baseExperience.camera.getForwardRay();
|
||||
|
@ -158,12 +160,18 @@ export async function startEngine(
|
|||
if (sm && latch(gp, 3)) {
|
||||
enableVR();
|
||||
}
|
||||
if (sm && latch(gp, 5)) {
|
||||
const q = xr.baseExperience.camera.rotationQuaternion;
|
||||
const r = q.toEulerAngles();
|
||||
if (latch(gp, 5)) {
|
||||
const r = sm
|
||||
? xr.baseExperience.camera.rotationQuaternion.toEulerAngles()
|
||||
: camera.rotation;
|
||||
r.y += Math.PI;
|
||||
r.y %= 2 * Math.PI;
|
||||
q.copyFrom(Quaternion.FromEulerAngles(r.x, r.y, r.z));
|
||||
if (sm) {
|
||||
xr.baseExperience.camera.rotationQuaternion.copyFrom(r.toQuaternion());
|
||||
}
|
||||
}
|
||||
if (sm && latch(gp, 4)) {
|
||||
xr.baseExperience.camera.rotationQuaternion.copyFrom(initialRotation.toQuaternion());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue