@@ -4,6 +4,11 @@ const VERSION = '0.0.0';
44import { Component , AutoIKComponent } from './ik.component.js' ;
55import { AutoIKChain , walkBoneChain } from './AutoIKChain.js' ;
66
7+ const quaternionZ180 = new THREE . Quaternion ( ) . setFromUnitVectors (
8+ new THREE . Vector3 ( 0 , 1 , 0 ) ,
9+ new THREE . Vector3 ( 0 , - 1 , 0 )
10+ ) ;
11+
712class Arm extends AutoIKComponent {
813 static get version ( ) { return VERSION ; }
914 constructor ( rig , options ) {
@@ -14,6 +19,14 @@ class Arm extends AutoIKComponent {
1419 // this.boneChain = walkBoneChain(this.from, this.to);
1520 // if (!this.boneChain.valid) throw new Error('invalid Arm bone chain: '+ [options.from, options.to]);
1621 // this.ik = new AutoIKChain(this.boneChain.lineage, this.target, this.options);
22+ this . ik . syncTail = ( ) => this . syncTail ( ) ;
23+ }
24+ syncTail ( ) {
25+ const { tail, target } = this . ik ;
26+ if ( ! target ) throw new Error ( '!target ' + tail . name ) ;
27+ tail . parent . updateMatrixWorld ( true ) ;
28+ tail . quaternion . copy ( getRelativeRotation ( target , tail . parent ) ) . multiply ( quaternionZ180 ) //this._armatureRelative(target).quaternion);//));
29+ tail . updateMatrixWorld ( true ) ;
1730 }
1831 // preSolve(time, deltaTime) {
1932 // this.ik.tick(time, deltaTime);
0 commit comments