I am using all of the preview packages (4.1.0-rc.5) which are working ok so far. But I have a compile error trying to create an AdvancedDynamicTexture for WebXR UI:
const plane = Mesh.CreatePlane('ui', 1, this.scene);
plane.visibility = 0;
plane.position = new Vector3(0, 1, 0);
const advancedTexture = AdvancedDynamicTexture.CreateForMesh(plane);
This causes this error:
TS2345: Argument of type 'Mesh' is not assignable to parameter of type 'AbstractMesh'.
Type 'Mesh' is missing the following properties from type 'AbstractMesh': _resyncLighSource, addToSceneRootNodes, removeFromSceneRootNodes
Well this is really weird as Mesh inherits from AbstracMesh
Do you have special linting tools or something?
I am using tslint and tslint-loader via webpack. Trying to explicitly cast gives an error that looks like there’s a conflict with the gui package vs core. So this could DEFINITELY be a configuration issue . Especially given this. (<deleted>
is just extra long path):
Argument of type 'import("<deleted>/node_modules/@babylonjs/core/Meshes/abstractMesh").AbstractMesh' is not assignable to parameter of type 'import("<deleted>/node_modules/@babylonjs/gui/node_modules/@babylonjs/core/Meshes/abstractMesh").AbstractMesh'.
Type 'AbstractMesh' is missing the following properties from type 'AbstractMesh': _resyncLighSource, addToSceneRootNodes, removeFromSceneRootNodes
make sure you are getting all the packages from the same version (including GUI of course)
1 Like
AHA! It looks like RC 9 snuck up on me. Indeed GUI was newer than the other packages. I am back in business. Thank you @Deltakosh
1 Like
sorry @MugOfPaul , same issue here, two years after.
Following this documentation Instances | Babylon.js Documentation i’m doing, in typescript,
i have these imports
import {Scene, Engine, FreeCamera, HemisphericLight, MeshBuilder, Vector3, StandardMaterial, Texture, SceneLoader, Mesh} from "@babylonjs/core"
and this code
async CreateTrees(howMany=1):Promise<void>{
const models = await SceneLoader.ImportMeshAsync("", "./models/", "alberino3.glb")
const meshes = models.meshes
const theMesh:Mesh = meshes[0]
theMesh.isVisible = false
for (let i = 0; i < howMany; i++) {
const newInstance = theMesh.createInstance("tree-"+i)
newInstance.position.x = 5 * i
newInstance.position.y = 0
}
}
but not working due to the AbrastractMesh class
please can you help me?
thanks
If you want to use AbstractMesh class as mesh you can try
const theMesh = meshes[0] as Mesh
It works for me.
1 Like
Thanks @Abhishek_Shakya
it works also for me.
i obtain only a object and the console log if filled by
logger.js?57a9:48 BJS - [20:24:49]: Instances should only be created for meshes with geometry.
but this is another problem
1 Like