deeptwins-engine-3d 0.1.52 → 0.1.53

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.
@@ -1,2 +1,3 @@
1
1
  import ViewShedAnalyserLayer from './viewShed/ViewShedAnalyserLayer';
2
- export { ViewShedAnalyserLayer };
2
+ import VolumeClouds from './volumeCloud/VolumeClouds';
3
+ export { ViewShedAnalyserLayer, VolumeClouds };
@@ -1,2 +1,3 @@
1
1
  import ViewShedAnalyserLayer from "./viewShed/ViewShedAnalyserLayer";
2
- export { ViewShedAnalyserLayer };
2
+ import VolumeClouds from "./volumeCloud/VolumeClouds";
3
+ export { ViewShedAnalyserLayer, VolumeClouds };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Custom Primitive for Geometry
3
+ */
4
+ declare class GeometryPrimitive {
5
+ /**
6
+ *
7
+ * @param {*} options
8
+ * @param {*} options.modelMatrix
9
+ * @param {*} options.vertexShaderSource
10
+ * @param {*} options.fragmentShaderSource
11
+ * @param {*} options.uniformMap
12
+ * @param {*} options.renderState
13
+ * @param {*} options.pass
14
+ */
15
+ private options;
16
+ private geometry;
17
+ private _drawCommand;
18
+ private _boundingSphereWC;
19
+ constructor(geometry: any, options: any);
20
+ /**
21
+ *
22
+ * @param {*} frameState
23
+ */
24
+ update(frameState: any): void;
25
+ destroy(): void;
26
+ isDestroyed(): boolean;
27
+ }
28
+ export default GeometryPrimitive;
@@ -0,0 +1,89 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
6
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
7
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ import * as Cesium from 'deeptwins-cesium';
11
+ /**
12
+ * Custom Primitive for Geometry
13
+ */
14
+ var GeometryPrimitive = /*#__PURE__*/function () {
15
+ function GeometryPrimitive(geometry, options) {
16
+ _classCallCheck(this, GeometryPrimitive);
17
+ /**
18
+ *
19
+ * @param {*} options
20
+ * @param {*} options.modelMatrix
21
+ * @param {*} options.vertexShaderSource
22
+ * @param {*} options.fragmentShaderSource
23
+ * @param {*} options.uniformMap
24
+ * @param {*} options.renderState
25
+ * @param {*} options.pass
26
+ */
27
+ _defineProperty(this, "options", void 0);
28
+ _defineProperty(this, "geometry", void 0);
29
+ _defineProperty(this, "_drawCommand", void 0);
30
+ _defineProperty(this, "_boundingSphereWC", void 0);
31
+ this.options = options;
32
+ this.geometry = geometry;
33
+ }
34
+
35
+ /**
36
+ *
37
+ * @param {*} frameState
38
+ */
39
+ _createClass(GeometryPrimitive, [{
40
+ key: "update",
41
+ value: function update(frameState) {
42
+ if (Cesium.defined(this._drawCommand)) {
43
+ frameState.commandList.push(this._drawCommand);
44
+ return;
45
+ }
46
+ if (this.geometry.constructor.createGeometry) {
47
+ this.geometry = this.geometry.constructor.createGeometry(this.geometry);
48
+ }
49
+ var context = frameState.context;
50
+ var attributeLocations = Cesium.GeometryPipeline.createAttributeLocations(this.geometry);
51
+ var vertexArray = Cesium.VertexArray.fromGeometry({
52
+ context: context,
53
+ geometry: this.geometry,
54
+ attributeLocations: attributeLocations
55
+ });
56
+
57
+ // calculate boundingSphere
58
+ var boundingSphere = this.geometry.boundingSphere;
59
+ boundingSphere.center = Cesium.Matrix4.multiplyByPoint(this.options.modelMatrix, boundingSphere.center, new Cesium.Cartesian3());
60
+ boundingSphere.radius = 1000000;
61
+ this._boundingSphereWC = [boundingSphere];
62
+ var shaderProgram = Cesium.ShaderProgram.fromCache({
63
+ context: context,
64
+ attributeLocations: attributeLocations,
65
+ vertexShaderSource: this.options.vertexShaderSource,
66
+ fragmentShaderSource: this.options.fragmentShaderSource
67
+ });
68
+ this._drawCommand = new Cesium.DrawCommand(_objectSpread({
69
+ owner: this,
70
+ boundingVolume: boundingSphere,
71
+ primitiveType: this.geometry.primitiveType,
72
+ vertexArray: vertexArray,
73
+ shaderProgram: shaderProgram
74
+ }, this.options));
75
+ }
76
+ }, {
77
+ key: "destroy",
78
+ value: function destroy() {
79
+ return Cesium.destroyObject(this);
80
+ }
81
+ }, {
82
+ key: "isDestroyed",
83
+ value: function isDestroyed() {
84
+ return false;
85
+ }
86
+ }]);
87
+ return GeometryPrimitive;
88
+ }();
89
+ export default GeometryPrimitive;
@@ -0,0 +1,15 @@
1
+ declare class ImprovedNoise {
2
+ makeTexture3D(context: any): any;
3
+ /**
4
+ * Returns a noise value for the given parameters.
5
+ *
6
+ * @param {number} x - The x coordinate.
7
+ * @param {number} y - The y coordinate.
8
+ * @param {number} z - The z coordinate.
9
+ * @return {number} The noise value.
10
+ */
11
+ noise(x: number, y: number, z: number): number;
12
+ fade(t: number): number;
13
+ grad(hash: number, x: number, y: number, z: number): number;
14
+ }
15
+ export default ImprovedNoise;
@@ -0,0 +1,112 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
4
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import * as Cesium from 'deeptwins-cesium';
8
+ var lerp = Cesium.Math.lerp;
9
+ var _p = [151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244, 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196, 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123, 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9, 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228, 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107, 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254, 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180];
10
+ for (var i = 0; i < 256; i++) {
11
+ _p[256 + i] = _p[i];
12
+ }
13
+ var ImprovedNoise = /*#__PURE__*/function () {
14
+ function ImprovedNoise() {
15
+ _classCallCheck(this, ImprovedNoise);
16
+ }
17
+ _createClass(ImprovedNoise, [{
18
+ key: "makeTexture3D",
19
+ value: function makeTexture3D(context) {
20
+ var size = 100;
21
+ var dataLength = size * size * size;
22
+ var data = new Uint8Array(dataLength);
23
+ var i = 0;
24
+ var scale = 0.05;
25
+ var perlin = new ImprovedNoise();
26
+ var vector = new Cesium.Cartesian3();
27
+ var halfSize = Cesium.Cartesian3.fromElements(size / 2, size / 2, size / 2, new Cesium.Cartesian3());
28
+ for (var z = 0; z < size; z++) {
29
+ for (var y = 0; y < size; y++) {
30
+ for (var x = 0; x < size; x++) {
31
+ vector = Cesium.Cartesian3.fromElements(x, y, z, vector);
32
+ vector = Cesium.Cartesian3.subtract(vector, halfSize, vector);
33
+ vector = Cesium.Cartesian3.divideByScalar(vector, size, vector);
34
+ var d = 1.0 - Cesium.Cartesian3.magnitude(vector);
35
+ var tv = (128 + 128 * perlin.noise(x * scale / 1.5, y * scale, z * scale / 1.5)) * d * d;
36
+ data[i] = tv;
37
+ i++;
38
+ }
39
+ }
40
+ }
41
+ return new Cesium.Texture3D({
42
+ context: context,
43
+ width: size,
44
+ height: size,
45
+ depth: size,
46
+ flipY: false,
47
+ pixelFormat: Cesium.PixelFormat.RED,
48
+ pixelDatatype: Cesium.PixelDatatype.UNSIGNED_BYTE,
49
+ source: {
50
+ arrayBufferView: data,
51
+ width: size,
52
+ height: size,
53
+ depth: size
54
+ },
55
+ sampler: new Cesium.Sampler({
56
+ minificationFilter: Cesium.TextureMinificationFilter.LINEAR,
57
+ magnificationFilter: Cesium.TextureMagnificationFilter.LINEAR
58
+ })
59
+ });
60
+ }
61
+
62
+ /**
63
+ * Returns a noise value for the given parameters.
64
+ *
65
+ * @param {number} x - The x coordinate.
66
+ * @param {number} y - The y coordinate.
67
+ * @param {number} z - The z coordinate.
68
+ * @return {number} The noise value.
69
+ */
70
+ }, {
71
+ key: "noise",
72
+ value: function noise(x, y, z) {
73
+ var floorX = Math.floor(x);
74
+ var floorY = Math.floor(y);
75
+ var floorZ = Math.floor(z);
76
+ var X = floorX & 255;
77
+ var Y = floorY & 255;
78
+ var Z = floorZ & 255;
79
+ x -= floorX;
80
+ y -= floorY;
81
+ z -= floorZ;
82
+ var xMinus1 = x - 1;
83
+ var yMinus1 = y - 1;
84
+ var zMinus1 = z - 1;
85
+ var u = this.fade(x);
86
+ var v = this.fade(y);
87
+ var w = this.fade(z);
88
+ var A = _p[X] + Y;
89
+ var AA = _p[A] + Z;
90
+ var AB = _p[A + 1] + Z;
91
+ var B = _p[X + 1] + Y;
92
+ var BA = _p[B] + Z;
93
+ var BB = _p[B + 1] + Z;
94
+ return lerp(lerp(lerp(this.grad(_p[AA], x, y, z), this.grad(_p[BA], xMinus1, y, z), u), lerp(this.grad(_p[AB], x, yMinus1, z), this.grad(_p[BB], xMinus1, yMinus1, z), u), v), lerp(lerp(this.grad(_p[AA + 1], x, y, zMinus1), this.grad(_p[BA + 1], xMinus1, y, zMinus1), u), lerp(this.grad(_p[AB + 1], x, yMinus1, zMinus1), this.grad(_p[BB + 1], xMinus1, yMinus1, zMinus1), u), v), w);
95
+ }
96
+ }, {
97
+ key: "fade",
98
+ value: function fade(t) {
99
+ return t * t * t * (t * (t * 6 - 15) + 10);
100
+ }
101
+ }, {
102
+ key: "grad",
103
+ value: function grad(hash, x, y, z) {
104
+ var h = hash & 15;
105
+ var u = h < 8 ? x : y;
106
+ var v = h < 4 ? y : h === 12 || h === 14 ? x : z;
107
+ return ((h & 1) === 0 ? u : -u) + ((h & 2) === 0 ? v : -v);
108
+ }
109
+ }]);
110
+ return ImprovedNoise;
111
+ }();
112
+ export default ImprovedNoise;
@@ -0,0 +1,4 @@
1
+ declare class VolumeClouds {
2
+ constructor(map: any);
3
+ }
4
+ export default VolumeClouds;
@@ -0,0 +1,91 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
5
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7
+ import * as Cesium from 'deeptwins-cesium';
8
+ import GeometryPrimitive from "./GeometryPrimitive";
9
+ import ImprovedNoise from "./ImprovedNoise";
10
+ var vertexShader = /* glsl */"\nin vec3 position3DHigh;\nin vec3 position3DLow;\nin vec3 normal;\nin vec2 st;\nin float batchId;\n\nout vec3 vOrigin;\nout vec3 vDirection;\nout vec3 vPosition;\n\nvec4 translateRelativeToEye(vec3 high, vec3 low) {\n vec3 highDifference = high - czm_encodedCameraPositionMCHigh;\n if(length(highDifference) == 0.0f) {\n highDifference = vec3(0);\n }\n vec3 lowDifference = low - czm_encodedCameraPositionMCLow;\n return vec4(highDifference + lowDifference, 1.0f);\n}\n\nvoid main()\n{\n vec4 p = translateRelativeToEye(position3DHigh, position3DLow);\n \n vOrigin = czm_encodedCameraPositionMCHigh + czm_encodedCameraPositionMCLow;\n\n vec3 modelPosition = position3DHigh + position3DLow;\n vPosition = modelPosition;\n\n vDirection = modelPosition - vOrigin;\n\n gl_Position = czm_modelViewProjectionRelativeToEye * p;\n}";
11
+ var fragmentShader = /* glsl */"\nprecision highp float;\nprecision highp sampler3D;\n\nin vec3 vOrigin;\nin vec3 vDirection;\n\n// https://github.com/mrdoob/three.js/blob/dev/examples/webgl_volume_cloud.html\nuniform vec3 base;\nuniform sampler3D map;\n uniform float threshold;\n uniform float range;\n uniform float opacity;\n uniform float steps;\n uniform float frame;\n\n uint wang_hash(uint seed)\n {\n seed = (seed ^ 61u) ^ (seed >> 16u);\n seed *= 9u;\n seed = seed ^ (seed >> 4u);\n seed *= 0x27d4eb2du;\n seed = seed ^ (seed >> 15u);\n return seed;\n }\n\n float randomFloat(inout uint seed)\n {\n return float(wang_hash(seed)) / 4294967296.;\n }\n\n vec2 hitBox( vec3 orig, vec3 dir ) {\n const vec3 box_min = vec3( - 0.5 );\n const vec3 box_max = vec3( 0.5 );\n vec3 inv_dir = 1.0 / dir;\n vec3 tmin_tmp = ( box_min - orig ) * inv_dir;\n vec3 tmax_tmp = ( box_max - orig ) * inv_dir;\n vec3 tmin = min( tmin_tmp, tmax_tmp );\n vec3 tmax = max( tmin_tmp, tmax_tmp );\n float t0 = max( tmin.x, max( tmin.y, tmin.z ) );\n float t1 = min( tmax.x, min( tmax.y, tmax.z ) );\n return vec2( t0, t1 );\n }\n\n float sample1( vec3 p ) {\n return texture( map, p ).r;\n }\n\n float shading( vec3 coord ) {\n float step = 0.01;\n return sample1( coord + vec3( - step ) ) - sample1( coord + vec3( step ) );\n }\n\n vec4 linearToSRGB( in vec4 value ) {\n return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n }\n\nvoid main() {\n vec3 rayDir = normalize( vDirection );\n vec2 bounds = hitBox( vOrigin, rayDir );\n if ( bounds.x > bounds.y ) discard;\n bounds.x = max( bounds.x, 0.0 );\n vec3 p = vOrigin + bounds.x * rayDir;\n vec3 inc = 1.0 / abs( rayDir );\n float delta = min( inc.x, min( inc.y, inc.z ) );\n delta /= steps;\n\n // Nice little seed from\n // https://blog.demofox.org/2020/05/25/casual-shadertoy-path-tracing-1-basic-camera-diffuse-emissive/\n uint seed = uint( gl_FragCoord.x ) * uint( 1973 ) + uint( gl_FragCoord.y ) * uint( 9277 ) + uint( frame ) * uint( 26699 );\n vec3 size = vec3( textureSize( map, 0 ) );\n float randNum = randomFloat( seed ) * 2.0 - 1.0;\n p += rayDir * randNum * ( 1.0 / size );\n\n vec4 ac = vec4( base, 0.0 );\n for ( float t = bounds.x; t < bounds.y; t += delta ) {\n float d = sample1( p + 0.5 );\n d = smoothstep( threshold - range, threshold + range, d ) * opacity;\n float col = shading( p + 0.5 ) * 3.0 + ( ( p.x + p.y ) * 0.25 ) + 0.2;\n ac.rgb += ( 1.0 - ac.a ) * d * col;\n ac.a += ( 1.0 - ac.a ) * d;\n if ( ac.a >= 0.95 ) break;\n p += rayDir * delta;\n }\n vec4 color = linearToSRGB( ac );\n color = czm_gammaCorrect( color );\n if ( color.a == 0.0 ) discard;\n out_FragColor = color;\n}\n";
12
+ var VolumeClouds = /*#__PURE__*/_createClass(function VolumeClouds(map) {
13
+ _classCallCheck(this, VolumeClouds);
14
+ var texture3D = new ImprovedNoise().makeTexture3D(map.scene.context);
15
+ texture3D.generateMipmap();
16
+ var boxSideLength = 1.0;
17
+ var zoomScale = 10000;
18
+ var centerPoint = Cesium.Cartesian3.fromDegrees(113, 33, boxSideLength / 0.5 * zoomScale);
19
+ var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(centerPoint);
20
+ var boxSize = new Cesium.Cartesian3(boxSideLength, boxSideLength, boxSideLength);
21
+ var renderState = Cesium.RenderState.fromCache({
22
+ depthMask: false,
23
+ blending: {
24
+ enabled: true,
25
+ color: {
26
+ red: 0.0,
27
+ green: 0.0,
28
+ blue: 0.0,
29
+ alpha: 0.0
30
+ }
31
+ },
32
+ depthTest: {
33
+ enabled: true,
34
+ func: Cesium.DepthFunction.LESS_OR_EQUAL
35
+ },
36
+ cull: {
37
+ enabled: true,
38
+ face: Cesium.CullFace.FRONT
39
+ }
40
+ });
41
+ var zoomMat = Cesium.Matrix4.fromScale(new Cesium.Cartesian3(zoomScale, zoomScale, zoomScale), new Cesium.Matrix4());
42
+ Cesium.Matrix4.multiply(modelMatrix, zoomMat, modelMatrix);
43
+ var halfBox = Cesium.Cartesian3.multiplyByScalar(boxSize, 0.5, new Cesium.Cartesian3());
44
+ var negHalfBox = Cesium.Cartesian3.negate(halfBox, new Cesium.Cartesian3());
45
+ var boxGeometry = new Cesium.BoxGeometry({
46
+ minimum: negHalfBox,
47
+ maximum: halfBox
48
+ });
49
+ var uniforms = {
50
+ base: new Cesium.Color(0.1912, 0.2542, 0.3515, 0),
51
+ map: texture3D,
52
+ opacity: 0.25,
53
+ range: 0.1,
54
+ steps: 100,
55
+ frame: 0,
56
+ threshold: 0.25
57
+ };
58
+ var cmdUniforms = {};
59
+ var _loop = function _loop(key) {
60
+ if (key) {
61
+ cmdUniforms[key] = function () {
62
+ return uniforms[key];
63
+ };
64
+ }
65
+ };
66
+ for (var key in uniforms) {
67
+ _loop(key);
68
+ }
69
+ var primitive = new GeometryPrimitive(boxGeometry, {
70
+ uniformMap: cmdUniforms,
71
+ vertexShaderSource: vertexShader,
72
+ fragmentShaderSource: fragmentShader,
73
+ renderState: renderState,
74
+ modelMatrix: modelMatrix,
75
+ pass: Cesium.Pass.TRANSLUCENT
76
+ });
77
+ map.scene.primitives.add(primitive);
78
+ var cameraState = {
79
+ destination: centerPoint,
80
+ orientation: {
81
+ heading: 4.159717744111784,
82
+ pitch: -0.4648127266675117,
83
+ roll: boxSideLength * zoomScale * 2
84
+ },
85
+ duration: 0
86
+ };
87
+ // viewer.camera.flyTo(camState);
88
+ var hpr = new Cesium.HeadingPitchRange(cameraState.orientation.heading, cameraState.orientation.pitch, boxSideLength * zoomScale * 2);
89
+ map.camera.lookAt(cameraState.destination, hpr);
90
+ });
91
+ export default VolumeClouds;
@@ -15,7 +15,7 @@ export default class BaseSource {
15
15
  remove(): void;
16
16
  setData(data: any): this | undefined;
17
17
  _toDestroy(): void;
18
- static analysisSourceType(data: any): "wkt" | "sourceId" | "sourceInstance" | "geoJson" | "clampedPolygonGrid" | "other";
18
+ static analysisSourceType(data: any): "other" | "wkt" | "sourceId" | "sourceInstance" | "geoJson" | "clampedPolygonGrid";
19
19
  static wktToGeoJon(wkt: string): any;
20
20
  static geoJsonToGeoCartesian3Array(geoJson: any): any[];
21
21
  static handleFeaturePoint(feature: any): any;
@@ -72,5 +72,6 @@ export declare class DeepTwinsEngine3D {
72
72
  static FlightRiskEvaluation: any;
73
73
  static BuildClampedPolygonGridUnified: any;
74
74
  static ViewShedAnalyserLayer: any;
75
+ static VolumeClouds: any;
75
76
  }
76
77
  export default DeepTwinsEngine3D;
package/dist/esm/index.js CHANGED
@@ -54,18 +54,18 @@ import Heatmap2d from "./visualization/Heatmap2d";
54
54
  import Heatmap3d from "./visualization/Heatmap3d";
55
55
  import PointCluster from "./visualization/PointCluster";
56
56
  // drawCommand
57
- import { ViewShedAnalyserLayer } from "./drawCommand";
57
+ import { ViewShedAnalyserLayer, VolumeClouds } from "./drawCommand";
58
58
  window.Cesium = Cesium;
59
59
  // 将DEEP_TWINS_BASE_URL赋值给CESIUM_BASE_URL
60
60
  DEEP_TWINS_BASE_URL && (window.CESIUM_BASE_URL = DEEP_TWINS_BASE_URL);
61
61
  // 全局加载css
62
62
  loadCss(Cesium.buildModuleUrl('Widgets/widgets.css'));
63
63
  // 打印版本信息
64
- console.log('DeepTwinsEngine3D Version:', "0.1.52");
64
+ console.log('DeepTwinsEngine3D Version:', "0.1.53");
65
65
  export var DeepTwinsEngine3D = /*#__PURE__*/_createClass(function DeepTwinsEngine3D() {
66
66
  _classCallCheck(this, DeepTwinsEngine3D);
67
67
  });
68
- _defineProperty(DeepTwinsEngine3D, "Version", "0.1.52");
68
+ _defineProperty(DeepTwinsEngine3D, "Version", "0.1.53");
69
69
  _defineProperty(DeepTwinsEngine3D, "Map", Map);
70
70
  _defineProperty(DeepTwinsEngine3D, "GroundSkyBox", GroundSkyBox);
71
71
  _defineProperty(DeepTwinsEngine3D, "RasterLayer", RasterLayer);
@@ -137,4 +137,5 @@ _defineProperty(DeepTwinsEngine3D, "FlightPlanning", FlightPlanning);
137
137
  _defineProperty(DeepTwinsEngine3D, "FlightRiskEvaluation", FlightRiskEvaluation);
138
138
  _defineProperty(DeepTwinsEngine3D, "BuildClampedPolygonGridUnified", BuildClampedPolygonGridUnified);
139
139
  _defineProperty(DeepTwinsEngine3D, "ViewShedAnalyserLayer", ViewShedAnalyserLayer);
140
+ _defineProperty(DeepTwinsEngine3D, "VolumeClouds", VolumeClouds);
140
141
  export default DeepTwinsEngine3D;