Can't add MeshWriter to react & babylonjs app

Hi, I am new to Babylonjs. I follow the doc for Babylon.js and React, it works fine. Then I follow the doc for MeshWriter, it works fine too for the playground & html page. When I add MeshWriter to react & babylonjs App, it is broken, gets a blank page, if open chrome dev-tools console, it says: Uncaught TypeError: (0 , meshwriter__WEBPACK_IMPORTED_MODULE_1__.MeshWriter) is not a function
Since it is a react & babylonjs, can’t have it on the playground, here is the github link, this is the deployed link
here is my local dev screen shot & deployed screen shot errors



Thanks for your help

I guess you face the same issue than this post so you could try the same recommendations : Import MeshWriter extension in typescript project - #2 by RaananW

Let me also ping @TheLeftover who is the daddy of the MeshWriter :slight_smile:

1 Like

I saw that post and related posts before I posted. That all didn’t work out. Thanks for the reply and pinging.

Sorry for your trouble. I did take a look at your app page. It looks like a load-order problem. But . . .

Let me suggest you change the line:
import { MeshWriter } from "meshwriter";
with
import MeshWriter from "meshwriter";

This all may be related to a documentation but that I am fixing today.

1 Like

Thanks for your help. I followed your suggestion and got new error: Uncaught TypeError: w.StandardMaterial is not a constructor. Here is the screenshot

I am pretty sure that represents progress. MeshWriter depends on certain BABYLON methods; StandardMaterial is one of them.

The coder must hand these methods to MeshWriter. If you visit GitHub - briantbutton/meshwriter: Babylon Mesh Writer and then scroll down to a section titled: Critical Environment Requirement, you will get a full explanation.

That section has a suggested recipe with a few lines of code. Those have worked for other people. I think they are solid.

1 Like

Great! that works. at the doc, it is missing: import { Color3 } from ‘@babylonjs/core/Maths/math.color’;

Thank you very much

2 Likes

Thank you. I will incorporate that change in the documentation.

1 Like