@tresjs/core 4.0.0-next.2 → 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.
- package/README.md +1 -0
- package/components.d.ts +1 -1
- package/composables.d.ts +1 -1
- package/dist/src/components/TresCanvas.vue.d.ts +35 -10
- package/dist/src/components/index.d.ts +2 -1
- package/dist/src/composables/index.d.ts +1 -0
- package/dist/src/composables/useCamera/index.d.ts +2453 -2381
- package/dist/src/composables/useLoader/index.d.ts +45 -0
- package/dist/src/composables/useLogger.d.ts +5 -2
- package/dist/src/composables/usePointerEventHandler/index.d.ts +8 -6
- package/dist/src/composables/useRaycaster/index.d.ts +17 -0
- package/dist/src/composables/useRenderLoop/index.d.ts +3 -2
- package/dist/src/composables/useRenderer/index.d.ts +9 -15
- package/dist/src/composables/useSeek/index.d.ts +21 -0
- package/dist/src/composables/useSizes/index.d.ts +2 -1
- package/dist/src/composables/useTexture/index.d.ts +2 -1
- package/dist/src/composables/useTresContextProvider/index.d.ts +16 -14
- package/dist/src/composables/useTresEventManager/index.d.ts +22 -0
- package/dist/src/core/catalogue.d.ts +3 -2
- package/dist/src/core/nodeOps.d.ts +3 -2
- package/dist/src/devtools/highlight.d.ts +1 -1
- package/dist/src/devtools/plugin.d.ts +3 -2
- package/dist/src/directives/index.d.ts +6 -4
- package/dist/src/directives/vAlwaysLookAt.d.ts +4 -3
- package/dist/src/directives/vDistanceTo.d.ts +3 -2
- package/dist/src/directives/vLightHelper.d.ts +2 -1
- package/dist/src/directives/vLog.d.ts +2 -1
- package/dist/src/directives/vRotate.d.ts +13 -0
- package/dist/src/index.d.ts +5 -3
- package/dist/src/types/index.d.ts +35 -21
- package/dist/src/utils/index.d.ts +7 -3
- package/dist/src/utils/normalize.d.ts +2 -2
- package/dist/src/utils/perf.d.ts +3 -2
- package/dist/src/utils/test-utils.d.ts +3 -1
- package/dist/tres.js +915 -728
- package/dist/tres.umd.cjs +2 -2
- package/package.json +32 -29
- package/types.d.ts +1 -1
- package/utils.d.ts +1 -1
|
@@ -0,0 +1,45 @@
|
|
|
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>;
|
|
6
|
+
}
|
|
7
|
+
export type LoaderProto<T> = new (...args: any) => TresLoader<T extends unknown ? any : T>;
|
|
8
|
+
export type LoaderReturnType<T, L extends LoaderProto<T>> = T extends unknown ? Awaited<ReturnType<InstanceType<L>['loadAsync']>> : T;
|
|
9
|
+
/**
|
|
10
|
+
* Traverse an object and return all the nodes and materials
|
|
11
|
+
*
|
|
12
|
+
* @export
|
|
13
|
+
* @param {Object3D} object
|
|
14
|
+
* @return { [key: string]: any }
|
|
15
|
+
*/
|
|
16
|
+
export declare function trasverseObjects(object: Object3D): {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
};
|
|
19
|
+
export type Extensions<T extends {
|
|
20
|
+
prototype: LoaderProto<any>;
|
|
21
|
+
}> = (loader: T['prototype']) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Load resources using THREE loaders and return the result as a promise
|
|
24
|
+
*
|
|
25
|
+
* @see https://tresjs.org/api/composables.html#useloader
|
|
26
|
+
* @see https://threejs.org/docs/index.html?q=loader#api/en/loaders/Loader
|
|
27
|
+
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* import { useLoader } from '@tresjs/core'
|
|
30
|
+
* import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'
|
|
31
|
+
*
|
|
32
|
+
* const { scene } = await useLoader(THREE.GLTFLoader, 'path/to/asset.gltf')
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @export
|
|
36
|
+
* @template T
|
|
37
|
+
* @template U
|
|
38
|
+
* @param {T} Loader
|
|
39
|
+
* @param {U} url
|
|
40
|
+
* @param {Extensions<T>} [extensions]
|
|
41
|
+
* @param {(event: ProgressEvent<EventTarget>) => void} [onProgress]
|
|
42
|
+
* @param {(proto: TresLoader<T>) => void} [cb]
|
|
43
|
+
* @return {*}
|
|
44
|
+
*/
|
|
45
|
+
export declare function useLoader<T extends LoaderProto<T>, U extends string | string[]>(Loader: T, url: U, extensions?: Extensions<T>, onProgress?: (event: ProgressEvent<EventTarget>) => void, cb?: (proto: TresLoader<T>) => void): Promise<U extends any[] ? LoaderReturnType<T, T>[] : LoaderReturnType<T, 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: (
|
|
4
|
-
logWarning: (
|
|
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
|
|
2
|
-
import
|
|
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:
|
|
13
|
-
deregisterObject: (object:
|
|
14
|
-
registerBlockingObject: (object:
|
|
15
|
-
deregisterBlockingObject: (object:
|
|
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 {};
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
};
|
|
@@ -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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
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:
|
|
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(
|
|
85
|
+
renderer: import('vue').ShallowRef<WebGLRenderer>;
|
|
92
86
|
};
|
|
93
87
|
export type UseRendererReturn = ReturnType<typeof useRenderer>;
|
|
94
88
|
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Object3D, Scene } from 'three';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Seek composable return type
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @interface UseSeekReturn
|
|
8
|
+
*/
|
|
9
|
+
export interface UseSeekReturn {
|
|
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[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Composable that provides utilities to easily traverse and navigate through complex scenes and object children graphs
|
|
17
|
+
*
|
|
18
|
+
* @export
|
|
19
|
+
* @return {*} {UseSeekReturn}
|
|
20
|
+
*/
|
|
21
|
+
export declare function useSeek(): UseSeekReturn;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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:
|
|
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
|
|
2
|
-
import
|
|
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 {
|
|
2
|
-
import
|
|
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>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
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 {
|
|
2
|
-
import { vLightHelper } from './vLightHelper';
|
|
3
|
-
import { vAlwaysLookAt } from './vAlwaysLookAt';
|
|
1
|
+
import { vRotate } from './vRotate';
|
|
4
2
|
import { vDistanceTo } from './vDistanceTo';
|
|
5
|
-
|
|
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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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
|
|
2
|
-
import
|
|
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;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
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
|
|
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
|
|
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
|
|
36
|
-
parent
|
|
39
|
+
objects?: TresObject3D[];
|
|
40
|
+
parent?: TresObject3D | null;
|
|
37
41
|
primitive?: boolean;
|
|
38
|
-
eventCount
|
|
39
|
-
handlers
|
|
40
|
-
memoizedProps
|
|
42
|
+
eventCount?: number;
|
|
43
|
+
handlers?: Partial<EventHandlers>;
|
|
44
|
+
memoizedProps?: {
|
|
41
45
|
[key: string]: any;
|
|
42
46
|
};
|
|
43
|
-
disposable
|
|
44
|
-
root
|
|
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
|
|
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])
|
|
126
|
+
set: (...args: number[] | [THREE.ColorRepresentation]) => any;
|
|
115
127
|
}
|
|
116
128
|
interface VectorRepresentation extends MathRepresentation {
|
|
117
|
-
setScalar(s: number)
|
|
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
|
-
|
|
126
|
-
export type
|
|
127
|
-
export type
|
|
128
|
-
export type
|
|
129
|
-
export type
|
|
130
|
-
export type
|
|
131
|
-
export type
|
|
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[])
|
|
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 {
|
|
2
|
-
import
|
|
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:
|
|
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;
|
package/dist/src/utils/perf.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
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;
|