reze-engine 0.8.3 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/engine.d.ts +22 -25
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +109 -325
- package/dist/model.d.ts +1 -10
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +3 -28
- package/package.json +1 -1
- package/src/engine.ts +129 -348
- package/src/model.ts +3 -35
package/src/model.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Mat4, Quat, Vec3 } from "./math"
|
|
2
2
|
import { Engine } from "./engine"
|
|
3
|
-
import { PmxLoader } from "./pmx-loader"
|
|
4
3
|
import { Rigidbody, Joint } from "./physics"
|
|
5
4
|
import { IKSolverSystem } from "./ik-solver"
|
|
6
5
|
import { VMDLoader, type VMDKeyFrame } from "./vmd-loader"
|
|
@@ -158,22 +157,6 @@ interface TweenState {
|
|
|
158
157
|
}
|
|
159
158
|
|
|
160
159
|
export class Model {
|
|
161
|
-
private static _nextId = 0
|
|
162
|
-
private static nextDefaultName(): string {
|
|
163
|
-
return "model_" + Model._nextId++
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
static async loadFrom(path: string): Promise<Model>
|
|
167
|
-
static async loadFrom(name: string, path: string): Promise<Model>
|
|
168
|
-
static async loadFrom(nameOrPath: string, path?: string): Promise<Model> {
|
|
169
|
-
const name = path === undefined ? Model.nextDefaultName() : nameOrPath
|
|
170
|
-
const pmxPath = path === undefined ? nameOrPath : path
|
|
171
|
-
const model = await PmxLoader.load(pmxPath)
|
|
172
|
-
model.setName(name)
|
|
173
|
-
await Engine.getInstance().registerModel(model, pmxPath)
|
|
174
|
-
return model
|
|
175
|
-
}
|
|
176
|
-
|
|
177
160
|
private _name: string = ""
|
|
178
161
|
|
|
179
162
|
get name(): string {
|
|
@@ -224,9 +207,6 @@ export class Model {
|
|
|
224
207
|
private morphTrackIndices: Map<string, number> = new Map()
|
|
225
208
|
private lastAppliedClip: AnimationClip | null = null
|
|
226
209
|
|
|
227
|
-
// IK and Physics enable flags
|
|
228
|
-
private ikEnabled = true
|
|
229
|
-
private physicsEnabled = true
|
|
230
210
|
|
|
231
211
|
constructor(
|
|
232
212
|
vertexData: Float32Array<ArrayBuffer>,
|
|
@@ -906,18 +886,6 @@ export class Model {
|
|
|
906
886
|
this.applyMorphs()
|
|
907
887
|
}
|
|
908
888
|
|
|
909
|
-
public setIKEnabled(enabled: boolean): void {
|
|
910
|
-
this.ikEnabled = enabled
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
public setPhysicsEnabled(enabled: boolean): void {
|
|
914
|
-
this.physicsEnabled = enabled
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
public getPhysicsEnabled(): boolean {
|
|
918
|
-
return this.physicsEnabled
|
|
919
|
-
}
|
|
920
|
-
|
|
921
889
|
getAnimationState(): AnimationState {
|
|
922
890
|
return this.animationState
|
|
923
891
|
}
|
|
@@ -1084,8 +1052,8 @@ export class Model {
|
|
|
1084
1052
|
}
|
|
1085
1053
|
}
|
|
1086
1054
|
|
|
1087
|
-
// Returns true when morphs changed (vertex buffer may need upload)
|
|
1088
|
-
update(deltaTime: number): boolean {
|
|
1055
|
+
// Returns true when morphs changed (vertex buffer may need upload). ikEnabled is driven by engine (same for all models).
|
|
1056
|
+
update(deltaTime: number, ikEnabled: boolean): boolean {
|
|
1089
1057
|
// Update tween time (in milliseconds)
|
|
1090
1058
|
this.tweenTimeMs += deltaTime * 1000
|
|
1091
1059
|
|
|
@@ -1110,7 +1078,7 @@ export class Model {
|
|
|
1110
1078
|
this.computeWorldMatrices()
|
|
1111
1079
|
|
|
1112
1080
|
// Solve IK chains (modifies localRotations with final IK rotations)
|
|
1113
|
-
if (
|
|
1081
|
+
if (ikEnabled) {
|
|
1114
1082
|
this.solveIKChains()
|
|
1115
1083
|
// Recompute world matrices with final IK rotations applied to localRotations
|
|
1116
1084
|
this.computeWorldMatrices()
|