How to import giu directory using npm?


I am working a custom virtual joystick in babylon.js i am using macos.

  let adt = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI");

I tried import this command line. I am using npm i used firstly npm i @babylonjs/gui and i tried import this method

import { AdvancedDynamicTexture } from '@babylonjs/gui/2D';

it doesn’t work . secondly i tried npm install --save babylonjs babylonjs-gui

import * as GUI from 'babylonjs-gui'; 

it doesn’t work . how to import gui directory to my project?

cc @RaananW

the BABYLON namespace is needed only if you use the UMD version of the engine (i.e. import ... from "babylonjs"); If you use es6, you need to import the class directly, and then not use the BABYLON namespace. It would be easier to tell you what is wrong if you shared a project or a reproduction

1 Like

I’m getting error on my chrome console.

main.js:116 Uncaught TypeError: Cannot read properties of undefined (reading ‘AdvancedDynamicTexture’)
at createScene

Can you please share a repro ? it is really hard without it.

1 Like