MeshBuilder.CreatePolygon and PolygonMeshBuilder API is inconsistent
See original GitHub issueHello,
I’m migrating not from babylonjs@3.3.0
to @babylonjs/core@4.0.0-alpha.18
to try out the new and long waited tree shaking! (@sebavan 👑)
And getting the following error: ReferenceError: earcut is not defined at new PolygonMeshBuilder
.
This is because MeshBuilder.CreatePolygon
API doesn’t support earcut injection:
Babylon.js/src/Meshes/meshBuilder.ts:
Help will be very much appreciated, Tomer.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
PolygonMeshBuilder vs MeshBuilder.createPolygon - Questions
My problem starts when I want to move it to my angular application. How should I use PolygonMeshBuilder to work like MeshBuilder.CreatePolygon?
Read more >Parametric Shapes - BabylonJS Guide
You must set at least the shape property. Example : var polygon = BABYLON.MeshBuilder.CreatePolygon("polygon", {shape: myShape, sideOrientation: BABYLON ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
With Webpack , install earcut via npm:
npm i --save-dev earcut
Then in your .ts or .js file:
In the documentation you can see that after scene, the next optional parameter is earcutInjection, this is the way. https://doc.babylonjs.com/api/classes/babylon.meshbuilder#createpolygon
@Fusseldieb, This was a temporary solution I used until @deltakosh solution, you can inject earcut into CreatePolygon, so there is no real reason to manually referance the global scope:
I’m using
@babylonjs/core@4.0.0
and it’s working.