Skip to content

Commit 3a7835a

Browse files
author
Avaer Kazmer
committed
Bugfix avatars tail sync
1 parent cc45354 commit 3a7835a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

proto/ik.component.Arms.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ const VERSION = '0.0.0';
44
import { Component, AutoIKComponent } from './ik.component.js';
55
import { 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+
712
class 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

Comments
 (0)