feat: 3 scene rendering setup
This commit is contained in:
25
apps/viewer/src/viewerUniverseLayer.ts
Normal file
25
apps/viewer/src/viewerUniverseLayer.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import * as THREE from "three";
|
||||
|
||||
/**
|
||||
* Universe rendering layer — always the first layer rendered.
|
||||
* Contains the infinite backdrop: backdrop stars and nebula clouds.
|
||||
* Has no dedicated camera; rendered with whichever camera is active for the current POV
|
||||
* so the backdrop always aligns with the foreground view.
|
||||
*/
|
||||
export class UniverseLayer {
|
||||
readonly scene = new THREE.Scene();
|
||||
|
||||
/** Backdrop stars and nebula clouds. Follows the active camera to act as a skybox. */
|
||||
readonly ambienceGroup = new THREE.Group();
|
||||
|
||||
constructor() {
|
||||
this.scene.background = new THREE.Color(0x040912);
|
||||
this.scene.add(this.ambienceGroup);
|
||||
}
|
||||
|
||||
updateAmbience(activeCamera: THREE.Camera, delta: number) {
|
||||
this.ambienceGroup.position.copy(activeCamera.position);
|
||||
this.ambienceGroup.rotation.y += delta * 0.005;
|
||||
this.ambienceGroup.rotation.x = Math.sin(performance.now() * 0.00003) * 0.015;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user