Variable MeshHelperConst

MeshHelper: Readonly<{
    createAxis: ((desc?: AxisDescriptor) => IMeshEntity);
    createCube: ((desc?: CubeDescriptor) => IMeshEntity);
    createCubes: ((numberToCreate: number, desc?: CubeDescriptor) => IMeshEntity[]);
    createGrid: ((desc?: GridDescriptor) => IMeshEntity);
    createJoint: ((desc?: IAnyPrimitiveDescriptor) => IMeshEntity);
    createLine: ((desc?: LineDescriptor) => IMeshEntity);
    createPlane: ((desc?: PlaneDescriptor & {
        direction?: "xz" | "xy" | "yz";
    }) => IMeshEntity);
    createShape: ((primitive: IShape) => IMeshEntity);
    createSphere: ((desc?: SphereDescriptor) => IMeshEntity);
    createSpheres: ((numberToCreate: number, desc?: SphereDescriptor) => IMeshEntity[]);
}> = ...

Type declaration

  • createAxis: ((desc?: AxisDescriptor) => IMeshEntity)
      • (desc?): IMeshEntity
      • Creates an axis mesh entity for coordinate system visualization. Typically displays X, Y, and Z axes with different colors.

        Parameters

        Returns IMeshEntity

        A mesh entity representing the coordinate axes

        const worldAxis = createAxis({
        length: 5.0,
        thickness: 0.1
        });
  • createCube: ((desc?: CubeDescriptor) => IMeshEntity)
      • (desc?): IMeshEntity
      • Creates a cube mesh entity with optional physics simulation.

        Parameters

        • desc: CubeDescriptor = {}

          Configuration object for the cube geometry and physics properties

        Returns IMeshEntity

        A mesh entity representing the cube, with physics component if specified

        // Create a simple cube
        const cube = createCube({ widthVector: Vector3.fromCopy3(2, 2, 2) });

        // Create a cube with physics
        const physicsCube = createCube({
        widthVector: Vector3.fromCopy3(1, 1, 1),
        physics: {
        use: true,
        move: true,
        density: 1.0,
        friction: 0.5,
        restitution: 0.3
        }
        });
  • createCubes: ((numberToCreate: number, desc?: CubeDescriptor) => IMeshEntity[])
      • (numberToCreate, desc?): IMeshEntity[]
      • Creates multiple cube mesh entities efficiently by sharing the same mesh geometry. This is more performance-friendly than creating individual cubes when you need many instances.

        Parameters

        • numberToCreate: number

          The number of cube entities to create

        • desc: CubeDescriptor = {}

          Configuration object for the cube geometry and physics properties

        Returns IMeshEntity[]

        An array of mesh entities representing the cubes

        // Create 100 cubes for instancing
        const cubes = createCubes(100, {
        widthVector: Vector3.fromCopy3(0.5, 0.5, 0.5),
        physics: { use: true, move: true }
        });

        // Position them individually
        cubes.forEach((cube, index) => {
        cube.localPosition = Vector3.fromCopy3(index % 10, 0, Math.floor(index / 10));
        });
  • createGrid: ((desc?: GridDescriptor) => IMeshEntity)
      • (desc?): IMeshEntity
      • Creates a grid mesh entity for visual reference.

        Parameters

        • desc: GridDescriptor = {}

          Configuration object for the grid geometry

        Returns IMeshEntity

        A mesh entity representing the grid

        const grid = createGrid({
        size: 10,
        divisions: 20
        });
  • createJoint: ((desc?: IAnyPrimitiveDescriptor) => IMeshEntity)
      • (desc?): IMeshEntity
      • Creates a joint mesh entity for skeletal animation or mechanical connections.

        Parameters

        Returns IMeshEntity

        A mesh entity representing the joint

        const joint = createJoint({
        radius: 0.1,
        length: 2.0
        });
  • createLine: ((desc?: LineDescriptor) => IMeshEntity)
      • (desc?): IMeshEntity
      • Creates a line mesh entity.

        Parameters

        Returns IMeshEntity

        A mesh entity representing the line

        const line = createLine({
        startPoint: Vector3.fromCopy3(0, 0, 0),
        endPoint: Vector3.fromCopy3(1, 1, 1)
        });
  • createPlane: ((desc?: PlaneDescriptor & {
        direction?: "xz" | "xy" | "yz";
    }) => IMeshEntity)
      • (desc?): IMeshEntity
      • Creates a plane mesh entity with configurable orientation.

        Parameters

        • desc: PlaneDescriptor & {
              direction?: "xz" | "xy" | "yz";
          } = {}

          Configuration object for the plane

        Returns IMeshEntity

        A mesh entity representing the plane

        // Create a horizontal plane (default)
        const horizontalPlane = createPlane();

        // Create a vertical plane facing forward
        const verticalPlane = createPlane({ direction: 'xy' });
  • createShape: ((primitive: IShape) => IMeshEntity)
      • (primitive): IMeshEntity
      • Creates a mesh entity from a primitive shape. This is a utility function used internally by other creation methods.

        Parameters

        • primitive: IShape

          The primitive shape to convert into a mesh entity

        Returns IMeshEntity

        A mesh entity containing the primitive shape

        const customPrimitive = new CustomShape();
        customPrimitive.generate(config);
        const entity = createShape(customPrimitive);
  • createSphere: ((desc?: SphereDescriptor) => IMeshEntity)
      • (desc?): IMeshEntity
      • Creates a sphere mesh entity with optional physics simulation.

        Parameters

        • desc: SphereDescriptor = {}

          Configuration object for the sphere geometry and physics properties

        Returns IMeshEntity

        A mesh entity representing the sphere, with physics component if specified

        // Create a simple sphere
        const sphere = createSphere({ radius: 2.0 });

        // Create a sphere with physics
        const physicsSphere = createSphere({
        radius: 1.0,
        physics: {
        use: true,
        move: true,
        density: 0.8,
        friction: 0.4,
        restitution: 0.9
        }
        });
  • createSpheres: ((numberToCreate: number, desc?: SphereDescriptor) => IMeshEntity[])
      • (numberToCreate, desc?): IMeshEntity[]
      • Creates multiple sphere mesh entities efficiently by sharing the same mesh geometry. This is more performance-friendly than creating individual spheres when you need many instances.

        Parameters

        • numberToCreate: number

          The number of sphere entities to create

        • desc: SphereDescriptor = {}

          Configuration object for the sphere geometry and physics properties

        Returns IMeshEntity[]

        An array of mesh entities representing the spheres

        // Create 50 spheres for a particle system
        const spheres = createSpheres(50, {
        radius: 0.2,
        physics: { use: true, move: true, density: 0.5 }
        });

        // Scatter them randomly
        spheres.forEach(sphere => {
        sphere.localPosition = Vector3.fromCopy3(
        Math.random() * 10 - 5,
        Math.random() * 10,
        Math.random() * 10 - 5
        );
        });