reze-engine 0.7.0 → 0.8.1
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 +24 -45
- package/dist/animation.d.ts +0 -27
- package/dist/animation.d.ts.map +1 -1
- package/dist/animation.js +3 -17
- package/dist/camera.d.ts.map +1 -1
- package/dist/camera.js +2 -2
- package/dist/engine.d.ts +49 -52
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +613 -614
- package/dist/ik-solver.d.ts +0 -11
- package/dist/ik-solver.d.ts.map +1 -1
- package/dist/ik-solver.js +1 -11
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/math.d.ts +1 -0
- package/dist/math.d.ts.map +1 -1
- package/dist/math.js +24 -0
- package/dist/model.d.ts +10 -50
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +60 -93
- package/dist/pmx-loader.js +1 -1
- package/package.json +1 -1
- package/src/animation.ts +3 -37
- package/src/camera.ts +2 -2
- package/src/engine.ts +646 -750
- package/src/ik-solver.ts +1 -11
- package/src/index.ts +3 -4
- package/src/math.ts +27 -0
- package/src/model.ts +68 -99
- package/src/pmx-loader.ts +1 -1
package/src/animation.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Quat, Vec3 } from "./math"
|
|
2
|
-
|
|
3
1
|
export interface ControlPoint {
|
|
4
2
|
x: number
|
|
5
3
|
y: number
|
|
@@ -12,34 +10,7 @@ export interface BoneInterpolation {
|
|
|
12
10
|
translationZ: ControlPoint[]
|
|
13
11
|
}
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
rotation: [{ x: 20, y: 20 }, { x: 107, y: 107 }],
|
|
17
|
-
translationX: [{ x: 20, y: 20 }, { x: 107, y: 107 }],
|
|
18
|
-
translationY: [{ x: 20, y: 20 }, { x: 107, y: 107 }],
|
|
19
|
-
translationZ: [{ x: 20, y: 20 }, { x: 107, y: 107 }],
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface BoneKeyframe {
|
|
23
|
-
frame: number
|
|
24
|
-
rotation: Quat
|
|
25
|
-
translation: Vec3
|
|
26
|
-
interpolation: BoneInterpolation
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface MorphKeyframe {
|
|
30
|
-
frame: number
|
|
31
|
-
weight: number
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface AnimationData {
|
|
35
|
-
boneTracks: Record<string, BoneKeyframe[]>
|
|
36
|
-
morphTracks: Record<string, MorphKeyframe[]>
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Cubic bezier interpolation using binary search.
|
|
41
|
-
* Control points define the curve shape in 0-1 normalized space.
|
|
42
|
-
*/
|
|
13
|
+
// Cubic bezier in normalized 0–1 space (binary search on x)
|
|
43
14
|
export function bezierInterpolate(x1: number, x2: number, y1: number, y2: number, t: number): number {
|
|
44
15
|
t = Math.max(0, Math.min(1, t))
|
|
45
16
|
|
|
@@ -70,9 +41,7 @@ export function bezierInterpolate(x1: number, x2: number, y1: number, y2: number
|
|
|
70
41
|
|
|
71
42
|
const INV_127 = 1 / 127
|
|
72
43
|
|
|
73
|
-
|
|
74
|
-
* Convert raw VMD interpolation bytes (64-byte Uint8Array) to structured BoneInterpolation.
|
|
75
|
-
*/
|
|
44
|
+
// VMD 64-byte interpolation blob → BoneInterpolation
|
|
76
45
|
export function rawInterpolationToBoneInterpolation(raw: Uint8Array): BoneInterpolation {
|
|
77
46
|
return {
|
|
78
47
|
rotation: [
|
|
@@ -94,10 +63,7 @@ export function rawInterpolationToBoneInterpolation(raw: Uint8Array): BoneInterp
|
|
|
94
63
|
}
|
|
95
64
|
}
|
|
96
65
|
|
|
97
|
-
|
|
98
|
-
* Compute bezier-interpolated weight for a pair of control points.
|
|
99
|
-
* Control point values are in 0-127 range.
|
|
100
|
-
*/
|
|
66
|
+
// Control points are 0–127 VMD bytes
|
|
101
67
|
export function interpolateControlPoints(cp: ControlPoint[], t: number): number {
|
|
102
68
|
return bezierInterpolate(
|
|
103
69
|
cp[0].x * INV_127,
|
package/src/camera.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Mat4, Vec3 } from "./math"
|
|
2
2
|
|
|
3
|
-
const FAR =
|
|
3
|
+
const FAR = 2000
|
|
4
4
|
|
|
5
5
|
export class Camera {
|
|
6
6
|
alpha: number
|
|
@@ -29,7 +29,7 @@ export class Camera {
|
|
|
29
29
|
panSensitivity: number = 0.0002 // Sensitivity for right-click panning
|
|
30
30
|
wheelPrecision: number = 0.01
|
|
31
31
|
pinchPrecision: number = 0.05
|
|
32
|
-
minZ: number = 0.
|
|
32
|
+
minZ: number = 0.05
|
|
33
33
|
maxZ: number = FAR
|
|
34
34
|
lowerBetaLimit: number = 0.001
|
|
35
35
|
upperBetaLimit: number = Math.PI - 0.001
|