Create instance doesn't work sometimes

Hello… I have several gltf meshes that I load from blob urls and then store in a variable and use later to create several instances of each asset in an absolute position at a defined scale. But for one particular asset it seems sometimes when I load even after loading it in the assets does not appear on the scene. This is not consistent as it re-appears on reloading the browser… Please help…

const plugin = BABYLON.SceneLoader.ImportMesh(
            '',
            url,
            '',
            _scene,
            null,
            null,
            (reason) => {
                console.log(reason)
                // TODO sceneError({ name: fileName }, null, reason.message || reason);
            },
            '.gltf'
        )

        const self = this

        plugin.onMeshLoaded = function (mesh) {
            if (mesh.name !== '__root__') {
                console.log(`loaded model: ${mesh.name}`)
                // remove it from scene
                mesh.setEnabled(false)
                self._sceneMeshes.set(key, mesh)
                self.progress += 1
                if (self.progress === self.totalModels) {
                    console.log('Loading successful')
                    self.createInstances()
                    self.loadAsset()
                }
            }
}

Here is how am creating the instances

const { instanceID, origin, size } = instance
        const { _sceneMeshes } = this
        const mesh = _sceneMeshes.get(modelType)
        if (mesh) {
            const asset = mesh.createInstance(instanceID)
            asset.setEnabled(true)
            asset.checkCollisions = true
            const modelSize = asset
                .getBoundingInfo()
                .boundingBox.extendSize.scale(2)

            const position = new BABYLON.Vector3(
                -origin.x - size.width,
                origin.y,
                origin.z
            )

            const scale = new BABYLON.Vector3(
                size.width / modelSize.x,
                size.height / modelSize.y,
                size.depth / modelSize.z
            )
            asset.setAbsolutePosition(position)
            asset.scaling = scale
        } else {
            console.error(`could not find: ${modelType}`)
        }

I have no errors in the console…

We would need a repro in the pg to help

Some doc about loading external assets:
https://doc.babylonjs.com/resources/external_pg_assets

sure let me try that… I’ll post the link here when done…

@Deltakosh it is not easy reproducing my specific architecture at the playground… If anyone is willing to offer paid support for an hour session it’d be better than spending hours to reproduce my exact architecture at the playground then I can organise a debug session.

That’s a good ask for our Paid services section :slight_smile:

sorry… where is that? :face_with_hand_over_mouth:

It’s the last entry of the category list:

1 Like