Can I change my GLB Model Color on runtime?

Hello Reader,
I’ve been working on three.js and successfully loaded my GLB model, but now I want to change its color during runtime, can someone guide me with it please?
This is my model:
https://drive.google.com/drive/folders/1dtldVoBYCpS7WwJNX5yqLYaE9TIm8Pqp?usp=sharing

warm regards.

Since your glTF asset consists of more than one mesh, use the following approach in your onLoad() callback:

root.traverse( ( object ) => {

	if ( object.isMesh ) {

		object.material.color.set( 0xffffff * Math.random() );

	}

} );

This will set a random color to the different materials which makes it easier to see how the asset is composed.

2 Likes

Thank you so much for the reply, but my question is how can I change the mesh color during runtime?

Well, you can use the same code if you want to change to color during animation.