@rtzh/engine 0.0.5 → 0.0.7

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 (237) hide show
  1. package/Build/Workers/chunk-243UEBJF.js +1045 -0
  2. package/Build/Workers/chunk-2UNHFFAZ.js +352 -0
  3. package/Build/Workers/chunk-2Y2KA6PM.js +387 -0
  4. package/Build/Workers/chunk-2ZXYLPPT.js +163 -0
  5. package/Build/Workers/chunk-32ZGDYJY.js +3514 -0
  6. package/Build/Workers/chunk-3NSMZ3XW.js +1067 -0
  7. package/Build/Workers/chunk-3WT5VKYM.js +101 -0
  8. package/Build/Workers/chunk-4DIL24GG.js +1460 -0
  9. package/Build/Workers/chunk-4FEDW3WT.js +299 -0
  10. package/Build/Workers/chunk-4IXXMXPJ.js +682 -0
  11. package/Build/Workers/chunk-4SC4KVID.js +692 -0
  12. package/Build/Workers/chunk-52UUGJQ6.js +288 -0
  13. package/Build/Workers/chunk-53AFSDGM.js +37 -0
  14. package/Build/Workers/chunk-54LZ6OUD.js +1067 -0
  15. package/Build/Workers/chunk-54SSO7NS.js +352 -0
  16. package/Build/Workers/chunk-565HBO3F.js +352 -0
  17. package/Build/Workers/chunk-5L3PEFKO.js +629 -0
  18. package/Build/Workers/chunk-5RMI6LFO.js +692 -0
  19. package/Build/Workers/chunk-5SVTAJRH.js +837 -0
  20. package/Build/Workers/chunk-5VDZEVQX.js +788 -0
  21. package/Build/Workers/chunk-5VWFNSLF.js +44 -0
  22. package/Build/Workers/chunk-5W4ISZGQ.js +1483 -0
  23. package/Build/Workers/chunk-5ZMMQ7HE.js +37 -0
  24. package/Build/Workers/chunk-64VDO4BW.js +114 -0
  25. package/Build/Workers/chunk-6AUSOZOL.js +476 -0
  26. package/Build/Workers/chunk-6BIU5AL4.js +692 -0
  27. package/Build/Workers/chunk-6KA3AJM6.js +455 -0
  28. package/Build/Workers/chunk-6MYDYE24.js +280 -0
  29. package/Build/Workers/chunk-6RUDXAFC.js +2719 -0
  30. package/Build/Workers/chunk-6YSUD2OH.js +219 -0
  31. package/Build/Workers/chunk-6YT2LZ3Z.js +1443 -0
  32. package/Build/Workers/chunk-73EGVDOC.js +398 -0
  33. package/Build/Workers/chunk-7BOVULMD.js +44 -0
  34. package/Build/Workers/chunk-7KOMCIWI.js +8366 -0
  35. package/Build/Workers/chunk-7MMYV5PM.js +288 -0
  36. package/Build/Workers/chunk-7QPQGSS3.js +57 -0
  37. package/Build/Workers/chunk-AEURJQ3B.js +73 -0
  38. package/Build/Workers/chunk-AMJRLIO3.js +414 -0
  39. package/Build/Workers/chunk-APOATHFZ.js +138 -0
  40. package/Build/Workers/chunk-AVNHAFMV.js +114 -0
  41. package/Build/Workers/chunk-AWMYTHW4.js +101 -0
  42. package/Build/Workers/chunk-BCYABDWF.js +3514 -0
  43. package/Build/Workers/chunk-BJHSYHOQ.js +97 -0
  44. package/Build/Workers/chunk-BM6ZG63T.js +171 -0
  45. package/Build/Workers/chunk-C3G2NDXM.js +162 -0
  46. package/Build/Workers/chunk-CTARL7CY.js +511 -0
  47. package/Build/Workers/chunk-DIA4J2DB.js +497 -0
  48. package/Build/Workers/chunk-E3NHG3TR.js +1460 -0
  49. package/Build/Workers/chunk-E5BSDIGY.js +139 -0
  50. package/Build/Workers/chunk-EDVAQGDJ.js +2719 -0
  51. package/Build/Workers/chunk-EFHDO3L2.js +102 -0
  52. package/Build/Workers/chunk-EJVGOIOW.js +1317 -0
  53. package/Build/Workers/chunk-EPVJ5OOH.js +8366 -0
  54. package/Build/Workers/chunk-ERYOZBVC.js +171 -0
  55. package/Build/Workers/chunk-ET7LWDHA.js +58 -0
  56. package/Build/Workers/chunk-EWDHM5NC.js +37 -0
  57. package/Build/Workers/chunk-F4Q3VOCC.js +1317 -0
  58. package/Build/Workers/chunk-FCSN7XOU.js +55 -0
  59. package/Build/Workers/chunk-FD62YGTB.js +219 -0
  60. package/Build/Workers/chunk-FHM3HFYM.js +1045 -0
  61. package/Build/Workers/chunk-FNI64UKI.js +57 -0
  62. package/Build/Workers/chunk-FRUZKVBP.js +352 -0
  63. package/Build/Workers/chunk-FSYQE5XE.js +55 -0
  64. package/Build/Workers/chunk-FYW5UQ24.js +837 -0
  65. package/Build/Workers/chunk-FYZVCB32.js +75 -0
  66. package/Build/Workers/chunk-G7PGTG3P.js +387 -0
  67. package/Build/Workers/chunk-GAQXLBFJ.js +1483 -0
  68. package/Build/Workers/chunk-GEH53ULL.js +299 -0
  69. package/Build/Workers/chunk-GLA2PT5T.js +476 -0
  70. package/Build/Workers/chunk-GWLEBUVI.js +2058 -0
  71. package/Build/Workers/chunk-GYIGOBV2.js +439 -0
  72. package/Build/Workers/chunk-GZMTBQM2.js +1443 -0
  73. package/Build/Workers/chunk-H2MM7FMU.js +1054 -0
  74. package/Build/Workers/chunk-H33FCT5U.js +940 -0
  75. package/Build/Workers/chunk-HAR6Y2HP.js +1800 -0
  76. package/Build/Workers/chunk-HBL3QZ2L.js +642 -0
  77. package/Build/Workers/chunk-HEKLTOOR.js +1443 -0
  78. package/Build/Workers/chunk-HM4MH5IG.js +138 -0
  79. package/Build/Workers/chunk-I5JHYEIE.js +241 -0
  80. package/Build/Workers/chunk-IB2XQV6U.js +101 -0
  81. package/Build/Workers/chunk-IC2JHDCI.js +114 -0
  82. package/Build/Workers/chunk-IEEHNZ36.js +241 -0
  83. package/Build/Workers/chunk-IRG63TBY.js +55 -0
  84. package/Build/Workers/chunk-IXM65GBF.js +256 -0
  85. package/Build/Workers/chunk-IY53MZW2.js +58 -0
  86. package/Build/Workers/chunk-IYAZCFAC.js +642 -0
  87. package/Build/Workers/chunk-J2CUNLQP.js +940 -0
  88. package/Build/Workers/chunk-J766O3PA.js +256 -0
  89. package/Build/Workers/chunk-JRPAFYGJ.js +1054 -0
  90. package/Build/Workers/chunk-JWEZXKBE.js +73 -0
  91. package/Build/Workers/chunk-KFOT2YV5.js +138 -0
  92. package/Build/Workers/chunk-KGQGZ7PF.js +778 -0
  93. package/Build/Workers/chunk-KMZXZUA7.js +1460 -0
  94. package/Build/Workers/chunk-KOVKY3HB.js +198 -0
  95. package/Build/Workers/chunk-KQ4ET526.js +163 -0
  96. package/Build/Workers/chunk-L2QIVAZV.js +3514 -0
  97. package/Build/Workers/chunk-LGMONS4O.js +1317 -0
  98. package/Build/Workers/chunk-LJHG4PJQ.js +305 -0
  99. package/Build/Workers/chunk-LNS36LUZ.js +2058 -0
  100. package/Build/Workers/chunk-LPJHTJDQ.js +305 -0
  101. package/Build/Workers/chunk-LRW2QXMW.js +352 -0
  102. package/Build/Workers/chunk-LUUEGFLT.js +305 -0
  103. package/Build/Workers/chunk-LW2VGHDM.js +1800 -0
  104. package/Build/Workers/chunk-LXM2ZC4V.js +288 -0
  105. package/Build/Workers/chunk-LXMLERGC.js +1067 -0
  106. package/Build/Workers/chunk-MEFWVMG6.js +788 -0
  107. package/Build/Workers/chunk-MJVNNURF.js +368 -0
  108. package/Build/Workers/chunk-MWN26ZEM.js +280 -0
  109. package/Build/Workers/chunk-NIWB6UMY.js +198 -0
  110. package/Build/Workers/chunk-NJEG7WRW.js +387 -0
  111. package/Build/Workers/chunk-O224ZEA5.js +58 -0
  112. package/Build/Workers/chunk-O5ICO3AS.js +682 -0
  113. package/Build/Workers/chunk-O5QH7XD5.js +629 -0
  114. package/Build/Workers/chunk-O6T3T3V3.js +97 -0
  115. package/Build/Workers/chunk-OBM2JYMG.js +75 -0
  116. package/Build/Workers/chunk-ODZZZGXK.js +219 -0
  117. package/Build/Workers/chunk-OFTWEOW2.js +1483 -0
  118. package/Build/Workers/chunk-OIJH6LAY.js +497 -0
  119. package/Build/Workers/chunk-OJFVD5ZS.js +778 -0
  120. package/Build/Workers/chunk-OJNPKCEL.js +73 -0
  121. package/Build/Workers/chunk-PQLZOYZE.js +642 -0
  122. package/Build/Workers/chunk-PU44PXY2.js +75 -0
  123. package/Build/Workers/chunk-Q36VXWGP.js +57 -0
  124. package/Build/Workers/chunk-Q4XPVYXJ.js +476 -0
  125. package/Build/Workers/chunk-QGXE4VZ3.js +55 -0
  126. package/Build/Workers/chunk-QIEHP7O4.js +280 -0
  127. package/Build/Workers/chunk-QY55DT53.js +97 -0
  128. package/Build/Workers/chunk-R3PTQZ6H.js +44 -0
  129. package/Build/Workers/chunk-RJVB3K2X.js +511 -0
  130. package/Build/Workers/chunk-RORZNBGJ.js +299 -0
  131. package/Build/Workers/chunk-RRBGLANL.js +55 -0
  132. package/Build/Workers/chunk-RT7PY6BH.js +2719 -0
  133. package/Build/Workers/chunk-SAD42JSM.js +102 -0
  134. package/Build/Workers/chunk-SBR7MW44.js +139 -0
  135. package/Build/Workers/chunk-SFM3GNS2.js +682 -0
  136. package/Build/Workers/chunk-SKXE77AM.js +139 -0
  137. package/Build/Workers/chunk-SLYUIIFB.js +455 -0
  138. package/Build/Workers/chunk-SQSWONTJ.js +241 -0
  139. package/Build/Workers/chunk-SRLJWNU2.js +368 -0
  140. package/Build/Workers/chunk-SZELHE7Q.js +163 -0
  141. package/Build/Workers/chunk-T4LDJBKR.js +124 -0
  142. package/Build/Workers/chunk-TBASKFFL.js +124 -0
  143. package/Build/Workers/chunk-TDGGEIZE.js +398 -0
  144. package/Build/Workers/chunk-TQ63SH2Z.js +352 -0
  145. package/Build/Workers/chunk-U3VI26GL.js +162 -0
  146. package/Build/Workers/chunk-U77FLUQF.js +368 -0
  147. package/Build/Workers/chunk-UIYQEJ5H.js +1054 -0
  148. package/Build/Workers/chunk-UJ72JOGF.js +511 -0
  149. package/Build/Workers/chunk-UY7I27VQ.js +1800 -0
  150. package/Build/Workers/chunk-VLB25GGE.js +439 -0
  151. package/Build/Workers/chunk-VVKDT4J7.js +837 -0
  152. package/Build/Workers/chunk-VXDOONLH.js +162 -0
  153. package/Build/Workers/chunk-W4DV7TAL.js +8366 -0
  154. package/Build/Workers/chunk-WFTPZ3ZX.js +788 -0
  155. package/Build/Workers/chunk-WLIQ26XU.js +455 -0
  156. package/Build/Workers/chunk-WOEPS2UA.js +171 -0
  157. package/Build/Workers/chunk-WWLWTSMV.js +55 -0
  158. package/Build/Workers/chunk-WX2ZANQC.js +940 -0
  159. package/Build/Workers/chunk-XEB4GEXW.js +629 -0
  160. package/Build/Workers/chunk-XFKTM6GN.js +2058 -0
  161. package/Build/Workers/chunk-XKBR7TJB.js +398 -0
  162. package/Build/Workers/chunk-XYRT4RDI.js +1045 -0
  163. package/Build/Workers/chunk-XZINQPR6.js +124 -0
  164. package/Build/Workers/chunk-YLKTSY65.js +414 -0
  165. package/Build/Workers/chunk-YLSZYTTO.js +102 -0
  166. package/Build/Workers/chunk-YQXKIGXX.js +414 -0
  167. package/Build/Workers/chunk-YR3LX3PR.js +497 -0
  168. package/Build/Workers/chunk-Z5MHVJGN.js +778 -0
  169. package/Build/Workers/chunk-ZBRVFEGF.js +256 -0
  170. package/Build/Workers/chunk-ZCPCQJBX.js +198 -0
  171. package/Build/Workers/chunk-ZS7KQSEM.js +439 -0
  172. package/Build/Workers/combineGeometry.js +24 -24
  173. package/Build/Workers/createBoxGeometry.js +18 -18
  174. package/Build/Workers/createBoxOutlineGeometry.js +16 -16
  175. package/Build/Workers/createCircleGeometry.js +26 -26
  176. package/Build/Workers/createCircleOutlineGeometry.js +19 -19
  177. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
  178. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
  179. package/Build/Workers/createCorridorGeometry.js +29 -29
  180. package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
  181. package/Build/Workers/createCylinderGeometry.js +20 -20
  182. package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
  183. package/Build/Workers/createEllipseGeometry.js +26 -26
  184. package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
  185. package/Build/Workers/createEllipsoidGeometry.js +19 -19
  186. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
  187. package/Build/Workers/createFrustumGeometry.js +18 -18
  188. package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
  189. package/Build/Workers/createGeometry.js +24 -24
  190. package/Build/Workers/createGroundPolylineGeometry.js +22 -22
  191. package/Build/Workers/createPlaneGeometry.js +16 -16
  192. package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
  193. package/Build/Workers/createPolygonGeometry.js +32 -32
  194. package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
  195. package/Build/Workers/createPolylineGeometry.js +25 -25
  196. package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
  197. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
  198. package/Build/Workers/createRectangleGeometry.js +27 -27
  199. package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
  200. package/Build/Workers/createSimplePolylineGeometry.js +23 -23
  201. package/Build/Workers/createSphereGeometry.js +19 -19
  202. package/Build/Workers/createSphereOutlineGeometry.js +18 -18
  203. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  204. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  205. package/Build/Workers/createVectorTileGeometries.js +24 -24
  206. package/Build/Workers/createVectorTilePoints.js +13 -13
  207. package/Build/Workers/createVectorTilePolygons.js +22 -22
  208. package/Build/Workers/createVectorTilePolylines.js +14 -14
  209. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
  210. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
  211. package/Build/Workers/createVerticesFromHeightmap.js +22 -22
  212. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
  213. package/Build/Workers/createWallGeometry.js +24 -24
  214. package/Build/Workers/createWallOutlineGeometry.js +23 -23
  215. package/Build/Workers/decodeDraco.js +10 -10
  216. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  217. package/Build/Workers/decodeI3S.js +10 -10
  218. package/Build/Workers/gaussianSplatSorter.js +4 -4
  219. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  220. package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
  221. package/Build/Workers/transcodeKTX2.js +6 -6
  222. package/Build/Workers/transferTypedArrayTest.js +1 -1
  223. package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
  224. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
  225. package/Source/Scene/Cesium3DTileset.js +4163 -4105
  226. package/Source/Scene/Model/BarycentricWireframePipelineStage.js +327 -73
  227. package/Source/Scene/Model/Model.js +3631 -3512
  228. package/Source/Scene/Model/Model3DTileContent.js +585 -568
  229. package/Source/Scene/Model/ModelRuntimePrimitive.js +391 -391
  230. package/Source/Scene/Model/WireframePipelineStage.js +122 -122
  231. package/Source/Shaders/Model/ModelFS.glsl +38 -2
  232. package/Source/Shaders/Model/ModelFS.js +38 -2
  233. package/Source/Shaders/Model/ModelVS.glsl +3 -0
  234. package/Source/Shaders/Model/ModelVS.js +3 -0
  235. package/index.d.ts +801 -773
  236. package/index.js +145 -145
  237. package/package.json +1 -1
@@ -1,568 +1,585 @@
1
- import Color from "../../Core/Color.js";
2
- import combine from "../../Core/combine.js";
3
- import defined from "../../Core/defined.js";
4
- import destroyObject from "../../Core/destroyObject.js";
5
- import DeveloperError from "../../Core/DeveloperError.js";
6
- import Ellipsoid from "../../Core/Ellipsoid.js";
7
- import Pass from "../../Renderer/Pass.js";
8
- import ModelAnimationLoop from "../ModelAnimationLoop.js";
9
- import Model from "./Model.js";
10
-
11
- /**
12
- * Represents the contents of a glTF, glb or
13
- * {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification/TileFormats/Batched3DModel|Batched 3D Model}
14
- * tile in a {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification|3D Tiles} tileset.
15
- * <p>
16
- * Implements the {@link Cesium3DTileContent} interface.
17
- * </p>
18
- * This object is normally not instantiated directly, use {@link Model3DTileContent.fromGltf}, {@link Model3DTileContent.fromB3dm}, {@link Model3DTileContent.fromI3dm}, {@link Model3DTileContent.fromPnts}, or {@link Model3DTileContent.fromGeoJson}.
19
- *
20
- * @alias Model3DTileContent
21
- * @constructor
22
- * @private
23
- */
24
- function Model3DTileContent(tileset, tile, resource) {
25
- this._tileset = tileset;
26
- this._tile = tile;
27
- this._resource = resource;
28
-
29
- this._model = undefined;
30
- this._metadata = undefined;
31
- this._group = undefined;
32
- this._ready = false;
33
- }
34
-
35
- Object.defineProperties(Model3DTileContent.prototype, {
36
- featuresLength: {
37
- get: function () {
38
- const model = this._model;
39
- const featureTables = model.featureTables;
40
- const featureTableId = model.featureTableId;
41
-
42
- if (defined(featureTables) && defined(featureTables[featureTableId])) {
43
- return featureTables[featureTableId].featuresLength;
44
- }
45
-
46
- return 0;
47
- },
48
- },
49
-
50
- pointsLength: {
51
- get: function () {
52
- return this._model.statistics.pointsLength;
53
- },
54
- },
55
-
56
- trianglesLength: {
57
- get: function () {
58
- return this._model.statistics.trianglesLength;
59
- },
60
- },
61
-
62
- geometryByteLength: {
63
- get: function () {
64
- return this._model.statistics.geometryByteLength;
65
- },
66
- },
67
-
68
- texturesByteLength: {
69
- get: function () {
70
- return this._model.statistics.texturesByteLength;
71
- },
72
- },
73
-
74
- batchTableByteLength: {
75
- get: function () {
76
- const statistics = this._model.statistics;
77
- return (
78
- statistics.propertyTablesByteLength + statistics.batchTexturesByteLength
79
- );
80
- },
81
- },
82
-
83
- innerContents: {
84
- get: function () {
85
- return undefined;
86
- },
87
- },
88
-
89
- /**
90
- * Returns true when the tile's content is ready to render; otherwise false
91
- *
92
- * @memberof Model3DTileContent.prototype
93
- *
94
- * @type {boolean}
95
- * @readonly
96
- * @private
97
- */
98
- ready: {
99
- get: function () {
100
- return this._ready;
101
- },
102
- },
103
-
104
- tileset: {
105
- get: function () {
106
- return this._tileset;
107
- },
108
- },
109
-
110
- tile: {
111
- get: function () {
112
- return this._tile;
113
- },
114
- },
115
-
116
- url: {
117
- get: function () {
118
- return this._resource.getUrlComponent(true);
119
- },
120
- },
121
-
122
- batchTable: {
123
- get: function () {
124
- const model = this._model;
125
- const featureTables = model.featureTables;
126
- const featureTableId = model.featureTableId;
127
-
128
- if (defined(featureTables) && defined(featureTables[featureTableId])) {
129
- return featureTables[featureTableId];
130
- }
131
-
132
- return undefined;
133
- },
134
- },
135
-
136
- metadata: {
137
- get: function () {
138
- return this._metadata;
139
- },
140
- set: function (value) {
141
- this._metadata = value;
142
- },
143
- },
144
-
145
- group: {
146
- get: function () {
147
- return this._group;
148
- },
149
- set: function (value) {
150
- this._group = value;
151
- },
152
- },
153
- });
154
-
155
- /**
156
- * Returns an array containing the `texture.id` values for all textures
157
- * that are part of this content.
158
- *
159
- * @returns {string[]} The texture IDs
160
- */
161
- Model3DTileContent.prototype.getTextureIds = function () {
162
- return this._model.statistics.getTextureIds();
163
- };
164
-
165
- /**
166
- * Returns the length, in bytes, of the texture data for the texture with
167
- * the given ID that is part of this content, or `undefined` if this
168
- * content does not contain the texture with the given ID.
169
- *
170
- * @param {string} textureId The texture ID
171
- * @returns {number|undefined} The texture byte length
172
- */
173
- Model3DTileContent.prototype.getTextureByteLengthById = function (textureId) {
174
- return this._model.statistics.getTextureByteLengthById(textureId);
175
- };
176
-
177
- /**
178
- * Returns the object that was created for the given extension.
179
- *
180
- * The given name may be the name of a glTF extension, like `"EXT_example_extension"`.
181
- * If the specified extension was present in the root of the underlying glTF asset,
182
- * and a loader for the specified extension has processed the extension data, then
183
- * this will return the model representation of the extension.
184
- *
185
- * @param {string} extensionName The name of the extension
186
- * @returns {object|undefined} The object, or `undefined`
187
- *
188
- * @private
189
- */
190
- Model3DTileContent.prototype.getExtension = function (extensionName) {
191
- const model = this._model;
192
- const extension = model.getExtension(extensionName);
193
- return extension;
194
- };
195
-
196
- Model3DTileContent.prototype.getFeature = function (featureId) {
197
- const model = this._model;
198
- const featureTableId = model.featureTableId;
199
-
200
- //>>includeStart('debug', pragmas.debug);
201
- if (!defined(featureTableId)) {
202
- throw new DeveloperError(
203
- "No feature ID set is selected. Make sure Cesium3DTileset.featureIdLabel or Cesium3DTileset.instanceFeatureIdLabel is defined",
204
- );
205
- }
206
- //>>includeEnd('debug');
207
-
208
- const featureTable = model.featureTables[featureTableId];
209
-
210
- //>>includeStart('debug', pragmas.debug);
211
- if (!defined(featureTable)) {
212
- throw new DeveloperError(
213
- "No feature table found for the selected feature ID set",
214
- );
215
- }
216
- //>>includeEnd('debug');
217
-
218
- //>>includeStart('debug', pragmas.debug);
219
- const featuresLength = featureTable.featuresLength;
220
- if (!defined(featureId) || featureId < 0 || featureId >= featuresLength) {
221
- throw new DeveloperError(
222
- `featureId is required and must be between 0 and featuresLength - 1 (${
223
- featuresLength - 1
224
- }).`,
225
- );
226
- }
227
- //>>includeEnd('debug');
228
- return featureTable.getFeature(featureId);
229
- };
230
-
231
- Model3DTileContent.prototype.hasProperty = function (featureId, name) {
232
- const model = this._model;
233
- const featureTableId = model.featureTableId;
234
- if (!defined(featureTableId)) {
235
- return false;
236
- }
237
-
238
- const featureTable = model.featureTables[featureTableId];
239
- return featureTable.hasProperty(featureId, name);
240
- };
241
-
242
- Model3DTileContent.prototype.applyDebugSettings = function (enabled, color) {
243
- color = enabled ? color : Color.WHITE;
244
- if (this.featuresLength === 0) {
245
- this._model.color = color;
246
- } else if (defined(this.batchTable)) {
247
- this.batchTable.setAllColor(color);
248
- }
249
- };
250
-
251
- Model3DTileContent.prototype.applyStyle = function (style) {
252
- // the setter will call model.applyStyle()
253
- this._model.style = style;
254
- };
255
-
256
- Model3DTileContent.prototype.update = function (tileset, frameState) {
257
- const model = this._model;
258
- const tile = this._tile;
259
-
260
- model.colorBlendAmount = tileset.colorBlendAmount;
261
- model.colorBlendMode = tileset.colorBlendMode;
262
- model.modelMatrix = tile.computedTransform;
263
- model.customShader = tileset.customShader;
264
- model.featureIdLabel = tileset.featureIdLabel;
265
- model.instanceFeatureIdLabel = tileset.instanceFeatureIdLabel;
266
- model.lightColor = tileset.lightColor;
267
- model.imageBasedLighting = tileset.imageBasedLighting;
268
- model.backFaceCulling = tileset.backFaceCulling;
269
- model.shadows = tileset.shadows;
270
- model.showCreditsOnScreen = tileset.showCreditsOnScreen;
271
- model.splitDirection = tileset.splitDirection;
272
- model.debugWireframe = tileset.debugWireframe;
273
- model.debugWireframeLineWidth = tileset.debugWireframeLineWidth;
274
- model.debugWireframeMode = tileset.debugWireframeMode;
275
- model.debugWireframeOverlay = tileset.debugWireframeOverlay;
276
- model.showOutline = tileset.showOutline;
277
- model.outlineColor = tileset.outlineColor;
278
- model.pointCloudShading = tileset.pointCloudShading;
279
-
280
- // Sync color from tileset style to model for barycentric wireframe shader
281
- if (tileset.debugWireframe) {
282
- const tilesetStyle = tileset.style;
283
- if (defined(tilesetStyle) && defined(tilesetStyle.color)) {
284
- const evaluatedColor = tilesetStyle.color.evaluateColor(undefined);
285
- if (defined(evaluatedColor)) {
286
- model.color = evaluatedColor;
287
- }
288
- }
289
- }
290
-
291
- // Updating clipping planes requires more effort because of ownership checks
292
- const tilesetClippingPlanes = tileset.clippingPlanes;
293
- model.referenceMatrix = tileset.clippingPlanesOriginMatrix;
294
- if (defined(tilesetClippingPlanes) && tile.clippingPlanesDirty) {
295
- // Dereference the clipping planes from the model if they are irrelevant.
296
- model._clippingPlanes =
297
- tilesetClippingPlanes.enabled && tile._isClipped
298
- ? tilesetClippingPlanes
299
- : undefined;
300
- }
301
-
302
- const tilesetEnvironmentMapManager = tileset.environmentMapManager;
303
- if (model.environmentMapManager !== tilesetClippingPlanes) {
304
- model._environmentMapManager = tilesetEnvironmentMapManager;
305
- }
306
-
307
- // If the model references a different ClippingPlaneCollection from the tileset,
308
- // update the model to use the new ClippingPlaneCollection.
309
- if (
310
- defined(tilesetClippingPlanes) &&
311
- defined(model._clippingPlanes) &&
312
- model._clippingPlanes !== tilesetClippingPlanes
313
- ) {
314
- model._clippingPlanes = tilesetClippingPlanes;
315
- model._clippingPlanesState = 0;
316
- }
317
-
318
- // Updating clipping polygons requires more effort because of ownership checks
319
- const tilesetClippingPolygons = tileset.clippingPolygons;
320
- if (defined(tilesetClippingPolygons) && tile.clippingPolygonsDirty) {
321
- // Dereference the clipping polygons from the model if they are irrelevant.
322
- model._clippingPolygons =
323
- tilesetClippingPolygons.enabled && tile._isClippedByPolygon
324
- ? tilesetClippingPolygons
325
- : undefined;
326
- }
327
-
328
- // If the model references a different ClippingPolygonCollection from the tileset,
329
- // update the model to use the new ClippingPolygonCollection.
330
- if (
331
- defined(tilesetClippingPolygons) &&
332
- defined(model._clippingPolygons) &&
333
- model._clippingPolygons !== tilesetClippingPolygons
334
- ) {
335
- model._clippingPolygons = tilesetClippingPolygons;
336
- model._clippingPolygonsState = 0;
337
- }
338
-
339
- model.update(frameState);
340
-
341
- if (!this._ready && model.ready) {
342
- // Animation can only be added once the model is ready
343
- model.activeAnimations.addAll({
344
- loop: ModelAnimationLoop.REPEAT,
345
- });
346
-
347
- this._ready = true;
348
- }
349
- };
350
-
351
- Model3DTileContent.prototype.isDestroyed = function () {
352
- return false;
353
- };
354
-
355
- Model3DTileContent.prototype.destroy = function () {
356
- this._model = this._model && this._model.destroy();
357
- return destroyObject(this);
358
- };
359
-
360
- Model3DTileContent.fromGltf = async function (tileset, tile, resource, gltf) {
361
- const content = new Model3DTileContent(tileset, tile, resource);
362
-
363
- const additionalOptions = {
364
- gltf: gltf,
365
- basePath: resource,
366
- };
367
-
368
- const modelOptions = makeModelOptions(
369
- tileset,
370
- tile,
371
- content,
372
- additionalOptions,
373
- );
374
-
375
- const classificationType = tileset.vectorClassificationOnly
376
- ? undefined
377
- : tileset.classificationType;
378
-
379
- modelOptions.classificationType = classificationType;
380
-
381
- const model = await Model.fromGltfAsync(modelOptions);
382
- content._model = model;
383
-
384
- return content;
385
- };
386
-
387
- Model3DTileContent.fromB3dm = async function (
388
- tileset,
389
- tile,
390
- resource,
391
- arrayBuffer,
392
- byteOffset,
393
- ) {
394
- const content = new Model3DTileContent(tileset, tile, resource);
395
-
396
- const additionalOptions = {
397
- arrayBuffer: arrayBuffer,
398
- byteOffset: byteOffset,
399
- resource: resource,
400
- };
401
-
402
- const modelOptions = makeModelOptions(
403
- tileset,
404
- tile,
405
- content,
406
- additionalOptions,
407
- );
408
-
409
- const classificationType = tileset.vectorClassificationOnly
410
- ? undefined
411
- : tileset.classificationType;
412
-
413
- modelOptions.classificationType = classificationType;
414
-
415
- const model = await Model.fromB3dm(modelOptions);
416
- content._model = model;
417
-
418
- return content;
419
- };
420
-
421
- Model3DTileContent.fromI3dm = async function (
422
- tileset,
423
- tile,
424
- resource,
425
- arrayBuffer,
426
- byteOffset,
427
- ) {
428
- const content = new Model3DTileContent(tileset, tile, resource);
429
-
430
- const additionalOptions = {
431
- arrayBuffer: arrayBuffer,
432
- byteOffset: byteOffset,
433
- resource: resource,
434
- };
435
-
436
- const modelOptions = makeModelOptions(
437
- tileset,
438
- tile,
439
- content,
440
- additionalOptions,
441
- );
442
-
443
- const model = await Model.fromI3dm(modelOptions);
444
- content._model = model;
445
-
446
- return content;
447
- };
448
-
449
- Model3DTileContent.fromPnts = async function (
450
- tileset,
451
- tile,
452
- resource,
453
- arrayBuffer,
454
- byteOffset,
455
- ) {
456
- const content = new Model3DTileContent(tileset, tile, resource);
457
-
458
- const additionalOptions = {
459
- arrayBuffer: arrayBuffer,
460
- byteOffset: byteOffset,
461
- resource: resource,
462
- };
463
-
464
- const modelOptions = makeModelOptions(
465
- tileset,
466
- tile,
467
- content,
468
- additionalOptions,
469
- );
470
- const model = await Model.fromPnts(modelOptions);
471
- content._model = model;
472
-
473
- return content;
474
- };
475
-
476
- Model3DTileContent.fromGeoJson = async function (
477
- tileset,
478
- tile,
479
- resource,
480
- geoJson,
481
- ) {
482
- const content = new Model3DTileContent(tileset, tile, resource);
483
-
484
- const additionalOptions = {
485
- geoJson: geoJson,
486
- resource: resource,
487
- };
488
-
489
- const modelOptions = makeModelOptions(
490
- tileset,
491
- tile,
492
- content,
493
- additionalOptions,
494
- );
495
- const model = await Model.fromGeoJson(modelOptions);
496
- content._model = model;
497
-
498
- return content;
499
- };
500
-
501
- /**
502
- * Find an intersection between a ray and the tile content surface that was rendered. The ray must be given in world coordinates.
503
- *
504
- * @param {Ray} ray The ray to test for intersection.
505
- * @param {FrameState} frameState The frame state.
506
- * @param {Cartesian3|undefined} [result] The intersection or <code>undefined</code> if none was found.
507
- * @returns {Cartesian3|undefined} The intersection or <code>undefined</code> if none was found.
508
- *
509
- * @private
510
- */
511
- Model3DTileContent.prototype.pick = function (ray, frameState, result) {
512
- if (!defined(this._model) || !this._ready) {
513
- return undefined;
514
- }
515
-
516
- const verticalExaggeration = frameState.verticalExaggeration;
517
- const relativeHeight = frameState.verticalExaggerationRelativeHeight;
518
-
519
- // All tilesets assume a WGS84 ellipsoid
520
- return this._model.pick(
521
- ray,
522
- frameState,
523
- verticalExaggeration,
524
- relativeHeight,
525
- Ellipsoid.WGS84,
526
- result,
527
- );
528
- };
529
-
530
- function makeModelOptions(tileset, tile, content, additionalOptions) {
531
- const mainOptions = {
532
- cull: false, // The model is already culled by 3D Tiles
533
- releaseGltfJson: true, // Models are unique and will not benefit from caching so save memory
534
- opaquePass: Pass.CESIUM_3D_TILE, // Draw opaque portions of the model during the 3D Tiles pass
535
- modelMatrix: tile.computedTransform,
536
- upAxis: tileset._modelUpAxis,
537
- forwardAxis: tileset._modelForwardAxis,
538
- incrementallyLoadTextures: false,
539
- customShader: tileset.customShader,
540
- content: content,
541
- colorBlendMode: tileset.colorBlendMode,
542
- colorBlendAmount: tileset.colorBlendAmount,
543
- lightColor: tileset.lightColor,
544
- imageBasedLighting: tileset.imageBasedLighting,
545
- featureIdLabel: tileset.featureIdLabel,
546
- instanceFeatureIdLabel: tileset.instanceFeatureIdLabel,
547
- pointCloudShading: tileset.pointCloudShading,
548
- clippingPlanes: tileset.clippingPlanes,
549
- backFaceCulling: tileset.backFaceCulling,
550
- shadows: tileset.shadows,
551
- showCreditsOnScreen: tileset.showCreditsOnScreen,
552
- splitDirection: tileset.splitDirection,
553
- enableDebugWireframe: tileset._enableDebugWireframe,
554
- debugWireframe: tileset.debugWireframe,
555
- debugWireframeLineWidth: tileset.debugWireframeLineWidth,
556
- debugWireframeMode: tileset.debugWireframeMode,
557
- debugWireframeOverlay: tileset.debugWireframeOverlay,
558
- projectTo2D: tileset._projectTo2D,
559
- enablePick: tileset._enablePick,
560
- enableShowOutline: tileset._enableShowOutline,
561
- showOutline: tileset.showOutline,
562
- outlineColor: tileset.outlineColor,
563
- };
564
-
565
- return combine(additionalOptions, mainOptions);
566
- }
567
-
568
- export default Model3DTileContent;
1
+ import Color from "../../Core/Color.js";
2
+ import combine from "../../Core/combine.js";
3
+ import Cartesian3 from "../../Core/Cartesian3.js";
4
+ import defined from "../../Core/defined.js";
5
+ import destroyObject from "../../Core/destroyObject.js";
6
+ import DeveloperError from "../../Core/DeveloperError.js";
7
+ import Ellipsoid from "../../Core/Ellipsoid.js";
8
+ import Pass from "../../Renderer/Pass.js";
9
+ import ModelAnimationLoop from "../ModelAnimationLoop.js";
10
+ import Model from "./Model.js";
11
+
12
+ /**
13
+ * Represents the contents of a glTF, glb or
14
+ * {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification/TileFormats/Batched3DModel|Batched 3D Model}
15
+ * tile in a {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification|3D Tiles} tileset.
16
+ * <p>
17
+ * Implements the {@link Cesium3DTileContent} interface.
18
+ * </p>
19
+ * This object is normally not instantiated directly, use {@link Model3DTileContent.fromGltf}, {@link Model3DTileContent.fromB3dm}, {@link Model3DTileContent.fromI3dm}, {@link Model3DTileContent.fromPnts}, or {@link Model3DTileContent.fromGeoJson}.
20
+ *
21
+ * @alias Model3DTileContent
22
+ * @constructor
23
+ * @private
24
+ */
25
+ function Model3DTileContent(tileset, tile, resource) {
26
+ this._tileset = tileset;
27
+ this._tile = tile;
28
+ this._resource = resource;
29
+
30
+ this._model = undefined;
31
+ this._metadata = undefined;
32
+ this._group = undefined;
33
+ this._ready = false;
34
+ }
35
+
36
+ Object.defineProperties(Model3DTileContent.prototype, {
37
+ featuresLength: {
38
+ get: function () {
39
+ const model = this._model;
40
+ const featureTables = model.featureTables;
41
+ const featureTableId = model.featureTableId;
42
+
43
+ if (defined(featureTables) && defined(featureTables[featureTableId])) {
44
+ return featureTables[featureTableId].featuresLength;
45
+ }
46
+
47
+ return 0;
48
+ },
49
+ },
50
+
51
+ pointsLength: {
52
+ get: function () {
53
+ return this._model.statistics.pointsLength;
54
+ },
55
+ },
56
+
57
+ trianglesLength: {
58
+ get: function () {
59
+ return this._model.statistics.trianglesLength;
60
+ },
61
+ },
62
+
63
+ geometryByteLength: {
64
+ get: function () {
65
+ return this._model.statistics.geometryByteLength;
66
+ },
67
+ },
68
+
69
+ texturesByteLength: {
70
+ get: function () {
71
+ return this._model.statistics.texturesByteLength;
72
+ },
73
+ },
74
+
75
+ batchTableByteLength: {
76
+ get: function () {
77
+ const statistics = this._model.statistics;
78
+ return (
79
+ statistics.propertyTablesByteLength + statistics.batchTexturesByteLength
80
+ );
81
+ },
82
+ },
83
+
84
+ innerContents: {
85
+ get: function () {
86
+ return undefined;
87
+ },
88
+ },
89
+
90
+ /**
91
+ * Returns true when the tile's content is ready to render; otherwise false
92
+ *
93
+ * @memberof Model3DTileContent.prototype
94
+ *
95
+ * @type {boolean}
96
+ * @readonly
97
+ * @private
98
+ */
99
+ ready: {
100
+ get: function () {
101
+ return this._ready;
102
+ },
103
+ },
104
+
105
+ tileset: {
106
+ get: function () {
107
+ return this._tileset;
108
+ },
109
+ },
110
+
111
+ tile: {
112
+ get: function () {
113
+ return this._tile;
114
+ },
115
+ },
116
+
117
+ url: {
118
+ get: function () {
119
+ return this._resource.getUrlComponent(true);
120
+ },
121
+ },
122
+
123
+ batchTable: {
124
+ get: function () {
125
+ const model = this._model;
126
+ const featureTables = model.featureTables;
127
+ const featureTableId = model.featureTableId;
128
+
129
+ if (defined(featureTables) && defined(featureTables[featureTableId])) {
130
+ return featureTables[featureTableId];
131
+ }
132
+
133
+ return undefined;
134
+ },
135
+ },
136
+
137
+ metadata: {
138
+ get: function () {
139
+ return this._metadata;
140
+ },
141
+ set: function (value) {
142
+ this._metadata = value;
143
+ },
144
+ },
145
+
146
+ group: {
147
+ get: function () {
148
+ return this._group;
149
+ },
150
+ set: function (value) {
151
+ this._group = value;
152
+ },
153
+ },
154
+ });
155
+
156
+ /**
157
+ * Returns an array containing the `texture.id` values for all textures
158
+ * that are part of this content.
159
+ *
160
+ * @returns {string[]} The texture IDs
161
+ */
162
+ Model3DTileContent.prototype.getTextureIds = function () {
163
+ return this._model.statistics.getTextureIds();
164
+ };
165
+
166
+ /**
167
+ * Returns the length, in bytes, of the texture data for the texture with
168
+ * the given ID that is part of this content, or `undefined` if this
169
+ * content does not contain the texture with the given ID.
170
+ *
171
+ * @param {string} textureId The texture ID
172
+ * @returns {number|undefined} The texture byte length
173
+ */
174
+ Model3DTileContent.prototype.getTextureByteLengthById = function (textureId) {
175
+ return this._model.statistics.getTextureByteLengthById(textureId);
176
+ };
177
+
178
+ /**
179
+ * Returns the object that was created for the given extension.
180
+ *
181
+ * The given name may be the name of a glTF extension, like `"EXT_example_extension"`.
182
+ * If the specified extension was present in the root of the underlying glTF asset,
183
+ * and a loader for the specified extension has processed the extension data, then
184
+ * this will return the model representation of the extension.
185
+ *
186
+ * @param {string} extensionName The name of the extension
187
+ * @returns {object|undefined} The object, or `undefined`
188
+ *
189
+ * @private
190
+ */
191
+ Model3DTileContent.prototype.getExtension = function (extensionName) {
192
+ const model = this._model;
193
+ const extension = model.getExtension(extensionName);
194
+ return extension;
195
+ };
196
+
197
+ Model3DTileContent.prototype.getFeature = function (featureId) {
198
+ const model = this._model;
199
+ const featureTableId = model.featureTableId;
200
+
201
+ //>>includeStart('debug', pragmas.debug);
202
+ if (!defined(featureTableId)) {
203
+ throw new DeveloperError(
204
+ "No feature ID set is selected. Make sure Cesium3DTileset.featureIdLabel or Cesium3DTileset.instanceFeatureIdLabel is defined",
205
+ );
206
+ }
207
+ //>>includeEnd('debug');
208
+
209
+ const featureTable = model.featureTables[featureTableId];
210
+
211
+ //>>includeStart('debug', pragmas.debug);
212
+ if (!defined(featureTable)) {
213
+ throw new DeveloperError(
214
+ "No feature table found for the selected feature ID set",
215
+ );
216
+ }
217
+ //>>includeEnd('debug');
218
+
219
+ //>>includeStart('debug', pragmas.debug);
220
+ const featuresLength = featureTable.featuresLength;
221
+ if (!defined(featureId) || featureId < 0 || featureId >= featuresLength) {
222
+ throw new DeveloperError(
223
+ `featureId is required and must be between 0 and featuresLength - 1 (${
224
+ featuresLength - 1
225
+ }).`,
226
+ );
227
+ }
228
+ //>>includeEnd('debug');
229
+ return featureTable.getFeature(featureId);
230
+ };
231
+
232
+ Model3DTileContent.prototype.hasProperty = function (featureId, name) {
233
+ const model = this._model;
234
+ const featureTableId = model.featureTableId;
235
+ if (!defined(featureTableId)) {
236
+ return false;
237
+ }
238
+
239
+ const featureTable = model.featureTables[featureTableId];
240
+ return featureTable.hasProperty(featureId, name);
241
+ };
242
+
243
+ Model3DTileContent.prototype.applyDebugSettings = function (enabled, color) {
244
+ color = enabled ? color : Color.WHITE;
245
+ if (this.featuresLength === 0) {
246
+ this._model.color = color;
247
+ } else if (defined(this.batchTable)) {
248
+ this.batchTable.setAllColor(color);
249
+ }
250
+ };
251
+
252
+ Model3DTileContent.prototype.applyStyle = function (style) {
253
+ // the setter will call model.applyStyle()
254
+ this._model.style = style;
255
+ };
256
+
257
+ Model3DTileContent.prototype.update = function (tileset, frameState) {
258
+ const model = this._model;
259
+ const tile = this._tile;
260
+
261
+ model.colorBlendAmount = tileset.colorBlendAmount;
262
+ model.colorBlendMode = tileset.colorBlendMode;
263
+ model.modelMatrix = tile.computedTransform;
264
+ model.customShader = tileset.customShader;
265
+ model.featureIdLabel = tileset.featureIdLabel;
266
+ model.instanceFeatureIdLabel = tileset.instanceFeatureIdLabel;
267
+ model.lightColor = tileset.lightColor;
268
+ model.imageBasedLighting = tileset.imageBasedLighting;
269
+ model.backFaceCulling = tileset.backFaceCulling;
270
+ model.shadows = tileset.shadows;
271
+ model.showCreditsOnScreen = tileset.showCreditsOnScreen;
272
+ model.splitDirection = tileset.splitDirection;
273
+ model.debugWireframe = tileset.debugWireframe;
274
+ model.debugWireframeColor = tileset._debugWireframeColor;
275
+ model.debugWireframeFillAlpha = tileset._debugWireframeFillAlpha;
276
+ model.debugWireframeLineWidth = tileset.debugWireframeLineWidth;
277
+ model.debugWireframeMode = tileset.debugWireframeMode;
278
+ model.debugWireframeOverlay = tileset.debugWireframeOverlay;
279
+ model._debugWireframeGlow = tileset._debugWireframeGlow ?? 0.0;
280
+ model._debugWireframeScanSpeed = tileset._debugWireframeScanSpeed ?? 0.0;
281
+ model._debugWireframeScanAxis = tileset._debugWireframeScanAxis ?? new Cartesian3(0, 0, 1);
282
+ model._debugWireframeScanMin = tileset._debugWireframeScanMin ?? 0.0;
283
+ model._debugWireframeScanMax = tileset._debugWireframeScanMax ?? 1.0;
284
+ model._debugWireframeModelMinHeight = tileset._debugWireframeModelMinHeight ?? 0.0;
285
+ model._debugWireframeModelMaxHeight = tileset._debugWireframeModelMaxHeight ?? 1.0;
286
+ model.showOutline = tileset.showOutline;
287
+ model.outlineColor = tileset.outlineColor;
288
+ model.pointCloudShading = tileset.pointCloudShading;
289
+
290
+ if (tileset.debugWireframe && defined(tileset._debugWireframeFillColor)) {
291
+ const fillColor = Color.clone(tileset._debugWireframeFillColor);
292
+ fillColor.alpha = tileset._debugWireframeFillAlpha;
293
+ model.color = fillColor;
294
+ model.colorBlendMode = tileset.colorBlendMode;
295
+ } else if (!tileset.debugWireframe) {
296
+ model.color = undefined;
297
+ }
298
+
299
+ // Updating clipping planes requires more effort because of ownership checks
300
+ const tilesetClippingPlanes = tileset.clippingPlanes;
301
+ model.referenceMatrix = tileset.clippingPlanesOriginMatrix;
302
+ if (defined(tilesetClippingPlanes) && tile.clippingPlanesDirty) {
303
+ // Dereference the clipping planes from the model if they are irrelevant.
304
+ model._clippingPlanes =
305
+ tilesetClippingPlanes.enabled && tile._isClipped
306
+ ? tilesetClippingPlanes
307
+ : undefined;
308
+ }
309
+
310
+ const tilesetEnvironmentMapManager = tileset.environmentMapManager;
311
+ if (model.environmentMapManager !== tilesetClippingPlanes) {
312
+ model._environmentMapManager = tilesetEnvironmentMapManager;
313
+ }
314
+
315
+ // If the model references a different ClippingPlaneCollection from the tileset,
316
+ // update the model to use the new ClippingPlaneCollection.
317
+ if (
318
+ defined(tilesetClippingPlanes) &&
319
+ defined(model._clippingPlanes) &&
320
+ model._clippingPlanes !== tilesetClippingPlanes
321
+ ) {
322
+ model._clippingPlanes = tilesetClippingPlanes;
323
+ model._clippingPlanesState = 0;
324
+ }
325
+
326
+ // Updating clipping polygons requires more effort because of ownership checks
327
+ const tilesetClippingPolygons = tileset.clippingPolygons;
328
+ if (defined(tilesetClippingPolygons) && tile.clippingPolygonsDirty) {
329
+ // Dereference the clipping polygons from the model if they are irrelevant.
330
+ model._clippingPolygons =
331
+ tilesetClippingPolygons.enabled && tile._isClippedByPolygon
332
+ ? tilesetClippingPolygons
333
+ : undefined;
334
+ }
335
+
336
+ // If the model references a different ClippingPolygonCollection from the tileset,
337
+ // update the model to use the new ClippingPolygonCollection.
338
+ if (
339
+ defined(tilesetClippingPolygons) &&
340
+ defined(model._clippingPolygons) &&
341
+ model._clippingPolygons !== tilesetClippingPolygons
342
+ ) {
343
+ model._clippingPolygons = tilesetClippingPolygons;
344
+ model._clippingPolygonsState = 0;
345
+ }
346
+
347
+ model.update(frameState);
348
+
349
+ if (!this._ready && model.ready) {
350
+ // Animation can only be added once the model is ready
351
+ model.activeAnimations.addAll({
352
+ loop: ModelAnimationLoop.REPEAT,
353
+ });
354
+
355
+ this._ready = true;
356
+ }
357
+ };
358
+
359
+ Model3DTileContent.prototype.isDestroyed = function () {
360
+ return false;
361
+ };
362
+
363
+ Model3DTileContent.prototype.destroy = function () {
364
+ this._model = this._model && this._model.destroy();
365
+ return destroyObject(this);
366
+ };
367
+
368
+ Model3DTileContent.fromGltf = async function (tileset, tile, resource, gltf) {
369
+ const content = new Model3DTileContent(tileset, tile, resource);
370
+
371
+ const additionalOptions = {
372
+ gltf: gltf,
373
+ basePath: resource,
374
+ };
375
+
376
+ const modelOptions = makeModelOptions(
377
+ tileset,
378
+ tile,
379
+ content,
380
+ additionalOptions,
381
+ );
382
+
383
+ const classificationType = tileset.vectorClassificationOnly
384
+ ? undefined
385
+ : tileset.classificationType;
386
+
387
+ modelOptions.classificationType = classificationType;
388
+
389
+ const model = await Model.fromGltfAsync(modelOptions);
390
+ content._model = model;
391
+
392
+ return content;
393
+ };
394
+
395
+ Model3DTileContent.fromB3dm = async function (
396
+ tileset,
397
+ tile,
398
+ resource,
399
+ arrayBuffer,
400
+ byteOffset,
401
+ ) {
402
+ const content = new Model3DTileContent(tileset, tile, resource);
403
+
404
+ const additionalOptions = {
405
+ arrayBuffer: arrayBuffer,
406
+ byteOffset: byteOffset,
407
+ resource: resource,
408
+ };
409
+
410
+ const modelOptions = makeModelOptions(
411
+ tileset,
412
+ tile,
413
+ content,
414
+ additionalOptions,
415
+ );
416
+
417
+ const classificationType = tileset.vectorClassificationOnly
418
+ ? undefined
419
+ : tileset.classificationType;
420
+
421
+ modelOptions.classificationType = classificationType;
422
+
423
+ const model = await Model.fromB3dm(modelOptions);
424
+ content._model = model;
425
+
426
+ return content;
427
+ };
428
+
429
+ Model3DTileContent.fromI3dm = async function (
430
+ tileset,
431
+ tile,
432
+ resource,
433
+ arrayBuffer,
434
+ byteOffset,
435
+ ) {
436
+ const content = new Model3DTileContent(tileset, tile, resource);
437
+
438
+ const additionalOptions = {
439
+ arrayBuffer: arrayBuffer,
440
+ byteOffset: byteOffset,
441
+ resource: resource,
442
+ };
443
+
444
+ const modelOptions = makeModelOptions(
445
+ tileset,
446
+ tile,
447
+ content,
448
+ additionalOptions,
449
+ );
450
+
451
+ const model = await Model.fromI3dm(modelOptions);
452
+ content._model = model;
453
+
454
+ return content;
455
+ };
456
+
457
+ Model3DTileContent.fromPnts = async function (
458
+ tileset,
459
+ tile,
460
+ resource,
461
+ arrayBuffer,
462
+ byteOffset,
463
+ ) {
464
+ const content = new Model3DTileContent(tileset, tile, resource);
465
+
466
+ const additionalOptions = {
467
+ arrayBuffer: arrayBuffer,
468
+ byteOffset: byteOffset,
469
+ resource: resource,
470
+ };
471
+
472
+ const modelOptions = makeModelOptions(
473
+ tileset,
474
+ tile,
475
+ content,
476
+ additionalOptions,
477
+ );
478
+ const model = await Model.fromPnts(modelOptions);
479
+ content._model = model;
480
+
481
+ return content;
482
+ };
483
+
484
+ Model3DTileContent.fromGeoJson = async function (
485
+ tileset,
486
+ tile,
487
+ resource,
488
+ geoJson,
489
+ ) {
490
+ const content = new Model3DTileContent(tileset, tile, resource);
491
+
492
+ const additionalOptions = {
493
+ geoJson: geoJson,
494
+ resource: resource,
495
+ };
496
+
497
+ const modelOptions = makeModelOptions(
498
+ tileset,
499
+ tile,
500
+ content,
501
+ additionalOptions,
502
+ );
503
+ const model = await Model.fromGeoJson(modelOptions);
504
+ content._model = model;
505
+
506
+ return content;
507
+ };
508
+
509
+ /**
510
+ * Find an intersection between a ray and the tile content surface that was rendered. The ray must be given in world coordinates.
511
+ *
512
+ * @param {Ray} ray The ray to test for intersection.
513
+ * @param {FrameState} frameState The frame state.
514
+ * @param {Cartesian3|undefined} [result] The intersection or <code>undefined</code> if none was found.
515
+ * @returns {Cartesian3|undefined} The intersection or <code>undefined</code> if none was found.
516
+ *
517
+ * @private
518
+ */
519
+ Model3DTileContent.prototype.pick = function (ray, frameState, result) {
520
+ if (!defined(this._model) || !this._ready) {
521
+ return undefined;
522
+ }
523
+
524
+ const verticalExaggeration = frameState.verticalExaggeration;
525
+ const relativeHeight = frameState.verticalExaggerationRelativeHeight;
526
+
527
+ // All tilesets assume a WGS84 ellipsoid
528
+ return this._model.pick(
529
+ ray,
530
+ frameState,
531
+ verticalExaggeration,
532
+ relativeHeight,
533
+ Ellipsoid.WGS84,
534
+ result,
535
+ );
536
+ };
537
+
538
+ function makeModelOptions(tileset, tile, content, additionalOptions) {
539
+ const mainOptions = {
540
+ cull: false, // The model is already culled by 3D Tiles
541
+ releaseGltfJson: true, // Models are unique and will not benefit from caching so save memory
542
+ opaquePass: Pass.CESIUM_3D_TILE, // Draw opaque portions of the model during the 3D Tiles pass
543
+ modelMatrix: tile.computedTransform,
544
+ upAxis: tileset._modelUpAxis,
545
+ forwardAxis: tileset._modelForwardAxis,
546
+ incrementallyLoadTextures: false,
547
+ customShader: tileset.customShader,
548
+ content: content,
549
+ colorBlendMode: tileset.colorBlendMode,
550
+ colorBlendAmount: tileset.colorBlendAmount,
551
+ lightColor: tileset.lightColor,
552
+ imageBasedLighting: tileset.imageBasedLighting,
553
+ featureIdLabel: tileset.featureIdLabel,
554
+ instanceFeatureIdLabel: tileset.instanceFeatureIdLabel,
555
+ pointCloudShading: tileset.pointCloudShading,
556
+ clippingPlanes: tileset.clippingPlanes,
557
+ backFaceCulling: tileset.backFaceCulling,
558
+ shadows: tileset.shadows,
559
+ showCreditsOnScreen: tileset.showCreditsOnScreen,
560
+ splitDirection: tileset.splitDirection,
561
+ enableDebugWireframe: tileset._enableDebugWireframe,
562
+ debugWireframe: tileset.debugWireframe,
563
+ debugWireframeColor: tileset._debugWireframeColor,
564
+ debugWireframeFillAlpha: tileset._debugWireframeFillAlpha,
565
+ debugWireframeLineWidth: tileset.debugWireframeLineWidth,
566
+ debugWireframeMode: tileset.debugWireframeMode,
567
+ debugWireframeOverlay: tileset.debugWireframeOverlay,
568
+ _debugWireframeGlow: tileset._debugWireframeGlow ?? 0.0,
569
+ _debugWireframeScanSpeed: tileset._debugWireframeScanSpeed ?? 0.0,
570
+ _debugWireframeScanAxis: tileset._debugWireframeScanAxis ?? new Cartesian3(0, 0, 1),
571
+ _debugWireframeScanMin: tileset._debugWireframeScanMin ?? 0.0,
572
+ _debugWireframeScanMax: tileset._debugWireframeScanMax ?? 1.0,
573
+ _debugWireframeModelMinHeight: tileset._debugWireframeModelMinHeight ?? 0.0,
574
+ _debugWireframeModelMaxHeight: tileset._debugWireframeModelMaxHeight ?? 1.0,
575
+ projectTo2D: tileset._projectTo2D,
576
+ enablePick: tileset._enablePick,
577
+ enableShowOutline: tileset._enableShowOutline,
578
+ showOutline: tileset.showOutline,
579
+ outlineColor: tileset.outlineColor,
580
+ };
581
+
582
+ return combine(additionalOptions, mainOptions);
583
+ }
584
+
585
+ export default Model3DTileContent;