Last active
March 21, 2016 09:46
-
-
Save sdcb/8fbaeafff8b5a63b5e8f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FaceColorBoxGeometry extends THREE.BoxGeometry { | |
constructor(width: number, height: number, depth: number, widthSegments?: number, heightSegments?: number, depthSegments?: number) { | |
super(width, height, depth, widthSegments, heightSegments, depthSegments); | |
for (let face of this.faces) { | |
let color = new THREE.Color(); | |
if (face.normal.x < 0 || face.normal.y < 0 || face.normal.z < 0) { | |
color.setRGB(1, 1, 1); | |
if (face.normal.x < 0) color.r = 0; | |
if (face.normal.y < 0) color.g = 0; | |
if (face.normal.z < 0) color.b = 0; | |
} else { | |
color.setRGB(face.normal.x, face.normal.y, face.normal.z); | |
} | |
face.color = color; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment