Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

Try to improve the UX a bit

Scott Petrovic5c66ea249649
diff --git a/src/create.html b/src/create.html
index 3879f0f..674d1b7 100644
--- a/src/create.html
+++ b/src/create.html
@@ -366,8 +366,6 @@
<!-- 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">
&#x2039; Back
@@ -413,17 +411,6 @@
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>
@@ -432,6 +419,21 @@
</div>
<!-- end tool-panel-->
+ <!-- floating props toggle and panel docked to the left of the tool panel -->
+ <div id="props-dock" style="display: none">
+ <button
+ class="secondary-button"
+ id="props-toggle-button"
+ aria-expanded="false"
+ aria-controls="props-panel-mount"
+ data-tippy-content="Attach props to the hands"
+ aria-label="Attach props to the hands"
+ >
+ <img src="images/icons/props.svg" alt="Props" width="32" height="32" />
+ </button>
+ <div id="props-panel-mount"></div>
+ </div>
+
<div id="animation-player-mount"></div>
<!-- 3d view controls shown on bottom right. This helps with click events -->
diff --git a/src/index.html b/src/index.html
index d587f91..ce634b8 100644
--- a/src/index.html
+++ b/src/index.html
@@ -146,8 +146,6 @@
that we get from the animations file(s) -->
<div id="animations-items"> </div>
- <div id="props-panel-mount"></div>
-
<div class="download-actions-row">
<!-- testing the mirroring options. Hide this for now until we get a better implementation for per animations -->
@@ -163,10 +161,6 @@
</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>
@@ -182,6 +176,14 @@
</div> <!-- end tool-panel-->
+ <!-- floating props toggle and panel docked to the left of the tool panel -->
+ <div id="props-dock" style="display: none">
+ <button class="secondary-button" id="props-toggle-button" aria-expanded="false" aria-controls="props-panel-mount" data-tippy-content="Attach props to the hands" aria-label="Attach props to the hands">
+ <img src="images/icons/props.svg" alt="Props" width="32" height="32" />
+ </button>
+ <div id="props-panel-mount"></div>
+ </div>
+
<div id="animation-player-mount"></div>
diff --git a/src/lib/UI.ts b/src/lib/UI.ts
index 3ba2a71..e557b6b 100644
--- a/src/lib/UI.ts
+++ b/src/lib/UI.ts
@@ -102,6 +102,7 @@ export class UI {
dom_import_animations_input: HTMLInputElement | null = null
dom_props_toggle_button: HTMLButtonElement | null = null
dom_props_panel_mount: HTMLElement | null = null
+ dom_props_dock: HTMLElement | null = null
dom_extend_arm_range_input: HTMLInputElement | null = null
dom_extend_arm_numeric_input: HTMLInputElement | null = null
dom_arm_extension_options: HTMLElement | null = null
@@ -227,6 +228,7 @@ export class UI {
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_props_dock = document.querySelector('#props-dock')
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')
@@ -287,6 +289,9 @@ export class UI {
if (this.dom_skinned_mesh_animation_tools != null) {
this.dom_skinned_mesh_animation_tools.style.display = 'none'
}
+ if (this.dom_props_dock != null) {
+ this.dom_props_dock.style.display = 'none'
+ }
if (this.dom_show_skeleton_container != null) {
this.dom_show_skeleton_container.style.display = 'none'
}
diff --git a/src/lib/processes/animations-listing/props/PropsPanel.ts b/src/lib/processes/animations-listing/props/PropsPanel.ts
index e369b95..dc13619 100644
--- a/src/lib/processes/animations-listing/props/PropsPanel.ts
+++ b/src/lib/processes/animations-listing/props/PropsPanel.ts
@@ -21,7 +21,7 @@ export class PropsPanel extends EventTarget {
}
mount.innerHTML = `
- <div class="props-panel" hidden>
+ <div class="props-panel" role="region" aria-label="Props" hidden>
<div class="props-panel-header">Props</div>
${this.side_row_html(PropSide.Left, 'Left hand')}
${this.side_row_html(PropSide.Right, 'Right hand')}
@@ -44,12 +44,21 @@ export class PropsPanel extends EventTarget {
this.set_expanded(this.dom_panel?.hidden === true)
})
+ // keep the floating panel docked beside the tool panel as its width changes
+ const tool_panel = document.querySelector<HTMLElement>('#tool-panel')
+ const dock = this.ui.dom_props_dock
+ if (tool_panel !== null && dock !== null) {
+ new ResizeObserver(() => {
+ dock.style.right = `calc(${tool_panel.offsetWidth}px + 0.5rem)`
+ }).observe(tool_panel)
+ }
+
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 (this.ui.dom_props_dock !== null) {
+ this.ui.dom_props_dock.style.display = is_visible ? '' : 'none'
}
if (!is_visible) {
diff --git a/src/lib/processes/animations-listing/props/props.css b/src/lib/processes/animations-listing/props/props.css
index acc7edf..66b92b6 100644
--- a/src/lib/processes/animations-listing/props/props.css
+++ b/src/lib/processes/animations-listing/props/props.css
@@ -3,15 +3,35 @@
outline: 1px solid var(--text-primary);
}
+#props-dock {
+ position: fixed;
+ top: calc(var(--navigation-height) + 0.5rem);
+ /* right offset is set from the tool panel width in PropsPanel */
+ right: 26rem;
+ z-index: 10;
+ display: flex;
+ flex-direction: column;
+ align-items: flex-end;
+ gap: 0.5rem;
+}
+
+#props-toggle-button {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: 0.5rem;
+}
+
.props-panel {
display: flex;
flex-direction: column;
gap: 0.5rem;
- margin: 0.5rem 0;
+ min-width: 14rem;
padding: 0.75rem;
border: 1px solid var(--bg-tertiary);
border-radius: 6px;
background: color-mix(in srgb, var(--bg-primary) 90%, black);
+ box-shadow: 1px 1px 8px 0px var(--bg-primary);
}
.props-panel[hidden] {
diff --git a/static/images/icons/props.svg b/static/images/icons/props.svg
index a7a196b..736e2b2 100644
--- a/static/images/icons/props.svg
+++ b/static/images/icons/props.svg
@@ -1,4 +1,12 @@
<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);"/>
+ <defs>
+ <g id="sword" style="fill:rgb(212,212,212);">
+ <path d="M12,1.5L13.1,3.6L13.1,15L10.9,15L10.9,3.6Z"/>
+ <rect x="8.6" y="15" width="6.8" height="1.5" rx="0.5"/>
+ <rect x="11.35" y="16.5" width="1.3" height="3.6"/>
+ <circle cx="12" cy="21" r="1.3"/>
+ </g>
+ </defs>
+ <use href="#sword" transform="rotate(45 12 12)"/>
+ <use href="#sword" transform="rotate(-45 12 12)"/>
</svg>