Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

have consistent debugging option for each skinning type. Bring back "show debug" option for skinning

Scott Petrovicfec9015f7947
diff --git a/src/index.html b/src/index.html
index 2bb05ab..e0939b1 100644
--- a/src/index.html
+++ b/src/index.html
@@ -151,15 +151,15 @@
<hr />
- <!-- checkbox for enabling weight skin debug mode. Hide for now since only bone envelope works-->
- <!-- <div style="display: flex; flex-direction: row">
+ <!-- checkbox for enabling weight skin debug mode. -->
+ <div class="styled-checkbox">
<input type="checkbox" id="debug-skinning-checkbox" >
- <label for="debug-skinning-checkbox">Debug Skinning</label>
+ <label for="debug-skinning-checkbox">Test Algorithm</label>
<div class="tooltip">
<span class="material-symbols-outlined" style="font-size: 16px;">help</span>
<span class="tooltiptext">Preview skinning cage with bone envelope</span>
</div>
- </div> -->
+ </div>
<button id="action_bind_pose" >Bind pose</button>
diff --git a/src/lib/processes/StepEditSkeleton.ts b/src/lib/processes/StepEditSkeleton.ts
index 9340fdd..047d665 100644
--- a/src/lib/processes/StepEditSkeleton.ts
+++ b/src/lib/processes/StepEditSkeleton.ts
@@ -63,7 +63,7 @@ export class StepEditSkeleton extends EventTarget {
private update_bind_button_text (): void {
if (this.show_debug && this.ui.dom_bind_pose_button !== null) {
- this.ui.dom_bind_pose_button.innerHTML = 'Test Skinning'
+ this.ui.dom_bind_pose_button.innerHTML = 'Test Skinning Algorithm &nbsp;&#x203a;'
return
}
diff --git a/src/lib/solvers/BoneWeightsByDistance.ts b/src/lib/solvers/BoneWeightsByDistance.ts
index c16f4a5..4c0f5bd 100644
--- a/src/lib/solvers/BoneWeightsByDistance.ts
+++ b/src/lib/solvers/BoneWeightsByDistance.ts
@@ -1,7 +1,8 @@
-import { Vector3 } from 'three'
+import { Vector3, type Points } from 'three'
import { Utility } from '../Utilities.js'
import { SkeletonType } from '../enums/SkeletonType.js'
import { AbstractAutoSkinSolver } from './AbstractAutoSkinSolver.js'
+import { Generators } from '../Generators.js'
export default class BoneWeightsByDistance extends AbstractAutoSkinSolver {
public calculate_indexes_and_weights (): number[][] {
@@ -43,9 +44,32 @@ export default class BoneWeightsByDistance extends AbstractAutoSkinSolver {
}
if (this.show_debug) {
- console.log('Assigned all the bones to vertices: ', this.get_bone_master_data())
+ this.debugging_scene_object.add(this.objects_to_show_for_debugging())
}
return [skin_indices, skin_weights]
}
+
+ private objects_to_show_for_debugging (): Points {
+ const debug_sphere_size: number = 0.2
+ const debug_color = 0xff0000 // vertices that are part of envelope
+
+ const vertex_points_to_show: Vector3[] = []
+
+ // Create a 10 random points to test that are hard-coded
+ for (let i = 0; i < 10; i++) {
+ const random_point: Vector3 = new Vector3(
+ Math.random() * 2 - 1,
+ Math.random() * 2 - 1,
+ Math.random() * 2 - 1
+ ).normalize().multiplyScalar(0.5)
+
+ vertex_points_to_show.push(random_point)
+ }
+
+ const debug_assigned_points: Points = Generators.create_spheres_for_points(vertex_points_to_show,
+ debug_sphere_size, debug_color, 'Vertices assigned to bone')
+
+ return debug_assigned_points
+ }
}
diff --git a/src/lib/solvers/BoneWeightsByDistanceChild.ts b/src/lib/solvers/BoneWeightsByDistanceChild.ts
index d59a5ba..d0b4adf 100644
--- a/src/lib/solvers/BoneWeightsByDistanceChild.ts
+++ b/src/lib/solvers/BoneWeightsByDistanceChild.ts
@@ -1,7 +1,8 @@
-import { Vector3 } from 'three'
+import { Vector3, type Points } from 'three'
import { Utility } from '../Utilities.js'
import { SkeletonType } from '../enums/SkeletonType.js'
import { AbstractAutoSkinSolver } from './AbstractAutoSkinSolver.js'
+import { Generators } from '../Generators.js'
/**
* BoneWeightsByDistanceChild
@@ -50,9 +51,32 @@ export default class BoneWeightsByDistanceChild extends AbstractAutoSkinSolver {
}
if (this.show_debug) {
- console.log('Assigned all the bones to vertices: ', this.get_bone_master_data())
+ this.debugging_scene_object.add(this.objects_to_show_for_debugging())
}
return [skin_indices, skin_weights]
}
+
+ private objects_to_show_for_debugging (): Points {
+ const debug_sphere_size: number = 0.2
+ const debug_color = 0xff00ff // vertices that are part of envelope
+
+ const vertex_points_to_show: Vector3[] = []
+
+ // Create a 10 random points to test that are hard-coded
+ for (let i = 0; i < 10; i++) {
+ const random_point: Vector3 = new Vector3(
+ Math.random() * 2 - 1,
+ Math.random() * 2 - 1,
+ Math.random() * 2 - 1
+ ).normalize().multiplyScalar(0.5)
+
+ vertex_points_to_show.push(random_point)
+ }
+
+ const debug_assigned_points: Points = Generators.create_spheres_for_points(vertex_points_to_show,
+ debug_sphere_size, debug_color, 'Vertices assigned to bone')
+
+ return debug_assigned_points
+ }
}