deeptwins-engine-3d 0.1.40 → 0.1.41

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.
File without changes
@@ -0,0 +1,442 @@
1
+ // import * as Cesium from 'deeptwins-cesium';
2
+ // import { merge } from 'lodash';
3
+ // import { DEFAULT_VIEWSHED_ANALYSIS_OPTIONS } from '../constant';
4
+ // import { MapContext } from '../map/Map';
5
+ // import * as utils from '../tool/utils';
6
+ //
7
+ // // 可视域分析。
8
+ // class ViewshedAnalysis {
9
+ // private readonly _mapContext: MapContext;
10
+ // public options: any;
11
+ // public isDestroyed: boolean = false;
12
+ // private _viewPositionC3: any;
13
+ // private _viewPositionEndC3: any;
14
+ // private _viewDistance: any;
15
+ // private _viewHeading: any;
16
+ // private _viewPitch: any;
17
+ // private lightCamera: any;
18
+ // private shadowMap: any;
19
+ // private postStage: any;
20
+ // private frustumOutline: any;
21
+ // private sketch: any;
22
+ //
23
+ // constructor(map: any, options: any) {
24
+ // this._mapContext = map._mapContext;
25
+ // this.options = merge(DEFAULT_VIEWSHED_ANALYSIS_OPTIONS(), options);
26
+ // if (!this.options.viewPosition) return;
27
+ // const [lng, lat, alt] = this.options.viewPosition;
28
+ // this._viewPositionC3 = utils.lngLatAltToCartesian3(lng, lat, alt || 0);
29
+ // this._viewDistance = this.options.viewDistance;
30
+ // this._viewHeading = this.options.viewHeading;
31
+ // this._viewPitch = this.options.viewPitch;
32
+ // if (this.options.viewPositionEnd) {
33
+ // const [lng, lat, alt] = this.options.viewPositionEnd;
34
+ // this._viewPositionEndC3 = utils.lngLatAltToCartesian3(lng, lat, alt || 0);
35
+ // this._viewDistance = Cesium.Cartesian3.distance(
36
+ // this._viewPositionC3,
37
+ // this._viewPositionEndC3,
38
+ // );
39
+ // this._viewHeading = getHeading(
40
+ // this._viewPositionC3,
41
+ // this._viewPositionEndC3,
42
+ // );
43
+ // this._viewPitch = getPitch(this._viewPositionC3, this._viewPositionEndC3);
44
+ // }
45
+ // this.add();
46
+ // }
47
+ //
48
+ // // 是否能进行操作
49
+ // private _canOperate() {
50
+ // if (this.isDestroyed) {
51
+ // utils.error('SunLightAnalysis实例已销毁');
52
+ // return false;
53
+ // }
54
+ // return true;
55
+ // }
56
+ //
57
+ // public getMap() {
58
+ // return this._mapContext && this._mapContext.getMap();
59
+ // }
60
+ //
61
+ // public add() {
62
+ // this.createLightCamera();
63
+ // this.createShadowMap();
64
+ // this.createPostStage();
65
+ // this.drawFrustumOutline();
66
+ // this.drawSketch();
67
+ // }
68
+ //
69
+ // public update() {
70
+ // if (!this._canOperate) return;
71
+ // this.clear();
72
+ // this.add();
73
+ // }
74
+ //
75
+ // //创建相机
76
+ // public createLightCamera() {
77
+ // if (!this._canOperate) return;
78
+ // this.lightCamera = new Cesium.Camera(this.getMap().scene);
79
+ // this.lightCamera.position = this._viewPositionC3;
80
+ // // if (this.viewPositionEnd) {
81
+ // // let direction = Cesium.Cartesian3.normalize(Cesium.Cartesian3.subtract(this.viewPositionEnd, this.viewPosition, new Cesium.Cartesian3()), new Cesium.Cartesian3());
82
+ // // this.lightCamera.direction = direction; // direction是相机面向的方向
83
+ // // }
84
+ // this.lightCamera.frustum.near = this._viewDistance * 0.001;
85
+ // this.lightCamera.frustum.far = this._viewDistance;
86
+ // const hr = Cesium.Math.toRadians(this.options.horizontalViewAngle);
87
+ // const vr = Cesium.Math.toRadians(this.options.verticalViewAngle);
88
+ // const aspectRatio =
89
+ // (this._viewDistance * Math.tan(hr / 2) * 2) /
90
+ // (this._viewDistance * Math.tan(vr / 2) * 2);
91
+ // this.lightCamera.frustum.aspectRatio = aspectRatio;
92
+ // if (hr > vr) {
93
+ // this.lightCamera.frustum.fov = hr;
94
+ // } else {
95
+ // this.lightCamera.frustum.fov = vr;
96
+ // }
97
+ // this.lightCamera.setView({
98
+ // destination: this._viewPositionC3,
99
+ // orientation: {
100
+ // heading: Cesium.Math.toRadians(this._viewHeading || 0),
101
+ // pitch: Cesium.Math.toRadians(this._viewPitch || 0),
102
+ // roll: 0,
103
+ // },
104
+ // });
105
+ // }
106
+ //
107
+ // //创建阴影贴图
108
+ // public createShadowMap() {
109
+ // if (!this._canOperate) return;
110
+ // // 启用地形阴影
111
+ // this.getMap().scene.globe.shadows = Cesium.ShadowMode.ENABLED;
112
+ // // this.shadowMap = new Cesium.ShadowMap();
113
+ // // this.shadowMap.enabled = this.options.enabled;
114
+ // // this.shadowMap.size = this.options.size;
115
+ // // this.shadowMap.softShadows = this.options.softShadows;
116
+ // // this.shadowMap.normalOffset = false;
117
+ // this.shadowMap = new Cesium.ShadowMap({
118
+ // context: this.getMap().scene.context,
119
+ // lightCamera: this.lightCamera,
120
+ // enabled: this.options.enabled,
121
+ // isPointLight: true,
122
+ // pointLightRadius: this._viewDistance,
123
+ // cascadesEnabled: false,
124
+ // size: this.options.size,
125
+ // softShadows: this.options.softShadows,
126
+ // normalOffset: false,
127
+ // fromLightSource: false,
128
+ // });
129
+ // this.getMap().scene.shadowMap = this.shadowMap;
130
+ // }
131
+ //
132
+ // //创建PostStage
133
+ // public createPostStage() {
134
+ // if (!this._canOperate) return;
135
+ // const fs = `
136
+ // #define USE_CUBE_MAP_SHADOW true
137
+ // uniform sampler2D colorTexture;
138
+ // uniform sampler2D depthTexture;
139
+ // varying vec2 v_textureCoordinates;
140
+ // uniform mat4 camera_projection_matrix;
141
+ // uniform mat4 camera_view_matrix;
142
+ // uniform samplerCube shadowMap_textureCube;
143
+ // uniform mat4 shadowMap_matrix;
144
+ // uniform vec4 shadowMap_lightPositionEC;
145
+ // uniform vec4 shadowMap_normalOffsetScaleDistanceMaxDistanceAndDarkness;
146
+ // uniform vec4 shadowMap_texelSizeDepthBiasAndNormalShadingSmooth;
147
+ // uniform float helsing_viewDistance;
148
+ // uniform vec4 helsing_visibleAreaColor;
149
+ // uniform vec4 helsing_invisibleAreaColor;
150
+ // struct zx_shadowParameters
151
+ // {
152
+ // vec3 texCoords;
153
+ // float depthBias;
154
+ // float depth;
155
+ // float nDotL;
156
+ // vec2 texelStepSize;
157
+ // float normalShadingSmooth;
158
+ // float darkness;
159
+ // };
160
+ // float czm_shadowVisibility(samplerCube shadowMap, zx_shadowParameters shadowParameters)
161
+ // {
162
+ // float depthBias = shadowParameters.depthBias;
163
+ // float depth = shadowParameters.depth;
164
+ // float nDotL = shadowParameters.nDotL;
165
+ // float normalShadingSmooth = shadowParameters.normalShadingSmooth;
166
+ // float darkness = shadowParameters.darkness;
167
+ // vec3 uvw = shadowParameters.texCoords;
168
+ // depth -= depthBias;
169
+ // float visibility = czm_shadowDepthCompare(shadowMap, uvw, depth);
170
+ // return czm_private_shadowVisibility(visibility, nDotL, normalShadingSmooth, darkness);
171
+ // }
172
+ // vec4 getPositionEC(){
173
+ // return czm_windowToEyeCoordinates(gl_FragCoord);
174
+ // }
175
+ // vec3 getNormalEC(){
176
+ // return vec3(1.);
177
+ // }
178
+ // vec4 toEye( vec2 uv, float depth){
179
+ // vec2 xy=vec2((uv.x*2.-1.),(uv.y*2.-1.));
180
+ // vec4 posInCamera=czm_inverseProjection*vec4(xy,depth,1.);
181
+ // posInCamera=posInCamera/posInCamera.w;
182
+ // return posInCamera;
183
+ // }
184
+ // vec3 pointProjectOnPlane( vec3 planeNormal, vec3 planeOrigin, vec3 point){
185
+ // vec3 v01=point-planeOrigin;
186
+ // float d=dot(planeNormal,v01);
187
+ // return(point-planeNormal*d);
188
+ // }
189
+ // float getDepth( vec4 depth){
190
+ // float z_window=czm_unpackDepth(depth);
191
+ // z_window=czm_reverseLogDepth(z_window);
192
+ // float n_range=czm_depthRange.near;
193
+ // float f_range=czm_depthRange.far;
194
+ // return(2.*z_window-n_range-f_range)/(f_range-n_range);
195
+ // }
196
+ // float shadow( vec4 positionEC){
197
+ // vec3 normalEC=getNormalEC();
198
+ // zx_shadowParameters shadowParameters;
199
+ // shadowParameters.texelStepSize=shadowMap_texelSizeDepthBiasAndNormalShadingSmooth.xy;
200
+ // shadowParameters.depthBias=shadowMap_texelSizeDepthBiasAndNormalShadingSmooth.z;
201
+ // shadowParameters.normalShadingSmooth=shadowMap_texelSizeDepthBiasAndNormalShadingSmooth.w;
202
+ // shadowParameters.darkness=shadowMap_normalOffsetScaleDistanceMaxDistanceAndDarkness.w;
203
+ // vec3 directionEC=positionEC.xyz-shadowMap_lightPositionEC.xyz;
204
+ // float distance=length(directionEC);
205
+ // directionEC=normalize(directionEC);
206
+ // float radius=shadowMap_lightPositionEC.w;
207
+ // if(distance>radius)
208
+ // {
209
+ // return 2.0;
210
+ // }
211
+ // vec3 directionWC=czm_inverseViewRotation*directionEC;
212
+ // shadowParameters.depth=distance/radius-0.0003;
213
+ // shadowParameters.nDotL=clamp(dot(normalEC,-directionEC),0.,1.);
214
+ // shadowParameters.texCoords=directionWC;
215
+ // float visibility=czm_shadowVisibility(shadowMap_textureCube,shadowParameters);
216
+ // return visibility;
217
+ // }
218
+ // bool visible( vec4 result)
219
+ // {
220
+ // result.x/=result.w;
221
+ // result.y/=result.w;
222
+ // result.z/=result.w;
223
+ // return result.x>=-1.&&result.x<=1.
224
+ // &&result.y>=-1.&&result.y<=1.
225
+ // &&result.z>=-1.&&result.z<=1.;
226
+ // }
227
+ // void main(){
228
+ // // 釉色 = 结构二维(颜色纹理, 纹理坐标)
229
+ // gl_FragColor = texture2D(colorTexture, v_textureCoordinates);
230
+ // // 深度 = 获取深度(结构二维(深度纹理, 纹理坐标))
231
+ // float depth = getDepth(texture2D(depthTexture, v_textureCoordinates));
232
+ // // 视角 = (纹理坐标, 深度)
233
+ // vec4 viewPos = toEye(v_textureCoordinates, depth);
234
+ // // 世界坐标
235
+ // vec4 wordPos = czm_inverseView * viewPos;
236
+ // // 虚拟相机中坐标
237
+ // vec4 vcPos = camera_view_matrix * wordPos;
238
+ // float near = .001 * helsing_viewDistance;
239
+ // float dis = length(vcPos.xyz);
240
+ // if(dis > near && dis < helsing_viewDistance){
241
+ // // 透视投影
242
+ // vec4 posInEye = camera_projection_matrix * vcPos;
243
+ // // 可视区颜色
244
+ // // vec4 helsing_visibleAreaColor=vec4(0.,1.,0.,.5);
245
+ // // vec4 helsing_invisibleAreaColor=vec4(1.,0.,0.,.5);
246
+ // if(visible(posInEye)){
247
+ // float vis = shadow(viewPos);
248
+ // if(vis > 0.3){
249
+ // gl_FragColor = mix(gl_FragColor,helsing_visibleAreaColor,.5);
250
+ // } else{
251
+ // gl_FragColor = mix(gl_FragColor,helsing_invisibleAreaColor,.5);
252
+ // }
253
+ // }
254
+ // }
255
+ // }`;
256
+ // const scene = this.getMap().scene;
257
+ // const postStage = new Cesium.PostProcessStage({
258
+ // fragmentShader: fs,
259
+ // uniforms: {
260
+ // shadowMap_textureCube: () => {
261
+ // this.shadowMap.update(Reflect.get(scene, '_frameState'));
262
+ // return Reflect.get(this.shadowMap, '_shadowMapTexture');
263
+ // },
264
+ // shadowMap_matrix: () => {
265
+ // this.shadowMap.update(Reflect.get(scene, '_frameState'));
266
+ // return Reflect.get(this.shadowMap, '_shadowMapMatrix');
267
+ // },
268
+ // shadowMap_lightPositionEC: () => {
269
+ // this.shadowMap.update(Reflect.get(scene, '_frameState'));
270
+ // return Reflect.get(this.shadowMap, '_lightPositionEC');
271
+ // },
272
+ // shadowMap_normalOffsetScaleDistanceMaxDistanceAndDarkness: () => {
273
+ // this.shadowMap.update(Reflect.get(scene, '_frameState'));
274
+ // const bias = this.shadowMap._pointBias;
275
+ // return Cesium.Cartesian4.fromElements(
276
+ // bias.normalOffsetScale,
277
+ // this.shadowMap._distance,
278
+ // this.shadowMap.maximumDistance,
279
+ // 0.0,
280
+ // new Cesium.Cartesian4(),
281
+ // );
282
+ // },
283
+ // shadowMap_texelSizeDepthBiasAndNormalShadingSmooth: () => {
284
+ // this.shadowMap.update(Reflect.get(scene, '_frameState'));
285
+ // const bias = this.shadowMap._pointBias;
286
+ // const scratchTexelStepSize = new Cesium.Cartesian2();
287
+ // const texelStepSize = scratchTexelStepSize;
288
+ // texelStepSize.x = 1.0 / this.shadowMap._textureSize.x;
289
+ // texelStepSize.y = 1.0 / this.shadowMap._textureSize.y;
290
+ //
291
+ // return Cesium.Cartesian4.fromElements(
292
+ // texelStepSize.x,
293
+ // texelStepSize.y,
294
+ // bias.depthBias,
295
+ // bias.normalShadingSmooth,
296
+ // new Cesium.Cartesian4(),
297
+ // );
298
+ // },
299
+ // camera_projection_matrix: this.lightCamera.frustum.projectionMatrix,
300
+ // camera_view_matrix: this.lightCamera.viewMatrix,
301
+ // helsing_viewDistance: () => {
302
+ // return this._viewDistance;
303
+ // },
304
+ // helsing_visibleAreaColor: this.options.visibleAreaColor,
305
+ // helsing_invisibleAreaColor: this.options.invisibleAreaColor,
306
+ // },
307
+ // });
308
+ // this.postStage = scene.postProcessStages.add(postStage);
309
+ // }
310
+ //
311
+ // //创建视锥线
312
+ // public drawFrustumOutline() {
313
+ // if (!this._canOperate) return;
314
+ // const scratchRight = new Cesium.Cartesian3();
315
+ // const scratchRotation = new Cesium.Matrix3();
316
+ // const scratchOrientation = new Cesium.Quaternion();
317
+ // // const position = this.lightCamera.positionWC;
318
+ // const direction = this.lightCamera.directionWC;
319
+ // const up = this.lightCamera.upWC;
320
+ // let right = this.lightCamera.rightWC;
321
+ // right = Cesium.Cartesian3.negate(right, scratchRight);
322
+ // const rotation = scratchRotation;
323
+ // Cesium.Matrix3.setColumn(rotation, 0, right, rotation);
324
+ // Cesium.Matrix3.setColumn(rotation, 1, up, rotation);
325
+ // Cesium.Matrix3.setColumn(rotation, 2, direction, rotation);
326
+ // const orientation = Cesium.Quaternion.fromRotationMatrix(
327
+ // rotation,
328
+ // scratchOrientation,
329
+ // );
330
+ //
331
+ // const instance = new Cesium.GeometryInstance({
332
+ // geometry: new Cesium.FrustumOutlineGeometry({
333
+ // frustum: this.lightCamera.frustum,
334
+ // origin: this._viewPositionC3,
335
+ // orientation: orientation,
336
+ // }),
337
+ // attributes: {
338
+ // color: Cesium.ColorGeometryInstanceAttribute.fromColor(
339
+ // Cesium.Color.YELLOWGREEN, //new Cesium.Color(0.0, 1.0, 0.0, 1.0)
340
+ // ),
341
+ // show: new Cesium.ShowGeometryInstanceAttribute(true),
342
+ // },
343
+ // });
344
+ //
345
+ // this.frustumOutline = this.getMap().scene.primitives.add(
346
+ // new Cesium.Primitive({
347
+ // geometryInstances: [instance],
348
+ // appearance: new Cesium.PerInstanceColorAppearance({
349
+ // flat: true,
350
+ // translucent: false,
351
+ // }),
352
+ // }),
353
+ // );
354
+ // }
355
+ //
356
+ // //创建视网
357
+ // public drawSketch() {
358
+ // if (!this._canOperate) return;
359
+ // this.sketch = this.getMap().entities.add({
360
+ // name: 'sketch',
361
+ // position: this._viewPositionC3,
362
+ // orientation: Cesium.Transforms.headingPitchRollQuaternion(
363
+ // this._viewPositionC3,
364
+ // Cesium.HeadingPitchRoll.fromDegrees(
365
+ // this._viewHeading - this.options.horizontalViewAngle,
366
+ // this._viewPitch,
367
+ // 0.0,
368
+ // ),
369
+ // ),
370
+ // ellipsoid: {
371
+ // radii: new Cesium.Cartesian3(
372
+ // this._viewDistance,
373
+ // this._viewDistance,
374
+ // this._viewDistance,
375
+ // ),
376
+ // // innerRadii: new Cesium.Cartesian3(2.0, 2.0, 2.0),
377
+ // minimumClock: Cesium.Math.toRadians(
378
+ // -this.options.horizontalViewAngle / 2,
379
+ // ),
380
+ // maximumClock: Cesium.Math.toRadians(
381
+ // this.options.horizontalViewAngle / 2,
382
+ // ),
383
+ // minimumCone: Cesium.Math.toRadians(
384
+ // this.options.verticalViewAngle + 7.75,
385
+ // ),
386
+ // maximumCone: Cesium.Math.toRadians(
387
+ // 180 - this.options.verticalViewAngle - 7.75,
388
+ // ),
389
+ // fill: false,
390
+ // outline: true,
391
+ // subdivisions: 256,
392
+ // stackPartitions: 64,
393
+ // slicePartitions: 64,
394
+ // outlineColor: Cesium.Color.YELLOWGREEN,
395
+ // },
396
+ // });
397
+ // }
398
+ //
399
+ // public clear() {
400
+ // if (!this._canOperate) return;
401
+ // if (this.frustumOutline) {
402
+ // this.frustumOutline.destroy();
403
+ // this.frustumOutline = null;
404
+ // }
405
+ // if (this.postStage) {
406
+ // this.getMap().scene.postProcessStages.remove(this.postStage);
407
+ // this.postStage = null;
408
+ // }
409
+ // if (this.sketch) {
410
+ // this.getMap().entities.remove(this.sketch);
411
+ // this.sketch = null;
412
+ // }
413
+ // }
414
+ //
415
+ // public destroy() {
416
+ // if (!this._canOperate) return;
417
+ // this.isDestroyed = true;
418
+ // this.clear();
419
+ // }
420
+ // }
421
+ //
422
+ // export default ViewshedAnalysis;
423
+ //
424
+ // //获取偏航角
425
+ // function getHeading(fromPosition: any, toPosition: any) {
426
+ // const finalPosition = new Cesium.Cartesian3();
427
+ // const matrix4 = Cesium.Transforms.eastNorthUpToFixedFrame(fromPosition);
428
+ // Cesium.Matrix4.inverse(matrix4, matrix4);
429
+ // Cesium.Matrix4.multiplyByPoint(matrix4, toPosition, finalPosition);
430
+ // Cesium.Cartesian3.normalize(finalPosition, finalPosition);
431
+ // return Cesium.Math.toDegrees(Math.atan2(finalPosition.x, finalPosition.y));
432
+ // }
433
+ //
434
+ // //获取俯仰角
435
+ // function getPitch(fromPosition: any, toPosition: any) {
436
+ // const finalPosition = new Cesium.Cartesian3();
437
+ // const matrix4 = Cesium.Transforms.eastNorthUpToFixedFrame(fromPosition);
438
+ // Cesium.Matrix4.inverse(matrix4, matrix4);
439
+ // Cesium.Matrix4.multiplyByPoint(matrix4, toPosition, finalPosition);
440
+ // Cesium.Cartesian3.normalize(finalPosition, finalPosition);
441
+ // return Cesium.Math.toDegrees(Math.asin(finalPosition.z));
442
+ // }
@@ -146,7 +146,20 @@ export declare const DEFAULT_SUN_ANALYSIS_OPTIONS: () => {
146
146
  clockRange: Cesium.ClockRange;
147
147
  clockStep: Cesium.ClockStep;
148
148
  };
149
- export declare const DEFAULT_VIEWSHED_ANALYSIS_OPTIONS: () => {};
149
+ export declare const DEFAULT_VIEWSHED_ANALYSIS_OPTIONS: () => {
150
+ viewPosition: null;
151
+ viewPositionEnd: null;
152
+ viewDistance: number;
153
+ viewHeading: number;
154
+ viewPitch: number;
155
+ horizontalViewAngle: number;
156
+ verticalViewAngle: number;
157
+ visibleAreaColor: Cesium.Color;
158
+ invisibleAreaColor: Cesium.Color;
159
+ enabled: boolean;
160
+ softShadows: boolean;
161
+ size: number;
162
+ };
150
163
  export declare const DEFAULT_BASE_LAYER_TYPE: any;
151
164
  export declare const DEFAULT_BASE_LAYER: any;
152
165
  export declare const LAYER_TYPE_TO_CLASS: any;
@@ -235,7 +235,31 @@ export var DEFAULT_SUN_ANALYSIS_OPTIONS = function DEFAULT_SUN_ANALYSIS_OPTIONS(
235
235
 
236
236
  // 默认可视域分析
237
237
  export var DEFAULT_VIEWSHED_ANALYSIS_OPTIONS = function DEFAULT_VIEWSHED_ANALYSIS_OPTIONS() {
238
- return {};
238
+ return {
239
+ viewPosition: null,
240
+ // 观测点位置
241
+ viewPositionEnd: null,
242
+ // 最远观测点位置 (如果设置了观测距离,这个属性可以不设置
243
+ viewDistance: 100,
244
+ // 观测距离
245
+ viewHeading: 0.0,
246
+ // 航向角
247
+ viewPitch: 0.0,
248
+ // 俯仰角
249
+ horizontalViewAngle: 90.0,
250
+ // 可视域水平夹角
251
+ verticalViewAngle: 60.0,
252
+ // 可视域垂直夹角
253
+ visibleAreaColor: Cesium.Color.GREEN,
254
+ // 可视区域颜色(默认值`绿色`)。
255
+ invisibleAreaColor: Cesium.Color.RED,
256
+ // 不可视区域颜色(默认值`红色`)。
257
+ enabled: true,
258
+ // 阴影贴图是否可用
259
+ softShadows: true,
260
+ // 是否启用柔和阴影
261
+ size: 2048 // 每个阴影贴图的大小
262
+ };
239
263
  };
240
264
 
241
265
  // 默认的底图类型
@@ -57,7 +57,6 @@ var DeepTwins = /*#__PURE__*/function () {
57
57
  moduleLayer: this._getModuleLayer.bind(this),
58
58
  trafficHistoryLayer: this._YunJing.TrafficHistoryLayer,
59
59
  trafficLayer: this._YunJing.TrafficLayer,
60
- // 优先从 YunjingCesiumPlugins 获取 GridVTLayer(与示例代码一致)
61
60
  gridVTLayer: (_this$_YunjingCesiumP = this._YunjingCesiumPlugins) === null || _this$_YunjingCesiumP === void 0 ? void 0 : _this$_YunjingCesiumP.GridVTLayer
62
61
  });
63
62
  }
package/dist/esm/index.js CHANGED
@@ -9,6 +9,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
9
9
  import * as Cesium from 'deeptwins-cesium';
10
10
  import SubmergenceAnalysis from "./analyze/SubmergenceAnalysis";
11
11
  import SunLightAnalysis from "./analyze/SunLightAnalysis";
12
+ // import ViewshedAnalysis from './analyze/ViewshedAnalysis';
12
13
  import ModelRoamHistory from "./cameraControl/ModelRoamHistory";
13
14
  import ModelRoamRealTime from "./cameraControl/ModelRoamRealTime";
14
15
  import Roam from "./cameraControl/Roam";
@@ -53,11 +54,11 @@ DEEP_TWINS_BASE_URL && (window.CESIUM_BASE_URL = DEEP_TWINS_BASE_URL);
53
54
  // 全局加载css
54
55
  loadCss(Cesium.buildModuleUrl('Widgets/widgets.css'));
55
56
  // 打印版本信息
56
- console.log('DeepTwinsEngine3D Version:', "0.1.40");
57
+ console.log('DeepTwinsEngine3D Version:', "0.1.41");
57
58
  export var DeepTwinsEngine3D = /*#__PURE__*/_createClass(function DeepTwinsEngine3D() {
58
59
  _classCallCheck(this, DeepTwinsEngine3D);
59
60
  });
60
- _defineProperty(DeepTwinsEngine3D, "Version", "0.1.40");
61
+ _defineProperty(DeepTwinsEngine3D, "Version", "0.1.41");
61
62
  _defineProperty(DeepTwinsEngine3D, "Map", Map);
62
63
  _defineProperty(DeepTwinsEngine3D, "GroundSkyBox", GroundSkyBox);
63
64
  _defineProperty(DeepTwinsEngine3D, "RasterLayer", RasterLayer);
@@ -65,11 +65,9 @@ export default class Map extends Cesium.Viewer implements MapContext {
65
65
  addTerrainUrl(url: string): Promise<unknown>;
66
66
  addTerrain(terrain: any): Promise<unknown>;
67
67
  resetTerrain(): void;
68
- showModuleLayer(isShow: boolean): void;
69
68
  addEffect(effect: any): void;
70
69
  removeEffect(effect: any): void;
71
70
  on(type: any, event: any): any;
72
71
  addModuleLayer: (moduleLayer: any) => any;
73
- pickMonomer(data: any): any;
74
72
  destroy(): void;
75
73
  }
@@ -74,7 +74,7 @@ var Map = /*#__PURE__*/function (_Cesium$Viewer) {
74
74
  _defineProperty(_assertThisInitialized(_this), "_defaultSkybox", null);
75
75
  // 近地天空盒监听
76
76
  _defineProperty(_assertThisInitialized(_this), "_handleSkyBox", null);
77
- // 云镜
77
+ // 云镜模型实例
78
78
  _defineProperty(_assertThisInitialized(_this), "_yunjing", void 0);
79
79
  // 事件
80
80
  _defineProperty(_assertThisInitialized(_this), "_event", void 0);
@@ -658,14 +658,6 @@ var Map = /*#__PURE__*/function (_Cesium$Viewer) {
658
658
  this.scene.terrainProvider = new Cesium.EllipsoidTerrainProvider({});
659
659
  }
660
660
 
661
- // 隐藏模型
662
- }, {
663
- key: "showModuleLayer",
664
- value: function showModuleLayer(isShow) {
665
- if (!this._yunjing) return;
666
- isShow ? this._yunjing.show() : this._yunjing.hide();
667
- }
668
-
669
661
  // 添加特效
670
662
  }, {
671
663
  key: "addEffect",
@@ -695,20 +687,10 @@ var Map = /*#__PURE__*/function (_Cesium$Viewer) {
695
687
  }
696
688
  }
697
689
  }, {
698
- key: "pickMonomer",
690
+ key: "destroy",
699
691
  value:
700
- // 拾取单体
701
- function pickMonomer(data) {
702
- if (!this._yunjing) {
703
- throw new Error('请先加载模型');
704
- }
705
- return this._yunjing.pickMonomer(data);
706
- }
707
-
708
692
  // 销毁
709
- }, {
710
- key: "destroy",
711
- value: function destroy() {
693
+ function destroy() {
712
694
  this._eventTrick.forEach(function (t) {
713
695
  t.off();
714
696
  });
@@ -13,14 +13,15 @@
13
13
  * ```
14
14
  */
15
15
  export default class BarrierLayer {
16
+ private readonly _mapContext;
17
+ isDestroyed: boolean;
16
18
  private _gridVTLayer;
17
- private _viewer;
18
19
  private _options;
19
20
  private _heightColors;
20
21
  private static readonly DEFAULT_HEIGHT_COLORS;
21
22
  /**
22
23
  * 创建障碍物图层
23
- * @param viewer Cesium Viewer实例
24
+ * @param map Cesium Viewer实例
24
25
  * @param options 配置选项
25
26
  * @param options.gridVTLayer GridVTLayer类(从DeepTwins.onLoad中获取)
26
27
  * @param options.url MVT数据URL模板,默认为障碍物数据地址
@@ -32,7 +33,9 @@ export default class BarrierLayer {
32
33
  * @param options.minHeight 最小高度(米),低于此高度的障碍物不渲染,默认0
33
34
  * @param options.maxHeight 最大高度(米),高于此高度的障碍物不渲染,默认Infinity
34
35
  */
35
- constructor(viewer: any, options?: any);
36
+ constructor(map: any, options?: any);
37
+ private _canOperate;
38
+ getMap(): any;
36
39
  /**
37
40
  * 创建primitives
38
41
  * 按照示例代码的逻辑实现,每个feature创建一个障碍物实例