Joins several meshes into one new mesh, which draws faster than many separate ones.
The sources are removed when disposeSource is true; set allow32BitsIndices when the
meshes together have more than 65 thousand vertices, and use the sub-mesh options to keep
separate materials.
The meshes and the merge options
The merged mesh
Gives every triangle of a mesh its own vertices and normals, so faces show as flat facets instead of being smoothed across edges; the mesh is changed in place and given back.
The mesh
The same mesh, flat shaded
Makes a copy of a mesh, with its children, that shares the geometry of the original and is placed at the same spot; the copy casts and receives shadows like the original.
The mesh to copy
The copy
Makes one copy of a mesh at every given position, in the same order; the copies share the geometry of the original.
The mesh and the positions
One copy per position
Reads the node a mesh is parented to, which is what it moves with; a mesh at the top level has none.
The mesh
The parent node
Reads whether a mesh takes part in collision checking.
The mesh
True when collisions are checked against the mesh
Sets whether a mesh answers to pointer picking, and its children too when includeChildren
is true; an unpickable mesh is skipped by clicks and rays that pick.
The mesh, the flag and whether children follow
Reads whether the mesh can be picked with the pointer.
The mesh
True when the mesh answers to picking
Finds every mesh in the scene whose name contains the given text, case-sensitive, in scene order.
The text to look for in mesh names
The matching meshes
Lists the meshes parented under a mesh: all descendants, or only the direct children when
directDescendantsOnly is true.
The mesh and whether to stop at direct children
The child meshes
Finds every mesh in the scene with exactly the given id; ids need not be unique, so several may match.
The id to look for
The meshes with that id
Finds the first mesh in the scene with exactly the given id; use getMeshesOfId when several
share it.
The id to look for
The first mesh with that id
Finds the mesh with the given unique id, the number the scene assigns to every mesh once, as
getUniqueId reads it.
The unique id
The mesh with that unique id
Reads the id of a mesh, the label set by setId or by the loader that created it.
The mesh
The id
Reads the unique id of a mesh, the number the scene gives every mesh once and never reuses.
The mesh
The unique id number
Reads the triangles of a mesh as lists of three points in the mesh's own coordinates, the
form jscad.shapes.fromPolygonPoints and similar builders take. The mesh must be made of
triangles.
The mesh
The triangles as lists of three points
Reads the name of a mesh, as set by setName or by whatever created it.
The mesh
The name
Reads the material of a mesh, the surface description its faces are drawn with.
The mesh
The material
Reads the position of a mesh relative to its parent, as a point.
The mesh
The position as a point
Reads the position of a mesh in world coordinates, with every parent's transform applied.
The mesh
The world position as a point
Reads the rotation of a mesh around X, Y and Z, in radians, as its rotation property holds it.
The mesh
The rotation angles in radians
Reads the scale factors of a mesh along X, Y and Z; 1 is unscaled.
The mesh
The scale factors
Creates a placed instance of a mesh, as createMeshInstanceAndTransform does, without giving
it back; for scripts that only need the copy to appear.
The mesh and the position, rotation and scaling of the instance
Creates an instance of a mesh, a lightweight copy that shares its geometry and draws cheaply, and places it at the given position, rotation in degrees and scaling.
A mesh with children gets one instance per child, gathered under a new container; the original is hidden.
The mesh and the position, rotation and scaling of the instance
The container holding the instances
Creates an instance of a mesh, a lightweight copy that shares its geometry and draws cheaply when many alike are needed, placed where the original is.
A mesh with children gets one instance per child, gathered under a new container.
The mesh
The instance, or the container holding the child instances
Tells whether two meshes overlap, judged by their bounding boxes: axis-aligned ones by
default, or boxes that follow each mesh's rotation when precise is true;
includeDescendants tests their children too.
The two meshes and the precision options
True when the meshes overlap
Tells whether a point lies inside the bounding box of a mesh.
The mesh and the point
True when the point is inside the mesh's bounds
Removes a mesh from the scene and frees its GPU resources; the mesh cannot be used afterwards. Nothing happens when no mesh is given.
The mesh to remove
Moves a mesh along its own forward direction, the local Z axis, by distance scene units; a
turned mesh moves the way it faces.
The mesh and the distance
Moves a mesh against its own forward direction, the local Z axis, by distance scene units.
The mesh and the distance
Moves a mesh along its own up direction, the local Y axis, by distance scene units.
The mesh and the distance
Moves a mesh against its own up direction, the local Y axis, by distance scene units.
The mesh and the distance
Moves a mesh along its own right direction, the local X axis, by distance scene units.
The mesh and the distance
Moves a mesh against its own right direction, the local X axis, by distance scene units.
The mesh and the distance
Turns a mesh around its own Y axis by rotate degrees, on top of its current rotation, the
way a car turns left or right.
The mesh and the angle in degrees
Turns a mesh around its own X axis by rotate degrees, on top of its current rotation, the
way a nose tips up or down.
The mesh and the angle in degrees
Turns a mesh around its own Z axis by rotate degrees, on top of its current rotation, the
way a wing banks.
The mesh and the angle in degrees
Turns a mesh by angle degrees around an axis that passes through position, so the mesh
orbits that point rather than spinning in place.
The mesh, the point on the axis, the axis direction and the angle in degrees
Makes one mesh the child of another, so it moves, turns and scales together with its parent from then on; its position becomes relative to the parent.
The mesh and the mesh to parent it to
Turns collision checking on or off for a mesh, and its children when includeChildren is
true, so a camera or another collider with collisions enabled cannot pass through it.
The mesh, the flag and whether children follow
Lets a mesh, and its children when includeChildren is true, react to the pointer merely
moving over it, which is off by default because it costs a pick on every pointer move.
The mesh and whether children follow
Stops a mesh, and its children when includeChildren is true, from reacting to pointer
moves, back to the default.
The mesh and whether children follow
Sets the id of a mesh, a label that getMeshOfId finds it by and that need not be unique.
The mesh and the id
Sets the name of a mesh, and of its children too when includeChildren is true; names are
what getMeshesWhereNameContains searches.
The mesh, the name and whether children follow
Gives a mesh a material, and its children too when includeChildren is true; the material
decides the color, shininess and transparency of its surface.
The mesh, the material and whether children follow
const material = bitbybit.babylon.material.pbrMetallicRoughness.create({ name: "red", baseColor: "#ff0000", emissiveColor: "#000000", metallic: 0.2, roughness: 0.6, alpha: 1, backFaceCulling: false, zOffset: 0 });
bitbybit.babylon.mesh.setMaterial({ babylonMesh: mesh, material, includeChildren: true });
Places a mesh, or an instance of one, at a point relative to its parent.
The mesh and the position
Sets the rotation of a mesh, or an instance of one, as angles in degrees around X, Y and Z, replacing its current rotation.
The mesh and the three angles in degrees
Sets the scale factors of a mesh, or an instance of one, along X, Y and Z, replacing its current scale; 1 is unscaled.
The mesh and the three scale factors
Multiplies the current scale of a mesh, or an instance of one, by one factor on all axes, so 2 doubles whatever size it has.
The mesh and the factor
Moves, rotates, scales and recolors a drawn mesh in place, without drawing it again, which is faster when only the placement or the color changes.
rotation is in radians here. colours is one hex color, or a list with one entry per child
mesh, or per point or line of such a drawing; any other list uses its first entry.
The drawn mesh, its new position, rotation, scaling and colors
Sets how visible a mesh is, from 0 for fully transparent to 1 for fully shown, with the
values between fading it; includeChildren applies the same value to its child meshes.
The mesh, the visibility from 0 to 1 and whether children follow
Hides a mesh without removing it from the scene, and its child meshes too when
includeChildren is true; show brings it back.
The mesh and whether its children follow
Shows a mesh that hide or a hidden draw made invisible, and its child meshes too when
includeChildren is true.
The mesh and whether its children follow
Working with meshes already in the BabylonJS scene, the objects
draw.drawAnyAsyncgives back: moving, rotating and scaling them, showing and hiding, parenting, picking and collision flags, names and ids, cloning and instancing for many copies, and reading their triangles back out. Rotations are given in degrees; positions and distances are in scene units.