@canvas3/nuxt 0.1.35 → 0.1.36
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,19 @@ 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
|
+
console.log("updatedBindingFormated", updatedBindingFormated);
|
|
239
|
+
this.scroll.DOM.onScrollActivateElements[index] = updatedBindingFormated;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
225
243
|
removeScrollActiveElement(elNode) {
|
|
226
244
|
if (!elNode || !this.scroll?.DOM.onScrollActivateElements || this.scroll?.DOM.onScrollActivateElements.length === 0)
|
|
227
245
|
return;
|
|
@@ -436,11 +454,40 @@ class Canvas3Class {
|
|
|
436
454
|
if (!this.lastTime) this.lastTime = timestamp;
|
|
437
455
|
const delta = (timestamp - this.lastTime) / 1e3;
|
|
438
456
|
this.lastTime = timestamp;
|
|
457
|
+
if (!this.lastFpsTime) this.lastFpsTime = timestamp;
|
|
458
|
+
this.frameCount++;
|
|
459
|
+
const elapsedSinceFpsStart = timestamp - this.lastFpsTime;
|
|
460
|
+
if (elapsedSinceFpsStart >= this.fpsUpdateInterval) {
|
|
461
|
+
this.fps = Math.round(
|
|
462
|
+
this.frameCount * 1e3 / elapsedSinceFpsStart
|
|
463
|
+
);
|
|
464
|
+
this.frameCount = 0;
|
|
465
|
+
this.lastFpsTime = timestamp;
|
|
466
|
+
}
|
|
439
467
|
this.render(delta);
|
|
440
468
|
this.rafId = requestAnimationFrame(loop);
|
|
441
469
|
};
|
|
442
470
|
this.rafId = requestAnimationFrame(loop);
|
|
443
471
|
}
|
|
472
|
+
// startRenderLoop() {
|
|
473
|
+
// if (this.rafId !== null) return
|
|
474
|
+
//
|
|
475
|
+
// const loop = (timestamp: number) => {
|
|
476
|
+
// this.rafId = null
|
|
477
|
+
//
|
|
478
|
+
// if (!this.documentVisibility || this.renderDisabled) return
|
|
479
|
+
//
|
|
480
|
+
// if (!this.lastTime) this.lastTime = timestamp
|
|
481
|
+
// const delta = (timestamp - this.lastTime) / 1000
|
|
482
|
+
// this.lastTime = timestamp
|
|
483
|
+
//
|
|
484
|
+
// this.render(delta)
|
|
485
|
+
//
|
|
486
|
+
// this.rafId = requestAnimationFrame(loop)
|
|
487
|
+
// }
|
|
488
|
+
//
|
|
489
|
+
// this.rafId = requestAnimationFrame(loop)
|
|
490
|
+
// }
|
|
444
491
|
stopRenderLoop() {
|
|
445
492
|
if (this.rafId !== null) {
|
|
446
493
|
cancelAnimationFrame(this.rafId);
|