Import a 3D Model and automatically assign and export animations
TypeScript
Make video preview generation options use the rig config
Scott Petrovicd4903e8000df
diff --git a/src/lib/RigConfig.ts b/src/lib/RigConfig.tsindex 708f807..3eb042d 100644--- a/src/lib/RigConfig.ts+++ b/src/lib/RigConfig.ts@@ -130,4 +130,31 @@ export class RigConfig {select.appendChild(option)}}++ /**+ * Populate a <select> with one <option> per animation file across all rigs.+ * base_path is prepended to each filename, e.g. '../animations/'.+ * A placeholder option is always inserted first.+ */+ static populate_animation_file_select (select: HTMLSelectElement, base_path: string): void {+ select.innerHTML = ''+ const placeholder = document.createElement('option')+ placeholder.value = ''+ placeholder.textContent = 'Pick a 3d animation to generate previews'+ select.appendChild(placeholder)+ for (const rig of this.all) {+ for (const file of rig.animation_files) {+ const option = document.createElement('option')+ option.value = `${base_path}${file}`+ // derive a readable label from the filename, e.g. 'human-base-animations.glb' -> 'Human Base Animations'+ const label = file+ .replace(/\.glb$/i, '')+ .split('-')+ .map(w => w.charAt(0).toUpperCase() + w.slice(1))+ .join(' ')+ option.textContent = label+ select.appendChild(option)+ }+ }+ }}diff --git a/src/preview-generator/index.html b/src/preview-generator/index.htmlindex a8564ca..efe4c1b 100644--- a/src/preview-generator/index.html+++ b/src/preview-generator/index.html@@ -14,13 +14,7 @@<button id="record-button" style="position: absolute; top: 20px; right: 20px;">Record</button><select id="animation-file-dropdown" style="position: absolute; top: 20px; left: 20px;">- <option>Pick a 3d animation to generate previews</option>- <option value="../animations/human-base-animations.glb">Human Base Animations</option>- <option value="../animations/human-addon-animations.glb">Human Addon Animations</option>- <option value="../animations/fox-animations.glb">Fox Animations</option>- <option value="../animations/bird-animations.glb">Bird Animations</option>- <option value="../animations/dragon-animations.glb">Dragon Animations</option>- <option value="../animations/kaiju-animations.glb">Kaiju Animations</option>+ <!-- populated dynamically from RigConfig --></select></body>diff --git a/src/preview-generator/preview-generator.ts b/src/preview-generator/preview-generator.tsindex 0fd0571..ea39a0b 100644--- a/src/preview-generator/preview-generator.ts+++ b/src/preview-generator/preview-generator.ts@@ -6,10 +6,10 @@ import { WebMRecorder } from './webm-recorder.ts'import { saveAs } from 'file-saver'import JSZip from 'jszip'-import { Utility } from '../lib/Utilities.ts'import { Generators } from '../lib/Generators.ts'import { ThemeManager } from '../lib/ThemeManager.ts'import { AnimationUtility } from '../lib/processes/animations-listing/AnimationUtility.ts'+import { RigConfig } from '../lib/RigConfig.ts'class PreviewGenerator {private readonly renderer_: THREE.WebGLRenderer@@ -227,9 +227,14 @@ class PreviewGenerator {const app = new PreviewGenerator()+// Populate animation file dropdown from central rig config+const animation_file_dropdown = document.getElementById('animation-file-dropdown') as HTMLSelectElement | null+if (animation_file_dropdown !== null) {+ RigConfig.populate_animation_file_select(animation_file_dropdown, '../animations/')+}+// look out for select change// don't start the application logic until we pick a model to use-const animation_file_dropdown = document.getElementById('animation-file-dropdown')animation_file_dropdown?.addEventListener('change', (event) => {const selected_file = (event.target as HTMLSelectElement).value