Import a 3D Model and automatically assign and export animations
TypeScript
Better UI description and tooltip. Add grid to plane preview. Use 2 decimal places for finer control
Scott Petrovic4017981a9631
diff --git a/src/create.html b/src/create.htmlindex e6b01d5..31b6488 100644--- a/src/create.html+++ b/src/create.html@@ -268,13 +268,14 @@<div style="display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem;"><div class="styled-checkbox"><input type="checkbox" id="preview-plane-checkbox" />- <label for="preview-plane-checkbox">Show Preview Plane</label>+ <label for="preview-plane-checkbox">Use Head Weight Correction</label>+ <span class="material-symbols-outlined" data-tippy-content="If you are having issues with the arms distorting your head (e.g. chibi characters), use a divider to help define the head area.">help</span></div><div style="display: flex; align-items: center; gap: 0.5rem;"><label for="preview-plane-height-input">Plane Height:</label><input type="range" id="preview-plane-height-input" min="0.20" max="2.00" step="0.01" value="0.50" />- <span id="preview-plane-height-label">0.50</span>+ <span id="preview-plane-height-label" style="width: 2rem;">0.50</span></div></div>diff --git a/src/lib/processes/edit-skeleton/PreviewPlaneManager.ts b/src/lib/processes/edit-skeleton/PreviewPlaneManager.tsindex 8920a5c..afb62ed 100644--- a/src/lib/processes/edit-skeleton/PreviewPlaneManager.ts+++ b/src/lib/processes/edit-skeleton/PreviewPlaneManager.ts@@ -1,4 +1,4 @@-import { Group, Mesh, PlaneGeometry, MeshBasicMaterial, type Scene, DoubleSide } from 'three'+import { Group, Mesh, PlaneGeometry, MeshBasicMaterial, type Scene, DoubleSide, GridHelper } from 'three'/*** PreviewPlaneManager - Singleton class for managing a preview 3D plane in the edit skeleton step@@ -12,6 +12,7 @@ export class PreviewPlaneManager {private scene_ref: Scene | null = nullprivate plane_group: Group | null = nullprivate plane_mesh: Mesh | null = null+ private grid_helper: GridHelper | null = nullprivate current_height: number = 0.0private current_size: number = 2.0private is_visible: boolean = false@@ -59,7 +60,7 @@ export class PreviewPlaneManager {this.plane_group = new Group()this.plane_group.name = this.preview_plane_group_name- // Create plane geometry and material+ // Create solid plane geometry and materialconst geometry = new PlaneGeometry(size, size)const material = new MeshBasicMaterial({color: 0x00ff00, // Green color for visibility@@ -69,7 +70,7 @@ export class PreviewPlaneManager {wireframe: false})- // Create the plane mesh+ // Create the solid plane meshthis.plane_mesh = new Mesh(geometry, material)this.plane_mesh.name = 'preview_plane'@@ -79,9 +80,20 @@ export class PreviewPlaneManager {// Rotate the plane to be horizontal (lying flat)this.plane_mesh.rotation.x = -Math.PI / 2- // Add plane to the group and group to scene+ // Create grid helper for rectangular grid lines+ const grid_divisions = 15 // Number of divisions+ this.grid_helper = new GridHelper(size, grid_divisions, 0x888888, 0x888888) // Gray grid+ this.grid_helper.name = 'preview_plane_grid'++ // Position the grid at the specified height (GridHelper is already horizontal)+ this.grid_helper.position.set(0, height, 0)++ // Add both the plane and grid to the group and group to scenethis.plane_group.add(this.plane_mesh)- this.scene_ref.add(this.plane_group)+ this.plane_group.add(this.grid_helper)++ // main scene to add to+ this.scene_ref.add(this.plane_group)return this.plane_mesh}@@ -91,8 +103,9 @@ export class PreviewPlaneManager {* @param height The new height position for the plane*/public update_height (height: number): void {- if (this.plane_mesh !== null && this.is_visible) {+ if (this.plane_mesh !== null && this.grid_helper !== null && this.is_visible) {this.plane_mesh.position.y = height+ this.grid_helper.position.y = height // Grid and plane at same height since no z-fightingthis.current_height = height}}@@ -102,11 +115,23 @@ export class PreviewPlaneManager {* @param size The new size for the plane*/public update_size (size: number): void {- if (this.plane_mesh !== null && this.is_visible) {- // Update the geometry with new size+ if (this.plane_mesh !== null && this.grid_helper !== null && this.is_visible) {+ // Update the solid plane geometryconst new_geometry = new PlaneGeometry(size, size)this.plane_mesh.geometry.dispose() // Clean up old geometrythis.plane_mesh.geometry = new_geometry++ // For GridHelper, we need to recreate it with new size+ const current_height = this.grid_helper.position.y+ this.plane_group?.remove(this.grid_helper)+ this.grid_helper.dispose() // Clean up old grid++ const grid_divisions = 10+ this.grid_helper = new GridHelper(size, grid_divisions, 0x888888, 0x888888)+ this.grid_helper.name = 'preview_plane_grid'+ this.grid_helper.position.set(0, current_height, 0)+ this.plane_group?.add(this.grid_helper)+this.current_size = size}}@@ -154,7 +179,7 @@ export class PreviewPlaneManager {*/public remove_plane (): void {if (this.plane_group !== null && this.scene_ref !== null) {- // Clean up geometry and material before removing+ // Clean up solid plane geometry and materialif (this.plane_mesh !== null) {this.plane_mesh.geometry.dispose()if (this.plane_mesh.material instanceof MeshBasicMaterial) {@@ -162,9 +187,15 @@ export class PreviewPlaneManager {}}+ // Clean up grid helper+ if (this.grid_helper !== null) {+ this.grid_helper.dispose()+ }+this.scene_ref.remove(this.plane_group)this.plane_group = nullthis.plane_mesh = null+ this.grid_helper = nullthis.is_visible = false}}@@ -176,7 +207,7 @@ export class PreviewPlaneManager {this.remove_plane()this.scene_ref = nullthis.current_height = 0.0- this.current_size = 5.0+ this.current_size = 2.0this.is_visible = false}}diff --git a/src/lib/processes/edit-skeleton/StepEditSkeleton.ts b/src/lib/processes/edit-skeleton/StepEditSkeleton.tsindex 16e7e3d..84e7c83 100644--- a/src/lib/processes/edit-skeleton/StepEditSkeleton.ts+++ b/src/lib/processes/edit-skeleton/StepEditSkeleton.ts@@ -282,7 +282,7 @@ export class StepEditSkeleton extends EventTarget {// Update the label to show current valueif (this.ui.dom_preview_plane_height_label !== null) {- this.ui.dom_preview_plane_height_label.textContent = final_height.toFixed(1)+ this.ui.dom_preview_plane_height_label.textContent = final_height.toFixed(2)}})}