@tresjs/core 2.4.2 → 3.0.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/components/TresCanvas.vue.d.ts +180 -98
- package/dist/composables/index.d.ts +2 -2
- package/dist/composables/useCamera/index.d.ts +3205 -98
- package/dist/composables/usePointerEventHandler/index.d.ts +7 -2
- package/dist/composables/useRaycaster/index.d.ts +4 -3
- package/dist/composables/useRenderLoop/index.d.ts +1 -1
- package/dist/composables/useRenderer/index.d.ts +25 -31
- package/dist/composables/useTresContextProvider/index.d.ts +27 -0
- package/dist/core/nodeOps.d.ts +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/tres.js +459 -496
- package/dist/tres.umd.cjs +2 -3
- package/dist/types/index.d.ts +13 -4
- package/dist/utils/index.d.ts +2 -0
- package/package.json +14 -14
- package/dist/components/TresScene.vue.d.ts +0 -128
- package/dist/composables/useTres/index.d.ts +0 -142
- package/dist/keys.d.ts +0 -6
- package/dist/utils/test-utils.d.ts +0 -1
|
@@ -1,13 +1,18 @@
|
|
|
1
|
+
import type { TresContext } from '../useTresContextProvider';
|
|
1
2
|
import type { Intersection, Event, Object3D } from 'three';
|
|
3
|
+
import { TresScene } from 'src/types';
|
|
2
4
|
type CallbackFn = (intersection: Intersection<Object3D<Event>>, event: PointerEvent) => void;
|
|
3
5
|
type CallbackFnPointerLeave = (object: Object3D<Event>, event: PointerEvent) => void;
|
|
4
|
-
type EventProps = {
|
|
6
|
+
export type EventProps = {
|
|
5
7
|
onClick?: CallbackFn;
|
|
6
8
|
onPointerEnter?: CallbackFn;
|
|
7
9
|
onPointerMove?: CallbackFn;
|
|
8
10
|
onPointerLeave?: CallbackFnPointerLeave;
|
|
9
11
|
};
|
|
10
|
-
export declare const usePointerEventHandler: (
|
|
12
|
+
export declare const usePointerEventHandler: ({ scene, contextParts }: {
|
|
13
|
+
scene: TresScene;
|
|
14
|
+
contextParts: Pick<TresContext, 'renderer' | 'camera' | 'raycaster'>;
|
|
15
|
+
}) => {
|
|
11
16
|
registerObject: (object: Object3D & EventProps) => void;
|
|
12
17
|
deregisterObject: (object: Object3D) => void;
|
|
13
18
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Object3D } from 'three';
|
|
1
|
+
import { type Intersection, Object3D } from 'three';
|
|
2
2
|
import { Ref } from 'vue';
|
|
3
|
-
|
|
3
|
+
import { type TresContext } from '../useTresContextProvider';
|
|
4
|
+
export type Intersects = Intersection<THREE.Object3D<THREE.Event>>[];
|
|
4
5
|
interface PointerMoveEventPayload {
|
|
5
6
|
intersects?: Intersects;
|
|
6
7
|
event: PointerEvent;
|
|
@@ -9,7 +10,7 @@ interface PointerClickEventPayload {
|
|
|
9
10
|
intersects: Intersects;
|
|
10
11
|
event: PointerEvent;
|
|
11
12
|
}
|
|
12
|
-
export declare const useRaycaster: (objects: Ref<THREE.Object3D[]>) => {
|
|
13
|
+
export declare const useRaycaster: (objects: Ref<THREE.Object3D[]>, { renderer, camera, raycaster }: Pick<TresContext, 'renderer' | 'camera' | 'raycaster'>) => {
|
|
13
14
|
intersects: import("vue").ComputedRef<Intersects>;
|
|
14
15
|
onClick: (fn: (value: PointerClickEventPayload) => void) => () => void;
|
|
15
16
|
onPointerMove: (fn: (value: PointerMoveEventPayload) => void) => () => void;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { WebGLRendererParameters, WebGLRenderer, ShadowMapType, ColorSpace } from 'three';
|
|
3
|
-
import type { ToneMapping } from 'three';
|
|
4
|
-
import { TresColor } from '../../types';
|
|
1
|
+
import { WebGLRenderer } from 'three';
|
|
5
2
|
import { RendererPresetsType } from './const';
|
|
6
|
-
|
|
3
|
+
import { type MaybeRef } from 'vue';
|
|
4
|
+
import { type MaybeRefOrGetter } from '@vueuse/core';
|
|
5
|
+
import { TresColor } from '../../types';
|
|
6
|
+
import type { Scene, ToneMapping } from 'three';
|
|
7
|
+
import type { TresContext } from '../useTresContextProvider';
|
|
8
|
+
import type { ColorSpace, ShadowMapType, WebGLRendererParameters } from 'three';
|
|
9
|
+
type TransformToMaybeRefOrGetter<T> = {
|
|
10
|
+
[K in keyof T]: MaybeRefOrGetter<T[K]> | MaybeRefOrGetter<T[K]>;
|
|
11
|
+
};
|
|
12
|
+
export interface UseRendererOptions extends TransformToMaybeRefOrGetter<WebGLRendererParameters> {
|
|
7
13
|
/**
|
|
8
14
|
* Enable shadows in the Renderer
|
|
9
15
|
*
|
|
@@ -42,7 +48,10 @@ export interface UseRendererOptions extends WebGLRendererParameters {
|
|
|
42
48
|
outputColorSpace?: MaybeRefOrGetter<ColorSpace>;
|
|
43
49
|
/**
|
|
44
50
|
* Defines the tone mapping used by the renderer.
|
|
45
|
-
* Can be NoToneMapping, LinearToneMapping,
|
|
51
|
+
* Can be NoToneMapping, LinearToneMapping,
|
|
52
|
+
* ReinhardToneMapping, Uncharted2ToneMapping,
|
|
53
|
+
* CineonToneMapping, ACESFilmicToneMapping,
|
|
54
|
+
* CustomToneMapping
|
|
46
55
|
*
|
|
47
56
|
* @default NoToneMapping
|
|
48
57
|
*/
|
|
@@ -53,25 +62,6 @@ export interface UseRendererOptions extends WebGLRendererParameters {
|
|
|
53
62
|
* @default 1
|
|
54
63
|
*/
|
|
55
64
|
toneMappingExposure?: MaybeRefOrGetter<number>;
|
|
56
|
-
/**
|
|
57
|
-
* The context used by the renderer.
|
|
58
|
-
*
|
|
59
|
-
* @default undefined
|
|
60
|
-
*/
|
|
61
|
-
context?: WebGLRenderingContext | undefined;
|
|
62
|
-
/**
|
|
63
|
-
* Provides a hint to the user agent indicating what configuration of GPU is suitable for this WebGL context.
|
|
64
|
-
* Can be "high-performance", "low-power" or "default".
|
|
65
|
-
*
|
|
66
|
-
* @default "default"
|
|
67
|
-
*/
|
|
68
|
-
powerPreference?: 'high-performance' | 'low-power' | 'default';
|
|
69
|
-
/**
|
|
70
|
-
* Whether to preserve the buffers until manually cleared or overwritten.
|
|
71
|
-
*
|
|
72
|
-
* @default false
|
|
73
|
-
*/
|
|
74
|
-
preserveDrawingBuffer?: boolean;
|
|
75
65
|
/**
|
|
76
66
|
* The color value to use when clearing the canvas.
|
|
77
67
|
*
|
|
@@ -79,7 +69,7 @@ export interface UseRendererOptions extends WebGLRendererParameters {
|
|
|
79
69
|
*/
|
|
80
70
|
clearColor?: MaybeRefOrGetter<TresColor>;
|
|
81
71
|
windowSize?: MaybeRefOrGetter<boolean | string>;
|
|
82
|
-
preset?: RendererPresetsType
|
|
72
|
+
preset?: MaybeRefOrGetter<RendererPresetsType>;
|
|
83
73
|
}
|
|
84
74
|
/**
|
|
85
75
|
* Reactive Three.js WebGLRenderer instance
|
|
@@ -87,10 +77,14 @@ export interface UseRendererOptions extends WebGLRendererParameters {
|
|
|
87
77
|
* @param canvas
|
|
88
78
|
* @param {UseRendererOptions} [options]
|
|
89
79
|
*/
|
|
90
|
-
export declare function useRenderer(options:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
80
|
+
export declare function useRenderer({ scene, canvas, options, disableRender, contextParts: { sizes, camera }, }: {
|
|
81
|
+
canvas: MaybeRef<HTMLCanvasElement>;
|
|
82
|
+
scene: Scene;
|
|
83
|
+
options: UseRendererOptions;
|
|
84
|
+
contextParts: Pick<TresContext, 'sizes' | 'camera'>;
|
|
85
|
+
disableRender: MaybeRefOrGetter<boolean>;
|
|
86
|
+
}): {
|
|
87
|
+
renderer: import("vue").ShallowRef<WebGLRenderer>;
|
|
95
88
|
};
|
|
96
89
|
export type UseRendererReturn = ReturnType<typeof useRenderer>;
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Camera, Raycaster, Scene, WebGLRenderer } from 'three';
|
|
2
|
+
import { UseRendererOptions } from '../useRenderer';
|
|
3
|
+
import type { ComputedRef, DeepReadonly, MaybeRef, MaybeRefOrGetter, Ref, ShallowRef } from 'vue';
|
|
4
|
+
export type TresContext = {
|
|
5
|
+
scene: ShallowRef<Scene>;
|
|
6
|
+
camera: ComputedRef<Camera | undefined>;
|
|
7
|
+
cameras: DeepReadonly<Ref<Camera[]>>;
|
|
8
|
+
renderer: ShallowRef<WebGLRenderer>;
|
|
9
|
+
raycaster: ShallowRef<Raycaster>;
|
|
10
|
+
addCamera: (camera: Camera) => void;
|
|
11
|
+
removeCamera: (camera: Camera) => void;
|
|
12
|
+
setCameraActive: (cameraOrUuid: Camera | string) => void;
|
|
13
|
+
sizes: {
|
|
14
|
+
height: Ref<number>;
|
|
15
|
+
width: Ref<number>;
|
|
16
|
+
aspectRatio: ComputedRef<number>;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare function useTresContextProvider({ scene, canvas, windowSize, disableRender, rendererOptions }: {
|
|
20
|
+
scene: Scene;
|
|
21
|
+
canvas: MaybeRef<HTMLCanvasElement>;
|
|
22
|
+
windowSize: MaybeRefOrGetter<boolean>;
|
|
23
|
+
disableRender: MaybeRefOrGetter<boolean>;
|
|
24
|
+
rendererOptions: UseRendererOptions;
|
|
25
|
+
}): TresContext;
|
|
26
|
+
export declare function useTresContext(): TresContext;
|
|
27
|
+
export declare const useTres: typeof useTresContext;
|
package/dist/core/nodeOps.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from './composables';
|
|
|
3
3
|
export * from './core/catalogue';
|
|
4
4
|
export * from './components';
|
|
5
5
|
export * from './types';
|
|
6
|
+
import { useTresContext, type TresContext } from './composables';
|
|
6
7
|
import { normalizeColor, normalizeVectorFlexibleParam } from './utils/normalize';
|
|
7
8
|
import templateCompilerOptions from './utils/template-compiler-options';
|
|
8
9
|
export interface TresOptions {
|
|
@@ -14,4 +15,4 @@ export interface TresPlugin {
|
|
|
14
15
|
}
|
|
15
16
|
declare const plugin: TresPlugin;
|
|
16
17
|
export default plugin;
|
|
17
|
-
export { normalizeColor, normalizeVectorFlexibleParam, templateCompilerOptions };
|
|
18
|
+
export { TresContext, useTresContext, normalizeColor, normalizeVectorFlexibleParam, templateCompilerOptions };
|