croustibat Posted April 19, 2016 Share Posted April 19, 2016 (edited) 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. Edited April 19, 2016 by croustibat Wrong place to post it! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 19, 2016 Share Posted April 19, 2016 Hey! completely agree. Do you want to submit a PR? Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted April 19, 2016 Share Posted April 19, 2016 Be carefull if you submit the PR, you wrote polytri and not poly2tri... Quote Link to comment Share on other sites More sharing options...
croustibat Posted April 20, 2016 Author Share Posted April 20, 2016 Thanks for the warn Vousk prod I will submit a PR Deltakosh! Quote Link to comment Share on other sites More sharing options...
croustibat Posted April 20, 2016 Author Share Posted April 20, 2016 Well, that's embarassing, but this doesn't seem to work. Even if I call PolygonMeshBuilder from a scope where poly2tri is defined, inside this constructor, poly2tri is not visible. I probably lack some knowledge here. Looking for a plan B now... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.