Created
March 2, 2014 22:51
-
-
Save sgrif/9315186 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 THREE.BoneHelper extends THREE.Object3D | |
constructor: (@bone, @size) -> | |
super() | |
@size ?= 1 | |
cubeGeometry = new THREE.CubeGeometry(@size, @size, @size) | |
cubeMaterial = new THREE.MeshBasicMaterial() | |
@cube = new THREE.Mesh(cubeGeometry, cubeMaterial) | |
@cube.matrixAutoUpdate = false | |
@add(@cube) | |
@update() | |
update: => | |
@cube.matrix.copy(@bone.skinMatrix) | |
@remove(@line) if @line? | |
if @bone.parent instanceof THREE.Bone | |
lineMaterial = new THREE.LineBasicMaterial() | |
lineGeometry = new THREE.Geometry() | |
lineGeometry.vertices.push(new THREE.Vector3().getPositionFromMatrix(@bone.skinMatrix)) | |
lineGeometry.vertices.push(new THREE.Vector3().getPositionFromMatrix(@bone.parent.skinMatrix)) | |
@line = new THREE.Line(lineGeometry, lineMaterial) | |
@add(@line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment