Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

Merge conflicts solved between origin/main into feature/87-skeleton-depth-slider

DarthMarino27ecb4ea142d
diff --cc src/Mesh2MotionEngine.ts
index 360de81,9c61ccf..f39a288
--- a/src/Mesh2MotionEngine.ts
+++ b/src/Mesh2MotionEngine.ts
@@@ -42,7 -43,7 +44,8 @@@ export class Mesh2MotionEngine
public readonly transform_controls: TransformControls = new TransformControls(this.camera, this.renderer.domElement)
public is_transform_controls_dragging: boolean = false
public readonly transform_controls_hover_distance: number = 0.02 // distance to hover over bones to select them
+ public is_model_gizmo_active: boolean = false
+ public readonly mesh_drag_bone_placement: MeshDragBonePlacement
public view_helper: CustomViewHelper | undefined // mini 3d view to help orient orthographic views
@@@ -266,27 -297,36 +301,57 @@@
}
}
+ // --- Model position gizmo (step 2) ---
+
+ public enable_model_gizmo (): void {
+ this.is_model_gizmo_active = true
+ this.transform_controls.attach(this.load_model_step.model_meshes())
+ this.transform_controls.setMode('translate')
+ this.transform_controls.enabled = true
+ }
+
+ private bake_and_disable_model_gizmo (): void {
+ const mesh_data = this.load_model_step.model_meshes()
+ const pos = mesh_data.position
+ if (pos.x !== 0 || pos.y !== 0 || pos.z !== 0) {
+ ModelCleanupUtility.translate_model_vertices(mesh_data, pos.x, pos.y, pos.z)
+ mesh_data.position.set(0, 0, 0)
+ }
+ this.is_model_gizmo_active = false
+ this.transform_controls.detach()
+ this.transform_controls.enabled = false
+ }
+
+ public handle_mesh_drag_mode_mouse_down (mouse_event: MouseEvent): void {
+ this.mesh_drag_bone_placement.handle_mouse_down(mouse_event)
+ }
+
+ public handle_mesh_drag_mode_mouse_move (mouse_event: MouseEvent): void {
+ this.mesh_drag_bone_placement.handle_mouse_move(mouse_event)
+ }
+
+ public handle_mesh_drag_mode_mouse_up (): void {
+ const did_end_drag = this.mesh_drag_bone_placement.handle_mouse_up()
+
+ if (!did_end_drag) {
+ return
+ }
+
+ if (this.process_step === ProcessStep.EditSkeleton &&
+ this.mesh_preview_display_type === ModelPreviewDisplay.WeightPainted) {
+ this.regenerate_weight_painted_preview_mesh()
+ }
+ }
+
+ public update_edit_bone_interaction_mode (): void {
+ this.mesh_drag_bone_placement.sync_interaction_mode(this.process_step, this.transform_controls)
+ this.is_transform_controls_dragging = false
+ }
+
+ public get is_mesh_drag_mode_dragging (): boolean {
+ return this.mesh_drag_bone_placement.is_dragging()
+ }
+
private show_skin_failure_message (bone_names_with_errors: string[], error_point_positions: Vector3[]): void {
// add the bone vertices as X markers to debugging object
const error_markers: Group = Generators.create_x_markers(error_point_positions, 0.02, 0xff0000)
diff --cc src/create.html
index c9e2b3c,bd6a0b4..7107aa8
--- a/src/create.html
+++ b/src/create.html
@@@ -1,94 -1,60 +1,85 @@@
-<!DOCTYPE html>
+<!doctype html>
<html lang="en">
-<head>
+ <head>
<title style="display: none">Create - Mesh2Motion</title>
- <link rel="icon" type="image/png" href="./images/favicon.png"/>
+ <link rel="icon" type="image/png" href="./images/favicon.png" />
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
-</head>
-<body style="margin: 0">
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ </head>
+ <body style="margin: 0">
<script type="module" src="./CustomModelUploadBootstrap.ts"></script>
<link href="./styles.css" rel="stylesheet" crossorigin="anonymous" />
- <link rel="stylesheet" href="./radio-button-group.css" crossorigin="anonymous" />
- <link rel="stylesheet" href="./animation-player.css" crossorigin="anonymous" />
+ <link
+ rel="stylesheet"
+ href="./radio-button-group.css"
+ crossorigin="anonymous"
+ />
+ <link
+ rel="stylesheet"
+ href="./animation-player.css"
+ crossorigin="anonymous"
+ />
<link rel="stylesheet" href="./dialog.css" crossorigin="anonymous" />
- <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" />
+ <link
+ rel="stylesheet"
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0"
+ />
<nav>
- <div style="display: inline-flex; align-items: center;">
- <a href="https://mesh2motion.org"><img src="./images/mesh2motion.svg" width="200" /></a>
- <a href="/">Explore</a>
- <span class="active-nav-item">Use Your Model</span>
- <a href="/retarget/index.html">Use Your Rigged Model</a>
- </div>
-
- <div style="display: inline-flex; align-items: center;">
- <a href="#" id="learn-link">Learn</a>
- <a href="#" id="attribution-link">Contributors</a>
- <a href="https://support.mesh2motion.org" target="_blank">πŸ’—</a>
- <a href="https://github.com/scottpetrovic/mesh2motion-app" target="_blank">
- <img src="../images/github-white-icon.png" width="24" height="24" alt="GitHub" />
- </a>
-
- <!-- Theme Toggle -->
- <button id="theme-toggle">
- <!-- icon will fill in here-->
- <span class="theme-icon"></span>
- </button>
- </div>
+ <div style="display: inline-flex; align-items: center">
+ <a href="https://mesh2motion.org"
+ ><img src="./images/mesh2motion.svg" width="200"
+ /></a>
+ <a href="/">Explore</a>
+ <span class="active-nav-item">Use Your Model</span>
+ <a href="/retarget/index.html">Use Your Rigged Model</a>
+ </div>
+
- <div style="display: inline-flex; align-items: center">
- <a href="https://support.mesh2motion.org" target="_blank">
- πŸ’— Support</a
- >
- <a
- href="https://github.com/scottpetrovic/mesh2motion-app"
- target="_blank"
- >
- <img
- src="../images/github-white-icon.png"
- width="24"
- height="24"
- alt="GitHub"
- />
- </a>
++ <div style="display: inline-flex; align-items: center;">
++ <a href="#" id="learn-link">Learn</a>
+ <a href="#" id="attribution-link">Contributors</a>
++ <a href="https://support.mesh2motion.org" target="_blank">πŸ’—</a>
++ <a href="https://github.com/scottpetrovic/mesh2motion-app" target="_blank">
++ <img src="../images/github-white-icon.png" width="24" height="24" alt="GitHub" />
++ </a>
+
+ <!-- Theme Toggle -->
+ <button id="theme-toggle">
+ <!-- icon will fill in here-->
+ <span class="theme-icon"></span>
+ </button>
+ </div>
</nav>
-
-
-
<!-- Top toolbar with mouse controls -->
<div id="header-ui">
- <div>
- <img class="nav-icon" src="/images/mouse-left.svg" style="vertical-align: middle;"/> Rotate
- </div>
-
- <div>
- <img class="nav-icon" src="/images/mouse-right.svg" style="vertical-align: middle;"/> Pan
- </div>
- <div>
- <img class="nav-icon" src="/images/mouse-middle.svg" style="vertical-align: middle;"/> Zoom
- </div>
+ <div>
+ <img
+ class="nav-icon"
+ src="/images/mouse-left.svg"
+ style="vertical-align: middle"
+ />
+ Rotate
+ </div>
+
+ <div>
+ <img
+ class="nav-icon"
+ src="/images/mouse-right.svg"
+ style="vertical-align: middle"
+ />
+ Pan
+ </div>
+ <div>
+ <img
+ class="nav-icon"
+ src="/images/mouse-middle.svg"
+ style="vertical-align: middle"
+ />
+ Zoom
+ </div>
</div>
<!-- Theme Toggle -->
@@@ -100,427 -66,257 +91,244 @@@
</div>
<div id="tool-panel">
- <!-- create a radio button group. There are two options. Move Skeleton, Rotate Mesh -->
- <div id="tool-selection-group">
-
- <div style="margin-bottom: 1rem; padding: 0;">
- <span id="current-step-index"></span>
- <span id="current-step-label"></span>
- </div>
-
- <div id="load-model-tools">
-
- <!-- <p class="step-instructions">Supports GLB, GLTF, FBX</p> -->
-
- <label for="model-upload" class="button" data-tippy-content="GLB and FBX preferred. ZIP is for GLTF+BIN and textures separately. DAE+textures is also supported in ZIP format." >
- <span class="button-icon-group">
- <span class="material-symbols-outlined" >upload</span>
- <span>Upload</span>
- <span class="material-symbols-outlined" >help</span>
- </span>
- </label>
- <input id="model-upload" type="file" name="file-upload" accept=".glb, .zip, .fbx" />
-
-
-
-
- <div style="text-align: center; font-size: 1.5rem">or</div>
-
- <div class="alternate-background-section">
- <p style="margin: 0">Reference model</p>
- <select id="model-selection">
- <!-- populated dynamically from RigConfig -->
- </select>
- <button id="load-model-button">Load</button>
- </div>
-
-
-
- <div class="styled-checkbox">
-
- <input type="checkbox" id="load-model-debug-checkbox" name="load-model-debug-checkbox">
- <label for="load-model-debug-checkbox">Debug</label>
-
- <span class="material-symbols-outlined" data-tippy-content="Replaces all materials with a 'normal' shader for debugging">help</span>
-
- </div>
-
- </div>
-
- <div id="load-skeleton-tools">
-
- <span>
- <span style="max-width: 220px">Rotate Model to face front <br/> (blue origin line)</span>
- <div style="display: flex; flex-direction: row">
- <button class="secondary-button" id="rotate-model-x-button">X</button>
- <button class="secondary-button" id="rotate-model-y-button">Y</button>
- <button class="secondary-button" id="rotate-model-z-button">Z</button>
- </div>
- </span>
-
- <hr />
-
- <span style="max-width: 220px">
- <span>If model is below the ground floor</span>
- <div style="display: flex; flex-direction: row">
- <button class="secondary-button" id="move-model-to-floor-button">Move</button>
- </div>
- </span>
-
- <hr />
-
-
- <div style="display: flex; flex-direction: column; gap: 1rem;">
- <span>Skeleton template</span>
- <select id="skeleton-selection">
- <!-- populated dynamically from RigConfig -->
- </select>
- </div>
-
-
- <!-- Hand skeleton options for human skeleton -->
- <div id="hand-skeleton-options" class="alternate-background-section" >
-
- <span style="display: flex; gap: 1rem;">
- <span>Hand Options</span>
- <span class="material-symbols-outlined" data-tippy-content="Variations on which finger bones you want to keep. Single Hand Bone removes all fingers and keeps only the hand bone.">help</span>
- </span>
-
- <select id="hand-skeleton-selection">
- <option value="all-fingers">All Fingers</option>
- <option value="thumb-and-index">Thumb + Main Finger</option>
- <option value="simplified-hand">All Fingers - Simplified</option>
- <option value="single-bone">Single Hand Bone</option>
- </select>
- </div>
-
-
- <!-- scale skeleton to get it close to the model size -->
- <div id="scale-skeleton-controls" style="display: none; flex-direction: column;">
- <div style="
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: center;
- gap: 1rem;
- ">
-
- <label style="display:inline-flex">Scale skeleton</label>
- <span class="material-symbols-outlined" data-tippy-content="Adjust the overall scale of the skeleton">help</span>
-
- <button class="secondary-button" id="reset-skeleton-scale-button">
- <img src="images/icons/reset.svg" alt="Reset Skeleton Scale" width="20" height="20" />
- </button>
-
- </div>
- <div style="display: flex; flex-direction: row; gap: 1rem; justify-content: flex-start; align-items: center;">
- <span id="scale-skeleton-percentage-display">100%</span>
- <input id="scale-skeleton-input" style="flex-grow: 1;" type="range" min=".10" max="2.00" value="1.0" step="0.01" />
- </div>
- </div>
-
-
- <div style="display: flex; gap: 0.5rem;">
- <button class="no-style-button" id="action_back_to_load_model" >&#x2039; Back</button>
- <button id="load-skeleton-button">Edit Skeleton &nbsp;&#x203a;</button>
- </div>
-
- </div>
-
-
- <span id="skeleton-step-actions">
-
- <!-- undo/redo system-->
- <fieldset style="position: fixed; right: 300px; top: 52px;">
- <div style="display: flex; gap: 2px;">
- <button id="undo-button" class="secondary-button" title="Undo (Ctrl+Z)" disabled>
- <img src="images/icons/undo.png" alt="Undo" width="16" height="16" />
- </button>
- <button id="redo-button" class="secondary-button" title="Redo (Ctrl+Y)" disabled>
- <img src="images/icons/redo.png" alt="Redo" width="16" height="16" />
- </button>
- </div>
- </fieldset>
-
- <!-- <p class="step-instructions">Move bones into position.</p> -->
-
- <p id="bone-selection-section">
- <span>Selected Bone: <span id="edit-selected-bone-label">None</span></span>
- </p>
-
- <div style="display: flex; flex-direction: column;">
-
- <div class="styled-checkbox">
- <input type="checkbox" id="mesh-drag-placement" name="mesh-drag-placement" value="mesh-drag-placement" checked>
- <label for="mesh-drag-placement">Position by mesh volume</label>
- </div>
-
- <div id="transform-manual-options" style="display: flex; flex-direction: row;">
- <fieldset>
- <span>Transform</span>
- <div id="transform-control-type-group" class="toggle">
- <input type="radio" name="transform-control-type" value="translate" id="transform-translate" checked="checked" />
- <label for="transform-translate">
- <img src="images/icons/tool-move.svg" alt="Translate" width="20" height="20" title="Translation" />
- </label>
- <input type="radio" name="transform-control-type" value="rotation" id="transform-rotate" />
- <label for="transform-rotate">
- <img src="images/icons/tool-rotate.svg" alt="Rotate" width="20" height="20" title="Rotation" />
- </label>
- </div>
- </fieldset>
-
- <fieldset>
- <span>Space</span>
- <div id="transform-space-group" class="toggle">
- <input type="radio" name="transform-space" value="global" id="transform-global" checked="checked" />
- <label for="transform-global">
- <img src="images/icons/tool-global.svg" alt="Global" width="20" height="20" title="Global" />
- </label>
- <input type="radio" name="transform-space" value="local" id="transform-local" />
- <label for="transform-local">
- <img src="images/icons/tool-local.svg" alt="Local" width="20" height="20" title="Local" />
- </label>
- </div>
- </fieldset>
- </div>
-
- </div>
-
- <hr />
-
- <!-- controls to change transfrom mode between transform and rotation -->
- <!-- View mode between textured mesh and weight painted mesh preview -->
- <fieldset style="display: flex; flex-direction: row;">
- <span>Preview</span>
-
- <span>
- <div id="mesh-preview-group" class="toggle">
- <input id="preview-painted" type="radio" name="mesh-preview-type" value="weight-painted" checked="checked" />
- <label for="preview-painted">
- <img src="images/icons/display-weight-painted.svg" alt="Weights" width="20" height="20" title="Weight painted mesh" />
- </label>
- <input id="preview-textured" type="radio" name="mesh-preview-type" value="textured" />
- <label for="preview-textured">
- <img src="images/icons/display-textured.svg" alt="Textured" width="20" height="20" title="Textured Mesh" />
- </label>
- </div>
- </span>
+ <!-- create a radio button group. There are two options. Move Skeleton, Rotate Mesh -->
+ <div id="tool-selection-group">
+ <div style="margin-bottom: 1rem; padding: 0">
+ <span id="current-step-index"></span>
+ <span id="current-step-label"></span>
+ </div>
+ <div id="load-model-tools">
+ <!-- <p class="step-instructions">Supports GLB, GLTF, FBX</p> -->
+
+ <label
+ for="model-upload"
+ class="button"
+ data-tippy-content="GLB and FBX preferred. ZIP is for GLTF+BIN and textures separately. DAE+textures is also supported in ZIP format."
+ >
+ <span class="button-icon-group">
+ <span class="material-symbols-outlined">upload</span>
+ <span>Upload</span>
+ <span class="material-symbols-outlined">help</span>
+ </span>
+ </label>
+ <input
+ id="model-upload"
+ type="file"
+ name="file-upload"
+ accept=".glb, .zip, .fbx"
+ />
+
+ <div style="text-align: center; font-size: 1.5rem">or</div>
+
+ <div class="alternate-background-section">
+ <p style="margin: 0">Reference model</p>
+ <select id="model-selection">
+ <option value="models/model-human.glb">Human</option>
+ <option value="models/model-fox.glb">Fox</option>
+ <option value="models/model-bird.glb">Bird</option>
+ <option value="models/model-dragon.glb">Dragon</option>
+ <option value="models/model-kaiju.glb">Kaiju</option>
+ </select>
+ <button id="load-model-button">Load</button>
+ </div>
+
+ <div class="styled-checkbox">
+ <input
+ type="checkbox"
+ id="load-model-debug-checkbox"
+ name="load-model-debug-checkbox"
+ />
+ <label for="load-model-debug-checkbox">Debug</label>
+
+ <span
+ class="material-symbols-outlined"
+ data-tippy-content="Replaces all materials with a 'normal' shader for debugging"
+ >help</span
+ >
+ </div>
+ </div>
- </fieldset>
-
+ <div id="load-skeleton-tools">
+ <span>
+ <span style="max-width: 220px"
+ >Rotate Model to face front <br />
+ (blue origin line)</span
+ >
+ <div style="display: flex; flex-direction: row">
+ <button class="secondary-button" id="rotate-model-x-button">
+ X
+ </button>
+ <button class="secondary-button" id="rotate-model-y-button">
+ Y
+ </button>
+ <button class="secondary-button" id="rotate-model-z-button">
+ Z
+ </button>
+ </div>
+ </span>
+
+ <hr />
+
+ <span style="max-width: 220px">
+ <span>Position model</span>
+ <div style="display: flex; flex-direction: column; gap: 0.5rem">
+ <button class="secondary-button" id="reset-model-position-button">
+ Reset position
+ </button>
+ <button class="secondary-button" id="auto-align-model-button">
+ Auto-align to floor
+ </button>
+ </div>
+ </span>
+
+ <hr />
+
- <div style="display: flex; flex-direction: column; gap: 1rem">
++ <div style="display: flex; flex-direction: column; gap: 1rem;">
+ <span>Skeleton template</span>
+ <select id="skeleton-selection">
- <option value="select-skeleton">Select a skeleton</option>
- <option value="human">Human</option>
- <option value="quadraped">4 Leg Creature</option>
- <option value="bird">Bird</option>
- <option value="dragon">Dragon</option>
- <option value="kaiju">Kaiju</option>
++ <!-- populated dynamically from RigConfig -->
+ </select>
+ </div>
+
+ <!-- Hand skeleton options for human skeleton -->
+ <div id="hand-skeleton-options" class="alternate-background-section">
- <span style="display: flex; gap: 1rem">
++ <span style="display: flex; gap: 1rem;">
+ <span>Hand Options</span>
- <span
- class="material-symbols-outlined"
- data-tippy-content="Variations on which finger bones you want to keep. Single Hand Bone removes all fingers and keeps only the hand bone."
- >help</span
- >
++ <span class="material-symbols-outlined" data-tippy-content="Variations on which finger bones you want to keep. Single Hand Bone removes all fingers and keeps only the hand bone.">help</span>
+ </span>
-
+ <select id="hand-skeleton-selection">
+ <option value="all-fingers">All Fingers</option>
+ <option value="thumb-and-index">Thumb + Main Finger</option>
+ <option value="simplified-hand">All Fingers - Simplified</option>
+ <option value="single-bone">Single Hand Bone</option>
+ </select>
+ </div>
+
+ <!-- scale skeleton to get it close to the model size -->
- <div
- id="scale-skeleton-controls"
- style="display: none; flex-direction: column"
- >
- <div
- style="
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: center;
- gap: 1rem;
- "
- >
- <label style="display: inline-flex">Scale skeleton</label>
- <span
- class="material-symbols-outlined"
- data-tippy-content="Adjust the overall scale of the skeleton"
- >help</span
- >
-
++ <div id="scale-skeleton-controls" style="display: none; flex-direction: column;">
++ <div style="display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 1rem;">
++ <label style="display:inline-flex">Scale skeleton</label>
++ <span class="material-symbols-outlined" data-tippy-content="Adjust the overall scale of the skeleton">help</span>
+ <button class="secondary-button" id="reset-skeleton-scale-button">
- <img
- src="images/icons/reset.svg"
- alt="Reset Skeleton Scale"
- width="20"
- height="20"
- />
++ <img src="images/icons/reset.svg" alt="Reset Skeleton Scale" width="20" height="20" />
+ </button>
+ </div>
- <div
- style="
- display: flex;
- flex-direction: row;
- gap: 1rem;
- justify-content: flex-start;
- align-items: center;
- "
- >
++ <div style="display: flex; flex-direction: row; gap: 1rem; justify-content: flex-start; align-items: center;">
+ <span id="scale-skeleton-percentage-display">100%</span>
- <input
- id="scale-skeleton-input"
- style="flex-grow: 1"
- type="range"
- min=".10"
- max="2.00"
- value="1.0"
- step="0.01"
- />
++ <input id="scale-skeleton-input" style="flex-grow: 1;" type="range" min=".10" max="2.00" value="1.0" step="0.01" />
+ </div>
+ </div>
- <div style="display: flex; gap: 0.5rem">
- <button class="no-style-button" id="action_back_to_load_model">
- &#x2039; Back
- </button>
- <button id="load-skeleton-button">
- Edit Skeleton &nbsp;&#x203a;
- </button>
+
++ <div style="display: flex; gap: 0.5rem;">
++ <button class="no-style-button" id="action_back_to_load_model">&#x2039; Back</button>
++ <button id="load-skeleton-button">Edit Skeleton &nbsp;&#x203a;</button>
+ </div>
+ </div>
-
+ <span id="skeleton-step-actions">
+ <!-- undo/redo system-->
- <fieldset style="position: fixed; right: 272px; top: 52px">
- <div style="display: flex; gap: 2px">
- <button
- id="undo-button"
- class="secondary-button"
- title="Undo (Ctrl+Z)"
- disabled
- >
- <img
- src="images/icons/undo.png"
- alt="Undo"
- width="16"
- height="16"
- />
++ <fieldset style="position: fixed; right: 300px; top: 52px;">
++ <div style="display: flex; gap: 2px;">
++ <button id="undo-button" class="secondary-button" title="Undo (Ctrl+Z)" disabled>
++ <img src="images/icons/undo.png" alt="Undo" width="16" height="16" />
+ </button>
- <button
- id="redo-button"
- class="secondary-button"
- title="Redo (Ctrl+Y)"
- disabled
- >
- <img
- src="images/icons/redo.png"
- alt="Redo"
- width="16"
- height="16"
- />
++ <button id="redo-button" class="secondary-button" title="Redo (Ctrl+Y)" disabled>
++ <img src="images/icons/redo.png" alt="Redo" width="16" height="16" />
+ </button>
+ </div>
+ </fieldset>
- <!-- <p class="step-instructions">Move bones into position.</p> -->
-
- <div class="styled-checkbox">
- <input type="checkbox" id="mirror-skeleton" name="mirror-skeleton" value="mirror" checked>
- <label for="mirror-skeleton">Mirror Left/Right Joints</label>
- </div>
+ <p id="bone-selection-section">
- <span
- >Selected Bone:
- <span id="edit-selected-bone-label">None</span></span
- >
++ <span>Selected Bone: <span id="edit-selected-bone-label">None</span></span>
+ </p>
- <!-- controls to change transfrom mode between transform and rotation -->
- <div style="display: flex; flex-direction: row">
- <!-- View mode between textured mesh and weight painted mesh preview -->
- <fieldset>
- <span>Preview</span>
- <div class="styled-checkbox">
- <input type="checkbox" id="independent-bone-movement" name="independent-bone-movement" value="independent" checked>
- <label for="independent-bone-movement">Move Bone Independently</label>
++ <div style="display: flex; flex-direction: column;">
++ <div class="styled-checkbox">
++ <input type="checkbox" id="mesh-drag-placement" name="mesh-drag-placement" value="mesh-drag-placement" checked>
++ <label for="mesh-drag-placement">Position by mesh volume</label>
++ </div>
++ <div id="transform-manual-options" style="display: flex; flex-direction: row;">
++ <fieldset>
++ <span>Transform</span>
++ <div id="transform-control-type-group" class="toggle">
++ <input type="radio" name="transform-control-type" value="translate" id="transform-translate" checked="checked" />
++ <label for="transform-translate">
++ <img src="images/icons/tool-move.svg" alt="Translate" width="20" height="20" title="Translation" />
++ </label>
++ <input type="radio" name="transform-control-type" value="rotation" id="transform-rotate" />
++ <label for="transform-rotate">
++ <img src="images/icons/tool-rotate.svg" alt="Rotate" width="20" height="20" title="Rotation" />
++ </label>
+ </div>
-
- <!-- Preview plane controls -->
- <div id="use-head-weight-correction-container" 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">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 id="preview-plane-setting-container" style="display: flex; align-items: center; gap: 0.5rem;">
- <label for="preview-plane-height-input">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" style="width: 2rem;">0.50</span>
- </div>
-
- <hr />
-
++ </fieldset>
++ <fieldset>
++ <span>Space</span>
++ <div id="transform-space-group" class="toggle">
++ <input type="radio" name="transform-space" value="global" id="transform-global" checked="checked" />
++ <label for="transform-global">
++ <img src="images/icons/tool-global.svg" alt="Global" width="20" height="20" title="Global" />
++ </label>
++ <input type="radio" name="transform-space" value="local" id="transform-local" />
++ <label for="transform-local">
++ <img src="images/icons/tool-local.svg" alt="Local" width="20" height="20" title="Local" />
++ </label>
+ </div>
++ </fieldset>
++ </div>
++ </div>
+
- <!-- back to load skeleton -->
- <div class="display: flex; gap: 0.5rem;">
- <button class="no-style-button" id="action_back_to_load_skeleton" >&#x2039; Back</button>
- <button id="action_bind_pose" >Bind pose</button>
- </div>
++ <hr />
+
++ <fieldset style="display: flex; flex-direction: row;">
++ <span>Preview</span>
++ <span>
+ <div id="mesh-preview-group" class="toggle">
- <input
- id="preview-painted"
- type="radio"
- name="mesh-preview-type"
- value="weight-painted"
- checked="checked"
- />
++ <input id="preview-painted" type="radio" name="mesh-preview-type" value="weight-painted" checked="checked" />
+ <label for="preview-painted">
- <img
- src="images/icons/display-weight-painted.svg"
- alt="Weights"
- width="20"
- height="20"
- title="Weight painted mesh"
- />
++ <img src="images/icons/display-weight-painted.svg" alt="Weights" width="20" height="20" title="Weight painted mesh" />
+ </label>
- <input
- id="preview-textured"
- type="radio"
- name="mesh-preview-type"
- value="textured"
- />
++ <input id="preview-textured" type="radio" name="mesh-preview-type" value="textured" />
+ <label for="preview-textured">
- <img
- src="images/icons/display-textured.svg"
- alt="Textured"
- width="20"
- height="20"
- title="Textured Mesh"
- />
- </label>
- </div>
- </fieldset>
-
- <fieldset>
- <span>Transform</span>
- <div id="transform-control-type-group" class="toggle">
- <input
- type="radio"
- name="transform-control-type"
- value="translate"
- id="transform-translate"
- checked="checked"
- />
- <label for="transform-translate">
- <img
- src="images/icons/tool-move.svg"
- alt="Translate"
- width="20"
- height="20"
- title="Translation"
- />
- </label>
- <input
- type="radio"
- name="transform-control-type"
- value="rotation"
- id="transform-rotate"
- />
- <label for="transform-rotate">
- <img
- src="images/icons/tool-rotate.svg"
- alt="Rotate"
- width="20"
- height="20"
- title="Rotation"
- />
- </label>
- </div>
- </fieldset>
-
- <fieldset>
- <span>Space</span>
- <div id="transform-space-group" class="toggle">
- <input
- type="radio"
- name="transform-space"
- value="global"
- id="transform-global"
- checked="checked"
- />
- <label for="transform-global">
- <img
- src="images/icons/tool-global.svg"
- alt="Global"
- width="20"
- height="20"
- title="Global"
- />
- </label>
- <input
- type="radio"
- name="transform-space"
- value="local"
- id="transform-local"
- />
- <label for="transform-local">
- <img
- src="images/icons/tool-local.svg"
- alt="Local"
- width="20"
- height="20"
- title="Local"
- />
++ <img src="images/icons/display-textured.svg" alt="Textured" width="20" height="20" title="Textured Mesh" />
+ </label>
+ </div>
- </fieldset>
- </div>
+ </span>
++ </fieldset>
+
+ <div class="styled-checkbox">
- <input
- type="checkbox"
- id="mirror-skeleton"
- name="mirror-skeleton"
- value="mirror"
- checked
- />
++ <input type="checkbox" id="mirror-skeleton" name="mirror-skeleton" value="mirror" checked>
+ <label for="mirror-skeleton">Mirror Left/Right Joints</label>
+ </div>
+
+ <div class="styled-checkbox">
- <input
- type="checkbox"
- id="independent-bone-movement"
- name="independent-bone-movement"
- value="independent"
- />
- <label for="independent-bone-movement"
- >Move Bone Independently</label
- >
++ <input type="checkbox" id="independent-bone-movement" name="independent-bone-movement" value="independent" checked>
++ <label for="independent-bone-movement">Move Bone Independently</label>
+ </div>
+
- <hr />
-
+ <!-- Preview plane controls -->
- <div
- id="use-head-weight-correction-container"
- style="
- display: flex;
- flex-direction: column;
- gap: 0.5rem;
- "
- >
++ <div id="use-head-weight-correction-container" 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"
- >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
- >
++ <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
- id="preview-plane-setting-container"
- style="display: flex; align-items: center; gap: 0.5rem"
- >
++ <div id="preview-plane-setting-container" style="display: flex; align-items: center; gap: 0.5rem;">
+ <label for="preview-plane-height-input">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" style="width: 2rem"
- >0.50</span
- >
++ <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" style="width: 2rem;">0.50</span>
+ </div>
-
+ <hr />
+ </div>
+
- <hr />
-
+ <!-- back to load skeleton -->
+ <div class="display: flex; gap: 0.5rem;">
- <button class="no-style-button" id="action_back_to_load_skeleton">
- &#x2039; Back
- </button>
++ <button class="no-style-button" id="action_back_to_load_skeleton">&#x2039; Back</button>
+ <button id="action_bind_pose">Bind pose</button>
+ </div>
+ </span>
- <!-- <span id="skinned-step-tools">
+ <!-- <span id="skinned-step-tools">
<p class="step-instructions">Select animations you want to export by checking them by animation</p>
</span> -->
diff --cc src/lib/processes/load-skeleton/PreviewSkeletonManager.ts
index 2b31d7f,27098c2..28abaca
--- a/src/lib/processes/load-skeleton/PreviewSkeletonManager.ts
+++ b/src/lib/processes/load-skeleton/PreviewSkeletonManager.ts
@@@ -11,24 -12,20 +12,24 @@@ const skeleton_group_name: string = 'pr
// and then add the new one based on the selected type
export async function add_preview_skeleton (
root: Scene,
- skeleton_file_path: SkeletonType,
+ skeleton_type: SkeletonType,
hand_skeleton_type: HandSkeletonType,
- skeleton_scale: number = 1.0
+ skeleton_scale: number = 1.0,
+ skeleton_offset_x: number = 0.0,
+ skeleton_offset_y: number = 0.0,
+ skeleton_offset_z: number = 0.0
): Promise<Object3D<Object3DEventMap>> {
let preview_skeleton_group = root.getObjectByName(skeleton_group_name) as Group | undefined
// Check if preview skeleton group exists and matches requested skeleton
if (preview_skeleton_group !== undefined) {
// Read previous skeleton info from userData
- const previous_file_path = preview_skeleton_group.userData.skeleton_file_path
+ const previous_file_path = preview_skeleton_group.userData.skeleton_type
const previous_hand_type = preview_skeleton_group.userData.hand_skeleton_type
- if (previous_file_path === skeleton_file_path && previous_hand_type === hand_skeleton_type) {
+ if (previous_file_path === skeleton_type && previous_hand_type === hand_skeleton_type) {
- // Only update scale
+ // Only update scale and offset
preview_skeleton_group.scale.set(skeleton_scale, skeleton_scale, skeleton_scale)
+ preview_skeleton_group.position.set(skeleton_offset_x, skeleton_offset_y, skeleton_offset_z)
// Return the first child (should be loaded_scene)
return preview_skeleton_group.children[0]
} else {