deeptwins-cesium-engine 0.1.5 → 0.1.6

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 (113) hide show
  1. package/Build/Workers/chunk-2YZA6LPJ.js +198 -0
  2. package/Build/Workers/chunk-2ZMHZFLT.js +454 -0
  3. package/Build/Workers/chunk-32XQ4O4B.js +973 -0
  4. package/Build/Workers/chunk-33T2EBLV.js +693 -0
  5. package/Build/Workers/chunk-3432RGPV.js +837 -0
  6. package/Build/Workers/chunk-37GXGYQQ.js +101 -0
  7. package/Build/Workers/chunk-3WKSNJUE.js +511 -0
  8. package/Build/Workers/chunk-44F55BA4.js +1287 -0
  9. package/Build/Workers/chunk-6BDLSEMA.js +219 -0
  10. package/Build/Workers/chunk-7PT7O3YI.js +9230 -0
  11. package/Build/Workers/chunk-7WHDI7BI.js +414 -0
  12. package/Build/Workers/chunk-AFFQ2CMC.js +1067 -0
  13. package/Build/Workers/chunk-BIB6XPIM.js +1483 -0
  14. package/Build/Workers/chunk-C3UF5MNO.js +778 -0
  15. package/Build/Workers/chunk-CCWEI762.js +398 -0
  16. package/Build/Workers/chunk-DAYFBDNX.js +2719 -0
  17. package/Build/Workers/chunk-DBBMSU35.js +58 -0
  18. package/Build/Workers/chunk-DWFATVBP.js +301 -0
  19. package/Build/Workers/chunk-FZRWHZXM.js +497 -0
  20. package/Build/Workers/chunk-G622FWYA.js +162 -0
  21. package/Build/Workers/chunk-GFLPPRNV.js +124 -0
  22. package/Build/Workers/chunk-GLWCA6KI.js +959 -0
  23. package/Build/Workers/chunk-GS3O447E.js +682 -0
  24. package/Build/Workers/chunk-GZTEO4UI.js +1344 -0
  25. package/Build/Workers/chunk-ISBTKJAC.js +82 -0
  26. package/Build/Workers/chunk-JDNJWTFK.js +38 -0
  27. package/Build/Workers/chunk-JGIXLITQ.js +352 -0
  28. package/Build/Workers/chunk-JLVYCO3M.js +56 -0
  29. package/Build/Workers/chunk-JOOUDMTZ.js +1800 -0
  30. package/Build/Workers/chunk-JUKLWXYI.js +352 -0
  31. package/Build/Workers/chunk-JYB4TLTT.js +455 -0
  32. package/Build/Workers/chunk-K32XL6YX.js +789 -0
  33. package/Build/Workers/chunk-KD7ICVZ4.js +305 -0
  34. package/Build/Workers/chunk-KEER6JJ5.js +3792 -0
  35. package/Build/Workers/chunk-LWYIN3TC.js +73 -0
  36. package/Build/Workers/chunk-M5WAMTKF.js +241 -0
  37. package/Build/Workers/chunk-MZT6BFQG.js +280 -0
  38. package/Build/Workers/chunk-NDNNNFEZ.js +140 -0
  39. package/Build/Workers/chunk-NR4EY3OY.js +171 -0
  40. package/Build/Workers/chunk-OEVMB2AO.js +368 -0
  41. package/Build/Workers/chunk-OMHXKTPL.js +138 -0
  42. package/Build/Workers/chunk-QC4WEYAG.js +630 -0
  43. package/Build/Workers/chunk-QQQ3H5CN.js +288 -0
  44. package/Build/Workers/chunk-R73Y7R5E.js +476 -0
  45. package/Build/Workers/chunk-RJRFSM25.js +56 -0
  46. package/Build/Workers/chunk-SOS6DD4R.js +97 -0
  47. package/Build/Workers/chunk-SVMMW4W6.js +163 -0
  48. package/Build/Workers/chunk-TXT5DGKT.js +278 -0
  49. package/Build/Workers/chunk-UGYGGCZX.js +2342 -0
  50. package/Build/Workers/chunk-URJMTCTS.js +387 -0
  51. package/Build/Workers/chunk-VN2GGIVK.js +57 -0
  52. package/Build/Workers/chunk-VSCRQSAK.js +1054 -0
  53. package/Build/Workers/chunk-W2QTHR4Z.js +102 -0
  54. package/Build/Workers/chunk-Z5F4S6OY.js +147 -0
  55. package/Build/Workers/chunk-ZFEO3XIZ.js +44 -0
  56. package/Build/Workers/chunk-ZFZ6MBNW.js +1992 -0
  57. package/Build/Workers/chunk-ZYGJXAFJ.js +3201 -0
  58. package/Build/Workers/combineGeometry.js +24 -24
  59. package/Build/Workers/createBoxGeometry.js +18 -18
  60. package/Build/Workers/createBoxOutlineGeometry.js +16 -16
  61. package/Build/Workers/createCircleGeometry.js +26 -26
  62. package/Build/Workers/createCircleOutlineGeometry.js +19 -19
  63. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
  64. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
  65. package/Build/Workers/createCorridorGeometry.js +29 -29
  66. package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
  67. package/Build/Workers/createCylinderGeometry.js +20 -20
  68. package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
  69. package/Build/Workers/createEllipseGeometry.js +26 -26
  70. package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
  71. package/Build/Workers/createEllipsoidGeometry.js +19 -19
  72. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
  73. package/Build/Workers/createFrustumGeometry.js +18 -18
  74. package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
  75. package/Build/Workers/createGeometry.js +24 -24
  76. package/Build/Workers/createGroundPolylineGeometry.js +22 -22
  77. package/Build/Workers/createPlaneGeometry.js +16 -16
  78. package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
  79. package/Build/Workers/createPolygonGeometry.js +32 -32
  80. package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
  81. package/Build/Workers/createPolylineGeometry.js +25 -25
  82. package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
  83. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
  84. package/Build/Workers/createRectangleGeometry.js +27 -27
  85. package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
  86. package/Build/Workers/createSimplePolylineGeometry.js +23 -23
  87. package/Build/Workers/createSphereGeometry.js +19 -19
  88. package/Build/Workers/createSphereOutlineGeometry.js +18 -18
  89. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  90. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  91. package/Build/Workers/createVectorTileGeometries.js +24 -24
  92. package/Build/Workers/createVectorTilePoints.js +13 -13
  93. package/Build/Workers/createVectorTilePolygons.js +22 -22
  94. package/Build/Workers/createVectorTilePolylines.js +14 -14
  95. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
  96. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
  97. package/Build/Workers/createVerticesFromHeightmap.js +22 -22
  98. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
  99. package/Build/Workers/createWallGeometry.js +24 -24
  100. package/Build/Workers/createWallOutlineGeometry.js +23 -23
  101. package/Build/Workers/decodeDraco.js +10 -10
  102. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  103. package/Build/Workers/decodeI3S.js +10 -10
  104. package/Build/Workers/gaussianSplatSorter.js +4 -4
  105. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  106. package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
  107. package/Build/Workers/transcodeKTX2.js +6 -6
  108. package/Build/Workers/transferTypedArrayTest.js +1 -1
  109. package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
  110. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
  111. package/Source/Scene/ViewshedShadowMap.js +0 -1
  112. package/index.js +223 -223
  113. package/package.json +1 -1
@@ -0,0 +1,198 @@
1
+ /**
2
+ * @license
3
+ * Cesium - https://github.com/CesiumGS/cesium
4
+ * Version 0.1.6
5
+ *
6
+ * Copyright 2011-2022 Cesium Contributors
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ *
20
+ * Columbus View (Pat. Pend.)
21
+ *
22
+ * Portions licensed separately.
23
+ * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
24
+ */
25
+
26
+ import {
27
+ PolylinePipeline_default
28
+ } from "./chunk-7WHDI7BI.js";
29
+ import {
30
+ arrayRemoveDuplicates_default
31
+ } from "./chunk-SOS6DD4R.js";
32
+ import {
33
+ Cartographic_default
34
+ } from "./chunk-ZFZ6MBNW.js";
35
+ import {
36
+ Cartesian3_default
37
+ } from "./chunk-UGYGGCZX.js";
38
+ import {
39
+ Math_default
40
+ } from "./chunk-FZRWHZXM.js";
41
+ import {
42
+ defined_default
43
+ } from "./chunk-ISBTKJAC.js";
44
+
45
+ // packages/engine/Source/Core/WallGeometryLibrary.js
46
+ var WallGeometryLibrary = {};
47
+ function latLonEquals(c0, c1) {
48
+ return Math_default.equalsEpsilon(c0.latitude, c1.latitude, Math_default.EPSILON10) && Math_default.equalsEpsilon(c0.longitude, c1.longitude, Math_default.EPSILON10);
49
+ }
50
+ var scratchCartographic1 = new Cartographic_default();
51
+ var scratchCartographic2 = new Cartographic_default();
52
+ function removeDuplicates(ellipsoid, positions, topHeights, bottomHeights) {
53
+ positions = arrayRemoveDuplicates_default(positions, Cartesian3_default.equalsEpsilon);
54
+ const length = positions.length;
55
+ if (length < 2) {
56
+ return;
57
+ }
58
+ const hasBottomHeights = defined_default(bottomHeights);
59
+ const hasTopHeights = defined_default(topHeights);
60
+ const cleanedPositions = new Array(length);
61
+ const cleanedTopHeights = new Array(length);
62
+ const cleanedBottomHeights = new Array(length);
63
+ const v0 = positions[0];
64
+ cleanedPositions[0] = v0;
65
+ const c0 = ellipsoid.cartesianToCartographic(v0, scratchCartographic1);
66
+ if (hasTopHeights) {
67
+ c0.height = topHeights[0];
68
+ }
69
+ cleanedTopHeights[0] = c0.height;
70
+ if (hasBottomHeights) {
71
+ cleanedBottomHeights[0] = bottomHeights[0];
72
+ } else {
73
+ cleanedBottomHeights[0] = 0;
74
+ }
75
+ const startTopHeight = cleanedTopHeights[0];
76
+ const startBottomHeight = cleanedBottomHeights[0];
77
+ let hasAllSameHeights = startTopHeight === startBottomHeight;
78
+ let index = 1;
79
+ for (let i = 1; i < length; ++i) {
80
+ const v1 = positions[i];
81
+ const c1 = ellipsoid.cartesianToCartographic(v1, scratchCartographic2);
82
+ if (hasTopHeights) {
83
+ c1.height = topHeights[i];
84
+ }
85
+ hasAllSameHeights = hasAllSameHeights && c1.height === 0;
86
+ if (!latLonEquals(c0, c1)) {
87
+ cleanedPositions[index] = v1;
88
+ cleanedTopHeights[index] = c1.height;
89
+ if (hasBottomHeights) {
90
+ cleanedBottomHeights[index] = bottomHeights[i];
91
+ } else {
92
+ cleanedBottomHeights[index] = 0;
93
+ }
94
+ hasAllSameHeights = hasAllSameHeights && cleanedTopHeights[index] === cleanedBottomHeights[index];
95
+ Cartographic_default.clone(c1, c0);
96
+ ++index;
97
+ } else if (c0.height < c1.height) {
98
+ cleanedTopHeights[index - 1] = c1.height;
99
+ }
100
+ }
101
+ if (hasAllSameHeights || index < 2) {
102
+ return;
103
+ }
104
+ cleanedPositions.length = index;
105
+ cleanedTopHeights.length = index;
106
+ cleanedBottomHeights.length = index;
107
+ return {
108
+ positions: cleanedPositions,
109
+ topHeights: cleanedTopHeights,
110
+ bottomHeights: cleanedBottomHeights
111
+ };
112
+ }
113
+ var positionsArrayScratch = new Array(2);
114
+ var heightsArrayScratch = new Array(2);
115
+ var generateArcOptionsScratch = {
116
+ positions: void 0,
117
+ height: void 0,
118
+ granularity: void 0,
119
+ ellipsoid: void 0
120
+ };
121
+ WallGeometryLibrary.computePositions = function(ellipsoid, wallPositions, maximumHeights, minimumHeights, granularity, duplicateCorners) {
122
+ const o = removeDuplicates(
123
+ ellipsoid,
124
+ wallPositions,
125
+ maximumHeights,
126
+ minimumHeights
127
+ );
128
+ if (!defined_default(o)) {
129
+ return;
130
+ }
131
+ wallPositions = o.positions;
132
+ maximumHeights = o.topHeights;
133
+ minimumHeights = o.bottomHeights;
134
+ const length = wallPositions.length;
135
+ const numCorners = length - 2;
136
+ let topPositions;
137
+ let bottomPositions;
138
+ const minDistance = Math_default.chordLength(
139
+ granularity,
140
+ ellipsoid.maximumRadius
141
+ );
142
+ const generateArcOptions = generateArcOptionsScratch;
143
+ generateArcOptions.minDistance = minDistance;
144
+ generateArcOptions.ellipsoid = ellipsoid;
145
+ if (duplicateCorners) {
146
+ let count = 0;
147
+ let i;
148
+ for (i = 0; i < length - 1; i++) {
149
+ count += PolylinePipeline_default.numberOfPoints(
150
+ wallPositions[i],
151
+ wallPositions[i + 1],
152
+ minDistance
153
+ ) + 1;
154
+ }
155
+ topPositions = new Float64Array(count * 3);
156
+ bottomPositions = new Float64Array(count * 3);
157
+ const generateArcPositions = positionsArrayScratch;
158
+ const generateArcHeights = heightsArrayScratch;
159
+ generateArcOptions.positions = generateArcPositions;
160
+ generateArcOptions.height = generateArcHeights;
161
+ let offset = 0;
162
+ for (i = 0; i < length - 1; i++) {
163
+ generateArcPositions[0] = wallPositions[i];
164
+ generateArcPositions[1] = wallPositions[i + 1];
165
+ generateArcHeights[0] = maximumHeights[i];
166
+ generateArcHeights[1] = maximumHeights[i + 1];
167
+ const pos = PolylinePipeline_default.generateArc(generateArcOptions);
168
+ topPositions.set(pos, offset);
169
+ generateArcHeights[0] = minimumHeights[i];
170
+ generateArcHeights[1] = minimumHeights[i + 1];
171
+ bottomPositions.set(
172
+ PolylinePipeline_default.generateArc(generateArcOptions),
173
+ offset
174
+ );
175
+ offset += pos.length;
176
+ }
177
+ } else {
178
+ generateArcOptions.positions = wallPositions;
179
+ generateArcOptions.height = maximumHeights;
180
+ topPositions = new Float64Array(
181
+ PolylinePipeline_default.generateArc(generateArcOptions)
182
+ );
183
+ generateArcOptions.height = minimumHeights;
184
+ bottomPositions = new Float64Array(
185
+ PolylinePipeline_default.generateArc(generateArcOptions)
186
+ );
187
+ }
188
+ return {
189
+ bottomPositions,
190
+ topPositions,
191
+ numCorners
192
+ };
193
+ };
194
+ var WallGeometryLibrary_default = WallGeometryLibrary;
195
+
196
+ export {
197
+ WallGeometryLibrary_default
198
+ };
@@ -0,0 +1,454 @@
1
+ /**
2
+ * @license
3
+ * Cesium - https://github.com/CesiumGS/cesium
4
+ * Version 0.1.6
5
+ *
6
+ * Copyright 2011-2022 Cesium Contributors
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ *
20
+ * Columbus View (Pat. Pend.)
21
+ *
22
+ * Portions licensed separately.
23
+ * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
24
+ */
25
+
26
+ import {
27
+ Matrix2_default
28
+ } from "./chunk-7PT7O3YI.js";
29
+ import {
30
+ Cartesian4_default,
31
+ Matrix4_default
32
+ } from "./chunk-ZYGJXAFJ.js";
33
+ import {
34
+ ComponentDatatype_default
35
+ } from "./chunk-TXT5DGKT.js";
36
+ import {
37
+ Cartesian2_default
38
+ } from "./chunk-ZFZ6MBNW.js";
39
+ import {
40
+ Cartesian3_default,
41
+ Matrix3_default
42
+ } from "./chunk-UGYGGCZX.js";
43
+ import {
44
+ Math_default
45
+ } from "./chunk-FZRWHZXM.js";
46
+ import {
47
+ Check_default,
48
+ DeveloperError_default
49
+ } from "./chunk-SVMMW4W6.js";
50
+ import {
51
+ defined_default
52
+ } from "./chunk-ISBTKJAC.js";
53
+
54
+ // packages/engine/Source/Scene/AttributeType.js
55
+ var AttributeType = {
56
+ /**
57
+ * The attribute is a single component.
58
+ *
59
+ * @type {string}
60
+ * @constant
61
+ */
62
+ SCALAR: "SCALAR",
63
+ /**
64
+ * The attribute is a two-component vector.
65
+ *
66
+ * @type {string}
67
+ * @constant
68
+ */
69
+ VEC2: "VEC2",
70
+ /**
71
+ * The attribute is a three-component vector.
72
+ *
73
+ * @type {string}
74
+ * @constant
75
+ */
76
+ VEC3: "VEC3",
77
+ /**
78
+ * The attribute is a four-component vector.
79
+ *
80
+ * @type {string}
81
+ * @constant
82
+ */
83
+ VEC4: "VEC4",
84
+ /**
85
+ * The attribute is a 2x2 matrix.
86
+ *
87
+ * @type {string}
88
+ * @constant
89
+ */
90
+ MAT2: "MAT2",
91
+ /**
92
+ * The attribute is a 3x3 matrix.
93
+ *
94
+ * @type {string}
95
+ * @constant
96
+ */
97
+ MAT3: "MAT3",
98
+ /**
99
+ * The attribute is a 4x4 matrix.
100
+ *
101
+ * @type {string}
102
+ * @constant
103
+ */
104
+ MAT4: "MAT4"
105
+ };
106
+ AttributeType.getMathType = function(attributeType) {
107
+ switch (attributeType) {
108
+ case AttributeType.SCALAR:
109
+ return Number;
110
+ case AttributeType.VEC2:
111
+ return Cartesian2_default;
112
+ case AttributeType.VEC3:
113
+ return Cartesian3_default;
114
+ case AttributeType.VEC4:
115
+ return Cartesian4_default;
116
+ case AttributeType.MAT2:
117
+ return Matrix2_default;
118
+ case AttributeType.MAT3:
119
+ return Matrix3_default;
120
+ case AttributeType.MAT4:
121
+ return Matrix4_default;
122
+ //>>includeStart('debug', pragmas.debug);
123
+ default:
124
+ throw new DeveloperError_default("attributeType is not a valid value.");
125
+ }
126
+ };
127
+ AttributeType.getNumberOfComponents = function(attributeType) {
128
+ switch (attributeType) {
129
+ case AttributeType.SCALAR:
130
+ return 1;
131
+ case AttributeType.VEC2:
132
+ return 2;
133
+ case AttributeType.VEC3:
134
+ return 3;
135
+ case AttributeType.VEC4:
136
+ case AttributeType.MAT2:
137
+ return 4;
138
+ case AttributeType.MAT3:
139
+ return 9;
140
+ case AttributeType.MAT4:
141
+ return 16;
142
+ //>>includeStart('debug', pragmas.debug);
143
+ default:
144
+ throw new DeveloperError_default("attributeType is not a valid value.");
145
+ }
146
+ };
147
+ AttributeType.getAttributeLocationCount = function(attributeType) {
148
+ switch (attributeType) {
149
+ case AttributeType.SCALAR:
150
+ case AttributeType.VEC2:
151
+ case AttributeType.VEC3:
152
+ case AttributeType.VEC4:
153
+ return 1;
154
+ case AttributeType.MAT2:
155
+ return 2;
156
+ case AttributeType.MAT3:
157
+ return 3;
158
+ case AttributeType.MAT4:
159
+ return 4;
160
+ //>>includeStart('debug', pragmas.debug);
161
+ default:
162
+ throw new DeveloperError_default("attributeType is not a valid value.");
163
+ }
164
+ };
165
+ AttributeType.getGlslType = function(attributeType) {
166
+ Check_default.typeOf.string("attributeType", attributeType);
167
+ switch (attributeType) {
168
+ case AttributeType.SCALAR:
169
+ return "float";
170
+ case AttributeType.VEC2:
171
+ return "vec2";
172
+ case AttributeType.VEC3:
173
+ return "vec3";
174
+ case AttributeType.VEC4:
175
+ return "vec4";
176
+ case AttributeType.MAT2:
177
+ return "mat2";
178
+ case AttributeType.MAT3:
179
+ return "mat3";
180
+ case AttributeType.MAT4:
181
+ return "mat4";
182
+ //>>includeStart('debug', pragmas.debug);
183
+ default:
184
+ throw new DeveloperError_default("attributeType is not a valid value.");
185
+ }
186
+ };
187
+ Object.freeze(AttributeType);
188
+ var AttributeType_default = AttributeType;
189
+
190
+ // packages/engine/Source/Core/AttributeCompression.js
191
+ var RIGHT_SHIFT8 = 1 / 256;
192
+ var LEFT_SHIFT16 = 65536;
193
+ var LEFT_SHIFT8 = 256;
194
+ var AttributeCompression = {};
195
+ AttributeCompression.octEncodeInRange = function(vector, rangeMax, result) {
196
+ Check_default.defined("vector", vector);
197
+ Check_default.defined("result", result);
198
+ const magSquared = Cartesian3_default.magnitudeSquared(vector);
199
+ if (Math.abs(magSquared - 1) > Math_default.EPSILON6) {
200
+ throw new DeveloperError_default("vector must be normalized.");
201
+ }
202
+ result.x = vector.x / (Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z));
203
+ result.y = vector.y / (Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z));
204
+ if (vector.z < 0) {
205
+ const x = result.x;
206
+ const y = result.y;
207
+ result.x = (1 - Math.abs(y)) * Math_default.signNotZero(x);
208
+ result.y = (1 - Math.abs(x)) * Math_default.signNotZero(y);
209
+ }
210
+ result.x = Math_default.toSNorm(result.x, rangeMax);
211
+ result.y = Math_default.toSNorm(result.y, rangeMax);
212
+ return result;
213
+ };
214
+ AttributeCompression.octEncode = function(vector, result) {
215
+ return AttributeCompression.octEncodeInRange(vector, 255, result);
216
+ };
217
+ var octEncodeScratch = new Cartesian2_default();
218
+ var uint8ForceArray = new Uint8Array(1);
219
+ function forceUint8(value) {
220
+ uint8ForceArray[0] = value;
221
+ return uint8ForceArray[0];
222
+ }
223
+ AttributeCompression.octEncodeToCartesian4 = function(vector, result) {
224
+ AttributeCompression.octEncodeInRange(vector, 65535, octEncodeScratch);
225
+ result.x = forceUint8(octEncodeScratch.x * RIGHT_SHIFT8);
226
+ result.y = forceUint8(octEncodeScratch.x);
227
+ result.z = forceUint8(octEncodeScratch.y * RIGHT_SHIFT8);
228
+ result.w = forceUint8(octEncodeScratch.y);
229
+ return result;
230
+ };
231
+ AttributeCompression.octDecodeInRange = function(x, y, rangeMax, result) {
232
+ Check_default.defined("result", result);
233
+ if (x < 0 || x > rangeMax || y < 0 || y > rangeMax) {
234
+ throw new DeveloperError_default(
235
+ `x and y must be unsigned normalized integers between 0 and ${rangeMax}`
236
+ );
237
+ }
238
+ result.x = Math_default.fromSNorm(x, rangeMax);
239
+ result.y = Math_default.fromSNorm(y, rangeMax);
240
+ result.z = 1 - (Math.abs(result.x) + Math.abs(result.y));
241
+ if (result.z < 0) {
242
+ const oldVX = result.x;
243
+ result.x = (1 - Math.abs(result.y)) * Math_default.signNotZero(oldVX);
244
+ result.y = (1 - Math.abs(oldVX)) * Math_default.signNotZero(result.y);
245
+ }
246
+ return Cartesian3_default.normalize(result, result);
247
+ };
248
+ AttributeCompression.octDecode = function(x, y, result) {
249
+ return AttributeCompression.octDecodeInRange(x, y, 255, result);
250
+ };
251
+ AttributeCompression.octDecodeFromCartesian4 = function(encoded, result) {
252
+ Check_default.typeOf.object("encoded", encoded);
253
+ Check_default.typeOf.object("result", result);
254
+ const x = encoded.x;
255
+ const y = encoded.y;
256
+ const z = encoded.z;
257
+ const w = encoded.w;
258
+ if (x < 0 || x > 255 || y < 0 || y > 255 || z < 0 || z > 255 || w < 0 || w > 255) {
259
+ throw new DeveloperError_default(
260
+ "x, y, z, and w must be unsigned normalized integers between 0 and 255"
261
+ );
262
+ }
263
+ const xOct16 = x * LEFT_SHIFT8 + y;
264
+ const yOct16 = z * LEFT_SHIFT8 + w;
265
+ return AttributeCompression.octDecodeInRange(xOct16, yOct16, 65535, result);
266
+ };
267
+ AttributeCompression.octPackFloat = function(encoded) {
268
+ Check_default.defined("encoded", encoded);
269
+ return 256 * encoded.x + encoded.y;
270
+ };
271
+ var scratchEncodeCart2 = new Cartesian2_default();
272
+ AttributeCompression.octEncodeFloat = function(vector) {
273
+ AttributeCompression.octEncode(vector, scratchEncodeCart2);
274
+ return AttributeCompression.octPackFloat(scratchEncodeCart2);
275
+ };
276
+ AttributeCompression.octDecodeFloat = function(value, result) {
277
+ Check_default.defined("value", value);
278
+ const temp = value / 256;
279
+ const x = Math.floor(temp);
280
+ const y = (temp - x) * 256;
281
+ return AttributeCompression.octDecode(x, y, result);
282
+ };
283
+ AttributeCompression.octPack = function(v1, v2, v3, result) {
284
+ Check_default.defined("v1", v1);
285
+ Check_default.defined("v2", v2);
286
+ Check_default.defined("v3", v3);
287
+ Check_default.defined("result", result);
288
+ const encoded1 = AttributeCompression.octEncodeFloat(v1);
289
+ const encoded2 = AttributeCompression.octEncodeFloat(v2);
290
+ const encoded3 = AttributeCompression.octEncode(v3, scratchEncodeCart2);
291
+ result.x = 65536 * encoded3.x + encoded1;
292
+ result.y = 65536 * encoded3.y + encoded2;
293
+ return result;
294
+ };
295
+ AttributeCompression.octUnpack = function(packed, v1, v2, v3) {
296
+ Check_default.defined("packed", packed);
297
+ Check_default.defined("v1", v1);
298
+ Check_default.defined("v2", v2);
299
+ Check_default.defined("v3", v3);
300
+ let temp = packed.x / 65536;
301
+ const x = Math.floor(temp);
302
+ const encodedFloat1 = (temp - x) * 65536;
303
+ temp = packed.y / 65536;
304
+ const y = Math.floor(temp);
305
+ const encodedFloat2 = (temp - y) * 65536;
306
+ AttributeCompression.octDecodeFloat(encodedFloat1, v1);
307
+ AttributeCompression.octDecodeFloat(encodedFloat2, v2);
308
+ AttributeCompression.octDecode(x, y, v3);
309
+ };
310
+ AttributeCompression.compressTextureCoordinates = function(textureCoordinates) {
311
+ Check_default.defined("textureCoordinates", textureCoordinates);
312
+ const x = textureCoordinates.x * 4095 | 0;
313
+ const y = textureCoordinates.y * 4095 | 0;
314
+ return 4096 * x + y;
315
+ };
316
+ AttributeCompression.decompressTextureCoordinates = function(compressed, result) {
317
+ Check_default.defined("compressed", compressed);
318
+ Check_default.defined("result", result);
319
+ const temp = compressed / 4096;
320
+ const xZeroTo4095 = Math.floor(temp);
321
+ result.x = xZeroTo4095 / 4095;
322
+ result.y = (compressed - xZeroTo4095 * 4096) / 4095;
323
+ return result;
324
+ };
325
+ function zigZagDecode(value) {
326
+ return value >> 1 ^ -(value & 1);
327
+ }
328
+ AttributeCompression.zigZagDeltaDecode = function(uBuffer, vBuffer, heightBuffer) {
329
+ Check_default.defined("uBuffer", uBuffer);
330
+ Check_default.defined("vBuffer", vBuffer);
331
+ Check_default.typeOf.number.equals(
332
+ "uBuffer.length",
333
+ "vBuffer.length",
334
+ uBuffer.length,
335
+ vBuffer.length
336
+ );
337
+ if (defined_default(heightBuffer)) {
338
+ Check_default.typeOf.number.equals(
339
+ "uBuffer.length",
340
+ "heightBuffer.length",
341
+ uBuffer.length,
342
+ heightBuffer.length
343
+ );
344
+ }
345
+ const count = uBuffer.length;
346
+ let u = 0;
347
+ let v = 0;
348
+ let height = 0;
349
+ for (let i = 0; i < count; ++i) {
350
+ u += zigZagDecode(uBuffer[i]);
351
+ v += zigZagDecode(vBuffer[i]);
352
+ uBuffer[i] = u;
353
+ vBuffer[i] = v;
354
+ if (defined_default(heightBuffer)) {
355
+ height += zigZagDecode(heightBuffer[i]);
356
+ heightBuffer[i] = height;
357
+ }
358
+ }
359
+ };
360
+ AttributeCompression.dequantize = function(typedArray, componentDatatype, type, count) {
361
+ Check_default.defined("typedArray", typedArray);
362
+ Check_default.defined("componentDatatype", componentDatatype);
363
+ Check_default.defined("type", type);
364
+ Check_default.defined("count", count);
365
+ const componentsPerAttribute = AttributeType_default.getNumberOfComponents(type);
366
+ let divisor;
367
+ switch (componentDatatype) {
368
+ case ComponentDatatype_default.BYTE:
369
+ divisor = 127;
370
+ break;
371
+ case ComponentDatatype_default.UNSIGNED_BYTE:
372
+ divisor = 255;
373
+ break;
374
+ case ComponentDatatype_default.SHORT:
375
+ divisor = 32767;
376
+ break;
377
+ case ComponentDatatype_default.UNSIGNED_SHORT:
378
+ divisor = 65535;
379
+ break;
380
+ case ComponentDatatype_default.INT:
381
+ divisor = 2147483647;
382
+ break;
383
+ case ComponentDatatype_default.UNSIGNED_INT:
384
+ divisor = 4294967295;
385
+ break;
386
+ //>>includeStart('debug', pragmas.debug);
387
+ default:
388
+ throw new DeveloperError_default(
389
+ `Cannot dequantize component datatype: ${componentDatatype}`
390
+ );
391
+ }
392
+ const dequantizedTypedArray = new Float32Array(
393
+ count * componentsPerAttribute
394
+ );
395
+ for (let i = 0; i < count; i++) {
396
+ for (let j = 0; j < componentsPerAttribute; j++) {
397
+ const index = i * componentsPerAttribute + j;
398
+ dequantizedTypedArray[index] = Math.max(
399
+ typedArray[index] / divisor,
400
+ -1
401
+ );
402
+ }
403
+ }
404
+ return dequantizedTypedArray;
405
+ };
406
+ AttributeCompression.encodeRGB8 = function(color) {
407
+ Check_default.typeOf.object("color", color);
408
+ return Math.round(Math_default.clamp(color.red * 255, 0, 255)) * LEFT_SHIFT16 + Math.round(Math_default.clamp(color.green * 255, 0, 255)) * LEFT_SHIFT8 + Math.round(Math_default.clamp(color.blue * 255, 0, 255));
409
+ };
410
+ AttributeCompression.decodeRGB8 = function(encoded, result) {
411
+ Check_default.typeOf.number("encoded", encoded);
412
+ Check_default.typeOf.object("result", result);
413
+ encoded = Math.floor(encoded);
414
+ result.red = (encoded >> 16 & 255) / 255;
415
+ result.green = (encoded >> 8 & 255) / 255;
416
+ result.blue = (encoded & 255) / 255;
417
+ return result;
418
+ };
419
+ AttributeCompression.decodeRGB565 = function(typedArray, result) {
420
+ Check_default.defined("typedArray", typedArray);
421
+ const expectedLength = typedArray.length * 3;
422
+ if (defined_default(result)) {
423
+ Check_default.typeOf.number.equals(
424
+ "result.length",
425
+ "typedArray.length * 3",
426
+ result.length,
427
+ expectedLength
428
+ );
429
+ }
430
+ const count = typedArray.length;
431
+ if (!defined_default(result)) {
432
+ result = new Float32Array(count * 3);
433
+ }
434
+ const mask5 = (1 << 5) - 1;
435
+ const mask6 = (1 << 6) - 1;
436
+ const normalize5 = 1 / 31;
437
+ const normalize6 = 1 / 63;
438
+ for (let i = 0; i < count; i++) {
439
+ const value = typedArray[i];
440
+ const red = value >> 11;
441
+ const green = value >> 5 & mask6;
442
+ const blue = value & mask5;
443
+ const offset = 3 * i;
444
+ result[offset] = red * normalize5;
445
+ result[offset + 1] = green * normalize6;
446
+ result[offset + 2] = blue * normalize5;
447
+ }
448
+ return result;
449
+ };
450
+ var AttributeCompression_default = AttributeCompression;
451
+
452
+ export {
453
+ AttributeCompression_default
454
+ };