@canvas3/nuxt 0.0.3 → 0.0.5
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 +1 -1
- package/dist/runtime/components/canvas3-image.vue +9 -12
- package/dist/runtime/components/canvas3-image.vue.d.ts +7 -4
- package/dist/runtime/components/canvas3-text.vue.d.ts +9 -8
- package/dist/runtime/directives/canvas3-image.client.js +1 -0
- package/dist/runtime/layouts/canvas3-layout.vue.d.ts +9 -8
- package/dist/runtime/types/types.d.ts +32 -2
- package/dist/runtime/utils/canvas3/canvas3.js +5 -5
- package/dist/runtime/utils/canvas3/helpers.js +1 -1
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -16,20 +16,17 @@
|
|
|
16
16
|
import { ref, computed, watch, onMounted, nextTick, onBeforeUnmount } from "vue";
|
|
17
17
|
import { Canvas3 } from "#canvas3-nuxt/utils/canvas3/canvas3";
|
|
18
18
|
const props = defineProps({
|
|
19
|
-
options: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
activateMeshUniforms: {}
|
|
28
|
-
})
|
|
29
|
-
}
|
|
19
|
+
options: { type: Object, required: true, default: () => ({
|
|
20
|
+
alt: "",
|
|
21
|
+
src: "",
|
|
22
|
+
loadStrategy: "lazy",
|
|
23
|
+
shaderName: void 0,
|
|
24
|
+
uniforms: {},
|
|
25
|
+
activateMeshUniforms: {}
|
|
26
|
+
}) }
|
|
30
27
|
});
|
|
31
28
|
const reducedMotion = computed(() => Canvas3.options?.disabled ?? null);
|
|
32
|
-
const image = ref(
|
|
29
|
+
const image = ref();
|
|
33
30
|
const generatedMeshId = "image_" + crypto.randomUUID();
|
|
34
31
|
const imgAddedToCanvas = ref(false);
|
|
35
32
|
const addImageToCanvas = async () => {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
1
|
+
import type { Canvas3ImageBindType } from '#canvas3-nuxt/types/types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
options: Canvas3ImageBindType;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
6
|
+
options: Canvas3ImageBindType;
|
|
7
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
5
8
|
export default _default;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
declare var __VLS_1: {};
|
|
2
|
+
type __VLS_Slots = {} & {
|
|
3
|
+
default?: (props: typeof __VLS_1) => any;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_component: import("vue").DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>;
|
|
1
6
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
2
7
|
export default _default;
|
|
3
|
-
type __VLS_WithSlots<T, S> = T &
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
$props: any;
|
|
8
|
-
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
9
|
-
type __VLS_Slots = {
|
|
10
|
-
default?: ((props: {}) => any) | undefined;
|
|
8
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
9
|
+
new (): {
|
|
10
|
+
$slots: S;
|
|
11
|
+
};
|
|
11
12
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
declare var __VLS_1: {};
|
|
2
|
+
type __VLS_Slots = {} & {
|
|
3
|
+
default?: (props: typeof __VLS_1) => any;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_component: import("vue").DefineComponent<{}, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, any, string, import("vue").PublicProps, any, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
1
6
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
2
7
|
export default _default;
|
|
3
|
-
type __VLS_WithSlots<T, S> = T &
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
$emit: (event: "canvas3-ready", ...args: any[]) => void;
|
|
8
|
-
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
9
|
-
type __VLS_Slots = {
|
|
10
|
-
default?: ((props: {}) => any) | undefined;
|
|
8
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
9
|
+
new (): {
|
|
10
|
+
$slots: S;
|
|
11
|
+
};
|
|
11
12
|
};
|
|
@@ -53,14 +53,36 @@ export type MeshType = {
|
|
|
53
53
|
width: number;
|
|
54
54
|
height: number;
|
|
55
55
|
};
|
|
56
|
+
export type scrollActionBindOptionType = {
|
|
57
|
+
activateOnce?: boolean;
|
|
58
|
+
trackOnly?: boolean;
|
|
59
|
+
fixToParent?: {
|
|
60
|
+
containerId: string;
|
|
61
|
+
fixPosition: number;
|
|
62
|
+
margin: number;
|
|
63
|
+
};
|
|
64
|
+
scrollSpeed?: {
|
|
65
|
+
value: number;
|
|
66
|
+
};
|
|
67
|
+
scrollSpeedSetTo?: {
|
|
68
|
+
value: number;
|
|
69
|
+
duration: number;
|
|
70
|
+
};
|
|
71
|
+
activateCallback?: (item: ScrollActionType) => void;
|
|
72
|
+
onScrollCallback?: (item: ScrollActionType, scrollSpeed: number, currentPosition: number) => void;
|
|
73
|
+
activeRangeMargin?: number;
|
|
74
|
+
activeRangeOrigin?: number;
|
|
75
|
+
activeRange?: number;
|
|
76
|
+
bidirectionalActivation?: boolean;
|
|
77
|
+
};
|
|
56
78
|
export type ScrollActionBinding = {
|
|
57
79
|
elNode: HTMLElement;
|
|
58
|
-
options:
|
|
80
|
+
options: scrollActionBindOptionType;
|
|
59
81
|
arg: DirectiveBinding['arg'];
|
|
60
82
|
};
|
|
61
83
|
export type ScrollActionType = {
|
|
62
84
|
elNode: HTMLElement;
|
|
63
|
-
options:
|
|
85
|
+
options: scrollActionBindOptionType;
|
|
64
86
|
arg: DirectiveBinding['arg'];
|
|
65
87
|
containedMeshIds?: string[];
|
|
66
88
|
bounds?: DOMRect;
|
|
@@ -83,6 +105,14 @@ export type Canvas3ImageBinding = {
|
|
|
83
105
|
uniforms?: MeshMaterialUniform;
|
|
84
106
|
activateMeshUniforms?: MeshMaterialUniform;
|
|
85
107
|
};
|
|
108
|
+
export type Canvas3ImageBindType = {
|
|
109
|
+
alt: string;
|
|
110
|
+
src: string;
|
|
111
|
+
loadStrategy?: 'lazy' | 'eager' | undefined;
|
|
112
|
+
shaderName?: string;
|
|
113
|
+
uniforms?: MeshMaterialUniform;
|
|
114
|
+
activateMeshUniforms: MeshMaterialUniform;
|
|
115
|
+
};
|
|
86
116
|
declare module 'vue' {
|
|
87
117
|
interface GlobalDirectives {
|
|
88
118
|
'canvas3-image': ObjectDirective<HTMLImageElement, Canvas3ImageBinding>;
|
|
@@ -6,8 +6,7 @@ import { ShaderPass } from "three/addons/postprocessing/ShaderPass.js";
|
|
|
6
6
|
import { gsap } from "gsap";
|
|
7
7
|
import {
|
|
8
8
|
generateBindingLogic,
|
|
9
|
-
getShaderMaterial
|
|
10
|
-
loadTexture
|
|
9
|
+
getShaderMaterial
|
|
11
10
|
} from "./helpers.js";
|
|
12
11
|
import Scroll from "#canvas3-nuxt/utils/canvas3/scroll";
|
|
13
12
|
import { defaultCanvas3Options } from "#canvas3-nuxt/constants/default-canvas3-options";
|
|
@@ -352,7 +351,8 @@ class Canvas3Class {
|
|
|
352
351
|
const position = { top: bounds.top, left: bounds.left };
|
|
353
352
|
position.top += this.currentScroll;
|
|
354
353
|
const geometry = new THREE.PlaneGeometry(1, 1);
|
|
355
|
-
const
|
|
354
|
+
const bitmap = await createImageBitmap(imgHtmlEl, { imageOrientation: "flipY" });
|
|
355
|
+
const texture = new THREE.Texture(bitmap);
|
|
356
356
|
texture.needsUpdate = true;
|
|
357
357
|
const material = new THREE.ShaderMaterial({
|
|
358
358
|
uniforms: {
|
|
@@ -366,8 +366,8 @@ class Canvas3Class {
|
|
|
366
366
|
uMeshSize: { value: new THREE.Vector2(bounds.width, bounds.height) },
|
|
367
367
|
uTextureSize: {
|
|
368
368
|
value: new THREE.Vector2(
|
|
369
|
-
|
|
370
|
-
|
|
369
|
+
bitmap.width,
|
|
370
|
+
bitmap.height
|
|
371
371
|
)
|
|
372
372
|
},
|
|
373
373
|
uViewport: {
|
|
@@ -38,7 +38,7 @@ export function generateBindingLogic(newBindingData) {
|
|
|
38
38
|
duration: newBindingData.options.scrollSpeedSetTo.duration,
|
|
39
39
|
value: newBindingData.options.scrollSpeedSetTo.value,
|
|
40
40
|
onComplete: () => {
|
|
41
|
-
binding.elNode.dataset.scrollSpeed = newBindingData.options.scrollSpeedSetTo.
|
|
41
|
+
binding.elNode.dataset.scrollSpeed = newBindingData.options.scrollSpeedSetTo?.value.toString() ?? "0";
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
44
|
}
|