reze-engine 0.2.16 → 0.2.17
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/dist/engine.d.ts +0 -3
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +0 -93
- package/package.json +1 -1
- package/src/engine.ts +1 -96
package/dist/engine.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ export type EngineOptions = {
|
|
|
9
9
|
export interface EngineStats {
|
|
10
10
|
fps: number;
|
|
11
11
|
frameTime: number;
|
|
12
|
-
gpuMemory: number;
|
|
13
12
|
}
|
|
14
13
|
export declare class Engine {
|
|
15
14
|
private canvas;
|
|
@@ -96,7 +95,6 @@ export declare class Engine {
|
|
|
96
95
|
private renderLoopCallback;
|
|
97
96
|
private animationFrames;
|
|
98
97
|
private animationTimeouts;
|
|
99
|
-
private gpuMemoryMB;
|
|
100
98
|
private hasAnimation;
|
|
101
99
|
private playingAnimation;
|
|
102
100
|
private breathingTimeout;
|
|
@@ -138,6 +136,5 @@ export declare class Engine {
|
|
|
138
136
|
private computeSkinMatrices;
|
|
139
137
|
private drawOutlines;
|
|
140
138
|
private updateStats;
|
|
141
|
-
private calculateGpuMemory;
|
|
142
139
|
}
|
|
143
140
|
//# sourceMappingURL=engine.d.ts.map
|
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAMnC,MAAM,MAAM,aAAa,GAAG;IAC1B,YAAY,CAAC,EAAE,IAAI,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,IAAI,CAAA;CACpB,CAAA;AAED,MAAM,WAAW,W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C,oBAAoB;IA4O5B,OAAO,CAAC,UAAU;IA+DlB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,YAAY;IA8EpB,OAAO,CAAC,WAAW;IAcnB,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,eAAe;IAQV,aAAa,CAAC,GAAG,EAAE,MAAM;IAM/B,aAAa,CAAC,OAAO,CAAC,EAAE;QAC7B,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAC/C,cAAc,CAAC,EAAE,MAAM,CAAA;KACxB;IAqKM,aAAa;IAQpB,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,cAAc;IAuDf,QAAQ,IAAI,WAAW;IAIvB,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI;IAgBnC,cAAc;IAQd,OAAO;IAYD,SAAS,CAAC,IAAI,EAAE,MAAM;IAY5B,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,UAAU,CAAC,EAAE,MAAM;YAK5D,iBAAiB;YA0GjB,cAAc;YA6Pd,qBAAqB;IAmC5B,MAAM;IAmIb,OAAO,CAAC,UAAU;IAmGlB,OAAO,CAAC,oBAAoB;IAY5B,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,eAAe;IAkBvB,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,YAAY;IAmBpB,OAAO,CAAC,WAAW;CAqBpB"}
|
package/dist/engine.js
CHANGED
|
@@ -45,13 +45,11 @@ export class Engine {
|
|
|
45
45
|
this.stats = {
|
|
46
46
|
fps: 0,
|
|
47
47
|
frameTime: 0,
|
|
48
|
-
gpuMemory: 0,
|
|
49
48
|
};
|
|
50
49
|
this.animationFrameId = null;
|
|
51
50
|
this.renderLoopCallback = null;
|
|
52
51
|
this.animationFrames = [];
|
|
53
52
|
this.animationTimeouts = [];
|
|
54
|
-
this.gpuMemoryMB = 0;
|
|
55
53
|
this.hasAnimation = false; // Set to true when loadAnimation is called
|
|
56
54
|
this.playingAnimation = false; // Set to true when playAnimation is called
|
|
57
55
|
this.breathingTimeout = null;
|
|
@@ -1468,14 +1466,6 @@ export class Engine {
|
|
|
1468
1466
|
const dir = pathParts.join("/") + "/";
|
|
1469
1467
|
this.modelDir = dir;
|
|
1470
1468
|
const model = await PmxLoader.load(path);
|
|
1471
|
-
// console.log({
|
|
1472
|
-
// vertices: Array.from(model.getVertices()),
|
|
1473
|
-
// indices: Array.from(model.getIndices()),
|
|
1474
|
-
// materials: model.getMaterials(),
|
|
1475
|
-
// textures: model.getTextures(),
|
|
1476
|
-
// bones: model.getSkeleton().bones,
|
|
1477
|
-
// skinning: { joints: Array.from(model.getSkinning().joints), weights: Array.from(model.getSkinning().weights) },
|
|
1478
|
-
// })
|
|
1479
1469
|
this.physics = new Physics(model.getRigidbodies(), model.getJoints());
|
|
1480
1470
|
await this.setupModelBuffers(model);
|
|
1481
1471
|
}
|
|
@@ -1789,7 +1779,6 @@ export class Engine {
|
|
|
1789
1779
|
}
|
|
1790
1780
|
currentIndexOffset += indexCount;
|
|
1791
1781
|
}
|
|
1792
|
-
this.gpuMemoryMB = this.calculateGpuMemory();
|
|
1793
1782
|
}
|
|
1794
1783
|
async createTextureFromPath(path) {
|
|
1795
1784
|
const cached = this.textureCache.get(path);
|
|
@@ -2095,87 +2084,5 @@ export class Engine {
|
|
|
2095
2084
|
this.framesSinceLastUpdate = 0;
|
|
2096
2085
|
this.lastFpsUpdate = now;
|
|
2097
2086
|
}
|
|
2098
|
-
this.stats.gpuMemory = this.gpuMemoryMB;
|
|
2099
|
-
}
|
|
2100
|
-
calculateGpuMemory() {
|
|
2101
|
-
let textureMemoryBytes = 0;
|
|
2102
|
-
for (const texture of this.textureCache.values()) {
|
|
2103
|
-
textureMemoryBytes += texture.width * texture.height * 4;
|
|
2104
|
-
}
|
|
2105
|
-
let bufferMemoryBytes = 0;
|
|
2106
|
-
if (this.vertexBuffer) {
|
|
2107
|
-
const vertices = this.currentModel?.getVertices();
|
|
2108
|
-
if (vertices)
|
|
2109
|
-
bufferMemoryBytes += vertices.byteLength;
|
|
2110
|
-
}
|
|
2111
|
-
if (this.indexBuffer) {
|
|
2112
|
-
const indices = this.currentModel?.getIndices();
|
|
2113
|
-
if (indices)
|
|
2114
|
-
bufferMemoryBytes += indices.byteLength;
|
|
2115
|
-
}
|
|
2116
|
-
if (this.jointsBuffer) {
|
|
2117
|
-
const skinning = this.currentModel?.getSkinning();
|
|
2118
|
-
if (skinning)
|
|
2119
|
-
bufferMemoryBytes += skinning.joints.byteLength;
|
|
2120
|
-
}
|
|
2121
|
-
if (this.weightsBuffer) {
|
|
2122
|
-
const skinning = this.currentModel?.getSkinning();
|
|
2123
|
-
if (skinning)
|
|
2124
|
-
bufferMemoryBytes += skinning.weights.byteLength;
|
|
2125
|
-
}
|
|
2126
|
-
if (this.skinMatrixBuffer) {
|
|
2127
|
-
const skeleton = this.currentModel?.getSkeleton();
|
|
2128
|
-
if (skeleton)
|
|
2129
|
-
bufferMemoryBytes += Math.max(256, skeleton.bones.length * 16 * 4);
|
|
2130
|
-
}
|
|
2131
|
-
if (this.worldMatrixBuffer) {
|
|
2132
|
-
const skeleton = this.currentModel?.getSkeleton();
|
|
2133
|
-
if (skeleton)
|
|
2134
|
-
bufferMemoryBytes += Math.max(256, skeleton.bones.length * 16 * 4);
|
|
2135
|
-
}
|
|
2136
|
-
if (this.inverseBindMatrixBuffer) {
|
|
2137
|
-
const skeleton = this.currentModel?.getSkeleton();
|
|
2138
|
-
if (skeleton)
|
|
2139
|
-
bufferMemoryBytes += Math.max(256, skeleton.bones.length * 16 * 4);
|
|
2140
|
-
}
|
|
2141
|
-
bufferMemoryBytes += 40 * 4;
|
|
2142
|
-
bufferMemoryBytes += 64 * 4;
|
|
2143
|
-
bufferMemoryBytes += 32;
|
|
2144
|
-
bufferMemoryBytes += 32;
|
|
2145
|
-
bufferMemoryBytes += 32;
|
|
2146
|
-
bufferMemoryBytes += 32;
|
|
2147
|
-
if (this.fullscreenQuadBuffer) {
|
|
2148
|
-
bufferMemoryBytes += 24 * 4;
|
|
2149
|
-
}
|
|
2150
|
-
const totalMaterialDraws = this.opaqueDraws.length +
|
|
2151
|
-
this.eyeDraws.length +
|
|
2152
|
-
this.hairDrawsOverEyes.length +
|
|
2153
|
-
this.hairDrawsOverNonEyes.length +
|
|
2154
|
-
this.transparentDraws.length;
|
|
2155
|
-
bufferMemoryBytes += totalMaterialDraws * 32;
|
|
2156
|
-
const totalOutlineDraws = this.opaqueOutlineDraws.length +
|
|
2157
|
-
this.eyeOutlineDraws.length +
|
|
2158
|
-
this.hairOutlineDraws.length +
|
|
2159
|
-
this.transparentOutlineDraws.length;
|
|
2160
|
-
bufferMemoryBytes += totalOutlineDraws * 32;
|
|
2161
|
-
let renderTargetMemoryBytes = 0;
|
|
2162
|
-
if (this.multisampleTexture) {
|
|
2163
|
-
const width = this.canvas.width;
|
|
2164
|
-
const height = this.canvas.height;
|
|
2165
|
-
renderTargetMemoryBytes += width * height * 4 * this.sampleCount;
|
|
2166
|
-
renderTargetMemoryBytes += width * height * 4;
|
|
2167
|
-
}
|
|
2168
|
-
if (this.sceneRenderTexture) {
|
|
2169
|
-
const width = this.canvas.width;
|
|
2170
|
-
const height = this.canvas.height;
|
|
2171
|
-
renderTargetMemoryBytes += width * height * 4;
|
|
2172
|
-
}
|
|
2173
|
-
if (this.bloomExtractTexture) {
|
|
2174
|
-
const width = Math.floor(this.canvas.width / this.BLOOM_DOWNSCALE_FACTOR);
|
|
2175
|
-
const height = Math.floor(this.canvas.height / this.BLOOM_DOWNSCALE_FACTOR);
|
|
2176
|
-
renderTargetMemoryBytes += width * height * 4 * 3;
|
|
2177
|
-
}
|
|
2178
|
-
const totalGPUMemoryBytes = textureMemoryBytes + bufferMemoryBytes + renderTargetMemoryBytes;
|
|
2179
|
-
return Math.round((totalGPUMemoryBytes / 1024 / 1024) * 100) / 100;
|
|
2180
2087
|
}
|
|
2181
2088
|
}
|
package/package.json
CHANGED
package/src/engine.ts
CHANGED
|
@@ -16,7 +16,6 @@ export type EngineOptions = {
|
|
|
16
16
|
export interface EngineStats {
|
|
17
17
|
fps: number
|
|
18
18
|
frameTime: number // ms
|
|
19
|
-
gpuMemory: number // MB (estimated total GPU memory)
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
interface DrawCall {
|
|
@@ -128,14 +127,12 @@ export class Engine {
|
|
|
128
127
|
private stats: EngineStats = {
|
|
129
128
|
fps: 0,
|
|
130
129
|
frameTime: 0,
|
|
131
|
-
gpuMemory: 0,
|
|
132
130
|
}
|
|
133
131
|
private animationFrameId: number | null = null
|
|
134
132
|
private renderLoopCallback: (() => void) | null = null
|
|
135
133
|
|
|
136
134
|
private animationFrames: VMDKeyFrame[] = []
|
|
137
135
|
private animationTimeouts: number[] = []
|
|
138
|
-
private gpuMemoryMB: number = 0
|
|
139
136
|
private hasAnimation = false // Set to true when loadAnimation is called
|
|
140
137
|
private playingAnimation = false // Set to true when playAnimation is called
|
|
141
138
|
private breathingTimeout: number | null = null
|
|
@@ -1668,14 +1665,7 @@ export class Engine {
|
|
|
1668
1665
|
this.modelDir = dir
|
|
1669
1666
|
|
|
1670
1667
|
const model = await PmxLoader.load(path)
|
|
1671
|
-
|
|
1672
|
-
// vertices: Array.from(model.getVertices()),
|
|
1673
|
-
// indices: Array.from(model.getIndices()),
|
|
1674
|
-
// materials: model.getMaterials(),
|
|
1675
|
-
// textures: model.getTextures(),
|
|
1676
|
-
// bones: model.getSkeleton().bones,
|
|
1677
|
-
// skinning: { joints: Array.from(model.getSkinning().joints), weights: Array.from(model.getSkinning().weights) },
|
|
1678
|
-
// })
|
|
1668
|
+
|
|
1679
1669
|
this.physics = new Physics(model.getRigidbodies(), model.getJoints())
|
|
1680
1670
|
await this.setupModelBuffers(model)
|
|
1681
1671
|
}
|
|
@@ -2042,8 +2032,6 @@ export class Engine {
|
|
|
2042
2032
|
|
|
2043
2033
|
currentIndexOffset += indexCount
|
|
2044
2034
|
}
|
|
2045
|
-
|
|
2046
|
-
this.gpuMemoryMB = this.calculateGpuMemory()
|
|
2047
2035
|
}
|
|
2048
2036
|
|
|
2049
2037
|
private async createTextureFromPath(path: string): Promise<GPUTexture | null> {
|
|
@@ -2400,88 +2388,5 @@ export class Engine {
|
|
|
2400
2388
|
this.framesSinceLastUpdate = 0
|
|
2401
2389
|
this.lastFpsUpdate = now
|
|
2402
2390
|
}
|
|
2403
|
-
|
|
2404
|
-
this.stats.gpuMemory = this.gpuMemoryMB
|
|
2405
|
-
}
|
|
2406
|
-
|
|
2407
|
-
private calculateGpuMemory(): number {
|
|
2408
|
-
let textureMemoryBytes = 0
|
|
2409
|
-
for (const texture of this.textureCache.values()) {
|
|
2410
|
-
textureMemoryBytes += texture.width * texture.height * 4
|
|
2411
|
-
}
|
|
2412
|
-
|
|
2413
|
-
let bufferMemoryBytes = 0
|
|
2414
|
-
if (this.vertexBuffer) {
|
|
2415
|
-
const vertices = this.currentModel?.getVertices()
|
|
2416
|
-
if (vertices) bufferMemoryBytes += vertices.byteLength
|
|
2417
|
-
}
|
|
2418
|
-
if (this.indexBuffer) {
|
|
2419
|
-
const indices = this.currentModel?.getIndices()
|
|
2420
|
-
if (indices) bufferMemoryBytes += indices.byteLength
|
|
2421
|
-
}
|
|
2422
|
-
if (this.jointsBuffer) {
|
|
2423
|
-
const skinning = this.currentModel?.getSkinning()
|
|
2424
|
-
if (skinning) bufferMemoryBytes += skinning.joints.byteLength
|
|
2425
|
-
}
|
|
2426
|
-
if (this.weightsBuffer) {
|
|
2427
|
-
const skinning = this.currentModel?.getSkinning()
|
|
2428
|
-
if (skinning) bufferMemoryBytes += skinning.weights.byteLength
|
|
2429
|
-
}
|
|
2430
|
-
if (this.skinMatrixBuffer) {
|
|
2431
|
-
const skeleton = this.currentModel?.getSkeleton()
|
|
2432
|
-
if (skeleton) bufferMemoryBytes += Math.max(256, skeleton.bones.length * 16 * 4)
|
|
2433
|
-
}
|
|
2434
|
-
if (this.worldMatrixBuffer) {
|
|
2435
|
-
const skeleton = this.currentModel?.getSkeleton()
|
|
2436
|
-
if (skeleton) bufferMemoryBytes += Math.max(256, skeleton.bones.length * 16 * 4)
|
|
2437
|
-
}
|
|
2438
|
-
if (this.inverseBindMatrixBuffer) {
|
|
2439
|
-
const skeleton = this.currentModel?.getSkeleton()
|
|
2440
|
-
if (skeleton) bufferMemoryBytes += Math.max(256, skeleton.bones.length * 16 * 4)
|
|
2441
|
-
}
|
|
2442
|
-
bufferMemoryBytes += 40 * 4
|
|
2443
|
-
bufferMemoryBytes += 64 * 4
|
|
2444
|
-
bufferMemoryBytes += 32
|
|
2445
|
-
bufferMemoryBytes += 32
|
|
2446
|
-
bufferMemoryBytes += 32
|
|
2447
|
-
bufferMemoryBytes += 32
|
|
2448
|
-
if (this.fullscreenQuadBuffer) {
|
|
2449
|
-
bufferMemoryBytes += 24 * 4
|
|
2450
|
-
}
|
|
2451
|
-
const totalMaterialDraws =
|
|
2452
|
-
this.opaqueDraws.length +
|
|
2453
|
-
this.eyeDraws.length +
|
|
2454
|
-
this.hairDrawsOverEyes.length +
|
|
2455
|
-
this.hairDrawsOverNonEyes.length +
|
|
2456
|
-
this.transparentDraws.length
|
|
2457
|
-
bufferMemoryBytes += totalMaterialDraws * 32
|
|
2458
|
-
|
|
2459
|
-
const totalOutlineDraws =
|
|
2460
|
-
this.opaqueOutlineDraws.length +
|
|
2461
|
-
this.eyeOutlineDraws.length +
|
|
2462
|
-
this.hairOutlineDraws.length +
|
|
2463
|
-
this.transparentOutlineDraws.length
|
|
2464
|
-
bufferMemoryBytes += totalOutlineDraws * 32
|
|
2465
|
-
|
|
2466
|
-
let renderTargetMemoryBytes = 0
|
|
2467
|
-
if (this.multisampleTexture) {
|
|
2468
|
-
const width = this.canvas.width
|
|
2469
|
-
const height = this.canvas.height
|
|
2470
|
-
renderTargetMemoryBytes += width * height * 4 * this.sampleCount
|
|
2471
|
-
renderTargetMemoryBytes += width * height * 4
|
|
2472
|
-
}
|
|
2473
|
-
if (this.sceneRenderTexture) {
|
|
2474
|
-
const width = this.canvas.width
|
|
2475
|
-
const height = this.canvas.height
|
|
2476
|
-
renderTargetMemoryBytes += width * height * 4
|
|
2477
|
-
}
|
|
2478
|
-
if (this.bloomExtractTexture) {
|
|
2479
|
-
const width = Math.floor(this.canvas.width / this.BLOOM_DOWNSCALE_FACTOR)
|
|
2480
|
-
const height = Math.floor(this.canvas.height / this.BLOOM_DOWNSCALE_FACTOR)
|
|
2481
|
-
renderTargetMemoryBytes += width * height * 4 * 3
|
|
2482
|
-
}
|
|
2483
|
-
|
|
2484
|
-
const totalGPUMemoryBytes = textureMemoryBytes + bufferMemoryBytes + renderTargetMemoryBytes
|
|
2485
|
-
return Math.round((totalGPUMemoryBytes / 1024 / 1024) * 100) / 100
|
|
2486
2391
|
}
|
|
2487
2392
|
}
|