I'm using Requirejs in Magento 2 to load Babylonjs (version 3.3). But in my callback, requirejs gives me an undefined in my BABYLON object.
I have tried doing it with a requirejs-config.js to substitute names, but no luck.
require(['My_Module/js/babylon','My_Module/js/babylon.gui.min'], function(BABYLON, GUI) {
console.log(BABYLON); // undefined
new BABYLON.Color3(0,0,0,0) // TypeError BABYLON.Color3 is not a constructor
});
The files I am trying to load are in My/Module/view/frontend/web/js
. and are named babylon.js
and babylon.gui.min.js
I expected my BABYLON variable in my callback to be the BABYLON object as I would import it in a CommonJS environment.
Turns out the library defined itself as babylonjs
. not as My_Module/js/babylonjs
.