Hide canvas until XR camera positioned in ship cockpit
All checks were successful
Build / build (push) Successful in 1m0s

- Hide #gameCanvas by default in CSS (display: none)
- Show canvas in setupXRCamera() after camera is parented to ship
- Show canvas in flat mode fallback paths
- Fix preloader to append to document.body (was hidden with #levelSelect)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Michael Mainguy 2025-11-29 05:42:53 -06:00
parent 54d562d210
commit dfa46c85a6
4 changed files with 19 additions and 4 deletions

View File

@ -107,6 +107,7 @@ body {
margin: 0;
padding: 0;
background: transparent;
display: none; /* Hidden until camera is positioned in ship */
}
/* ============================================================================

View File

@ -92,6 +92,11 @@ export function createLevelSelectedHandler(context: LevelSelectedContext): (e: C
} catch (error) {
log.debug('Failed to enter XR, will fall back to flat mode:', error);
DefaultScene.XR = null;
// Show canvas for flat mode
const canvas = document.getElementById('gameCanvas');
if (canvas) {
canvas.style.display = 'block';
}
engine.runRenderLoop(() => {
DefaultScene.MainScene.render();
});
@ -154,6 +159,11 @@ export function createLevelSelectedHandler(context: LevelSelectedContext): (e: C
log.debug('[Main] XR setup and mission brief complete');
} else {
log.info('[Main] XR not active yet - will use onInitialXRPoseSetObservable instead');
// Show canvas for non-XR mode
const canvas = document.getElementById('gameCanvas');
if (canvas) {
canvas.style.display = 'block';
}
engine.runRenderLoop(() => {
DefaultScene.MainScene.render();
});

View File

@ -106,6 +106,12 @@ export class Level1 implements Level {
xr.baseExperience.camera.position = new Vector3(0, 1.2, 0);
log.debug('[Level1] XR camera parented to cameraRig at position (0, 1.2, 0)');
// Show the canvas now that camera is properly positioned in ship
const canvas = document.getElementById('gameCanvas');
if (canvas) {
canvas.style.display = 'block';
}
// Ensure render loop is running
const engine = DefaultScene.MainScene.getEngine();
engine.runRenderLoop(() => {

View File

@ -14,9 +14,6 @@ export class Preloader {
}
private createUI(): void {
const levelSelect = document.getElementById('levelSelect');
if (!levelSelect) return;
// Create preloader container
this.container = document.createElement('div');
this.container.className = 'preloader';
@ -45,7 +42,8 @@ export class Preloader {
</div>
`;
levelSelect.appendChild(this.container);
// Append to body so it's visible even when other UI elements are hidden
document.body.appendChild(this.container);
// Get references
this.progressBar = document.getElementById('preloaderProgress');