简体   繁体   中英

Changing face colors during run-time in Three.js on a model imported from blender

I've imported a model of a soccer ball (truncated icosahedron) from blender (via JSON loader) and I wanted to change the face colors upon clicking. The faces are correctly identified I can change the color of the entire model but not particular faces. I have dug a bit deeper and I found that the colors are correctly assigned to soccerball.geometry.faces[i] but the new face colors are not shown.

I've gone through all of the similar threads and tried all of the proposed solutions (different materials, dirtyColors, dynamic, colorsNeedUpdate, etc.) but nothing helped.

this is how I import the model:

var loader = new THREE.JSONLoader(  );
var onGeometry = function(geom) {
soccer = new THREE.Mesh( geom, new THREE.MeshLambertMaterial());
soccer.position.set( 0, 0, 0 );
soccer.scale.set( 2, 2, 2 );
soccer.geometry.dynamic  = true;
soccer.geometry.dirty = true;
soccer.overdraw = true;
objects.push(soccer);
scene.add(soccer);
};

loader.load("models/model.js", onGeometry);

Can you please help me? thanks in advance

soccer.material.vertexColors = THREE.VertexColors ;

or

soccer.material.vertexColors = THREE.FaceColors;

If that doesn't work then I'll need to havre the model itself to do some tests.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM