|
|
@@ -23,7 +23,7 @@ const _matrixWorldInv = /*@__PURE__*/ new Matrix4();
|
|
|
class SkeletonHelper extends LineSegments {
|
|
|
|
|
|
/**
|
|
|
- * Constructs a new hemisphere light helper.
|
|
|
+ * Constructs a new skeleton helper.
|
|
|
*
|
|
|
* @param {Object3D} object - Usually an instance of {@link SkinnedMesh}. However, any 3D object
|
|
|
* can be used if it represents a hierarchy of bones (see {@link Bone}).
|
|
|
@@ -37,9 +37,6 @@ class SkeletonHelper extends LineSegments {
|
|
|
const vertices = [];
|
|
|
const colors = [];
|
|
|
|
|
|
- const color1 = new Color( 0, 0, 1 );
|
|
|
- const color2 = new Color( 0, 1, 0 );
|
|
|
-
|
|
|
for ( let i = 0; i < bones.length; i ++ ) {
|
|
|
|
|
|
const bone = bones[ i ];
|
|
|
@@ -48,8 +45,8 @@ class SkeletonHelper extends LineSegments {
|
|
|
|
|
|
vertices.push( 0, 0, 0 );
|
|
|
vertices.push( 0, 0, 0 );
|
|
|
- colors.push( color1.r, color1.g, color1.b );
|
|
|
- colors.push( color2.r, color2.g, color2.b );
|
|
|
+ colors.push( 0, 0, 0 );
|
|
|
+ colors.push( 0, 0, 0 );
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -90,6 +87,13 @@ class SkeletonHelper extends LineSegments {
|
|
|
this.matrix = object.matrixWorld;
|
|
|
this.matrixAutoUpdate = false;
|
|
|
|
|
|
+ // colors
|
|
|
+
|
|
|
+ const color1 = new Color( 0x0000ff );
|
|
|
+ const color2 = new Color( 0x00ff00 );
|
|
|
+
|
|
|
+ this.setColors( color1, color2 );
|
|
|
+
|
|
|
}
|
|
|
|
|
|
updateMatrixWorld( force ) {
|
|
|
@@ -127,6 +131,31 @@ class SkeletonHelper extends LineSegments {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Defines the colors of the helper.
|
|
|
+ *
|
|
|
+ * @param {Color} color1 - The first line color for each bone.
|
|
|
+ * @param {Color} color2 - The second line color for each bone.
|
|
|
+ * @return {SkeletonHelper} A reference to this helper.
|
|
|
+ */
|
|
|
+ setColors( color1, color2 ) {
|
|
|
+
|
|
|
+ const geometry = this.geometry;
|
|
|
+ const colorAttribute = geometry.getAttribute( 'color' );
|
|
|
+
|
|
|
+ for ( let i = 0; i < colorAttribute.count; i += 2 ) {
|
|
|
+
|
|
|
+ colorAttribute.setXYZ( i, color1.r, color1.g, color1.b );
|
|
|
+ colorAttribute.setXYZ( i + 1, color2.r, color2.g, color2.b );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ colorAttribute.needsUpdate = true;
|
|
|
+
|
|
|
+ return this;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Frees the GPU-related resources allocated by this instance. Call this
|
|
|
* method whenever this instance is no longer used in your app.
|