Hi!
So I wonder why it doesn’t work in my case as in the playground.
I use babylon 4.1.0 with react as shown by this example code: How to use Babylon.js with ReactJS - Babylon.js Documentation
onSceneMount = (e: SceneEventArgs) => {
const { height, width } = this.state.windowDimension;
const { canvas, scene, engine } = e;
let camera = new BABYLON.ArcRotateCamera("Camera", -Math.PI / 2, 1.0, 110, BABYLON.Vector3.Zero(), scene);
camera.setPosition(new BABYLON.Vector3(0, 0, -250));
camera.attachControl(canvas, true);
let hemi = new BABYLON.HemisphericLight("toto");
console.log("engine starting");
let sphere = new BABYLON.Mesh.CreateSphere("Sphere", 10.0, 9.0, scene );
sphere.name = "THIS IS AN EXAMPLE NODE";
let advancedTexture = GUI.AdvancedDynamicTexture("test",width,height,scene); <-- Another Error?
//another test
//let advancedTexture2 = advancedTexture.CreateFullscreenUI("test");
let optionswrapper = new GUI.Rectangle("label for " + sphere.name);
optionswrapper.height = "30px";
optionswrapper.width = "100px";
optionswrapper.thickness = 20;
optionswrapper.linkOffsetY = -30;
optionswrapper.isVisible = true;
advancedTexture2.addControl(optionswrapper);
optionswrapper.linkWithMesh(sphere);
engine.runRenderLoop(() => {
if (scene) {
scene.render();
}
});
}
Even this code shows:
TypeError: setting getter-only property “name” for let advancedTexture = GUI.AdvancedDynamicTexture("test",width,height,scene);
in <.>/sourceES6/core/Materials/Textures/texture.ts:283
here are my installed babylon dependecies:
“@babylonjs/core”: “^4.1.0”,
“@babylonjs/gui”: “^4.1.0”,
“@babylonjs/inspector”: “^4.1.0”,
“@babylonjs/loaders”: “^4.1.0”,
“@babylonjs/materials”: “^4.1.0”,
“@babylonjs/post-processes”: “^4.1.0”,
“@babylonjs/procedural-textures”: “^4.1.0”,
“@babylonjs/serializers”: “^4.1.0”,
Any idea what I may do wrong?
EDIT:
My import looks like this:
import * as BABYLON from ‘babylonjs’;
import * as GUI from ‘@babylonjs/gui’;