Hi,
I recently encountered a small problem when I refactored my project relying on polygon mesh builder using ES6 modules and npm.
If I include babylon js and poly2tri with npm and import it using
import poly2tri from 'poly2tri';
import BABYLON from 'babylonjs';
This way, the poly2tri package is available locally.
So, I get an error saying:
"PolygonMeshBuilder cannot be used because poly2tri is not referenced"
It probably comes from there (babylon.polygonMesh.ts):
if (!("poly2tri" in window)) {
throw "PolygonMeshBuilder cannot be used because poly2tri is not referenced";
}
So, I'm forced to do the following before using PolygonMeshBuilder (which is not a very good way to go IMO):
window.poly2tri = poly2tri;
Shouldn't it be:
if (!("poly2tri" in window || polytri)) {
throw "PolygonMeshBuilder cannot be used because poly2tri is not referenced";
}
EDIT: Sorry, I put this in the wrong place, and I can't delete it neither move it.