@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.
- package/dist/index.d.ts +3 -0
- package/dist/src/components/TresCanvas.vue.d.ts +21 -58
- package/dist/src/components/index.d.ts +0 -1
- package/dist/src/composables/index.d.ts +8 -5
- package/dist/src/composables/useCamera/index.d.ts +4377 -488
- package/dist/src/composables/useLoader/component.vue.d.ts +25 -0
- package/dist/src/composables/useLoader/index.d.ts +0 -1
- package/dist/src/composables/useLoop/index.d.ts +1 -2
- package/dist/src/composables/useRaycaster/index.d.ts +1 -2
- package/dist/src/composables/useRenderLoop/index.d.ts +0 -1
- package/dist/src/composables/useRenderer/index.d.ts +3 -5
- package/dist/src/composables/useSeek/index.d.ts +0 -1
- package/dist/src/composables/useSizes/index.d.ts +2 -3
- package/dist/src/composables/useTexture/component.vue.d.ts +28 -0
- package/dist/src/composables/useTexture/index.d.ts +0 -1
- package/dist/src/composables/useTresContextProvider/index.d.ts +4 -6
- package/dist/src/composables/useTresEventManager/index.d.ts +1 -2
- package/dist/src/composables/useTresReady/createReadyEventHook/index.d.ts +0 -1
- package/dist/src/composables/useTresReady/index.d.ts +0 -1
- package/dist/src/core/catalogue.d.ts +1 -2
- package/dist/src/core/loop.d.ts +2 -3
- package/dist/src/core/nodeOps.d.ts +1 -2
- package/dist/src/devtools/plugin.d.ts +0 -1
- package/dist/src/directives/index.d.ts +3 -4
- package/dist/src/directives/vDistanceTo.d.ts +0 -1
- package/dist/src/directives/vLightHelper.d.ts +0 -1
- package/dist/src/directives/vLog.d.ts +0 -1
- package/dist/src/index.d.ts +5 -6
- package/dist/src/types/index.d.ts +14 -9
- package/dist/src/utils/createPriorityEventHook.d.ts +0 -1
- package/dist/src/utils/index.d.ts +2 -3
- package/dist/src/utils/is.d.ts +1 -2
- package/dist/src/utils/normalize.d.ts +0 -1
- package/dist/src/utils/perf.d.ts +0 -1
- package/dist/src/utils/test-utils.d.ts +0 -1
- package/dist/tres.js +935 -900
- package/dist/tres.umd.cjs +2 -2
- 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,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
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,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,11 +1,10 @@
|
|
|
1
1
|
import { Camera, WebGLRenderer, Raycaster } from 'three';
|
|
2
2
|
import { ComputedRef, DeepReadonly, MaybeRef, MaybeRefOrGetter, Ref, ShallowRef } from 'vue';
|
|
3
|
-
import {
|
|
3
|
+
import { RendererLoop } from '../../core/loop';
|
|
4
4
|
import { EmitEventFn, TresControl, TresObject, TresScene } from '../../types';
|
|
5
|
-
import {
|
|
5
|
+
import { UseRendererOptions } from '../useRenderer';
|
|
6
6
|
import { SizesType } from '../useSizes';
|
|
7
|
-
import {
|
|
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,
|
|
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,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;
|
package/dist/src/core/loop.d.ts
CHANGED
|
@@ -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,5 +1,4 @@
|
|
|
1
|
-
import { vLog } from './vLog';
|
|
2
|
-
import { vLightHelper } from './vLightHelper';
|
|
3
1
|
import { vDistanceTo } from './vDistanceTo';
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { vLightHelper } from './vLightHelper';
|
|
3
|
+
import { vLog } from './vLog';
|
|
4
|
+
export { vDistanceTo, vLightHelper, vLog };
|
package/dist/src/index.d.ts
CHANGED
|
@@ -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
|
-
|
|
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,
|
|
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
|
|
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
|
-
|
|
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
|
|
139
|
+
set(...args: number[] | [THREE.ColorRepresentation]): any;
|
|
135
140
|
}
|
|
136
141
|
interface VectorRepresentation extends MathRepresentation {
|
|
137
|
-
setScalar
|
|
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
|
|
165
|
-
children?: VNode
|
|
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<
|
|
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,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;
|
package/dist/src/utils/is.d.ts
CHANGED
|
@@ -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
|
|
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;
|
package/dist/src/utils/perf.d.ts
CHANGED
|
@@ -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;
|