@tresjs/core 3.7.0 → 3.8.1

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 (36) hide show
  1. package/README.md +1 -0
  2. package/components.d.ts +1 -1
  3. package/composables.d.ts +1 -1
  4. package/dist/src/components/TresCanvas.vue.d.ts +7 -6
  5. package/dist/src/components/index.d.ts +2 -1
  6. package/dist/src/composables/useCamera/index.d.ts +472 -433
  7. package/dist/src/composables/useLoader/index.d.ts +3 -2
  8. package/dist/src/composables/useLogger.d.ts +5 -2
  9. package/dist/src/composables/usePointerEventHandler/index.d.ts +4 -3
  10. package/dist/src/composables/useRaycaster/index.d.ts +7 -6
  11. package/dist/src/composables/useRenderLoop/index.d.ts +3 -2
  12. package/dist/src/composables/useRenderer/index.d.ts +8 -8
  13. package/dist/src/composables/useSeek/index.d.ts +6 -4
  14. package/dist/src/composables/useSizes/index.d.ts +12 -0
  15. package/dist/src/composables/useTexture/index.d.ts +2 -1
  16. package/dist/src/composables/useTresContextProvider/index.d.ts +6 -9
  17. package/dist/src/core/catalogue.d.ts +3 -2
  18. package/dist/src/core/nodeOps.d.ts +3 -2
  19. package/dist/src/core/renderer.d.ts +1 -1
  20. package/dist/src/devtools/plugin.d.ts +3 -2
  21. package/dist/src/directives/index.d.ts +4 -3
  22. package/dist/src/directives/vAlwaysLookAt.d.ts +4 -3
  23. package/dist/src/directives/vDistanceTo.d.ts +3 -2
  24. package/dist/src/directives/vLightHelper.d.ts +2 -1
  25. package/dist/src/directives/vLog.d.ts +2 -1
  26. package/dist/src/index.d.ts +3 -2
  27. package/dist/src/types/index.d.ts +3 -2
  28. package/dist/src/utils/index.d.ts +2 -2
  29. package/dist/src/utils/normalize.d.ts +2 -2
  30. package/dist/src/utils/perf.d.ts +3 -2
  31. package/dist/src/utils/test-utils.d.ts +1 -1
  32. package/dist/tres.js +573 -578
  33. package/dist/tres.umd.cjs +2 -2
  34. package/package.json +18 -17
  35. package/types.d.ts +1 -1
  36. package/utils.d.ts +1 -1
@@ -1,5 +1,6 @@
1
- import type { Object3D } from 'three';
2
- export interface TresLoader<T> extends THREE.Loader {
1
+ import { Loader, Object3D } from 'three';
2
+
3
+ export interface TresLoader<T> extends Loader {
3
4
  load(url: string, onLoad?: (result: T) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): unknown;
4
5
  loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<T>;
5
6
  }
@@ -1,7 +1,10 @@
1
1
  export declare const isProd: boolean;
2
+ type OneOrMore<T> = {
3
+ 0: T;
4
+ } & Array<T>;
2
5
  interface LoggerComposition {
3
- logError: (message: string, error?: Error | ErrorEvent) => void;
4
- logWarning: (message: string) => void;
6
+ logError: (...args: OneOrMore<any>) => void;
7
+ logWarning: (...args: OneOrMore<any>) => void;
5
8
  logMessage: (name: string, value: any) => void;
6
9
  }
7
10
  export declare function useLogger(): LoggerComposition;
@@ -1,6 +1,7 @@
1
- import type { Intersection, Event, Object3D } from 'three';
2
- import type { TresScene } from 'src/types';
3
- import type { TresContext } from '../useTresContextProvider';
1
+ import { TresContext } from '../useTresContextProvider';
2
+ import { TresScene } from 'src/types';
3
+ import { Intersection, Event, Object3D } from 'three';
4
+
4
5
  type CallbackFn = (intersection: Intersection<Object3D<Event>>, event: PointerEvent) => void;
5
6
  type CallbackFnPointerLeave = (object: Object3D<Event>, event: PointerEvent) => void;
6
7
  export interface EventProps {
@@ -1,7 +1,8 @@
1
- import type { Object3D, type Intersection } from 'three';
2
- import type { Ref } from 'vue';
3
- import { type TresContext } from '../useTresContextProvider';
4
- export type Intersects = Intersection<THREE.Object3D<THREE.Event>>[];
1
+ import { TresContext } from '../useTresContextProvider';
2
+ import { Ref } from 'vue';
3
+ import { Object3D, Intersection, Object3DEventMap } from 'three';
4
+
5
+ export type Intersects = Intersection<Object3D<Object3DEventMap>>[];
5
6
  interface PointerMoveEventPayload {
6
7
  intersects?: Intersects;
7
8
  event: PointerEvent;
@@ -10,8 +11,8 @@ interface PointerClickEventPayload {
10
11
  intersects: Intersects;
11
12
  event: PointerEvent;
12
13
  }
13
- export declare const useRaycaster: (objects: Ref<THREE.Object3D[]>, { renderer, camera, raycaster }: Pick<TresContext, 'renderer' | 'camera' | 'raycaster'>) => {
14
- intersects: import("vue").ComputedRef<Intersects>;
14
+ export declare const useRaycaster: (objects: Ref<Object3D[]>, { renderer, camera, raycaster }: Pick<TresContext, 'renderer' | 'camera' | 'raycaster'>) => {
15
+ intersects: import('vue').ComputedRef<Intersects>;
15
16
  onClick: (fn: (value: PointerClickEventPayload) => void) => () => void;
16
17
  onPointerMove: (fn: (value: PointerMoveEventPayload) => void) => () => void;
17
18
  };
@@ -1,6 +1,7 @@
1
- import type { EventHookOn, Fn } from '@vueuse/core';
2
- import type { Ref } from 'vue';
3
1
  import { Clock } from 'three';
2
+ import { Ref } from 'vue';
3
+ import { EventHookOn, Fn } from '@vueuse/core';
4
+
4
5
  export interface RenderLoop {
5
6
  delta: number;
6
7
  elapsed: number;
@@ -1,10 +1,10 @@
1
- import { WebGLRenderer } from 'three';
2
- import { type MaybeRef } from 'vue';
3
- import { type MaybeRefOrGetter } from '@vueuse/core';
4
- import type { Scene, ToneMapping, ColorSpace, ShadowMapType, WebGLRendererParameters } from 'three';
5
- import type { TresColor } from '../../types';
6
- import type { TresContext } from '../useTresContextProvider';
7
- import type { RendererPresetsType } from './const';
1
+ import { RendererPresetsType } from './const';
2
+ import { TresContext } from '../useTresContextProvider';
3
+ import { TresColor } from '../../types';
4
+ import { MaybeRefOrGetter } from '@vueuse/core';
5
+ import { MaybeRef } from 'vue';
6
+ import { WebGLRenderer, Scene, ToneMapping, ColorSpace, ShadowMapType, WebGLRendererParameters } from 'three';
7
+
8
8
  type TransformToMaybeRefOrGetter<T> = {
9
9
  [K in keyof T]: MaybeRefOrGetter<T[K]> | MaybeRefOrGetter<T[K]>;
10
10
  };
@@ -83,7 +83,7 @@ export declare function useRenderer({ scene, canvas, options, disableRender, con
83
83
  contextParts: Pick<TresContext, 'sizes' | 'camera'>;
84
84
  disableRender: MaybeRefOrGetter<boolean>;
85
85
  }): {
86
- renderer: import("vue").ShallowRef<WebGLRenderer>;
86
+ renderer: import('vue').ShallowRef<WebGLRenderer>;
87
87
  };
88
88
  export type UseRendererReturn = ReturnType<typeof useRenderer>;
89
89
  export {};
@@ -1,3 +1,5 @@
1
+ import { Scene, Object3D } from 'three';
2
+
1
3
  /**
2
4
  * Seek composable return type
3
5
  *
@@ -5,10 +7,10 @@
5
7
  * @interface UseSeekReturn
6
8
  */
7
9
  export interface UseSeekReturn {
8
- seek: (parent: THREE.Scene | THREE.Object3D, property: string, value: string) => THREE.Object3D | null;
9
- seekByName: (parent: THREE.Scene | THREE.Object3D, value: string) => THREE.Object3D | null;
10
- seekAll: (parent: THREE.Scene | THREE.Object3D, property: string, value: string) => THREE.Object3D[];
11
- seekAllByName: (parent: THREE.Scene | THREE.Object3D, value: string) => THREE.Object3D[];
10
+ seek: (parent: Scene | Object3D, property: string, value: string) => Object3D | null;
11
+ seekByName: (parent: Scene | Object3D, value: string) => Object3D | null;
12
+ seekAll: (parent: Scene | Object3D, property: string, value: string) => Object3D[];
13
+ seekAllByName: (parent: Scene | Object3D, value: string) => Object3D[];
12
14
  }
13
15
  /**
14
16
  * Composable that provides utilities to easily traverse and navigate through complex scenes and object children graphs
@@ -0,0 +1,12 @@
1
+ import { MaybeRefOrGetter, MaybeRef, ComputedRef, Ref } from 'vue';
2
+
3
+ export interface SizesType {
4
+ height: Readonly<Ref<number>>;
5
+ width: Readonly<Ref<number>>;
6
+ aspectRatio: ComputedRef<number>;
7
+ }
8
+ export default function useSizes(windowSize: MaybeRefOrGetter<boolean>, canvas: MaybeRef<HTMLCanvasElement>, debounceMs?: number): {
9
+ height: Readonly<Ref<number>>;
10
+ width: Readonly<Ref<number>>;
11
+ aspectRatio: ComputedRef<number>;
12
+ };
@@ -1,4 +1,5 @@
1
- import type { Texture } from 'three';
1
+ import { Texture } from 'three';
2
+
2
3
  export interface PBRMaterialOptions {
3
4
  /**
4
5
  * List of texture maps to load.
@@ -1,14 +1,11 @@
1
- import type { Camera, EventDispatcher, Scene, WebGLRenderer } from 'three';
2
- import { Raycaster } from 'three';
3
- import type { ComputedRef, DeepReadonly, MaybeRef, MaybeRefOrGetter, Ref, ShallowRef } from 'vue';
4
- import type { UseRendererOptions } from '../useRenderer';
1
+ import { SizesType } from '../useSizes';
2
+ import { UseRendererOptions } from '../useRenderer';
3
+ import { ComputedRef, DeepReadonly, MaybeRef, MaybeRefOrGetter, Ref, ShallowRef } from 'vue';
4
+ import { Camera, EventDispatcher, Scene, WebGLRenderer, Raycaster } from 'three';
5
+
5
6
  export interface TresContext {
6
7
  scene: ShallowRef<Scene>;
7
- sizes: {
8
- height: Ref<number>;
9
- width: Ref<number>;
10
- aspectRatio: ComputedRef<number>;
11
- };
8
+ sizes: SizesType;
12
9
  extend: (objects: any) => void;
13
10
  camera: ComputedRef<Camera | undefined>;
14
11
  cameras: DeepReadonly<Ref<Camera[]>>;
@@ -1,5 +1,6 @@
1
- import type { Ref } from 'vue';
2
- import type { TresCatalogue } from '../types';
1
+ import { TresCatalogue } from '../types';
2
+ import { Ref } from 'vue';
3
+
3
4
  export declare const catalogue: Ref<TresCatalogue>;
4
5
  export declare const extend: (objects: any) => any;
5
6
  declare const _default: {
@@ -1,3 +1,4 @@
1
- import type { RendererOptions } from 'vue';
2
- import type { TresObject } from '../types';
1
+ import { TresObject } from '../types';
2
+ import { RendererOptions } from 'vue';
3
+
3
4
  export declare const nodeOps: RendererOptions<TresObject, TresObject>;
@@ -1,4 +1,4 @@
1
- export declare const render: import("vue").RootRenderFunction<import("..").TresObject>;
1
+ export declare const render: import('vue').RootRenderFunction<import("src").TresObject>;
2
2
  declare const _default: {
3
3
  extend: (objects: any) => any;
4
4
  };
@@ -1,5 +1,6 @@
1
- import type { App as DevtoolsApp } from '@vue/devtools-api';
2
- import type { TresContext } from '../composables';
1
+ import { TresContext } from '../composables';
2
+ import { App as DevtoolsApp } from '@vue/devtools-api';
3
+
3
4
  export interface Tags {
4
5
  label: string;
5
6
  textColor: number;
@@ -1,5 +1,6 @@
1
- import { vLog } from './vLog';
2
- import { vLightHelper } from './vLightHelper';
3
- import { vAlwaysLookAt } from './vAlwaysLookAt';
4
1
  import { vDistanceTo } from './vDistanceTo';
2
+ import { vAlwaysLookAt } from './vAlwaysLookAt';
3
+ import { vLightHelper } from './vLightHelper';
4
+ import { vLog } from './vLog';
5
+
5
6
  export { vLog, vLightHelper, vAlwaysLookAt, vDistanceTo };
@@ -1,6 +1,7 @@
1
- import type { Object3D } from 'three';
2
- import type { Ref } from 'vue';
3
- import type { TresVector3 } from '../types';
1
+ import { TresVector3 } from '../types';
2
+ import { Ref } from 'vue';
3
+ import { Object3D } from 'three';
4
+
4
5
  export declare const vAlwaysLookAt: {
5
6
  updated: (el: Object3D, binding: Ref<TresVector3>) => void;
6
7
  };
@@ -1,5 +1,6 @@
1
- import type { Ref } from 'vue';
2
- import type { TresObject } from '../types';
1
+ import { TresObject } from '../types';
2
+ import { Ref } from 'vue';
3
+
3
4
  export declare const vDistanceTo: {
4
5
  updated: (el: TresObject, binding: Ref<TresObject>) => void;
5
6
  unmounted: (el: TresObject) => void;
@@ -1,4 +1,5 @@
1
- import type { TresObject } from '../types';
1
+ import { TresObject } from '../types';
2
+
2
3
  export declare const vLightHelper: {
3
4
  mounted: (el: TresObject) => void;
4
5
  updated: (el: TresObject) => void;
@@ -1,4 +1,5 @@
1
- import type { TresObject } from '../types';
1
+ import { TresObject } from '../types';
2
+
2
3
  export declare const vLog: {
3
4
  mounted: (el: TresObject, binding: {
4
5
  arg: string;
@@ -1,6 +1,7 @@
1
- import type { App } from 'vue';
1
+ import { default as templateCompilerOptions } from './utils/template-compiler-options';
2
2
  import { normalizeColor, normalizeVectorFlexibleParam } from './utils/normalize';
3
- import templateCompilerOptions from './utils/template-compiler-options';
3
+ import { App } from 'vue';
4
+
4
5
  export * from './composables';
5
6
  export * from './core/catalogue';
6
7
  export * from './components';
@@ -1,6 +1,7 @@
1
- import type { DefineComponent, VNode, VNodeRef } from 'vue';
1
+ import { EventProps as PointerEventHandlerEventProps } from '../composables/usePointerEventHandler';
2
+ import { DefineComponent, VNode, VNodeRef } from 'vue';
3
+
2
4
  import type * as THREE from 'three';
3
- import type { EventProps as PointerEventHandlerEventProps } from '../composables/usePointerEventHandler';
4
5
  export type AttachFnType<O = any> = (parent: any, self: O) => () => void;
5
6
  export type AttachType<O = any> = string | AttachFnType<O>;
6
7
  export type ConstructorRepresentation = new (...args: any[]) => any;
@@ -1,5 +1,5 @@
1
- import { MeshBasicMaterial, Vector3 } from 'three';
2
- import type { Mesh, Scene, Object3D } from 'three';
1
+ import { MeshBasicMaterial, Vector3, Mesh, Scene, Object3D } from 'three';
2
+
3
3
  export declare function toSetMethodName(key: string): string;
4
4
  export declare const merge: (target: any, source: any) => any;
5
5
  export declare const isHTMLTag: (key: string) => boolean;
@@ -1,5 +1,5 @@
1
- import type { ColorRepresentation } from 'three';
2
- import { Vector3, Color } from 'three';
1
+ import { ColorRepresentation, Vector3, Color } from 'three';
2
+
3
3
  export type SizeFlexibleParams = number[] | {
4
4
  width: number;
5
5
  height: number;
@@ -1,5 +1,6 @@
1
- import type { Scene } from 'three';
2
- import type { TresObject } from './../types';
1
+ import { TresObject } from './../types';
2
+ import { Scene } from 'three';
3
+
3
4
  export declare function calculateMemoryUsage(object: TresObject | Scene): number;
4
5
  export declare function bytesToKB(bytes: number): string;
5
6
  export declare function bytesToMB(bytes: number): string;
@@ -1 +1 @@
1
- export declare function withSetup(composable: any): (import("vue").App<Element> | undefined)[];
1
+ export declare function withSetup(composable: any): (import('vue').App<Element> | undefined)[];