I'm trying to apply different material on front and back sides of extruded shape, but cannot figure out where to put side: THREE.FrontSide
and side: THREE.BackSide
. Where they should be putted?
My relevant code part is:
var materialFront = new THREE.MeshPhongMaterial({ ambient: 0xffffff, map: frontTexture }); var materialSide = new THREE.MeshPhongMaterial({color: 0xE68A00, ambient: 0xffffff}); var extrusionSettings = { amount: 10, bevelEnabled: false, bevelThickness: 0.2, bevelSize: 0.2, bevelSegments: 8, material: 0, extrudeMaterial: 1 }; var geometry = new THREE.ExtrudeGeometry(shapes, extrusionSettings); var materials = [materialFront, materialSide]; var material = new THREE.MeshFaceMaterial(materials); mesh = new THREE.Mesh(geometry, material);
UPDATE: According to WestLangley's comment I succeeded in adding the different texture to backfaces:
// ... var materials = [materialFront, materialSide, materialBack]; // ... for ( var face in mesh.geometry.faces ) { if (mesh.geometry.faces[ face ].normal.z == 1) mesh.geometry.faces[ face ].materialIndex = 2; }
THREE.FrontSide
refers to the front side of aface
, not the front side of amesh
orshape
. What is not working, exactly? – WestLangleymaterialFront
is also there. I'd want to add a different material on the backside of the mesh, like the dice cube in stemkoski.github.io/Three.js/Textures.html. – Timo Kähkönen