@qy_better_lib/hooks 0.2.9 → 0.2.11
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/DOCUMENTATION.md +104 -8
- package/lib/use-three/index.d.ts +8 -0
- package/lib/use-three/index.mjs +1233 -0
- package/lib/use-three/interface.d.ts +204 -0
- package/lib/use-three/modules/box-helper.d.ts +15 -0
- package/lib/use-three/modules/camera.d.ts +15 -0
- package/lib/use-three/modules/effect-composer.d.ts +45 -0
- package/lib/use-three/modules/interaction.d.ts +21 -0
- package/lib/use-three/modules/lighting.d.ts +15 -0
- package/lib/use-three/modules/loader.d.ts +28 -0
- package/lib/use-three/modules/renderer.d.ts +18 -0
- package/lib/use-three/modules/resources.d.ts +12 -0
- package/lib/use-three/modules/utils.d.ts +133 -0
- package/lib/use-three/toolTip.d.ts +101 -0
- package/lib/use-three/type.d.ts +82 -0
- package/lib/use-three/utils.d.ts +11 -0
- package/package.json +11 -1
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { ThreeTarget } from '../shared/type';
|
|
2
|
+
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
3
|
+
import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js';
|
|
4
|
+
import { OutlinePass } from 'three/examples/jsm/postprocessing/OutlinePass.js';
|
|
5
|
+
import { UnrealBloomPass } from 'three/examples/jsm/postprocessing/UnrealBloomPass.js';
|
|
6
|
+
import { BoxHelper, Object3D } from 'three';
|
|
7
|
+
import { ObjectToolTip, ToolTipOptions } from './toolTip';
|
|
8
|
+
import { OutLineOptions } from './type';
|
|
9
|
+
export interface UseThree {
|
|
10
|
+
/**three 实例*/
|
|
11
|
+
instance: ThreeTarget;
|
|
12
|
+
/**
|
|
13
|
+
* 初始化
|
|
14
|
+
*/
|
|
15
|
+
init_three: () => void;
|
|
16
|
+
/**
|
|
17
|
+
* 设置渲染容器
|
|
18
|
+
* @param container 渲染容器元素
|
|
19
|
+
*/
|
|
20
|
+
set_container: (container: HTMLElement) => void;
|
|
21
|
+
/**
|
|
22
|
+
* 创建透视相机
|
|
23
|
+
*/
|
|
24
|
+
create_perspective_camera: () => void;
|
|
25
|
+
/**
|
|
26
|
+
* 创建正交相机
|
|
27
|
+
* @param options 正交相机配置
|
|
28
|
+
*/
|
|
29
|
+
create_orthographic_camera: (options?: any) => void;
|
|
30
|
+
/**
|
|
31
|
+
* 设置相机预设
|
|
32
|
+
* @param preset 预设名称
|
|
33
|
+
*/
|
|
34
|
+
set_camera_preset: (preset: 'front' | 'back' | 'top' | 'bottom' | 'left' | 'right') => void;
|
|
35
|
+
/**
|
|
36
|
+
* 添加默认光照
|
|
37
|
+
*/
|
|
38
|
+
add_default_lighting: () => void;
|
|
39
|
+
/**
|
|
40
|
+
* 添加环境光
|
|
41
|
+
* @param options 光源配置
|
|
42
|
+
*/
|
|
43
|
+
add_ambient_light: (options?: any) => void;
|
|
44
|
+
/**
|
|
45
|
+
* 添加平行光
|
|
46
|
+
* @param options 光源配置
|
|
47
|
+
*/
|
|
48
|
+
add_directional_light: (options?: any) => void;
|
|
49
|
+
/**
|
|
50
|
+
* 添加点光源
|
|
51
|
+
* @param options 光源配置
|
|
52
|
+
*/
|
|
53
|
+
add_point_light: (options?: any) => void;
|
|
54
|
+
/**
|
|
55
|
+
* 添加聚光灯
|
|
56
|
+
* @param options 光源配置
|
|
57
|
+
*/
|
|
58
|
+
add_spot_light: (options?: any) => void;
|
|
59
|
+
/**
|
|
60
|
+
* 设置渲染状态
|
|
61
|
+
* @param status 渲染状态
|
|
62
|
+
*/
|
|
63
|
+
set_rendering_status: (status: boolean) => void;
|
|
64
|
+
/**
|
|
65
|
+
* 设置目标帧率
|
|
66
|
+
* @param fps 帧率
|
|
67
|
+
*/
|
|
68
|
+
set_target_fps: (fps: number) => void;
|
|
69
|
+
/**
|
|
70
|
+
* 加载GLTF模型
|
|
71
|
+
* @param url 模型URL
|
|
72
|
+
* @param options 加载选项
|
|
73
|
+
* @returns 加载状态对象
|
|
74
|
+
*/
|
|
75
|
+
load_gltf_model: (url: string, options?: {
|
|
76
|
+
onProgress?: (progress: number) => void;
|
|
77
|
+
onError?: (error: any) => void;
|
|
78
|
+
}) => any;
|
|
79
|
+
/**
|
|
80
|
+
* 加载OBJ模型
|
|
81
|
+
* @param url 模型URL
|
|
82
|
+
* @param mtlUrl 材质URL
|
|
83
|
+
* @param options 加载选项
|
|
84
|
+
* @returns 加载状态对象
|
|
85
|
+
*/
|
|
86
|
+
load_obj_model: (url: string, mtlUrl?: string, options?: {
|
|
87
|
+
onProgress?: (progress: number) => void;
|
|
88
|
+
onError?: (error: any) => void;
|
|
89
|
+
}) => any;
|
|
90
|
+
/**
|
|
91
|
+
* 启用对象拖拽
|
|
92
|
+
* @param object 要拖拽的对象
|
|
93
|
+
* @param options 拖拽选项
|
|
94
|
+
*/
|
|
95
|
+
enable_object_drag: (object: Object3D, options?: {
|
|
96
|
+
onDragStart?: () => void;
|
|
97
|
+
onDragEnd?: () => void;
|
|
98
|
+
onDrag?: (position: {
|
|
99
|
+
x: number;
|
|
100
|
+
y: number;
|
|
101
|
+
z: number;
|
|
102
|
+
}) => void;
|
|
103
|
+
}) => void;
|
|
104
|
+
/**
|
|
105
|
+
* 禁用对象拖拽
|
|
106
|
+
*/
|
|
107
|
+
disable_object_drag: () => void;
|
|
108
|
+
/**
|
|
109
|
+
* 启用触摸设备支持
|
|
110
|
+
*/
|
|
111
|
+
enable_touch_support: () => void;
|
|
112
|
+
/**
|
|
113
|
+
* 工具函数集合
|
|
114
|
+
*/
|
|
115
|
+
utils: any;
|
|
116
|
+
/**
|
|
117
|
+
* three渲染
|
|
118
|
+
* @param renderer 渲染器
|
|
119
|
+
* @param scene 场景
|
|
120
|
+
* @param camera 相机
|
|
121
|
+
* @param renderAction 渲染行为
|
|
122
|
+
*/
|
|
123
|
+
render: (renderAction?: Function) => void;
|
|
124
|
+
/**
|
|
125
|
+
* 获取模型点击的对象
|
|
126
|
+
*/
|
|
127
|
+
get_select_object: (e: any) => any;
|
|
128
|
+
/**开启VR */
|
|
129
|
+
enabled_vr: () => void;
|
|
130
|
+
/**禁用VR */
|
|
131
|
+
disabled_vr: () => void;
|
|
132
|
+
/**使用模型解压缩,适用于使用DRAC算法压缩的模型 */
|
|
133
|
+
use_draco_loader: (gltf_loader: GLTFLoader) => void;
|
|
134
|
+
/**释放 */
|
|
135
|
+
dispose_three: () => void;
|
|
136
|
+
/**复位 */
|
|
137
|
+
reset: () => void;
|
|
138
|
+
/**容器大小变更 */
|
|
139
|
+
resize: () => void;
|
|
140
|
+
/**开启阴影 */
|
|
141
|
+
enable_shadow: () => void;
|
|
142
|
+
/**
|
|
143
|
+
* 创建3D对象工具提示
|
|
144
|
+
* @param obj 3D对象
|
|
145
|
+
* @param options 配置选项
|
|
146
|
+
* @returns ObjectToolTip实例
|
|
147
|
+
*/
|
|
148
|
+
create_tool_tip: (obj: Object3D, options?: ToolTipOptions) => ObjectToolTip;
|
|
149
|
+
/**
|
|
150
|
+
* 创建ObjectToolTip实例
|
|
151
|
+
* @returns ObjectToolTip实例
|
|
152
|
+
*/
|
|
153
|
+
create_tool_tip_instance: () => ObjectToolTip;
|
|
154
|
+
/**
|
|
155
|
+
* 创建边界框辅助
|
|
156
|
+
* @param color 边界框颜色
|
|
157
|
+
* @returns 边界框辅助对象
|
|
158
|
+
*/
|
|
159
|
+
create_box_helper: (color?: string) => {
|
|
160
|
+
helper: BoxHelper;
|
|
161
|
+
add_to_scene: (scene: any) => void;
|
|
162
|
+
set_box_frame: (obj: Object3D) => void;
|
|
163
|
+
set_visible: (visible: boolean) => void;
|
|
164
|
+
destroy: () => void;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* 开启后期处理
|
|
168
|
+
* @param use_ssao 是否使用SSAO效果
|
|
169
|
+
* @param ssao_options SSAO配置选项
|
|
170
|
+
* @returns EffectComposer实例
|
|
171
|
+
*/
|
|
172
|
+
enable_effect: (use_ssao?: boolean, ssao_options?: {
|
|
173
|
+
kernel_radius?: number;
|
|
174
|
+
min_distance?: number;
|
|
175
|
+
max_distance?: number;
|
|
176
|
+
}) => EffectComposer | null;
|
|
177
|
+
/**
|
|
178
|
+
* 开启FXAA抗锯齿
|
|
179
|
+
* @param composer 后期处理composer
|
|
180
|
+
*/
|
|
181
|
+
enable_fxaa: (composer: EffectComposer) => void;
|
|
182
|
+
/**
|
|
183
|
+
* 开启辉光光晕效果
|
|
184
|
+
* @param composer 后期处理composer
|
|
185
|
+
* @param strength 强度
|
|
186
|
+
* @param radius 半径
|
|
187
|
+
* @param threshold 阈值
|
|
188
|
+
* @returns UnrealBloomPass实例
|
|
189
|
+
*/
|
|
190
|
+
enable_unreal_bloom: (composer: EffectComposer, strength?: number, radius?: number, threshold?: number) => UnrealBloomPass | null;
|
|
191
|
+
/**
|
|
192
|
+
* 开启轮廓高亮
|
|
193
|
+
* @param composer 后期处理composer
|
|
194
|
+
* @returns OutlinePass实例
|
|
195
|
+
*/
|
|
196
|
+
enable_outline: (composer: EffectComposer) => OutlinePass | null;
|
|
197
|
+
/**
|
|
198
|
+
* 设置模型高光
|
|
199
|
+
* @param outline_pass OutlinePass实例
|
|
200
|
+
* @param objects 需要高光的模型
|
|
201
|
+
* @param out_line_options 配置
|
|
202
|
+
*/
|
|
203
|
+
set_out_line: (outline_pass: OutlinePass, objects: Object3D[], out_line_options?: OutLineOptions) => void;
|
|
204
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BoxHelper, Object3D, Scene } from 'three';
|
|
2
|
+
import { ThreeTarget } from '../../shared/type';
|
|
3
|
+
/**
|
|
4
|
+
* 边界框辅助 Hook
|
|
5
|
+
* @param current_three Three.js实例
|
|
6
|
+
* @param color 边界框颜色
|
|
7
|
+
* @returns 边界框相关方法
|
|
8
|
+
*/
|
|
9
|
+
export declare function use_box_helper(current_three: ThreeTarget, color?: string): {
|
|
10
|
+
helper: BoxHelper;
|
|
11
|
+
add_to_scene: (scene: Scene) => void;
|
|
12
|
+
set_box_frame: (obj: Object3D) => void;
|
|
13
|
+
set_visible: (visible: boolean) => void;
|
|
14
|
+
destroy: () => void;
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ThreeOption } from '../type';
|
|
2
|
+
import { ThreeTarget } from '../../shared/type';
|
|
3
|
+
/**
|
|
4
|
+
* 相机系统 Hook
|
|
5
|
+
* @param current_three Three.js实例
|
|
6
|
+
* @returns 相机相关方法
|
|
7
|
+
*/
|
|
8
|
+
export declare function use_camera(current_three: ThreeTarget): {
|
|
9
|
+
create_perspective_camera: (options: ThreeOption) => void;
|
|
10
|
+
create_orthographic_camera: (options?: any) => void;
|
|
11
|
+
set_camera_preset: (preset: "front" | "back" | "top" | "bottom" | "left" | "right") => void;
|
|
12
|
+
orbit_controls: () => void;
|
|
13
|
+
axes_helper: (size?: number) => void;
|
|
14
|
+
reset_camera: (options: ThreeOption) => void;
|
|
15
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ThreeTarget } from '../../shared/type';
|
|
2
|
+
import { Object3D } from 'three';
|
|
3
|
+
import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js';
|
|
4
|
+
import { OutlinePass } from 'three/examples/jsm/postprocessing/OutlinePass.js';
|
|
5
|
+
import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js';
|
|
6
|
+
import { UnrealBloomPass } from 'three/examples/jsm/postprocessing/UnrealBloomPass.js';
|
|
7
|
+
import { FilmPass } from 'three/examples/jsm/postprocessing/FilmPass.js';
|
|
8
|
+
import { OutLineOptions } from '../type';
|
|
9
|
+
/**
|
|
10
|
+
* SSAO 配置选项
|
|
11
|
+
*/
|
|
12
|
+
interface SSAOOptions {
|
|
13
|
+
/** 内核半径 */
|
|
14
|
+
kernel_radius?: number;
|
|
15
|
+
/** 最小距离 */
|
|
16
|
+
min_distance?: number;
|
|
17
|
+
/** 最大距离 */
|
|
18
|
+
max_distance?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 电影效果配置选项
|
|
22
|
+
*/
|
|
23
|
+
interface FilmOptions {
|
|
24
|
+
/** 颗粒强度 */
|
|
25
|
+
noise_intensity?: number;
|
|
26
|
+
/** 灰度模式 */
|
|
27
|
+
grayscale?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 后期处理 Hook
|
|
31
|
+
* @param current_three Three.js实例
|
|
32
|
+
* @returns 后期处理相关方法
|
|
33
|
+
*/
|
|
34
|
+
export declare function use_effect_composer(current_three: ThreeTarget): {
|
|
35
|
+
enable_effect: (use_ssao?: boolean, ssao_options?: SSAOOptions) => EffectComposer;
|
|
36
|
+
enable_fxaa: (composer: EffectComposer) => void;
|
|
37
|
+
enable_unreal_bloom: (composer: EffectComposer, strength?: number, radius?: number, threshold?: number) => UnrealBloomPass | null;
|
|
38
|
+
enable_outline: (composer: EffectComposer) => OutlinePass | null;
|
|
39
|
+
set_out_line: (outline_pass: OutlinePass, objects: Object3D[], out_line_options?: OutLineOptions) => void;
|
|
40
|
+
enable_film_effect: (composer: EffectComposer, options?: FilmOptions) => FilmPass | null;
|
|
41
|
+
enable_grayscale: (composer: EffectComposer) => ShaderPass | null;
|
|
42
|
+
update_all_composers_size: () => void;
|
|
43
|
+
clear_composers: () => void;
|
|
44
|
+
};
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Object3D, Object3DEventMap } from 'three';
|
|
2
|
+
import { ThreeTarget } from '../../shared/type';
|
|
3
|
+
/**
|
|
4
|
+
* 交互系统 Hook
|
|
5
|
+
* @param current_three Three.js实例
|
|
6
|
+
* @returns 交互相关方法
|
|
7
|
+
*/
|
|
8
|
+
export declare function use_interaction(current_three: ThreeTarget): {
|
|
9
|
+
get_select_object: (e: any) => Object3D< Object3DEventMap> | null;
|
|
10
|
+
enable_object_drag: (object: Object3D, options?: {
|
|
11
|
+
onDragStart?: () => void;
|
|
12
|
+
onDragEnd?: () => void;
|
|
13
|
+
onDrag?: (position: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
z: number;
|
|
17
|
+
}) => void;
|
|
18
|
+
}) => void;
|
|
19
|
+
disable_object_drag: () => void;
|
|
20
|
+
enable_touch_support: () => void;
|
|
21
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AmbientLight, DirectionalLight, PointLight, SpotLight } from 'three';
|
|
2
|
+
import { ThreeTarget } from '../../shared/type';
|
|
3
|
+
/**
|
|
4
|
+
* 光照系统 Hook
|
|
5
|
+
* @param current_three Three.js实例
|
|
6
|
+
* @returns 光照相关方法
|
|
7
|
+
*/
|
|
8
|
+
export declare function use_lighting(current_three: ThreeTarget): {
|
|
9
|
+
add_default_lighting: () => void;
|
|
10
|
+
add_ambient_light: (options?: any) => AmbientLight;
|
|
11
|
+
add_directional_light: (options?: any) => DirectionalLight;
|
|
12
|
+
add_point_light: (options?: any) => PointLight;
|
|
13
|
+
add_spot_light: (options?: any) => SpotLight;
|
|
14
|
+
enable_shadow: () => void;
|
|
15
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
2
|
+
import { ThreeTarget } from '../../shared/type';
|
|
3
|
+
/**
|
|
4
|
+
* 模型加载系统 Hook
|
|
5
|
+
* @param current_three Three.js实例
|
|
6
|
+
* @returns 模型加载相关方法
|
|
7
|
+
*/
|
|
8
|
+
export declare function use_loader(current_three: ThreeTarget): {
|
|
9
|
+
use_draco_loader: (gltfLoader: GLTFLoader) => void;
|
|
10
|
+
load_gltf_model: (url: string, options?: {
|
|
11
|
+
onProgress?: (progress: number) => void;
|
|
12
|
+
onError?: (error: any) => void;
|
|
13
|
+
}) => {
|
|
14
|
+
progress: number;
|
|
15
|
+
loaded: boolean;
|
|
16
|
+
error: null;
|
|
17
|
+
model: any;
|
|
18
|
+
};
|
|
19
|
+
load_obj_model: (url: string, mtlUrl?: string, options?: {
|
|
20
|
+
onProgress?: (progress: number) => void;
|
|
21
|
+
onError?: (error: any) => void;
|
|
22
|
+
}) => {
|
|
23
|
+
progress: number;
|
|
24
|
+
loaded: boolean;
|
|
25
|
+
error: null;
|
|
26
|
+
model: any;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ThreeTarget } from '../../shared/type';
|
|
2
|
+
import { ThreeOption } from '../type';
|
|
3
|
+
/**
|
|
4
|
+
* 渲染系统 Hook
|
|
5
|
+
* @param current_three Three.js实例
|
|
6
|
+
* @returns 渲染相关方法
|
|
7
|
+
*/
|
|
8
|
+
export declare function use_renderer(current_three: ThreeTarget): {
|
|
9
|
+
init_renderer: (options: ThreeOption) => void;
|
|
10
|
+
init_css2_renderer: () => void;
|
|
11
|
+
set_rendering_status: (status: boolean) => void;
|
|
12
|
+
set_target_fps: (fps: number) => void;
|
|
13
|
+
render: (render_action?: Function) => void;
|
|
14
|
+
resize: () => void;
|
|
15
|
+
set_container: (container: HTMLElement) => void;
|
|
16
|
+
cancel_animation: () => void;
|
|
17
|
+
get_rendering_status: () => boolean;
|
|
18
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Object3D } from 'three';
|
|
2
|
+
import { ThreeTarget } from '../../shared/type';
|
|
3
|
+
/**
|
|
4
|
+
* 资源管理系统 Hook
|
|
5
|
+
* @param current_three Three.js实例
|
|
6
|
+
* @returns 资源管理相关方法
|
|
7
|
+
*/
|
|
8
|
+
export declare function use_resources(current_three: ThreeTarget): {
|
|
9
|
+
clear_resources: () => void;
|
|
10
|
+
clear_renderer: () => void;
|
|
11
|
+
remove_object: (object: Object3D) => void;
|
|
12
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Object3D, Vector3, Box3 } from 'three';
|
|
2
|
+
/**
|
|
3
|
+
* 安全执行函数
|
|
4
|
+
* @param fn 要执行的函数
|
|
5
|
+
* @param default_value 默认返回值
|
|
6
|
+
* @returns 函数执行结果或默认值
|
|
7
|
+
*/
|
|
8
|
+
export declare function safe_execute<T>(fn: () => T, default_value?: T): T | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* 工具函数集合
|
|
11
|
+
*/
|
|
12
|
+
export declare const three_utils: {
|
|
13
|
+
/**
|
|
14
|
+
* 计算对象边界盒
|
|
15
|
+
* @param object 3D对象
|
|
16
|
+
* @returns 边界盒对象
|
|
17
|
+
*/
|
|
18
|
+
compute_bounding_box: (object: Object3D) => Box3 | null | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* 计算对象中心点
|
|
21
|
+
* @param object 3D对象
|
|
22
|
+
* @returns 中心点坐标
|
|
23
|
+
*/
|
|
24
|
+
compute_center: (object: Object3D) => Vector3 | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* 生成网格辅助线
|
|
27
|
+
* @param size 网格大小
|
|
28
|
+
* @param divisions 网格细分
|
|
29
|
+
* @returns 网格辅助线对象
|
|
30
|
+
*/
|
|
31
|
+
create_grid_helper: (size?: number, divisions?: number) => any;
|
|
32
|
+
/**
|
|
33
|
+
* 创建坐标轴辅助器
|
|
34
|
+
* @param size 坐标轴大小
|
|
35
|
+
* @returns 坐标轴辅助器对象
|
|
36
|
+
*/
|
|
37
|
+
create_axes_helper: (size?: number) => any;
|
|
38
|
+
/**
|
|
39
|
+
* 创建立方体
|
|
40
|
+
* @param size 立方体大小
|
|
41
|
+
* @param material 材质
|
|
42
|
+
* @returns 立方体对象
|
|
43
|
+
*/
|
|
44
|
+
create_box: (size?: number, material?: any) => any;
|
|
45
|
+
/**
|
|
46
|
+
* 创建球体
|
|
47
|
+
* @param radius 球体半径
|
|
48
|
+
* @param material 材质
|
|
49
|
+
* @returns 球体对象
|
|
50
|
+
*/
|
|
51
|
+
create_sphere: (radius?: number, material?: any) => any;
|
|
52
|
+
/**
|
|
53
|
+
* 创建圆柱体
|
|
54
|
+
* @param radius_top 顶部半径
|
|
55
|
+
* @param radius_bottom 底部半径
|
|
56
|
+
* @param height 高度
|
|
57
|
+
* @param material 材质
|
|
58
|
+
* @returns 圆柱体对象
|
|
59
|
+
*/
|
|
60
|
+
create_cylinder: (radius_top?: number, radius_bottom?: number, height?: number, material?: any) => any;
|
|
61
|
+
/**
|
|
62
|
+
* 屏幕坐标转世界坐标
|
|
63
|
+
* @param x 屏幕X坐标
|
|
64
|
+
* @param y 屏幕Y坐标
|
|
65
|
+
* @param camera 相机
|
|
66
|
+
* @returns 世界坐标
|
|
67
|
+
*/
|
|
68
|
+
screen_to_world: (x: number, y: number, camera: any) => any;
|
|
69
|
+
/**
|
|
70
|
+
* 世界坐标转屏幕坐标
|
|
71
|
+
* @param position 世界坐标
|
|
72
|
+
* @param camera 相机
|
|
73
|
+
* @returns 屏幕坐标
|
|
74
|
+
*/
|
|
75
|
+
world_to_screen: (position: Vector3, camera: any) => {
|
|
76
|
+
x: number;
|
|
77
|
+
y: number;
|
|
78
|
+
} | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* 平滑动画函数
|
|
81
|
+
* @param start 起始值
|
|
82
|
+
* @param end 结束值
|
|
83
|
+
* @param duration 动画时长
|
|
84
|
+
* @param callback 每帧回调
|
|
85
|
+
* @param ease 缓动函数
|
|
86
|
+
*/
|
|
87
|
+
animate: (start: number, end: number, duration: number, callback: (value: number) => void, ease?: (t: number) => number) => void;
|
|
88
|
+
/**
|
|
89
|
+
* 缓动函数集合
|
|
90
|
+
*/
|
|
91
|
+
easing: {
|
|
92
|
+
linear: (t: number) => number;
|
|
93
|
+
ease_in_quad: (t: number) => number;
|
|
94
|
+
ease_out_quad: (t: number) => number;
|
|
95
|
+
ease_in_out_quad: (t: number) => number;
|
|
96
|
+
ease_in_cubic: (t: number) => number;
|
|
97
|
+
ease_out_cubic: (t: number) => number;
|
|
98
|
+
ease_in_out_cubic: (t: number) => number;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
/**相机预设位置 */
|
|
102
|
+
export declare const camera_presets: {
|
|
103
|
+
front: {
|
|
104
|
+
x: number;
|
|
105
|
+
y: number;
|
|
106
|
+
z: number;
|
|
107
|
+
};
|
|
108
|
+
back: {
|
|
109
|
+
x: number;
|
|
110
|
+
y: number;
|
|
111
|
+
z: number;
|
|
112
|
+
};
|
|
113
|
+
top: {
|
|
114
|
+
x: number;
|
|
115
|
+
y: number;
|
|
116
|
+
z: number;
|
|
117
|
+
};
|
|
118
|
+
bottom: {
|
|
119
|
+
x: number;
|
|
120
|
+
y: number;
|
|
121
|
+
z: number;
|
|
122
|
+
};
|
|
123
|
+
left: {
|
|
124
|
+
x: number;
|
|
125
|
+
y: number;
|
|
126
|
+
z: number;
|
|
127
|
+
};
|
|
128
|
+
right: {
|
|
129
|
+
x: number;
|
|
130
|
+
y: number;
|
|
131
|
+
z: number;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Object3D, Vector3 } from 'three';
|
|
2
|
+
/**
|
|
3
|
+
* 3D对象工具提示配置选项
|
|
4
|
+
*/
|
|
5
|
+
export interface ToolTipOptions {
|
|
6
|
+
/**
|
|
7
|
+
* 关闭回调函数
|
|
8
|
+
*/
|
|
9
|
+
onClose?: () => void;
|
|
10
|
+
/**
|
|
11
|
+
* 提示框内容
|
|
12
|
+
*/
|
|
13
|
+
content?: string;
|
|
14
|
+
/**
|
|
15
|
+
* 提示框样式类名
|
|
16
|
+
*/
|
|
17
|
+
className?: string;
|
|
18
|
+
/**
|
|
19
|
+
* 提示框位置偏移
|
|
20
|
+
*/
|
|
21
|
+
offset?: Vector3;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 3D对象工具提示类
|
|
25
|
+
* 用于在3D场景中为对象添加交互式工具提示
|
|
26
|
+
*/
|
|
27
|
+
export declare class ObjectToolTip {
|
|
28
|
+
/**
|
|
29
|
+
* 关联的3D对象
|
|
30
|
+
*/
|
|
31
|
+
obj: Object3D | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* 工具提示元素
|
|
34
|
+
*/
|
|
35
|
+
container: HTMLElement | null;
|
|
36
|
+
/**
|
|
37
|
+
* CSS2D对象,用于在3D场景中渲染HTML元素
|
|
38
|
+
*/
|
|
39
|
+
private css2Object;
|
|
40
|
+
/**
|
|
41
|
+
* 事件回调
|
|
42
|
+
*/
|
|
43
|
+
private events;
|
|
44
|
+
/**
|
|
45
|
+
* 是否显示
|
|
46
|
+
*/
|
|
47
|
+
private isVisible;
|
|
48
|
+
/**
|
|
49
|
+
* 提示框内容
|
|
50
|
+
*/
|
|
51
|
+
private content;
|
|
52
|
+
/**
|
|
53
|
+
* 创建3D对象工具提示
|
|
54
|
+
* @param obj 3D对象
|
|
55
|
+
* @param options 配置选项
|
|
56
|
+
*/
|
|
57
|
+
create(obj: Object3D, options?: ToolTipOptions): void;
|
|
58
|
+
/**
|
|
59
|
+
* 更新提示框内容
|
|
60
|
+
* @param content 新的内容
|
|
61
|
+
*/
|
|
62
|
+
updateContent(content: string): void;
|
|
63
|
+
/**
|
|
64
|
+
* 更新提示框位置
|
|
65
|
+
* @param position 新的位置
|
|
66
|
+
*/
|
|
67
|
+
updatePosition(position: Vector3): void;
|
|
68
|
+
/**
|
|
69
|
+
* 显示提示框
|
|
70
|
+
*/
|
|
71
|
+
show(): void;
|
|
72
|
+
/**
|
|
73
|
+
* 隐藏提示框
|
|
74
|
+
*/
|
|
75
|
+
hide(): void;
|
|
76
|
+
/**
|
|
77
|
+
* 移除提示框
|
|
78
|
+
*/
|
|
79
|
+
remove(): void;
|
|
80
|
+
/**
|
|
81
|
+
* 清理资源
|
|
82
|
+
*/
|
|
83
|
+
private clear;
|
|
84
|
+
/**
|
|
85
|
+
* 检查提示框是否可见
|
|
86
|
+
* @returns 是否可见
|
|
87
|
+
*/
|
|
88
|
+
isShowing(): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* 获取提示框内容
|
|
91
|
+
* @returns 提示框内容
|
|
92
|
+
*/
|
|
93
|
+
getContent(): string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 创建3D对象工具提示的工厂函数
|
|
97
|
+
* @param obj 3D对象
|
|
98
|
+
* @param options 配置选项
|
|
99
|
+
* @returns ObjectToolTip实例
|
|
100
|
+
*/
|
|
101
|
+
export declare function createObjectToolTip(obj: Object3D, options?: ToolTipOptions): ObjectToolTip;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Point3D } from '../shared/type';
|
|
2
|
+
import { Texture } from 'three';
|
|
3
|
+
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
|
|
4
|
+
export type ThreeOption = {
|
|
5
|
+
/**背景色 */
|
|
6
|
+
scenebgcolor?: string;
|
|
7
|
+
/**环境贴图 */
|
|
8
|
+
scenebg?: Texture;
|
|
9
|
+
/**相机配置 */
|
|
10
|
+
camera_option?: CameraOption;
|
|
11
|
+
/**相机类型,默认为透视相机 */
|
|
12
|
+
camera_type?: 'perspective' | 'orthographic';
|
|
13
|
+
/**是否包含控制器 */
|
|
14
|
+
controls?: boolean;
|
|
15
|
+
/**坐标辅助器 */
|
|
16
|
+
axes_helper?: boolean;
|
|
17
|
+
/**2d html渲染-展示html元素 */
|
|
18
|
+
css2_render?: boolean;
|
|
19
|
+
/**开启GPU加速 */
|
|
20
|
+
gpu?: boolean;
|
|
21
|
+
/**默认光照设置 */
|
|
22
|
+
default_lighting?: boolean;
|
|
23
|
+
};
|
|
24
|
+
/**光源配置 */
|
|
25
|
+
export type LightOption = {
|
|
26
|
+
/**光源颜色 */
|
|
27
|
+
color?: string | number;
|
|
28
|
+
/**光源强度 */
|
|
29
|
+
intensity?: number;
|
|
30
|
+
/**光源位置 */
|
|
31
|
+
position?: Point3D;
|
|
32
|
+
};
|
|
33
|
+
/**正交相机配置 */
|
|
34
|
+
export type OrthographicCameraOption = {
|
|
35
|
+
/**相机位置 */
|
|
36
|
+
position: Point3D;
|
|
37
|
+
/**左边界 */
|
|
38
|
+
left: number;
|
|
39
|
+
/**右边界 */
|
|
40
|
+
right: number;
|
|
41
|
+
/**上边界 */
|
|
42
|
+
top: number;
|
|
43
|
+
/**下边界 */
|
|
44
|
+
bottom: number;
|
|
45
|
+
/**近截面 */
|
|
46
|
+
near: number;
|
|
47
|
+
/**远截面 */
|
|
48
|
+
far: number;
|
|
49
|
+
};
|
|
50
|
+
/**相机配置 */
|
|
51
|
+
export type CameraOption = {
|
|
52
|
+
/**相机位置 */
|
|
53
|
+
position: Point3D;
|
|
54
|
+
/**摄像机视锥体垂直视野角度,从视图的底部到顶部,以角度来表示。默认值是50 */
|
|
55
|
+
fov: number;
|
|
56
|
+
/**摄像机视锥体长宽比 */
|
|
57
|
+
aspect?: number;
|
|
58
|
+
/**近距离面 */
|
|
59
|
+
near: number;
|
|
60
|
+
/**远局里面 */
|
|
61
|
+
far: number;
|
|
62
|
+
};
|
|
63
|
+
/**模型加载器 */
|
|
64
|
+
export type ModelLoader = {
|
|
65
|
+
gltf_loader: GLTFLoader;
|
|
66
|
+
};
|
|
67
|
+
export type OutLineOptions = {
|
|
68
|
+
/**律动值,数值越大,律动越慢 */
|
|
69
|
+
pulse_period?: number;
|
|
70
|
+
/**高光颜色 */
|
|
71
|
+
visible_edge_color?: string | number;
|
|
72
|
+
/**阴影颜色 */
|
|
73
|
+
hidden_edge_color?: string | number;
|
|
74
|
+
/**是否使用纹理覆盖 */
|
|
75
|
+
use_pattern_texture?: boolean;
|
|
76
|
+
/**高光边缘强度 */
|
|
77
|
+
edge_strength?: number;
|
|
78
|
+
/**边缘微光强度 */
|
|
79
|
+
edge_glow?: number;
|
|
80
|
+
/**高光厚度 */
|
|
81
|
+
edge_thickness?: number;
|
|
82
|
+
};
|