@rtzh/engine 0.0.8 → 0.0.10

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 (243) hide show
  1. package/Build/ThirdParty/Workers/zip-web-worker.js +586 -480
  2. package/Build/Workers/chunk-2B7VLWK3.js +58 -0
  3. package/Build/Workers/chunk-2CZLDPAQ.js +101 -0
  4. package/Build/Workers/chunk-2LMIHR6B.js +73 -0
  5. package/Build/Workers/chunk-2ZR6KBRW.js +8366 -0
  6. package/Build/Workers/chunk-32GOIUYC.js +139 -0
  7. package/Build/Workers/chunk-37WPNI52.js +55 -0
  8. package/Build/Workers/chunk-3CD4WIF4.js +101 -0
  9. package/Build/Workers/chunk-3L7XBXFS.js +124 -0
  10. package/Build/Workers/chunk-3PWX65TL.js +398 -0
  11. package/Build/Workers/chunk-3QLIXW6V.js +778 -0
  12. package/Build/Workers/chunk-3SVEN5QG.js +288 -0
  13. package/Build/Workers/chunk-3YO7HM5H.js +476 -0
  14. package/Build/Workers/chunk-3ZDA3MBK.js +114 -0
  15. package/Build/Workers/chunk-45SKJP37.js +102 -0
  16. package/Build/Workers/chunk-4C4UR2S6.js +682 -0
  17. package/Build/Workers/chunk-4CQDMEZY.js +2058 -0
  18. package/Build/Workers/chunk-4DQ3ODGO.js +629 -0
  19. package/Build/Workers/chunk-4GZLJPDW.js +8366 -0
  20. package/Build/Workers/chunk-4SZJ3KRD.js +497 -0
  21. package/Build/Workers/chunk-4UBPBH32.js +162 -0
  22. package/Build/Workers/chunk-5A4OWIAY.js +511 -0
  23. package/Build/Workers/chunk-5D3ECYS3.js +97 -0
  24. package/Build/Workers/chunk-5IOA3NCI.js +8366 -0
  25. package/Build/Workers/chunk-5UKR42KW.js +1483 -0
  26. package/Build/Workers/chunk-5WAMP6Z4.js +299 -0
  27. package/Build/Workers/chunk-5WKGRIN6.js +114 -0
  28. package/Build/Workers/chunk-6BNIWSFA.js +940 -0
  29. package/Build/Workers/chunk-6F4HKBHD.js +352 -0
  30. package/Build/Workers/chunk-6HB2DMC2.js +2719 -0
  31. package/Build/Workers/chunk-6J63N735.js +171 -0
  32. package/Build/Workers/chunk-6TWMNB7Q.js +455 -0
  33. package/Build/Workers/chunk-72Q33KL6.js +280 -0
  34. package/Build/Workers/chunk-72YPCD72.js +1067 -0
  35. package/Build/Workers/chunk-74HENCNJ.js +171 -0
  36. package/Build/Workers/chunk-7AS3X42P.js +682 -0
  37. package/Build/Workers/chunk-7BQLJI3P.js +692 -0
  38. package/Build/Workers/chunk-7C2MOK27.js +57 -0
  39. package/Build/Workers/chunk-7EFYX4FL.js +642 -0
  40. package/Build/Workers/chunk-7EU3DIKZ.js +3514 -0
  41. package/Build/Workers/chunk-7RAUHLDW.js +497 -0
  42. package/Build/Workers/chunk-AFZVC5JN.js +778 -0
  43. package/Build/Workers/chunk-ASGXCLGL.js +97 -0
  44. package/Build/Workers/chunk-B3FJJGCH.js +305 -0
  45. package/Build/Workers/chunk-BGG3BP2R.js +280 -0
  46. package/Build/Workers/chunk-BIJHMMCD.js +138 -0
  47. package/Build/Workers/chunk-BQRZMSMM.js +102 -0
  48. package/Build/Workers/chunk-BYTLHM7N.js +414 -0
  49. package/Build/Workers/chunk-CGAHG2LR.js +163 -0
  50. package/Build/Workers/chunk-CQ5PWUMS.js +37 -0
  51. package/Build/Workers/chunk-CQB3KRGK.js +198 -0
  52. package/Build/Workers/chunk-CR6BZUQC.js +1443 -0
  53. package/Build/Workers/chunk-CV5JLCHF.js +387 -0
  54. package/Build/Workers/chunk-CXDJ7YNS.js +305 -0
  55. package/Build/Workers/chunk-DBM2NHJ5.js +352 -0
  56. package/Build/Workers/chunk-DHWZGIOA.js +139 -0
  57. package/Build/Workers/chunk-DLRIAMQF.js +1800 -0
  58. package/Build/Workers/chunk-DPTYP7J3.js +75 -0
  59. package/Build/Workers/chunk-E7SFSMUX.js +44 -0
  60. package/Build/Workers/chunk-EDFDPOY6.js +55 -0
  61. package/Build/Workers/chunk-EE4T7VKT.js +368 -0
  62. package/Build/Workers/chunk-ENIF6OQ5.js +139 -0
  63. package/Build/Workers/chunk-ET7K6FSD.js +398 -0
  64. package/Build/Workers/chunk-F2BQY3GT.js +1317 -0
  65. package/Build/Workers/chunk-F6JVBOM5.js +788 -0
  66. package/Build/Workers/chunk-F7IITURY.js +497 -0
  67. package/Build/Workers/chunk-FARHIBOA.js +75 -0
  68. package/Build/Workers/chunk-FRF5LWIM.js +299 -0
  69. package/Build/Workers/chunk-G6PDJHNG.js +476 -0
  70. package/Build/Workers/chunk-GCPD37SU.js +1054 -0
  71. package/Build/Workers/chunk-GDHDJK32.js +1045 -0
  72. package/Build/Workers/chunk-GMOKUODV.js +352 -0
  73. package/Build/Workers/chunk-GNGGEDZK.js +352 -0
  74. package/Build/Workers/chunk-GNGZG6C6.js +162 -0
  75. package/Build/Workers/chunk-GPWELPVQ.js +198 -0
  76. package/Build/Workers/chunk-H3BSU65R.js +1067 -0
  77. package/Build/Workers/chunk-HEFUSHA6.js +3514 -0
  78. package/Build/Workers/chunk-HFCJLXTG.js +55 -0
  79. package/Build/Workers/chunk-HKII76UV.js +1800 -0
  80. package/Build/Workers/chunk-HKSICPYV.js +55 -0
  81. package/Build/Workers/chunk-HWUHUN7Z.js +387 -0
  82. package/Build/Workers/chunk-I3VVEQQ6.js +439 -0
  83. package/Build/Workers/chunk-I7LWED3Z.js +101 -0
  84. package/Build/Workers/chunk-IHOM6QXV.js +439 -0
  85. package/Build/Workers/chunk-IK4D64GY.js +439 -0
  86. package/Build/Workers/chunk-IKMU6YHA.js +288 -0
  87. package/Build/Workers/chunk-IVDXHQYL.js +124 -0
  88. package/Build/Workers/chunk-J2S3WMUZ.js +642 -0
  89. package/Build/Workers/chunk-J4PNHKWO.js +2719 -0
  90. package/Build/Workers/chunk-JFLJS4QU.js +1443 -0
  91. package/Build/Workers/chunk-JJWMDUOJ.js +44 -0
  92. package/Build/Workers/chunk-JM4TFRYQ.js +163 -0
  93. package/Build/Workers/chunk-JNNIPGJU.js +163 -0
  94. package/Build/Workers/chunk-JOQFYJZ2.js +692 -0
  95. package/Build/Workers/chunk-JQ7IQ56G.js +837 -0
  96. package/Build/Workers/chunk-JUJONRWD.js +788 -0
  97. package/Build/Workers/chunk-K2PUGKEO.js +2058 -0
  98. package/Build/Workers/chunk-KMJD5APO.js +162 -0
  99. package/Build/Workers/chunk-KWX3CJFT.js +198 -0
  100. package/Build/Workers/chunk-L33HPENB.js +75 -0
  101. package/Build/Workers/chunk-LFQ63ZU4.js +455 -0
  102. package/Build/Workers/chunk-LHJDLAZT.js +1483 -0
  103. package/Build/Workers/chunk-LSGHTNF5.js +511 -0
  104. package/Build/Workers/chunk-LVU4AZC6.js +219 -0
  105. package/Build/Workers/chunk-LXOUU2I5.js +219 -0
  106. package/Build/Workers/chunk-M7EEEKQE.js +476 -0
  107. package/Build/Workers/chunk-MCJRXFRL.js +102 -0
  108. package/Build/Workers/chunk-MLL4AAXV.js +1460 -0
  109. package/Build/Workers/chunk-MPCZC3G6.js +414 -0
  110. package/Build/Workers/chunk-MPHEIDPB.js +629 -0
  111. package/Build/Workers/chunk-MXKQUDTP.js +55 -0
  112. package/Build/Workers/chunk-NEF7XO5W.js +940 -0
  113. package/Build/Workers/chunk-NL7US44X.js +171 -0
  114. package/Build/Workers/chunk-NSRZZEHH.js +455 -0
  115. package/Build/Workers/chunk-NUMQ72QV.js +55 -0
  116. package/Build/Workers/chunk-NXZJKIYD.js +97 -0
  117. package/Build/Workers/chunk-O4MZOV3C.js +414 -0
  118. package/Build/Workers/chunk-OD7UYXFV.js +352 -0
  119. package/Build/Workers/chunk-OOIZ7CHP.js +114 -0
  120. package/Build/Workers/chunk-OX4DGIUJ.js +788 -0
  121. package/Build/Workers/chunk-PEEYBEL5.js +2058 -0
  122. package/Build/Workers/chunk-PEUDXOFI.js +241 -0
  123. package/Build/Workers/chunk-PKXFFIEZ.js +57 -0
  124. package/Build/Workers/chunk-Q2X2Z7JH.js +241 -0
  125. package/Build/Workers/chunk-QFN5B75P.js +1054 -0
  126. package/Build/Workers/chunk-QOLOPE4O.js +1317 -0
  127. package/Build/Workers/chunk-R2AFDOIY.js +778 -0
  128. package/Build/Workers/chunk-RBLCJVK6.js +73 -0
  129. package/Build/Workers/chunk-RGD6RGTH.js +138 -0
  130. package/Build/Workers/chunk-RJ564LVX.js +398 -0
  131. package/Build/Workers/chunk-RNZ5L3W4.js +387 -0
  132. package/Build/Workers/chunk-SCF2OVAZ.js +219 -0
  133. package/Build/Workers/chunk-SJX7UJNW.js +241 -0
  134. package/Build/Workers/chunk-SPPYSEH2.js +1460 -0
  135. package/Build/Workers/chunk-SSE2O2SB.js +1460 -0
  136. package/Build/Workers/chunk-SX6GJD6B.js +837 -0
  137. package/Build/Workers/chunk-SXISWCV7.js +58 -0
  138. package/Build/Workers/chunk-SZQC2TUH.js +368 -0
  139. package/Build/Workers/chunk-TAWVKT4B.js +58 -0
  140. package/Build/Workers/chunk-TBEKWAR5.js +73 -0
  141. package/Build/Workers/chunk-TE277WT3.js +280 -0
  142. package/Build/Workers/chunk-TFL2ZV77.js +692 -0
  143. package/Build/Workers/chunk-THWXTO7B.js +57 -0
  144. package/Build/Workers/chunk-TSNKYHSC.js +305 -0
  145. package/Build/Workers/chunk-TYQ7MNMK.js +37 -0
  146. package/Build/Workers/chunk-U267N6IJ.js +299 -0
  147. package/Build/Workers/chunk-ULWO6TCN.js +352 -0
  148. package/Build/Workers/chunk-UQSQNTEF.js +368 -0
  149. package/Build/Workers/chunk-USWXYJRX.js +1045 -0
  150. package/Build/Workers/chunk-UTDSEOTC.js +288 -0
  151. package/Build/Workers/chunk-UUKLWTJC.js +2719 -0
  152. package/Build/Workers/chunk-UZXJSLDO.js +3514 -0
  153. package/Build/Workers/chunk-V7QHEF6O.js +1317 -0
  154. package/Build/Workers/chunk-VFC54WB7.js +940 -0
  155. package/Build/Workers/chunk-VG7NX64T.js +37 -0
  156. package/Build/Workers/chunk-VIMRGSM5.js +256 -0
  157. package/Build/Workers/chunk-VL4QTEZC.js +138 -0
  158. package/Build/Workers/chunk-VP2OAU4C.js +124 -0
  159. package/Build/Workers/chunk-W3LNGBJU.js +44 -0
  160. package/Build/Workers/chunk-WDMHDACX.js +1800 -0
  161. package/Build/Workers/chunk-WF224D4A.js +642 -0
  162. package/Build/Workers/chunk-WZJEAPEP.js +629 -0
  163. package/Build/Workers/chunk-XHGB5IOL.js +1045 -0
  164. package/Build/Workers/chunk-XMIENZET.js +256 -0
  165. package/Build/Workers/chunk-XXD3TQVI.js +837 -0
  166. package/Build/Workers/chunk-XZN7KCY3.js +1054 -0
  167. package/Build/Workers/chunk-YCTK62TY.js +1483 -0
  168. package/Build/Workers/chunk-YWPKCFKZ.js +1443 -0
  169. package/Build/Workers/chunk-YWSB7PZP.js +511 -0
  170. package/Build/Workers/chunk-ZEEVOFG2.js +256 -0
  171. package/Build/Workers/chunk-ZVXETFPZ.js +1067 -0
  172. package/Build/Workers/chunk-ZXZTWDTN.js +682 -0
  173. package/Build/Workers/combineGeometry.js +24 -24
  174. package/Build/Workers/createBoxGeometry.js +18 -18
  175. package/Build/Workers/createBoxOutlineGeometry.js +16 -16
  176. package/Build/Workers/createCircleGeometry.js +26 -26
  177. package/Build/Workers/createCircleOutlineGeometry.js +19 -19
  178. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
  179. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
  180. package/Build/Workers/createCorridorGeometry.js +29 -29
  181. package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
  182. package/Build/Workers/createCylinderGeometry.js +20 -20
  183. package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
  184. package/Build/Workers/createEllipseGeometry.js +26 -26
  185. package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
  186. package/Build/Workers/createEllipsoidGeometry.js +19 -19
  187. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
  188. package/Build/Workers/createFrustumGeometry.js +18 -18
  189. package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
  190. package/Build/Workers/createGeometry.js +24 -24
  191. package/Build/Workers/createGroundPolylineGeometry.js +22 -22
  192. package/Build/Workers/createPlaneGeometry.js +16 -16
  193. package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
  194. package/Build/Workers/createPolygonGeometry.js +32 -32
  195. package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
  196. package/Build/Workers/createPolylineGeometry.js +25 -25
  197. package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
  198. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
  199. package/Build/Workers/createRectangleGeometry.js +27 -27
  200. package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
  201. package/Build/Workers/createSimplePolylineGeometry.js +23 -23
  202. package/Build/Workers/createSphereGeometry.js +19 -19
  203. package/Build/Workers/createSphereOutlineGeometry.js +18 -18
  204. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  205. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  206. package/Build/Workers/createVectorTileGeometries.js +24 -24
  207. package/Build/Workers/createVectorTilePoints.js +13 -13
  208. package/Build/Workers/createVectorTilePolygons.js +22 -22
  209. package/Build/Workers/createVectorTilePolylines.js +14 -14
  210. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
  211. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
  212. package/Build/Workers/createVerticesFromHeightmap.js +22 -22
  213. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
  214. package/Build/Workers/createWallGeometry.js +24 -24
  215. package/Build/Workers/createWallOutlineGeometry.js +23 -23
  216. package/Build/Workers/decodeDraco.js +10 -10
  217. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  218. package/Build/Workers/decodeI3S.js +10 -10
  219. package/Build/Workers/gaussianSplatSorter.js +4 -4
  220. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  221. package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
  222. package/Build/Workers/transcodeKTX2.js +6 -6
  223. package/Build/Workers/transferTypedArrayTest.js +1 -1
  224. package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
  225. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
  226. package/Source/Renderer/AutomaticUniforms.js +76 -1
  227. package/Source/Renderer/UniformState.js +108 -1
  228. package/Source/Scene/Cesium3DTileset.js +4157 -4157
  229. package/Source/Scene/Model/BarycentricWireframePipelineStage.js +462 -414
  230. package/Source/Scene/Model/LightingPipelineStage.js +17 -2
  231. package/Source/Scene/Model/Model.js +3646 -3623
  232. package/Source/Scene/Model/Model3DTileContent.js +568 -580
  233. package/Source/Scene/Model/ModelRuntimePrimitive.js +391 -391
  234. package/Source/Scene/Model/WireframePipelineStage.js +122 -122
  235. package/Source/Scene/PointLight.js +36 -0
  236. package/Source/Scene/Scene.js +9 -1
  237. package/Source/Shaders/Model/LightingStageFS.glsl +33 -0
  238. package/Source/Shaders/Model/LightingStageFS.js +33 -0
  239. package/Source/ThirdParty/Workers/zip-web-worker.js +1 -1
  240. package/Source/ThirdParty/zip-module.wasm +0 -0
  241. package/index.d.ts +809 -779
  242. package/index.js +48 -47
  243. package/package.json +1 -1
@@ -1,580 +1,568 @@
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._debugWireframeFillColor = tileset._debugWireframeFillColor;
276
- model.debugWireframeFillAlpha = tileset._debugWireframeFillAlpha;
277
- model.debugWireframeLineWidth = tileset.debugWireframeLineWidth;
278
- model.debugWireframeMode = tileset.debugWireframeMode;
279
- model.debugWireframeOverlay = tileset.debugWireframeOverlay;
280
- model._debugWireframeGlow = tileset._debugWireframeGlow ?? 0.0;
281
- model._debugWireframeScanSpeed = tileset._debugWireframeScanSpeed ?? 0.0;
282
- model._debugWireframeScanAxis =
283
- tileset._debugWireframeScanAxis ?? new Cartesian3(0, 0, 1);
284
- model._debugWireframeScanMin = tileset._debugWireframeScanMin ?? 0.0;
285
- model._debugWireframeScanMax = tileset._debugWireframeScanMax ?? 1.0;
286
- model.showOutline = tileset.showOutline;
287
- model.outlineColor = tileset.outlineColor;
288
- model.pointCloudShading = tileset.pointCloudShading;
289
-
290
- if (!tileset.debugWireframe) {
291
- model.color = undefined;
292
- }
293
-
294
- // Updating clipping planes requires more effort because of ownership checks
295
- const tilesetClippingPlanes = tileset.clippingPlanes;
296
- model.referenceMatrix = tileset.clippingPlanesOriginMatrix;
297
- if (defined(tilesetClippingPlanes) && tile.clippingPlanesDirty) {
298
- // Dereference the clipping planes from the model if they are irrelevant.
299
- model._clippingPlanes =
300
- tilesetClippingPlanes.enabled && tile._isClipped
301
- ? tilesetClippingPlanes
302
- : undefined;
303
- }
304
-
305
- const tilesetEnvironmentMapManager = tileset.environmentMapManager;
306
- if (model.environmentMapManager !== tilesetClippingPlanes) {
307
- model._environmentMapManager = tilesetEnvironmentMapManager;
308
- }
309
-
310
- // If the model references a different ClippingPlaneCollection from the tileset,
311
- // update the model to use the new ClippingPlaneCollection.
312
- if (
313
- defined(tilesetClippingPlanes) &&
314
- defined(model._clippingPlanes) &&
315
- model._clippingPlanes !== tilesetClippingPlanes
316
- ) {
317
- model._clippingPlanes = tilesetClippingPlanes;
318
- model._clippingPlanesState = 0;
319
- }
320
-
321
- // Updating clipping polygons requires more effort because of ownership checks
322
- const tilesetClippingPolygons = tileset.clippingPolygons;
323
- if (defined(tilesetClippingPolygons) && tile.clippingPolygonsDirty) {
324
- // Dereference the clipping polygons from the model if they are irrelevant.
325
- model._clippingPolygons =
326
- tilesetClippingPolygons.enabled && tile._isClippedByPolygon
327
- ? tilesetClippingPolygons
328
- : undefined;
329
- }
330
-
331
- // If the model references a different ClippingPolygonCollection from the tileset,
332
- // update the model to use the new ClippingPolygonCollection.
333
- if (
334
- defined(tilesetClippingPolygons) &&
335
- defined(model._clippingPolygons) &&
336
- model._clippingPolygons !== tilesetClippingPolygons
337
- ) {
338
- model._clippingPolygons = tilesetClippingPolygons;
339
- model._clippingPolygonsState = 0;
340
- }
341
-
342
- model.update(frameState);
343
-
344
- if (!this._ready && model.ready) {
345
- // Animation can only be added once the model is ready
346
- model.activeAnimations.addAll({
347
- loop: ModelAnimationLoop.REPEAT,
348
- });
349
-
350
- this._ready = true;
351
- }
352
- };
353
-
354
- Model3DTileContent.prototype.isDestroyed = function () {
355
- return false;
356
- };
357
-
358
- Model3DTileContent.prototype.destroy = function () {
359
- this._model = this._model && this._model.destroy();
360
- return destroyObject(this);
361
- };
362
-
363
- Model3DTileContent.fromGltf = async function (tileset, tile, resource, gltf) {
364
- const content = new Model3DTileContent(tileset, tile, resource);
365
-
366
- const additionalOptions = {
367
- gltf: gltf,
368
- basePath: resource,
369
- };
370
-
371
- const modelOptions = makeModelOptions(
372
- tileset,
373
- tile,
374
- content,
375
- additionalOptions,
376
- );
377
-
378
- const classificationType = tileset.vectorClassificationOnly
379
- ? undefined
380
- : tileset.classificationType;
381
-
382
- modelOptions.classificationType = classificationType;
383
-
384
- const model = await Model.fromGltfAsync(modelOptions);
385
- content._model = model;
386
-
387
- return content;
388
- };
389
-
390
- Model3DTileContent.fromB3dm = async function (
391
- tileset,
392
- tile,
393
- resource,
394
- arrayBuffer,
395
- byteOffset,
396
- ) {
397
- const content = new Model3DTileContent(tileset, tile, resource);
398
-
399
- const additionalOptions = {
400
- arrayBuffer: arrayBuffer,
401
- byteOffset: byteOffset,
402
- resource: resource,
403
- };
404
-
405
- const modelOptions = makeModelOptions(
406
- tileset,
407
- tile,
408
- content,
409
- additionalOptions,
410
- );
411
-
412
- const classificationType = tileset.vectorClassificationOnly
413
- ? undefined
414
- : tileset.classificationType;
415
-
416
- modelOptions.classificationType = classificationType;
417
-
418
- const model = await Model.fromB3dm(modelOptions);
419
- content._model = model;
420
-
421
- return content;
422
- };
423
-
424
- Model3DTileContent.fromI3dm = async function (
425
- tileset,
426
- tile,
427
- resource,
428
- arrayBuffer,
429
- byteOffset,
430
- ) {
431
- const content = new Model3DTileContent(tileset, tile, resource);
432
-
433
- const additionalOptions = {
434
- arrayBuffer: arrayBuffer,
435
- byteOffset: byteOffset,
436
- resource: resource,
437
- };
438
-
439
- const modelOptions = makeModelOptions(
440
- tileset,
441
- tile,
442
- content,
443
- additionalOptions,
444
- );
445
-
446
- const model = await Model.fromI3dm(modelOptions);
447
- content._model = model;
448
-
449
- return content;
450
- };
451
-
452
- Model3DTileContent.fromPnts = async function (
453
- tileset,
454
- tile,
455
- resource,
456
- arrayBuffer,
457
- byteOffset,
458
- ) {
459
- const content = new Model3DTileContent(tileset, tile, resource);
460
-
461
- const additionalOptions = {
462
- arrayBuffer: arrayBuffer,
463
- byteOffset: byteOffset,
464
- resource: resource,
465
- };
466
-
467
- const modelOptions = makeModelOptions(
468
- tileset,
469
- tile,
470
- content,
471
- additionalOptions,
472
- );
473
- const model = await Model.fromPnts(modelOptions);
474
- content._model = model;
475
-
476
- return content;
477
- };
478
-
479
- Model3DTileContent.fromGeoJson = async function (
480
- tileset,
481
- tile,
482
- resource,
483
- geoJson,
484
- ) {
485
- const content = new Model3DTileContent(tileset, tile, resource);
486
-
487
- const additionalOptions = {
488
- geoJson: geoJson,
489
- resource: resource,
490
- };
491
-
492
- const modelOptions = makeModelOptions(
493
- tileset,
494
- tile,
495
- content,
496
- additionalOptions,
497
- );
498
- const model = await Model.fromGeoJson(modelOptions);
499
- content._model = model;
500
-
501
- return content;
502
- };
503
-
504
- /**
505
- * Find an intersection between a ray and the tile content surface that was rendered. The ray must be given in world coordinates.
506
- *
507
- * @param {Ray} ray The ray to test for intersection.
508
- * @param {FrameState} frameState The frame state.
509
- * @param {Cartesian3|undefined} [result] The intersection or <code>undefined</code> if none was found.
510
- * @returns {Cartesian3|undefined} The intersection or <code>undefined</code> if none was found.
511
- *
512
- * @private
513
- */
514
- Model3DTileContent.prototype.pick = function (ray, frameState, result) {
515
- if (!defined(this._model) || !this._ready) {
516
- return undefined;
517
- }
518
-
519
- const verticalExaggeration = frameState.verticalExaggeration;
520
- const relativeHeight = frameState.verticalExaggerationRelativeHeight;
521
-
522
- // All tilesets assume a WGS84 ellipsoid
523
- return this._model.pick(
524
- ray,
525
- frameState,
526
- verticalExaggeration,
527
- relativeHeight,
528
- Ellipsoid.WGS84,
529
- result,
530
- );
531
- };
532
-
533
- function makeModelOptions(tileset, tile, content, additionalOptions) {
534
- const mainOptions = {
535
- cull: false, // The model is already culled by 3D Tiles
536
- releaseGltfJson: true, // Models are unique and will not benefit from caching so save memory
537
- opaquePass: Pass.CESIUM_3D_TILE, // Draw opaque portions of the model during the 3D Tiles pass
538
- modelMatrix: tile.computedTransform,
539
- upAxis: tileset._modelUpAxis,
540
- forwardAxis: tileset._modelForwardAxis,
541
- incrementallyLoadTextures: false,
542
- customShader: tileset.customShader,
543
- content: content,
544
- colorBlendMode: tileset.colorBlendMode,
545
- colorBlendAmount: tileset.colorBlendAmount,
546
- lightColor: tileset.lightColor,
547
- imageBasedLighting: tileset.imageBasedLighting,
548
- featureIdLabel: tileset.featureIdLabel,
549
- instanceFeatureIdLabel: tileset.instanceFeatureIdLabel,
550
- pointCloudShading: tileset.pointCloudShading,
551
- clippingPlanes: tileset.clippingPlanes,
552
- backFaceCulling: tileset.backFaceCulling,
553
- shadows: tileset.shadows,
554
- showCreditsOnScreen: tileset.showCreditsOnScreen,
555
- splitDirection: tileset.splitDirection,
556
- enableDebugWireframe: tileset._enableDebugWireframe,
557
- debugWireframe: tileset.debugWireframe,
558
- debugWireframeColor: tileset._debugWireframeColor,
559
- debugWireframeFillColor: tileset._debugWireframeFillColor,
560
- debugWireframeFillAlpha: tileset._debugWireframeFillAlpha,
561
- debugWireframeLineWidth: tileset.debugWireframeLineWidth,
562
- debugWireframeMode: tileset.debugWireframeMode,
563
- debugWireframeOverlay: tileset.debugWireframeOverlay,
564
- _debugWireframeGlow: tileset._debugWireframeGlow ?? 0.0,
565
- _debugWireframeScanSpeed: tileset._debugWireframeScanSpeed ?? 0.0,
566
- _debugWireframeScanAxis:
567
- tileset._debugWireframeScanAxis ?? new Cartesian3(0, 0, 1),
568
- _debugWireframeScanMin: tileset._debugWireframeScanMin ?? 0.0,
569
- _debugWireframeScanMax: tileset._debugWireframeScanMax ?? 1.0,
570
- projectTo2D: tileset._projectTo2D,
571
- enablePick: tileset._enablePick,
572
- enableShowOutline: tileset._enableShowOutline,
573
- showOutline: tileset.showOutline,
574
- outlineColor: tileset.outlineColor,
575
- };
576
-
577
- return combine(additionalOptions, mainOptions);
578
- }
579
-
580
- 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
+ const defaultScanAxis = new Cartesian3(0, 0, 1);
13
+
14
+ /**
15
+ * Represents the contents of a glTF, glb or
16
+ * {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification/TileFormats/Batched3DModel|Batched 3D Model}
17
+ * tile in a {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification|3D Tiles} tileset.
18
+ * <p>
19
+ * Implements the {@link Cesium3DTileContent} interface.
20
+ * </p>
21
+ * This object is normally not instantiated directly, use {@link Model3DTileContent.fromGltf}, {@link Model3DTileContent.fromB3dm}, {@link Model3DTileContent.fromI3dm}, {@link Model3DTileContent.fromPnts}, or {@link Model3DTileContent.fromGeoJson}.
22
+ *
23
+ * @alias Model3DTileContent
24
+ * @constructor
25
+ * @private
26
+ */
27
+ function Model3DTileContent(tileset, tile, resource) {
28
+ this._tileset = tileset;
29
+ this._tile = tile;
30
+ this._resource = resource;
31
+
32
+ this._model = undefined;
33
+ this._metadata = undefined;
34
+ this._group = undefined;
35
+ this._ready = false;
36
+ }
37
+
38
+ Object.defineProperties(Model3DTileContent.prototype, {
39
+ featuresLength: {
40
+ get: function () {
41
+ const model = this._model;
42
+ const featureTables = model.featureTables;
43
+ const featureTableId = model.featureTableId;
44
+
45
+ if (defined(featureTables) && defined(featureTables[featureTableId])) {
46
+ return featureTables[featureTableId].featuresLength;
47
+ }
48
+
49
+ return 0;
50
+ },
51
+ },
52
+
53
+ pointsLength: {
54
+ get: function () {
55
+ return this._model.statistics.pointsLength;
56
+ },
57
+ },
58
+
59
+ trianglesLength: {
60
+ get: function () {
61
+ return this._model.statistics.trianglesLength;
62
+ },
63
+ },
64
+
65
+ geometryByteLength: {
66
+ get: function () {
67
+ return this._model.statistics.geometryByteLength;
68
+ },
69
+ },
70
+
71
+ texturesByteLength: {
72
+ get: function () {
73
+ return this._model.statistics.texturesByteLength;
74
+ },
75
+ },
76
+
77
+ batchTableByteLength: {
78
+ get: function () {
79
+ const statistics = this._model.statistics;
80
+ return (
81
+ statistics.propertyTablesByteLength + statistics.batchTexturesByteLength
82
+ );
83
+ },
84
+ },
85
+
86
+ innerContents: {
87
+ get: function () {
88
+ return undefined;
89
+ },
90
+ },
91
+
92
+ /**
93
+ * Returns true when the tile's content is ready to render; otherwise false
94
+ *
95
+ * @memberof Model3DTileContent.prototype
96
+ *
97
+ * @type {boolean}
98
+ * @readonly
99
+ * @private
100
+ */
101
+ ready: {
102
+ get: function () {
103
+ return this._ready;
104
+ },
105
+ },
106
+
107
+ tileset: {
108
+ get: function () {
109
+ return this._tileset;
110
+ },
111
+ },
112
+
113
+ tile: {
114
+ get: function () {
115
+ return this._tile;
116
+ },
117
+ },
118
+
119
+ url: {
120
+ get: function () {
121
+ return this._resource.getUrlComponent(true);
122
+ },
123
+ },
124
+
125
+ batchTable: {
126
+ get: function () {
127
+ const model = this._model;
128
+ const featureTables = model.featureTables;
129
+ const featureTableId = model.featureTableId;
130
+
131
+ if (defined(featureTables) && defined(featureTables[featureTableId])) {
132
+ return featureTables[featureTableId];
133
+ }
134
+
135
+ return undefined;
136
+ },
137
+ },
138
+
139
+ metadata: {
140
+ get: function () {
141
+ return this._metadata;
142
+ },
143
+ set: function (value) {
144
+ this._metadata = value;
145
+ },
146
+ },
147
+
148
+ group: {
149
+ get: function () {
150
+ return this._group;
151
+ },
152
+ set: function (value) {
153
+ this._group = value;
154
+ },
155
+ },
156
+ });
157
+
158
+ /**
159
+ * Returns an array containing the `texture.id` values for all textures
160
+ * that are part of this content.
161
+ *
162
+ * @returns {string[]} The texture IDs
163
+ */
164
+ Model3DTileContent.prototype.getTextureIds = function () {
165
+ return this._model.statistics.getTextureIds();
166
+ };
167
+
168
+ /**
169
+ * Returns the length, in bytes, of the texture data for the texture with
170
+ * the given ID that is part of this content, or `undefined` if this
171
+ * content does not contain the texture with the given ID.
172
+ *
173
+ * @param {string} textureId The texture ID
174
+ * @returns {number|undefined} The texture byte length
175
+ */
176
+ Model3DTileContent.prototype.getTextureByteLengthById = function (textureId) {
177
+ return this._model.statistics.getTextureByteLengthById(textureId);
178
+ };
179
+
180
+ /**
181
+ * Returns the object that was created for the given extension.
182
+ *
183
+ * The given name may be the name of a glTF extension, like `"EXT_example_extension"`.
184
+ * If the specified extension was present in the root of the underlying glTF asset,
185
+ * and a loader for the specified extension has processed the extension data, then
186
+ * this will return the model representation of the extension.
187
+ *
188
+ * @param {string} extensionName The name of the extension
189
+ * @returns {object|undefined} The object, or `undefined`
190
+ *
191
+ * @private
192
+ */
193
+ Model3DTileContent.prototype.getExtension = function (extensionName) {
194
+ const model = this._model;
195
+ const extension = model.getExtension(extensionName);
196
+ return extension;
197
+ };
198
+
199
+ Model3DTileContent.prototype.getFeature = function (featureId) {
200
+ const model = this._model;
201
+ const featureTableId = model.featureTableId;
202
+
203
+ //>>includeStart('debug', pragmas.debug);
204
+ if (!defined(featureTableId)) {
205
+ throw new DeveloperError(
206
+ "No feature ID set is selected. Make sure Cesium3DTileset.featureIdLabel or Cesium3DTileset.instanceFeatureIdLabel is defined",
207
+ );
208
+ }
209
+ //>>includeEnd('debug');
210
+
211
+ const featureTable = model.featureTables[featureTableId];
212
+
213
+ //>>includeStart('debug', pragmas.debug);
214
+ if (!defined(featureTable)) {
215
+ throw new DeveloperError(
216
+ "No feature table found for the selected feature ID set",
217
+ );
218
+ }
219
+ //>>includeEnd('debug');
220
+
221
+ //>>includeStart('debug', pragmas.debug);
222
+ const featuresLength = featureTable.featuresLength;
223
+ if (!defined(featureId) || featureId < 0 || featureId >= featuresLength) {
224
+ throw new DeveloperError(
225
+ `featureId is required and must be between 0 and featuresLength - 1 (${
226
+ featuresLength - 1
227
+ }).`,
228
+ );
229
+ }
230
+ //>>includeEnd('debug');
231
+ return featureTable.getFeature(featureId);
232
+ };
233
+
234
+ Model3DTileContent.prototype.hasProperty = function (featureId, name) {
235
+ const model = this._model;
236
+ const featureTableId = model.featureTableId;
237
+ if (!defined(featureTableId)) {
238
+ return false;
239
+ }
240
+
241
+ const featureTable = model.featureTables[featureTableId];
242
+ return featureTable.hasProperty(featureId, name);
243
+ };
244
+
245
+ Model3DTileContent.prototype.applyDebugSettings = function (enabled, color) {
246
+ color = enabled ? color : Color.WHITE;
247
+ if (this.featuresLength === 0) {
248
+ this._model.color = color;
249
+ } else if (defined(this.batchTable)) {
250
+ this.batchTable.setAllColor(color);
251
+ }
252
+ };
253
+
254
+ Model3DTileContent.prototype.applyStyle = function (style) {
255
+ // the setter will call model.applyStyle()
256
+ this._model.style = style;
257
+ };
258
+
259
+ Model3DTileContent.prototype.update = function (tileset, frameState) {
260
+ const model = this._model;
261
+ const tile = this._tile;
262
+
263
+ model.colorBlendAmount = tileset.colorBlendAmount;
264
+ model.colorBlendMode = tileset.colorBlendMode;
265
+ model.modelMatrix = tile.computedTransform;
266
+ model.customShader = tileset.customShader;
267
+ model.featureIdLabel = tileset.featureIdLabel;
268
+ model.instanceFeatureIdLabel = tileset.instanceFeatureIdLabel;
269
+ model.lightColor = tileset.lightColor;
270
+ model.imageBasedLighting = tileset.imageBasedLighting;
271
+ model.backFaceCulling = tileset.backFaceCulling;
272
+ model.shadows = tileset.shadows;
273
+ model.showCreditsOnScreen = tileset.showCreditsOnScreen;
274
+ model.splitDirection = tileset.splitDirection;
275
+ model.debugWireframe = tileset.debugWireframe;
276
+ if (tileset.debugWireframe) {
277
+ model.debugWireframeColor = tileset._debugWireframeColor;
278
+ model._debugWireframeFillColor = tileset._debugWireframeFillColor;
279
+ model.debugWireframeFillAlpha = tileset._debugWireframeFillAlpha;
280
+ model.debugWireframeLineWidth = tileset.debugWireframeLineWidth;
281
+ model.debugWireframeMode = tileset.debugWireframeMode;
282
+ model.debugWireframeOverlay = tileset.debugWireframeOverlay;
283
+ model._debugWireframeGlow = tileset._debugWireframeGlow ?? 0.0;
284
+ model._debugWireframeScanSpeed = tileset._debugWireframeScanSpeed ?? 0.0;
285
+ model._debugWireframeScanAxis =
286
+ tileset._debugWireframeScanAxis ?? defaultScanAxis;
287
+ model._debugWireframeScanMin = tileset._debugWireframeScanMin ?? 0.0;
288
+ model._debugWireframeScanMax = tileset._debugWireframeScanMax ?? 1.0;
289
+ }
290
+ model.showOutline = tileset.showOutline;
291
+ model.outlineColor = tileset.outlineColor;
292
+ model.pointCloudShading = tileset.pointCloudShading;
293
+
294
+ // Updating clipping planes requires more effort because of ownership checks
295
+ const tilesetClippingPlanes = tileset.clippingPlanes;
296
+ model.referenceMatrix = tileset.clippingPlanesOriginMatrix;
297
+ if (defined(tilesetClippingPlanes) && tile.clippingPlanesDirty) {
298
+ // Dereference the clipping planes from the model if they are irrelevant.
299
+ model._clippingPlanes =
300
+ tilesetClippingPlanes.enabled && tile._isClipped
301
+ ? tilesetClippingPlanes
302
+ : undefined;
303
+ }
304
+
305
+ const tilesetEnvironmentMapManager = tileset.environmentMapManager;
306
+ if (model.environmentMapManager !== tilesetClippingPlanes) {
307
+ model._environmentMapManager = tilesetEnvironmentMapManager;
308
+ }
309
+
310
+ // If the model references a different ClippingPlaneCollection from the tileset,
311
+ // update the model to use the new ClippingPlaneCollection.
312
+ if (
313
+ defined(tilesetClippingPlanes) &&
314
+ defined(model._clippingPlanes) &&
315
+ model._clippingPlanes !== tilesetClippingPlanes
316
+ ) {
317
+ model._clippingPlanes = tilesetClippingPlanes;
318
+ model._clippingPlanesState = 0;
319
+ }
320
+
321
+ // Updating clipping polygons requires more effort because of ownership checks
322
+ const tilesetClippingPolygons = tileset.clippingPolygons;
323
+ if (defined(tilesetClippingPolygons) && tile.clippingPolygonsDirty) {
324
+ // Dereference the clipping polygons from the model if they are irrelevant.
325
+ model._clippingPolygons =
326
+ tilesetClippingPolygons.enabled && tile._isClippedByPolygon
327
+ ? tilesetClippingPolygons
328
+ : undefined;
329
+ }
330
+
331
+ // If the model references a different ClippingPolygonCollection from the tileset,
332
+ // update the model to use the new ClippingPolygonCollection.
333
+ if (
334
+ defined(tilesetClippingPolygons) &&
335
+ defined(model._clippingPolygons) &&
336
+ model._clippingPolygons !== tilesetClippingPolygons
337
+ ) {
338
+ model._clippingPolygons = tilesetClippingPolygons;
339
+ model._clippingPolygonsState = 0;
340
+ }
341
+
342
+ model.update(frameState);
343
+
344
+ if (!this._ready && model.ready) {
345
+ // Animation can only be added once the model is ready
346
+ model.activeAnimations.addAll({
347
+ loop: ModelAnimationLoop.REPEAT,
348
+ });
349
+
350
+ this._ready = true;
351
+ }
352
+ };
353
+
354
+ Model3DTileContent.prototype.isDestroyed = function () {
355
+ return false;
356
+ };
357
+
358
+ Model3DTileContent.prototype.destroy = function () {
359
+ this._model = this._model && this._model.destroy();
360
+ return destroyObject(this);
361
+ };
362
+
363
+ Model3DTileContent.fromGltf = async function (tileset, tile, resource, gltf) {
364
+ const content = new Model3DTileContent(tileset, tile, resource);
365
+
366
+ const additionalOptions = {
367
+ gltf: gltf,
368
+ basePath: resource,
369
+ };
370
+
371
+ const modelOptions = makeModelOptions(
372
+ tileset,
373
+ tile,
374
+ content,
375
+ additionalOptions,
376
+ );
377
+
378
+ const classificationType = tileset.vectorClassificationOnly
379
+ ? undefined
380
+ : tileset.classificationType;
381
+
382
+ modelOptions.classificationType = classificationType;
383
+
384
+ const model = await Model.fromGltfAsync(modelOptions);
385
+ content._model = model;
386
+
387
+ return content;
388
+ };
389
+
390
+ Model3DTileContent.fromB3dm = async function (
391
+ tileset,
392
+ tile,
393
+ resource,
394
+ arrayBuffer,
395
+ byteOffset,
396
+ ) {
397
+ const content = new Model3DTileContent(tileset, tile, resource);
398
+
399
+ const additionalOptions = {
400
+ arrayBuffer: arrayBuffer,
401
+ byteOffset: byteOffset,
402
+ resource: resource,
403
+ };
404
+
405
+ const modelOptions = makeModelOptions(
406
+ tileset,
407
+ tile,
408
+ content,
409
+ additionalOptions,
410
+ );
411
+
412
+ const classificationType = tileset.vectorClassificationOnly
413
+ ? undefined
414
+ : tileset.classificationType;
415
+
416
+ modelOptions.classificationType = classificationType;
417
+
418
+ const model = await Model.fromB3dm(modelOptions);
419
+ content._model = model;
420
+
421
+ return content;
422
+ };
423
+
424
+ Model3DTileContent.fromI3dm = async function (
425
+ tileset,
426
+ tile,
427
+ resource,
428
+ arrayBuffer,
429
+ byteOffset,
430
+ ) {
431
+ const content = new Model3DTileContent(tileset, tile, resource);
432
+
433
+ const additionalOptions = {
434
+ arrayBuffer: arrayBuffer,
435
+ byteOffset: byteOffset,
436
+ resource: resource,
437
+ };
438
+
439
+ const modelOptions = makeModelOptions(
440
+ tileset,
441
+ tile,
442
+ content,
443
+ additionalOptions,
444
+ );
445
+
446
+ const model = await Model.fromI3dm(modelOptions);
447
+ content._model = model;
448
+
449
+ return content;
450
+ };
451
+
452
+ Model3DTileContent.fromPnts = async function (
453
+ tileset,
454
+ tile,
455
+ resource,
456
+ arrayBuffer,
457
+ byteOffset,
458
+ ) {
459
+ const content = new Model3DTileContent(tileset, tile, resource);
460
+
461
+ const additionalOptions = {
462
+ arrayBuffer: arrayBuffer,
463
+ byteOffset: byteOffset,
464
+ resource: resource,
465
+ };
466
+
467
+ const modelOptions = makeModelOptions(
468
+ tileset,
469
+ tile,
470
+ content,
471
+ additionalOptions,
472
+ );
473
+ const model = await Model.fromPnts(modelOptions);
474
+ content._model = model;
475
+
476
+ return content;
477
+ };
478
+
479
+ Model3DTileContent.fromGeoJson = async function (
480
+ tileset,
481
+ tile,
482
+ resource,
483
+ geoJson,
484
+ ) {
485
+ const content = new Model3DTileContent(tileset, tile, resource);
486
+
487
+ const additionalOptions = {
488
+ geoJson: geoJson,
489
+ resource: resource,
490
+ };
491
+
492
+ const modelOptions = makeModelOptions(
493
+ tileset,
494
+ tile,
495
+ content,
496
+ additionalOptions,
497
+ );
498
+ const model = await Model.fromGeoJson(modelOptions);
499
+ content._model = model;
500
+
501
+ return content;
502
+ };
503
+
504
+ /**
505
+ * Find an intersection between a ray and the tile content surface that was rendered. The ray must be given in world coordinates.
506
+ *
507
+ * @param {Ray} ray The ray to test for intersection.
508
+ * @param {FrameState} frameState The frame state.
509
+ * @param {Cartesian3|undefined} [result] The intersection or <code>undefined</code> if none was found.
510
+ * @returns {Cartesian3|undefined} The intersection or <code>undefined</code> if none was found.
511
+ *
512
+ * @private
513
+ */
514
+ Model3DTileContent.prototype.pick = function (ray, frameState, result) {
515
+ if (!defined(this._model) || !this._ready) {
516
+ return undefined;
517
+ }
518
+
519
+ const verticalExaggeration = frameState.verticalExaggeration;
520
+ const relativeHeight = frameState.verticalExaggerationRelativeHeight;
521
+
522
+ // All tilesets assume a WGS84 ellipsoid
523
+ return this._model.pick(
524
+ ray,
525
+ frameState,
526
+ verticalExaggeration,
527
+ relativeHeight,
528
+ Ellipsoid.WGS84,
529
+ result,
530
+ );
531
+ };
532
+
533
+ function makeModelOptions(tileset, tile, content, additionalOptions) {
534
+ const mainOptions = {
535
+ cull: false, // The model is already culled by 3D Tiles
536
+ releaseGltfJson: true, // Models are unique and will not benefit from caching so save memory
537
+ opaquePass: Pass.CESIUM_3D_TILE, // Draw opaque portions of the model during the 3D Tiles pass
538
+ modelMatrix: tile.computedTransform,
539
+ upAxis: tileset._modelUpAxis,
540
+ forwardAxis: tileset._modelForwardAxis,
541
+ incrementallyLoadTextures: false,
542
+ customShader: tileset.customShader,
543
+ content: content,
544
+ colorBlendMode: tileset.colorBlendMode,
545
+ colorBlendAmount: tileset.colorBlendAmount,
546
+ lightColor: tileset.lightColor,
547
+ imageBasedLighting: tileset.imageBasedLighting,
548
+ featureIdLabel: tileset.featureIdLabel,
549
+ instanceFeatureIdLabel: tileset.instanceFeatureIdLabel,
550
+ pointCloudShading: tileset.pointCloudShading,
551
+ clippingPlanes: tileset.clippingPlanes,
552
+ backFaceCulling: tileset.backFaceCulling,
553
+ shadows: tileset.shadows,
554
+ showCreditsOnScreen: tileset.showCreditsOnScreen,
555
+ splitDirection: tileset.splitDirection,
556
+ enableDebugWireframe: tileset._enableDebugWireframe,
557
+ debugWireframe: tileset.debugWireframe,
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;