Loading and displaying a glTF (.gltf) file (Threejs)

This article can be read in about 2 minutes.
PR

The purpose 

Load a 3D model in Three.js, using the glTF (.gltf) file format, .bin files, and separate texture files recommended by Three.js and Microsoft.

Instructions on how to save the model in Blender are available on this page:

PR

Environment

Threejs: r150

Chrome: 111.0.5563.65

PR

Load and display

Loading and displaying can be done with the same code as for .glb files.

loadObjects(scene,"./dice.glb");

The specified input file mentioned above will be changed to the designated .gltf file.

The .bin file and texture files, which are created simultaneously when saving the .gltf file, do not need to be specified in the source code.

When saving a .gltf file in Blender, the .bin file and texture files are saved in the same folder. All saved files need to be uploaded to the server.

Pay particular attention to the texture files, as they are easily overlooked; they are saved in the same folder as the original .blend file.

PR

Related page

Blenderで作成した3DオブジェクトをThreejsで読込、表示するまとめ

comment

Copied title and URL