@lijuhong1981/cesium.utils 0.0.0-stage → 0.1.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.
Files changed (99) hide show
  1. package/README.md +62 -2
  2. package/package.json +45 -4
  3. package/src/additions/Geographic.js +603 -0
  4. package/src/additions/GeographicTransform.js +291 -0
  5. package/src/additions/GeometryInstanceAttributes.js +164 -0
  6. package/src/additions/ModelMatrixTransforms.js +822 -0
  7. package/src/additions/PropertyChangedListener.js +72 -0
  8. package/src/additions/PropertyType.js +30 -0
  9. package/src/additions/StTransforms.js +266 -0
  10. package/src/additions/TranslationRotationScaleTransform.js +809 -0
  11. package/src/additions/index.js +8 -0
  12. package/src/index.js +4 -0
  13. package/src/parses/index.js +46 -0
  14. package/src/parses/parseAltitude.js +32 -0
  15. package/src/parses/parseArcType.js +26 -0
  16. package/src/parses/parseAttitudeToHeadingPitchRoll.js +26 -0
  17. package/src/parses/parseAttitudeToMatrix3.js +17 -0
  18. package/src/parses/parseAttitudeToQuaternion.js +21 -0
  19. package/src/parses/parseCartographicToCartesian.js +21 -0
  20. package/src/parses/parseCartographicsToPositions.js +20 -0
  21. package/src/parses/parseClassificationType.js +24 -0
  22. package/src/parses/parseClockRange.js +26 -0
  23. package/src/parses/parseColorBlendMode.js +26 -0
  24. package/src/parses/parseCornerType.js +24 -0
  25. package/src/parses/parseCullFace.js +28 -0
  26. package/src/parses/parseEulerToHeadingPitchRoll.js +21 -0
  27. package/src/parses/parseEulerToQuaternion.js +18 -0
  28. package/src/parses/parseGeographicToCartesian.js +21 -0
  29. package/src/parses/parseGeographicsToPositions.js +20 -0
  30. package/src/parses/parseHeading.js +28 -0
  31. package/src/parses/parseHeightReference.js +24 -0
  32. package/src/parses/parseHorizontalOrigin.js +26 -0
  33. package/src/parses/parseLabelStyle.js +26 -0
  34. package/src/parses/parseLatitude.js +28 -0
  35. package/src/parses/parseLongitude.js +28 -0
  36. package/src/parses/parsePitch.js +26 -0
  37. package/src/parses/parseRoll.js +26 -0
  38. package/src/parses/parseRotationToHeadingPitchRoll.js +40 -0
  39. package/src/parses/parseRotationToMatrix3.js +25 -0
  40. package/src/parses/parseRotationToQuaternion.js +27 -0
  41. package/src/parses/parseShadowMode.js +26 -0
  42. package/src/parses/parseToBoundingRectangle.js +33 -0
  43. package/src/parses/parseToCartesian2.js +35 -0
  44. package/src/parses/parseToCartesian3.js +37 -0
  45. package/src/parses/parseToCartesian3Array.js +21 -0
  46. package/src/parses/parseToCartesian4.js +39 -0
  47. package/src/parses/parseToCartographic.js +31 -0
  48. package/src/parses/parseToColor.js +33 -0
  49. package/src/parses/parseToDistanceDisplayCondition.js +41 -0
  50. package/src/parses/parseToGeographic.js +31 -0
  51. package/src/parses/parseToHeadingPitchRange.js +45 -0
  52. package/src/parses/parseToJulianDate.js +23 -0
  53. package/src/parses/parseToNearFarScalar.js +33 -0
  54. package/src/parses/parseToPlane.js +37 -0
  55. package/src/parses/parseToPolygonHierarchy.js +48 -0
  56. package/src/parses/parseToRange.js +26 -0
  57. package/src/parses/parseToRectangle.js +32 -0
  58. package/src/parses/parseToTimeInterval.js +45 -0
  59. package/src/parses/parseVerticalOrigin.js +28 -0
  60. package/src/revisions/BoundingSphere.revise.js +107 -0
  61. package/src/revisions/Camera.revise.js +366 -0
  62. package/src/revisions/Cartesian.revise.js +313 -0
  63. package/src/revisions/Cartographic.revise.js +443 -0
  64. package/src/revisions/Check.revise.js +164 -0
  65. package/src/revisions/Color.revise.js +271 -0
  66. package/src/revisions/DistanceDisplayCondition.revise.js +37 -0
  67. package/src/revisions/Ellipsoid.revise.js +64 -0
  68. package/src/revisions/Geometry.revise.js +79 -0
  69. package/src/revisions/Globe.revise.js +92 -0
  70. package/src/revisions/HeadingPitchRoll.revise.js +328 -0
  71. package/src/revisions/JulianDate.revise.js +28 -0
  72. package/src/revisions/Material.revise.js +308 -0
  73. package/src/revisions/Math.revise.js +98 -0
  74. package/src/revisions/Matrix.revise.js +578 -0
  75. package/src/revisions/POI.revise.js +178 -0
  76. package/src/revisions/Plane.revise.js +43 -0
  77. package/src/revisions/PolylinePipeline.revise.js +54 -0
  78. package/src/revisions/PostProcessStageLibrary.revise.js +1143 -0
  79. package/src/revisions/Primitive.revise.js +83 -0
  80. package/src/revisions/Property.revise.js +37 -0
  81. package/src/revisions/Quaternion.revise.js +66 -0
  82. package/src/revisions/Rectangle.revise.js +570 -0
  83. package/src/revisions/SceneTransforms.revise.js +82 -0
  84. package/src/revisions/Spherical.revise.js +35 -0
  85. package/src/revisions/index.js +25 -0
  86. package/src/utils/Scratch.js +165 -0
  87. package/src/utils/computeCirclePositions.js +48 -0
  88. package/src/utils/computeCircleRadius.js +19 -0
  89. package/src/utils/computeModelMatrix.js +109 -0
  90. package/src/utils/computeStTransform.js +57 -0
  91. package/src/utils/createGeometry.js +114 -0
  92. package/src/utils/createPointCloudGeometry.js +79 -0
  93. package/src/utils/getGeometryInstanceAttributes.js +43 -0
  94. package/src/utils/getPositionFromTarget.js +29 -0
  95. package/src/utils/getRenderState.js +35 -0
  96. package/src/utils/index.js +13 -0
  97. package/src/utils/isColorMaterial.js +13 -0
  98. package/src/utils/isTranslucent.js +13 -0
  99. package/src/utils/resolveModelMatrixByFixedFrame.js +30 -0
@@ -0,0 +1,83 @@
1
+ import { BoundingSphere, BoundingSphereState, Check, ClassificationPrimitive, GroundPolylinePrimitive, GroundPrimitive, Primitive } from "cesium";
2
+
3
+ /**
4
+ * 扩展 Cesium 的 Primitive 类,补充获取包围球的方法。
5
+ * @class Primitive
6
+ * @see {@link https://cesium.com/learn/cesiumjs/ref-doc/Primitive.html}
7
+ */
8
+ /**
9
+ * 扩展 Cesium 的 GroundPrimitive 类,补充获取包围球的方法。
10
+ * @class GroundPrimitive
11
+ * @see {@link https://cesium.com/learn/cesiumjs/ref-doc/GroundPrimitive.html}
12
+ */
13
+ /**
14
+ * 扩展 Cesium 的 ClassificationPrimitive 类,补充获取包围球的方法。
15
+ * @class ClassificationPrimitive
16
+ * @see {@link https://cesium.com/learn/cesiumjs/ref-doc/ClassificationPrimitive.html}
17
+ */
18
+ /**
19
+ * 扩展 Cesium 的 GroundPolylinePrimitive 类,补充获取包围球的方法。
20
+ * @class GroundPolylinePrimitive
21
+ * @see {@link https://cesium.com/learn/cesiumjs/ref-doc/GroundPolylinePrimitive.html}
22
+ */
23
+
24
+ /**
25
+ * 获取当前图元的包围球。
26
+ * @param {boolean} allowPartial 是否允许仅使用部分已就绪的几何数据计算包围球。
27
+ * @param {BoundingSphere} result 用于存储包围球的对象。
28
+ * @returns {BoundingSphereState} 包围球的计算状态。
29
+ * @memberof Primitive
30
+ */
31
+ Primitive.prototype.getBoundingSphere = function (allowPartial, result) {
32
+ Check.defined('result', result);
33
+ if (!this._ready || this._recomputeBoundingSpheres)
34
+ return BoundingSphereState.PENDING;
35
+ BoundingSphere.fromBoundingSpheres(this._boundingSphereWC, result);
36
+ return BoundingSphereState.DONE;
37
+ };
38
+
39
+ /**
40
+ * 获取当前地面图元的包围球。
41
+ * @param {boolean} allowPartial 是否允许仅使用部分已就绪的几何数据计算包围球。
42
+ * @param {BoundingSphere} result 用于存储包围球的对象。
43
+ * @returns {BoundingSphereState} 包围球的计算状态。
44
+ * @memberof GroundPrimitive
45
+ */
46
+ GroundPrimitive.prototype.getBoundingSphere = function (allowPartial, result) {
47
+ Check.defined('result', result);
48
+ if (!this._ready)
49
+ return BoundingSphereState.PENDING;
50
+ BoundingSphere.fromBoundingSpheres(this._boundingSpheres, result);
51
+ return BoundingSphereState.DONE;;
52
+ };
53
+
54
+ /**
55
+ * 获取当前分类图元的包围球。
56
+ * @param {boolean} allowPartial 是否允许仅使用部分已就绪的几何数据计算包围球。
57
+ * @param {BoundingSphere} result 用于存储包围球的对象。
58
+ * @returns {BoundingSphereState} 包围球的计算状态。
59
+ * @memberof ClassificationPrimitive
60
+ */
61
+ ClassificationPrimitive.prototype.getBoundingSphere = function (allowPartial, result) {
62
+ Check.defined('result', result);
63
+ if (!this._ready || !this._primitive || !this._primitive._ready)
64
+ return BoundingSphereState.PENDING;
65
+ return this._primitive.getBoundingSphere(allowPartial, result);
66
+ };
67
+
68
+ /**
69
+ * 获取当前地面线图元的包围球。
70
+ * @param {boolean} allowPartial 是否允许仅使用部分已就绪的几何数据计算包围球。
71
+ * @param {BoundingSphere} result 用于存储包围球的对象。
72
+ * @returns {BoundingSphereState} 包围球的计算状态。
73
+ * @memberof GroundPolylinePrimitive
74
+ */
75
+ GroundPolylinePrimitive.prototype.getBoundingSphere = function (allowPartial, result) {
76
+ Check.defined('result', result);
77
+ if (!this._ready || !this._primitive || !this._primitive._ready)
78
+ return BoundingSphereState.PENDING;
79
+ return this._primitive.getBoundingSphere(allowPartial, result);
80
+ };
81
+
82
+ export default Primitive;
83
+ export { ClassificationPrimitive, GroundPolylinePrimitive, GroundPrimitive, Primitive };
@@ -0,0 +1,37 @@
1
+ import { defined, Property } from "cesium";
2
+
3
+ /**
4
+ * 扩展 Cesium 的 Property 类,补充属性判断与取值的方法。
5
+ * @class Property
6
+ * @see {@link https://cesium.com/learn/cesiumjs/ref-doc/Property.html}
7
+ */
8
+
9
+ /**
10
+ * 判断给定对象是否为一个 Property(具有 getValue 方法且定义了 isConstant)。
11
+ * @param {object} property 待判断的对象。
12
+ * @returns {boolean} 若为 Property 返回 true;否则返回 undefined。
13
+ * @memberof Property
14
+ * @static
15
+ */
16
+ Property.isProperty = function (property) {
17
+ if (typeof property.getValue === 'function' && defined(property.isConstant))
18
+ return true;
19
+ };
20
+
21
+ /**
22
+ * 获取属性在指定时间的值,若对象非 Property 则直接返回其本身。
23
+ * @param {object|Property} property 属性对象或普通值。
24
+ * @param {JulianDate} [time] 取值的时间。
25
+ * @param {object} [result] 用于存储结果的可选对象。
26
+ * @returns {object} 属性在指定时间的值。
27
+ * @memberof Property
28
+ * @static
29
+ */
30
+ Property.getValue = function (property, time, result) {
31
+ if (typeof property.getValue === 'function')
32
+ return property.getValue(time, result);
33
+ return property;
34
+ };
35
+
36
+ export default Property;
37
+ export { Property };
@@ -0,0 +1,66 @@
1
+ import { HeadingPitchRoll, Matrix3, Quaternion } from "cesium";
2
+ import Scratch from "../utils/Scratch.js";
3
+
4
+ /**
5
+ * 扩展 Cesium 的 Quaternion 类,补充通过航向俯仰横滚角创建四元数、
6
+ * 四元数向量变换以及转换为航向俯仰横滚角的方法。
7
+ * @class Quaternion
8
+ * @see {@link https://cesium.com/learn/cesiumjs/ref-doc/Quaternion.html}
9
+ */
10
+
11
+ /**
12
+ * 从以角度表示的航向、俯仰、横滚角创建四元数。
13
+ * @param {number} heading 航向角,单位度。
14
+ * @param {number} pitch 俯仰角,单位度。
15
+ * @param {number} roll 横滚角,单位度。
16
+ * @param {Quaternion} [result] 用于存储结果的可选对象。
17
+ * @returns {Quaternion} 生成的四元数。
18
+ * @memberof Quaternion
19
+ * @static
20
+ */
21
+ Quaternion.fromDegrees = function (heading, pitch, roll, result) {
22
+ const hpr = HeadingPitchRoll.fromDegrees(heading, pitch, roll, Scratch.scratchHeadingPitchRoll);
23
+ return Quaternion.fromHeadingPitchRoll(hpr, result);
24
+ };
25
+
26
+ /**
27
+ * 从以弧度表示的航向、俯仰、横滚角创建四元数。
28
+ * @param {number} heading 航向角,单位弧度。
29
+ * @param {number} pitch 俯仰角,单位弧度。
30
+ * @param {number} roll 横滚角,单位弧度。
31
+ * @param {Quaternion} [result] 用于存储结果的可选对象。
32
+ * @returns {Quaternion} 生成的四元数。
33
+ * @memberof Quaternion
34
+ * @static
35
+ */
36
+ Quaternion.fromRadians = function (heading, pitch, roll, result) {
37
+ const hpr = HeadingPitchRoll.fromRadians(heading, pitch, roll, Scratch.scratchHeadingPitchRoll);
38
+ return Quaternion.fromHeadingPitchRoll(hpr, result);
39
+ };
40
+
41
+ /**
42
+ * 使用四元数表示的旋转对笛卡尔坐标向量进行变换。
43
+ * @param {Quaternion} quaterion 旋转四元数。
44
+ * @param {Cartesian3} cartesian 待变换的向量。
45
+ * @param {Cartesian3} [result] 用于存储结果的可选对象。
46
+ * @returns {Cartesian3} 变换后的向量。
47
+ * @memberof Quaternion
48
+ * @static
49
+ */
50
+ Quaternion.multiplyByVector = function (quaterion, cartesian, result) {
51
+ const rotationMatrix = Matrix3.fromQuaternion(quaterion, Scratch.scratchMatrix3);
52
+ return Matrix3.multiplyByVector(rotationMatrix, cartesian, result);
53
+ };
54
+
55
+ /**
56
+ * 将当前四元数转换为航向、俯仰、横滚角。
57
+ * @param {HeadingPitchRoll} [result] 用于存储结果的可选对象。
58
+ * @returns {HeadingPitchRoll} 对应的航向俯仰横滚角。
59
+ * @memberof Quaternion
60
+ */
61
+ Quaternion.prototype.toHeadingPitchRoll = function (result) {
62
+ return HeadingPitchRoll.fromQuaternion(this, result);
63
+ };
64
+
65
+ export default Quaternion;
66
+ export { Quaternion };