@canvas3/nuxt 0.1.19 → 0.1.21
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
|
@@ -19,13 +19,17 @@ type MeshAnimation = {
|
|
|
19
19
|
ease: string;
|
|
20
20
|
};
|
|
21
21
|
export type AnimationCallback = () => void;
|
|
22
|
-
|
|
22
|
+
type BaseAnimationCall = {
|
|
23
23
|
onScroll: boolean;
|
|
24
24
|
onResize: boolean;
|
|
25
25
|
onMouseMove: boolean;
|
|
26
26
|
onAnimationsRender: boolean;
|
|
27
|
+
render: boolean;
|
|
28
|
+
animationIds: string[];
|
|
27
29
|
animationCallback: AnimationCallback;
|
|
28
30
|
};
|
|
31
|
+
export type AnimationCallSetup = Omit<BaseAnimationCall, 'animationIds'>;
|
|
32
|
+
export type AnimationCallOptions = BaseAnimationCall;
|
|
29
33
|
export type AnimationCallbacks = Map<string, AnimationCallOptions>;
|
|
30
34
|
export type MeshMaterialUniform = Record<string, {
|
|
31
35
|
duration: number;
|
|
@@ -4,7 +4,7 @@ import type { Pass } from 'three/addons/postprocessing/Pass.js';
|
|
|
4
4
|
import { ShaderPass } from 'three/addons/postprocessing/ShaderPass.js';
|
|
5
5
|
import type { ShaderMaterial, WebGLRenderer } from 'three';
|
|
6
6
|
import Scroll from '#canvas3-nuxt/utils/canvas3/scroll';
|
|
7
|
-
import type { AnimationCallbacks, Canvas3OptionsType, ScrollActionBinding, MeshMaterialUniform, MeshType, myEffectType,
|
|
7
|
+
import type { AnimationCallbacks, Canvas3OptionsType, ScrollActionBinding, MeshMaterialUniform, MeshType, myEffectType, AnimationCallSetup } from '#canvas3-nuxt/types/types';
|
|
8
8
|
declare class Canvas3Class {
|
|
9
9
|
canvasInitiated: import("vue").Ref<boolean, boolean>;
|
|
10
10
|
mouseMoveInProgress: boolean;
|
|
@@ -49,7 +49,7 @@ declare class Canvas3Class {
|
|
|
49
49
|
updateOnScrollActiveElement(updatedBinding: ScrollActionBinding): void;
|
|
50
50
|
removeScrollActiveElement(elNode: HTMLElement): void;
|
|
51
51
|
removeMesh(id: string): void;
|
|
52
|
-
addAnimationToRender(callBackName: string,
|
|
52
|
+
addAnimationToRender(callBackName: string, callBackSetup: AnimationCallSetup): void;
|
|
53
53
|
removeAnimationFromRender(callBackName: string): void;
|
|
54
54
|
addImageAsMesh(imgHtmlEl: HTMLImageElement, shaderName: string | null, meshId: string, meshUniforms: MeshMaterialUniform, activateMeshUniforms: MeshMaterialUniform): Promise<void>;
|
|
55
55
|
composerPass(): void;
|
|
@@ -59,6 +59,7 @@ declare class Canvas3Class {
|
|
|
59
59
|
scrollToElBySelector(elQuerySelector: string, delay?: number, margin?: number): void;
|
|
60
60
|
setMeshPositionsUpdate(state: boolean): void;
|
|
61
61
|
setAnimationsToRender(state: boolean): void;
|
|
62
|
+
setAnimationToRender(callBackName: string, state: boolean, animationId: string): void;
|
|
62
63
|
externalAnimationsRender(): void;
|
|
63
64
|
render(): void;
|
|
64
65
|
}
|
|
@@ -239,9 +239,10 @@ class Canvas3Class {
|
|
|
239
239
|
this.activateMeshUniformMap.delete(id);
|
|
240
240
|
this.imageStore = this.imageStore.filter((item) => item.name !== id);
|
|
241
241
|
}
|
|
242
|
-
addAnimationToRender(callBackName,
|
|
242
|
+
addAnimationToRender(callBackName, callBackSetup) {
|
|
243
243
|
if (this.animations.has(callBackName)) return;
|
|
244
|
-
|
|
244
|
+
const newCallbackFunction = { ...callBackSetup, animationIds: [] };
|
|
245
|
+
this.animations.set(callBackName, newCallbackFunction);
|
|
245
246
|
}
|
|
246
247
|
removeAnimationFromRender(callBackName) {
|
|
247
248
|
this.animations.delete(callBackName);
|
|
@@ -367,6 +368,16 @@ class Canvas3Class {
|
|
|
367
368
|
setAnimationsToRender(state) {
|
|
368
369
|
this.animationsRender = state;
|
|
369
370
|
}
|
|
371
|
+
setAnimationToRender(callBackName, state, animationId) {
|
|
372
|
+
const animationToUpdate = this.animations.get(callBackName);
|
|
373
|
+
if (!animationToUpdate) return;
|
|
374
|
+
if (state) {
|
|
375
|
+
animationToUpdate.animationIds.push(animationId);
|
|
376
|
+
} else {
|
|
377
|
+
animationToUpdate.animationIds.splice(animationToUpdate.animationIds.indexOf(animationId), 1);
|
|
378
|
+
}
|
|
379
|
+
animationToUpdate.render = animationToUpdate.animationIds.length > 0;
|
|
380
|
+
}
|
|
370
381
|
externalAnimationsRender() {
|
|
371
382
|
for (const [_key, callbackOption] of this.animations.entries()) {
|
|
372
383
|
const callBack = callbackOption.animationCallback;
|
|
@@ -375,7 +386,8 @@ class Canvas3Class {
|
|
|
375
386
|
const shouldRunOnAnimationsRender = callbackOption.onAnimationsRender && this.animationsRender;
|
|
376
387
|
const shouldRunOnResize = callbackOption.onResize && this.resizeInProgress;
|
|
377
388
|
const shouldRunOnMouseMove = callbackOption.onMouseMove && this.mouseMoveInProgress;
|
|
378
|
-
|
|
389
|
+
const shouldRender = callbackOption.render;
|
|
390
|
+
if (shouldRunOnScroll || shouldRunOnAnimationsRender || shouldRunOnResize || shouldRunOnMouseMove || shouldRender) {
|
|
379
391
|
callBack();
|
|
380
392
|
}
|
|
381
393
|
}
|
|
@@ -3,12 +3,13 @@ import { getShaderMaterial } from '#canvas3-nuxt/utils/canvas3/helpers';
|
|
|
3
3
|
export declare const Canvas3: {
|
|
4
4
|
addMeshToScene: (mesh: Mesh) => void;
|
|
5
5
|
getMeshFromSceneByName: (meshName: string) => import("three").Object3D<import("three").Object3DEventMap> | undefined;
|
|
6
|
-
addAnimationToRender: (callBackName: string,
|
|
6
|
+
addAnimationToRender: (callBackName: string, callBackSetup: import("../types/types.js").AnimationCallSetup) => void;
|
|
7
7
|
removeAnimationFromRender: (callBackName: string) => void;
|
|
8
8
|
addImageAsMesh: (imgHtmlEl: HTMLImageElement, shaderName: string | null, meshId: string, meshUniforms: import("../types/types.js").MeshMaterialUniform, activateMeshUniforms: import("../types/types.js").MeshMaterialUniform) => Promise<void>;
|
|
9
9
|
getShaderMaterial: typeof getShaderMaterial;
|
|
10
10
|
removeMesh: (id: string) => void;
|
|
11
11
|
setAnimationsToRender: (state: boolean) => void;
|
|
12
|
+
setAnimationToRender: (callBackName: string, state: boolean, animationId: string) => void;
|
|
12
13
|
resizeOnChange: () => void;
|
|
13
14
|
scrollToElBySelector: (elQuerySelector: string, delay?: number, margin?: number) => void;
|
|
14
15
|
setMeshPositionsUpdate: (state: boolean) => void;
|
|
@@ -13,6 +13,7 @@ export const Canvas3 = {
|
|
|
13
13
|
getShaderMaterial,
|
|
14
14
|
removeMesh: mainClass.removeMesh.bind(mainClass),
|
|
15
15
|
setAnimationsToRender: mainClass.setAnimationsToRender.bind(mainClass),
|
|
16
|
+
setAnimationToRender: mainClass.setAnimationToRender.bind(mainClass),
|
|
16
17
|
resizeOnChange: mainClass.resizeOnChange.bind(mainClass),
|
|
17
18
|
scrollToElBySelector: mainClass.scrollToElBySelector.bind(mainClass),
|
|
18
19
|
setMeshPositionsUpdate: mainClass.setMeshPositionsUpdate.bind(mainClass),
|