MCPcopy Create free account
hub / github.com/RodrigoHamuy/react-three-map / syncCamera

Function syncCamera

src/core/sync-camera.ts:14–37  ·  view source on GitHub ↗
(camera: PerspectiveCamera, origin: Matrix4Tuple, mapCamMx: Matrix4Tuple)

Source from the content-addressed store, hash-verified

12
13
14export function syncCamera(camera: PerspectiveCamera, origin: Matrix4Tuple, mapCamMx: Matrix4Tuple) {
15
16 projByView
17 .fromArray(mapCamMx)
18 .multiply(originMx.fromArray(origin));
19 projByViewInv
20 .copy(projByView)
21 .invert();
22
23 updateCamera(camera, projByViewInv);
24 camera.updateMatrix();
25 camera.updateMatrixWorld(true);
26
27 camera.projectionMatrix.copy(camera.matrix).premultiply(projByView);
28 camera.projectionMatrixInverse.copy(camera.projectionMatrix).invert();
29
30 camera.far = calculateFar(
31 camera.matrix.elements[10], camera.matrix.elements[14], camera.near
32 )
33
34 camera.userData.projByView = projByView.toArray();
35 camera.userData.projByViewInv = projByViewInv.toArray();
36
37}
38
39const updateCamera = (target: Object3D, projByViewInv: Matrix4) => {
40

Callers 3

sync-camera-fc.tsxFile · 0.90
useRenderFunction · 0.90
RenderAtCoordsFunction · 0.90

Calls 2

updateCameraFunction · 0.85
calculateFarFunction · 0.85

Tested by

no test coverage detected