@tresjs/core 5.0.0-next.0 → 5.0.0-next.2
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 +66 -64
- package/dist/src/composables/index.d.ts +4 -9
- package/dist/src/composables/useCamera/index.d.ts +42 -8555
- package/dist/src/composables/useEventManager/index.d.ts +10 -0
- package/dist/src/composables/useLoader/index.d.ts +1 -0
- package/dist/src/composables/useRenderer/useRendererManager.d.ts +187 -0
- package/dist/src/composables/useTres/index.d.ts +37 -0
- package/dist/src/composables/useTresContextProvider/index.d.ts +10 -60
- package/dist/src/core/loop.d.ts +0 -2
- package/dist/src/devtools/inspectorHandlers.d.ts +60 -0
- package/dist/src/devtools/plugin.d.ts +3 -7
- package/dist/src/devtools/setupDevtools.d.ts +13 -1
- package/dist/src/devtools/types.d.ts +90 -0
- package/dist/src/types/index.d.ts +3 -69
- package/dist/src/utils/createPriorityEventHook.d.ts +1 -1
- package/dist/src/utils/is.d.ts +47 -3
- package/dist/src/utils/pointerEvents.d.ts +10 -0
- package/dist/tres.js +2582 -1998
- package/package.json +6 -3
- package/dist/src/composables/useRaycaster/index.d.ts +0 -16
- 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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tresjs/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.0.0-next.
|
|
4
|
+
"version": "5.0.0-next.2",
|
|
5
5
|
"packageManager": "pnpm@10.6.3",
|
|
6
6
|
"description": "Declarative ThreeJS using Vue Components",
|
|
7
7
|
"author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)",
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"coverage": "vitest run --coverage",
|
|
59
59
|
"lint": "eslint .",
|
|
60
60
|
"lint:fix": "eslint . --fix",
|
|
61
|
+
"typecheck": "vue-tsc --noEmit",
|
|
61
62
|
"docs:dev": "vitepress dev docs",
|
|
62
63
|
"docs:build": "vitepress build docs",
|
|
63
64
|
"docs:serve": "vitepress serve docs",
|
|
@@ -70,13 +71,14 @@
|
|
|
70
71
|
},
|
|
71
72
|
"dependencies": {
|
|
72
73
|
"@alvarosabu/utils": "^3.2.0",
|
|
74
|
+
"@pmndrs/pointer-events": "^6.6.17",
|
|
73
75
|
"@vue/devtools-api": "^7.7.2",
|
|
74
76
|
"@vueuse/core": "^12.5.0"
|
|
75
77
|
},
|
|
76
78
|
"devDependencies": {
|
|
77
79
|
"@release-it/conventional-changelog": "^10.0.0",
|
|
78
80
|
"@stackblitz/sdk": "^1.11.0",
|
|
79
|
-
"@tresjs/cientos": "
|
|
81
|
+
"@tresjs/cientos": "5.0.0-next.0",
|
|
80
82
|
"@tresjs/eslint-config": "^1.4.0",
|
|
81
83
|
"@types/three": "^0.173.0",
|
|
82
84
|
"@typescript-eslint/eslint-plugin": "^8.23.0",
|
|
@@ -112,6 +114,7 @@
|
|
|
112
114
|
"vitepress": "1.6.3",
|
|
113
115
|
"vitest": "3.0.5",
|
|
114
116
|
"vue": "3.5.13",
|
|
115
|
-
"vue-demi": "^0.14.10"
|
|
117
|
+
"vue-demi": "^0.14.10",
|
|
118
|
+
"vue-tsc": "^2.2.0"
|
|
116
119
|
}
|
|
117
120
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { TresEvent, TresInstance } from 'src/types';
|
|
2
|
-
import { Intersection, Object3D, Object3DEventMap } from 'three';
|
|
3
|
-
import { ShallowRef } from 'vue';
|
|
4
|
-
import { TresContext } from '../useTresContextProvider';
|
|
5
|
-
export declare const useRaycaster: (objectsWithEvents: ShallowRef<TresInstance[]>, ctx: TresContext) => {
|
|
6
|
-
intersects: ShallowRef<Intersection<Object3D<Object3DEventMap>>[]>;
|
|
7
|
-
onClick: (fn: (value: TresEvent) => void) => () => void;
|
|
8
|
-
onDblClick: (fn: (value: TresEvent) => void) => () => void;
|
|
9
|
-
onContextMenu: (fn: (value: TresEvent) => void) => () => void;
|
|
10
|
-
onPointerMove: (fn: (value: TresEvent) => void) => () => void;
|
|
11
|
-
onPointerUp: (fn: (value: TresEvent) => void) => () => void;
|
|
12
|
-
onPointerDown: (fn: (value: TresEvent) => void) => () => void;
|
|
13
|
-
onPointerMissed: (fn: (value: TresEvent) => void) => () => void;
|
|
14
|
-
onWheel: (fn: (value: TresEvent) => void) => () => void;
|
|
15
|
-
forceUpdate: () => void;
|
|
16
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export declare const rendererPresets: {
|
|
2
|
-
realistic: {
|
|
3
|
-
shadows: boolean;
|
|
4
|
-
physicallyCorrectLights: boolean;
|
|
5
|
-
outputColorSpace: "srgb";
|
|
6
|
-
toneMapping: 4;
|
|
7
|
-
toneMappingExposure: number;
|
|
8
|
-
shadowMap: {
|
|
9
|
-
enabled: boolean;
|
|
10
|
-
type: 2;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
flat: {
|
|
14
|
-
toneMapping: 0;
|
|
15
|
-
toneMappingExposure: number;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export type RendererPresetsType = keyof typeof rendererPresets;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { ColorSpace, Scene, ShadowMapType, ToneMapping, WebGLRendererParameters, WebGLRenderer } from 'three';
|
|
2
|
-
import { EmitEventFn, TresColor } from '../../types';
|
|
3
|
-
import { TresContext } from '../useTresContextProvider';
|
|
4
|
-
import { RendererPresetsType } from './const';
|
|
5
|
-
import { MaybeRefOrGetter } from '@vueuse/core';
|
|
6
|
-
import { MaybeRef } from 'vue';
|
|
7
|
-
type TransformToMaybeRefOrGetter<T> = {
|
|
8
|
-
[K in keyof T]: MaybeRefOrGetter<T[K]> | MaybeRefOrGetter<T[K]>;
|
|
9
|
-
};
|
|
10
|
-
export interface UseRendererOptions extends TransformToMaybeRefOrGetter<WebGLRendererParameters> {
|
|
11
|
-
/**
|
|
12
|
-
* Enable shadows in the Renderer
|
|
13
|
-
*
|
|
14
|
-
* @default false
|
|
15
|
-
*/
|
|
16
|
-
shadows?: MaybeRefOrGetter<boolean>;
|
|
17
|
-
/**
|
|
18
|
-
* Set the shadow map type
|
|
19
|
-
* Can be PCFShadowMap, PCFSoftShadowMap, BasicShadowMap, VSMShadowMap
|
|
20
|
-
* [see](https://threejs.org/docs/?q=we#api/en/constants/Renderer)
|
|
21
|
-
*
|
|
22
|
-
* @default PCFSoftShadowMap
|
|
23
|
-
*/
|
|
24
|
-
shadowMapType?: MaybeRefOrGetter<ShadowMapType>;
|
|
25
|
-
/**
|
|
26
|
-
* Whether to use physically correct lighting mode.
|
|
27
|
-
* See the [lights / physical example](https://threejs.org/examples/#webgl_lights_physical).
|
|
28
|
-
*
|
|
29
|
-
* @default false
|
|
30
|
-
* @deprecated Use {@link WebGLRenderer.useLegacyLights useLegacyLights} instead.
|
|
31
|
-
*/
|
|
32
|
-
physicallyCorrectLights?: MaybeRefOrGetter<boolean>;
|
|
33
|
-
/**
|
|
34
|
-
* Whether to use legacy lighting mode.
|
|
35
|
-
*
|
|
36
|
-
* @type {MaybeRefOrGetter<boolean>}
|
|
37
|
-
* @memberof UseRendererOptions
|
|
38
|
-
*/
|
|
39
|
-
useLegacyLights?: MaybeRefOrGetter<boolean>;
|
|
40
|
-
/**
|
|
41
|
-
* Defines the output encoding of the renderer.
|
|
42
|
-
* Can be LinearSRGBColorSpace, SRGBColorSpace
|
|
43
|
-
*
|
|
44
|
-
* @default LinearSRGBColorSpace
|
|
45
|
-
*/
|
|
46
|
-
outputColorSpace?: MaybeRefOrGetter<ColorSpace>;
|
|
47
|
-
/**
|
|
48
|
-
* Defines the tone mapping used by the renderer.
|
|
49
|
-
* Can be NoToneMapping, LinearToneMapping,
|
|
50
|
-
* ReinhardToneMapping, Uncharted2ToneMapping,
|
|
51
|
-
* CineonToneMapping, ACESFilmicToneMapping,
|
|
52
|
-
* CustomToneMapping
|
|
53
|
-
*
|
|
54
|
-
* @default ACESFilmicToneMapping
|
|
55
|
-
*/
|
|
56
|
-
toneMapping?: MaybeRefOrGetter<ToneMapping>;
|
|
57
|
-
/**
|
|
58
|
-
* Defines the tone mapping exposure used by the renderer.
|
|
59
|
-
*
|
|
60
|
-
* @default 1
|
|
61
|
-
*/
|
|
62
|
-
toneMappingExposure?: MaybeRefOrGetter<number>;
|
|
63
|
-
/**
|
|
64
|
-
* The color value to use when clearing the canvas.
|
|
65
|
-
*
|
|
66
|
-
* @default 0x000000
|
|
67
|
-
*/
|
|
68
|
-
clearColor?: MaybeRefOrGetter<TresColor>;
|
|
69
|
-
windowSize?: MaybeRefOrGetter<boolean | string>;
|
|
70
|
-
preset?: MaybeRefOrGetter<RendererPresetsType>;
|
|
71
|
-
renderMode?: MaybeRefOrGetter<'always' | 'on-demand' | 'manual'>;
|
|
72
|
-
/**
|
|
73
|
-
* A `number` sets the renderer's device pixel ratio.
|
|
74
|
-
* `[number, number]` clamp's the renderer's device pixel ratio.
|
|
75
|
-
*/
|
|
76
|
-
dpr?: MaybeRefOrGetter<number | [number, number]>;
|
|
77
|
-
}
|
|
78
|
-
export declare function useRenderer({ canvas, options, contextParts: { sizes, render, invalidate, advance }, }: {
|
|
79
|
-
canvas: MaybeRef<HTMLCanvasElement>;
|
|
80
|
-
scene: Scene;
|
|
81
|
-
options: UseRendererOptions;
|
|
82
|
-
emit: EmitEventFn;
|
|
83
|
-
contextParts: Pick<TresContext, 'sizes' | 'camera' | 'render'> & {
|
|
84
|
-
invalidate: () => void;
|
|
85
|
-
advance: () => void;
|
|
86
|
-
};
|
|
87
|
-
}): {
|
|
88
|
-
renderer: import('vue').ShallowRef<WebGLRenderer, WebGLRenderer>;
|
|
89
|
-
};
|
|
90
|
-
export type UseRendererReturn = ReturnType<typeof useRenderer>;
|
|
91
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Object3D, Scene } from 'three';
|
|
2
|
-
/**
|
|
3
|
-
* Seek composable return type
|
|
4
|
-
*
|
|
5
|
-
* @export
|
|
6
|
-
* @interface UseSeekReturn
|
|
7
|
-
*/
|
|
8
|
-
export interface UseSeekReturn {
|
|
9
|
-
seek: (parent: Scene | Object3D, property: string, value: string) => Object3D | null;
|
|
10
|
-
seekByName: (parent: Scene | Object3D, value: string) => Object3D | null;
|
|
11
|
-
seekAll: (parent: Scene | Object3D, property: string, value: string) => Object3D[];
|
|
12
|
-
seekAllByName: (parent: Scene | Object3D, value: string) => Object3D[];
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Composable that provides utilities to easily traverse and navigate through complex scenes and object children graphs
|
|
16
|
-
*
|
|
17
|
-
* @export
|
|
18
|
-
* @return {*} {UseSeekReturn}
|
|
19
|
-
*/
|
|
20
|
-
export declare function useSeek(): UseSeekReturn;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { PBRUseTextureMap } from './index';
|
|
2
|
-
declare function __VLS_template(): {
|
|
3
|
-
attrs: Partial<{}>;
|
|
4
|
-
slots: {
|
|
5
|
-
default?(_: {
|
|
6
|
-
textures: {
|
|
7
|
-
map: import('three').Texture;
|
|
8
|
-
displacementMap: import('three').Texture;
|
|
9
|
-
normalMap: import('three').Texture;
|
|
10
|
-
roughnessMap: import('three').Texture;
|
|
11
|
-
metalnessMap: import('three').Texture;
|
|
12
|
-
aoMap: import('three').Texture;
|
|
13
|
-
alphaMap: import('three').Texture;
|
|
14
|
-
matcap: import('three').Texture;
|
|
15
|
-
};
|
|
16
|
-
}): any;
|
|
17
|
-
};
|
|
18
|
-
refs: {};
|
|
19
|
-
rootEl: any;
|
|
20
|
-
};
|
|
21
|
-
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
22
|
-
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>;
|
|
23
|
-
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
24
|
-
export default _default;
|
|
25
|
-
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
26
|
-
new (): {
|
|
27
|
-
$slots: S;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { Texture } from 'three';
|
|
2
|
-
export interface PBRMaterialOptions {
|
|
3
|
-
/**
|
|
4
|
-
* List of texture maps to load.
|
|
5
|
-
*
|
|
6
|
-
* @type {string[]}
|
|
7
|
-
* @memberof PBRMaterialOptions
|
|
8
|
-
*/
|
|
9
|
-
maps: string[];
|
|
10
|
-
/**
|
|
11
|
-
* Path to the texture maps.
|
|
12
|
-
*
|
|
13
|
-
* @type {('png' | 'jpg')}
|
|
14
|
-
* @memberof PBRMaterialOptions
|
|
15
|
-
*/
|
|
16
|
-
ext: 'png' | 'jpg';
|
|
17
|
-
}
|
|
18
|
-
export interface PBRTextureMaps {
|
|
19
|
-
[key: string]: Texture | null;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Map of textures to load that can be passed to `useTexture()`.
|
|
23
|
-
*/
|
|
24
|
-
export interface PBRUseTextureMap {
|
|
25
|
-
map?: string;
|
|
26
|
-
displacementMap?: string;
|
|
27
|
-
normalMap?: string;
|
|
28
|
-
roughnessMap?: string;
|
|
29
|
-
metalnessMap?: string;
|
|
30
|
-
aoMap?: string;
|
|
31
|
-
alphaMap?: string;
|
|
32
|
-
matcap?: string;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Loads a single texture.
|
|
36
|
-
*
|
|
37
|
-
* ```ts
|
|
38
|
-
* import { useTexture } from 'tres'
|
|
39
|
-
*
|
|
40
|
-
* const matcapTexture = await useTexture(['path/to/texture.png'])
|
|
41
|
-
* ```
|
|
42
|
-
* Then you can use the texture in your material.
|
|
43
|
-
*
|
|
44
|
-
* ```vue
|
|
45
|
-
* <TresMeshMatcapMaterial :matcap="matcapTexture" />
|
|
46
|
-
* ```
|
|
47
|
-
* @see https://tresjs.org/examples/load-textures.html
|
|
48
|
-
* @export
|
|
49
|
-
* @param paths
|
|
50
|
-
* @return A promise of the resulting texture
|
|
51
|
-
*/
|
|
52
|
-
export declare function useTexture(paths: readonly [string]): Promise<Texture>;
|
|
53
|
-
/**
|
|
54
|
-
* Loads multiple textures.
|
|
55
|
-
*
|
|
56
|
-
* ```ts
|
|
57
|
-
* import { useTexture } from 'tres'
|
|
58
|
-
*
|
|
59
|
-
* const [texture1, texture2] = await useTexture([
|
|
60
|
-
* 'path/to/texture1.png',
|
|
61
|
-
* 'path/to/texture2.png',
|
|
62
|
-
* ])
|
|
63
|
-
* ```
|
|
64
|
-
* Then you can use the texture in your material.
|
|
65
|
-
*
|
|
66
|
-
* ```vue
|
|
67
|
-
* <TresMeshStandardMaterial map="texture1" />
|
|
68
|
-
* ```
|
|
69
|
-
* @see https://tresjs.org/examples/load-textures.html
|
|
70
|
-
* @export
|
|
71
|
-
* @param paths
|
|
72
|
-
* @return A promise of the resulting textures
|
|
73
|
-
*/
|
|
74
|
-
export declare function useTexture<T extends string[]>(paths: [...T]): Promise<{
|
|
75
|
-
[K in keyof T]: Texture;
|
|
76
|
-
}>;
|
|
77
|
-
/**
|
|
78
|
-
* Loads a PBR texture map.
|
|
79
|
-
*
|
|
80
|
-
* ```ts
|
|
81
|
-
* import { useTexture } from 'tres'
|
|
82
|
-
*
|
|
83
|
-
* const pbrTexture = await useTexture({
|
|
84
|
-
* map: 'path/to/texture.png',
|
|
85
|
-
* displacementMap: 'path/to/displacement-map.png',
|
|
86
|
-
* roughnessMap: 'path/to/roughness-map.png',
|
|
87
|
-
* normalMap: 'path/to/normal-map.png',
|
|
88
|
-
* ambientOcclusionMap: 'path/to/ambient-occlusion-map.png',
|
|
89
|
-
* })
|
|
90
|
-
* ```
|
|
91
|
-
* Then you can use the texture in your material.
|
|
92
|
-
*
|
|
93
|
-
* ```vue
|
|
94
|
-
* <TresMeshStandardMaterial v-bind="pbrTexture" />
|
|
95
|
-
* ```
|
|
96
|
-
* @see https://tresjs.org/examples/load-textures.html
|
|
97
|
-
* @export
|
|
98
|
-
* @param paths
|
|
99
|
-
* @return A promise of the resulting pbr texture map
|
|
100
|
-
*/
|
|
101
|
-
export declare function useTexture<TextureMap extends PBRUseTextureMap>(paths: TextureMap): Promise<{
|
|
102
|
-
[K in keyof Required<PBRUseTextureMap>]: K extends keyof TextureMap ? Texture : null;
|
|
103
|
-
}>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { EmitEventFn } from 'src/types';
|
|
2
|
-
import { Scene } from 'three';
|
|
3
|
-
import { TresContext } from '../useTresContextProvider';
|
|
4
|
-
export interface TresEventManager {
|
|
5
|
-
/**
|
|
6
|
-
* Forces the event system to refire events with the previous mouse event
|
|
7
|
-
*/
|
|
8
|
-
forceUpdate: () => void;
|
|
9
|
-
/**
|
|
10
|
-
* pointer-missed events by definition are fired when the pointer missed every object in the scene
|
|
11
|
-
* So we need to track them separately
|
|
12
|
-
* Note: These are used in nodeOps
|
|
13
|
-
*/
|
|
14
|
-
registerObject: (object: unknown) => void;
|
|
15
|
-
deregisterObject: (object: unknown) => void;
|
|
16
|
-
registerPointerMissedObject: (object: unknown) => void;
|
|
17
|
-
deregisterPointerMissedObject: (object: unknown) => void;
|
|
18
|
-
}
|
|
19
|
-
export declare function useTresEventManager(scene: Scene, context: TresContext, emit: EmitEventFn): {
|
|
20
|
-
forceUpdate: () => void;
|
|
21
|
-
registerObject: (maybeTresObject: unknown) => void;
|
|
22
|
-
deregisterObject: (maybeTresObject: unknown) => void;
|
|
23
|
-
registerPointerMissedObject: (maybeTresObject: unknown) => void;
|
|
24
|
-
deregisterPointerMissedObject: (maybeTresObject: unknown) => void;
|
|
25
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { TresContext } from '../useTresContextProvider';
|
|
2
|
-
export declare function useTresReady(ctx?: TresContext): import('@vueuse/core').EventHook<TresContext> & {
|
|
3
|
-
cancel: () => void;
|
|
4
|
-
};
|
|
5
|
-
export declare function onTresReady(fn: (ctx: TresContext) => void): {
|
|
6
|
-
off: () => void;
|
|
7
|
-
} | undefined;
|