As an example, this three.js examples looks very nice, but if try to open this glb by three.js editor then it doesn’t look the same. Otherwise, if try to open any glb from https://threejs.org using three.js examples gltf-loader configuration it doesn’t work at all. So, my question what should be the proper configuration of gltf-loader to open any glb/gltf nicely in a general way?
Can you share a screenshot comparing what you mean by “nicely” and not-“nicely”?
Loader just loads the vertices and materials - it’s not much responsible for the rendering. To make things look pretty you usually need to add some light or environment to the scene, separately from the model.
Lighting is the difference you see there, and is unrelated to configuring the loader – if you enable one of the options in the “Environment” dropdown in the three.js editor right-hand sidebar you’ll have some options. THREE.RoomEnvironment is a good starting point for most models, or see any of the three.js lighting examples.
I, tried to use the example webgl instancing performance witch is a 3D model in a json file and change it to load my own model gltf and it didn’t work with the gltf loader or maybe it’s my code, I’m artist not developper so I generate the code change by ia. Thanks for help
Instancing only works for a single mesh, so if your GLTF has multiple meshes… you’ll have to instance each mesh separately.
You can get an array of the meshes by doing:
let meshes = [ ]
gltf.scene.traverse(e=>e.isMesh&&meshes.push(e));
then you have meshes as an array of meshes.
@MadMax888 just in case if this might help, you can always consider using my GM Viewer.
Its HTML file is purely online based and can be used as a standalone, just remove the following line which points to my repository:
<link rel="shortcut icon" href="../../images/favicon.ico" type="image/x-icon"/>
You can try modifying anything else in the viewer to serve your purposes.
It is using Google’s model-viewer web component in case if you want to try configuring any other options than what’s currently present in the viewer.
The menu is fairly simple and allows for loading multiple models at once, either locally or remotely, but will be showing one model at the time (switchable with the M
button). The menu also has Eq
and NL
controls to change the lighting and the environment map.