Untitled
unknown
plain_text
13 days ago
1.3 kB
2
Indexable
import * as gfx from 'gophergfx' import { AnimatedBone } from './AnimatedBone'; import { AnimatedCharacter } from './AnimatedCharacter' export class JointSpaceAxesCharacter extends AnimatedCharacter { constructor() { super(); } public override addGeometryToAnimatedBone(bone: AnimatedBone): void { // Choose a base size for the axes. For the root, we enlarge the axes. let size = 0.15; if (bone.name === "root") { size *= 2; } // Create the axes geometry. const axes = gfx.Geometry3Factory.createAxes(size); // Retrieve the transform from bone space to joint space for this bone. // (This method should be provided by your BoneData.) const boneToJoint = this.boneData.boneSpaceToJointSpace(bone.name); // Convert the boneToJoint matrix to a quaternion. let jointQuat = new gfx.Quaternion(); jointQuat.setMatrix(boneToJoint); // Instead of setting localToParentMatrix, directly set the rotation. axes.rotation.copy(jointQuat); // Ensure the axes are at the bone's origin. axes.position.set(0, 0, 0); // Add the axes to the bone. bone.add(axes); } }
Editor is loading...
Leave a Comment