Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * creates a new reflection matrix about this plane.
- */
- export function createReflectionMatrix(plane: THREE.Plane) : THREE.Matrix4 {
- var n = plane.normalize()
- var m = new THREE.Matrix4()
- return m.set(
- -1.0 - 2.0 * n.normal.x * n.normal.x, // negated?
- -2.0 * n.normal.x * n.normal.y,
- -2.0 * n.normal.x * n.normal.z,
- 0.0,
- -2.0 * n.normal.x * n.normal.y,
- 1.0 - 2.0 * n.normal.y * n.normal.y,
- -2.0 * n.normal.y * n.normal.z,
- 0.0,
- -2.0 * n.normal.z * n.normal.x,
- -2.0 * n.normal.z * n.normal.y,
- 1.0 - 2.0 * n.normal.z * n.normal.z,
- 0.0,
- -2.0 * n.constant * n.normal.x,
- -2.0 * n.constant * n.normal.y,
- -2.0 * n.constant * n.normal.z,
- 1.0);
- }
- /**
- * mirrors this camera about a plane.
- * @param camera {THREE.Camera} the camera to mirror
- * @param plane {THREE.Plane} the plane to mirror against.
- * @returns {THREE.Camera} a new camera mirrored against this plane.
- */
- export function reflect(camera: THREE.PerspectiveCamera, plane: THREE.Plane) : THREE.Camera {
- var reflect = camera.clone()
- plane = new THREE.Plane(new THREE.Vector3(0, 1, 0), 0)
- reflect.matrixAutoUpdate = false;
- reflect.matrix.identity()
- reflect.matrix.multiply(acid.graphics.math.createReflectionMatrix(plane))
- reflect.matrix.multiply(camera.matrix)
- reflect.updateProjectionMatrix();
- reflect.updateMatrixWorld(true);
- return reflect;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement