feat: 3 scene rendering setup
This commit is contained in:
37
apps/viewer/src/viewerGalaxyLayer.ts
Normal file
37
apps/viewer/src/viewerGalaxyLayer.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import * as THREE from "three";
|
||||
import type { Selectable } from "./viewerTypes";
|
||||
|
||||
/**
|
||||
* Galaxy rendering layer — the galaxy map.
|
||||
* Scene coordinate unit: display-unit (light-year scale).
|
||||
* Only visible in galaxy POV, rendered on top of the universe backdrop.
|
||||
* Contains star dots and shell reticles for each system.
|
||||
*/
|
||||
export class GalaxyLayer {
|
||||
readonly scene = new THREE.Scene();
|
||||
readonly camera = new THREE.PerspectiveCamera(50, 1, 0.1, 600000);
|
||||
|
||||
/** Star dots and shell reticles, one per system. */
|
||||
readonly systemGroup = new THREE.Group();
|
||||
|
||||
readonly selectableTargets = new Map<THREE.Object3D, Selectable>();
|
||||
|
||||
constructor() {
|
||||
this.scene.fog = new THREE.FogExp2(0x040912, 0.000035);
|
||||
this.scene.add(new THREE.AmbientLight(0x90a6c0, 0.55));
|
||||
const keyLight = new THREE.DirectionalLight(0xdcecff, 1.3);
|
||||
keyLight.position.set(1000, 1200, 800);
|
||||
this.scene.add(keyLight);
|
||||
this.scene.add(this.systemGroup);
|
||||
}
|
||||
|
||||
updateCamera(focus: THREE.Vector3, orbitOffset: THREE.Vector3) {
|
||||
this.camera.position.copy(focus).add(orbitOffset);
|
||||
this.camera.lookAt(focus);
|
||||
}
|
||||
|
||||
onResize(aspect: number) {
|
||||
this.camera.aspect = aspect;
|
||||
this.camera.updateProjectionMatrix();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user