@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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "canvas-nuxt-layout",
3
3
  "configKey": "canvas3Layout",
4
- "version": "0.0.3",
4
+ "version": "0.0.5",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.0"
@@ -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
- type: Object,
21
- default: () => ({
22
- alt: "",
23
- src: "",
24
- loadStrategy: "lazy",
25
- shaderName: void 0,
26
- uniforms: {},
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(null);
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
- declare const _default: import("vue").DefineComponent<{}, {
2
- options: Record<string, any>;
3
- $props: any;
4
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
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 & (new () => {
4
- $slots: S;
5
- });
6
- declare const __VLS_component: import("vue").DefineComponent<{}, {
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
  };
@@ -33,6 +33,7 @@ async function tryAdd(el, options) {
33
33
  addedMap.set(el, true);
34
34
  srcMap.set(el, getImgSrc(el));
35
35
  el.classList.add("webgl-img");
36
+ el.style.opacity = "0";
36
37
  }
37
38
  function remove(el) {
38
39
  const meshId = meshIdMap.get(el);
@@ -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 & (new () => {
4
- $slots: S;
5
- });
6
- declare const __VLS_component: import("vue").DefineComponent<{}, {
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: DirectiveBinding['value'];
80
+ options: scrollActionBindOptionType;
59
81
  arg: DirectiveBinding['arg'];
60
82
  };
61
83
  export type ScrollActionType = {
62
84
  elNode: HTMLElement;
63
- options: DirectiveBinding['value'];
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 texture = await loadTexture(imgHtmlEl.src);
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
- texture.image.naturalWidth,
370
- texture.image.naturalHeight
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.value;
41
+ binding.elNode.dataset.scrollSpeed = newBindingData.options.scrollSpeedSetTo?.value.toString() ?? "0";
42
42
  }
43
43
  });
44
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canvas3/nuxt",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },