shaders 2.3.54 → 2.3.55
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/core/index.js +71 -38
- package/dist/core/performanceTracker.d.ts +12 -0
- package/dist/core/performanceTracker.d.ts.map +1 -1
- package/dist/core/renderer.d.ts.map +1 -1
- package/dist/core/telemetry/index.js +2 -2
- package/dist/vue/Shader.vue_vue_type_script_setup_true_lang.js +14 -9
- package/dist/vue/engine/Shader.vue.d.ts +4 -0
- package/dist/vue/engine/Shader.vue.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/core/index.js
CHANGED
|
@@ -258,6 +258,8 @@ function applyMask(target, mask, maskType = "alpha") {
|
|
|
258
258
|
}
|
|
259
259
|
var PerformanceTracker = class {
|
|
260
260
|
frameTimesMs = [];
|
|
261
|
+
frameTimesIndex = 0;
|
|
262
|
+
frameTimesCount = 0;
|
|
261
263
|
maxSamples = 60;
|
|
262
264
|
targetFrameTime = 16.67;
|
|
263
265
|
jankFrameCount = 0;
|
|
@@ -272,16 +274,37 @@ var PerformanceTracker = class {
|
|
|
272
274
|
isRendering = false;
|
|
273
275
|
lastFrameTimestamp = 0;
|
|
274
276
|
frameIntervals = [];
|
|
277
|
+
frameIntervalsIndex = 0;
|
|
278
|
+
frameIntervalsCount = 0;
|
|
279
|
+
pushToCircularBuffer(buffer, value, index, _count, maxSize) {
|
|
280
|
+
if (buffer.length < maxSize) {
|
|
281
|
+
buffer.push(value);
|
|
282
|
+
return {
|
|
283
|
+
index: buffer.length,
|
|
284
|
+
count: buffer.length
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
buffer[index % maxSize] = value;
|
|
288
|
+
return {
|
|
289
|
+
index: index + 1,
|
|
290
|
+
count: maxSize
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
getBufferValues(buffer, count) {
|
|
294
|
+
return count <= buffer.length ? buffer.slice(0, count) : buffer;
|
|
295
|
+
}
|
|
275
296
|
recordFrame(frameTimeMs) {
|
|
276
|
-
this.frameTimesMs.
|
|
277
|
-
|
|
297
|
+
const result = this.pushToCircularBuffer(this.frameTimesMs, frameTimeMs, this.frameTimesIndex, this.frameTimesCount, this.maxSamples);
|
|
298
|
+
this.frameTimesIndex = result.index;
|
|
299
|
+
this.frameTimesCount = result.count;
|
|
278
300
|
this.totalFrameCount++;
|
|
279
301
|
if (frameTimeMs > this.targetFrameTime) this.jankFrameCount++;
|
|
280
302
|
const now = performance.now();
|
|
281
303
|
if (this.lastFrameTimestamp > 0) {
|
|
282
304
|
const interval = now - this.lastFrameTimestamp;
|
|
283
|
-
this.frameIntervals.
|
|
284
|
-
|
|
305
|
+
const intervalResult = this.pushToCircularBuffer(this.frameIntervals, interval, this.frameIntervalsIndex, this.frameIntervalsCount, this.maxSamples);
|
|
306
|
+
this.frameIntervalsIndex = intervalResult.index;
|
|
307
|
+
this.frameIntervalsCount = intervalResult.count;
|
|
285
308
|
}
|
|
286
309
|
this.lastFrameTimestamp = now;
|
|
287
310
|
this.recordMemorySnapshot();
|
|
@@ -357,12 +380,13 @@ var PerformanceTracker = class {
|
|
|
357
380
|
return this.nodeCount + this.rttNodeCount * 10;
|
|
358
381
|
}
|
|
359
382
|
calculateIntensityScore() {
|
|
360
|
-
const
|
|
383
|
+
const frameTimes = this.getBufferValues(this.frameTimesMs, this.frameTimesCount);
|
|
384
|
+
const frameCount = frameTimes.length;
|
|
361
385
|
if (frameCount === 0) return {
|
|
362
386
|
score: 0,
|
|
363
387
|
label: "N/A"
|
|
364
388
|
};
|
|
365
|
-
const avgFrameTime =
|
|
389
|
+
const avgFrameTime = frameTimes.reduce((a, b) => a + b, 0) / frameCount;
|
|
366
390
|
const frameTimeScore = Math.min(avgFrameTime / 16.67 * 100, 100);
|
|
367
391
|
const complexity = this.calculateComplexityScore();
|
|
368
392
|
const complexityScore = Math.min(complexity / 100 * 100, 100);
|
|
@@ -390,13 +414,15 @@ var PerformanceTracker = class {
|
|
|
390
414
|
};
|
|
391
415
|
}
|
|
392
416
|
getStats(rendererInfo) {
|
|
393
|
-
const
|
|
394
|
-
const
|
|
395
|
-
const
|
|
396
|
-
const
|
|
397
|
-
const
|
|
398
|
-
const
|
|
399
|
-
const
|
|
417
|
+
const frameTimes = this.getBufferValues(this.frameTimesMs, this.frameTimesCount);
|
|
418
|
+
const intervals = this.getBufferValues(this.frameIntervals, this.frameIntervalsCount);
|
|
419
|
+
const frameCount = frameTimes.length;
|
|
420
|
+
const fps = intervals.length > 0 ? 1e3 / (intervals.reduce((a, b) => a + b, 0) / intervals.length) : 0;
|
|
421
|
+
const avgFrameTime = frameCount > 0 ? frameTimes.reduce((a, b) => a + b, 0) / frameCount : 0;
|
|
422
|
+
const minFrameTime = frameCount > 0 ? Math.min(...frameTimes) : 0;
|
|
423
|
+
const maxFrameTime = frameCount > 0 ? Math.max(...frameTimes) : 0;
|
|
424
|
+
const p99FrameTime = this.calculateP99(frameTimes);
|
|
425
|
+
const stdDevFrameTime = this.calculateStdDev(frameTimes);
|
|
400
426
|
const jankPercent = this.totalFrameCount > 0 ? this.jankFrameCount / this.totalFrameCount * 100 : 0;
|
|
401
427
|
const memory = performance.memory;
|
|
402
428
|
const memoryUsedMB = memory ? memory.usedJSHeapSize / (1024 * 1024) : null;
|
|
@@ -433,7 +459,11 @@ var PerformanceTracker = class {
|
|
|
433
459
|
}
|
|
434
460
|
reset() {
|
|
435
461
|
this.frameTimesMs.length = 0;
|
|
462
|
+
this.frameTimesIndex = 0;
|
|
463
|
+
this.frameTimesCount = 0;
|
|
436
464
|
this.frameIntervals.length = 0;
|
|
465
|
+
this.frameIntervalsIndex = 0;
|
|
466
|
+
this.frameIntervalsCount = 0;
|
|
437
467
|
this.lastFrameTimestamp = 0;
|
|
438
468
|
this.jankFrameCount = 0;
|
|
439
469
|
this.totalFrameCount = 0;
|
|
@@ -654,7 +684,7 @@ function shaderRenderer() {
|
|
|
654
684
|
});
|
|
655
685
|
});
|
|
656
686
|
lastRenderTime = 0;
|
|
657
|
-
renderFrame()
|
|
687
|
+
renderFrame();
|
|
658
688
|
});
|
|
659
689
|
}
|
|
660
690
|
};
|
|
@@ -755,7 +785,7 @@ function shaderRenderer() {
|
|
|
755
785
|
isUpdatingMaterial = false;
|
|
756
786
|
pendingNodeRemoval = false;
|
|
757
787
|
}
|
|
758
|
-
if (!animationFrameId) renderFrame()
|
|
788
|
+
if (!animationFrameId) renderFrame();
|
|
759
789
|
};
|
|
760
790
|
const findChildNodes = (parentId) => {
|
|
761
791
|
const childIds = parentToChildren.get(parentId);
|
|
@@ -1120,7 +1150,7 @@ function shaderRenderer() {
|
|
|
1120
1150
|
if (!uniformDefinition || !uniformDefinition.uniform) return;
|
|
1121
1151
|
if (uniformDefinition.transform) updateUniformValue(uniformDefinition, value);
|
|
1122
1152
|
else uniformDefinition.uniform.value = value;
|
|
1123
|
-
if (!animationFrameId) renderFrame()
|
|
1153
|
+
if (!animationFrameId) renderFrame();
|
|
1124
1154
|
};
|
|
1125
1155
|
const updateNodeMetadata = (nodeId, metadata) => {
|
|
1126
1156
|
const existingNode = nodeRegistry.nodes.get(nodeId);
|
|
@@ -1185,7 +1215,7 @@ function shaderRenderer() {
|
|
|
1185
1215
|
materialUpdateBatchRAF = null;
|
|
1186
1216
|
updateMaterial();
|
|
1187
1217
|
});
|
|
1188
|
-
} else if (!animationFrameId) renderFrame()
|
|
1218
|
+
} else if (!animationFrameId) renderFrame();
|
|
1189
1219
|
};
|
|
1190
1220
|
const removeNode = (id) => {
|
|
1191
1221
|
if (!nodeRegistry.nodes.has(id)) return;
|
|
@@ -1254,7 +1284,7 @@ function shaderRenderer() {
|
|
|
1254
1284
|
};
|
|
1255
1285
|
const renderAndWait = async () => {
|
|
1256
1286
|
if (!canRender()) throw new Error("Renderer is not ready");
|
|
1257
|
-
|
|
1287
|
+
renderFrame();
|
|
1258
1288
|
if (renderer instanceof WebGPURenderer) try {
|
|
1259
1289
|
const backend = renderer.backend;
|
|
1260
1290
|
if (backend?.device) await backend.device.queue.onSubmittedWorkDone();
|
|
@@ -1262,7 +1292,7 @@ function shaderRenderer() {
|
|
|
1262
1292
|
await new Promise((resolve) => setTimeout(resolve, 16));
|
|
1263
1293
|
}
|
|
1264
1294
|
};
|
|
1265
|
-
const renderFrame =
|
|
1295
|
+
const renderFrame = () => {
|
|
1266
1296
|
if (pendingNodeRemoval) return;
|
|
1267
1297
|
if (!canRender()) return;
|
|
1268
1298
|
const frameStartTime = enablePerformanceTracking ? performance.now() : 0;
|
|
@@ -1335,15 +1365,23 @@ function shaderRenderer() {
|
|
|
1335
1365
|
const startAnimation = () => {
|
|
1336
1366
|
if (animationFrameId || !shouldAnimate) return;
|
|
1337
1367
|
performanceTracker.setRendering(true);
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1368
|
+
if (renderer && "setAnimationLoop" in renderer && typeof renderer.setAnimationLoop === "function") {
|
|
1369
|
+
renderer.setAnimationLoop(() => {
|
|
1370
|
+
renderFrame();
|
|
1371
|
+
});
|
|
1372
|
+
animationFrameId = 1;
|
|
1373
|
+
} else {
|
|
1374
|
+
const animate = () => {
|
|
1375
|
+
renderFrame();
|
|
1376
|
+
animationFrameId = requestAnimationFrame(animate);
|
|
1377
|
+
};
|
|
1378
|
+
animate();
|
|
1379
|
+
}
|
|
1343
1380
|
};
|
|
1344
1381
|
const stopAnimation = () => {
|
|
1345
1382
|
if (animationFrameId) {
|
|
1346
|
-
|
|
1383
|
+
if (renderer && "setAnimationLoop" in renderer && typeof renderer.setAnimationLoop === "function") renderer.setAnimationLoop(null);
|
|
1384
|
+
else cancelAnimationFrame(animationFrameId);
|
|
1347
1385
|
animationFrameId = null;
|
|
1348
1386
|
}
|
|
1349
1387
|
performanceTracker.setRendering(false);
|
|
@@ -1377,20 +1415,20 @@ function shaderRenderer() {
|
|
|
1377
1415
|
const globalMouseUpHandler = () => {
|
|
1378
1416
|
if (!isInitialized) return;
|
|
1379
1417
|
pointerActive = false;
|
|
1380
|
-
if (!animationFrameId) renderFrame()
|
|
1418
|
+
if (!animationFrameId) renderFrame();
|
|
1381
1419
|
};
|
|
1382
1420
|
const globalTouchEndHandler = () => {
|
|
1383
1421
|
if (!isInitialized) return;
|
|
1384
1422
|
pointerActive = false;
|
|
1385
|
-
if (!animationFrameId) renderFrame()
|
|
1423
|
+
if (!animationFrameId) renderFrame();
|
|
1386
1424
|
};
|
|
1387
1425
|
const canvasMouseDownHandler = () => {
|
|
1388
1426
|
pointerActive = true;
|
|
1389
|
-
if (!animationFrameId) renderFrame()
|
|
1427
|
+
if (!animationFrameId) renderFrame();
|
|
1390
1428
|
};
|
|
1391
1429
|
const canvasTouchStartHandler = () => {
|
|
1392
1430
|
pointerActive = true;
|
|
1393
|
-
if (!animationFrameId) renderFrame()
|
|
1431
|
+
if (!animationFrameId) renderFrame();
|
|
1394
1432
|
};
|
|
1395
1433
|
const processQueuedRegistrations = () => {
|
|
1396
1434
|
if (pendingRegistrationQueue.length === 0) return;
|
|
@@ -1398,7 +1436,7 @@ function shaderRenderer() {
|
|
|
1398
1436
|
pendingRegistrationQueue = [];
|
|
1399
1437
|
for (const { id, fragmentNodeFunc, parentId, metadata, uniforms, componentDefinition } of queue) if (fragmentNodeFunc) registerNode(id, fragmentNodeFunc, parentId, metadata, uniforms, componentDefinition);
|
|
1400
1438
|
};
|
|
1401
|
-
const initialize = async ({ canvas, enablePerformanceTracking: enableTracking =
|
|
1439
|
+
const initialize = async ({ canvas, enablePerformanceTracking: enableTracking = false }) => {
|
|
1402
1440
|
if (isInitialized || isInitializing) return;
|
|
1403
1441
|
enablePerformanceTracking = enableTracking;
|
|
1404
1442
|
isInitializing = true;
|
|
@@ -1425,18 +1463,13 @@ function shaderRenderer() {
|
|
|
1425
1463
|
window.addEventListener("beforeunload", unloadHandler);
|
|
1426
1464
|
if (localAbortController.signal.aborted) return;
|
|
1427
1465
|
try {
|
|
1428
|
-
|
|
1466
|
+
renderer = new WebGPURenderer({
|
|
1429
1467
|
canvas,
|
|
1430
1468
|
antialias: true,
|
|
1431
1469
|
alpha: true,
|
|
1432
1470
|
depth: false,
|
|
1433
1471
|
powerPreference: "high-performance"
|
|
1434
|
-
};
|
|
1435
|
-
if (enablePerformanceTracking) {
|
|
1436
|
-
rendererOptions.forceWebGL = false;
|
|
1437
|
-
rendererOptions.requiredFeatures = ["timestamp-query"];
|
|
1438
|
-
}
|
|
1439
|
-
renderer = new WebGPURenderer(rendererOptions);
|
|
1472
|
+
});
|
|
1440
1473
|
await renderer.init();
|
|
1441
1474
|
if (localAbortController.signal.aborted) return;
|
|
1442
1475
|
} catch (e) {
|
|
@@ -1493,7 +1526,7 @@ function shaderRenderer() {
|
|
|
1493
1526
|
camera.bottom = -frustumHeight / 2;
|
|
1494
1527
|
camera.updateProjectionMatrix();
|
|
1495
1528
|
mesh.scale.set(frustumWidth, frustumHeight, 1);
|
|
1496
|
-
|
|
1529
|
+
renderFrame();
|
|
1497
1530
|
} else hasInitialDimensions = false;
|
|
1498
1531
|
if (shouldAnimate) startAnimation();
|
|
1499
1532
|
if (!localAbortController.signal.aborted) {
|
|
@@ -28,6 +28,8 @@ export interface PerformanceStats {
|
|
|
28
28
|
}
|
|
29
29
|
export declare class PerformanceTracker {
|
|
30
30
|
private frameTimesMs;
|
|
31
|
+
private frameTimesIndex;
|
|
32
|
+
private frameTimesCount;
|
|
31
33
|
private readonly maxSamples;
|
|
32
34
|
private readonly targetFrameTime;
|
|
33
35
|
private jankFrameCount;
|
|
@@ -42,6 +44,16 @@ export declare class PerformanceTracker {
|
|
|
42
44
|
private isRendering;
|
|
43
45
|
private lastFrameTimestamp;
|
|
44
46
|
private frameIntervals;
|
|
47
|
+
private frameIntervalsIndex;
|
|
48
|
+
private frameIntervalsCount;
|
|
49
|
+
/**
|
|
50
|
+
* Adds a value to a circular buffer, returning the active slice for calculations
|
|
51
|
+
*/
|
|
52
|
+
private pushToCircularBuffer;
|
|
53
|
+
/**
|
|
54
|
+
* Gets the active values from a circular buffer
|
|
55
|
+
*/
|
|
56
|
+
private getBufferValues;
|
|
45
57
|
/**
|
|
46
58
|
* Records a frame's render time
|
|
47
59
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"performanceTracker.d.ts","sourceRoot":"","sources":["../src/performanceTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,gBAAgB;IAE7B,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;IAGvB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IAGnB,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;IAGvB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAG/B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAGlB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAG3B,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IAGtB,WAAW,EAAE,OAAO,CAAA;CACvB;AAED,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAK;IAChC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAQ;IAExC,OAAO,CAAC,cAAc,CAAI;IAC1B,OAAO,CAAC,eAAe,CAAI;IAE3B,OAAO,C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aAAY,WAAW,wBAA6B,mBAAmB,KAAG,IAAI;qBA0R5M,MAAM,KAAG,IAAI;iCAxID,MAAM,eAAe,MAAM,SAAS,GAAG,KAAG,IAAI;iCAgC9C,MAAM,YAAY,OAAO,CAAC,YAAY,CAAC,KAAG,IAAI;;0BAmYvD,IAAI;yBAyBL,IAAI;yBA9ME,OAAO,CAAC,IAAI,CAAC;+BAoKb,gBAAgB;;eAsemB,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC;;2BAjBpE,QAAQ,GAAG,OAAO,GAAG,IAAI;;;mCAljDnB,MAAM,KAAG,QAAQ,EAAE;oCAuCzC,IAAI,YACF,QAAQ,UACV,MAAM,kBACE,GAAG,CAAC,MAAM,CAAC,gBACb,IAAI,KACnB,IAAI;0CAuCK,IAAI,YACF,QAAQ,KACnB,IAAI;;;;EA2/CV"}
|
|
@@ -2,7 +2,7 @@ const TELEMETRY_CONFIG = {
|
|
|
2
2
|
samplingRate: .01,
|
|
3
3
|
collectionDuration: 5e3,
|
|
4
4
|
warmupDuration: 500,
|
|
5
|
-
sampleInterval:
|
|
5
|
+
sampleInterval: 500,
|
|
6
6
|
apiEndpoint: "https://shaders.com/api/telemetry"
|
|
7
7
|
};
|
|
8
8
|
function detectBrowserFamily(userAgent) {
|
|
@@ -68,7 +68,7 @@ var TelemetryCollector = class {
|
|
|
68
68
|
clearInterval(this.sampleInterval);
|
|
69
69
|
this.sampleInterval = null;
|
|
70
70
|
}
|
|
71
|
-
if (!this.stopped && this.frameSamples.length >=
|
|
71
|
+
if (!this.stopped && this.frameSamples.length >= 5) {
|
|
72
72
|
const payload = this.aggregateData();
|
|
73
73
|
await this.sendTelemetry(payload);
|
|
74
74
|
}
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
import { createElementBlock, createElementVNode, defineComponent, mergeProps, onBeforeUnmount, onMounted, openBlock, provide, ref, renderSlot } from "vue";
|
|
1
|
+
import { createElementBlock, createElementVNode, defineComponent, mergeProps, onBeforeUnmount, onMounted, openBlock, provide, ref, renderSlot, shallowRef } from "vue";
|
|
2
2
|
import { shaderRenderer } from "../core/index.js";
|
|
3
3
|
import { vec4 } from "three/tsl";
|
|
4
4
|
import { TelemetryCollector, isExternalUser, shouldCollectTelemetry } from "../core/telemetry/index.js";
|
|
5
5
|
var Shader_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
6
6
|
__name: "Shader",
|
|
7
|
-
props: {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
props: {
|
|
8
|
+
disableTelemetry: {
|
|
9
|
+
type: Boolean,
|
|
10
|
+
default: false
|
|
11
|
+
},
|
|
12
|
+
enablePerformanceTracking: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
default: false
|
|
15
|
+
}
|
|
16
|
+
},
|
|
11
17
|
setup(__props, { expose: __expose }) {
|
|
12
18
|
const props = __props;
|
|
13
19
|
const containerRef = ref(null);
|
|
14
20
|
const canvasRef = ref(null);
|
|
15
21
|
const rootId = ref("shader-root-" + Math.random().toString(36).substring(7));
|
|
16
|
-
const rendererInstance =
|
|
22
|
+
const rendererInstance = shallowRef(shaderRenderer());
|
|
17
23
|
const rendererResetSignal = ref(0);
|
|
18
24
|
let telemetryCollector = null;
|
|
19
25
|
let telemetryStartTimeout = null;
|
|
@@ -33,7 +39,7 @@ var Shader_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineC
|
|
|
33
39
|
if (!canvasRef.value) return;
|
|
34
40
|
if (!rendererInstance.value.isInitialized()) await rendererInstance.value.initialize({
|
|
35
41
|
canvas: canvasRef.value,
|
|
36
|
-
enablePerformanceTracking:
|
|
42
|
+
enablePerformanceTracking: props.enablePerformanceTracking
|
|
37
43
|
});
|
|
38
44
|
rendererInstance.value.registerNode(rootId.value, ({ childNode }) => childNode || vec4(0, 0, 0, 0), null, null, {}, void 0);
|
|
39
45
|
if (isExternalUser() && shouldCollectTelemetry(props.disableTelemetry) && !telemetryCollector) startTelemetryWhenReady();
|
|
@@ -55,8 +61,7 @@ var Shader_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineC
|
|
|
55
61
|
visibilityObserver = new IntersectionObserver((entries) => {
|
|
56
62
|
const entry = entries[0];
|
|
57
63
|
if (!entry) return;
|
|
58
|
-
const
|
|
59
|
-
const isCurrentlyVisible = entry.isIntersecting && rect && rect.width > 0 && rect.height > 0;
|
|
64
|
+
const isCurrentlyVisible = entry.isIntersecting;
|
|
60
65
|
if (isCurrentlyVisible && !wasVisible) {
|
|
61
66
|
if (rendererInstance.value.isInitialized()) {
|
|
62
67
|
rendererInstance.value.startAnimation();
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
interface Props {
|
|
2
2
|
disableTelemetry?: boolean;
|
|
3
|
+
enablePerformanceTracking?: boolean;
|
|
3
4
|
}
|
|
4
5
|
declare function __VLS_template(): {
|
|
5
6
|
default?(_: {}): any;
|
|
6
7
|
};
|
|
7
8
|
declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
|
|
8
9
|
disableTelemetry: boolean;
|
|
10
|
+
enablePerformanceTracking: boolean;
|
|
9
11
|
}>>, {
|
|
10
12
|
captureScreenshot: (maxWidth?: number) => Promise<Blob>;
|
|
11
13
|
getPerformanceStats: () => import('../../core').PerformanceStats;
|
|
12
14
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
|
|
13
15
|
disableTelemetry: boolean;
|
|
16
|
+
enablePerformanceTracking: boolean;
|
|
14
17
|
}>>> & Readonly<{}>, {
|
|
15
18
|
disableTelemetry: boolean;
|
|
19
|
+
enablePerformanceTracking: boolean;
|
|
16
20
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
17
21
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
18
22
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Shader.vue.d.ts","sourceRoot":"","sources":["../../src/engine/Shader.vue"],"names":[],"mappings":"AASA,UAAU,KAAK;IACb,gBAAgB,CAAC,EAAE,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Shader.vue.d.ts","sourceRoot":"","sources":["../../src/engine/Shader.vue"],"names":[],"mappings":"AASA,UAAU,KAAK;IACb,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,yBAAyB,CAAC,EAAE,OAAO,CAAA;CACpC;AAiRD,iBAAS,cAAc;qBAkDO,GAAG;EAKhC;AAUD,QAAA,MAAM,eAAe;;;;8CA/K8B,OAAO,CAAC,IAAI,CAAC;;;;;;sBArK3C,OAAO;+BACE,OAAO;4EA0VnC,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAAvG,wBAAwG;AACxG,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AACjE,KAAK,6BAA6B,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CAAE,CAAC;AAC9M,KAAK,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI;KAE1B,CAAC,IAAI,MAAM,IAAI,CAAC,CAA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