Import a 3D Model and automatically assign and export animations
TypeScript
Add reference rig images to help placement. Thinner joint image
Scott Petrovic700a27144f31
diff --git a/src/create.html b/src/create.htmlindex c516486..b7dd15a 100644--- a/src/create.html+++ b/src/create.html@@ -261,6 +261,11 @@</div></fieldset>+ <!-- reference image for people to see example of rig fitting on a model -->+ <div id="skeleton-template-image" class="skeleton-template-image-clickable">+ <img class="skeleton-template-image-preview ignore-filters" src="images/icons/zoom.svg" alt="Preview image" width="20" height="20" />+ </div>+<p id="bone-selection-section"><span>Selected Bone: <span id="edit-selected-bone-label">None</span></span></p>diff --git a/src/dialog.css b/src/dialog.cssindex 901f5bb..d144e1d 100644--- a/src/dialog.css+++ b/src/dialog.css@@ -202,4 +202,5 @@justify-content: flex-end;gap: 0.75rem;margin-top: 1rem;-}\ No newline at end of file+}+diff --git a/src/lib/RigConfig.ts b/src/lib/RigConfig.tsindex a6380d2..7ae660b 100644--- a/src/lib/RigConfig.ts+++ b/src/lib/RigConfig.ts@@ -8,6 +8,7 @@ export interface RigConfigEntry {rig_display_name: string // Display name shown in both the model and skeleton dropdownsanimation_files: string[] // Animation filenames (no base path) loaded for this rig typeanimation_preview_folder: string // Sub-folder name used when referencing animation preview thumbnails+ skeleton_template_image_url: string // URL for the skeleton template image shown in the edit skeleton step// The bone used for position tracking (e.g., 'hips' or 'head').// we only have one bone per rig that we allow position keyframes (besides root)position_tracking_bone_name: string@@ -30,6 +31,7 @@ export class RigConfig {animation_files: ['../animations/human-base-animations.glb', '../animations/human-addon-animations.glb'],animation_preview_folder: 'human',position_tracking_bone_name: 'pelvis',+ skeleton_template_image_url: 'rigs/reference/human.png',model_variations: humanVariations} satisfies RigConfigEntry,{@@ -40,6 +42,7 @@ export class RigConfig {animation_files: ['../animations/fox-animations.glb'],animation_preview_folder: 'fox',position_tracking_bone_name: 'hips',+ skeleton_template_image_url: 'rigs/reference/fox.png',model_variations: foxVariations} satisfies RigConfigEntry,{@@ -50,6 +53,7 @@ export class RigConfig {animation_files: ['../animations/bird-animations.glb'],animation_preview_folder: 'bird',position_tracking_bone_name: 'hips',+ skeleton_template_image_url: 'rigs/reference/bird.png',model_variations: birdVariations} satisfies RigConfigEntry,{@@ -60,6 +64,7 @@ export class RigConfig {animation_files: ['../animations/dragon-animations.glb'],animation_preview_folder: 'dragon',position_tracking_bone_name: 'hips',+ skeleton_template_image_url: 'rigs/reference/dragon.png',} satisfies RigConfigEntry,{skeleton_type: SkeletonType.Kaiju,@@ -69,6 +74,7 @@ export class RigConfig {animation_files: ['../animations/kaiju-animations.glb'],animation_preview_folder: 'kaiju',position_tracking_bone_name: 'hips',+ skeleton_template_image_url: 'rigs/reference/kaiju.png',model_variations: kaijuVariations} satisfies RigConfigEntry,{@@ -79,6 +85,7 @@ export class RigConfig {animation_files: ['../animations/spider-animations.glb'],animation_preview_folder: 'spider',position_tracking_bone_name: 'hips',+ skeleton_template_image_url: 'rigs/reference/spider.png',} satisfies RigConfigEntry,{skeleton_type: SkeletonType.Snake,@@ -88,6 +95,7 @@ export class RigConfig {animation_files: ['../animations/snake-animations.glb'],animation_preview_folder: 'snake',position_tracking_bone_name: 'head', // snake doesn't have hips, so we track position from the head instead+ skeleton_template_image_url: 'rigs/reference/snake.png',} satisfies RigConfigEntry,{skeleton_type: SkeletonType.Fish,@@ -97,6 +105,7 @@ export class RigConfig {animation_files: ['../animations/shark-animations.glb'],animation_preview_folder: 'shark',position_tracking_bone_name: 'pelvis',+ skeleton_template_image_url: 'rigs/reference/shark.png',model_variations: fishVariations} satisfies RigConfigEntry]diff --git a/src/lib/processes/edit-skeleton/StepEditSkeleton.ts b/src/lib/processes/edit-skeleton/StepEditSkeleton.tsindex 12d0de5..51465f5 100644--- a/src/lib/processes/edit-skeleton/StepEditSkeleton.ts+++ b/src/lib/processes/edit-skeleton/StepEditSkeleton.ts@@ -4,6 +4,7 @@ import { Utility } from '../../Utilities.ts'import { UndoRedoSystem } from './UndoRedoSystem.ts'import { PreviewPlaneManager } from './PreviewPlaneManager.ts'import { IndependentBoneMovement } from './IndependentBoneMovement.ts'+import { ModalDialog } from '../../ModalDialog.ts'import {Vector3,Euler,@@ -58,6 +59,10 @@ export class StepEditSkeleton extends EventTarget {private readonly preview_plane_manager: PreviewPlaneManager = PreviewPlaneManager.getInstance()public readonly independent_bone_movement: IndependentBoneMovement = new IndependentBoneMovement()+ // UI elements specific for this area+ private _current_skeleton_type: SkeletonType | null = null+ private dom_template_image: HTMLElement | null = null+constructor () {super()this.ui = UI.getInstance()@@ -112,14 +117,45 @@ export class StepEditSkeleton extends EventTarget {}}+ this.update_skeleton_template_image(skeleton_type)+// show/hide settings for the head correct depending on if it is checkedthis.show_preview_plane_options()}+ private update_skeleton_template_image(skeleton_type: SkeletonType): void {+ // figure out where the template image URL is at from the Rig Config+ const rig_config_entry = RigConfig.all.find(entry => entry.skeleton_type === skeleton_type)++ // update DOM element background image+ this.dom_template_image = document.getElementById('skeleton-template-image')+ if (this.dom_template_image !== null && rig_config_entry !== undefined) {+ this.dom_template_image.style.width = '250px'+ this.dom_template_image.style.height = '220px'+ this.dom_template_image.style.backgroundImage = `url(${ rig_config_entry.skeleton_template_image_url })`+ this.dom_template_image.style.backgroundSize = 'contain'+ this.dom_template_image.style.backgroundRepeat = 'no-repeat'+ this.dom_template_image.style.backgroundPosition = 'center'+ this.dom_template_image.style.cursor = 'pointer'++ // Remove existing click handler to avoid duplicates+ this.dom_template_image.onclick = null++ // Add click handler to open larger image in dialog+ this.dom_template_image.onclick = () => {+ const dialog = new ModalDialog(+ 'Rig Template',+ `<img class="ignore-filters" src="${rig_config_entry.skeleton_template_image_url}" style="max-width: 100%; height: auto; border-radius: 8px;">`+ )+ dialog.show()+ }+ }+ }+public begin (main_scene: Scene, skeleton_type: SkeletonType): void {this.update_ui_options_on_begin(skeleton_type)- // show UI elemnents for editing mesh+ // show UI elements for editing meshif (this.ui.dom_current_step_element != null) {this.ui.dom_current_step_element.innerHTML = 'Position Joints'diff --git a/src/styles.css b/src/styles.cssindex daf6272..c33c6e4 100644--- a/src/styles.css+++ b/src/styles.css@@ -57,6 +57,10 @@ body.light-theme img[src$=".png"] {filter: invert(0.7);}+img.ignore-filters {+ filter: none !important;+}+ul {padding: 0.5rem;}@@ -755,4 +759,26 @@ input[type="file"] {.nav-icon {width: var(--navigation-icon-size);height: var(--navigation-icon-size);+}+++/* Skeleton Template Image Styles */+.skeleton-template-image-clickable {+ position: relative;+ transition: border 0.2s ease;+ border: 2px solid transparent;+ border-radius: 4px;+}++.skeleton-template-image-clickable:hover {+ border: 2px solid var(--text-alternate);+}++.skeleton-template-image-preview {+ position: absolute;+ bottom: 8px;+ right: 8px;+ background: rgb(0 0 0 / 26%);+ border-radius: 4px;+ padding: 6px;}\ No newline at end of filediff --git a/static/images/icons/zoom.svg b/static/images/icons/zoom.svgnew file mode 100644index 0000000..672a1ab--- /dev/null+++ b/static/images/icons/zoom.svg@@ -0,0 +1 @@+<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg width="100%" height="100%" viewBox="0 0 128 128" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;"><rect id="Zoom" x="0" y="0" width="128" height="128" style="fill:none;"/><path d="M76.252,7.751c20.908,0 37.882,16.974 37.882,37.882c0,20.908 -16.974,37.882 -37.882,37.882c-20.908,0 -37.882,-16.974 -37.882,-37.882c0,-20.908 16.974,-37.882 37.882,-37.882Zm0,12c-14.285,0 -25.882,11.597 -25.882,25.882c0,14.285 11.597,25.882 25.882,25.882c14.285,0 25.882,-11.597 25.882,-25.882c0,-14.285 -11.597,-25.882 -25.882,-25.882Z" style="fill:#e4e4e4;"/><path d="M54.235,88.747l-25.857,31.154l-16.309,-13.537l25.857,-31.154l16.309,13.537Z" style="fill:#e2e2e2;"/></svg>\ No newline at end of filediff --git a/static/images/skeleton-joint-point.png b/static/images/skeleton-joint-point.pngindex 9edf2e3..e69a1ab 100644Binary files a/static/images/skeleton-joint-point.png and b/static/images/skeleton-joint-point.png differdiff --git a/static/rigs/reference/bird.png b/static/rigs/reference/bird.pngnew file mode 100644index 0000000..50c5241Binary files /dev/null and b/static/rigs/reference/bird.png differdiff --git a/static/rigs/reference/dragon.png b/static/rigs/reference/dragon.pngnew file mode 100644index 0000000..323084cBinary files /dev/null and b/static/rigs/reference/dragon.png differdiff --git a/static/rigs/reference/fox.png b/static/rigs/reference/fox.pngnew file mode 100644index 0000000..e1c5105Binary files /dev/null and b/static/rigs/reference/fox.png differdiff --git a/static/rigs/reference/human.png b/static/rigs/reference/human.pngnew file mode 100644index 0000000..8d0af69Binary files /dev/null and b/static/rigs/reference/human.png differdiff --git a/static/rigs/reference/kaiju.png b/static/rigs/reference/kaiju.pngnew file mode 100644index 0000000..c380400Binary files /dev/null and b/static/rigs/reference/kaiju.png differdiff --git a/static/rigs/reference/shark.png b/static/rigs/reference/shark.pngnew file mode 100644index 0000000..8925403Binary files /dev/null and b/static/rigs/reference/shark.png differdiff --git a/static/rigs/reference/snake.png b/static/rigs/reference/snake.pngnew file mode 100644index 0000000..c0a7789Binary files /dev/null and b/static/rigs/reference/snake.png differdiff --git a/static/rigs/reference/spider.png b/static/rigs/reference/spider.pngnew file mode 100644index 0000000..30104d6Binary files /dev/null and b/static/rigs/reference/spider.png differ