# All files / src/WebGL/core Projector.ts

11.11% Statements 1/9
100% Branches 0/0
0% Functions 0/4
11.11% Lines 1/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39

    18x

     import type { Vector3 } from '../math';
    import type { Camera } from '../Camera';
    import { Matrix4 } from '../math';

    const viewProjectionMatrix = new Matrix4();

    //$3Dmol Projection
    export class Projector {
      static unprojectVector(vector: Vector3, camera: Camera) {

        camera.projectionMatrixInverse.getInverse(camera.projectionMatrix);

        viewProjectionMatrix.multiplyMatrices(camera.matrixWorld, camera.projectionMatrixInverse);

        return vector.applyProjection(viewProjectionMatrix);

      };

      static projectVector(vector: Vector3, camera: Camera) {

        camera.matrixWorldInverse.getInverse(camera.matrixWorld);

        viewProjectionMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);

        return vector.applyProjection(viewProjectionMatrix);
      };

      projectVector(vector: Vector3, camera: Camera) {

        return Projector.projectVector(vector, camera);

      }

      unprojectVector(vector: Vector3, camera: Camera) {

        return Projector.unprojectVector(vector, camera);

      }
    }