@canvas3/nuxt 0.1.35 → 0.1.37
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/module.json
CHANGED
|
@@ -26,6 +26,17 @@ export const vCanvas3ScrollAction = {
|
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
+
updated(el, binding) {
|
|
30
|
+
if (!Canvas3.canvasInitiated.value) return;
|
|
31
|
+
const newScrollSpeedValue = binding.value?.scrollSpeedSetTo?.value;
|
|
32
|
+
if (newScrollSpeedValue !== void 0 && newScrollSpeedValue !== binding.oldValue?.scrollSpeedSetTo?.value) {
|
|
33
|
+
Canvas3.updateOnScrollActiveElement({
|
|
34
|
+
elNode: el,
|
|
35
|
+
options: binding.value,
|
|
36
|
+
arg: binding.arg
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
},
|
|
29
40
|
unmounted(el) {
|
|
30
41
|
Canvas3.removeScrollActiveElement(el);
|
|
31
42
|
},
|
|
@@ -42,6 +42,10 @@ declare class Canvas3Class {
|
|
|
42
42
|
xPrev: number;
|
|
43
43
|
yPrev: number;
|
|
44
44
|
};
|
|
45
|
+
frameCount: number;
|
|
46
|
+
lastFpsTime: number;
|
|
47
|
+
fps: number;
|
|
48
|
+
fpsUpdateInterval: number;
|
|
45
49
|
init(canvasElement: HTMLElement, scrollableContent: HTMLElement, canvas3Options: Canvas3OptionsType): Promise<void>;
|
|
46
50
|
setScrollShaderByName(shaderName: string): void;
|
|
47
51
|
setRenderDisabled(status: boolean): void;
|
|
@@ -52,6 +56,7 @@ declare class Canvas3Class {
|
|
|
52
56
|
meshUniformsUpdate(id: string, uniforms: MeshMaterialUniform | BaseUniform): void;
|
|
53
57
|
activateMesh(meshId: string, isActive: boolean): void;
|
|
54
58
|
addOnScrollActivateElement(binding: ScrollActionBinding): void;
|
|
59
|
+
updateOnScrollActiveElement(updatedBinding: ScrollActionBinding): void;
|
|
55
60
|
removeScrollActiveElement(elNode: HTMLElement): void;
|
|
56
61
|
removeMesh(id: string): void;
|
|
57
62
|
addAnimationToRender(callBackName: string, callBackSetup: AnimationCallSetup): void;
|
|
@@ -53,6 +53,11 @@ class Canvas3Class {
|
|
|
53
53
|
customPass = null;
|
|
54
54
|
animations = /* @__PURE__ */ new Map();
|
|
55
55
|
mouse = { x: 0, y: 0, movementX: 0, movementY: 0, xPrev: 0, yPrev: 0 };
|
|
56
|
+
// FPS tracking
|
|
57
|
+
frameCount = 0;
|
|
58
|
+
lastFpsTime = 0;
|
|
59
|
+
fps = 0;
|
|
60
|
+
fpsUpdateInterval = 500;
|
|
56
61
|
async init(canvasElement, scrollableContent, canvas3Options) {
|
|
57
62
|
this.options = canvas3Options;
|
|
58
63
|
this.scene = new THREE.Scene();
|
|
@@ -222,6 +227,18 @@ class Canvas3Class {
|
|
|
222
227
|
const newBinding = generateBindingLogic(binding);
|
|
223
228
|
this.scroll?.DOM.onScrollActivateElements.push(newBinding);
|
|
224
229
|
}
|
|
230
|
+
updateOnScrollActiveElement(updatedBinding) {
|
|
231
|
+
if (!this.scroll) return;
|
|
232
|
+
for (const [
|
|
233
|
+
index,
|
|
234
|
+
item
|
|
235
|
+
] of this.scroll.DOM.onScrollActivateElements.entries()) {
|
|
236
|
+
if (item.elNode.dataset.scrollActivateId === updatedBinding.elNode.dataset.scrollActivateId) {
|
|
237
|
+
const updatedBindingFormated = generateBindingLogic(updatedBinding);
|
|
238
|
+
this.scroll.DOM.onScrollActivateElements[index] = updatedBindingFormated;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
225
242
|
removeScrollActiveElement(elNode) {
|
|
226
243
|
if (!elNode || !this.scroll?.DOM.onScrollActivateElements || this.scroll?.DOM.onScrollActivateElements.length === 0)
|
|
227
244
|
return;
|
|
@@ -436,11 +453,40 @@ class Canvas3Class {
|
|
|
436
453
|
if (!this.lastTime) this.lastTime = timestamp;
|
|
437
454
|
const delta = (timestamp - this.lastTime) / 1e3;
|
|
438
455
|
this.lastTime = timestamp;
|
|
456
|
+
if (!this.lastFpsTime) this.lastFpsTime = timestamp;
|
|
457
|
+
this.frameCount++;
|
|
458
|
+
const elapsedSinceFpsStart = timestamp - this.lastFpsTime;
|
|
459
|
+
if (elapsedSinceFpsStart >= this.fpsUpdateInterval) {
|
|
460
|
+
this.fps = Math.round(
|
|
461
|
+
this.frameCount * 1e3 / elapsedSinceFpsStart
|
|
462
|
+
);
|
|
463
|
+
this.frameCount = 0;
|
|
464
|
+
this.lastFpsTime = timestamp;
|
|
465
|
+
}
|
|
439
466
|
this.render(delta);
|
|
440
467
|
this.rafId = requestAnimationFrame(loop);
|
|
441
468
|
};
|
|
442
469
|
this.rafId = requestAnimationFrame(loop);
|
|
443
470
|
}
|
|
471
|
+
// startRenderLoop() {
|
|
472
|
+
// if (this.rafId !== null) return
|
|
473
|
+
//
|
|
474
|
+
// const loop = (timestamp: number) => {
|
|
475
|
+
// this.rafId = null
|
|
476
|
+
//
|
|
477
|
+
// if (!this.documentVisibility || this.renderDisabled) return
|
|
478
|
+
//
|
|
479
|
+
// if (!this.lastTime) this.lastTime = timestamp
|
|
480
|
+
// const delta = (timestamp - this.lastTime) / 1000
|
|
481
|
+
// this.lastTime = timestamp
|
|
482
|
+
//
|
|
483
|
+
// this.render(delta)
|
|
484
|
+
//
|
|
485
|
+
// this.rafId = requestAnimationFrame(loop)
|
|
486
|
+
// }
|
|
487
|
+
//
|
|
488
|
+
// this.rafId = requestAnimationFrame(loop)
|
|
489
|
+
// }
|
|
444
490
|
stopRenderLoop() {
|
|
445
491
|
if (this.rafId !== null) {
|
|
446
492
|
cancelAnimationFrame(this.rafId);
|