Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

More moving files to appropriate steps and breaking out interfaces to their own folders

Scott Petrovic28ff2a82dc79
diff --git a/src/lib/UI.ts b/src/lib/UI.ts
index aec9ade..8d2cce6 100644
--- a/src/lib/UI.ts
+++ b/src/lib/UI.ts
@@ -68,7 +68,6 @@ export class UI {
private constructor () {
this.initialize_dom_elements()
- // AnimationSearch will be initialized when needed
}
public static getInstance (): UI {
diff --git a/src/lib/Utilities.ts b/src/lib/Utilities.ts
index aee92d8..a053d01 100644
--- a/src/lib/Utilities.ts
+++ b/src/lib/Utilities.ts
@@ -2,9 +2,9 @@ import {
Vector3, Vector2, type Object3D, Mesh, Group, Bone, type Skeleton, Euler, Raycaster, AnimationClip, KeyframeTrack,
type PerspectiveCamera, type Scene, type Object3DEventMap, type BufferAttribute, type BufferGeometry, type InterleavedBufferAttribute
} from 'three'
-import BoneTransformState from './models/BoneTransformState'
-import type BoneCalculationData from './models/BoneCalculationData'
-import IntersectionPointData from './models/IntersectionPointData'
+import BoneTransformState from './interfaces/BoneTransformState'
+import type BoneCalculationData from './interfaces/BoneCalculationData'
+import IntersectionPointData from './interfaces/IntersectionPointData'
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
export class Utility {
diff --git a/src/lib/models/BoneCalculationData.ts b/src/lib/interfaces/BoneCalculationData.ts
similarity index 100%
rename from src/lib/models/BoneCalculationData.ts
rename to src/lib/interfaces/BoneCalculationData.ts
diff --git a/src/lib/models/BoneTesterData.ts b/src/lib/interfaces/BoneTesterData.ts
similarity index 100%
rename from src/lib/models/BoneTesterData.ts
rename to src/lib/interfaces/BoneTesterData.ts
diff --git a/src/lib/models/BoneTransformState.ts b/src/lib/interfaces/BoneTransformState.ts
similarity index 100%
rename from src/lib/models/BoneTransformState.ts
rename to src/lib/interfaces/BoneTransformState.ts
diff --git a/src/lib/models/IntersectionGeometryData.ts b/src/lib/interfaces/IntersectionGeometryData.ts
similarity index 100%
rename from src/lib/models/IntersectionGeometryData.ts
rename to src/lib/interfaces/IntersectionGeometryData.ts
diff --git a/src/lib/models/IntersectionPointData.ts b/src/lib/interfaces/IntersectionPointData.ts
similarity index 100%
rename from src/lib/models/IntersectionPointData.ts
rename to src/lib/interfaces/IntersectionPointData.ts
diff --git a/src/lib/processes/animations-listing/AnimationSearch.ts b/src/lib/processes/animations-listing/AnimationSearch.ts
index 4d21348..e7d8ecc 100644
--- a/src/lib/processes/animations-listing/AnimationSearch.ts
+++ b/src/lib/processes/animations-listing/AnimationSearch.ts
@@ -1,11 +1,7 @@
import { type AnimationClip } from 'three'
import { type ThemeManager } from '../../ThemeManager'
import { SkeletonType } from '../../enums/SkeletonType'
-
-export interface AnimationWithState extends AnimationClip {
- isChecked?: boolean
- name: string
-}
+import { type AnimationWithState } from './interfaces/AnimationWithState'
export class AnimationSearch extends EventTarget {
private all_animations: AnimationWithState[] = []
diff --git a/src/lib/processes/animations-listing/StepAnimationsListing.ts b/src/lib/processes/animations-listing/StepAnimationsListing.ts
index 5769567..a3f0d0b 100644
--- a/src/lib/processes/animations-listing/StepAnimationsListing.ts
+++ b/src/lib/processes/animations-listing/StepAnimationsListing.ts
@@ -2,32 +2,18 @@ import { UI } from '../../UI.ts'
import { AnimationPlayer } from './AnimationPlayer.ts'
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'
-import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader.js'
-import { AnimationClip, AnimationMixer, Quaternion, Vector3, type SkinnedMesh, type QuaternionKeyframeTrack,
- type KeyframeTrack, type AnimationAction, type Object3D, Bone } from 'three'
+import {
+ type AnimationClip, AnimationMixer, Quaternion, Vector3, type SkinnedMesh, type QuaternionKeyframeTrack,
+ type KeyframeTrack, type AnimationAction, type Object3D, Bone
+} from 'three'
import { SkeletonType } from '../../enums/SkeletonType.ts'
import { Utility } from '../../Utilities.ts'
import { type ThemeManager } from '../../ThemeManager.ts'
-import { AnimationSearch, type AnimationWithState } from './AnimationSearch.ts'
-
-export interface TransformedAnimationClipPair {
- /**
- * The original version of the animation clip, without any transformations
- * applied to it.
- *
- * This allows for simple non-destructive modification of the animation,
- * since we can always reset to the original.
- */
- original_animation_clip: AnimationClip
- /**
- * The warped version of the animation clip, which is what will be displayed
- * and downloaded by the user.
- */
- display_animation_clip: AnimationClip
-}
-
+import { AnimationSearch } from './AnimationSearch.ts'
+import { type TransformedAnimationClipPair } from './interfaces/TransformedAnimationClipPair.ts'
+import { AnimationWithState } from './interfaces/AnimationWithState.ts'
// Note: EventTarget is a built-ininterface and do not need to import it
export class StepAnimationsListing extends EventTarget {
@@ -36,7 +22,6 @@ export class StepAnimationsListing extends EventTarget {
private readonly animation_player: AnimationPlayer
private animation_clips_loaded: TransformedAnimationClipPair[] = []
private gltf_animation_loader: GLTFLoader = new GLTFLoader()
- private readonly fbx_animation_loader: FBXLoader = new FBXLoader()
private animation_mixer: AnimationMixer = new AnimationMixer()
private skinned_meshes_to_animate: SkinnedMesh[] = []
diff --git a/src/lib/processes/animations-listing/interfaces/AnimationWithState.ts b/src/lib/processes/animations-listing/interfaces/AnimationWithState.ts
new file mode 100644
index 0000000..e5b322e
--- /dev/null
+++ b/src/lib/processes/animations-listing/interfaces/AnimationWithState.ts
@@ -0,0 +1,6 @@
+import { type AnimationClip } from "three"
+
+export interface AnimationWithState extends AnimationClip {
+ isChecked?: boolean
+ name: string
+}
diff --git a/src/lib/processes/animations-listing/interfaces/TransformedAnimationClipPair.ts b/src/lib/processes/animations-listing/interfaces/TransformedAnimationClipPair.ts
new file mode 100644
index 0000000..152adff
--- /dev/null
+++ b/src/lib/processes/animations-listing/interfaces/TransformedAnimationClipPair.ts
@@ -0,0 +1,17 @@
+import { type AnimationClip } from "three"
+
+export interface TransformedAnimationClipPair {
+ /**
+ * The original version of the animation clip, without any transformations
+ * applied to it.
+ *
+ * This allows for simple non-destructive modification of the animation,
+ * since we can always reset to the original.
+ */
+ original_animation_clip: AnimationClip
+ /**
+ * The warped version of the animation clip, which is what will be displayed
+ * and downloaded by the user.
+ */
+ display_animation_clip: AnimationClip
+}
diff --git a/src/lib/processes/edit-skeleton/UndoRedoSystem.ts b/src/lib/processes/edit-skeleton/UndoRedoSystem.ts
index a69f7fb..23f98e3 100644
--- a/src/lib/processes/edit-skeleton/UndoRedoSystem.ts
+++ b/src/lib/processes/edit-skeleton/UndoRedoSystem.ts
@@ -1,6 +1,6 @@
import { type Skeleton, type Bone } from 'three'
import { Utility } from '../../Utilities.ts'
-import type BoneTransformState from '../../models/BoneTransformState.ts'
+import type BoneTransformState from '../../interfaces/BoneTransformState.ts'
/**
* UndoRedoSystem
diff --git a/src/lib/processes/weight-skin/StepWeightSkin.ts b/src/lib/processes/weight-skin/StepWeightSkin.ts
index 2a4eebb..df8d42c 100644
--- a/src/lib/processes/weight-skin/StepWeightSkin.ts
+++ b/src/lib/processes/weight-skin/StepWeightSkin.ts
@@ -9,7 +9,7 @@ import { SkinningFormula } from '../../enums/SkinningFormula.ts'
import { Generators } from '../../Generators.ts'
import { type BufferGeometry, type Material, type Object3D, type Skeleton, SkinnedMesh, type Scene, Group, Uint16BufferAttribute, Float32BufferAttribute } from 'three'
-import BoneTesterData from '../../models/BoneTesterData.ts'
+import BoneTesterData from '../../interfaces/BoneTesterData.ts'
import { type SkeletonType } from '../../enums/SkeletonType.ts'
import { type AbstractAutoSkinSolver } from '../../solvers/AbstractAutoSkinSolver.ts'
diff --git a/src/lib/solvers/AbstractAutoSkinSolver.ts b/src/lib/solvers/AbstractAutoSkinSolver.ts
index c556d44..6622afc 100644
--- a/src/lib/solvers/AbstractAutoSkinSolver.ts
+++ b/src/lib/solvers/AbstractAutoSkinSolver.ts
@@ -1,6 +1,6 @@
import { BufferGeometry, Object3D, type Bone } from 'three'
import { type SkeletonType } from '../enums/SkeletonType.js'
-import BoneTesterData from '../models/BoneTesterData.js'
+import BoneTesterData from '../interfaces/BoneTesterData.js'
import { Utility } from '../Utilities.js'
export abstract class AbstractAutoSkinSolver {
diff --git a/src/lib/solvers/BoneWeightsByMedianDistance.ts b/src/lib/solvers/BoneWeightsByMedianDistance.ts
index 93d4499..f11aa9b 100644
--- a/src/lib/solvers/BoneWeightsByMedianDistance.ts
+++ b/src/lib/solvers/BoneWeightsByMedianDistance.ts
@@ -1,8 +1,8 @@
import { Utility } from '../Utilities.js'
import { type Bone, BufferGeometry, Object3D, type Scene, Vector3 } from 'three'
-import BoneCalculationData from '../models/BoneCalculationData.js'
+import BoneCalculationData from '../interfaces/BoneCalculationData.js'
import { type IAutoSkinSolver } from '../interfaces/IAutoSkinSolver.js' //unused...delete to abstract class
-import BoneTesterData from '../models/BoneTesterData.js'
+import BoneTesterData from '../interfaces/BoneTesterData.js'
import { SkeletonType } from '../enums/SkeletonType.js'
/**
diff --git a/src/script.ts b/src/script.ts
index 0afa6c1..4c3f074 100644
--- a/src/script.ts
+++ b/src/script.ts
@@ -17,7 +17,7 @@ import { StepWeightSkin } from './lib/processes/weight-skin/StepWeightSkin.ts'
import { ProcessStep } from './lib/enums/ProcessStep.ts'
import { type Bone, Group, Scene, type Skeleton, type Vector3 } from 'three'
-import type BoneTesterData from './lib/models/BoneTesterData.ts'
+import type BoneTesterData from './lib/interfaces/BoneTesterData.ts'
import { build_version } from './environment.js'
import { SkeletonType } from './lib/enums/SkeletonType.ts'