Import a 3D Model and automatically assign and export animations
TypeScript
add preview images for props
Scott Petrovic9467a43af4d9
diff --git a/src/lib/processes/animations-listing/props/PropCatalog.ts b/src/lib/processes/animations-listing/props/PropCatalog.tsindex 7bf9507..77a3b77 100644--- a/src/lib/processes/animations-listing/props/PropCatalog.ts+++ b/src/lib/processes/animations-listing/props/PropCatalog.ts@@ -20,6 +20,7 @@ export interface PropDefinition {display_name: stringcategory: PropCategoryasset_path: string+ preview_path: stringmodel_offset_y: numberdefault_mount_offsets: Record<PropSide, PropMountOffset>rig_mount_offsets: Partial<Record<SkeletonType, Record<PropSide, PropMountOffset>>>@@ -37,6 +38,7 @@ function create_definition (display_name,category,asset_path: `props/${filename}`,+ preview_path: `props/preview/${filename.replace(/\.glb$/, '.png')}`,model_offset_y,default_mount_offsets: {[PropSide.Left]: { along_hand: 0.09, below_palm: 0.035, rotation: new Euler() },diff --git a/src/lib/processes/animations-listing/props/PropsPanel.ts b/src/lib/processes/animations-listing/props/PropsPanel.tsindex 216c674..f5d982b 100644--- a/src/lib/processes/animations-listing/props/PropsPanel.ts+++ b/src/lib/processes/animations-listing/props/PropsPanel.ts@@ -7,6 +7,7 @@ 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 readonly previews = new Map<PropSide, HTMLImageElement>()private dom_panel: HTMLElement | null = nullprivate added_event_listeners: boolean = false@@ -37,7 +38,15 @@ export class PropsPanel extends EventTarget {}this.selects.set(side, select)- select.addEventListener('change', () => { this.dispatch_selection_changed() })+ const preview = mount.querySelector<HTMLImageElement>(`#props-${side}-hand-preview`)+ if (preview !== null) {+ this.previews.set(side, preview)+ }++ select.addEventListener('change', () => {+ this.update_preview(side)+ this.dispatch_selection_changed()+ })})this.ui.dom_props_toggle_button?.addEventListener('click', () => {@@ -82,6 +91,28 @@ export class PropsPanel extends EventTarget {if (left_select !== undefined) { left_select.value = selection.left }if (right_select !== undefined) { right_select.value = selection.right }++ this.update_preview(PropSide.Left)+ this.update_preview(PropSide.Right)+ }++ private update_preview (side: PropSide): void {+ const preview = this.previews.get(side)+ if (preview === undefined) {+ return+ }++ const definition = PropCatalog.find(this.selected_prop(side))+ if (definition === undefined) {+ preview.removeAttribute('src')+ preview.alt = ''+ preview.hidden = true+ return+ }++ preview.src = definition.preview_path+ preview.alt = definition.display_name+ preview.hidden = false}private set_expanded (is_expanded: boolean): void {@@ -113,7 +144,12 @@ export class PropsPanel extends EventTarget {return `<label class="props-panel-row" for="props-${side}-hand-select"><span>${label}</span>- <select id="props-${side}-hand-select">${options_html}</select>+ <span class="props-panel-control">+ <span class="props-panel-preview">+ <img id="props-${side}-hand-preview" alt="" hidden>+ </span>+ <select id="props-${side}-hand-select">${options_html}</select>+ </span></label>`}diff --git a/src/lib/processes/animations-listing/props/props.css b/src/lib/processes/animations-listing/props/props.cssindex 66b92b6..ca6ffc6 100644--- a/src/lib/processes/animations-listing/props/props.css+++ b/src/lib/processes/animations-listing/props/props.css@@ -51,6 +51,34 @@color: var(--text-alternate);}+.props-panel-control {+ display: flex;+ align-items: center;+ gap: 0.5rem;+}++.props-panel-preview {+ display: flex;+ align-items: center;+ justify-content: center;+ flex-shrink: 0;+ width: 2.5rem;+ height: 2.5rem;+ border: 1px solid var(--bg-tertiary);+ border-radius: 4px;+ background: var(--bg-alternate);+}++.props-panel-preview img {+ width: 100%;+ height: 100%;+ object-fit: contain;+}++.props-panel-preview img[hidden] {+ display: none;+}+.props-panel-row select {min-width: 8rem;}diff --git a/static/props/preview/arrow_A.png b/static/props/preview/arrow_A.pngnew file mode 100644index 0000000..9d6cbaeBinary files /dev/null and b/static/props/preview/arrow_A.png differdiff --git a/static/props/preview/arrow_B.png b/static/props/preview/arrow_B.pngnew file mode 100644index 0000000..0fceb09Binary files /dev/null and b/static/props/preview/arrow_B.png differdiff --git a/static/props/preview/axe_A.png b/static/props/preview/axe_A.pngnew file mode 100644index 0000000..b4934dcBinary files /dev/null and b/static/props/preview/axe_A.png differdiff --git a/static/props/preview/axe_B.png b/static/props/preview/axe_B.pngnew file mode 100644index 0000000..99ebeeaBinary files /dev/null and b/static/props/preview/axe_B.png differdiff --git a/static/props/preview/axe_C.png b/static/props/preview/axe_C.pngnew file mode 100644index 0000000..e050fb7Binary files /dev/null and b/static/props/preview/axe_C.png differdiff --git a/static/props/preview/bow_A.png b/static/props/preview/bow_A.pngnew file mode 100644index 0000000..c7722b1Binary files /dev/null and b/static/props/preview/bow_A.png differdiff --git a/static/props/preview/bow_A_withString.png b/static/props/preview/bow_A_withString.pngnew file mode 100644index 0000000..b2701ebBinary files /dev/null and b/static/props/preview/bow_A_withString.png differdiff --git a/static/props/preview/bow_B.png b/static/props/preview/bow_B.pngnew file mode 100644index 0000000..830ce8eBinary files /dev/null and b/static/props/preview/bow_B.png differdiff --git a/static/props/preview/bow_B_withString.png b/static/props/preview/bow_B_withString.pngnew file mode 100644index 0000000..5f40a26Binary files /dev/null and b/static/props/preview/bow_B_withString.png differdiff --git a/static/props/preview/dagger_A.png b/static/props/preview/dagger_A.pngnew file mode 100644index 0000000..be46ddcBinary files /dev/null and b/static/props/preview/dagger_A.png differdiff --git a/static/props/preview/dagger_B.png b/static/props/preview/dagger_B.pngnew file mode 100644index 0000000..6362db8Binary files /dev/null and b/static/props/preview/dagger_B.png differdiff --git a/static/props/preview/fistweapon_A.png b/static/props/preview/fistweapon_A.pngnew file mode 100644index 0000000..cf6443dBinary files /dev/null and b/static/props/preview/fistweapon_A.png differdiff --git a/static/props/preview/fistweapon_A_stacked.png b/static/props/preview/fistweapon_A_stacked.pngnew file mode 100644index 0000000..0c5439bBinary files /dev/null and b/static/props/preview/fistweapon_A_stacked.png differdiff --git a/static/props/preview/fistweapon_B.png b/static/props/preview/fistweapon_B.pngnew file mode 100644index 0000000..06a7e4eBinary files /dev/null and b/static/props/preview/fistweapon_B.png differdiff --git a/static/props/preview/fistweapon_B_stacked.png b/static/props/preview/fistweapon_B_stacked.pngnew file mode 100644index 0000000..f574ca3Binary files /dev/null and b/static/props/preview/fistweapon_B_stacked.png differdiff --git a/static/props/preview/halberd.png b/static/props/preview/halberd.pngnew file mode 100644index 0000000..b3729d4Binary files /dev/null and b/static/props/preview/halberd.png differdiff --git a/static/props/preview/hammer_A.png b/static/props/preview/hammer_A.pngnew file mode 100644index 0000000..ff83a02Binary files /dev/null and b/static/props/preview/hammer_A.png differdiff --git a/static/props/preview/hammer_B.png b/static/props/preview/hammer_B.pngnew file mode 100644index 0000000..6bee10eBinary files /dev/null and b/static/props/preview/hammer_B.png differdiff --git a/static/props/preview/hammer_C.png b/static/props/preview/hammer_C.pngnew file mode 100644index 0000000..5ea8587Binary files /dev/null and b/static/props/preview/hammer_C.png differdiff --git a/static/props/preview/shield_A.png b/static/props/preview/shield_A.pngnew file mode 100644index 0000000..4bffdc6Binary files /dev/null and b/static/props/preview/shield_A.png differdiff --git a/static/props/preview/shield_B.png b/static/props/preview/shield_B.pngnew file mode 100644index 0000000..1163032Binary files /dev/null and b/static/props/preview/shield_B.png differdiff --git a/static/props/preview/shield_C.png b/static/props/preview/shield_C.pngnew file mode 100644index 0000000..d930338Binary files /dev/null and b/static/props/preview/shield_C.png differdiff --git a/static/props/preview/spear_A.png b/static/props/preview/spear_A.pngnew file mode 100644index 0000000..0f3e6ffBinary files /dev/null and b/static/props/preview/spear_A.png differdiff --git a/static/props/preview/staff_A.png b/static/props/preview/staff_A.pngnew file mode 100644index 0000000..6acd403Binary files /dev/null and b/static/props/preview/staff_A.png differdiff --git a/static/props/preview/staff_B.png b/static/props/preview/staff_B.pngnew file mode 100644index 0000000..1372d8cBinary files /dev/null and b/static/props/preview/staff_B.png differdiff --git a/static/props/preview/sword_A.png b/static/props/preview/sword_A.pngnew file mode 100644index 0000000..adf41b8Binary files /dev/null and b/static/props/preview/sword_A.png differdiff --git a/static/props/preview/sword_B.png b/static/props/preview/sword_B.pngnew file mode 100644index 0000000..909a393Binary files /dev/null and b/static/props/preview/sword_B.png differdiff --git a/static/props/preview/sword_C.png b/static/props/preview/sword_C.pngnew file mode 100644index 0000000..13234ccBinary files /dev/null and b/static/props/preview/sword_C.png differdiff --git a/static/props/preview/sword_D.png b/static/props/preview/sword_D.pngnew file mode 100644index 0000000..52f8db9Binary files /dev/null and b/static/props/preview/sword_D.png differdiff --git a/static/props/preview/sword_E.png b/static/props/preview/sword_E.pngnew file mode 100644index 0000000..c450135Binary files /dev/null and b/static/props/preview/sword_E.png differdiff --git a/static/props/preview/wand_A.png b/static/props/preview/wand_A.pngnew file mode 100644index 0000000..312b2faBinary files /dev/null and b/static/props/preview/wand_A.png differ