Add rendering groups, camera far plane, and planet physics
- Set renderingGroupId=2 for game objects (ship, asteroids, base, sun, planets) - Set camera maxZ=100000 for FreeCamera and XR camera (distant planets) - Add static sphere physics bodies to planets 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
21a6d7c9ec
commit
29db6ec4b7
@ -68,6 +68,10 @@ async function createXRExperience(): Promise<void> {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
log.debug('Pointer selection enabled with renderingGroupId:', XR_RENDERING_GROUP);
|
log.debug('Pointer selection enabled with renderingGroupId:', XR_RENDERING_GROUP);
|
||||||
|
|
||||||
|
// Set far clipping plane for distant planets
|
||||||
|
DefaultScene.XR.baseExperience.camera.maxZ = 100000;
|
||||||
|
|
||||||
createFadeSphere();
|
createFadeSphere();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -150,6 +150,7 @@ export class RockFactory {
|
|||||||
this._asteroidMesh.material.freeze();
|
this._asteroidMesh.material.freeze();
|
||||||
if (this._asteroidMesh) {
|
if (this._asteroidMesh) {
|
||||||
this._asteroidMesh.setEnabled(false);
|
this._asteroidMesh.setEnabled(false);
|
||||||
|
this._asteroidMesh.renderingGroupId = 2;
|
||||||
}
|
}
|
||||||
log.debug(this._asteroidMesh);
|
log.debug(this._asteroidMesh);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,6 +55,11 @@ export default class StarBase {
|
|||||||
|
|
||||||
this._loadedBase = { baseMesh, landingMesh, container: importMeshes.container };
|
this._loadedBase = { baseMesh, landingMesh, container: importMeshes.container };
|
||||||
|
|
||||||
|
// Set rendering group for all base meshes
|
||||||
|
for (const mesh of importMeshes.meshes.values()) {
|
||||||
|
if (mesh) mesh.renderingGroupId = 2;
|
||||||
|
}
|
||||||
|
|
||||||
log.debug(`[StarBase] Added to scene (hidden: ${hidden})`);
|
log.debug(`[StarBase] Added to scene (hidden: ${hidden})`);
|
||||||
return { baseMesh, landingMesh, container: importMeshes.container };
|
return { baseMesh, landingMesh, container: importMeshes.container };
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,8 @@ import {
|
|||||||
Observable,
|
Observable,
|
||||||
PBRMaterial,
|
PBRMaterial,
|
||||||
PhysicsAggregate,
|
PhysicsAggregate,
|
||||||
|
PhysicsMotionType,
|
||||||
|
PhysicsShapeType,
|
||||||
Texture,
|
Texture,
|
||||||
Vector3,
|
Vector3,
|
||||||
} from "@babylonjs/core";
|
} from "@babylonjs/core";
|
||||||
@ -51,6 +53,9 @@ export class LevelDeserializer {
|
|||||||
// Store score observable for deferred physics
|
// Store score observable for deferred physics
|
||||||
private _scoreObservable: Observable<ScoreEvent> | null = null;
|
private _scoreObservable: Observable<ScoreEvent> | null = null;
|
||||||
|
|
||||||
|
// Store planets for deferred physics
|
||||||
|
private _planets: { mesh: AbstractMesh; diameter: number }[] = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deserialize meshes only (Phase 2 - before XR, hidden)
|
* Deserialize meshes only (Phase 2 - before XR, hidden)
|
||||||
*/
|
*/
|
||||||
@ -96,6 +101,18 @@ export class LevelDeserializer {
|
|||||||
// Initialize asteroid physics
|
// Initialize asteroid physics
|
||||||
RockFactory.initPhysics();
|
RockFactory.initPhysics();
|
||||||
|
|
||||||
|
// Initialize planet physics (static spheres)
|
||||||
|
for (const { mesh, diameter } of this._planets) {
|
||||||
|
const agg = new PhysicsAggregate(
|
||||||
|
mesh,
|
||||||
|
PhysicsShapeType.SPHERE,
|
||||||
|
{ radius: diameter / 2, mass: 0 },
|
||||||
|
this.scene
|
||||||
|
);
|
||||||
|
agg.body.setMotionType(PhysicsMotionType.STATIC);
|
||||||
|
}
|
||||||
|
log.debug(`[LevelDeserializer] Created physics for ${this._planets.length} planets`);
|
||||||
|
|
||||||
return landingAggregate;
|
return landingAggregate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,6 +154,7 @@ export class LevelDeserializer {
|
|||||||
//material.emissiveColor.set(0.5, 0.5, 0.1);
|
//material.emissiveColor.set(0.5, 0.5, 0.1);
|
||||||
material.unlit = true;
|
material.unlit = true;
|
||||||
sun.material = material;
|
sun.material = material;
|
||||||
|
sun.renderingGroupId = 2;
|
||||||
|
|
||||||
return sun;
|
return sun;
|
||||||
}
|
}
|
||||||
@ -185,8 +203,10 @@ export class LevelDeserializer {
|
|||||||
material.metallic = 0;
|
material.metallic = 0;
|
||||||
material.unlit = true;
|
material.unlit = true;
|
||||||
planet.material = material;
|
planet.material = material;
|
||||||
|
planet.renderingGroupId = 2;
|
||||||
|
|
||||||
planets.push(planet);
|
planets.push(planet);
|
||||||
|
this._planets.push({ mesh: planet, diameter: planetConfig.diameter });
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug(`Created ${planets.length} planets from config`);
|
log.debug(`Created ${planets.length} planets from config`);
|
||||||
|
|||||||
@ -173,6 +173,11 @@ export class Ship {
|
|||||||
this._loadedAssetData = await loadAsset("ship.glb", "default", { hidden });
|
this._loadedAssetData = await loadAsset("ship.glb", "default", { hidden });
|
||||||
this._ship = this._loadedAssetData.container.transformNodes[0];
|
this._ship = this._loadedAssetData.container.transformNodes[0];
|
||||||
|
|
||||||
|
// Set rendering group for all ship meshes
|
||||||
|
for (const mesh of this._loadedAssetData.meshes.values()) {
|
||||||
|
if (mesh) mesh.renderingGroupId = 2;
|
||||||
|
}
|
||||||
|
|
||||||
if (initialPosition) {
|
if (initialPosition) {
|
||||||
this._ship.position.copyFrom(initialPosition);
|
this._ship.position.copyFrom(initialPosition);
|
||||||
}
|
}
|
||||||
@ -198,6 +203,7 @@ export class Ship {
|
|||||||
this._camera = new FreeCamera("Flat Camera", new Vector3(0, 1.5, 0), DefaultScene.MainScene);
|
this._camera = new FreeCamera("Flat Camera", new Vector3(0, 1.5, 0), DefaultScene.MainScene);
|
||||||
this._camera.parent = this._ship;
|
this._camera.parent = this._ship;
|
||||||
this._camera.rotation = new Vector3(0, Math.PI, 0);
|
this._camera.rotation = new Vector3(0, Math.PI, 0);
|
||||||
|
this._camera.maxZ = 100000; // Far clipping plane for distant planets
|
||||||
|
|
||||||
if (!DefaultScene.XR && !this._isReplayMode) {
|
if (!DefaultScene.XR && !this._isReplayMode) {
|
||||||
DefaultScene.MainScene.activeCamera = this._camera;
|
DefaultScene.MainScene.activeCamera = this._camera;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user