Babylon is a excellent web3d library, react is a excellent web-ui library, and they all support typescript,
By reading this doc, I create a project which contian react and babylonjs with typescript, it work well, but when I use the MeshBuilder.CreatePolygon function it report this bug.
ReferenceError: earcut is not defined
Function.e.CreatePolygon
C:/Users/Administrator/Documents/WebProjects/SunnyHouseWeb/node_modules/_babylonjs@4.2.0-beta.12@babylonjs/babylon.js:16
Babylonjs is no longer built-in the earcut, I have to add it to my project in advance.
Has anyone ever tried to do that?
I have found an artical for this question, but the answer mention a way to change webpack config, I don’t think change webpack config in a create-react-app project is a wise thing so I didn’t try it.
I have try use React-script-tag to add earcut as react component to my project, but it doesn’t work.