BABYLON.SceneLoader.ImportMesh which I used in version 7.22.5 and then the onMeshLoaded method I ran gives an error in version 7.49
var hallLoader = BABYLON.SceneLoader.ImportMesh(
"",
env.STATICS_SERVER + "/assets/babylon5/hall_yeni/",
"hall.gltf",
this.sahne,
(meshes) => {
var scale = 100;
meshes[0].scaling = new BABYLON.Vector3(scale, scale, -1 * scale);
}
);
hallLoader.onMeshLoaded = (mesh) => {
console.log(mesh)
}
The error message I encountered
↓↓↓↓
Uncaught (in promise) TypeError: Cannot set properties of undefined (setting ‘onMeshLoaded’)
RaananW
2
Is this local? on the playground?
If it is local, did you update the loaders package as well?
RaananW
4
CC @ryantrem , ImportMesh returns void now. was the signature different before?
Yes, when mime type support was added, it introduced new asynchrony in previously synchronous paths, and a breaking change was made to this API: Adding support to mimetype autodetection by deltakosh · Pull Request #15798 · BabylonJS/Babylon.js
3 Likes
You can do a similar thing with newer APIs though like this:
const assetContainer = await BABYLON.LoadAssetContainerAsync("https://raw.githubusercontent.com/BabylonJS/Assets/master/meshes/ufo.glb", scene, {
pluginOptions: {
gltf: {
onMeshLoaded: (mesh) => {
console.log(`Loaded mesh: ${mesh.name}`);
},
},
},
});
assetContainer.meshes.forEach((mesh) => scene.addMesh(mesh));
Here is a PG for this: Babylon.js Playground
3 Likes