Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

preview generator have code to switch models loaded

Scott Petrovic4a6193474d0c
diff --git a/src/index.html b/src/index.html
index d6bdedc..b912e5d 100644
--- a/src/index.html
+++ b/src/index.html
@@ -277,10 +277,7 @@
<!-- Filter textbox for animations -->
<input type="text" id="animation-filter" placeholder="Filter animations...">
- <div id="animations-listing-header">
- <span>Animation name</span>
- <div style="margin-right: 1rem;">Export</div>
- </div>
+
<!-- javascript will populate this item with animations
that we get from the animations file(s) -->
diff --git a/src/preview-generator/preview-generator.ts b/src/preview-generator/preview-generator.ts
index cde9cae..7694bba 100644
--- a/src/preview-generator/preview-generator.ts
+++ b/src/preview-generator/preview-generator.ts
@@ -86,8 +86,14 @@ class PreviewGenerator {
}
public initialize (): void {
+ // swap this out. Eventually make this a UI option
+ let file_to_load: string = '../animations/human-base-animations.glb'
+ file_to_load = '../animations/quad-creature-animations.glb'
+ // file_to_load = '../animations/bird-animations.glb'
+
+
const loader = new GLTFLoader()
- loader.load('../animations/human-base-animations.glb', (gltf) => {
+ loader.load(file_to_load, (gltf) => {
this.scene_.add(gltf.scene)
// Find the first SkinnedMesh
@@ -106,11 +112,15 @@ class PreviewGenerator {
this.animation_clips = gltf.animations
- // remove all root motion data. This is the same function that the animation listing
- // does
- Utility.clean_track_data(this.animation_clips)
+ // remove all root motion data.
+ // This is the same function that the animation listing done
+ // TODO: with cleaning up data, the fox sitting has a weird height offset
+ // I would think the cleanup should work with all skeleton types
+ if (file_to_load.includes('human')) {
+ Utility.clean_track_data(this.animation_clips)
+ }
- const clip = this.animation_clips[0]
+ const clip = this.animation_clips[1]
const action = this.mixer_.clipAction(clip)
action.reset()
action.play()
diff --git a/src/styles.css b/src/styles.css
index d7746d8..3e3d635 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -66,11 +66,12 @@ h1, h2, h3, h4, h5, h6, input, button, select {
}
#animation-filter {
- width: 100%;
+ width: 95%;
padding: 0.5rem;
background-color: var(--bg-primary);
border: none;
border-radius: 4px;
+ margin-bottom: 0.5rem;
}
hr {
@@ -273,11 +274,6 @@ option {
width: 100%;
}
-#animations-listing-header {
- justify-content: space-between;
- display: flex;
- align-items: center;
-}
/* Track */