Skip to content

Commit

Permalink
feat(model): load sequence information when loading models
Browse files Browse the repository at this point in the history
  • Loading branch information
fallenoak committed Jan 5, 2024
1 parent c3e424a commit 73a5ecb
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/lib/model/M2Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import M2TextureWeight from './M2TextureWeight.js';
import M2TextureTransform from './M2TextureTransform.js';
import { m2typedArray } from './io/common.js';
import * as io from '@wowserhq/io';
import M2Sequence from './M2Sequence.js';

class M2Model {
#name: string;
Expand All @@ -25,6 +26,8 @@ class M2Model {
#materials: M2Material[] = [];
#skinProfileCount: number;

#sequences: M2Sequence[] = [];

get flags() {
return this.#flags;
}
Expand All @@ -37,6 +40,10 @@ class M2Model {
return this.#name;
}

get sequences() {
return this.#sequences;
}

get textures() {
return this.#textures;
}
Expand Down Expand Up @@ -106,6 +113,8 @@ class M2Model {

this.#loadMaterials(data);

this.#loadSequences(data);

return this;
}

Expand All @@ -115,6 +124,24 @@ class M2Model {
}
}

#loadSequences(data: any) {
for (const sequenceData of data.sequences) {
this.#sequences.push(
new M2Sequence(
sequenceData.id,
sequenceData.variationIndex,
sequenceData.duration,
sequenceData.moveSpeed,
sequenceData.flags,
sequenceData.frequency,
sequenceData.blendTime,
sequenceData.variationNext,
sequenceData.aliasNext,
),
);
}
}

#loadTextures(data: any) {
for (const textureData of data.textures) {
this.#textures.push(
Expand Down
71 changes: 71 additions & 0 deletions src/lib/model/M2Sequence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
class M2Sequence {
#id: number;
#variationIndex: number;
#duration: number;
#moveSpeed: number;
#flags: number;
#frequency: number;
#blendTime: number;
#variationNext: number;
#aliasNext: number;

constructor(
id: number,
variationIndex: number,
duration: number,
moveSpeed: number,
flags: number,
frequency: number,
blendTime: number,
variationNext: number,
aliasNext: number,
) {
this.#id = id;
this.#variationIndex = variationIndex;
this.#duration = duration;
this.#moveSpeed = moveSpeed;
this.#flags = flags;
this.#frequency = frequency;
this.#blendTime = blendTime;
this.#variationNext = variationNext;
this.#aliasNext = aliasNext;
}

get aliasNext() {
return this.#aliasNext;
}

get blendTime() {
return this.#blendTime;
}

get duration() {
return this.#duration;
}

get flags() {
return this.#flags;
}

get frequency() {
return this.#frequency;
}

get id() {
return this.#id;
}

get moveSpeed() {
return this.#moveSpeed;
}

get variationIndex() {
return this.#variationIndex;
}

get variationNext() {
return this.#variationNext;
}
}

export default M2Sequence;

0 comments on commit 73a5ecb

Please sign in to comment.