Delete last callback content

hello ,
I tried to load objects with the callback method. the problem is that i have to delete the old object before adding a new one.
I tried with .dispose () but I don’t work because I use the callback method.

Some thing like this avec Three.js :
// Remove previous results
while ( container.children.length ) {

						container.remove( container.children[ 0 ] );

					}

my funtion :
('body').on('click', '.img-obj', function () { const pos = (this).attr(‘id’);

        var aux = assets[pos];
        var format = getFormat('GLTF2', aux.formats);
        if (format !== undefined) {

            var uri = format.root.url;
            var fileIndex = uri.lastIndexOf("/");
            var path = uri.substring(0, fileIndex + 1);
            var filename = uri.substring(fileIndex + 1);
            callback(path,filename);
        }
    });

thanks for help

Hi @issam_abdelhedi,

I think we are missing context. and code. and a way to help :slight_smile:

As general as possible, dispose() should remove the object from the scene and stop rendering it. If it is not working, you are calling dispose on the wrong object.

Oh, and we have no issues with Three.js, we all think it is a great framework, but we (usually) don’t know it that well. So try to provide babylon examples and not three.js :+1:

2 Likes