@canvas3/nuxt 0.1.21 → 0.1.23
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
|
@@ -9,6 +9,7 @@ declare class Canvas3Class {
|
|
|
9
9
|
canvasInitiated: import("vue").Ref<boolean, boolean>;
|
|
10
10
|
mouseMoveInProgress: boolean;
|
|
11
11
|
animationsRender: boolean;
|
|
12
|
+
documentVisibility: boolean;
|
|
12
13
|
resizeInProgress: boolean;
|
|
13
14
|
meshPositionsUpdate: boolean;
|
|
14
15
|
canvasContainer: HTMLElement | null;
|
|
@@ -16,6 +16,7 @@ class Canvas3Class {
|
|
|
16
16
|
canvasInitiated = canvasInitiated;
|
|
17
17
|
mouseMoveInProgress = false;
|
|
18
18
|
animationsRender = false;
|
|
19
|
+
documentVisibility = true;
|
|
19
20
|
resizeInProgress = false;
|
|
20
21
|
meshPositionsUpdate = false;
|
|
21
22
|
canvasContainer = null;
|
|
@@ -77,6 +78,14 @@ class Canvas3Class {
|
|
|
77
78
|
this.mouseMoveInProgress = false;
|
|
78
79
|
}, 0);
|
|
79
80
|
});
|
|
81
|
+
document.addEventListener("visibilitychange", () => {
|
|
82
|
+
if (document.hidden) {
|
|
83
|
+
this.documentVisibility = false;
|
|
84
|
+
} else {
|
|
85
|
+
this.documentVisibility = true;
|
|
86
|
+
this.render();
|
|
87
|
+
}
|
|
88
|
+
});
|
|
80
89
|
this.canvasInitiated.value = true;
|
|
81
90
|
studio783log();
|
|
82
91
|
}
|
|
@@ -403,21 +412,24 @@ class Canvas3Class {
|
|
|
403
412
|
if (this.meshPositionsUpdate) {
|
|
404
413
|
this.resizeImageStore();
|
|
405
414
|
}
|
|
406
|
-
this.
|
|
415
|
+
if (this.animations.size > 0)
|
|
416
|
+
this.externalAnimationsRender();
|
|
407
417
|
if (this.materials.length > 0) {
|
|
408
418
|
for (const material of this.materials) {
|
|
409
419
|
if (material.uniforms.uTime)
|
|
410
420
|
material.uniforms.uTime.value = this.time;
|
|
411
|
-
if (
|
|
412
|
-
material.uniforms.uMouse
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
material.uniforms.uMouseMovement
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
+
if (this.mouseMoveInProgress) {
|
|
422
|
+
if (material.uniforms.uMouse)
|
|
423
|
+
material.uniforms.uMouse.value.set(
|
|
424
|
+
this.mouse.x,
|
|
425
|
+
this.mouse.y
|
|
426
|
+
);
|
|
427
|
+
if (material.uniforms.uMouseMovement)
|
|
428
|
+
material.uniforms.uMouseMovement.value.set(
|
|
429
|
+
this.mouse.movementX,
|
|
430
|
+
this.mouse.movementY
|
|
431
|
+
);
|
|
432
|
+
}
|
|
421
433
|
}
|
|
422
434
|
}
|
|
423
435
|
if (this.composer) {
|
|
@@ -426,6 +438,7 @@ class Canvas3Class {
|
|
|
426
438
|
this.renderer.render(this.scene, this.camera);
|
|
427
439
|
}
|
|
428
440
|
try {
|
|
441
|
+
if (!this.documentVisibility) return;
|
|
429
442
|
requestAnimationFrame(this.render.bind(this));
|
|
430
443
|
} catch (e) {
|
|
431
444
|
console.error(e);
|