(camera: PerspectiveCamera, origin: Matrix4Tuple, mapCamMx: Matrix4Tuple)
| 12 | |
| 13 | |
| 14 | export 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 | |
| 39 | const updateCamera = (target: Object3D, projByViewInv: Matrix4) => { |
| 40 |
no test coverage detected