@reall3d/reall3dviewer 0.0.1
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/README.md +1 -0
- package/dist/assets/Sorter-Dl_LG4bh.js +1 -0
- package/dist/favicon.ico +0 -0
- package/dist/pkg.d.ts +285 -0
- package/dist/pkg.js +4923 -0
- package/dist/pkg.umd.cjs +725 -0
- package/dist/style.css +1 -0
- package/package.json +21 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Reall3dViewer
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){"use strict";let i=0;i++;const D=`$${i++}`;i++,i++,i++;const W=`$${i++}`,p=`$${i++}`,S=`$${i++}`,y=`$${i++}`,C=`$${i++}`,A=`$${i++}`,R=`$${i++}`,G=`$${i++}`;i++;const H=`$${i++}`,J=`$${i++}`;i++;const T=`$${i++}`;i++;const K=`$${i++}`;i++;const L=`$${i++}`,N=`$${i++}`,O=`$${i++}`,Q=`$${i++}`,_=`$${i++}`,V=`$${i++}`,j=`$${i++}`,P=`$${i++}`;i++;const nn=navigator.userAgent.includes("Mobi"),b=self;let X={index:0,version:0},Y={index:1,version:0},w=!1,Z;const tn=.2;let k,f=[],M,z=0,B;function an(n){if(!w)return;let a=X.version>Y.version?X:Y;if(!a.version)return;const{xyz:t,renderSplatCount:o,visibleSplatCount:m,modelSplatCount:E,watermarkCount:x,index:F,version:u}=a;if(z===u&&Math.abs(f[2]-n[2])+Math.abs(f[6]-n[6])+Math.abs(f[10]-n[10])+Math.abs(f[14]-n[14])<tn)return;f=n,z=u;let I=Date.now(),l;if(!o){l=new Uint32Array(0),b.postMessage({[D]:l,[S]:o,[y]:m,[C]:E,[W]:F,[p]:u,[R]:0,[A]:I},[l.buffer]);return}let q=0;const r=o-x;l=new Uint32Array(o);const{maxDepth:v,minDepth:d}=en(a,k);if(v-d<=1e-5)for(let s=0;s<o;s++)l[s]=s;else{let s=Math.min(r,65535),g=(s-1)/(v-d),c=new Int32Array(s);for(let e=0,h=0;e<r;e++)h=($(n,t[3*e],t[3*e+1],t[3*e+2])-d)*g|0,c[M[e]=h]++;for(let e=1;e<s;e++)c[e]+=c[e-1];for(let e=0;e<r;e++)l[--c[M[e]]]=e;if(x){s=Math.min(Math.max(x/8|0,512),65535),g=(s-1)/(v-d),c=new Int32Array(s);for(let e=r,h=0;e<o;e++)h=($(n,t[3*e],t[3*e+1],t[3*e+2])-d)*g|0,c[M[e-r]=h]++;for(let e=1;e<s;e++)c[e]+=c[e-1];for(let e=0;e<x;e++)l[r+--c[M[e]]]=r+e}}q=Date.now()-I,b.postMessage({[D]:l,[S]:o,[y]:m,[C]:E,[W]:F,[p]:u,[A]:I,[R]:q},[l.buffer])}function $(n,a,t,o){return-(n[2]*a+n[6]*t+n[10]*o)}function en(n,a){let t=-1/0,o=1/0,m=0;return m=$(a,n.minX,n.minY,n.minZ),t=Math.max(t,m),o=Math.min(o,m),m=$(a,n.minX,n.minY,n.maxZ),t=Math.max(t,m),o=Math.min(o,m),m=$(a,n.minX,n.maxY,n.minZ),t=Math.max(t,m),o=Math.min(o,m),m=$(a,n.minX,n.maxY,n.maxZ),t=Math.max(t,m),o=Math.min(o,m),m=$(a,n.maxX,n.minY,n.minZ),t=Math.max(t,m),o=Math.min(o,m),m=$(a,n.maxX,n.minY,n.maxZ),t=Math.max(t,m),o=Math.min(o,m),m=$(a,n.maxX,n.maxY,n.minZ),t=Math.max(t,m),o=Math.min(o,m),m=$(a,n.maxX,n.maxY,n.maxZ),t=Math.max(t,m),o=Math.min(o,m),{maxDepth:t,minDepth:o}}const U=()=>{if(!Z){Z=!0;const n=k;an(n),setTimeout(()=>!(Z=!1)&&n!==k&&U())}};b.onmessage=n=>{const a=n.data;if(a[G]){let t=!B||a[W]===0?X:Y;t.minX=a[L],t.maxX=a[N],t.minY=a[O],t.maxY=a[Q],t.minZ=a[_],t.maxZ=a[V],t.xyz=new Float32Array(a[K].buffer),t.watermarkCount=a[P],t.version=a[p],t.renderSplatCount=a[S],t.visibleSplatCount=a[y],t.modelSplatCount=a[C],t.textureReady=!0,t.textureReadyTime=Date.now()}else a[T]?(k=a[T],U()):a[j]&&(B=a[H],M=new Int32Array(a[J]),w=!0)}})();
|
package/dist/favicon.ico
ADDED
|
Binary file
|
package/dist/pkg.d.ts
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { AmbientLight } from 'three';
|
|
2
|
+
import { DirectionalLight } from 'three';
|
|
3
|
+
import { EventDispatcher } from 'three';
|
|
4
|
+
import { MapControls } from 'three/examples/jsm/controls/MapControls.js';
|
|
5
|
+
import { OrbitControls } from 'three/examples/jsm/Addons.js';
|
|
6
|
+
import { PerspectiveCamera } from 'three';
|
|
7
|
+
import { Renderer } from 'three';
|
|
8
|
+
import { Scene } from 'three';
|
|
9
|
+
import * as tt from '@gotoeasy/three-tile';
|
|
10
|
+
import { WebGLRenderer } from 'three';
|
|
11
|
+
|
|
12
|
+
declare class Events {
|
|
13
|
+
private map;
|
|
14
|
+
constructor();
|
|
15
|
+
on(key: number, fn?: Function, multiFn?: boolean): Function | Function[];
|
|
16
|
+
fire(key: number, ...args: any): any;
|
|
17
|
+
tryFire(key: number, ...args: any): any;
|
|
18
|
+
off(key: number): void;
|
|
19
|
+
clear(): void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 高斯模型选项
|
|
24
|
+
*/
|
|
25
|
+
declare interface ModelOptions {
|
|
26
|
+
/**
|
|
27
|
+
* 模型地址
|
|
28
|
+
*/
|
|
29
|
+
url: string;
|
|
30
|
+
/**
|
|
31
|
+
* 模型格式(ply | splat | spx | spz),默认自动识别
|
|
32
|
+
*/
|
|
33
|
+
format?: 'ply' | 'splat' | 'spx' | 'spz';
|
|
34
|
+
/**
|
|
35
|
+
* 是否重新下载
|
|
36
|
+
*/
|
|
37
|
+
fetchReload?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 地图渲染器
|
|
42
|
+
*/
|
|
43
|
+
export declare class Reall3dMapViewer extends EventDispatcher<tt.plugin.GLViewerEventMap> {
|
|
44
|
+
scene: Scene;
|
|
45
|
+
renderer: WebGLRenderer;
|
|
46
|
+
camera: PerspectiveCamera;
|
|
47
|
+
controls: MapControls;
|
|
48
|
+
ambLight: AmbientLight;
|
|
49
|
+
dirLight: DirectionalLight;
|
|
50
|
+
container: HTMLElement;
|
|
51
|
+
tileMap: tt.TileMap;
|
|
52
|
+
events: Events;
|
|
53
|
+
private clock;
|
|
54
|
+
private updateTime;
|
|
55
|
+
private disposed;
|
|
56
|
+
constructor(options?: Reall3dMapViewerOptions);
|
|
57
|
+
/**
|
|
58
|
+
* 打开地图场景
|
|
59
|
+
* @param 场景索引文件地址
|
|
60
|
+
*/
|
|
61
|
+
addScenes(urlScenesJson: string): void;
|
|
62
|
+
private resize;
|
|
63
|
+
private animate;
|
|
64
|
+
/**
|
|
65
|
+
* 销毁
|
|
66
|
+
*/
|
|
67
|
+
dispose(): void;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 地图配置项
|
|
72
|
+
*/
|
|
73
|
+
declare interface Reall3dMapViewerOptions {
|
|
74
|
+
/**
|
|
75
|
+
* 容器元素或其选择器,默认选择器为'#map',自动创建画布时若找不到容器节点,将在'#gsviewer'下自动创建容器
|
|
76
|
+
*/
|
|
77
|
+
root?: HTMLElement | string;
|
|
78
|
+
/**
|
|
79
|
+
* 是否调试模式,生产环境默认false
|
|
80
|
+
*/
|
|
81
|
+
debugMode?: boolean;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 高斯渲染器
|
|
86
|
+
*/
|
|
87
|
+
export declare class Reall3dViewer {
|
|
88
|
+
private disposed;
|
|
89
|
+
private splatMesh;
|
|
90
|
+
private events;
|
|
91
|
+
private updateTime;
|
|
92
|
+
needUpdate: boolean;
|
|
93
|
+
constructor(opts?: Reall3dViewerOptions);
|
|
94
|
+
private init;
|
|
95
|
+
/**
|
|
96
|
+
* 允许拖拽本地文件进行渲染
|
|
97
|
+
*/
|
|
98
|
+
private enableDropLocalFile;
|
|
99
|
+
/**
|
|
100
|
+
* 刷新
|
|
101
|
+
*/
|
|
102
|
+
update(): void;
|
|
103
|
+
fire(n: number, p1?: any, p2?: any): void;
|
|
104
|
+
/**
|
|
105
|
+
* 设定或者获取最新配置项
|
|
106
|
+
* @param opts 配置项
|
|
107
|
+
* @returns 最新配置项
|
|
108
|
+
*/
|
|
109
|
+
options(opts?: Reall3dViewerOptions): Reall3dViewerOptions;
|
|
110
|
+
/**
|
|
111
|
+
* 重置
|
|
112
|
+
*/
|
|
113
|
+
reset(opts?: Reall3dViewerOptions): void;
|
|
114
|
+
/**
|
|
115
|
+
* 光圈过渡切换显示
|
|
116
|
+
* @returns
|
|
117
|
+
*/
|
|
118
|
+
switchDeiplayMode(): void;
|
|
119
|
+
/**
|
|
120
|
+
* 添加场景
|
|
121
|
+
* @param sceneUrl 场景地址
|
|
122
|
+
*/
|
|
123
|
+
addScene(sceneUrl: string): Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* 添加要渲染的高斯模型(小场景模式)
|
|
126
|
+
* @param urlOpts 高斯模型链接或元数据文件链接或选项
|
|
127
|
+
*/
|
|
128
|
+
addModel(urlOpts: string | ModelOptions): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* 根据需要暴露的接口
|
|
131
|
+
*/
|
|
132
|
+
private initGsApi;
|
|
133
|
+
/**
|
|
134
|
+
* 销毁渲染器不再使用
|
|
135
|
+
*/
|
|
136
|
+
dispose(): void;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* 高斯网格配置项
|
|
141
|
+
*/
|
|
142
|
+
declare interface Reall3dViewerOptions {
|
|
143
|
+
/**
|
|
144
|
+
* 指定渲染器对象传入使用,未定义时自动生成
|
|
145
|
+
*/
|
|
146
|
+
renderer?: Renderer | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* 指定场景对象传入使用,未定义时自动生成
|
|
149
|
+
*/
|
|
150
|
+
scene?: Scene | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* 指定相机对象传入使用,未定义时自动生成
|
|
153
|
+
*/
|
|
154
|
+
camera?: PerspectiveCamera | undefined;
|
|
155
|
+
/**
|
|
156
|
+
* 控制器
|
|
157
|
+
*/
|
|
158
|
+
controls?: OrbitControls;
|
|
159
|
+
/**
|
|
160
|
+
* 渲染器事件管理器
|
|
161
|
+
*/
|
|
162
|
+
viewerEvents?: Events | undefined;
|
|
163
|
+
/**
|
|
164
|
+
* 是否调试模式,生产环境默认false
|
|
165
|
+
*/
|
|
166
|
+
debugMode?: boolean | undefined;
|
|
167
|
+
/**
|
|
168
|
+
* 是否大场景模式,初始化后不可修改
|
|
169
|
+
*/
|
|
170
|
+
bigSceneMode?: boolean;
|
|
171
|
+
/**
|
|
172
|
+
* 是否点云模式渲染,默认为true
|
|
173
|
+
* 支持通过viewer.options()动态更新
|
|
174
|
+
*/
|
|
175
|
+
pointcloudMode?: boolean | undefined;
|
|
176
|
+
/**
|
|
177
|
+
* 移动端可渲染的高斯点数量限制
|
|
178
|
+
* 支持通过viewer.options()动态更新
|
|
179
|
+
*/
|
|
180
|
+
maxRenderCountOfMobile?: number | undefined;
|
|
181
|
+
/**
|
|
182
|
+
* PC端可渲染的高斯点数量限制
|
|
183
|
+
* 支持通过viewer.options()动态更新
|
|
184
|
+
*/
|
|
185
|
+
maxRenderCountOfPc?: number | undefined;
|
|
186
|
+
/**
|
|
187
|
+
* 颜色亮度系数,默认1.1
|
|
188
|
+
*/
|
|
189
|
+
lightFactor?: number | undefined;
|
|
190
|
+
/**
|
|
191
|
+
* 容器元素或其选择器,默认选择器为'#gsviewer',自动创建画布时若找不到容器节点,将在body下自动创建容器
|
|
192
|
+
*/
|
|
193
|
+
root?: HTMLElement | string | undefined;
|
|
194
|
+
/**
|
|
195
|
+
* 相机视场,默认 45
|
|
196
|
+
*/
|
|
197
|
+
fov?: number | undefined;
|
|
198
|
+
/**
|
|
199
|
+
* 相机近截面距离,默认 0.1
|
|
200
|
+
*/
|
|
201
|
+
near?: number | undefined;
|
|
202
|
+
/**
|
|
203
|
+
* 相机远截面距离,默认 1000
|
|
204
|
+
*/
|
|
205
|
+
far?: number | undefined;
|
|
206
|
+
/**
|
|
207
|
+
* 相机位置,默认 [0, -5, 15]
|
|
208
|
+
*/
|
|
209
|
+
position?: number[] | undefined;
|
|
210
|
+
/**
|
|
211
|
+
* 相机注视点,默认 [0, 0, 0]
|
|
212
|
+
*/
|
|
213
|
+
lookAt?: number[] | undefined;
|
|
214
|
+
/**
|
|
215
|
+
* 相机上向量,默认 [0, -1, 0]
|
|
216
|
+
*/
|
|
217
|
+
lookUp?: number[] | undefined;
|
|
218
|
+
/**
|
|
219
|
+
* 是否自动旋转,默认true
|
|
220
|
+
* 支持通过viewer.options()动态更新
|
|
221
|
+
*/
|
|
222
|
+
autoRotate?: boolean | undefined;
|
|
223
|
+
/**
|
|
224
|
+
* 是否启用阻尼效果,默认true
|
|
225
|
+
*/
|
|
226
|
+
enableDamping?: boolean | undefined;
|
|
227
|
+
/**
|
|
228
|
+
* 是否允许操作缩放,默认true
|
|
229
|
+
*/
|
|
230
|
+
enableZoom?: boolean | undefined;
|
|
231
|
+
/**
|
|
232
|
+
* 是否允许操作旋转,默认true
|
|
233
|
+
*/
|
|
234
|
+
enableRotate?: boolean | undefined;
|
|
235
|
+
/**
|
|
236
|
+
* 是否允许操作拖动,默认true
|
|
237
|
+
*/
|
|
238
|
+
enablePan?: boolean | undefined;
|
|
239
|
+
/**
|
|
240
|
+
* 最小视距
|
|
241
|
+
*/
|
|
242
|
+
minDistance?: number | undefined;
|
|
243
|
+
/**
|
|
244
|
+
* 最大视距
|
|
245
|
+
*/
|
|
246
|
+
maxDistance?: number | undefined;
|
|
247
|
+
/**
|
|
248
|
+
* 最小倾斜角度
|
|
249
|
+
*/
|
|
250
|
+
minPolarAngle?: number | undefined;
|
|
251
|
+
/**
|
|
252
|
+
* 最大倾斜角度
|
|
253
|
+
*/
|
|
254
|
+
maxPolarAngle?: number | undefined;
|
|
255
|
+
/**
|
|
256
|
+
* 是否允许键盘操作,默认true
|
|
257
|
+
*/
|
|
258
|
+
enableKeyboard?: boolean | undefined;
|
|
259
|
+
/**
|
|
260
|
+
* 标注模式,默认false
|
|
261
|
+
*/
|
|
262
|
+
markMode?: boolean | undefined;
|
|
263
|
+
/**
|
|
264
|
+
* 标注类型(点、线、面、距离、面积、圆),默认undefined
|
|
265
|
+
*/
|
|
266
|
+
markType?: 'point' | 'lines' | 'plans' | 'distance' | 'area' | 'circle' | undefined;
|
|
267
|
+
/**
|
|
268
|
+
* 标注是否显示,默认true
|
|
269
|
+
*/
|
|
270
|
+
markVisible?: boolean | undefined;
|
|
271
|
+
/**
|
|
272
|
+
* 米单位比例尺(1单位长度等于多少米),默认1
|
|
273
|
+
*/
|
|
274
|
+
meterScale?: number | undefined;
|
|
275
|
+
/**
|
|
276
|
+
* 是否禁止直接拖拽本地文件进行查看,默认false
|
|
277
|
+
*/
|
|
278
|
+
disableDropLocalFile?: boolean | undefined;
|
|
279
|
+
/**
|
|
280
|
+
* 球谐系数的渲染级别,默认为模型数据的最大可渲染级别
|
|
281
|
+
*/
|
|
282
|
+
shDegree?: number | undefined;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export { }
|