reze-engine 0.8.3 → 0.9.0
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 +50 -38
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +400 -722
- package/dist/model.d.ts +1 -13
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +3 -28
- package/dist/pmx-loader.d.ts.map +1 -1
- package/dist/pmx-loader.js +0 -17
- package/package.json +2 -2
- package/src/engine.ts +470 -790
- package/src/model.ts +3 -38
- package/src/pmx-loader.ts +0 -21
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"
|
|
@@ -37,9 +36,6 @@ export interface Material {
|
|
|
37
36
|
edgeColor: [number, number, number, number]
|
|
38
37
|
edgeSize: number
|
|
39
38
|
vertexCount: number
|
|
40
|
-
isEye?: boolean // New: marks eye materials
|
|
41
|
-
isFace?: boolean // New: marks face/skin materials
|
|
42
|
-
isHair?: boolean // New: marks hair materials
|
|
43
39
|
}
|
|
44
40
|
|
|
45
41
|
export interface Bone {
|
|
@@ -158,22 +154,6 @@ interface TweenState {
|
|
|
158
154
|
}
|
|
159
155
|
|
|
160
156
|
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
157
|
private _name: string = ""
|
|
178
158
|
|
|
179
159
|
get name(): string {
|
|
@@ -224,9 +204,6 @@ export class Model {
|
|
|
224
204
|
private morphTrackIndices: Map<string, number> = new Map()
|
|
225
205
|
private lastAppliedClip: AnimationClip | null = null
|
|
226
206
|
|
|
227
|
-
// IK and Physics enable flags
|
|
228
|
-
private ikEnabled = true
|
|
229
|
-
private physicsEnabled = true
|
|
230
207
|
|
|
231
208
|
constructor(
|
|
232
209
|
vertexData: Float32Array<ArrayBuffer>,
|
|
@@ -906,18 +883,6 @@ export class Model {
|
|
|
906
883
|
this.applyMorphs()
|
|
907
884
|
}
|
|
908
885
|
|
|
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
886
|
getAnimationState(): AnimationState {
|
|
922
887
|
return this.animationState
|
|
923
888
|
}
|
|
@@ -1084,8 +1049,8 @@ export class Model {
|
|
|
1084
1049
|
}
|
|
1085
1050
|
}
|
|
1086
1051
|
|
|
1087
|
-
// Returns true when morphs changed (vertex buffer may need upload)
|
|
1088
|
-
update(deltaTime: number): boolean {
|
|
1052
|
+
// Returns true when morphs changed (vertex buffer may need upload). ikEnabled is driven by engine (same for all models).
|
|
1053
|
+
update(deltaTime: number, ikEnabled: boolean): boolean {
|
|
1089
1054
|
// Update tween time (in milliseconds)
|
|
1090
1055
|
this.tweenTimeMs += deltaTime * 1000
|
|
1091
1056
|
|
|
@@ -1110,7 +1075,7 @@ export class Model {
|
|
|
1110
1075
|
this.computeWorldMatrices()
|
|
1111
1076
|
|
|
1112
1077
|
// Solve IK chains (modifies localRotations with final IK rotations)
|
|
1113
|
-
if (
|
|
1078
|
+
if (ikEnabled) {
|
|
1114
1079
|
this.solveIKChains()
|
|
1115
1080
|
// Recompute world matrices with final IK rotations applied to localRotations
|
|
1116
1081
|
this.computeWorldMatrices()
|
package/src/pmx-loader.ts
CHANGED
|
@@ -294,27 +294,6 @@ export class PmxLoader {
|
|
|
294
294
|
vertexCount,
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
// Classify materials based on name
|
|
298
|
-
const materialName = name.toLowerCase()
|
|
299
|
-
|
|
300
|
-
// Classify eye materials
|
|
301
|
-
mat.isEye =
|
|
302
|
-
materialName.includes("目") || // Japanese "eye"
|
|
303
|
-
materialName.includes("瞳") || // Japanese "pupil"
|
|
304
|
-
materialName.includes("eye") ||
|
|
305
|
-
materialName.includes("pupil") ||
|
|
306
|
-
materialName.includes("iris") ||
|
|
307
|
-
materialName.includes("目白") ||
|
|
308
|
-
materialName.includes("眼") ||
|
|
309
|
-
materialName.includes("睛") ||
|
|
310
|
-
materialName.includes("眉")
|
|
311
|
-
|
|
312
|
-
// Classify face materials
|
|
313
|
-
mat.isFace = materialName.includes("face") || materialName.includes("脸")
|
|
314
|
-
|
|
315
|
-
// Classify hair materials
|
|
316
|
-
mat.isHair = materialName.includes("hair_f") || materialName.includes("头发")
|
|
317
|
-
|
|
318
297
|
this.materials.push(mat)
|
|
319
298
|
}
|
|
320
299
|
} catch (error) {
|