MeshWriter Mesh Error

Uncaught Error: Missing method ‘Mesh’
import { MeshWriter } from “meshwriter”;

Wrapper = require("meshwriter");
import { Vector3, StandardMaterial, Mesh } from "@babylonjs/core";
import { scene, engine } from "./scene";
//import { MeshWriter } from "meshwriter";

Writer = MeshWriter(scene, { scale: 1 });
text1 = new Writer("This Works", {
    anchor: "center",
    "letter-height": 50,
    color: "#1C3870",
    position: {
        z: 20,
textMesh = text1.getMesh();

Error shows up even with JUST " import { MeshWriter } from “meshwriter”;", on the page.

Mesh.CreatePoplyhedron() works well


@TheLeftover is the brillant mind behind the MeshWriter I believe so maybe he has some ideas about what could be wrong here.

@sebevan, that was very kind.

@charliesideroad, if BABYLON is not loaded in the address space, then there are several methods that must be manually passed to MeshWriter. The documentation on this was pretty unclear; my bad. So, I improved it. Screenshot attached nearby.

You may also visit meshwriter/ at master · briantbutton/meshwriter · GitHub


@sebevan, it occurred to me that the documentation would be further improved by including the exact import statements that would get those methods with the current version of BABYLON. Then our recipe would leave less to the imagination.

I can include that information in the MeshWriter documentation.

Charlie started us with one example that captures three of them.

import { Vector3, StandardMaterial, Mesh } from "@babylonjs/core";

Would it be possible to get the incantations to pull in the whole list?

Not sure of what you mean by the whole list ? but I love the idea of improving the docs :slight_smile:

It does work now, thank you Lefty

import * as BABYLON from “@babylonjs/core/Legacy/legacy”;

BABYLON = [Vector2,Vector3,

import * as MeshWriter from “meshwriter”;

var scale = 0.1,
Writer = MeshWriter(scene, { scale: scale });
text1 = new Writer(“ABC”, {
anchor: “center”,
“letter-height”: 50,
color: “#1C3870”,
position: {
z: -0.1,
textMesh1 = text1.getMesh();
textMesh1.rotation = new Vector3(-1.57, 0, 0);
textMesh1.parent = FrontPlane;

1 Like

By doing this:

import * as BABYLON from “@babylonjs/core/Legacy/legacy”;

you are basically getting rid of tree shaking I guess the import should be refined to the exclusive sets of resources required by MeshWriter which is probably what @TheLeftover was mentioning above :slight_smile:

@sebavan, exactly!

Who can give us a more optimal recipe?

I you let me know any you are using in the meshWriter, I can take care of writing the imports :slight_smile:

It seems to be just the Mesh. I did the SPS .getSPS() Rotating BabylonJS example from the Docs and it worked fine with these settings for imports:

import {Mesh,} from “@babylonjs/core”;
import {} from “@babylonjs/core/Legacy/legacy”;
import {} from “meshwriter”;

1 Like

Thank you @sebavan. Here is the list.
• Vector2
• Vector3
• Path2
• Curve3
• SolidParticleSystem
• PolygonMeshBuilder
• StandardMaterial
• Mesh

1 Like

the import list should then be:

import { Vector2, Vector3 } from "@babylonjs/core/Maths/math.vector";
import { Path2, Curve3 } from "@babylonjs/core/Maths/math.path";
import { Mesh } from "@babylonjs/core/Meshes/mesh";
import { CSG } from "@babylonjs/core/Meshes/csg";
import { PolygonMeshBuilder} from "@babylonjs/core/Meshes/polygonMesh";
import { SolidParticleSystem } from "@babylonjs/core/Particles/solidParticleSystem";
import { StandardMaterial } from "@babylonjs/core/Materials/standardMaterial";

BABYLON = [Vector2, Vector3, Path2, Curve3, SolidParticleSystem, PolygonMeshBuilder, CSG, StandardMaterial, Mesh];

Very cool. I will get this in a documentation update.