Import a 3D Model and automatically assign and export animations
TypeScript
add in a prop attachment. get base functionality working
Scott Petrovic1bc3d8899d15
diff --git a/src/create.html b/src/create.htmlindex 0403c29..3879f0f 100644--- a/src/create.html+++ b/src/create.html@@ -23,6 +23,7 @@<link rel="stylesheet" href="./dialog.css" crossorigin="anonymous" /><link rel="stylesheet" href="./settings-dropdown.css" crossorigin="anonymous" /><link rel="stylesheet" href="./offline.css" crossorigin="anonymous" />+ <link rel="stylesheet" href="./lib/processes/animations-listing/props/props.css" crossorigin="anonymous" /><nav>@@ -365,6 +366,8 @@<!-- slider to control arm extension. shared with the retarget workflow --><div id="arm-extension-mount"></div>+ <div id="props-panel-mount"></div>+<div class="download-actions-row"><button class="no-style-button" id="action_back_to_edit_skeleton">‹ Back@@ -410,6 +413,17 @@style="display: none"/>+ <button+ class="secondary-button"+ id="props-toggle-button"+ style="display: none"+ aria-expanded="false"+ data-tippy-content="Attach props to the hands"+ aria-label="Attach props to the hands"+ >+ <img src="images/icons/props.svg" alt="Props" width="16" height="16" />+ </button>+<div id="download-control-mount"></div></div></div>diff --git a/src/index.html b/src/index.htmlindex b748e33..d587f91 100644--- a/src/index.html+++ b/src/index.html@@ -19,6 +19,7 @@<link rel="stylesheet" href="./settings-dropdown.css" crossorigin="anonymous" /><link rel="stylesheet" href="./marketing/marketing.css" crossorigin="anonymous" /><link rel="stylesheet" href="./offline.css" crossorigin="anonymous" />+ <link rel="stylesheet" href="./lib/processes/animations-listing/props/props.css" crossorigin="anonymous" /><nav><div style="display: inline-flex; align-items: center;">@@ -145,8 +146,7 @@that we get from the animations file(s) --><div id="animations-items"> </div>--+ <div id="props-panel-mount"></div><div class="download-actions-row">@@ -163,6 +163,10 @@</button><input id="import-animations-input" type="file" accept=".glb" multiple style="display:none" />+ <button class="secondary-button" id="props-toggle-button" style="display: none" aria-expanded="false" data-tippy-content="Attach props to the hands" aria-label="Attach props to the hands">+ <img src="images/icons/props.svg" alt="Props" width="20" height="20" />+ </button>+<div id="download-control-mount"></div></div>diff --git a/src/lib/UI.ts b/src/lib/UI.tsindex 9c565f0..3ba2a71 100644--- a/src/lib/UI.ts+++ b/src/lib/UI.ts@@ -100,6 +100,8 @@ export class UI {dom_import_animations_button: HTMLButtonElement | null = nulldom_import_animations_input: HTMLInputElement | null = null+ dom_props_toggle_button: HTMLButtonElement | null = null+ dom_props_panel_mount: HTMLElement | null = nulldom_extend_arm_range_input: HTMLInputElement | null = nulldom_extend_arm_numeric_input: HTMLInputElement | null = nulldom_arm_extension_options: HTMLElement | null = null@@ -223,6 +225,8 @@ export class UI {this.dom_animation_clip_list = document.querySelector('#animations-items')this.dom_export_button = document.querySelector('#export-button')this.dom_import_animations_button = document.querySelector('#import-animations-button')+ this.dom_props_toggle_button = document.querySelector('#props-toggle-button')+ this.dom_props_panel_mount = document.querySelector('#props-panel-mount')this.dom_import_animations_input = document.querySelector('#import-animations-input')this.dom_mirror_animations_checkbox = document.querySelector('#mirror-animations-checkbox')this.dom_reset_arm_extension_button = document.querySelector('#reset-arm-extension-button')diff --git a/src/lib/processes/animations-listing/StepAnimationsListing.ts b/src/lib/processes/animations-listing/StepAnimationsListing.tsindex 04ef3bb..733a770 100644--- a/src/lib/processes/animations-listing/StepAnimationsListing.ts+++ b/src/lib/processes/animations-listing/StepAnimationsListing.ts@@ -18,6 +18,7 @@ import { type ThemeManager } from '../../ThemeManager.ts'import { AnimationSearch } from './AnimationSearch.ts'import { type AnimationClipMetadata, type TransformedAnimationClipPair } from './interfaces/TransformedAnimationClipPair.ts'import { type AnimationExportSelection } from './interfaces/AnimationExportSelection.ts'+import { PropsManager } from './props/PropsManager.ts'// Note: EventTarget is a built-ininterface and do not need to import itexport class StepAnimationsListing extends EventTarget {@@ -43,6 +44,7 @@ export class StepAnimationsListing extends EventTarget {private model_variation_pelvis_position_scale: number = 1.0private readonly custom_animation_importer: CustomAnimationImporter+ private readonly props_manager: PropsManager = new PropsManager()private _added_event_listeners: boolean = falseprivate is_loading_default_animations: boolean = false@@ -112,6 +114,7 @@ export class StepAnimationsListing extends EventTarget {this.custom_animation_importer.set_enabled(!this.is_loading_default_animations)this.skeleton_type = skeleton_type+ this.props_manager.begin(skeleton_type, skeleton_scale)// if we are navigating back to this step, we don't want to add the event listeners againif (!this._added_event_listeners) {@@ -125,6 +128,7 @@ export class StepAnimationsListing extends EventTarget {public reset_step_data (): void {// reset previous state if we are re-entering this step// this will happen if we are reskinning the mesh after changes+ this.props_manager.detach_all()this.animation_clips_loaded = []this.skinned_meshes_to_animate = []this.animation_mixer = new AnimationMixer(new Object3D())@@ -233,6 +237,7 @@ export class StepAnimationsListing extends EventTarget {*/public swap_skinned_meshes (scene: Scene, new_skinned_meshes: SkinnedMesh[]): void {const is_variation_active = this.model_variation_switcher?.is_variation_active ?? false+ this.props_manager.detach_all()this.clear_variation_model_from_scene()if (!is_variation_active) {@@ -251,6 +256,7 @@ export class StepAnimationsListing extends EventTarget {}this.skinned_meshes_to_animate = new_skinned_meshes+ this.props_manager.attach_to_skinned_meshes(new_skinned_meshes)// replay current animation on the new meshesthis.play_animation(this.current_playing_index)@@ -264,6 +270,7 @@ export class StepAnimationsListing extends EventTarget {public clear_variation_model_from_scene (): void {const is_variation_active = this.model_variation_switcher?.is_variation_active ?? falseif (is_variation_active) {+ this.props_manager.detach_all()for (const mesh of this.skinned_meshes_to_animate) {Utility.remove_object_with_children(mesh)}@@ -275,6 +282,7 @@ export class StepAnimationsListing extends EventTarget {public load_and_apply_default_animation_to_skinned_mesh (final_skinned_meshes: SkinnedMesh[]): void {this.skinned_meshes_to_animate = final_skinned_meshes+ this.props_manager.attach_to_skinned_meshes(final_skinned_meshes)// Set the animations file path on the loaderthis.animation_loader.set_animations_file_path(this.animations_file_path)diff --git a/src/lib/processes/animations-listing/props/HandBoneResolver.ts b/src/lib/processes/animations-listing/props/HandBoneResolver.tsnew file mode 100644index 0000000..d30cfba--- /dev/null+++ b/src/lib/processes/animations-listing/props/HandBoneResolver.ts@@ -0,0 +1,47 @@+import { type Bone, type Skeleton } from 'three'+import { PropSide } from './PropSide.ts'++export class HandBoneResolver {+ private static readonly exact_names: Record<PropSide, string[]> = {+ [PropSide.Left]: ['hand_l', 'Hand_L', 'DEF-hand.L', 'mixamorigLeftHand', 'LeftHand', 'Hand.L', 'hand.L'],+ [PropSide.Right]: ['hand_r', 'Hand_R', 'DEF-hand.R', 'mixamorigRightHand', 'RightHand', 'Hand.R', 'hand.R']+ }++ private static readonly excluded_keywords: string[] = [+ 'finger', 'thumb', 'index', 'middle', 'ring', 'pinky', 'twist', 'ik', 'end'+ ]++ public static resolve (skeleton: Skeleton, side: PropSide): Bone | null {+ const bones = skeleton.bones.filter((bone) => bone !== undefined && bone !== null)++ for (const exact_name of this.exact_names[side]) {+ const exact_match = bones.find((bone) => bone.name === exact_name)+ if (exact_match !== undefined) {+ return exact_match+ }+ }++ const fallback_match = bones.find((bone) => {+ const lower_name = bone.name.toLowerCase()+ if (!lower_name.includes('hand')) {+ return false+ }++ if (this.excluded_keywords.some((keyword) => lower_name.includes(keyword))) {+ return false+ }++ return this.name_has_side(bone.name, side)+ })++ return fallback_match ?? null+ }++ private static name_has_side (bone_name: string, side: PropSide): boolean {+ const side_letter = side === PropSide.Left ? 'l' : 'r'+ const side_word = side === PropSide.Left ? 'left' : 'right'+ const side_letter_pattern = new RegExp(`(^|[_.\\-\\s])${side_letter}($|[_.\\-\\s])`, 'i')++ return bone_name.toLowerCase().includes(side_word) || side_letter_pattern.test(bone_name)+ }+}diff --git a/src/lib/processes/animations-listing/props/ProceduralPropBuilder.ts b/src/lib/processes/animations-listing/props/ProceduralPropBuilder.tsnew file mode 100644index 0000000..73ba707--- /dev/null+++ b/src/lib/processes/animations-listing/props/ProceduralPropBuilder.ts@@ -0,0 +1,17 @@+import { CylinderGeometry, Group, Mesh, MeshStandardMaterial } from 'three'++export class ProceduralPropBuilder {+ // sized in meters for a rig at skeleton scale 1.0+ public static create_pole (): Group {+ const pole_group = new Group()++ const geometry = new CylinderGeometry(0.018, 0.018, 1.7, 12)+ const material = new MeshStandardMaterial({ color: 0x8b5a2b, roughness: 0.8, metalness: 0.0 })+ const pole_mesh = new Mesh(geometry, material)+ pole_mesh.name = 'prop_pole_mesh'+ pole_mesh.castShadow = true++ pole_group.add(pole_mesh)+ return pole_group+ }+}diff --git a/src/lib/processes/animations-listing/props/PropCatalog.ts b/src/lib/processes/animations-listing/props/PropCatalog.tsnew file mode 100644index 0000000..16ee774--- /dev/null+++ b/src/lib/processes/animations-listing/props/PropCatalog.ts@@ -0,0 +1,55 @@+import { Euler, type Object3D } from 'three'+import { SkeletonType } from '../../../enums/SkeletonType.ts'+import { PropType } from './PropType.ts'+import { PropSide } from './PropSide.ts'+import { ProceduralPropBuilder } from './ProceduralPropBuilder.ts'++export interface PropMountOffset {+ // meters for a rig at skeleton scale 1.0, along the hand bone toward the fingers+ along_hand: number+ // meters for a rig at skeleton scale 1.0, along world down in the bind pose+ below_palm: number+ // applied after the prop's +Y is aligned with the grip axis (world forward)+ rotation: Euler+}++export interface PropDefinition {+ type: PropType+ display_name: string+ create_object: () => Object3D+ default_mount_offsets: Record<PropSide, PropMountOffset>+ rig_mount_offsets: Partial<Record<SkeletonType, Record<PropSide, PropMountOffset>>>+}++export class PropCatalog {+ public static readonly supported_skeleton_types: SkeletonType[] = [SkeletonType.Human, SkeletonType.Kaiju]++ private static readonly definitions: PropDefinition[] = [+ {+ type: PropType.Pole,+ display_name: 'Pole',+ create_object: () => ProceduralPropBuilder.create_pole(),+ default_mount_offsets: {+ [PropSide.Left]: { along_hand: 0.09, below_palm: 0.035, rotation: new Euler() },+ [PropSide.Right]: { along_hand: 0.09, below_palm: 0.035, rotation: new Euler() }+ },+ rig_mount_offsets: {}+ }+ ]++ public static all (): PropDefinition[] {+ return this.definitions+ }++ public static find (type: PropType): PropDefinition | undefined {+ return this.definitions.find((definition) => definition.type === type)+ }++ public static is_supported_skeleton (skeleton_type: SkeletonType): boolean {+ return this.supported_skeleton_types.includes(skeleton_type)+ }++ public static mount_offset (definition: PropDefinition, skeleton_type: SkeletonType, side: PropSide): PropMountOffset {+ return definition.rig_mount_offsets[skeleton_type]?.[side] ?? definition.default_mount_offsets[side]+ }+}diff --git a/src/lib/processes/animations-listing/props/PropSelection.ts b/src/lib/processes/animations-listing/props/PropSelection.tsnew file mode 100644index 0000000..c32a0e1--- /dev/null+++ b/src/lib/processes/animations-listing/props/PropSelection.ts@@ -0,0 +1,6 @@+import { type PropType } from './PropType.ts'++export interface PropSelection {+ left: PropType+ right: PropType+}diff --git a/src/lib/processes/animations-listing/props/PropSide.ts b/src/lib/processes/animations-listing/props/PropSide.tsnew file mode 100644index 0000000..0482994--- /dev/null+++ b/src/lib/processes/animations-listing/props/PropSide.ts@@ -0,0 +1,4 @@+export enum PropSide {+ Left = 'left',+ Right = 'right'+}diff --git a/src/lib/processes/animations-listing/props/PropType.ts b/src/lib/processes/animations-listing/props/PropType.tsnew file mode 100644index 0000000..3512946--- /dev/null+++ b/src/lib/processes/animations-listing/props/PropType.ts@@ -0,0 +1,4 @@+export enum PropType {+ None = 'none',+ Pole = 'pole'+}diff --git a/src/lib/processes/animations-listing/props/Props.test.ts b/src/lib/processes/animations-listing/props/Props.test.tsnew file mode 100644index 0000000..22e5b40--- /dev/null+++ b/src/lib/processes/animations-listing/props/Props.test.ts@@ -0,0 +1,53 @@+import { describe, it, expect } from 'vitest'+import { Bone, Group, Mesh, Skeleton } from 'three'+import { HandBoneResolver } from './HandBoneResolver'+import { PropsExportFilter, PROP_USER_DATA_KEY } from './PropsExportFilter'+import { PropSide } from './PropSide'++function make_skeleton (names: string[]): Skeleton {+ return new Skeleton(names.map((name) => {+ const bone = new Bone()+ bone.name = name+ return bone+ }))+}++describe('HandBoneResolver', () => {+ it('finds exact hand bone names', () => {+ const skeleton = make_skeleton(['pelvis', 'hand_l', 'index_01_l', 'hand_r'])+ expect(HandBoneResolver.resolve(skeleton, PropSide.Left)?.name).toBe('hand_l')+ expect(HandBoneResolver.resolve(skeleton, PropSide.Right)?.name).toBe('hand_r')+ })++ it('falls back to side-marked hand bones and skips fingers', () => {+ const skeleton = make_skeleton(['Hand_Index_L', 'Claw_Hand_L', 'Claw_Hand_R'])+ expect(HandBoneResolver.resolve(skeleton, PropSide.Left)?.name).toBe('Claw_Hand_L')+ expect(HandBoneResolver.resolve(skeleton, PropSide.Right)?.name).toBe('Claw_Hand_R')+ })++ it('returns null when the hand bone is missing', () => {+ const skeleton = make_skeleton(['pelvis', 'hand_r'])+ expect(HandBoneResolver.resolve(skeleton, PropSide.Left)).toBeNull()+ })+})++describe('PropsExportFilter', () => {+ it('detaches props and restores them to their original parents', () => {+ const root = new Bone()+ const hand = new Bone()+ root.add(hand)++ const prop = new Group()+ prop.userData[PROP_USER_DATA_KEY] = true+ prop.add(new Mesh())+ const other_child = new Bone()+ hand.add(prop, other_child)++ const restore = PropsExportFilter.detach_props([root])+ expect(prop.parent).toBeNull()+ expect(hand.children).toEqual([other_child])++ restore()+ expect(prop.parent).toBe(hand)+ })+})diff --git a/src/lib/processes/animations-listing/props/PropsExportFilter.ts b/src/lib/processes/animations-listing/props/PropsExportFilter.tsnew file mode 100644index 0000000..e387798--- /dev/null+++ b/src/lib/processes/animations-listing/props/PropsExportFilter.ts@@ -0,0 +1,28 @@+import { type Object3D } from 'three'++export const PROP_USER_DATA_KEY = 'is_mesh2motion_prop'++export class PropsExportFilter {+ /**+ * Detaches every prop found under the given roots.+ * @returns a function that puts each prop back on its original parent+ */+ public static detach_props (roots: Object3D[]): () => void {+ const detached: Array<{ prop: Object3D, parent: Object3D }> = []++ roots.forEach((root) => {+ root.traverse((scene_object) => {+ if (scene_object.userData[PROP_USER_DATA_KEY] === true && scene_object.parent !== null) {+ detached.push({ prop: scene_object, parent: scene_object.parent })+ }+ })+ })++ // removed after traversal so the traversal does not skip siblings+ detached.forEach(({ prop, parent }) => { parent.remove(prop) })++ return () => {+ detached.forEach(({ prop, parent }) => { parent.add(prop) })+ }+ }+}diff --git a/src/lib/processes/animations-listing/props/PropsManager.ts b/src/lib/processes/animations-listing/props/PropsManager.tsnew file mode 100644index 0000000..c436ecf--- /dev/null+++ b/src/lib/processes/animations-listing/props/PropsManager.ts@@ -0,0 +1,171 @@+import { Mesh, Quaternion, type Bone, type Object3D, type Skeleton, type SkinnedMesh, Vector3 } from 'three'+import { SkeletonType } from '../../../enums/SkeletonType.ts'+import { PropCatalog } from './PropCatalog.ts'+import { PropSide } from './PropSide.ts'+import { PropType } from './PropType.ts'+import { type PropSelection } from './PropSelection.ts'+import { PropsPanel } from './PropsPanel.ts'+import { HandBoneResolver } from './HandBoneResolver.ts'+import { PROP_USER_DATA_KEY } from './PropsExportFilter.ts'++interface HandGripFrame {+ local_down: Vector3+ local_forward: Vector3+}++/**+ * Attaches the user's chosen props to the hand bones of the animated skinned meshes.+ * Props are children of the bones, so they follow every animation and are exported with the rig.+ */+export class PropsManager extends EventTarget {+ private readonly panel: PropsPanel = new PropsPanel()+ private selection: PropSelection = { left: PropType.None, right: PropType.None }+ private skeleton_type: SkeletonType = SkeletonType.None+ private skeleton_scale: number = 1.0+ private target_skinned_meshes: SkinnedMesh[] = []+ private attached_props: Object3D[] = []+ private readonly grip_frames = new Map<Bone, HandGripFrame>()+ private added_event_listeners: boolean = false++ public begin (skeleton_type: SkeletonType, skeleton_scale: number): void {+ this.panel.initialize()++ if (!this.added_event_listeners) {+ this.panel.addEventListener('props-selection-changed', (event: Event) => {+ this.selection = (event as CustomEvent<PropSelection>).detail+ this.refresh_attached_props()+ })+ this.added_event_listeners = true+ }++ this.skeleton_type = skeleton_type+ this.skeleton_scale = skeleton_scale++ const is_supported = PropCatalog.is_supported_skeleton(skeleton_type)+ if (!is_supported) {+ this.selection = { left: PropType.None, right: PropType.None }+ this.panel.set_selection(this.selection)+ }++ this.panel.set_visible(is_supported)+ }++ // meshes must still be in their rest pose here, since the grip frames are captured from it+ public attach_to_skinned_meshes (skinned_meshes: SkinnedMesh[]): void {+ this.target_skinned_meshes = skinned_meshes+ this.capture_grip_frames()+ this.refresh_attached_props()+ }++ /**+ * Must be called before the skinned meshes are disposed, since disposing them+ * would also dispose any prop still parented to their bones.+ */+ public detach_all (): void {+ this.dispose_attached_props()+ this.grip_frames.clear()+ this.target_skinned_meshes = []+ }++ private capture_grip_frames (): void {+ this.grip_frames.clear()++ this.unique_skeletons().forEach((skeleton) => {+ Object.values(PropSide).forEach((side) => {+ const hand_bone = HandBoneResolver.resolve(skeleton, side)+ if (hand_bone !== null) {+ this.grip_frames.set(hand_bone, this.compute_grip_frame(hand_bone))+ }+ })+ })+ }++ // palms face down and the character faces +Z in the rest pose, so grip along world forward+ private compute_grip_frame (hand_bone: Bone): HandGripFrame {+ const world_to_local = hand_bone.getWorldQuaternion(new Quaternion()).invert()++ return {+ local_down: new Vector3(0, -1, 0).applyQuaternion(world_to_local),+ local_forward: new Vector3(0, 0, 1).applyQuaternion(world_to_local)+ }+ }++ private refresh_attached_props (): void {+ this.dispose_attached_props()++ if (!PropCatalog.is_supported_skeleton(this.skeleton_type)) {+ return+ }++ const skeletons = this.unique_skeletons()++ Object.values(PropSide).forEach((side) => {+ const prop_type = side === PropSide.Left ? this.selection.left : this.selection.right+ let found_hand_bone = false++ skeletons.forEach((skeleton) => {+ const hand_bone = HandBoneResolver.resolve(skeleton, side)+ if (hand_bone === null) {+ return+ }++ found_hand_bone = true+ this.attach_prop(prop_type, side, hand_bone)+ })++ this.panel.set_side_enabled(side, skeletons.length === 0 || found_hand_bone)+ })+ }++ private attach_prop (prop_type: PropType, side: PropSide, hand_bone: Bone): void {+ const definition = PropCatalog.find(prop_type)+ if (definition === undefined) {+ return+ }++ const prop_object = definition.create_object()+ prop_object.name = `prop_${prop_type}_${side}`+ prop_object.userData[PROP_USER_DATA_KEY] = true++ // keep the prop the same world size no matter how the hand bone is scaled+ const hand_world_scale = hand_bone.getWorldScale(new Vector3())+ const size_factor = this.skeleton_scale / Math.max(hand_world_scale.x, 1e-6)++ const mount_offset = PropCatalog.mount_offset(definition, this.skeleton_type, side)++ const { local_down, local_forward } = this.grip_frames.get(hand_bone) ?? this.compute_grip_frame(hand_bone)++ prop_object.quaternion+ .setFromUnitVectors(new Vector3(0, 1, 0), local_forward)+ .multiply(new Quaternion().setFromEuler(mount_offset.rotation))++ prop_object.position+ .set(0, mount_offset.along_hand, 0)+ .addScaledVector(local_down, mount_offset.below_palm)+ .multiplyScalar(size_factor)++ prop_object.scale.setScalar(size_factor)++ hand_bone.add(prop_object)+ this.attached_props.push(prop_object)+ }++ private unique_skeletons (): Skeleton[] {+ return Array.from(new Set(this.target_skinned_meshes.map((mesh) => mesh.skeleton)))+ }++ private dispose_attached_props (): void {+ this.attached_props.forEach((prop_object) => {+ prop_object.removeFromParent()+ prop_object.traverse((child) => {+ if (child instanceof Mesh) {+ child.geometry.dispose()+ const materials = Array.isArray(child.material) ? child.material : [child.material]+ materials.forEach((material) => { material.dispose() })+ }+ })+ })++ this.attached_props = []+ }+}diff --git a/src/lib/processes/animations-listing/props/PropsPanel.ts b/src/lib/processes/animations-listing/props/PropsPanel.tsnew file mode 100644index 0000000..e369b95--- /dev/null+++ b/src/lib/processes/animations-listing/props/PropsPanel.ts@@ -0,0 +1,117 @@+import { UI } from '../../../UI.ts'+import { PropCatalog } from './PropCatalog.ts'+import { PropSide } from './PropSide.ts'+import { PropType } from './PropType.ts'+import { type PropSelection } from './PropSelection.ts'++export class PropsPanel extends EventTarget {+ private readonly ui: UI = UI.getInstance()+ private readonly selects = new Map<PropSide, HTMLSelectElement>()+ private dom_panel: HTMLElement | null = null+ private added_event_listeners: boolean = false++ public initialize (): void {+ if (this.added_event_listeners) {+ return+ }++ const mount = this.ui.dom_props_panel_mount+ if (mount === null) {+ return+ }++ mount.innerHTML = `+ <div class="props-panel" hidden>+ <div class="props-panel-header">Props</div>+ ${this.side_row_html(PropSide.Left, 'Left hand')}+ ${this.side_row_html(PropSide.Right, 'Right hand')}+ </div>+ `++ this.dom_panel = mount.querySelector('.props-panel')++ Object.values(PropSide).forEach((side) => {+ const select = mount.querySelector<HTMLSelectElement>(`#props-${side}-hand-select`)+ if (select === null) {+ return+ }++ this.selects.set(side, select)+ select.addEventListener('change', () => { this.dispatch_selection_changed() })+ })++ this.ui.dom_props_toggle_button?.addEventListener('click', () => {+ this.set_expanded(this.dom_panel?.hidden === true)+ })++ this.added_event_listeners = true+ }++ public set_visible (is_visible: boolean): void {+ if (this.ui.dom_props_toggle_button !== null) {+ this.ui.dom_props_toggle_button.style.display = is_visible ? '' : 'none'+ }++ if (!is_visible) {+ this.set_expanded(false)+ }+ }++ public set_side_enabled (side: PropSide, is_enabled: boolean): void {+ const select = this.selects.get(side)+ if (select === undefined) {+ return+ }++ select.disabled = !is_enabled+ select.title = is_enabled ? '' : 'No hand bone was found for this side'+ }++ public set_selection (selection: PropSelection): void {+ const left_select = this.selects.get(PropSide.Left)+ const right_select = this.selects.get(PropSide.Right)++ if (left_select !== undefined) { left_select.value = selection.left }+ if (right_select !== undefined) { right_select.value = selection.right }+ }++ private set_expanded (is_expanded: boolean): void {+ if (this.dom_panel !== null) {+ this.dom_panel.hidden = !is_expanded+ }++ const toggle_button = this.ui.dom_props_toggle_button+ if (toggle_button !== null) {+ toggle_button.setAttribute('aria-expanded', String(is_expanded))+ toggle_button.classList.toggle('active', is_expanded)+ }+ }++ private side_row_html (side: PropSide, label: string): string {+ const options_html = [+ `<option value="${PropType.None}">None</option>`,+ ...PropCatalog.all().map((definition) => `<option value="${definition.type}">${definition.display_name}</option>`)+ ].join('')++ return `+ <label class="props-panel-row" for="props-${side}-hand-select">+ <span>${label}</span>+ <select id="props-${side}-hand-select">${options_html}</select>+ </label>+ `+ }++ private selected_prop (side: PropSide): PropType {+ const value = this.selects.get(side)?.value+ return Object.values(PropType).includes(value as PropType) ? value as PropType : PropType.None+ }++ private dispatch_selection_changed (): void {+ const selection: PropSelection = {+ left: this.selected_prop(PropSide.Left),+ right: this.selected_prop(PropSide.Right)+ }++ this.dispatchEvent(new CustomEvent<PropSelection>('props-selection-changed', { detail: selection }))+ }+}diff --git a/src/lib/processes/animations-listing/props/props.css b/src/lib/processes/animations-listing/props/props.cssnew file mode 100644index 0000000..acc7edf--- /dev/null+++ b/src/lib/processes/animations-listing/props/props.css@@ -0,0 +1,41 @@+#props-toggle-button.active {+ background: var(--bg-alternate);+ outline: 1px solid var(--text-primary);+}++.props-panel {+ display: flex;+ flex-direction: column;+ gap: 0.5rem;+ margin: 0.5rem 0;+ padding: 0.75rem;+ border: 1px solid var(--bg-tertiary);+ border-radius: 6px;+ background: color-mix(in srgb, var(--bg-primary) 90%, black);+}++.props-panel[hidden] {+ display: none;+}++.props-panel-header {+ color: var(--text-primary);+ font-size: 1.1rem;+}++.props-panel-row {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 1rem;+ color: var(--text-alternate);+}++.props-panel-row select {+ min-width: 8rem;+}++.props-panel-row select:disabled {+ opacity: 0.5;+ cursor: not-allowed;+}diff --git a/src/lib/processes/export-to-file/StepExportToFile.ts b/src/lib/processes/export-to-file/StepExportToFile.tsindex 9935c71..053adec 100644--- a/src/lib/processes/export-to-file/StepExportToFile.ts+++ b/src/lib/processes/export-to-file/StepExportToFile.ts@@ -10,6 +10,7 @@ import { GlbSkinCleanupService } from './GlbSkinCleanupService.ts'import { AnimationUtility } from '../animations-listing/AnimationUtility.ts'import { type AnimationExportSelection } from '../animations-listing/interfaces/AnimationExportSelection.ts'import { FbxTextureCompatibilityService } from './FbxTextureCompatibilityService.ts'+import { PropsExportFilter } from '../animations-listing/props/PropsExportFilter.ts'// Note: EventTarget is a built-in interface and do not need to import itexport class StepExportToFile extends EventTarget {@@ -74,6 +75,7 @@ export class StepExportToFile extends EventTarget {// to work against the exported skeleton.const skeleton_only = download_settings.export_contents() === ExportContents.Skeletonconst objects_to_export: Object3D[] = ExportHierarchyService.collect_objects_to_export(skinned_meshes, skeleton_only)+ const restore_props = skeleton_only ? PropsExportFilter.detach_props(objects_to_export) : () => {}// The base animation data can contain tracks for joints the user removed (e.g. fingers),// and keyframe times can contain float32 duplicates that glTF validators reject.@@ -115,11 +117,13 @@ export class StepExportToFile extends EventTarget {}})+ restore_props()restore_bone_names()}).catch((error) => {console.log('Error exporting file:', error)+ restore_props()restore_bone_names()throw errordiff --git a/static/images/icons/props.svg b/static/images/icons/props.svgnew file mode 100644index 0000000..a7a196b--- /dev/null+++ b/static/images/icons/props.svg@@ -0,0 +1,4 @@+<svg width="100%" height="100%" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">+ <path d="M18.4,3.2L20.8,5.6L6.6,19.8L4.2,17.4Z" style="fill:rgb(212,212,212);"/>+ <circle cx="5" cy="19" r="2.2" style="fill:rgb(212,212,212);"/>+</svg>