Three.js load gltf

Hello.
I save the file from the blender in the format gltf.

upload to the project
https://codepen.io/Lighty/pen/MWePVNz
nothing is displayed in the project
but if i upload the same file to tree.js editor
i see this object

can explain what the problem is?

I have seen this many times and I’m not sure why users are doing this. But you should never do this:

mesh = gltf.scene.children[0];

It might work but not in all cases. Your glTF contains three 3D objects and you are currently selecting not the mesh. To avoid such issues, it’s best to do this:

mesh = gltf.scene;

In Blender, you should also ensure to only export objects you actually want. I guess it is not your intention to export the camera and light, right?

yes right. but I also tried to export the light, it didn’t have any effect)))

thanks for the answer.
I also wanted to ask if it is possible for objects that have no textures and no color to set the color using three.js ?

You have to enable the export of punctual lights in the Include section:

image

In this case, it’s best if you just overwrite the asset’s materials in your app.

1 Like

but asset materials are set only in blender?