@tresjs/core 4.2.9 → 4.3.0

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 (38) hide show
  1. package/dist/index.d.ts +3 -0
  2. package/dist/src/components/TresCanvas.vue.d.ts +21 -58
  3. package/dist/src/components/index.d.ts +0 -1
  4. package/dist/src/composables/index.d.ts +8 -5
  5. package/dist/src/composables/useCamera/index.d.ts +4377 -488
  6. package/dist/src/composables/useLoader/component.vue.d.ts +25 -0
  7. package/dist/src/composables/useLoader/index.d.ts +0 -1
  8. package/dist/src/composables/useLoop/index.d.ts +1 -2
  9. package/dist/src/composables/useRaycaster/index.d.ts +1 -2
  10. package/dist/src/composables/useRenderLoop/index.d.ts +0 -1
  11. package/dist/src/composables/useRenderer/index.d.ts +3 -5
  12. package/dist/src/composables/useSeek/index.d.ts +0 -1
  13. package/dist/src/composables/useSizes/index.d.ts +2 -3
  14. package/dist/src/composables/useTexture/component.vue.d.ts +28 -0
  15. package/dist/src/composables/useTexture/index.d.ts +0 -1
  16. package/dist/src/composables/useTresContextProvider/index.d.ts +4 -6
  17. package/dist/src/composables/useTresEventManager/index.d.ts +1 -2
  18. package/dist/src/composables/useTresReady/createReadyEventHook/index.d.ts +0 -1
  19. package/dist/src/composables/useTresReady/index.d.ts +0 -1
  20. package/dist/src/core/catalogue.d.ts +1 -2
  21. package/dist/src/core/loop.d.ts +2 -3
  22. package/dist/src/core/nodeOps.d.ts +1 -2
  23. package/dist/src/devtools/plugin.d.ts +0 -1
  24. package/dist/src/directives/index.d.ts +3 -4
  25. package/dist/src/directives/vDistanceTo.d.ts +0 -1
  26. package/dist/src/directives/vLightHelper.d.ts +0 -1
  27. package/dist/src/directives/vLog.d.ts +0 -1
  28. package/dist/src/index.d.ts +5 -6
  29. package/dist/src/types/index.d.ts +14 -9
  30. package/dist/src/utils/createPriorityEventHook.d.ts +0 -1
  31. package/dist/src/utils/index.d.ts +2 -3
  32. package/dist/src/utils/is.d.ts +1 -2
  33. package/dist/src/utils/normalize.d.ts +0 -1
  34. package/dist/src/utils/perf.d.ts +0 -1
  35. package/dist/src/utils/test-utils.d.ts +0 -1
  36. package/dist/tres.js +935 -900
  37. package/dist/tres.umd.cjs +2 -2
  38. package/package.json +29 -30
@@ -0,0 +1,25 @@
1
+ import { LoaderProto } from './index';
2
+ declare function __VLS_template(): {
3
+ slots: {
4
+ default?(_: {
5
+ data: unknown;
6
+ }): any;
7
+ };
8
+ refs: {};
9
+ attrs: Partial<{}>;
10
+ };
11
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
12
+ declare const __VLS_component: import('vue').DefineComponent<{
13
+ loader: LoaderProto<unknown>;
14
+ url: string | string[];
15
+ }, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{
16
+ loader: LoaderProto<unknown>;
17
+ url: string | string[];
18
+ }> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
19
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
20
+ export default _default;
21
+ type __VLS_WithTemplateSlots<T, S> = T & {
22
+ new (): {
23
+ $slots: S;
24
+ };
25
+ };
@@ -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
  };
@@ -1,8 +1,7 @@
1
+ import { TresEvent, TresInstance } from 'src/types';
1
2
  import { Intersection, Object3D, Object3DEventMap } from 'three';
2
3
  import { ShallowRef } from 'vue';
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;
@@ -1,10 +1,9 @@
1
- import { WebGLRenderer, ColorSpace, Scene, ShadowMapType, ToneMapping, WebGLRendererParameters } from 'three';
2
- import { MaybeRef } from 'vue';
3
- import { MaybeRefOrGetter } from '@vueuse/core';
1
+ import { ColorSpace, Scene, ShadowMapType, ToneMapping, WebGLRendererParameters, WebGLRenderer } from 'three';
4
2
  import { EmitEventFn, TresColor } from '../../types';
5
3
  import { TresContext } from '../useTresContextProvider';
6
4
  import { RendererPresetsType } from './const';
7
-
5
+ import { MaybeRefOrGetter } from '@vueuse/core';
6
+ import { MaybeRef } from 'vue';
8
7
  type TransformToMaybeRefOrGetter<T> = {
9
8
  [K in keyof T]: MaybeRefOrGetter<T[K]> | MaybeRefOrGetter<T[K]>;
10
9
  };
@@ -85,7 +84,6 @@ export declare function useRenderer({ canvas, options, contextParts: { sizes, re
85
84
  invalidate: () => void;
86
85
  advance: () => void;
87
86
  };
88
- disableRender: MaybeRefOrGetter<boolean>;
89
87
  }): {
90
88
  renderer: import('vue').ShallowRef<WebGLRenderer>;
91
89
  };
@@ -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
  };
@@ -0,0 +1,28 @@
1
+ import { PBRUseTextureMap } from './index';
2
+ declare function __VLS_template(): {
3
+ slots: {
4
+ default?(_: {
5
+ textures: {
6
+ map: import('three').Texture;
7
+ displacementMap: import('three').Texture;
8
+ normalMap: import('three').Texture;
9
+ roughnessMap: import('three').Texture;
10
+ metalnessMap: import('three').Texture;
11
+ aoMap: import('three').Texture;
12
+ alphaMap: import('three').Texture;
13
+ matcap: import('three').Texture;
14
+ };
15
+ }): any;
16
+ };
17
+ refs: {};
18
+ attrs: Partial<{}>;
19
+ };
20
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
21
+ declare const __VLS_component: import('vue').DefineComponent<PBRUseTextureMap, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<PBRUseTextureMap> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
22
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
23
+ export default _default;
24
+ type __VLS_WithTemplateSlots<T, S> = T & {
25
+ new (): {
26
+ $slots: S;
27
+ };
28
+ };
@@ -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.
@@ -1,11 +1,10 @@
1
1
  import { Camera, WebGLRenderer, Raycaster } from 'three';
2
2
  import { ComputedRef, DeepReadonly, MaybeRef, MaybeRefOrGetter, Ref, ShallowRef } from 'vue';
3
- import { UseRendererOptions } from '../useRenderer';
3
+ import { RendererLoop } from '../../core/loop';
4
4
  import { EmitEventFn, TresControl, TresObject, TresScene } from '../../types';
5
- import { TresEventManager } from '../useTresEventManager';
5
+ import { UseRendererOptions } from '../useRenderer';
6
6
  import { SizesType } from '../useSizes';
7
- import { RendererLoop } from '../../core/loop';
8
-
7
+ import { TresEventManager } from '../useTresEventManager';
9
8
  export interface InternalState {
10
9
  priority: Ref<number>;
11
10
  frames: Ref<number>;
@@ -64,11 +63,10 @@ export interface TresContext {
64
63
  registerBlockingObjectAtPointerEventHandler?: (object: TresObject) => void;
65
64
  deregisterBlockingObjectAtPointerEventHandler?: (object: TresObject) => void;
66
65
  }
67
- export declare function useTresContextProvider({ scene, canvas, windowSize, disableRender, rendererOptions, emit, }: {
66
+ export declare function useTresContextProvider({ scene, canvas, windowSize, rendererOptions, emit, }: {
68
67
  scene: TresScene;
69
68
  canvas: MaybeRef<HTMLCanvasElement>;
70
69
  windowSize: MaybeRefOrGetter<boolean>;
71
- disableRender: MaybeRefOrGetter<boolean>;
72
70
  rendererOptions: UseRendererOptions;
73
71
  emit: EmitEventFn;
74
72
  }): TresContext;
@@ -1,7 +1,6 @@
1
- import { Scene } from 'three';
2
1
  import { EmitEventFn } from 'src/types';
2
+ import { Scene } from 'three';
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
- import { Ref } from 'vue';
2
- import { Camera, EventDispatcher, Raycaster, Scene, WebGLRenderer, Clock } from 'three';
3
1
  import { Fn } from '@vueuse/core';
4
-
2
+ import { Camera, EventDispatcher, Raycaster, Scene, WebGLRenderer, Clock } from 'three';
3
+ import { Ref } from 'vue';
5
4
  export type LoopStage = 'before' | 'render' | 'after';
6
5
  export interface LoopCallback {
7
6
  delta: number;
@@ -1,5 +1,4 @@
1
- import { RendererOptions } from 'vue';
2
1
  import { TresContext } from '../composables';
3
2
  import { TresObject } from '../types';
4
-
3
+ import { RendererOptions } from 'vue';
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
- import { vLog } from './vLog';
2
- import { vLightHelper } from './vLightHelper';
3
1
  import { vDistanceTo } from './vDistanceTo';
4
-
5
- export { vLog, vLightHelper, vDistanceTo };
2
+ import { vLightHelper } from './vLightHelper';
3
+ import { vLog } from './vLog';
4
+ export { vDistanceTo, vLightHelper, vLog };
@@ -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;
@@ -1,14 +1,13 @@
1
1
  import { App } from 'vue';
2
+ import { disposeObject3D as dispose } from './utils';
2
3
  import { normalizeColor, normalizeVectorFlexibleParam } from './utils/normalize';
3
4
  import { default as templateCompilerOptions } from './utils/template-compiler-options';
4
- import { disposeObject3D as dispose } from './utils';
5
-
5
+ export * from './components';
6
6
  export * from './composables';
7
7
  export * from './core/catalogue';
8
- export * from './components';
9
- export * from './types';
10
- export * from './directives';
11
8
  export * from './core/loop';
9
+ export * from './directives';
10
+ export * from './types';
12
11
  export interface TresOptions {
13
12
  extends?: Record<string, unknown>;
14
13
  }
@@ -18,5 +17,5 @@ export interface TresPlugin {
18
17
  }
19
18
  declare const plugin: TresPlugin;
20
19
  export default plugin;
21
- export { normalizeColor, normalizeVectorFlexibleParam, templateCompilerOptions, dispose, };
20
+ export { dispose, normalizeColor, normalizeVectorFlexibleParam, templateCompilerOptions, };
22
21
  export type { VectorFlexibleParams } from './utils/normalize';
@@ -1,13 +1,12 @@
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;
7
6
  export type DisposeType = ((self: TresInstance) => void) | boolean | 'default';
8
7
  export type ConstructorRepresentation = new (...args: any[]) => any;
9
8
  export type NonFunctionKeys<P> = {
10
- [K in keyof P]-?: P[K] extends Function ? never : K;
9
+ [K in keyof P]-?: P[K] extends (...args: any[]) => any ? never : K;
11
10
  }[keyof P];
12
11
  export type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O;
13
12
  export type Properties<T> = Pick<T, NonFunctionKeys<T>>;
@@ -21,12 +20,18 @@ 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;
34
+ attach?: AttachType;
30
35
  }
31
36
  interface TresBaseObject {
32
37
  removeFromParent?: () => void;
@@ -131,10 +136,10 @@ export interface EventHandlers {
131
136
  onWheel?: (event: ThreeEvent<WheelEvent>) => void;
132
137
  }
133
138
  interface MathRepresentation {
134
- set: (...args: number[] | [THREE.ColorRepresentation]) => any;
139
+ set(...args: number[] | [THREE.ColorRepresentation]): any;
135
140
  }
136
141
  interface VectorRepresentation extends MathRepresentation {
137
- setScalar: (s: number) => any;
142
+ setScalar(s: number): any;
138
143
  }
139
144
  export interface VectorCoordinates {
140
145
  x: number;
@@ -154,19 +159,19 @@ export type TresEuler = THREE.Euler;
154
159
  export type TresControl = THREE.EventDispatcher & {
155
160
  enabled: boolean;
156
161
  };
157
- type WithMathProps<P> = {
162
+ export type WithMathProps<P> = {
158
163
  [K in keyof P]: P[K] extends MathRepresentation | THREE.Euler ? MathType<P[K]> : P[K];
159
164
  };
160
165
  interface RaycastableRepresentation {
161
166
  raycast: (raycaster: THREE.Raycaster, intersects: THREE.Intersection[]) => void;
162
167
  }
163
168
  type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : unknown;
164
- export interface VueProps<P> {
165
- children?: VNode<P>[];
169
+ export interface VueProps {
170
+ children?: VNode[];
166
171
  ref?: VNodeRef;
167
172
  key?: string | number | symbol;
168
173
  }
169
- type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<Overwrite<WithMathProps<P>, VueProps<P> & EventProps<P>>>;
174
+ export type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<Overwrite<P, WithMathProps<P> & VueProps & EventProps<P>>>;
170
175
  export type ThreeElement<T extends ConstructorRepresentation> = Mutable<Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>>;
171
176
  type ThreeExports = typeof THREE;
172
177
  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);
@@ -1,8 +1,7 @@
1
- import { Material, Mesh, MeshBasicMaterial, Scene, Vector3 } from 'three';
2
- import { AttachType, LocalState, TresInstance, TresObject, TresPrimitive } from 'src/types';
3
1
  import { nodeOps } from 'src/core/nodeOps';
2
+ import { AttachType, LocalState, TresInstance, TresObject, TresPrimitive } from 'src/types';
3
+ import { Material, Mesh, MeshBasicMaterial, Scene, Vector3 } from 'three';
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,12 +1,11 @@
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;
7
6
  export declare function str(u: unknown): u is string;
8
7
  export declare function bool(u: unknown): u is boolean;
9
- export declare function fun(u: unknown): u is Function;
8
+ export declare function fun(u: unknown): u is (...args: any[]) => any;
10
9
  export declare function obj(u: unknown): u is Record<string | number | symbol, unknown>;
11
10
  export declare function object3D(u: unknown): u is Object3D;
12
11
  export declare function camera(u: unknown): u is Camera;
@@ -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)[];