BabylonJS/Babylon.js · error

Import MeshBuilder to populate this function

Error message

Import MeshBuilder to populate this function

What it means

mesh.pure.ts is the tree-shakeable "pure" build of the Mesh class: static legacy mesh-creation helpers are deliberately unimplemented stubs that throw. The real implementations live in MeshBuilder, which must be imported so its side effects populate these functions.

Source

Thrown at packages/dev/core/src/Meshes/mesh.pure.ts:5449

     * @param _scene defines the hosting scene
     * @param _updatable defines if the mesh must be flagged as updatable
     * @param _sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#side-orientation)
     * @param _instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
     * @returns a new Mesh
     * @deprecated Please use MeshBuilder instead
     */
    public static CreateRibbon(
        _name: string,
        _pathArray: Vector3[][],
        _closeArray: boolean,
        _closePath: boolean,
        _offset: number,
        _scene?: Scene,
        _updatable?: boolean,
        _sideOrientation?: number,
        _instance?: Mesh
    ): Mesh {
        throw new Error("Import MeshBuilder to populate this function");
    }

    /**
     * Creates a plane polygonal mesh.  By default, this is a disc.
     * @param _name defines the name of the mesh to create
     * @param _radius sets the radius size (float) of the polygon (default 0.5)
     * @param _tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
     * @param _scene defines the hosting scene
     * @param _updatable defines if the mesh must be flagged as updatable
     * @param _sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#side-orientation)
     * @returns a new Mesh
     * @deprecated Please use MeshBuilder instead
     */
    public static CreateDisc(_name: string, _radius: number, _tessellation: number, _scene: Nullable<Scene>, _updatable?: boolean, _sideOrientation?: number): Mesh {
        throw new Error("Import MeshBuilder to populate this function");
    }

    /**

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Add `import "@babylonjs/core/Meshes/MeshBuilder";` (side-effect import) once at entry point.
  2. Better: replace `Mesh.CreateX(...)` calls with `MeshBuilder.CreateX(...)` directly.
  3. Alternatively import from the full UMD bundle `@babylonjs/core` where MeshBuilder is auto-registered.

Example fix

// before
import { Mesh } from "@babylonjs/core/Meshes/mesh";
const m = Mesh.CreateDisc("d", 1, 32, scene); // throws
// after
import { MeshBuilder } from "@babylonjs/core/Meshes/meshBuilder";
const m = MeshBuilder.CreateDisc("d", { radius: 1, tessellation: 32 }, scene);
Defensive patterns

Strategy: fallback

Validate before calling

// ensure MeshBuilder is loaded before legacy calls
import "@babylonjs/core/Meshes/MeshBuilder";
function legacyMeshFactoryReady(): boolean {
  try { Mesh.CreateDisc("__probe__", 0.1, 3, null as any); } catch { return false; }
  return true;
}

Try / catch

try {
  const m = Mesh.CreateDisc("d", 1, 32, scene);
} catch (e) {
  if ((e as Error).message.includes("Import MeshBuilder")) {
    const m = MeshBuilder.CreateDisc("d", { radius: 1, tessellation: 32 }, scene);
  }
}

Prevention

When it happens

Trigger: Calling any deprecated static factory on Mesh — here `Mesh.CreatePolygon`-style overload at line 5449 — without importing the MeshBuilder module (`import "@babylonjs/core/Meshes/meshBuilder"` or the full core bundle).

Common situations: Tree-shaken ES6 builds where only Mesh is imported; migrating legacy code that used `Mesh.CreateX(...)` to the modular Babylon packages; copy-pasting old snippets from pre-4.x tutorials.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/9ea5a7dc7608ef25. Report an issue: GitHub.