Interface CutPlaneManagerInterface

The CutPlaneManagerInterface interface is used to create cut planes, that are used to hide half of the scene.

The CutPlaneManagerInterface is included in the InfiniteEngineInterface and accessed through getCutPlaneManager.

There are no javascript cut plane objects, cut planes are modified through the CutPlaneManagerInterface by their ids. Indeed, each cut plane is assigned an integer id upon its creation, 0 is an invalid id, and is the expected result if the cut plan creation fails. Ids are recycled upon cut planes deletion, so there may be cases when a new cut plane is assigned an id that belonged to a deleted cut plane.

There is a limited number of cut planes that may be created by an application (shader limitations) : only 16 different cut planes may be created / manipulated.

A cut plane is defined by a position P that belong to the plane and a normal N : (Nx,Ny,Nz). This defines a plane (hyperplane) in 3D dimension. Such a plane has the equation : {x,y,z} / Nx.x + Ny.y + Nz.z = dot(N,P). Each vertex on the side of the normal N will be discarded, so every vertex V : {Vx,Vy,Vz} / Nx.Vx + Ny.Vy + Nz.Vz > dot(N,P) will be discarded.

A CutPlaneManipulatorInterface may be created and bound to a cut plane to display a GUI element that allows the end user to change the cut plane orientation / position through createCutPlaneManipulator.

When a cut plane is modified or disabled/enabled, CutPlaneManagerInterfaceSignal signals are sent.

Suppose that we want to hide all items whose "altitude" (z) is superior to 10.

/** 
* Sample to illustrate the creation of a cut plane, manipulated with a CutPlaneManipulatorInterface.
*/
import { InfiniteEngineInterface, CutPlaneManagerInterface, Vector3, CutPlaneManipulatorInterface } from 'generated/documentation/appinfiniteapi';

// lEngine has been created previously
let lEngine : InfiniteEngineInterface;

// we want to hide items that are above (and not under), thus the normal is in the positive side.
const lNormal : Vector3 = new Vector3(0, 0, 1);
// any point with z = 10 is ok
const lPoint : Vector3 = new Vector3(Math.random(), Math.random(), 10);
// get the cut plane manager
const lCutPlaneManager : CutPlaneManagerInterface = lEngine.getCutPlaneManager();
const lCutPlaneId = lCutPlaneManager.createCutPlane(lPoint, lNormal);
console.assert(lCutPlaneId !== 0);
// do what you want, the cut plane is working as it is enabled upon creation
// and create a cut plane manipulator to allow the end user to change the cut plane geometry.
const lCutPlaneManipulator : CutPlaneManipulatorInterface = lCutPlaneManager.createCutPlaneManipulator();
// bind the manipulator to the newly created cut plane
lCutPlaneManipulator.setCutPlaneId(lCutPlaneId);
// hide it for the moment, we may need it later
lCutPlaneManipulator.setVisible(false);

Please refer to the [CutPlaneManipulatorInterface](CutPlaneManipulatorInterface.html) for more information.
3D Rendering

See

Hierarchy

Methods

  • Adds a listener to an event type.

    When an event of the type pType fires, the callback pListener will be called. This function returns a unique string id that may be used in removeEventListenerById to allow simple listener removal. It is possible to add an object that will be included in the callback to avoid creating too many closures.

    Returns

    The id of the inserted callback (actually an UUID).

    Parameters

    • pType: string
      in
      The type of the event pListener will be called upon.
    • pListener: tListenerCallback
      in
      The listener function that fires when the given event type occurs.
    • pObject: undefined | Object
      in
      The optional object the callback will be called with when the given event fires.

    Returns string

  • Adds a listener to an event type.

    When an event of the type pType fires, the callback pListener will be called. This function returns a unique string id that may be used in removeEventListenerById to allow simple listener removal.

    Returns

    The id of the inserted callback (actually an UUID).

    Parameters

    • pType: string
      in
      The type of the event pListener will be called upon.
    • pListener: tListenerCallback
      in
      The listener function that fires when the given event type occurs.

    Returns string

  • Creates a new plane given a point position and a normal vector.

    The normal does not need to be unit length, but a zero vector is invalid. Each vertex on the side of the normal pNormal will be discarded.

    Returns the id (non zero) of the newly created cut plane, or 0 if the maximum number of cut planes have already been reached or if pNormal is equal to (0,0,0).

    The newly created cut plane is enabled by default.

    Returns

    The id of the created plane. If the maximum number of available cut planes slots has been reached or if pNormal is equal to (0,0,0), returns 0.

    Parameters

    • pPoint: Vector3
      in
      The 3D position of a point that belongs to the plane.
    • pNormal: Vector3
      in
      The 3D normal vector of the plane.

    Returns number

  • Gets the cut plane equation of the given plane.

    Be N : (Nx,Ny, Nz) the normal of the cut plane, Be P a point of the plane, we get the equation : {x,y,z} / Nx.x + Ny.y + Nz.z = dot(N,P). pCutPlaneEquation will be set such as
    pCutPlaneEquation.x = Nx
    pCutPlaneEquation.y = Ny
    pCutPlaneEquation.z = Nz
    pCutPlaneEquation.w = dot(N,P).

    Returns false if the cut plane was not found.

    Returns

    true if pCutPlaneId refers to a valid cut plane.

    Parameters

    • pCutPlaneId: number
      in
      The id of the plane to query.
    • pCutPlaneEquation: Vector4
      out
      The cut plane equation used to determine the plane.

    Returns boolean

  • Gets the normal used to determine the given plane normal. The cut plane normal is unit length.

    Returns false if the plane was not found.

    Returns

    true if pCutPlaneId refers to a valid cut plane.

    Parameters

    • pCutPlaneId: number
      in
      The id of the plane to query.
    • pCutPlaneNormal: Vector3
      out
      The cut plane normal used to determine the plane.

    Returns boolean

  • Gets the point used to determine the given plane position.

    Returns false if the cut plane was not found.

    Returns

    true if pCutPlaneId refers to a valid cut plane.

    Parameters

    • pCutPlaneId: number
      in
      The id of the plane to query.
    • pCutPlanePoint: Vector3
      out
      The cut plane point used to determine the plane.

    Returns boolean

  • Gets the actual cut plane ids that have been created.

    Returns

    const
    The ids of the cut planes in use.

    Returns number[]

  • Gets the actual number of cut planes.

    Returns

    The number of created cut planes.

    Returns number

  • Gets the maximum number of cut planes that can be created.

    This number is constant, it returns 16 at the moment.

    Returns

    The maximum number of planes that can be created.

    Returns number

  • Tells if the EventDispatcher has such a callback registered for the given event type.

    Returns

    true if such a listener is installed for the given type of event.

    Parameters

    • pType: string
      in
      The type of the event to test.
    • pListener: tListenerCallback
      in
      The listener function that gets tested.

    Returns boolean

  • Tells if the given cut plane is enabled.

    Returns false if the cut plane was not found or if the cut plane is disabled.

    Returns

    true if the given cut plane exists and is enabled.

    Parameters

    • pCutPlaneId: number
      in
      The id of the plane to query.

    Returns boolean

  • Removes all previously created cut planes.

    Returns void

  • Removes the cut plane with id pCutPlaneId.

    Returns

    true if the cut plane exists and therefore has been removed.

    Parameters

    • pCutPlaneId: number
      in
      The id of the cut plane to remove.

    Returns boolean

  • Removes a listener from an event type.

    If no such listener is found, then the function returns false and does nothing. You must use the exact parameters that were used in addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pType: string
      in
      The type of the listener that gets removed.
    • pListener: tListenerCallback

      The listener function that gets removed.

    • pObject: undefined | Object

      The listener object that was used when addEventListener was called.

    Returns boolean

  • Removes a listener from an event type.

    If no such listener is found, then the function returns false and does nothing. You must use the exact parameters that were used in addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pType: string
      in
      The type of the listener that gets removed.
    • pListener: tListenerCallback

      The listener function that gets removed.

    Returns boolean

  • Removes a listener by its id.

    If no such listener is found, then the function returns false and does nothing. You must use the return value of addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pId: string
      in
      The id returned by the call to [addEventListener](CutPlaneManagerInterface.html#addEventListener) that you want to remove.

    Returns boolean

  • Sets the enabled status of the cut plane.

    A disabled cut plane does not cut anything.

    Returns false if the cut plane was not found.

    Returns

    true if pCutPlaneId refers to a valid cut plane.

    Parameters

    • pCutPlaneId: number
      in
      The id of the plane to query.
    • pEnabled: boolean
      in
      The enabled status of the cutPlane.

    Returns boolean

  • Updates the shape of the plane pCutPlaneId, changes the point position and the normal vector of the given plane.

    Returns false if the plane was not found or if pNormal is (0,0,0).

    Returns

    true if the plane was found, pNormal is not (0,0,0) and therefore the plane orientation/position is updated.

    Parameters

    • pCutPlaneId: number
      in
      The id of the plane to modify.
    • pPoint: Vector3
      in
      The new 3D position of a point of the plane.
    • pNormal: Vector3
      in
      The new 3D normal vector of the plane.

    Returns boolean