mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-11 20:32:12 +00:00
Add a blacklist filter for the FK bones
This commit is contained in:
1 parent
06ca3be4f5
commit
d773c4ddfe
2 files changed
+36
No files matched your search
@@ -0,0 +1,23 @@
|
||||
export const FKBoneBlacklistStrings = [
|
||||
"def",
|
||||
"toe_end",
|
||||
"thumb",
|
||||
"index",
|
||||
"handmiddle",
|
||||
"handring",
|
||||
"pinky",
|
||||
"headtop",
|
||||
"ear",
|
||||
"teeth",
|
||||
"eye",
|
||||
"lid",
|
||||
"jaw",
|
||||
"tongue",
|
||||
"lip",
|
||||
"chin",
|
||||
"brow",
|
||||
"cheek",
|
||||
"forehead",
|
||||
"nose",
|
||||
"temple"
|
||||
];
|
||||
@@ -1,5 +1,6 @@
|
||||
import { TransformControls } from "three/examples/jsm/Addons";
|
||||
import * as THREE from "three";
|
||||
import { FKBoneBlacklistSet, FKBoneBlacklistStrings } from "./FKBoneFilter";
|
||||
|
||||
export const FKHelperSphereName = "__FKHelperSphere__";
|
||||
|
||||
@@ -50,10 +51,21 @@ export class FKHelper {
|
||||
// TODO: Highlight all the necessary bones
|
||||
this.clear();
|
||||
target.traverse((child) => {
|
||||
// Skip if not bone
|
||||
if (child.type !== "Bone") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip if bones is one of the blacklisted ones
|
||||
// This step could probably be optimized better
|
||||
for (const blacklistedBone of FKBoneBlacklistStrings) {
|
||||
if (child.name.toLowerCase().includes(blacklistedBone)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(child.name);
|
||||
|
||||
// For each target bone, display a sphere to show the FK target and raycast intersect
|
||||
const geometry = new THREE.SphereGeometry(0.015, 16, 16);
|
||||
const material = new THREE.MeshBasicMaterial({ color: 0xff0000, depthTest: false, transparent: true });
|
||||
@@ -75,6 +87,7 @@ export class FKHelper {
|
||||
|
||||
this.skeletonHelper = new THREE.SkeletonHelper(target);
|
||||
this.scene.add(this.skeletonHelper);
|
||||
console.log("All bones:", this.skeletonHelper.bones.map((b) => b.name));
|
||||
}
|
||||
|
||||
onMouseClick(mouse: THREE.Vector2) {
|
||||
|
||||
Reference in new issue
Block a user