BabylonNative - PolygonMeshBuilder not implemented correctly?


this.xrPlanes.onPlaneAddedObservable.add(plane => {
 console.log('abc: ', plane);
 var polygon_triangulation = new BABYLON.PolygonMeshBuilder("name", => new BABYLON.Vector2(p.x, p.z)), this.scene);

on last line error Uncaught Error: earcut is not defined

Do you have earcut.js?

It’s BABYLON NATIVE, I haven’t any external js. All engine js needs compiled to player. = new BABYLON.GlowLayer("glow", this.scene, {mainTextureSamples: 4});

results is black screen (no render) - not implemented correcttly?

The PolygonMeshBuilder still needs the earcut plugin to work.
I’m a bit underqualified to say more about babylon native

CC: @Cedric @bghgary who ever is around first :slight_smile:

You can add it as an injection

BabylonNative can’t import modules, only embedded classes

Adding @srzerbetto @Cedric and @bghgary

@Cr0c , how are you using Babylon Native? Are you creating a project from the templates we have on the Github repo?

@Cr0c , you actually CAN load dependencies on Babylon Native. However, it need to be done on the C++ side where the js scripts get loaded. Usually in the samples we have a ScriptLoader that ir responsible for loading all js scripts required for the application to run (babylon.max.js, and others).

If you have earcut.min.js in your applications folder you can do the following using the ScriptLoader C++ object:

Babylon::ScriptLoader loader{*runtime};
        loader.Eval("document = {}", "");
        //Add earcut before babylon.max.js

This will make earcut available to babylon.js.
To get the earcut.min.js you can use npm to install it and add it to the list of scripts in CMake file like we do in our samples.

If you need extra instructions on how to do that let me know.


I am inject all earcut to meshwriter directly as var earcut = function(...) {...} and comment all export earcut...