@tresjs/core 4.3.5 → 5.0.0-alpha.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/dist/src/components/TresCanvas.vue.d.ts +70 -64
- package/dist/src/composables/index.d.ts +6 -12
- package/dist/src/composables/useCamera/index.d.ts +42 -8555
- package/dist/src/composables/useCreateRafLoop/index.d.ts +14 -0
- package/dist/src/composables/useEventManager/index.d.ts +10 -0
- package/dist/src/composables/useGraph/index.d.ts +3 -0
- package/dist/src/composables/useLoader/component.vue.d.ts +31 -17
- package/dist/src/composables/useLoader/index.d.ts +44 -37
- package/dist/src/composables/useLoop/index.d.ts +13 -16
- package/dist/src/composables/useRenderer/pixelRatio.d.ts +4 -0
- package/dist/src/composables/useRenderer/useRendererManager.d.ts +194 -0
- package/dist/src/composables/useTres/index.d.ts +37 -0
- package/dist/src/composables/useTresContextProvider/index.d.ts +14 -64
- package/dist/src/devtools/inspectorHandlers.d.ts +60 -0
- package/dist/src/devtools/plugin.d.ts +3 -8
- package/dist/src/devtools/setupDevtools.d.ts +14 -0
- package/dist/src/devtools/types.d.ts +90 -0
- package/dist/src/index.d.ts +4 -1
- package/dist/src/types/index.d.ts +13 -69
- package/dist/src/utils/array.d.ts +6 -0
- package/dist/src/utils/createPriorityEventHook.d.ts +4 -6
- package/dist/src/utils/graph.d.ts +15 -0
- package/dist/src/utils/index.d.ts +2 -34
- package/dist/src/utils/is/dom.d.ts +1 -0
- package/dist/src/utils/is/index.d.ts +4 -0
- package/dist/src/utils/is/three.d.ts +162 -0
- package/dist/src/utils/is/tres.d.ts +70 -0
- package/dist/src/utils/is/typed.d.ts +1 -0
- package/dist/src/utils/is/util.d.ts +1 -0
- package/dist/src/utils/logger.d.ts +25 -0
- package/dist/src/utils/makeMap.d.ts +9 -0
- package/dist/src/utils/perf.d.ts +1 -0
- package/dist/src/utils/pointerEvents.d.ts +10 -0
- package/dist/src/utils/string.d.ts +1 -0
- package/dist/src/utils/three.d.ts +9 -0
- package/dist/tres.js +5320 -1482
- package/package.json +42 -16
- package/dist/src/composables/useLogger.d.ts +0 -11
- package/dist/src/composables/useRaycaster/index.d.ts +0 -16
- package/dist/src/composables/useRenderLoop/index.d.ts +0 -17
- package/dist/src/composables/useRenderer/const.d.ts +0 -18
- package/dist/src/composables/useRenderer/index.d.ts +0 -91
- package/dist/src/composables/useSeek/index.d.ts +0 -20
- package/dist/src/composables/useTexture/component.vue.d.ts +0 -29
- package/dist/src/composables/useTexture/index.d.ts +0 -103
- package/dist/src/composables/useTresEventManager/index.d.ts +0 -25
- package/dist/src/composables/useTresReady/createReadyEventHook/index.d.ts +0 -4
- package/dist/src/composables/useTresReady/index.d.ts +0 -7
- package/dist/src/core/loop.d.ts +0 -38
- package/dist/src/utils/is.d.ts +0 -36
- package/dist/tres.umd.cjs +0 -8
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a tag that can be displayed in the inspector UI
|
|
3
|
+
* @interface Tags
|
|
4
|
+
*/
|
|
5
|
+
export interface Tags {
|
|
6
|
+
/** The text to display in the tag */
|
|
7
|
+
label: string;
|
|
8
|
+
/** The color of the text in hexadecimal format (e.g., 0xFFFFFF) */
|
|
9
|
+
textColor: number;
|
|
10
|
+
/** The background color of the tag in hexadecimal format (e.g., 0x000000) */
|
|
11
|
+
backgroundColor: number;
|
|
12
|
+
/** Optional tooltip text to show on hover */
|
|
13
|
+
tooltip?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Represents a node in the scene graph that can be displayed in the inspector
|
|
17
|
+
* @interface SceneGraphObject
|
|
18
|
+
*/
|
|
19
|
+
export interface SceneGraphObject {
|
|
20
|
+
/** Unique identifier for the node */
|
|
21
|
+
id: string;
|
|
22
|
+
/** Display name of the node */
|
|
23
|
+
label: string;
|
|
24
|
+
/** Array of child nodes */
|
|
25
|
+
children: SceneGraphObject[];
|
|
26
|
+
/** Array of tags associated with the node */
|
|
27
|
+
tags: Tags[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Represents memory usage statistics for Three.js resources
|
|
31
|
+
* @interface MemoryStats
|
|
32
|
+
*/
|
|
33
|
+
export interface MemoryStats {
|
|
34
|
+
/** Map of geometry names to their memory usage in bytes */
|
|
35
|
+
geometries: Map<string, number>;
|
|
36
|
+
/** Map of material names to their memory usage in bytes */
|
|
37
|
+
materials: Map<string, number>;
|
|
38
|
+
/** Map of texture names to their memory usage in bytes */
|
|
39
|
+
textures: Map<string, number>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Represents a property in the inspector state
|
|
43
|
+
* @interface InspectorStateProperty
|
|
44
|
+
*/
|
|
45
|
+
export interface InspectorStateProperty {
|
|
46
|
+
/** The name of the property */
|
|
47
|
+
key: string;
|
|
48
|
+
/** The value of the property */
|
|
49
|
+
value: unknown;
|
|
50
|
+
/** Whether the property can be edited in the inspector */
|
|
51
|
+
editable: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Represents the state of an inspector panel
|
|
55
|
+
* @interface InspectorState
|
|
56
|
+
*/
|
|
57
|
+
export interface InspectorState {
|
|
58
|
+
/** Array of properties to display in the inspector */
|
|
59
|
+
object: InspectorStateProperty[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Represents the internal state of the devtools
|
|
63
|
+
* @interface DevtoolsState
|
|
64
|
+
*/
|
|
65
|
+
export interface DevtoolsState {
|
|
66
|
+
/** The current scene graph representation */
|
|
67
|
+
sceneGraph: SceneGraphObject | null;
|
|
68
|
+
/** Timestamp of the last update */
|
|
69
|
+
lastUpdate: number;
|
|
70
|
+
/** Minimum time between updates in milliseconds */
|
|
71
|
+
updateThreshold: number;
|
|
72
|
+
/** Current memory usage statistics */
|
|
73
|
+
memoryStats: MemoryStats;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Represents a payload sent to or received from the devtools
|
|
77
|
+
* @interface DevtoolsPayload
|
|
78
|
+
*/
|
|
79
|
+
export interface DevtoolsPayload {
|
|
80
|
+
/** The ID of the inspector panel */
|
|
81
|
+
inspectorId: string;
|
|
82
|
+
/** The ID of the node being inspected */
|
|
83
|
+
nodeId: string;
|
|
84
|
+
/** Optional filter string for searching */
|
|
85
|
+
filter?: string;
|
|
86
|
+
/** Optional state to update */
|
|
87
|
+
state?: InspectorState;
|
|
88
|
+
/** Optional path to the property being edited */
|
|
89
|
+
path?: string[];
|
|
90
|
+
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -5,9 +5,12 @@ import { default as templateCompilerOptions } from './utils/template-compiler-op
|
|
|
5
5
|
export * from './components';
|
|
6
6
|
export * from './composables';
|
|
7
7
|
export * from './core/catalogue';
|
|
8
|
-
export * from './core/loop';
|
|
9
8
|
export * from './directives';
|
|
10
9
|
export * from './types';
|
|
10
|
+
export * from './utils/graph';
|
|
11
|
+
export * from './utils/is/three';
|
|
12
|
+
export * from './utils/is/tres';
|
|
13
|
+
export * from './utils/logger';
|
|
11
14
|
export interface TresOptions {
|
|
12
15
|
extends?: Record<string, unknown>;
|
|
13
16
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DefineComponent, VNode, VNodeRef } from 'vue';
|
|
2
2
|
import { TresContext } from '../composables/useTresContextProvider';
|
|
3
|
+
import { PointerEventHandlers } from '../utils/pointerEvents';
|
|
3
4
|
import type * as THREE from 'three';
|
|
4
5
|
export type AttachFnType = (parent: any, self: TresInstance) => () => void;
|
|
5
6
|
export type AttachType = string | AttachFnType;
|
|
@@ -17,8 +18,6 @@ export type Args<T> = T extends ConstructorRepresentation ? ConstructorParameter
|
|
|
17
18
|
export interface TresCatalogue {
|
|
18
19
|
[name: string]: ConstructorRepresentation;
|
|
19
20
|
}
|
|
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';
|
|
21
|
-
export type EmitEventFn = (event: EmitEventName, ...args: any[]) => void;
|
|
22
21
|
export type TresCamera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
|
|
23
22
|
/**
|
|
24
23
|
* Represents the properties of an instance.
|
|
@@ -40,9 +39,7 @@ interface TresBaseObject {
|
|
|
40
39
|
}
|
|
41
40
|
export interface LocalState {
|
|
42
41
|
type: string;
|
|
43
|
-
eventCount: number;
|
|
44
42
|
root: TresContext;
|
|
45
|
-
handlers: Partial<EventHandlers>;
|
|
46
43
|
memoizedProps: {
|
|
47
44
|
[key: string]: any;
|
|
48
45
|
};
|
|
@@ -60,6 +57,12 @@ export interface TresObject3D extends THREE.Object3D<THREE.Object3DEventMap> {
|
|
|
60
57
|
export type TresObject = TresBaseObject & (TresObject3D | THREE.BufferGeometry | THREE.Material | THREE.Fog) & {
|
|
61
58
|
__tres?: LocalState;
|
|
62
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* Union type covering all common Three.js material types
|
|
62
|
+
* This provides better TypeScript intellisense and type checking
|
|
63
|
+
* when accessing specific material properties
|
|
64
|
+
*/
|
|
65
|
+
export type TresMaterial = THREE.MeshBasicMaterial | THREE.MeshStandardMaterial | THREE.MeshPhysicalMaterial | THREE.MeshLambertMaterial | THREE.MeshPhongMaterial | THREE.MeshToonMaterial | THREE.MeshNormalMaterial | THREE.MeshMatcapMaterial | THREE.MeshDepthMaterial | THREE.MeshDistanceMaterial | THREE.LineBasicMaterial | THREE.LineDashedMaterial | THREE.PointsMaterial | THREE.SpriteMaterial | THREE.ShaderMaterial | THREE.RawShaderMaterial | THREE.ShadowMaterial | THREE.Material;
|
|
63
66
|
export type TresInstance = TresObject & {
|
|
64
67
|
__tres: LocalState;
|
|
65
68
|
};
|
|
@@ -72,69 +75,6 @@ export interface TresScene extends THREE.Scene {
|
|
|
72
75
|
root: TresContext;
|
|
73
76
|
};
|
|
74
77
|
}
|
|
75
|
-
export interface Intersection extends THREE.Intersection {
|
|
76
|
-
/** The event source (the object which registered the handler) */
|
|
77
|
-
eventObject: TresObject;
|
|
78
|
-
}
|
|
79
|
-
export interface IntersectionEvent<TSourceEvent> extends Intersection {
|
|
80
|
-
/** The event source (the object which registered the handler) */
|
|
81
|
-
eventObject: TresObject;
|
|
82
|
-
/** An array of intersections */
|
|
83
|
-
intersections: Intersection[];
|
|
84
|
-
/** vec3.set(pointer.x, pointer.y, 0).unproject(camera) */
|
|
85
|
-
unprojectedPoint: THREE.Vector3;
|
|
86
|
-
/** Normalized event coordinates */
|
|
87
|
-
pointer: THREE.Vector2;
|
|
88
|
-
/** Delta between first click and this event */
|
|
89
|
-
delta: number;
|
|
90
|
-
/** The ray that pierced it */
|
|
91
|
-
ray: THREE.Ray;
|
|
92
|
-
/** The camera that was used by the raycaster */
|
|
93
|
-
camera: TresCamera;
|
|
94
|
-
/** stopPropagation will stop underlying handlers from firing */
|
|
95
|
-
stopPropagation: () => void;
|
|
96
|
-
/** The original host event */
|
|
97
|
-
nativeEvent: TSourceEvent;
|
|
98
|
-
/** If the event was stopped by calling stopPropagation */
|
|
99
|
-
stopped: boolean;
|
|
100
|
-
}
|
|
101
|
-
export type ThreeEvent<TEvent> = IntersectionEvent<TEvent> & Properties<TEvent>;
|
|
102
|
-
export type DomEvent = PointerEvent | MouseEvent | WheelEvent;
|
|
103
|
-
export interface TresEvent {
|
|
104
|
-
eventObject: TresObject;
|
|
105
|
-
event: DomEvent;
|
|
106
|
-
stopPropagation: () => void;
|
|
107
|
-
stopPropagating: boolean;
|
|
108
|
-
intersections: Intersection[];
|
|
109
|
-
intersects: Intersection[];
|
|
110
|
-
}
|
|
111
|
-
export interface Events {
|
|
112
|
-
onClick: EventListener;
|
|
113
|
-
onContextMenu: EventListener;
|
|
114
|
-
onDoubleClick: EventListener;
|
|
115
|
-
onWheel: EventListener;
|
|
116
|
-
onPointerDown: EventListener;
|
|
117
|
-
onPointerUp: EventListener;
|
|
118
|
-
onPointerLeave: EventListener;
|
|
119
|
-
onPointerMove: EventListener;
|
|
120
|
-
onPointerCancel: EventListener;
|
|
121
|
-
onLostPointerCapture: EventListener;
|
|
122
|
-
}
|
|
123
|
-
export interface EventHandlers {
|
|
124
|
-
onClick?: (event: ThreeEvent<MouseEvent>) => void;
|
|
125
|
-
onContextMenu?: (event: ThreeEvent<MouseEvent>) => void;
|
|
126
|
-
onDoubleClick?: (event: ThreeEvent<MouseEvent>) => void;
|
|
127
|
-
onPointerUp?: (event: ThreeEvent<PointerEvent>) => void;
|
|
128
|
-
onPointerDown?: (event: ThreeEvent<PointerEvent>) => void;
|
|
129
|
-
onPointerOver?: (event: ThreeEvent<PointerEvent>) => void;
|
|
130
|
-
onPointerOut?: (event: ThreeEvent<PointerEvent>) => void;
|
|
131
|
-
onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void;
|
|
132
|
-
onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void;
|
|
133
|
-
onPointerMove?: (event: ThreeEvent<PointerEvent>) => void;
|
|
134
|
-
onPointerMissed?: (event: MouseEvent) => void;
|
|
135
|
-
onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void;
|
|
136
|
-
onWheel?: (event: ThreeEvent<WheelEvent>) => void;
|
|
137
|
-
}
|
|
138
78
|
interface MathRepresentation {
|
|
139
79
|
set(...args: number[] | [THREE.ColorRepresentation]): any;
|
|
140
80
|
}
|
|
@@ -159,13 +99,18 @@ export type TresEuler = THREE.Euler;
|
|
|
159
99
|
export type TresControl = THREE.EventDispatcher & {
|
|
160
100
|
enabled: boolean;
|
|
161
101
|
};
|
|
102
|
+
export type TresContextWithClock = TresContext & {
|
|
103
|
+
delta: number;
|
|
104
|
+
elapsed: number;
|
|
105
|
+
};
|
|
162
106
|
export type WithMathProps<P> = {
|
|
163
107
|
[K in keyof P]: P[K] extends MathRepresentation | THREE.Euler ? MathType<P[K]> : P[K];
|
|
164
108
|
};
|
|
165
109
|
interface RaycastableRepresentation {
|
|
166
110
|
raycast: (raycaster: THREE.Raycaster, intersects: THREE.Intersection[]) => void;
|
|
167
111
|
}
|
|
168
|
-
type EventProps<P> = P extends RaycastableRepresentation ? Partial<
|
|
112
|
+
type EventProps<P> = P extends RaycastableRepresentation ? Partial<PointerEventHandlers> : unknown;
|
|
113
|
+
export type { TresPointerEvent } from '../utils/pointerEvents';
|
|
169
114
|
export interface VueProps {
|
|
170
115
|
children?: VNode[];
|
|
171
116
|
ref?: VNodeRef;
|
|
@@ -190,4 +135,3 @@ declare module 'vue' {
|
|
|
190
135
|
primitive: DefineComponent<TresPrimitive>;
|
|
191
136
|
}
|
|
192
137
|
}
|
|
193
|
-
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Like Array.filter, but modifies the array in place.
|
|
3
|
+
* @param array - Array to modify
|
|
4
|
+
* @param callbackFn - A function called for each element of the array. It should return a truthy value to keep the element in the array.
|
|
5
|
+
*/
|
|
6
|
+
export declare const filterInPlace: <T>(array: T[], callbackFn: (element: T, index: number) => unknown) => T[];
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { EventHookOff,
|
|
2
|
-
export type Callback<T> =
|
|
3
|
-
T
|
|
4
|
-
] extends [void] ? () => void : (param: T) => void);
|
|
1
|
+
import { EventHookOff, EventHookTrigger } from '@vueuse/core';
|
|
2
|
+
export type Callback<T> = Parameters<EventHookOff<T>>[0];
|
|
5
3
|
export type PriorityEventHookOn<T> = (fn: Callback<T>, priority?: number) => {
|
|
6
4
|
off: () => void;
|
|
7
5
|
};
|
|
8
6
|
export type PriorityEventHookOff<T> = EventHookOff<T>;
|
|
9
|
-
export type PriorityEventHookTrigger<T
|
|
7
|
+
export type PriorityEventHookTrigger<T> = EventHookTrigger<T>;
|
|
10
8
|
export interface PriorityEventHook<T = any> {
|
|
11
9
|
on: PriorityEventHookOn<T>;
|
|
12
|
-
off:
|
|
10
|
+
off: (fn: Callback<T>) => void;
|
|
13
11
|
trigger: PriorityEventHookTrigger<T>;
|
|
14
12
|
dispose: () => void;
|
|
15
13
|
count: number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Mesh, Object3D, Scene } from 'three';
|
|
2
|
+
import { TresMaterial, TresObject } from '../types';
|
|
3
|
+
export interface TresObjectMap {
|
|
4
|
+
nodes: {
|
|
5
|
+
[name: string]: TresObject;
|
|
6
|
+
};
|
|
7
|
+
materials: {
|
|
8
|
+
[name: string]: TresMaterial;
|
|
9
|
+
};
|
|
10
|
+
meshes: {
|
|
11
|
+
[name: string]: Mesh;
|
|
12
|
+
};
|
|
13
|
+
scene?: Scene;
|
|
14
|
+
}
|
|
15
|
+
export declare function buildGraph(object: Object3D | TresObject): TresObjectMap;
|
|
@@ -1,37 +1,10 @@
|
|
|
1
1
|
import { nodeOps } from 'src/core/nodeOps';
|
|
2
2
|
import { AttachType, LocalState, TresInstance, TresObject, TresPrimitive } from 'src/types';
|
|
3
|
-
import { Material
|
|
3
|
+
import { Material } from 'three';
|
|
4
4
|
import { TresContext } from '../composables/useTresContextProvider';
|
|
5
|
-
export
|
|
6
|
-
export declare const merge: (target: any, source: any) => any;
|
|
7
|
-
export declare const isHTMLTag: (key: string) => boolean;
|
|
8
|
-
export declare function isDOMElement(obj: any): obj is HTMLElement;
|
|
9
|
-
export declare function kebabToCamel(str: string): string;
|
|
10
|
-
export declare function hyphenate(str: string): string;
|
|
11
|
-
export declare function makeMap(str: string, expectsLowerCase?: boolean): (key: string) => boolean;
|
|
12
|
-
export declare const uniqueBy: <T, K>(array: T[], iteratee: (value: T) => K) => T[];
|
|
13
|
-
export declare const get: <T>(obj: any, path: string | string[]) => T | undefined;
|
|
14
|
-
export declare const set: (obj: any, path: string | string[], value: any) => void;
|
|
15
|
-
export declare function deepEqual(a: any, b: any): boolean;
|
|
16
|
-
export declare function deepArrayEqual(arr1: any[], arr2: any[]): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* TypeSafe version of Array.isArray
|
|
19
|
-
*/
|
|
20
|
-
export declare const isArray: (a: any) => a is any[] | readonly any[];
|
|
21
|
-
export declare function editSceneObject(scene: Scene, objectUuid: string, propertyPath: string[], value: any): void;
|
|
22
|
-
export declare function createHighlightMaterial(): MeshBasicMaterial;
|
|
23
|
-
export declare function animateHighlight(highlightMesh: Mesh, startTime: number): void;
|
|
24
|
-
export declare function stopHighlightAnimation(): void;
|
|
25
|
-
export declare function createHighlightMesh(object: TresObject): Mesh;
|
|
26
|
-
export declare function extractBindingPosition(binding: any): Vector3;
|
|
5
|
+
export * from './logger';
|
|
27
6
|
export declare function disposeMaterial(material: Material): void;
|
|
28
7
|
export declare function disposeObject3D(object: TresObject): void;
|
|
29
|
-
/**
|
|
30
|
-
* Like Array.filter, but modifies the array in place.
|
|
31
|
-
* @param array - Array to modify
|
|
32
|
-
* @param callbackFn - A function called for each element of the array. It should return a truthy value to keep the element in the array.
|
|
33
|
-
*/
|
|
34
|
-
export declare function filterInPlace<T>(array: T[], callbackFn: (element: T, index: number) => unknown): T[];
|
|
35
8
|
export declare function resolve(obj: Record<string, any>, key: string): {
|
|
36
9
|
target: Record<string, any>;
|
|
37
10
|
key: string;
|
|
@@ -40,11 +13,6 @@ export declare function attach(parent: TresInstance, child: TresInstance, type:
|
|
|
40
13
|
export declare function detach(parent: any, child: TresInstance, type: AttachType): void;
|
|
41
14
|
export declare function prepareTresInstance<T extends TresObject>(obj: T, state: Partial<LocalState>, context: TresContext): TresInstance;
|
|
42
15
|
export declare function invalidateInstance(instance: TresObject): void;
|
|
43
|
-
export declare function noop(fn: string): any;
|
|
44
|
-
export declare function setPixelRatio(renderer: {
|
|
45
|
-
setPixelRatio?: (dpr: number) => void;
|
|
46
|
-
getPixelRatio?: () => number;
|
|
47
|
-
}, systemDpr: number, userDpr?: number | [number, number]): void;
|
|
48
16
|
export declare function setPrimitiveObject(newObject: TresObject, primitive: TresPrimitive, setTarget: (object: TresObject) => void, nodeOpsFns: Pick<ReturnType<typeof nodeOps>, 'patchProp' | 'insert' | 'remove'>, context: TresContext): boolean;
|
|
49
17
|
export declare function unboxTresPrimitive<T>(maybePrimitive: T): T | TresInstance;
|
|
50
18
|
export declare function doRemoveDetach(node: TresObject, context: TresContext): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isHTMLTag: (key: string) => boolean;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { BufferGeometry, Camera, Color, ColorRepresentation, Fog, Group, Light, Material, Mesh, Object3D, OrthographicCamera, PerspectiveCamera, Scene, Layers } from 'three';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if a value is a Three.js Object3D
|
|
4
|
+
* @param value - The value to check
|
|
5
|
+
* @returns True if the value is a Three.js Object3D instance, false otherwise
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const value = new THREE.Object3D()
|
|
9
|
+
* if (isObject3D(value)) {
|
|
10
|
+
* // TypeScript knows value is Object3D here
|
|
11
|
+
* value.position // OK
|
|
12
|
+
* value.rotation // OK
|
|
13
|
+
* value.scale // OK
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const isObject3D: (value: unknown) => value is Object3D<import('three').Object3DEventMap>;
|
|
18
|
+
/**
|
|
19
|
+
* Type guard to check if a value is a Three.js Mesh
|
|
20
|
+
* @param value - The value to check
|
|
21
|
+
* @returns True if the value is a Three.js Mesh instance, false otherwise
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const value = new THREE.Mesh()
|
|
25
|
+
* if (isMesh(value)) {
|
|
26
|
+
* // TypeScript knows value is Mesh here
|
|
27
|
+
* value.geometry // OK
|
|
28
|
+
*/
|
|
29
|
+
export declare const isMesh: (value: unknown) => value is Mesh<BufferGeometry<import('three').NormalBufferAttributes>, Material | Material[], import('three').Object3DEventMap>;
|
|
30
|
+
/**
|
|
31
|
+
* Type guard to check if a value is a Three.js Camera
|
|
32
|
+
* @param value - The value to check
|
|
33
|
+
* @returns True if the value is a Three.js Camera instance, false otherwise
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const value = new THREE.PerspectiveCamera()
|
|
37
|
+
* if (isCamera(value)) {
|
|
38
|
+
* // TypeScript knows value is Camera here
|
|
39
|
+
* value.fov // OK
|
|
40
|
+
* value.near // OK
|
|
41
|
+
* value.far // OK
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare const isCamera: (value: unknown) => value is Camera;
|
|
46
|
+
/**
|
|
47
|
+
* Type guard to check if a value is a Three.js OrthographicCamera
|
|
48
|
+
* @param value - The value to check
|
|
49
|
+
* @returns True if the value is a Three.js OrthographicCamera instance, false otherwise
|
|
50
|
+
*/
|
|
51
|
+
export declare const isOrthographicCamera: (value: unknown) => value is OrthographicCamera;
|
|
52
|
+
/**
|
|
53
|
+
* Type guard to check if a value is a Three.js PerspectiveCamera
|
|
54
|
+
* @param value - The value to check
|
|
55
|
+
* @returns True if the value is a Three.js PerspectiveCamera instance, false otherwise
|
|
56
|
+
*/
|
|
57
|
+
export declare const isPerspectiveCamera: (value: unknown) => value is PerspectiveCamera;
|
|
58
|
+
/**
|
|
59
|
+
* Type guard to check if a value is a Three.js Color
|
|
60
|
+
* @param value - The value to check
|
|
61
|
+
* @returns True if the value is a Three.js Color instance, false otherwise
|
|
62
|
+
*/
|
|
63
|
+
export declare const isColor: (value: unknown) => value is Color;
|
|
64
|
+
/**
|
|
65
|
+
* Type guard to check if a value is a Three.js ColorRepresentation
|
|
66
|
+
* @param value - The value to check
|
|
67
|
+
* @returns True if the value is a Three.js ColorRepresentation instance, false otherwise
|
|
68
|
+
*/
|
|
69
|
+
export declare const isColorRepresentation: (value: unknown) => value is ColorRepresentation;
|
|
70
|
+
/**
|
|
71
|
+
* Type guard to check if a value is a Three.js Layers
|
|
72
|
+
* @param value - The value to check
|
|
73
|
+
* @returns True if the value is a Three.js Layers instance, false otherwise
|
|
74
|
+
*/
|
|
75
|
+
export declare const isLayers: (value: unknown) => value is Layers;
|
|
76
|
+
/**
|
|
77
|
+
* Type guard to check if a value is a Three.js BufferGeometry
|
|
78
|
+
* @param value - The value to check
|
|
79
|
+
* @returns True if the value is a Three.js BufferGeometry instance, false otherwise
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* const value = new THREE.BufferGeometry()
|
|
83
|
+
* if (isBufferGeometry(value)) {
|
|
84
|
+
* // TypeScript knows value is BufferGeometry here
|
|
85
|
+
* value.attributes // OK
|
|
86
|
+
* value.index // OK
|
|
87
|
+
* value.computeVertexNormals() // OK
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare const isBufferGeometry: (value: unknown) => value is BufferGeometry<import('three').NormalBufferAttributes>;
|
|
92
|
+
/**
|
|
93
|
+
* Type guard to check if a value is a Three.js Material
|
|
94
|
+
* @param value - The value to check
|
|
95
|
+
* @returns True if the value is a Three.js Material instance, false otherwise
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* const value = new THREE.MeshStandardMaterial()
|
|
99
|
+
* if (isMaterial(value)) {
|
|
100
|
+
* // TypeScript knows value is Material here
|
|
101
|
+
* value.color // OK
|
|
102
|
+
* value.metalness // OK
|
|
103
|
+
* value.roughness // OK
|
|
104
|
+
* }
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export declare const isMaterial: (value: unknown) => value is Material;
|
|
108
|
+
/**
|
|
109
|
+
* Type guard to check if a value is a Three.js Light
|
|
110
|
+
* @param value - The value to check
|
|
111
|
+
* @returns True if the value is a Three.js Light instance, false otherwise
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* const value = new THREE.DirectionalLight()
|
|
115
|
+
* if (isLight(value)) {
|
|
116
|
+
* // TypeScript knows value is Light here
|
|
117
|
+
* value.intensity // OK
|
|
118
|
+
* value.color // OK
|
|
119
|
+
* value.position // OK
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
export declare const isLight: (value: unknown) => value is Light<import('three').LightShadow<Camera> | undefined>;
|
|
124
|
+
/**
|
|
125
|
+
* Type guard to check if a value is a Three.js Fog
|
|
126
|
+
* @param value - The value to check
|
|
127
|
+
* @returns True if the value is a Three.js Fog instance, false otherwise
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* const value = new THREE.Fog(0x000000, 1, 1000)
|
|
131
|
+
* if (isFog(value)) {
|
|
132
|
+
* // TypeScript knows value is Fog here
|
|
133
|
+
* value.color // OK
|
|
134
|
+
* value.near // OK
|
|
135
|
+
* value.far // OK
|
|
136
|
+
* }
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export declare const isFog: (value: unknown) => value is Fog;
|
|
140
|
+
/**
|
|
141
|
+
* Type guard to check if a value is a Three.js Scene
|
|
142
|
+
* @param value - The value to check
|
|
143
|
+
* @returns True if the value is a Three.js Scene instance, false otherwise
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* const value = new THREE.Scene()
|
|
147
|
+
* if (isScene(value)) {
|
|
148
|
+
* // TypeScript knows value is Scene here
|
|
149
|
+
* value.children // OK
|
|
150
|
+
* value.add(new THREE.Object3D()) // OK
|
|
151
|
+
* value.remove(new THREE.Object3D()) // OK
|
|
152
|
+
* }
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
export declare const isScene: (value: unknown) => value is Scene;
|
|
156
|
+
/**
|
|
157
|
+
* Type guard to check if a value is a Three.js Group
|
|
158
|
+
* @param value - The value to check
|
|
159
|
+
* @returns True if the value is a Three.js Group instance, false otherwise
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
export declare const isGroup: (value: unknown) => value is Group<import('three').Object3DEventMap>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { TresCamera, TresInstance, TresObject, TresPrimitive } from 'src/types';
|
|
2
|
+
interface VectorLike {
|
|
3
|
+
set: (...args: any[]) => void;
|
|
4
|
+
constructor?: (...args: any[]) => any;
|
|
5
|
+
}
|
|
6
|
+
export declare const isVectorLike: (value: unknown) => value is VectorLike;
|
|
7
|
+
interface Copyable {
|
|
8
|
+
copy: (...args: any[]) => void;
|
|
9
|
+
constructor?: (...args: any[]) => any;
|
|
10
|
+
}
|
|
11
|
+
export declare const isCopyable: (value: unknown) => value is Copyable;
|
|
12
|
+
interface ClassInstance {
|
|
13
|
+
constructor?: (...args: any[]) => any;
|
|
14
|
+
}
|
|
15
|
+
export declare const isClassInstance: (object: unknown) => object is ClassInstance;
|
|
16
|
+
/**
|
|
17
|
+
* Type guard to check if a value is a TresCamera
|
|
18
|
+
* @param value - The value to check
|
|
19
|
+
* @returns True if the value is a TresCamera instance, false otherwise
|
|
20
|
+
*/
|
|
21
|
+
export declare const isTresCamera: (value: unknown) => value is TresCamera;
|
|
22
|
+
/**
|
|
23
|
+
* Type guard to check if a value is a TresObject
|
|
24
|
+
* @param value - The value to check
|
|
25
|
+
* @returns True if the value is a TresObject (Object3D | BufferGeometry | Material | Fog), false otherwise
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const value = new THREE.Mesh()
|
|
29
|
+
* if (isTresObject(value)) {
|
|
30
|
+
* // TypeScript knows value is TresObject here
|
|
31
|
+
* // You can use common properties and methods shared by all TresObjects
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
* @remarks
|
|
35
|
+
* TresObject is a union type that represents the core Three.js objects that can be used in TresJS.
|
|
36
|
+
* This includes Object3D, BufferGeometry, Material, and Fog instances.
|
|
37
|
+
*/
|
|
38
|
+
export declare const isTresObject: (value: unknown) => value is TresObject;
|
|
39
|
+
/**
|
|
40
|
+
* Type guard to check if a value is a TresPrimitive
|
|
41
|
+
* @param value - The value to check
|
|
42
|
+
* @returns True if the value is a TresPrimitive instance, false otherwise
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const value = { isPrimitive: true }
|
|
46
|
+
* if (isTresPrimitive(value)) {
|
|
47
|
+
* // TypeScript knows value is TresPrimitive here
|
|
48
|
+
* // You can use properties and methods specific to TresPrimitives
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
* @remarks
|
|
52
|
+
* TresPrimitive is a special type in TresJS that represents primitive objects
|
|
53
|
+
* that can be used directly in the scene without needing to be wrapped in a Three.js object.
|
|
54
|
+
*/
|
|
55
|
+
export declare const isTresPrimitive: (value: unknown) => value is TresPrimitive;
|
|
56
|
+
/**
|
|
57
|
+
* Type guard to check if a value is a TresInstance (has __tres property)
|
|
58
|
+
* @param value - The value to check
|
|
59
|
+
* @returns True if the value is a TresInstance (has __tres property), false otherwise
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* const value = new THREE.Mesh()
|
|
63
|
+
* if (isTresInstance(value)) {
|
|
64
|
+
* // TypeScript knows value is TresInstance here
|
|
65
|
+
* // You can safely access value.__tres
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare const isTresInstance: (value: unknown) => value is TresInstance;
|
|
70
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isBoolean, isEqual, isFunction, isNumber, isObject, isString, isUndefined } from 'radashi';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createTypeGuard: <T>(property: keyof T) => (value: unknown) => value is T;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger utility for TresJS
|
|
3
|
+
* @module logger
|
|
4
|
+
*/
|
|
5
|
+
export declare const isProd: boolean;
|
|
6
|
+
type OneOrMore<T> = {
|
|
7
|
+
0: T;
|
|
8
|
+
} & Array<T>;
|
|
9
|
+
/**
|
|
10
|
+
* Logs an error message with the TresJS prefix
|
|
11
|
+
* @param args - Arguments to log
|
|
12
|
+
*/
|
|
13
|
+
export declare function logError(...args: OneOrMore<any>): void;
|
|
14
|
+
/**
|
|
15
|
+
* Logs a warning message with the TresJS prefix
|
|
16
|
+
* @param args - Arguments to log
|
|
17
|
+
*/
|
|
18
|
+
export declare function logWarning(...args: OneOrMore<any>): void;
|
|
19
|
+
/**
|
|
20
|
+
* Logs a message with the TresJS prefix (only in development mode)
|
|
21
|
+
* @param name - Name of the message
|
|
22
|
+
* @param value - Value to log
|
|
23
|
+
*/
|
|
24
|
+
export declare function logMessage(name: string, value: any): void;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Make a map and return a function for checking if a key
|
|
3
|
+
* is in that map.
|
|
4
|
+
* IMPORTANT: all calls of this function must be prefixed with
|
|
5
|
+
* \/\*#\_\_PURE\_\_\*\/
|
|
6
|
+
* So that rollup can tree-shake them if necessary.
|
|
7
|
+
*/
|
|
8
|
+
/*! #__NO_SIDE_EFFECTS__ */
|
|
9
|
+
export declare function makeMap(str: string): (key: string) => boolean;
|
package/dist/src/utils/perf.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Scene } from 'three';
|
|
2
2
|
import { TresObject } from './../types';
|
|
3
3
|
export declare function calculateMemoryUsage(object: TresObject | Scene): number;
|
|
4
|
+
export declare function boundedPush<T>(arr: T[], value: T, max: number): void;
|
|
4
5
|
export declare function bytesToKB(bytes: number): string;
|
|
5
6
|
export declare function bytesToMB(bytes: number): string;
|
|
6
7
|
export declare function bytesToGB(bytes: number): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PointerEvent } from '@pmndrs/pointer-events';
|
|
2
|
+
export declare const supportedPointerEvents: readonly ["onClick", "onContextmenu", "onPointermove", "onPointerenter", "onPointerleave", "onPointerover", "onPointerout", "onDblclick", "onPointerdown", "onPointerup", "onPointercancel", "onLostpointercapture", "onWheel"];
|
|
3
|
+
export type SupportedVuePointerEvent = typeof supportedPointerEvents[number];
|
|
4
|
+
export type TresPointerEventName = 'click' | 'contextmenu' | 'pointermove' | 'pointerenter' | 'pointerleave' | 'pointerover' | 'pointerout' | 'dblclick' | 'pointerdown' | 'pointerup' | 'pointercancel' | 'lostpointercapture' | 'wheel';
|
|
5
|
+
export declare const pointerEventsMapVueToThree: Record<SupportedVuePointerEvent, TresPointerEventName>;
|
|
6
|
+
export declare const isSupportedPointerEvent: (event: string) => event is SupportedVuePointerEvent;
|
|
7
|
+
export type TresPointerEvent = PointerEvent<MouseEvent>;
|
|
8
|
+
export type PointerEventHandlers = {
|
|
9
|
+
[key in SupportedVuePointerEvent]: (event: TresPointerEvent) => void;
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { camel } from 'radashi';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Object3D } from 'three';
|
|
2
|
+
/**
|
|
3
|
+
* Recursively searches for an Object3D with the specified UUID within a Three.js scene graph.
|
|
4
|
+
*
|
|
5
|
+
* @param node - The root Object3D to start searching from
|
|
6
|
+
* @param uuid - The unique identifier of the object to find
|
|
7
|
+
* @returns The Object3D with the matching UUID, or undefined if not found
|
|
8
|
+
*/
|
|
9
|
+
export declare const getObjectByUuid: (node: Object3D, uuid: string) => Object3D | undefined;
|