@pixi/3d
    Preparing search index...

    Class Plane

    An infinite flat plane: the points p where normal ยท p + constant = 0

    The ground y = 0 is new Plane(new Vector3(0, 1, 0), 0), and the upward-facing plane y = 2 has a constant of -2. Keep normal unit length, or distances come out scaled; Plane#normalize fixes one that isn't.

    const water = new Plane(new Vector3(0, 1, 0), -waterLevel);

    app.ticker.add(() => {
    underwaterFilter.enabled = water.distanceToPoint(camera.position) < 0;
    });

    Ray#intersectPlane For the point where a ray hits the plane

    Index
    • Creates a new Plane

      Left out, the plane is x = 0 facing +X. A normal passed in becomes the plane's own; it is not copied.

      Parameters

      • Optionalnormal: Vector3

        The unit-length normal of the plane

      • constant: number = 0

        The origin's signed distance from the plane

      Returns Plane

    constant: number = 0

    The origin's signed distance from the plane, negative when the origin is behind it

    water.constant = -waterLevel;
    
    normal: Vector3

    The unit-length direction the plane faces; its positive side

    const facingUp = slope.normal.y > 0.7;
    
    type: SHAPE_PRIMITIVE_3D = 'plane'

    Names the shape without an instanceof check, like the type on pixi's 2D shapes

    'plane'
    
    • Transforms this plane by an affine matrix, so points on it stay on it

      Non-uniform scale is fine, and the normal comes out unit length. A mirroring matrix swaps which side of the plane is positive. Needs a unit-length normal, and matrix must be affine (bottom row [0, 0, 0, 1]), as a Container3D#worldTransform always is.

      Parameters

      • matrix: Matrix4

        The affine matrix to transform by

      • out: Plane = ...

        Target to write the result into instead of mutating this plane

      Returns this

      The result plane for chaining

      const worldMirror = new Plane();

      localMirror.applyMatrix4(mirror.worldTransform, worldMirror);
    • Creates a new Plane with the same normal and constant

      Returns Plane

      The new plane

      const worldPlane = localPlane.clone().applyMatrix4(portal.worldTransform);
      
    • Copies plane into this plane

      Parameters

      • plane: Plane

        The plane to copy from

      Returns this

      This plane for chaining

      reflectionPlane.copyFrom(water);
      
    • Copies this plane into target and returns it

      Type Parameters

      Parameters

      • target: T

        The plane to copy into

      Returns T

      The given target

      water.copyTo(reflectionPlane);
      
    • Returns the signed distance from point to this plane (positive on the side of normal)

      Parameters

      Returns number

      The signed distance to the plane

      const depth = -water.distanceToPoint(diver.position);
      
    • Returns true when normal and constant match plane exactly (no epsilon tolerance)

      Parameters

      • plane: Plane

        The plane to compare with

      Returns boolean

      Whether the normal and constant match

      if (!clipPlane.equals(lastClipPlane)) rebuildClipping(clipPlane);
      
    • Returns true when this plane passes through box or touches it; same as Box#intersectsPlane

      Parameters

      • box: Box

        The box to test

      Returns boolean

      Whether the plane passes through or touches the box

      const halfSubmerged = water.intersectsBox(boatBounds);
      
    • Returns true when ray hits this plane; same as Ray#intersectsPlane

      Parameters

      • ray: Ray

        The ray to test

      Returns boolean

      Whether the ray intersects this plane

      cursor.visible = ground.intersectsRay(pointerRay);
      
    • Returns true when this plane passes through sphere or touches it; never for an empty sphere

      Parameters

      • sphere: Sphere

        The sphere to test

      Returns boolean

      Whether the plane passes through or touches the sphere

      const splashing = water.intersectsSphere(ball.boundingSphere);
      
    • Scales the plane so normal has unit length

      The constant scales with it, so the plane stays in place. A zero-length normal gives NaN.

      Parameters

      • out: Plane = ...

        Target to write the result into instead of mutating this plane

      Returns this

      The result plane for chaining

      const slope = new Plane(new Vector3(0, 2, 1), 0).normalize();
      
    • Writes the closest point on this plane to point into out (or a new Vector3)

      Parameters

      • point: PointData3D

        The point to project

      • Optionalout: Vector3

        Optional vector to write into; a new Vector3 when omitted

      Returns Vector3

      The projected point

      const footprint = new Vector3();

      ground.projectPoint(ball.position, footprint);
      blobShadow.position.copyFrom(footprint);
    • Sets the normal and constant of this plane, copying the normal

      Parameters

      • normal: PointData3D

        The unit-length normal

      • constant: number

        The origin's signed distance from the plane

      Returns this

      This plane for chaining

      ceiling.set({ x: 0, y: -1, z: 0 }, roomHeight);
      
    • Sets the normal to (x, y, z) and the constant to w, the four numbers of a plane equation

      Equations from elsewhere, such as rows of a projection matrix, rarely have a unit-length normal, so call Plane#normalize after.

      Parameters

      • x: number

        The x component of the normal

      • y: number

        The y component of the normal

      • z: number

        The z component of the normal

      • w: number

        The plane constant

      Returns this

      This plane for chaining

      clipPlane.setComponents(equation[0], equation[1], equation[2], equation[3]).normalize();
      
    • Sets this plane from a unit-length normal and a coplanar point

      Parameters

      Returns this

      This plane for chaining

      mirrorPlane.setFromNormalAndCoplanarPoint({ x: 0, y: 0, z: 1 }, mirror.position);
      
    • Advanced

      Returns a string representation of this plane

      Returns string

      A string in the form [@pixi/3d/math:Plane normal=(1, 0, 0) constant=0]