MCPcopy Create free account
hub / github.com/DFin/palaeograph / constructor

Method constructor

src/sceneManager.js:9–104  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7
8export class SceneManager {
9 constructor() {
10 this.scene = new THREE.Scene();
11 this.scene.background = new THREE.Color(0x787878);
12
13 this.renderer = new THREE.WebGLRenderer({ antialias: true });
14 this.renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
15 document.body.appendChild(this.renderer.domElement);
16
17 this.frustumSize = SPREAD;
18 this.sceneCenter = new THREE.Vector3(0, 0, 0);
19 this.sceneRadius = SPREAD / 2;
20 this.pointBaseScale = 0.9;
21 this.pointScaleFactor = 1;
22 this.labelScaleFactor = 1;
23 this.lastBounds = null;
24 this.lastRawExtents = null;
25 this.lastFlipOptions = { flipEast: false, flipNorth: false, flipElevation: false };
26 this.cameraInitialized = false;
27
28 this.backgroundColor = new THREE.Color(0x787878);
29 this.scene.background = this.backgroundColor.clone();
30 this.gridSpacing = 1;
31 this.gridColor = new THREE.Color(0xb4ccff);
32 this.gridMajorColor = this.gridColor.clone().lerp(new THREE.Color(0xffffff), 0.35);
33 this.appliedGridStep = this.gridSpacing;
34
35 this.perspectiveCamera = new THREE.PerspectiveCamera(60, 1, 0.1, 200);
36 this.perspectiveCamera.position.set(25, 25, 35);
37 this.perspectiveCamera.lookAt(0, 0, 0);
38
39 this.orthographicCamera = this.createOrthographicCamera();
40
41 this.cameraMode = "perspective";
42 this.cameraView = "free";
43 this.activeCamera = this.perspectiveCamera;
44
45 this.controls = new OrbitControls(this.activeCamera, this.renderer.domElement);
46 this.controls.enableDamping = true;
47 this.controls.target.set(0, 0, 0);
48 this.controls.addEventListener("start", () => {
49 if (this.cameraView !== "free") {
50 this.setCameraView("free");
51 }
52 });
53
54 this.savedPerspectiveState = {
55 position: this.perspectiveCamera.position.clone(),
56 target: this.controls.target.clone()
57 };
58 this.savedOrthoState = {
59 position: this.orthographicCamera.position.clone(),
60 target: this.controls.target.clone()
61 };
62 this.shouldFrameNextUpdate = true;
63
64 this.scene.add(new THREE.AmbientLight(0xffffff, 0.6));
65
66 const keyLight = new THREE.DirectionalLight(0xffffff, 0.85);

Callers

nothing calls this directly

Calls 4

setCameraViewMethod · 0.95
handleResizeMethod · 0.95
applyViewMethod · 0.95

Tested by

no test coverage detected