@tresjs/core 4.0.0-next.1 → 4.0.0-rc.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 (39) 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 +35 -10
  5. package/dist/src/components/index.d.ts +2 -1
  6. package/dist/src/composables/index.d.ts +1 -0
  7. package/dist/src/composables/useCamera/index.d.ts +2453 -2414
  8. package/dist/src/composables/useLoader/index.d.ts +5 -4
  9. package/dist/src/composables/useLogger.d.ts +5 -2
  10. package/dist/src/composables/usePointerEventHandler/index.d.ts +8 -6
  11. package/dist/src/composables/useRaycaster/index.d.ts +16 -17
  12. package/dist/src/composables/useRenderLoop/index.d.ts +3 -2
  13. package/dist/src/composables/useRenderer/index.d.ts +9 -15
  14. package/dist/src/composables/useSeek/index.d.ts +6 -4
  15. package/dist/src/composables/useSizes/index.d.ts +2 -1
  16. package/dist/src/composables/useTexture/index.d.ts +2 -1
  17. package/dist/src/composables/useTresContextProvider/index.d.ts +16 -14
  18. package/dist/src/composables/useTresEventManager/index.d.ts +22 -0
  19. package/dist/src/core/catalogue.d.ts +3 -2
  20. package/dist/src/core/nodeOps.d.ts +3 -2
  21. package/dist/src/devtools/highlight.d.ts +1 -1
  22. package/dist/src/devtools/plugin.d.ts +3 -2
  23. package/dist/src/directives/index.d.ts +6 -4
  24. package/dist/src/directives/vAlwaysLookAt.d.ts +4 -3
  25. package/dist/src/directives/vDistanceTo.d.ts +3 -2
  26. package/dist/src/directives/vLightHelper.d.ts +2 -1
  27. package/dist/src/directives/vLog.d.ts +2 -1
  28. package/dist/src/directives/vRotate.d.ts +13 -0
  29. package/dist/src/index.d.ts +5 -3
  30. package/dist/src/types/index.d.ts +35 -21
  31. package/dist/src/utils/index.d.ts +7 -3
  32. package/dist/src/utils/normalize.d.ts +2 -2
  33. package/dist/src/utils/perf.d.ts +3 -2
  34. package/dist/src/utils/test-utils.d.ts +3 -1
  35. package/dist/tres.js +1015 -822
  36. package/dist/tres.umd.cjs +2 -2
  37. package/package.json +43 -39
  38. package/types.d.ts +1 -1
  39. package/utils.d.ts +1 -1
@@ -1,7 +1,8 @@
1
- import type { Object3D } from 'three';
2
- export interface TresLoader<T> extends THREE.Loader {
3
- load(url: string, onLoad?: (result: T) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): unknown;
4
- loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<T>;
1
+ import { Loader, Object3D } from 'three';
2
+
3
+ export interface TresLoader<T> extends Loader {
4
+ load: (url: string, onLoad?: (result: T) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void) => unknown;
5
+ loadAsync: (url: string, onProgress?: (event: ProgressEvent) => void) => Promise<T>;
5
6
  }
6
7
  export type LoaderProto<T> = new (...args: any) => TresLoader<T extends unknown ? any : T>;
7
8
  export type LoaderReturnType<T, L extends LoaderProto<T>> = T extends unknown ? Awaited<ReturnType<InstanceType<L>['loadAsync']>> : T;
@@ -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,5 +1,7 @@
1
- import type { Intersection, Object3D, Object3DEventMap } from 'three';
2
- import type { TresContext } from '../useTresContextProvider';
1
+ import { TresContext } from '../useTresContextProvider';
2
+ import { TresObject } from 'src/types';
3
+ import { Intersection, Object3D, Object3DEventMap } from 'three';
4
+
3
5
  type CallbackFn = (intersection: Intersection<Object3D<Object3DEventMap>>, event: PointerEvent) => void;
4
6
  type CallbackFnPointerLeave = (object: Object3D, event: PointerEvent) => void;
5
7
  export interface EventProps {
@@ -9,9 +11,9 @@ export interface EventProps {
9
11
  onPointerLeave?: CallbackFnPointerLeave;
10
12
  }
11
13
  export declare const usePointerEventHandler: (ctx: TresContext) => {
12
- registerObject: (object: Object3D & EventProps) => void;
13
- deregisterObject: (object: Object3D) => void;
14
- registerBlockingObject: (object: Object3D) => void;
15
- deregisterBlockingObject: (object: Object3D) => void;
14
+ registerObject: (object: TresObject & EventProps) => void;
15
+ deregisterObject: (object: TresObject) => void;
16
+ registerBlockingObject: (object: TresObject) => void;
17
+ deregisterBlockingObject: (object: TresObject) => void;
16
18
  };
17
19
  export {};
@@ -1,18 +1,17 @@
1
- import type { Object3D, Intersection } from 'three';
2
- import type { Ref } from 'vue';
3
- import { type TresContext } from '../useTresContextProvider';
4
- export type Intersects = Intersection<THREE.Object3D<THREE.Object3DEventMap>>[];
5
- interface PointerMoveEventPayload {
6
- intersects?: Intersects;
7
- event: PointerEvent;
8
- }
9
- interface PointerClickEventPayload {
10
- intersects: Intersects;
11
- event: PointerEvent;
12
- }
13
- export declare const useRaycaster: (objects: Ref<THREE.Object3D[]>, ctx: TresContext) => {
14
- intersects: import("vue").ComputedRef<Intersects>;
15
- onClick: (fn: (value: PointerClickEventPayload) => void) => () => void;
16
- onPointerMove: (fn: (value: PointerMoveEventPayload) => void) => () => void;
1
+ import { TresContext } from '../useTresContextProvider';
2
+ import { TresEvent } from 'src/types';
3
+ import { Ref, ShallowRef } from 'vue';
4
+ import { Intersection, Object3D } from 'three';
5
+
6
+ export declare const useRaycaster: (objects: Ref<Object3D[]>, ctx: TresContext) => {
7
+ intersects: ShallowRef<Intersection<Object3D<import('three').Object3DEventMap>>[]>;
8
+ onClick: (fn: (value: TresEvent) => void) => () => void;
9
+ onDblClick: (fn: (value: TresEvent) => void) => () => void;
10
+ onContextMenu: (fn: (value: TresEvent) => void) => () => void;
11
+ onPointerMove: (fn: (value: TresEvent) => void) => () => void;
12
+ onPointerUp: (fn: (value: TresEvent) => void) => () => void;
13
+ onPointerDown: (fn: (value: TresEvent) => void) => () => void;
14
+ onPointerMissed: (fn: (value: TresEvent) => void) => () => void;
15
+ onWheel: (fn: (value: TresEvent) => void) => () => void;
16
+ forceUpdate: () => void;
17
17
  };
18
- export {};
@@ -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 { EmitEventFn, TresColor } from '../../types';
4
+ import { MaybeRefOrGetter } from '@vueuse/core';
5
+ import { MaybeRef } from 'vue';
6
+ import { WebGLRenderer, ColorSpace, Scene, ShadowMapType, ToneMapping, WebGLRendererParameters } from 'three';
7
+
8
8
  type TransformToMaybeRefOrGetter<T> = {
9
9
  [K in keyof T]: MaybeRefOrGetter<T[K]> | MaybeRefOrGetter<T[K]>;
10
10
  };
@@ -71,24 +71,18 @@ export interface UseRendererOptions extends TransformToMaybeRefOrGetter<WebGLRen
71
71
  preset?: MaybeRefOrGetter<RendererPresetsType>;
72
72
  renderMode?: MaybeRefOrGetter<'always' | 'on-demand' | 'manual'>;
73
73
  }
74
- /**
75
- * Reactive three.js WebGLRenderer instance
76
- *
77
- * @param canvas
78
- * @param {UseRendererOptions} [options]
79
- */
80
74
  export declare function useRenderer({ scene, canvas, options, disableRender, emit, contextParts: { sizes, camera, render, invalidate, advance }, }: {
81
75
  canvas: MaybeRef<HTMLCanvasElement>;
82
76
  scene: Scene;
83
77
  options: UseRendererOptions;
84
- emit: (event: string, ...args: any[]) => void;
78
+ emit: EmitEventFn;
85
79
  contextParts: Pick<TresContext, 'sizes' | 'camera' | 'render'> & {
86
80
  invalidate: () => void;
87
81
  advance: () => void;
88
82
  };
89
83
  disableRender: MaybeRefOrGetter<boolean>;
90
84
  }): {
91
- renderer: import("vue").ShallowRef<WebGLRenderer>;
85
+ renderer: import('vue').ShallowRef<WebGLRenderer>;
92
86
  };
93
87
  export type UseRendererReturn = ReturnType<typeof useRenderer>;
94
88
  export {};
@@ -1,3 +1,5 @@
1
+ import { Object3D, Scene } 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
@@ -1,4 +1,5 @@
1
- import type { MaybeRefOrGetter, MaybeRef, ComputedRef, Ref } from 'vue';
1
+ import { ComputedRef, MaybeRef, MaybeRefOrGetter, Ref } from 'vue';
2
+
2
3
  export interface SizesType {
3
4
  height: Readonly<Ref<number>>;
4
5
  width: Readonly<Ref<number>>;
@@ -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,10 +1,11 @@
1
- import type { Camera, EventDispatcher, Object3D, 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';
5
- import type { TresScene } from '../../types';
6
- import type { EventProps } from '../usePointerEventHandler';
7
- import { type SizesType } from '../useSizes';
1
+ import { SizesType } from '../useSizes';
2
+ import { TresEventManager } from '../useTresEventManager';
3
+ import { EventProps } from '../usePointerEventHandler';
4
+ import { EmitEventFn, TresObject, TresScene } from '../../types';
5
+ import { UseRendererOptions } from '../useRenderer';
6
+ import { ComputedRef, DeepReadonly, MaybeRef, MaybeRefOrGetter, Ref, ShallowRef } from 'vue';
7
+ import { Camera, EventDispatcher, WebGLRenderer, Raycaster } from 'three';
8
+
8
9
  export interface InternalState {
9
10
  priority: Ref<number>;
10
11
  frames: Ref<number>;
@@ -52,16 +53,17 @@ export interface TresContext {
52
53
  */
53
54
  invalidate: () => void;
54
55
  /**
55
- * Advance one frame when renderMode === 'manual'
56
- */
56
+ * Advance one frame when renderMode === 'manual'
57
+ */
57
58
  advance: () => void;
58
59
  registerCamera: (camera: Camera) => void;
59
60
  setCameraActive: (cameraOrUuid: Camera | string) => void;
60
61
  deregisterCamera: (camera: Camera) => void;
61
- registerObjectAtPointerEventHandler: (object: Object3D & EventProps) => void;
62
- deregisterObjectAtPointerEventHandler: (object: Object3D) => void;
63
- registerBlockingObjectAtPointerEventHandler: (object: Object3D) => void;
64
- deregisterBlockingObjectAtPointerEventHandler: (object: Object3D) => void;
62
+ eventManager?: TresEventManager;
63
+ registerObjectAtPointerEventHandler?: (object: TresObject & EventProps) => void;
64
+ deregisterObjectAtPointerEventHandler?: (object: TresObject) => void;
65
+ registerBlockingObjectAtPointerEventHandler?: (object: TresObject) => void;
66
+ deregisterBlockingObjectAtPointerEventHandler?: (object: TresObject) => void;
65
67
  }
66
68
  export declare function useTresContextProvider({ scene, canvas, windowSize, disableRender, rendererOptions, emit, }: {
67
69
  scene: TresScene;
@@ -69,7 +71,7 @@ export declare function useTresContextProvider({ scene, canvas, windowSize, disa
69
71
  windowSize: MaybeRefOrGetter<boolean>;
70
72
  disableRender: MaybeRefOrGetter<boolean>;
71
73
  rendererOptions: UseRendererOptions;
72
- emit: (event: string, ...args: any[]) => void;
74
+ emit: EmitEventFn;
73
75
  }): TresContext;
74
76
  export declare function useTresContext(): TresContext;
75
77
  export declare const useTres: typeof useTresContext;
@@ -0,0 +1,22 @@
1
+ import { TresContext } from '../useTresContextProvider';
2
+ import { EmitEventFn, TresObject } from 'src/types';
3
+ import { Scene } from 'three';
4
+
5
+ export interface TresEventManager {
6
+ /**
7
+ * Forces the event system to refire events with the previous mouse event
8
+ */
9
+ forceUpdate: () => void;
10
+ /**
11
+ * pointer-missed events by definition are fired when the pointer missed every object in the scene
12
+ * So we need to track them separately
13
+ * Note: These are used in nodeOps
14
+ */
15
+ registerPointerMissedObject: (object: TresObject) => void;
16
+ deregisterPointerMissedObject: (object: TresObject) => void;
17
+ }
18
+ export declare function useTresEventManager(scene: Scene, context: TresContext, emit: EmitEventFn): {
19
+ forceUpdate: () => void;
20
+ registerPointerMissedObject: (object: TresObject) => void;
21
+ deregisterPointerMissedObject: (object: TresObject) => void;
22
+ };
@@ -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,4 +1,5 @@
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 function invalidateInstance(instance: TresObject): void;
4
5
  export declare const nodeOps: () => RendererOptions<TresObject, TresObject | null>;
@@ -2,6 +2,6 @@ import * as THREE from 'three';
2
2
  export declare class HightlightMesh extends THREE.Mesh {
3
3
  type: string;
4
4
  createTime: number;
5
- constructor(...args: THREE.Mesh['args']);
5
+ constructor(...args: any[]);
6
6
  onBeforeRender(): void;
7
7
  }
@@ -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,7 @@
1
- import { vLog } from './vLog';
2
- import { vLightHelper } from './vLightHelper';
3
- import { vAlwaysLookAt } from './vAlwaysLookAt';
1
+ import { vRotate } from './vRotate';
4
2
  import { vDistanceTo } from './vDistanceTo';
5
- export { vLog, vLightHelper, vAlwaysLookAt, vDistanceTo };
3
+ import { vAlwaysLookAt } from './vAlwaysLookAt';
4
+ import { vLightHelper } from './vLightHelper';
5
+ import { vLog } from './vLog';
6
+
7
+ export { vLog, vLightHelper, vAlwaysLookAt, vDistanceTo, vRotate };
@@ -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;
@@ -0,0 +1,13 @@
1
+ import { TresObject } from '../types';
2
+
3
+ export declare const vRotate: {
4
+ mounted: (el: TresObject, binding: {
5
+ arg: 'x' | 'y' | 'z';
6
+ value: number;
7
+ modifiers: Partial<{
8
+ x: boolean;
9
+ y: boolean;
10
+ z: boolean;
11
+ }>;
12
+ }) => void;
13
+ };
@@ -1,6 +1,8 @@
1
- import type { App } from 'vue';
1
+ import { disposeObject3D as dispose } from './utils';
2
+ import { default as templateCompilerOptions } from './utils/template-compiler-options';
2
3
  import { normalizeColor, normalizeVectorFlexibleParam } from './utils/normalize';
3
- import templateCompilerOptions from './utils/template-compiler-options';
4
+ import { App } from 'vue';
5
+
4
6
  export * from './composables';
5
7
  export * from './core/catalogue';
6
8
  export * from './components';
@@ -15,4 +17,4 @@ export interface TresPlugin {
15
17
  }
16
18
  declare const plugin: TresPlugin;
17
19
  export default plugin;
18
- export { normalizeColor, normalizeVectorFlexibleParam, templateCompilerOptions, };
20
+ export { normalizeColor, normalizeVectorFlexibleParam, templateCompilerOptions, dispose, };
@@ -1,6 +1,7 @@
1
- import type { DefineComponent, VNode, VNodeRef } from 'vue';
1
+ import { TresContext } from '../composables/useTresContextProvider';
2
+ import { DefineComponent, VNode, VNodeRef } from 'vue';
3
+
2
4
  import type * as THREE from 'three';
3
- import type { TresContext } from '../composables/useTresContextProvider';
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;
@@ -16,6 +17,8 @@ export type Args<T> = T extends ConstructorRepresentation ? ConstructorParameter
16
17
  export interface TresCatalogue {
17
18
  [name: string]: ConstructorRepresentation;
18
19
  }
20
+ export type EmitEventName = 'render' | 'click' | 'double-click' | 'context-menu' | 'pointer-move' | 'pointer-up' | 'pointer-down' | 'pointer-enter' | 'pointer-leave' | 'pointer-over' | 'pointer-out' | 'pointer-missed' | 'wheel';
21
+ export type EmitEventFn = (event: EmitEventName, ...args: any[]) => void;
19
22
  export type TresCamera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
20
23
  export interface InstanceProps<T = any, P = any> {
21
24
  args?: Args<P>;
@@ -23,6 +26,7 @@ export interface InstanceProps<T = any, P = any> {
23
26
  visible?: boolean;
24
27
  dispose?: null;
25
28
  attach?: AttachType<T>;
29
+ [prop: string]: any;
26
30
  }
27
31
  interface TresBaseObject {
28
32
  attach?: string;
@@ -32,23 +36,23 @@ interface TresBaseObject {
32
36
  }
33
37
  export interface LocalState {
34
38
  type: string;
35
- objects: TresObject3D[];
36
- parent: TresObject3D | null;
39
+ objects?: TresObject3D[];
40
+ parent?: TresObject3D | null;
37
41
  primitive?: boolean;
38
- eventCount: number;
39
- handlers: Partial<EventHandlers>;
40
- memoizedProps: {
42
+ eventCount?: number;
43
+ handlers?: Partial<EventHandlers>;
44
+ memoizedProps?: {
41
45
  [key: string]: any;
42
46
  };
43
- disposable: boolean;
44
- root: TresContext;
47
+ disposable?: boolean;
48
+ root?: TresContext;
45
49
  }
46
50
  export interface TresObject3D extends THREE.Object3D<THREE.Object3DEventMap> {
47
51
  geometry?: THREE.BufferGeometry & TresBaseObject;
48
52
  material?: THREE.Material & TresBaseObject;
49
53
  }
50
54
  export type TresObject = TresBaseObject & (TresObject3D | THREE.BufferGeometry | THREE.Material | THREE.Fog) & {
51
- __tres: LocalState;
55
+ __tres?: LocalState;
52
56
  };
53
57
  export interface TresScene extends THREE.Scene {
54
58
  __tres: {
@@ -83,6 +87,14 @@ export interface IntersectionEvent<TSourceEvent> extends Intersection {
83
87
  }
84
88
  export type ThreeEvent<TEvent> = IntersectionEvent<TEvent> & Properties<TEvent>;
85
89
  export type DomEvent = PointerEvent | MouseEvent | WheelEvent;
90
+ export interface TresEvent {
91
+ eventObject: TresObject;
92
+ event: DomEvent;
93
+ stopPropagation: () => void;
94
+ stopPropagating: boolean;
95
+ intersections: Intersection[];
96
+ intersects: Intersection[];
97
+ }
86
98
  export interface Events {
87
99
  onClick: EventListener;
88
100
  onContextMenu: EventListener;
@@ -111,10 +123,10 @@ export interface EventHandlers {
111
123
  onWheel?: (event: ThreeEvent<WheelEvent>) => void;
112
124
  }
113
125
  interface MathRepresentation {
114
- set(...args: number[] | [THREE.ColorRepresentation]): any;
126
+ set: (...args: number[] | [THREE.ColorRepresentation]) => any;
115
127
  }
116
128
  interface VectorRepresentation extends MathRepresentation {
117
- setScalar(s: number): any;
129
+ setScalar: (s: number) => any;
118
130
  }
119
131
  export interface VectorCoordinates {
120
132
  x: number;
@@ -122,22 +134,24 @@ export interface VectorCoordinates {
122
134
  z: number;
123
135
  }
124
136
  export type MathType<T extends MathRepresentation | THREE.Euler> = T extends THREE.Color ? ConstructorParameters<typeof THREE.Color> | THREE.ColorRepresentation : T extends VectorRepresentation | THREE.Layers | THREE.Euler ? T | Parameters<T['set']> | number | VectorCoordinates : T | Parameters<T['set']>;
125
- export type TresVector2 = MathType<THREE.Vector2>;
126
- export type TresVector3 = MathType<THREE.Vector3>;
127
- export type TresVector4 = MathType<THREE.Vector4>;
128
- export type TresColor = MathType<THREE.Color>;
129
- export type TresLayers = MathType<THREE.Layers>;
130
- export type TresQuaternion = MathType<THREE.Quaternion>;
131
- export type TresEuler = MathType<THREE.Euler>;
137
+ type VectorLike<VectorClass extends THREE.Vector2 | THREE.Vector3 | THREE.Vector4> = VectorClass | Parameters<VectorClass['set']> | Readonly<Parameters<VectorClass['set']>> | Parameters<VectorClass['setScalar']>[0];
138
+ export type TresVector2 = VectorLike<THREE.Vector2>;
139
+ export type TresVector3 = VectorLike<THREE.Vector3>;
140
+ export type TresVector4 = VectorLike<THREE.Vector4>;
141
+ export type TresColor = ConstructorParameters<typeof THREE.Color> | THREE.Color | number | string;
142
+ export type TresColorArray = typeof THREE.Color | [color: THREE.ColorRepresentation];
143
+ export type TresLayers = THREE.Layers | Parameters<THREE.Layers['set']>[0];
144
+ export type TresQuaternion = THREE.Quaternion | Parameters<THREE.Quaternion['set']>;
145
+ export type TresEuler = THREE.Euler;
132
146
  type WithMathProps<P> = {
133
147
  [K in keyof P]: P[K] extends MathRepresentation | THREE.Euler ? MathType<P[K]> : P[K];
134
148
  };
135
149
  interface RaycastableRepresentation {
136
- raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void;
150
+ raycast: (raycaster: THREE.Raycaster, intersects: THREE.Intersection[]) => void;
137
151
  }
138
152
  type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : unknown;
139
153
  export interface VueProps<P> {
140
- children?: VNode[];
154
+ children?: VNode<P>[];
141
155
  ref?: VNodeRef;
142
156
  key?: string | number | symbol;
143
157
  }
@@ -1,10 +1,12 @@
1
- import { MeshBasicMaterial, Vector3 } from 'three';
2
- import type { Mesh, Scene, Object3D } from 'three';
1
+ import { TresObject } from 'src/types';
2
+ import { Material, Mesh, MeshBasicMaterial, Scene, Vector3 } from 'three';
3
+
3
4
  export declare function toSetMethodName(key: string): string;
4
5
  export declare const merge: (target: any, source: any) => any;
5
6
  export declare const isHTMLTag: (key: string) => boolean;
6
7
  export declare function isDOMElement(obj: any): obj is HTMLElement;
7
8
  export declare function kebabToCamel(str: string): string;
9
+ export declare function hyphenate(str: string): string;
8
10
  export declare function makeMap(str: string, expectsLowerCase?: boolean): (key: string) => boolean;
9
11
  export declare const uniqueBy: <T, K>(array: T[], iteratee: (value: T) => K) => T[];
10
12
  export declare const get: <T>(obj: any, path: string | string[]) => T | undefined;
@@ -19,5 +21,7 @@ export declare function editSceneObject(scene: Scene, objectUuid: string, proper
19
21
  export declare function createHighlightMaterial(): MeshBasicMaterial;
20
22
  export declare function animateHighlight(highlightMesh: Mesh, startTime: number): void;
21
23
  export declare function stopHighlightAnimation(): void;
22
- export declare function createHighlightMesh(object: Object3D): Mesh;
24
+ export declare function createHighlightMesh(object: TresObject): Mesh;
23
25
  export declare function extractBindingPosition(binding: any): Vector3;
26
+ export declare function disposeMaterial(material: Material): void;
27
+ export declare function disposeObject3D(object: TresObject): void;
@@ -1,5 +1,5 @@
1
- import type { ColorRepresentation } from 'three';
2
- import { Vector3, Color } from 'three';
1
+ import { ColorRepresentation, Color, Vector3 } 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,3 @@
1
- export declare function withSetup(composable: any): (import("vue").App<Element> | undefined)[];
1
+ import { Fn } from '@vueuse/core';
2
+
3
+ export declare function withSetup(composable: Fn): (import('vue').App<Element> | undefined)[];