@tresjs/core 4.2.8 → 4.2.10

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.
Files changed (35) hide show
  1. package/dist/index.d.ts +3 -0
  2. package/dist/src/components/TresCanvas.vue.d.ts +7 -50
  3. package/dist/src/components/index.d.ts +0 -1
  4. package/dist/src/composables/useCamera/index.d.ts +4376 -487
  5. package/dist/src/composables/useLoader/index.d.ts +0 -1
  6. package/dist/src/composables/useLoop/index.d.ts +1 -2
  7. package/dist/src/composables/useRaycaster/index.d.ts +0 -1
  8. package/dist/src/composables/useRenderLoop/index.d.ts +0 -1
  9. package/dist/src/composables/useRenderer/index.d.ts +0 -1
  10. package/dist/src/composables/useSeek/index.d.ts +0 -1
  11. package/dist/src/composables/useSizes/index.d.ts +2 -3
  12. package/dist/src/composables/useTexture/index.d.ts +0 -1
  13. package/dist/src/composables/useTresContextProvider/index.d.ts +0 -1
  14. package/dist/src/composables/useTresEventManager/index.d.ts +0 -1
  15. package/dist/src/composables/useTresReady/createReadyEventHook/index.d.ts +0 -1
  16. package/dist/src/composables/useTresReady/index.d.ts +0 -1
  17. package/dist/src/core/catalogue.d.ts +1 -2
  18. package/dist/src/core/loop.d.ts +0 -1
  19. package/dist/src/core/nodeOps.d.ts +0 -1
  20. package/dist/src/devtools/plugin.d.ts +0 -1
  21. package/dist/src/directives/index.d.ts +0 -1
  22. package/dist/src/directives/vDistanceTo.d.ts +0 -1
  23. package/dist/src/directives/vLightHelper.d.ts +0 -1
  24. package/dist/src/directives/vLog.d.ts +0 -1
  25. package/dist/src/index.d.ts +0 -1
  26. package/dist/src/types/index.d.ts +11 -7
  27. package/dist/src/utils/createPriorityEventHook.d.ts +0 -1
  28. package/dist/src/utils/index.d.ts +0 -1
  29. package/dist/src/utils/is.d.ts +0 -1
  30. package/dist/src/utils/normalize.d.ts +0 -1
  31. package/dist/src/utils/perf.d.ts +0 -1
  32. package/dist/src/utils/test-utils.d.ts +0 -1
  33. package/dist/tres.js +24 -26
  34. package/dist/tres.umd.cjs +2 -2
  35. package/package.json +16 -16
@@ -1,5 +1,4 @@
1
1
  import { Loader, LoadingManager, Object3D } from 'three';
2
-
3
2
  export interface TresLoader<T> extends Loader {
4
3
  load: (url: string | string[], onLoad: (result: T) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void) => void;
5
4
  loadAsync: (url: string, onProgress?: (event: ProgressEvent) => void) => Promise<T>;
@@ -1,11 +1,10 @@
1
1
  import { LoopCallbackFn } from './../../core/loop';
2
-
3
2
  export declare function useLoop(): {
4
3
  pause: import('@vueuse/core').Fn;
5
4
  resume: import('@vueuse/core').Fn;
6
5
  pauseRender: import('@vueuse/core').Fn;
7
6
  resumeRender: import('@vueuse/core').Fn;
8
- isActive: import('vue').Ref<boolean>;
7
+ isActive: import('vue').Ref<boolean, boolean>;
9
8
  onBeforeRender: (cb: LoopCallbackFn, index?: number) => {
10
9
  off: import('@vueuse/core').Fn;
11
10
  };
@@ -2,7 +2,6 @@ import { Intersection, Object3D, Object3DEventMap } from 'three';
2
2
  import { ShallowRef } from 'vue';
3
3
  import { TresEvent, TresInstance } from 'src/types';
4
4
  import { TresContext } from '../useTresContextProvider';
5
-
6
5
  export declare const useRaycaster: (objectsWithEvents: ShallowRef<TresInstance[]>, ctx: TresContext) => {
7
6
  intersects: ShallowRef<Intersection<Object3D<Object3DEventMap>>[]>;
8
7
  onClick: (fn: (value: TresEvent) => void) => () => void;
@@ -1,7 +1,6 @@
1
1
  import { EventHookOn, Fn } from '@vueuse/core';
2
2
  import { Ref } from 'vue';
3
3
  import { Clock } from 'three';
4
-
5
4
  export interface RenderLoop {
6
5
  delta: number;
7
6
  elapsed: number;
@@ -4,7 +4,6 @@ import { MaybeRefOrGetter } from '@vueuse/core';
4
4
  import { EmitEventFn, TresColor } from '../../types';
5
5
  import { TresContext } from '../useTresContextProvider';
6
6
  import { RendererPresetsType } from './const';
7
-
8
7
  type TransformToMaybeRefOrGetter<T> = {
9
8
  [K in keyof T]: MaybeRefOrGetter<T[K]> | MaybeRefOrGetter<T[K]>;
10
9
  };
@@ -1,5 +1,4 @@
1
1
  import { Object3D, Scene } from 'three';
2
-
3
2
  /**
4
3
  * Seek composable return type
5
4
  *
@@ -1,12 +1,11 @@
1
1
  import { ComputedRef, MaybeRef, MaybeRefOrGetter, Ref } from 'vue';
2
-
3
2
  export interface SizesType {
4
3
  height: Readonly<Ref<number>>;
5
4
  width: Readonly<Ref<number>>;
6
5
  aspectRatio: ComputedRef<number>;
7
6
  }
8
7
  export default function useSizes(windowSize: MaybeRefOrGetter<boolean>, canvas: MaybeRef<HTMLCanvasElement>, debounceMs?: number): {
9
- height: Readonly<Ref<number>>;
10
- width: Readonly<Ref<number>>;
8
+ height: Readonly<Ref<number, number>>;
9
+ width: Readonly<Ref<number, number>>;
11
10
  aspectRatio: ComputedRef<number>;
12
11
  };
@@ -1,5 +1,4 @@
1
1
  import { Texture } from 'three';
2
-
3
2
  export interface PBRMaterialOptions {
4
3
  /**
5
4
  * List of texture maps to load.
@@ -5,7 +5,6 @@ import { EmitEventFn, TresControl, TresObject, TresScene } from '../../types';
5
5
  import { TresEventManager } from '../useTresEventManager';
6
6
  import { SizesType } from '../useSizes';
7
7
  import { RendererLoop } from '../../core/loop';
8
-
9
8
  export interface InternalState {
10
9
  priority: Ref<number>;
11
10
  frames: Ref<number>;
@@ -1,7 +1,6 @@
1
1
  import { Scene } from 'three';
2
2
  import { EmitEventFn } from 'src/types';
3
3
  import { TresContext } from '../useTresContextProvider';
4
-
5
4
  export interface TresEventManager {
6
5
  /**
7
6
  * Forces the event system to refire events with the previous mouse event
@@ -1,5 +1,4 @@
1
1
  import { EventHook } from '@vueuse/core';
2
-
3
2
  export declare function createReadyEventHook<T>(getIsReady: () => boolean, triggerParams: T, pollIntervalMs?: number): EventHook<T> & {
4
3
  cancel: () => void;
5
4
  };
@@ -1,5 +1,4 @@
1
1
  import { TresContext } from '../useTresContextProvider';
2
-
3
2
  export declare function useTresReady(ctx?: TresContext): import('@vueuse/core').EventHook<TresContext> & {
4
3
  cancel: () => void;
5
4
  };
@@ -1,10 +1,9 @@
1
1
  import { Ref } from 'vue';
2
2
  import { TresCatalogue } from '../types';
3
-
4
3
  export declare const catalogue: Ref<TresCatalogue>;
5
4
  export declare const extend: (objects: any) => any;
6
5
  declare const _default: {
7
- catalogue: Ref<TresCatalogue>;
6
+ catalogue: Ref<TresCatalogue, TresCatalogue>;
8
7
  extend: (objects: any) => any;
9
8
  };
10
9
  export default _default;
@@ -1,7 +1,6 @@
1
1
  import { Ref } from 'vue';
2
2
  import { Camera, EventDispatcher, Raycaster, Scene, WebGLRenderer, Clock } from 'three';
3
3
  import { Fn } from '@vueuse/core';
4
-
5
4
  export type LoopStage = 'before' | 'render' | 'after';
6
5
  export interface LoopCallback {
7
6
  delta: number;
@@ -1,5 +1,4 @@
1
1
  import { RendererOptions } from 'vue';
2
2
  import { TresContext } from '../composables';
3
3
  import { TresObject } from '../types';
4
-
5
4
  export declare const nodeOps: (context: TresContext) => RendererOptions<TresObject, TresObject | null>;
@@ -1,6 +1,5 @@
1
1
  import { App as DevtoolsApp } from '@vue/devtools-api';
2
2
  import { TresContext } from '../composables';
3
-
4
3
  export interface Tags {
5
4
  label: string;
6
5
  textColor: number;
@@ -1,5 +1,4 @@
1
1
  import { vLog } from './vLog';
2
2
  import { vLightHelper } from './vLightHelper';
3
3
  import { vDistanceTo } from './vDistanceTo';
4
-
5
4
  export { vLog, vLightHelper, vDistanceTo };
@@ -1,6 +1,5 @@
1
1
  import { Ref } from 'vue';
2
2
  import { TresObject } from '../types';
3
-
4
3
  export declare const vDistanceTo: {
5
4
  updated: (el: TresObject, binding: Ref<TresObject>) => void;
6
5
  unmounted: (el: TresObject) => void;
@@ -1,5 +1,4 @@
1
1
  import { TresObject } from '../types';
2
-
3
2
  export declare const vLightHelper: {
4
3
  mounted: (el: TresObject) => void;
5
4
  updated: (el: TresObject) => void;
@@ -1,5 +1,4 @@
1
1
  import { TresObject } from '../types';
2
-
3
2
  export declare const vLog: {
4
3
  mounted: (el: TresObject, binding: {
5
4
  arg: string;
@@ -2,7 +2,6 @@ import { App } from 'vue';
2
2
  import { normalizeColor, normalizeVectorFlexibleParam } from './utils/normalize';
3
3
  import { default as templateCompilerOptions } from './utils/template-compiler-options';
4
4
  import { disposeObject3D as dispose } from './utils';
5
-
6
5
  export * from './composables';
7
6
  export * from './core/catalogue';
8
7
  export * from './components';
@@ -1,6 +1,5 @@
1
1
  import { DefineComponent, VNode, VNodeRef } from 'vue';
2
2
  import { TresContext } from '../composables/useTresContextProvider';
3
-
4
3
  import type * as THREE from 'three';
5
4
  export type AttachFnType = (parent: any, self: TresInstance) => () => void;
6
5
  export type AttachType = string | AttachFnType;
@@ -21,12 +20,17 @@ export interface TresCatalogue {
21
20
  export type EmitEventName = 'render' | 'ready' | 'click' | 'double-click' | 'context-menu' | 'pointer-move' | 'pointer-up' | 'pointer-down' | 'pointer-enter' | 'pointer-leave' | 'pointer-over' | 'pointer-out' | 'pointer-missed' | 'wheel';
22
21
  export type EmitEventFn = (event: EmitEventName, ...args: any[]) => void;
23
22
  export type TresCamera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
23
+ /**
24
+ * Represents the properties of an instance.
25
+ *
26
+ * @template T - The type of the object.
27
+ * @template P - The type of the arguments.
28
+ */
24
29
  export interface InstanceProps<T = any, P = any> {
25
30
  args?: Args<P>;
26
31
  object?: T;
27
32
  visible?: boolean;
28
33
  dispose?: null;
29
- [prop: string]: any;
30
34
  }
31
35
  interface TresBaseObject {
32
36
  removeFromParent?: () => void;
@@ -131,10 +135,10 @@ export interface EventHandlers {
131
135
  onWheel?: (event: ThreeEvent<WheelEvent>) => void;
132
136
  }
133
137
  interface MathRepresentation {
134
- set: (...args: number[] | [THREE.ColorRepresentation]) => any;
138
+ set(...args: number[] | [THREE.ColorRepresentation]): any;
135
139
  }
136
140
  interface VectorRepresentation extends MathRepresentation {
137
- setScalar: (s: number) => any;
141
+ setScalar(s: number): any;
138
142
  }
139
143
  export interface VectorCoordinates {
140
144
  x: number;
@@ -161,12 +165,12 @@ interface RaycastableRepresentation {
161
165
  raycast: (raycaster: THREE.Raycaster, intersects: THREE.Intersection[]) => void;
162
166
  }
163
167
  type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : unknown;
164
- export interface VueProps<P> {
165
- children?: VNode<P>[];
168
+ export interface VueProps {
169
+ children?: VNode[];
166
170
  ref?: VNodeRef;
167
171
  key?: string | number | symbol;
168
172
  }
169
- type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<Overwrite<WithMathProps<P>, VueProps<P> & EventProps<P>>>;
173
+ type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<Overwrite<P, WithMathProps<P> & VueProps & EventProps<P>>>;
170
174
  export type ThreeElement<T extends ConstructorRepresentation> = Mutable<Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>>;
171
175
  type ThreeExports = typeof THREE;
172
176
  type ThreeInstancesImpl = {
@@ -1,5 +1,4 @@
1
1
  import { EventHookOff, IsAny } from '@vueuse/core';
2
-
3
2
  export type Callback<T> = IsAny<T> extends true ? (param: any) => void : ([
4
3
  T
5
4
  ] extends [void] ? () => void : (param: T) => void);
@@ -2,7 +2,6 @@ import { Material, Mesh, MeshBasicMaterial, Scene, Vector3 } from 'three';
2
2
  import { AttachType, LocalState, TresInstance, TresObject, TresPrimitive } from 'src/types';
3
3
  import { nodeOps } from 'src/core/nodeOps';
4
4
  import { TresContext } from '../composables/useTresContextProvider';
5
-
6
5
  export declare function toSetMethodName(key: string): string;
7
6
  export declare const merge: (target: any, source: any) => any;
8
7
  export declare const isHTMLTag: (key: string) => boolean;
@@ -1,6 +1,5 @@
1
1
  import { TresObject, TresPrimitive } from 'src/types';
2
2
  import { BufferGeometry, Camera, Fog, Light, Material, Object3D, Scene } from 'three';
3
-
4
3
  export declare function und(u: unknown): u is undefined;
5
4
  export declare function arr(u: unknown): u is any[];
6
5
  export declare function num(u: unknown): u is number;
@@ -1,5 +1,4 @@
1
1
  import { ColorRepresentation, Color, Vector3 } from 'three';
2
-
3
2
  export type SizeFlexibleParams = number[] | {
4
3
  width: number;
5
4
  height: number;
@@ -1,6 +1,5 @@
1
1
  import { Scene } from 'three';
2
2
  import { TresObject } from './../types';
3
-
4
3
  export declare function calculateMemoryUsage(object: TresObject | Scene): number;
5
4
  export declare function bytesToKB(bytes: number): string;
6
5
  export declare function bytesToMB(bytes: number): string;
@@ -1,3 +1,2 @@
1
1
  import { Fn } from '@vueuse/core';
2
-
3
2
  export declare function withSetup(composable: Fn): (import('vue').App<Element> | undefined)[];
package/dist/tres.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * name: @tresjs/core
3
- * version: v4.2.8
3
+ * version: v4.2.10
4
4
  * (c) 2024
5
5
  * description: Declarative ThreeJS using Vue Components
6
6
  * author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
@@ -12,7 +12,7 @@ import { ref as H, computed as V, watchEffect as Te, onUnmounted as K, shallowRe
12
12
  import * as et from "three";
13
13
  import { PerspectiveCamera as we, Camera as Dt, Clock as tt, Vector3 as Se, Color as Z, Scene as nt, MathUtils as rt, MeshBasicMaterial as ot, DoubleSide as jt, REVISION as Bt, SRGBColorSpace as It, ACESFilmicToneMapping as st, PCFSoftShadowMap as Ht, NoToneMapping as $t, WebGLRenderer as he, TextureLoader as Ut, Vector2 as ge, Raycaster as Ft, BufferAttribute as Wt, Object3D as Nt, Line as zt, BufferGeometry as $e, Float32BufferAttribute as Ue, LineBasicMaterial as Gt, Mesh as Vt, BackSide as Yt, DirectionalLightHelper as qt, PointLightHelper as Jt, SpotLightHelper as Kt, HemisphereLightHelper as Qt, ArrowHelper as Xt } from "three";
14
14
  import { createEventHook as j, useRafFn as it, toValue as k, unrefElement as Zt, useDevicePixelRatio as en, usePointer as tn, useElementBounding as nn, useWindowSize as rn, useElementSize as on, refDebounced as Fe, tryOnScopeDispose as sn, useFps as an, useMemory as ln } from "@vueuse/core";
15
- const cn = "@tresjs/core", un = "module", fn = "4.2.8", dn = "pnpm@9.1.4", pn = "Declarative ThreeJS using Vue Components", mn = "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", hn = "MIT", gn = {
15
+ const cn = "@tresjs/core", un = "module", fn = "4.2.10", dn = "pnpm@9.1.4", pn = "Declarative ThreeJS using Vue Components", mn = "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", hn = "MIT", gn = {
16
16
  type: "git",
17
17
  url: "git+https://github.com/Tresjs/tres.git"
18
18
  }, vn = [
@@ -72,22 +72,22 @@ const cn = "@tresjs/core", un = "module", fn = "4.2.8", dn = "pnpm@9.1.4", pn =
72
72
  }, An = {
73
73
  "@release-it/conventional-changelog": "^8.0.1",
74
74
  "@stackblitz/sdk": "^1.11.0",
75
- "@tresjs/cientos": "3.9.0",
75
+ "@tresjs/cientos": "4.0.2",
76
76
  "@tresjs/eslint-config": "^1.1.0",
77
- "@types/three": "^0.166.0",
78
- "@typescript-eslint/eslint-plugin": "^7.16.0",
79
- "@typescript-eslint/parser": "^7.16.0",
77
+ "@types/three": "^0.168.0",
78
+ "@typescript-eslint/eslint-plugin": "^8.4.0",
79
+ "@typescript-eslint/parser": "^8.4.0",
80
80
  "@vitejs/plugin-vue": "^5.0.5",
81
81
  "@vitest/coverage-c8": "^0.33.0",
82
82
  "@vitest/coverage-v8": "^2.0.2",
83
83
  "@vitest/ui": "^2.0.2",
84
84
  "@vue/test-utils": "^2.4.6",
85
85
  eslint: "^9.6.0",
86
- "eslint-plugin-vue": "^9.27.0",
86
+ "eslint-plugin-vue": "^9.28.0",
87
87
  esno: "^4.7.0",
88
88
  gsap: "^3.12.5",
89
89
  husky: "^9.0.11",
90
- jsdom: "^24.1.0",
90
+ jsdom: "^25.0.0",
91
91
  kolorist: "^1.8.0",
92
92
  ohmyfetch: "^0.4.21",
93
93
  pathe: "^1.1.2",
@@ -95,20 +95,20 @@ const cn = "@tresjs/core", un = "module", fn = "4.2.8", dn = "pnpm@9.1.4", pn =
95
95
  "rollup-plugin-analyzer": "^4.0.0",
96
96
  "rollup-plugin-copy": "^3.5.0",
97
97
  "rollup-plugin-visualizer": "^5.12.0",
98
- sponsorkit: "^0.14.6",
99
- three: "^0.166.1",
100
- unocss: "^0.61.3",
101
- unplugin: "^1.11.0",
98
+ sponsorkit: "^0.15.4",
99
+ three: "^0.168.0",
100
+ unocss: "^0.62.3",
101
+ unplugin: "^1.13.1",
102
102
  "unplugin-vue-components": "^0.27.2",
103
- vite: "^5.3.3",
104
- "vite-plugin-banner": "^0.7.1",
105
- "vite-plugin-dts": "3.9.1",
103
+ vite: "^5.4.3",
104
+ "vite-plugin-banner": "^0.8.0",
105
+ "vite-plugin-dts": "4.1.0",
106
106
  "vite-plugin-inspect": "^0.8.4",
107
107
  "vite-plugin-require-transform": "^1.0.21",
108
108
  "vite-svg-loader": "^5.1.0",
109
- vitepress: "1.3.0",
109
+ vitepress: "1.3.4",
110
110
  vitest: "^2.0.2",
111
- vue: "^3.4.31",
111
+ vue: "3.5.0",
112
112
  "vue-demi": "^0.14.8"
113
113
  }, xn = {
114
114
  name: cn,
@@ -581,18 +581,16 @@ function lr(e) {
581
581
  }
582
582
  async function Nr(e, t, n, r, s) {
583
583
  const { logError: l } = Y(), i = new e();
584
- s && s(i), n && n(i);
585
- const a = Array.isArray(t) ? t : [t];
586
- return await new Promise((c, o) => {
584
+ return s && s(i), n && n(i), await new Promise((a, c) => {
587
585
  i.load(
588
- a,
589
- (u) => {
590
- const v = u;
591
- v.scene && Object.assign(v, lr(v.scene)), c(v);
586
+ t,
587
+ (o) => {
588
+ const u = o;
589
+ u.scene && Object.assign(u, lr(u.scene)), a(u);
592
590
  },
593
591
  r,
594
- (u) => {
595
- l("[useLoader] - Failed to load resource", u), o(u);
592
+ (o) => {
593
+ l("[useLoader] - Failed to load resource", o), c(o);
596
594
  }
597
595
  );
598
596
  });