ThreeJS GLTF Exporter and Face Materialindex - three.js

The materialindex for every face of a model exported from Blender using the GLTF exporter is returning 0 for me. Is that correct? The model is using 6 different materials.

Related

Substitute for the geometry property when working with a GLTF/GLB model in ThreeJS?

I have the following code in my ThreeJS scene that I use for computing the center of a 3D object, by getting its bounding box first:
const geometry = threeJsMesh.geometry;
geometry.computeBoundingBox();
This has worked fine for me with the cubes, planes, spheres, etc. I have created for my ThreeJS world. But I am now working with 3D models and when I tried to execute that code on a GLTF/GLB model I have in the world, I discovered that its geometry property was undefined.
So I take it that 3D models don't have a geometry property? If so, how can I computer the bounding box of a 3D model and also its center point?

Threejs Imported GLTF Model metal material turned black

in threejs imported GLTF model downloaded from sketchfab model looks good in blender but in Threejs metal materials turned black. how to fix this

Draco (gltf 2.0) texture appears rotated after importing from Blender

As it is well known, threejs.org recommends using gltf for models.
I'm trying to use a simple shape (plane) with a texture.
When I export from Blender 2.97b the shape appears 180 degrees rotated so I rotate the shape in Blender to avoid rotating it in three.js.
The real problem is that the texture always appears rotated vs the mesh, no matter what I tried. Has anyone imported gltf from Blender? I wonder if anything will ever work properly when using Blender...
Blender export settings I use for gltf 2.0:
export selected only
convert z-up to y-up
export texture coordinates
export normals
export materials
I have installed pipeline via node.js and each time I convert and compress to .glb based on the Khronos info here:enter link description here
I also use a Three.MeshBasicMaterial and assign the png image as a map.

3d max collada with animation and texture not working with threejs

I have the collada pump example working fine. I'm now trying to export an animated dice with 1 texture but in the threejs I only see the shape of the dice with no texture. The animation works fine.
Also the lighting on the dice looks wrong.
I can load the collada file in other program with no problems.
I'm using this version of threejs: https://cdnjs.cloudflare.com/ajax/libs/three.js/r72/three.js
anyone?
ADDED: I have create an example with a cube and one texture. In this example you can see that the texture is not on the cube: http://sigmaphp.dk/threejscollada.zip

How do you export and load models with custom materials in three.js?

How can I export a 3d model e.g. from Maya with custom materials, load them in three.js and apply all materials?
All examples that can be found on threejs.org are using hardcoded materials for the child elements of the geometry. Is there any library or 3d format to export custom materials with my own parameters and load them in three.js?
This seems to be a common problem in 3d programming. I guess I need to develop my own material editor for three.js if I want more complex 3d objects with more than Lambert or Phong materials.
Any thoughts?

Resources