Hello, I am just a beginner of Three.js.
I am trying to change material colors with mouse click and change it back to original colors with click again.
I could change colors but could not find the way to store original colors as attribution of the group which gltf loader loads.
I choose Float32Array to contain RGB info of each material has, but do not know how to attach it to the group.
So, could anyone give ne any advise?
Here is my code:
let materialColors;
gltfLoader.load(
"MiniCar.glb",
(glb) =>
{
const sceneObject = glb.scene;
const len = sceneObject.children[0].children.length;
materialColors = new Float32Array(len * 3)
for(let i=0; i < len; i++)
{
const i3 = i * 3;
let colors = new Vector3;
colors = sceneObject.children[0].children[i].material.color;
materialColors[i3 ]= colors.r;
materialColors[i3 + 1]= colors.g;
materialColors[i3 + 2]= colors.b;
}
/// I would like to attach color attribution here
scene.add(sceneObject);
});