Hi is there a way to hide the whole loader and the scene if there is not any file in my case STL file. In my use sometimes i have stl files and sometimes just an photo and i already solve the problem for the photo if there isn`t any photos only loads the stl loader but i need to make the same thing for the stl loader.
this is what i used for hiding the picture:
img.onerror = function () {
this.style.display = “none”;
}
I tried on the scene of the loader and on the loader where the path is but no luck.
Not sure I fully understand your use but you can of course stop rendering and hide/remove the renderer’s canvas no asset has to be rendered. Hiding the canvas can be done like so:
sounds like you want to show either the image or the canvas, if the stl file exists, right? If so, i would go for just checking the file existance first (see https://stackoverflow.com/a/3646923) and putting the threejs scen in the success path.
Thanks this solved my problem using also ajax from Sebastian_Bauer link. Now the code looks something like this :
$.ajax({
url:“the url of the file location”,
type:‘HEAD’,
error: function()
{
webGLRenderer.domElement.style.display = ‘none’;