deeptwins-engine-3d 0.1.48 → 0.1.50

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.
Files changed (40) hide show
  1. package/dist/esm/constant.d.ts +9 -0
  2. package/dist/esm/constant.js +18 -0
  3. package/dist/esm/drawCommand/index.d.ts +2 -0
  4. package/dist/esm/drawCommand/index.js +2 -0
  5. package/dist/esm/drawCommand/viewShed/Event.d.ts +42 -0
  6. package/dist/esm/drawCommand/viewShed/Event.js +142 -0
  7. package/dist/esm/drawCommand/viewShed/RectangularSensorPrimitive.d.ts +266 -0
  8. package/dist/esm/drawCommand/viewShed/RectangularSensorPrimitive.js +1271 -0
  9. package/dist/esm/drawCommand/viewShed/ViewShadowPrimitive.d.ts +29 -0
  10. package/dist/esm/drawCommand/viewShed/ViewShadowPrimitive.js +66 -0
  11. package/dist/esm/drawCommand/viewShed/ViewShedAnalyserLayer.d.ts +182 -0
  12. package/dist/esm/drawCommand/viewShed/ViewShedAnalyserLayer.js +466 -0
  13. package/dist/esm/drawCommand/viewShed/ViewShedMap.d.ts +22 -0
  14. package/dist/esm/drawCommand/viewShed/ViewShedMap.js +1238 -0
  15. package/dist/esm/drawCommand/viewShed/config.d.ts +20 -0
  16. package/dist/esm/drawCommand/viewShed/config.js +21 -0
  17. package/dist/esm/graphicLayer/BaseLayer.js +3 -0
  18. package/dist/esm/graphicLayer/BasePrimitiveInstance.d.ts +2 -0
  19. package/dist/esm/graphicLayer/BasePrimitiveInstance.js +13 -5
  20. package/dist/esm/graphicLayer/BaseSource.d.ts +1 -1
  21. package/dist/esm/graphicLayer/BaseSource.js +6 -0
  22. package/dist/esm/graphicLayer/PolygonGroundPrimitiveImageMaterialInstance.d.ts +5 -0
  23. package/dist/esm/graphicLayer/PolygonGroundPrimitiveImageMaterialInstance.js +84 -0
  24. package/dist/esm/graphicLayer/PolygonPrimitiveImageMaterialInstance.js +7 -1
  25. package/dist/esm/graphicLayer/PolylineGroundPrimitiveInstance.js +1 -1
  26. package/dist/esm/index.d.ts +2 -0
  27. package/dist/esm/index.js +7 -2
  28. package/dist/esm/map/Map.js +2 -2
  29. package/dist/esm/material/primitive/ImageMaterialAppearance.d.ts +1 -1
  30. package/dist/esm/tool/BuildClampedPolygonGrid.d.ts +4 -0
  31. package/dist/esm/tool/BuildClampedPolygonGrid.js +273 -0
  32. package/dist/esm/tool/utils.d.ts +9 -0
  33. package/dist/esm/tool/utils.js +50 -0
  34. package/dist/esm/videoFusion/BaseVideo.js +17 -17
  35. package/dist/esm/videoFusion/VideoProject.d.ts +5 -5
  36. package/dist/esm/videoFusion/VideoProject.js +174 -184
  37. package/dist/esm/videoFusion/VideoTexture.d.ts +5 -1
  38. package/dist/esm/videoFusion/VideoTexture.js +133 -46
  39. package/dist/umd/deeptwins-engine-3d.min.js +1 -1
  40. package/package.json +5 -3
@@ -0,0 +1,20 @@
1
+ /**
2
+ * 公共着色器
3
+ * @returns {ShaderSource}
4
+ */
5
+ export declare const sensorComm = "\nuniform vec4 u_intersectionColor;\nuniform float u_intersectionWidth;\nuniform vec4 u_lineColor;\n\nbool inSensorShadow(vec3 coneVertexWC, vec3 pointWC)\n{ \n // Diagonal matrix from the unscaled ellipsoid space to the scaled space.\n vec3 D = czm_ellipsoidInverseRadii; \n // Sensor vertex in the scaled ellipsoid space \n vec3 q = D * coneVertexWC; \n float qMagnitudeSquared = dot(q, q); \n float test = qMagnitudeSquared - 1.0; \n // Sensor vertex to fragment vector in the ellipsoid's scaled space \n vec3 temp = D * pointWC - q; \n float d = dot(temp, q); \n // Behind silhouette plane and inside silhouette cone \n return (d < -test) && (d / length(temp) < -sqrt(test));\n}\n\nvec4 getLineColor()\n{ \n return u_lineColor;\n}\n\nvec4 getIntersectionColor()\n{ \n return u_intersectionColor;\n}\n\nfloat getIntersectionWidth()\n{ \n return u_intersectionWidth;\n}\n\nvec2 sensor2dTextureCoordinates(float sensorRadius, vec3 pointMC)\n{ \n // (s, t) both in the range [0, 1] \n float t = pointMC.z / sensorRadius; \n float s = 1.0 + (atan(pointMC.y, pointMC.x) / czm_twoPi); \n s = s - floor(s); \n return vec2(s, t);\n}\n\n";
6
+ /**
7
+ * VS着色器
8
+ * @returns {ShaderSource}
9
+ */
10
+ export declare const sensorVS = "\nin vec4 position;\nin vec3 normal;\nout vec3 v_position;\nout vec3 v_positionWC;\nout vec3 v_positionEC;\nout vec3 v_normalEC;\nvoid main()\n{ \n gl_Position = czm_modelViewProjection * position; \n v_position = vec3(position); \n v_positionWC = (czm_model * position).xyz; \n v_positionEC = (czm_modelView * position).xyz; \n v_normalEC = czm_normal * normal;\n}";
11
+ /**
12
+ * FS着色器
13
+ * @returns {ShaderSource}
14
+ */
15
+ export declare const sensorFS = "\nuniform bool u_showIntersection;\nuniform bool u_showThroughEllipsoid;\nuniform float u_radius;\nuniform float u_xHalfAngle;\nuniform float u_yHalfAngle;\nuniform float u_normalDirection;\nuniform float u_type;\nin vec3 v_position;\nin vec3 v_positionWC;\nin vec3 v_positionEC;\nin vec3 v_normalEC;\nvec4 getColor(float sensorRadius, vec3 pointEC)\n{ \n czm_materialInput materialInput; \n vec3 pointMC = (czm_inverseModelView * vec4(pointEC, 1.0)).xyz; \n materialInput.st = sensor2dTextureCoordinates(sensorRadius, pointMC); \n materialInput.str = pointMC / sensorRadius; \n\n vec3 positionToEyeEC = -v_positionEC; \n materialInput.positionToEyeEC = positionToEyeEC; \n\n vec3 normalEC = normalize(v_normalEC); \n materialInput.normalEC = u_normalDirection * normalEC; \n\n czm_material material = czm_getMaterial(materialInput); \n\n return mix(czm_phong(normalize(positionToEyeEC), material,czm_lightDirectionEC),vec4(material.diffuse, material.alpha), 0.4);\n}\n\nbool isOnBoundary(float value, float epsilon)\n{ \n float width = getIntersectionWidth(); \n float tolerance = width * epsilon;\n #ifdef GL_OES_standard_derivatives \n float delta = max(abs(dFdx(value)), abs(dFdy(value))); \n float pixels = width * delta; \n float temp = abs(value); \n // There are a couple things going on here. \n // First we test the value at the current fragment to see if it is within the tolerance. \n // We also want to check if the value of an adjacent pixel is within the tolerance, \n // but we don't want to admit points that are obviously not on the surface. \n // For example, if we are looking for \"value\" to be close to 0, but value is 1 and the adjacent value is 2, \n // then the delta would be 1 and \"temp - delta\" would be \"1 - 1\" which is zero even though neither of \n // the points is close to zero. \n return temp < tolerance && temp < pixels || (delta < 10.0 * tolerance && temp - delta < tolerance && temp < pixels);\n #else \n return abs(value) < tolerance;\n #endif\n}\n\n\nvec4 shade(bool isOnBoundary)\n{ \n\n if (u_showIntersection && isOnBoundary) \n { \n return getIntersectionColor(); \n } \n if(u_type == 1.0)\n { \n return getLineColor(); \n } \n\n return getColor(u_radius, v_positionEC);\n\n}\n \nfloat ellipsoidSurfaceFunction(vec3 point)\n{ \n vec3 scaled = czm_ellipsoidInverseRadii * point; \n return dot(scaled, scaled) - 1.0;\n}\n\nvoid main()\n{ \n vec3 sensorVertexWC = czm_model[3].xyz; // (0.0, 0.0, 0.0) in model coordinates \n vec3 sensorVertexEC = czm_modelView[3].xyz; // (0.0, 0.0, 0.0) in model coordinates \n //vec3 pixDir = normalize(v_position); \n float positionX = v_position.x; \n float positionY = v_position.y; \n float positionZ = v_position.z; \n vec3 zDir = vec3(0.0, 0.0, 1.0); \n vec3 lineX = vec3(positionX, 0 ,positionZ); \n vec3 lineY = vec3(0, positionY, positionZ); \n float resX = dot(normalize(lineX), zDir); \n if(resX < cos(u_xHalfAngle)-0.00001)\n { \n discard; \n } \n float resY = dot(normalize(lineY), zDir); \n if(resY < cos(u_yHalfAngle)-0.00001)\n { \n discard; \n } \n float ellipsoidValue = ellipsoidSurfaceFunction(v_positionWC);\n // Occluded by the ellipsoid?\n if (!u_showThroughEllipsoid)\n { \n // Discard if in the ellipsoid \n // PERFORMANCE_IDEA: A coarse check for ellipsoid intersection could be done on the CPU first. \n if (ellipsoidValue < 0.0) \n { \n discard; \n } \n // Discard if in the sensor's shadow \n if (inSensorShadow(sensorVertexWC, v_positionWC)) \n { \n discard; \n } \n } \n // Notes: Each surface functions should have an associated tolerance based on the floating point error. \n bool isOnEllipsoid = isOnBoundary(ellipsoidValue, czm_epsilon3); \n //isOnEllipsoid = false; \n // if((resX >= 0.8 && resX <= 0.81)||(resY >= 0.8 && resY <= 0.81))\n // { \n // out_FragColor = shade(false);\n // }\n out_FragColor = shade(isOnEllipsoid);\n}\n";
16
+ /**
17
+ * 扫描面FS着色器
18
+ * @returns {ShaderSource}
19
+ */
20
+ export declare const scanPlaneFS = "\nuniform bool u_showIntersection;\nuniform bool u_showThroughEllipsoid;\nuniform float u_radius;\nuniform float u_xHalfAngle;\nuniform float u_yHalfAngle;\nuniform float u_normalDirection;\nuniform vec4 u_color;\nin vec3 v_position;\nin vec3 v_positionWC;\nin vec3 v_positionEC;\nin vec3 v_normalEC;\nvec4 getColor(float sensorRadius, vec3 pointEC)\n{ \n czm_materialInput materialInput; \n vec3 pointMC = (czm_inverseModelView * vec4(pointEC, 1.0)).xyz; \n materialInput.st = sensor2dTextureCoordinates(sensorRadius, pointMC);\n materialInput.str = pointMC / sensorRadius; \n vec3 positionToEyeEC = -v_positionEC; \n materialInput.positionToEyeEC = positionToEyeEC; \n vec3 normalEC = normalize(v_normalEC); \n materialInput.normalEC = u_normalDirection * normalEC; \n czm_material material = czm_getMaterial(materialInput); \n material.diffuse = u_color.rgb; \n material.alpha = u_color.a; \n return mix(czm_phong(normalize(positionToEyeEC), material,czm_lightDirectionEC), vec4(material.diffuse, material.alpha), 0.4);\n}\n\nbool isOnBoundary(float value, float epsilon)\n{ \n float width = getIntersectionWidth(); \n float tolerance = width * epsilon;\n #ifdef GL_OES_standard_derivatives \n float delta = max(abs(dFdx(value)), abs(dFdy(value))); \n float pixels = width * delta; \n float temp = abs(value); \n // There are a couple things going on here. \n // First we test the value at the current fragment to see if it is within the tolerance. \n // We also want to check if the value of an adjacent pixel is within the tolerance, \n // but we don't want to admit points that are obviously not on the surface. \n // For example, if we are looking for value to be close to 0, but value is 1 and the adjacent value is 2, \n // then the delta would be 1 and temp - delta would be 1 - 1 which is zero even though neither of \n // the points is close to zero. \n return temp < tolerance && temp < pixels || (delta < 10.0 * tolerance && temp - delta < tolerance && temp < pixels);\n #else \n return abs(value) < tolerance;\n #endif\n}\n\n\nvec4 shade(bool isOnBoundary)\n { \n if (u_showIntersection && isOnBoundary) \n { \n return getIntersectionColor(); \n } \n return getColor(u_radius, v_positionEC);\n}\n\n\nfloat ellipsoidSurfaceFunction(vec3 point)\n{ \n vec3 scaled = czm_ellipsoidInverseRadii * point; \n return dot(scaled, scaled) - 1.0;\n}\n\n\nvoid main()\n{ \n vec3 sensorVertexWC = czm_model[3].xyz; // (0.0, 0.0, 0.0) in model coordinates \n vec3 sensorVertexEC = czm_modelView[3].xyz; // (0.0, 0.0, 0.0) in model coordinates \n //vec3 pixDir = normalize(v_position); \n float positionX = v_position.x; \n float positionY = v_position.y; \n float positionZ = v_position.z; \n vec3 zDir = vec3(0.0, 0.0, 1.0); \n vec3 lineX = vec3(positionX, 0 ,positionZ); \n vec3 lineY = vec3(0, positionY, positionZ); \n float resX = dot(normalize(lineX), zDir); \n if(resX < cos(u_xHalfAngle) - 0.0001)\n { \n discard; \n } \n float resY = dot(normalize(lineY), zDir); \n if(resY < cos(u_yHalfAngle)- 0.0001)\n { \n discard; \n } \n float ellipsoidValue = ellipsoidSurfaceFunction(v_positionWC); \n // Occluded by the ellipsoid\n if (!u_showThroughEllipsoid)\n { \n // Discard if in the ellipsoid \n // PERFORMANCE_IDEA: A coarse check for ellipsoid intersection could be done on the CPU first. \n if (ellipsoidValue < 0.0) \n { \n discard; \n } \n // Discard if in the sensor's shadow \n if (inSensorShadow(sensorVertexWC, v_positionWC)) \n { \n discard; \n } \n } \n // Notes: Each surface functions should have an associated tolerance based on the floating point error. \n bool isOnEllipsoid = isOnBoundary(ellipsoidValue, czm_epsilon3); \n out_FragColor = shade(isOnEllipsoid);\n}\n ";
@@ -0,0 +1,21 @@
1
+ /**
2
+ * 公共着色器
3
+ * @returns {ShaderSource}
4
+ */
5
+ export var sensorComm = "\nuniform vec4 u_intersectionColor;\nuniform float u_intersectionWidth;\nuniform vec4 u_lineColor;\n\nbool inSensorShadow(vec3 coneVertexWC, vec3 pointWC)\n{ \n // Diagonal matrix from the unscaled ellipsoid space to the scaled space.\n vec3 D = czm_ellipsoidInverseRadii; \n // Sensor vertex in the scaled ellipsoid space \n vec3 q = D * coneVertexWC; \n float qMagnitudeSquared = dot(q, q); \n float test = qMagnitudeSquared - 1.0; \n // Sensor vertex to fragment vector in the ellipsoid's scaled space \n vec3 temp = D * pointWC - q; \n float d = dot(temp, q); \n // Behind silhouette plane and inside silhouette cone \n return (d < -test) && (d / length(temp) < -sqrt(test));\n}\n\nvec4 getLineColor()\n{ \n return u_lineColor;\n}\n\nvec4 getIntersectionColor()\n{ \n return u_intersectionColor;\n}\n\nfloat getIntersectionWidth()\n{ \n return u_intersectionWidth;\n}\n\nvec2 sensor2dTextureCoordinates(float sensorRadius, vec3 pointMC)\n{ \n // (s, t) both in the range [0, 1] \n float t = pointMC.z / sensorRadius; \n float s = 1.0 + (atan(pointMC.y, pointMC.x) / czm_twoPi); \n s = s - floor(s); \n return vec2(s, t);\n}\n\n";
6
+ /**
7
+ * VS着色器
8
+ * @returns {ShaderSource}
9
+ */
10
+ export var sensorVS = "\nin vec4 position;\nin vec3 normal;\nout vec3 v_position;\nout vec3 v_positionWC;\nout vec3 v_positionEC;\nout vec3 v_normalEC;\nvoid main()\n{ \n gl_Position = czm_modelViewProjection * position; \n v_position = vec3(position); \n v_positionWC = (czm_model * position).xyz; \n v_positionEC = (czm_modelView * position).xyz; \n v_normalEC = czm_normal * normal;\n}";
11
+
12
+ /**
13
+ * FS着色器
14
+ * @returns {ShaderSource}
15
+ */
16
+ export var sensorFS = "\nuniform bool u_showIntersection;\nuniform bool u_showThroughEllipsoid;\nuniform float u_radius;\nuniform float u_xHalfAngle;\nuniform float u_yHalfAngle;\nuniform float u_normalDirection;\nuniform float u_type;\nin vec3 v_position;\nin vec3 v_positionWC;\nin vec3 v_positionEC;\nin vec3 v_normalEC;\nvec4 getColor(float sensorRadius, vec3 pointEC)\n{ \n czm_materialInput materialInput; \n vec3 pointMC = (czm_inverseModelView * vec4(pointEC, 1.0)).xyz; \n materialInput.st = sensor2dTextureCoordinates(sensorRadius, pointMC); \n materialInput.str = pointMC / sensorRadius; \n\n vec3 positionToEyeEC = -v_positionEC; \n materialInput.positionToEyeEC = positionToEyeEC; \n\n vec3 normalEC = normalize(v_normalEC); \n materialInput.normalEC = u_normalDirection * normalEC; \n\n czm_material material = czm_getMaterial(materialInput); \n\n return mix(czm_phong(normalize(positionToEyeEC), material,czm_lightDirectionEC),vec4(material.diffuse, material.alpha), 0.4);\n}\n\nbool isOnBoundary(float value, float epsilon)\n{ \n float width = getIntersectionWidth(); \n float tolerance = width * epsilon;\n #ifdef GL_OES_standard_derivatives \n float delta = max(abs(dFdx(value)), abs(dFdy(value))); \n float pixels = width * delta; \n float temp = abs(value); \n // There are a couple things going on here. \n // First we test the value at the current fragment to see if it is within the tolerance. \n // We also want to check if the value of an adjacent pixel is within the tolerance, \n // but we don't want to admit points that are obviously not on the surface. \n // For example, if we are looking for \"value\" to be close to 0, but value is 1 and the adjacent value is 2, \n // then the delta would be 1 and \"temp - delta\" would be \"1 - 1\" which is zero even though neither of \n // the points is close to zero. \n return temp < tolerance && temp < pixels || (delta < 10.0 * tolerance && temp - delta < tolerance && temp < pixels);\n #else \n return abs(value) < tolerance;\n #endif\n}\n\n\nvec4 shade(bool isOnBoundary)\n{ \n\n if (u_showIntersection && isOnBoundary) \n { \n return getIntersectionColor(); \n } \n if(u_type == 1.0)\n { \n return getLineColor(); \n } \n\n return getColor(u_radius, v_positionEC);\n\n}\n \nfloat ellipsoidSurfaceFunction(vec3 point)\n{ \n vec3 scaled = czm_ellipsoidInverseRadii * point; \n return dot(scaled, scaled) - 1.0;\n}\n\nvoid main()\n{ \n vec3 sensorVertexWC = czm_model[3].xyz; // (0.0, 0.0, 0.0) in model coordinates \n vec3 sensorVertexEC = czm_modelView[3].xyz; // (0.0, 0.0, 0.0) in model coordinates \n //vec3 pixDir = normalize(v_position); \n float positionX = v_position.x; \n float positionY = v_position.y; \n float positionZ = v_position.z; \n vec3 zDir = vec3(0.0, 0.0, 1.0); \n vec3 lineX = vec3(positionX, 0 ,positionZ); \n vec3 lineY = vec3(0, positionY, positionZ); \n float resX = dot(normalize(lineX), zDir); \n if(resX < cos(u_xHalfAngle)-0.00001)\n { \n discard; \n } \n float resY = dot(normalize(lineY), zDir); \n if(resY < cos(u_yHalfAngle)-0.00001)\n { \n discard; \n } \n float ellipsoidValue = ellipsoidSurfaceFunction(v_positionWC);\n // Occluded by the ellipsoid?\n if (!u_showThroughEllipsoid)\n { \n // Discard if in the ellipsoid \n // PERFORMANCE_IDEA: A coarse check for ellipsoid intersection could be done on the CPU first. \n if (ellipsoidValue < 0.0) \n { \n discard; \n } \n // Discard if in the sensor's shadow \n if (inSensorShadow(sensorVertexWC, v_positionWC)) \n { \n discard; \n } \n } \n // Notes: Each surface functions should have an associated tolerance based on the floating point error. \n bool isOnEllipsoid = isOnBoundary(ellipsoidValue, czm_epsilon3); \n //isOnEllipsoid = false; \n // if((resX >= 0.8 && resX <= 0.81)||(resY >= 0.8 && resY <= 0.81))\n // { \n // out_FragColor = shade(false);\n // }\n out_FragColor = shade(isOnEllipsoid);\n}\n";
17
+ /**
18
+ * 扫描面FS着色器
19
+ * @returns {ShaderSource}
20
+ */
21
+ export var scanPlaneFS = "\nuniform bool u_showIntersection;\nuniform bool u_showThroughEllipsoid;\nuniform float u_radius;\nuniform float u_xHalfAngle;\nuniform float u_yHalfAngle;\nuniform float u_normalDirection;\nuniform vec4 u_color;\nin vec3 v_position;\nin vec3 v_positionWC;\nin vec3 v_positionEC;\nin vec3 v_normalEC;\nvec4 getColor(float sensorRadius, vec3 pointEC)\n{ \n czm_materialInput materialInput; \n vec3 pointMC = (czm_inverseModelView * vec4(pointEC, 1.0)).xyz; \n materialInput.st = sensor2dTextureCoordinates(sensorRadius, pointMC);\n materialInput.str = pointMC / sensorRadius; \n vec3 positionToEyeEC = -v_positionEC; \n materialInput.positionToEyeEC = positionToEyeEC; \n vec3 normalEC = normalize(v_normalEC); \n materialInput.normalEC = u_normalDirection * normalEC; \n czm_material material = czm_getMaterial(materialInput); \n material.diffuse = u_color.rgb; \n material.alpha = u_color.a; \n return mix(czm_phong(normalize(positionToEyeEC), material,czm_lightDirectionEC), vec4(material.diffuse, material.alpha), 0.4);\n}\n\nbool isOnBoundary(float value, float epsilon)\n{ \n float width = getIntersectionWidth(); \n float tolerance = width * epsilon;\n #ifdef GL_OES_standard_derivatives \n float delta = max(abs(dFdx(value)), abs(dFdy(value))); \n float pixels = width * delta; \n float temp = abs(value); \n // There are a couple things going on here. \n // First we test the value at the current fragment to see if it is within the tolerance. \n // We also want to check if the value of an adjacent pixel is within the tolerance, \n // but we don't want to admit points that are obviously not on the surface. \n // For example, if we are looking for value to be close to 0, but value is 1 and the adjacent value is 2, \n // then the delta would be 1 and temp - delta would be 1 - 1 which is zero even though neither of \n // the points is close to zero. \n return temp < tolerance && temp < pixels || (delta < 10.0 * tolerance && temp - delta < tolerance && temp < pixels);\n #else \n return abs(value) < tolerance;\n #endif\n}\n\n\nvec4 shade(bool isOnBoundary)\n { \n if (u_showIntersection && isOnBoundary) \n { \n return getIntersectionColor(); \n } \n return getColor(u_radius, v_positionEC);\n}\n\n\nfloat ellipsoidSurfaceFunction(vec3 point)\n{ \n vec3 scaled = czm_ellipsoidInverseRadii * point; \n return dot(scaled, scaled) - 1.0;\n}\n\n\nvoid main()\n{ \n vec3 sensorVertexWC = czm_model[3].xyz; // (0.0, 0.0, 0.0) in model coordinates \n vec3 sensorVertexEC = czm_modelView[3].xyz; // (0.0, 0.0, 0.0) in model coordinates \n //vec3 pixDir = normalize(v_position); \n float positionX = v_position.x; \n float positionY = v_position.y; \n float positionZ = v_position.z; \n vec3 zDir = vec3(0.0, 0.0, 1.0); \n vec3 lineX = vec3(positionX, 0 ,positionZ); \n vec3 lineY = vec3(0, positionY, positionZ); \n float resX = dot(normalize(lineX), zDir); \n if(resX < cos(u_xHalfAngle) - 0.0001)\n { \n discard; \n } \n float resY = dot(normalize(lineY), zDir); \n if(resY < cos(u_yHalfAngle)- 0.0001)\n { \n discard; \n } \n float ellipsoidValue = ellipsoidSurfaceFunction(v_positionWC); \n // Occluded by the ellipsoid\n if (!u_showThroughEllipsoid)\n { \n // Discard if in the ellipsoid \n // PERFORMANCE_IDEA: A coarse check for ellipsoid intersection could be done on the CPU first. \n if (ellipsoidValue < 0.0) \n { \n discard; \n } \n // Discard if in the sensor's shadow \n if (inSensorShadow(sensorVertexWC, v_positionWC)) \n { \n discard; \n } \n } \n // Notes: Each surface functions should have an associated tolerance based on the floating point error. \n bool isOnEllipsoid = isOnBoundary(ellipsoidValue, czm_epsilon3); \n out_FragColor = shade(isOnEllipsoid);\n}\n ";
@@ -115,6 +115,9 @@ var BaseLayer = /*#__PURE__*/function () {
115
115
  polygonImageP: function polygonImageP() {
116
116
  _this2.primitiveCollection = new PolygonPrimitive(_this2._mapContext);
117
117
  },
118
+ polygonGroundImageP: function polygonGroundImageP() {
119
+ _this2.primitiveCollection = new PolygonPrimitive(_this2._mapContext);
120
+ },
118
121
  polygonGroundP: function polygonGroundP() {
119
122
  _this2.primitiveCollection = new PolygonGroundPrimitive(_this2._mapContext);
120
123
  },
@@ -1,9 +1,11 @@
1
1
  export default class BasePrimitiveInstance {
2
+ private readonly _mapContext;
2
3
  id: any;
3
4
  source: any;
4
5
  style: any;
5
6
  type: string;
6
7
  readonly isPrimitive: boolean;
7
8
  constructor(options: any);
9
+ getMap(): any;
8
10
  updateStyle(): void;
9
11
  }
@@ -6,11 +6,11 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
6
6
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
7
  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); }
8
8
  import { v4 as uuidv4 } from 'uuid';
9
-
10
9
  // 基础PrimitiveInstance图层
11
10
  var BasePrimitiveInstance = /*#__PURE__*/function () {
12
11
  function BasePrimitiveInstance(options) {
13
12
  _classCallCheck(this, BasePrimitiveInstance);
13
+ _defineProperty(this, "_mapContext", void 0);
14
14
  _defineProperty(this, "id", void 0);
15
15
  _defineProperty(this, "source", void 0);
16
16
  _defineProperty(this, "style", void 0);
@@ -18,14 +18,22 @@ var BasePrimitiveInstance = /*#__PURE__*/function () {
18
18
  _defineProperty(this, "isPrimitive", true);
19
19
  this.id = uuidv4();
20
20
  var style = options.style,
21
- source = options.source;
22
- this.type = options.type;
21
+ source = options.source,
22
+ type = options.type,
23
+ mapContext = options.mapContext;
24
+ this._mapContext = mapContext;
25
+ this.type = type;
23
26
  this.source = source;
24
27
  this.style = style || {};
25
28
  }
26
-
27
- // 更新样式
28
29
  _createClass(BasePrimitiveInstance, [{
30
+ key: "getMap",
31
+ value: function getMap() {
32
+ return this._mapContext && this._mapContext.getMap();
33
+ }
34
+
35
+ // 更新样式
36
+ }, {
29
37
  key: "updateStyle",
30
38
  value: function updateStyle() {
31
39
  console.warn("".concat(this.type, "\u7C7B\u578B\u4E0D\u652F\u6301\u66F4\u65B0\u6837\u5F0F"));
@@ -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): "other" | "wkt" | "sourceId" | "sourceInstance" | "geoJson";
18
+ static analysisSourceType(data: any): "clampedPolygonGrid" | "wkt" | "sourceId" | "sourceInstance" | "geoJson" | "other";
19
19
  static wktToGeoJon(wkt: string): any;
20
20
  static geoJsonToGeoCartesian3Array(geoJson: any): any[];
21
21
  static handleFeaturePoint(feature: any): any;
@@ -100,6 +100,9 @@ var BaseSource = /*#__PURE__*/function () {
100
100
  this._handleGeoJson(source);
101
101
  } else if (sourceType === 'wkt') {
102
102
  this._handleGeoJson(BaseSource.wktToGeoJon(source));
103
+ } else if (sourceType === 'clampedPolygonGrid') {
104
+ // 贴地网格
105
+ this.source = source.source;
103
106
  } else {
104
107
  throw new Error('数据格式错误');
105
108
  }
@@ -152,6 +155,9 @@ var BaseSource = /*#__PURE__*/function () {
152
155
  return 'sourceInstance';
153
156
  } else if (data.type === 'Feature' || data.type === 'FeatureCollection') {
154
157
  return 'geoJson';
158
+ } else if (data.type === 'clampedPolygonGrid') {
159
+ // 贴地网格
160
+ return 'clampedPolygonGrid';
155
161
  } else {
156
162
  return 'other';
157
163
  }
@@ -0,0 +1,5 @@
1
+ import PolygonPrimitiveInstance from './PolygonPrimitiveInstance';
2
+ export default class PolygonGroundPrimitiveImageMaterialInstance extends PolygonPrimitiveInstance {
3
+ constructor(options: any);
4
+ _init(options: any): void;
5
+ }
@@ -0,0 +1,84 @@
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
+ var _excluded = ["color", "stRotation"];
3
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
+ 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); } }
7
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
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
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
11
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
13
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
14
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
15
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
16
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17
+ import * as Cesium from 'deeptwins-cesium';
18
+ import * as utils from "../tool/utils";
19
+ import PolygonPrimitiveInstance from "./PolygonPrimitiveInstance";
20
+
21
+ // polygon ground Primitive 图片材质贴图
22
+ var PolygonGroundPrimitiveImageMaterialInstance = /*#__PURE__*/function (_PolygonPrimitiveInst) {
23
+ _inherits(PolygonGroundPrimitiveImageMaterialInstance, _PolygonPrimitiveInst);
24
+ var _super = _createSuper(PolygonGroundPrimitiveImageMaterialInstance);
25
+ function PolygonGroundPrimitiveImageMaterialInstance(options) {
26
+ _classCallCheck(this, PolygonGroundPrimitiveImageMaterialInstance);
27
+ return _super.call(this, options);
28
+ }
29
+
30
+ // 初始化
31
+ _createClass(PolygonGroundPrimitiveImageMaterialInstance, [{
32
+ key: "_init",
33
+ value: function _init(options) {
34
+ var _options$style = options.style,
35
+ color = _options$style.color,
36
+ stRotation = _options$style.stRotation,
37
+ style = _objectWithoutProperties(_options$style, _excluded),
38
+ positions = options.positions,
39
+ indices = options.indices,
40
+ primitiveInstance = options.primitiveInstance;
41
+ if (!indices || indices.length < 3) return;
42
+ if (!positions || positions.length < 3) return;
43
+ var geometry = new Cesium.Geometry({
44
+ // @ts-ignore
45
+ attributes: {
46
+ position: new Cesium.GeometryAttribute({
47
+ componentDatatype: Cesium.ComponentDatatype.DOUBLE,
48
+ componentsPerAttribute: 3,
49
+ values: Cesium.Cartesian3.packArray(utils.buildPolygonHierarchy(positions).positions)
50
+ })
51
+ },
52
+ indices: new Uint32Array(indices),
53
+ primitiveType: Cesium.PrimitiveType.TRIANGLES,
54
+ boundingSphere: Cesium.BoundingSphere.fromPoints(positions)
55
+ });
56
+ if (!style.extrudedHeight) {
57
+ var posAttr = geometry.attributes.position;
58
+ var vertexCount = posAttr.values.length / 3;
59
+ var finalPositions = [];
60
+ for (var i = 0; i < vertexCount; i++) {
61
+ finalPositions.push(new Cesium.Cartesian3(posAttr.values[i * 3], posAttr.values[i * 3 + 1], posAttr.values[i * 3 + 2]));
62
+ }
63
+ geometry.attributes.st = new Cesium.GeometryAttribute({
64
+ componentDatatype: Cesium.ComponentDatatype.FLOAT,
65
+ componentsPerAttribute: 2,
66
+ values: utils.computeSTAlongPlane(finalPositions, stRotation)
67
+ });
68
+ } else {
69
+ utils.error('不支持extrudedHeight');
70
+ return;
71
+ }
72
+ var instance = new Cesium.GeometryInstance({
73
+ id: this.id,
74
+ geometry: geometry,
75
+ attributes: {
76
+ color: color
77
+ }
78
+ });
79
+ primitiveInstance.push(instance);
80
+ }
81
+ }]);
82
+ return PolygonGroundPrimitiveImageMaterialInstance;
83
+ }(PolygonPrimitiveInstance);
84
+ export { PolygonGroundPrimitiveImageMaterialInstance as default };
@@ -51,10 +51,16 @@ var PolygonPrimitiveImageMaterialInstance = /*#__PURE__*/function (_PolygonPrimi
51
51
  }, style));
52
52
  if (!style.extrudedHeight) {
53
53
  geometry = Cesium.PolygonGeometry.createGeometry(polygonGeometry);
54
+ var posAttr = geometry.attributes.position;
55
+ var vertexCount = posAttr.values.length / 3;
56
+ var finalPositions = [];
57
+ for (var i = 0; i < vertexCount; i++) {
58
+ finalPositions.push(new Cesium.Cartesian3(posAttr.values[i * 3], posAttr.values[i * 3 + 1], posAttr.values[i * 3 + 2]));
59
+ }
54
60
  geometry.attributes.st = new Cesium.GeometryAttribute({
55
61
  componentDatatype: Cesium.ComponentDatatype.FLOAT,
56
62
  componentsPerAttribute: 2,
57
- values: utils.computeSTAlongPlane(positions, stRotation)
63
+ values: utils.computeSTAlongPlane(finalPositions, stRotation)
58
64
  });
59
65
  } else {
60
66
  utils.error('不支持extrudedHeight');
@@ -24,7 +24,7 @@ import { DEFAULT_POLYLINE_PRIMITIVE_OPTIONS } from "../constant";
24
24
  import * as utils from "../tool/utils";
25
25
  import BasePrimitiveInstance from "./BasePrimitiveInstance";
26
26
 
27
- // 线实体图层
27
+ // 线 primitive 实体图层
28
28
  var PolylineGroundPrimitiveInstance = /*#__PURE__*/function (_BasePrimitiveInstanc) {
29
29
  _inherits(PolylineGroundPrimitiveInstance, _BasePrimitiveInstanc);
30
30
  var _super = _createSuper(PolylineGroundPrimitiveInstance);
@@ -70,5 +70,7 @@ export declare class DeepTwinsEngine3D {
70
70
  static PoiLayer: any;
71
71
  static FlightPlanning: any;
72
72
  static FlightRiskEvaluation: any;
73
+ static BuildClampedPolygonGridUnified: any;
74
+ static ViewShedAnalyserLayer: any;
73
75
  }
74
76
  export default DeepTwinsEngine3D;
package/dist/esm/index.js CHANGED
@@ -42,6 +42,7 @@ import ArcGisLayer from "./tileLayer/ArcGisLayer";
42
42
  import RasterLayer from "./tileLayer/RasterLayer";
43
43
  import WmsLayer from "./tileLayer/WmsLayer";
44
44
  import WmtsLayer from "./tileLayer/WmtsLayer";
45
+ import BuildClampedPolygonGridUnified from "./tool/BuildClampedPolygonGrid";
45
46
  import Compass from "./tool/Compass";
46
47
  import TimerInterval from "./tool/TimerInterval";
47
48
  import { ClampToGround, ShapeSection } from "./tool/common";
@@ -52,17 +53,19 @@ import Frustum from "./visualization/Frustum";
52
53
  import Heatmap2d from "./visualization/Heatmap2d";
53
54
  import Heatmap3d from "./visualization/Heatmap3d";
54
55
  import PointCluster from "./visualization/PointCluster";
56
+ // drawCommand
57
+ import { ViewShedAnalyserLayer } from "./drawCommand";
55
58
  window.Cesium = Cesium;
56
59
  // 将DEEP_TWINS_BASE_URL赋值给CESIUM_BASE_URL
57
60
  DEEP_TWINS_BASE_URL && (window.CESIUM_BASE_URL = DEEP_TWINS_BASE_URL);
58
61
  // 全局加载css
59
62
  loadCss(Cesium.buildModuleUrl('Widgets/widgets.css'));
60
63
  // 打印版本信息
61
- console.log('DeepTwinsEngine3D Version:', "0.1.48");
64
+ console.log('DeepTwinsEngine3D Version:', "0.1.50");
62
65
  export var DeepTwinsEngine3D = /*#__PURE__*/_createClass(function DeepTwinsEngine3D() {
63
66
  _classCallCheck(this, DeepTwinsEngine3D);
64
67
  });
65
- _defineProperty(DeepTwinsEngine3D, "Version", "0.1.48");
68
+ _defineProperty(DeepTwinsEngine3D, "Version", "0.1.50");
66
69
  _defineProperty(DeepTwinsEngine3D, "Map", Map);
67
70
  _defineProperty(DeepTwinsEngine3D, "GroundSkyBox", GroundSkyBox);
68
71
  _defineProperty(DeepTwinsEngine3D, "RasterLayer", RasterLayer);
@@ -132,4 +135,6 @@ _defineProperty(DeepTwinsEngine3D, "VisitLayer", VisitLayer);
132
135
  _defineProperty(DeepTwinsEngine3D, "PoiLayer", PoiLayer);
133
136
  _defineProperty(DeepTwinsEngine3D, "FlightPlanning", FlightPlanning);
134
137
  _defineProperty(DeepTwinsEngine3D, "FlightRiskEvaluation", FlightRiskEvaluation);
138
+ _defineProperty(DeepTwinsEngine3D, "BuildClampedPolygonGridUnified", BuildClampedPolygonGridUnified);
139
+ _defineProperty(DeepTwinsEngine3D, "ViewShedAnalyserLayer", ViewShedAnalyserLayer);
135
140
  export default DeepTwinsEngine3D;
@@ -151,7 +151,7 @@ var Map = /*#__PURE__*/function (_Cesium$Viewer) {
151
151
  value: function _createVideoContainer() {
152
152
  var el = document.createElement('div');
153
153
  el.id = constant.VIDEO_CONTAINER_ID;
154
- el.style.cssText = 'position: absolute; left: 0; top: 0; right: 0; bottom: 0; pointer-events: none; overflow: hidden; display: none';
154
+ el.style.cssText = 'position: absolute; left: 0; top: 0; pointer-events: none; opacity: 0';
155
155
  this.container.appendChild(el);
156
156
  }
157
157
 
@@ -270,10 +270,10 @@ var Map = /*#__PURE__*/function (_Cesium$Viewer) {
270
270
  if (!deepTwins && !this._yunjing) {
271
271
  !isNil(show) && (this.scene.globe.show = show);
272
272
  !isNil(showGroundAtmosphere) && (this.scene.globe.showGroundAtmosphere = showGroundAtmosphere);
273
- !isNil(depthTestAgainstTerrain) && (this.scene.globe.depthTestAgainstTerrain = depthTestAgainstTerrain);
274
273
  !isNil(baseColor) && (this.scene.globe.baseColor = utils.colorString(baseColor));
275
274
  !isNil(enableLighting) && (this.scene.globe.enableLighting = enableLighting);
276
275
  }
276
+ !isNil(depthTestAgainstTerrain) && (this.scene.globe.depthTestAgainstTerrain = depthTestAgainstTerrain);
277
277
  }
278
278
 
279
279
  // 添加默认近地天空盒
@@ -2,7 +2,7 @@ import BaseMaterialAppearance from './BaseMaterialAppearance';
2
2
  declare class ImageMaterialAppearance extends BaseMaterialAppearance {
3
3
  private readonly currMaterial;
4
4
  private readonly currAppearance;
5
- constructor(material: any, appearance: any);
5
+ constructor(material: any, appearance?: any);
6
6
  static handleMaterial(style: any): any;
7
7
  private _createMaterial;
8
8
  private _createAppearance;
@@ -0,0 +1,4 @@
1
+ export default function BuildClampedPolygonGridUnified(map: any, geoJson: any, gridSize?: number, heightBuffer?: number): Promise<{
2
+ type: string;
3
+ source: any[];
4
+ }>;