@cesium/engine 14.0.0 → 15.0.0
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.
- package/Build/Workers/{chunk-EWDGNOJE.js → chunk-25TOENEE.js} +7 -7
- package/Build/Workers/{chunk-OMXHEJTK.js → chunk-2AVIUB5H.js} +2 -2
- package/Build/Workers/{chunk-LJBJM6VI.js → chunk-3JZGPJMZ.js} +6 -6
- package/Build/Workers/{chunk-DT5NFR5C.js → chunk-3LHBH4TC.js} +7 -7
- package/Build/Workers/{chunk-3QLSKXKF.js → chunk-3LZF23RY.js} +6 -6
- package/Build/Workers/{chunk-ED6GLQTK.js → chunk-5S2B46UQ.js} +1 -1
- package/Build/Workers/{chunk-B4GSRXE3.js → chunk-67ONR44K.js} +6 -6
- package/Build/Workers/{chunk-LOZ4NKY3.js → chunk-6EDBC234.js} +11 -11
- package/Build/Workers/{chunk-7ZB2RVIQ.js → chunk-6EV4VOET.js} +10 -10
- package/Build/Workers/{chunk-KHWLAQVA.js → chunk-7ITUZTFH.js} +1 -1
- package/Build/Workers/{chunk-JHBPC4LK.js → chunk-ARVZCY6X.js} +7 -7
- package/Build/Workers/{chunk-FFBJDW4A.js → chunk-B2UQN3DH.js} +6 -6
- package/Build/Workers/{chunk-VCNOFQYH.js → chunk-B2Y4ZS6X.js} +9 -9
- package/Build/Workers/{chunk-Q4ZVWJXX.js → chunk-BD2TPFGC.js} +5 -5
- package/Build/Workers/{chunk-K4AH3TDT.js → chunk-CHX2K5AC.js} +10 -10
- package/Build/Workers/{chunk-3LYROPON.js → chunk-CJGVEABL.js} +13 -13
- package/Build/Workers/{chunk-KSYBJA4M.js → chunk-DYJHEP3B.js} +5 -5
- package/Build/Workers/{chunk-CI2HEJFC.js → chunk-E3H7AVMK.js} +13 -13
- package/Build/Workers/{chunk-F4CUH4MR.js → chunk-EZNAJPP5.js} +4 -4
- package/Build/Workers/{chunk-YJX7X577.js → chunk-F7ZI463G.js} +15 -15
- package/Build/Workers/{chunk-HEZHXDYB.js → chunk-FMZ5CX6V.js} +1 -1
- package/Build/Workers/{chunk-G3BVMPWG.js → chunk-FRAWHNSR.js} +2 -2
- package/Build/Workers/{chunk-J7IH4EYI.js → chunk-GGV2XJHE.js} +7 -7
- package/Build/Workers/{chunk-5KWRW7YL.js → chunk-GK4QU6QI.js} +2 -2
- package/Build/Workers/{chunk-77XPS7ZA.js → chunk-HYPB7FAV.js} +10 -10
- package/Build/Workers/{chunk-MVM4JV5U.js → chunk-I4HO2ED2.js} +9 -9
- package/Build/Workers/{chunk-FX4R4MTH.js → chunk-IGINOLDX.js} +6 -6
- package/Build/Workers/{chunk-PWF4EY5P.js → chunk-ISQSYLZY.js} +4 -4
- package/Build/Workers/{chunk-7UHKH6M3.js → chunk-JZAMRL5I.js} +6 -6
- package/Build/Workers/{chunk-HUFQVUMY.js → chunk-K5G2WELR.js} +7 -7
- package/Build/Workers/{chunk-5S5OOA6U.js → chunk-L5SO4Y5V.js} +1 -1
- package/Build/Workers/{chunk-LNSWJ43X.js → chunk-LCMJQVIF.js} +11 -11
- package/Build/Workers/{chunk-WVNLSTOF.js → chunk-MWJW37I7.js} +2 -2
- package/Build/Workers/{chunk-ZGFIT57T.js → chunk-NAGMYRDW.js} +27 -20
- package/Build/Workers/{chunk-SDIDRZDG.js → chunk-OYO6TKMU.js} +7 -7
- package/Build/Workers/{chunk-HKHQ3EDR.js → chunk-PUTA3AE2.js} +4 -4
- package/Build/Workers/{chunk-JPDKYBLF.js → chunk-Q5BHMNKU.js} +13 -13
- package/Build/Workers/{chunk-XK4OP6VA.js → chunk-QTEX3Y4V.js} +17 -17
- package/Build/Workers/{chunk-TVL3F7IU.js → chunk-QZKN2RXM.js} +1 -1
- package/Build/Workers/{chunk-Z3QWTHI7.js → chunk-RO2Z3LCR.js} +14 -14
- package/Build/Workers/{chunk-N2XAJBC6.js → chunk-RRN6LRDX.js} +12 -12
- package/Build/Workers/{chunk-FYGLNDKG.js → chunk-SLIA3GQP.js} +7 -7
- package/Build/Workers/{chunk-7EO56M5R.js → chunk-TFCOEX3W.js} +2 -2
- package/Build/Workers/{chunk-KM6MITPF.js → chunk-TU6ZXHVU.js} +5 -5
- package/Build/Workers/{chunk-LS3KVHYY.js → chunk-VJ2PDF64.js} +6 -6
- package/Build/Workers/{chunk-D7ZBZPHV.js → chunk-VMVPONIV.js} +5 -5
- package/Build/Workers/{chunk-3PIZQT3I.js → chunk-WPXU45PH.js} +4 -4
- package/Build/Workers/{chunk-WEHZP4SE.js → chunk-XDHM4G3P.js} +7 -7
- package/Build/Workers/{chunk-TY4DKOWR.js → chunk-XED3RXKO.js} +2 -2
- package/Build/Workers/{chunk-ZMNLEL6W.js → chunk-YNYCGTQH.js} +5 -5
- package/Build/Workers/{chunk-4CHMVQTQ.js → chunk-Z4SI54EB.js} +4 -4
- package/Build/Workers/{chunk-3JBEPBPL.js → chunk-ZVDLC3T4.js} +13 -13
- package/Build/Workers/combineGeometry.js +22 -22
- package/Build/Workers/createBoxGeometry.js +16 -16
- package/Build/Workers/createBoxOutlineGeometry.js +14 -14
- package/Build/Workers/createCircleGeometry.js +24 -24
- package/Build/Workers/createCircleOutlineGeometry.js +17 -17
- package/Build/Workers/createCoplanarPolygonGeometry.js +31 -31
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -29
- package/Build/Workers/createCorridorGeometry.js +27 -27
- package/Build/Workers/createCorridorOutlineGeometry.js +26 -26
- package/Build/Workers/createCylinderGeometry.js +18 -18
- package/Build/Workers/createCylinderOutlineGeometry.js +16 -16
- package/Build/Workers/createEllipseGeometry.js +24 -24
- package/Build/Workers/createEllipseOutlineGeometry.js +17 -17
- package/Build/Workers/createEllipsoidGeometry.js +17 -17
- package/Build/Workers/createEllipsoidOutlineGeometry.js +16 -16
- package/Build/Workers/createFrustumGeometry.js +16 -16
- package/Build/Workers/createFrustumOutlineGeometry.js +16 -16
- package/Build/Workers/createGeometry.js +22 -22
- package/Build/Workers/createGroundPolylineGeometry.js +20 -20
- package/Build/Workers/createPlaneGeometry.js +14 -14
- package/Build/Workers/createPlaneOutlineGeometry.js +13 -13
- package/Build/Workers/createPolygonGeometry.js +30 -30
- package/Build/Workers/createPolygonOutlineGeometry.js +28 -28
- package/Build/Workers/createPolylineGeometry.js +23 -23
- package/Build/Workers/createPolylineVolumeGeometry.js +29 -29
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +25 -25
- package/Build/Workers/createRectangleGeometry.js +25 -25
- package/Build/Workers/createRectangleOutlineGeometry.js +18 -18
- package/Build/Workers/createSimplePolylineGeometry.js +21 -21
- package/Build/Workers/createSphereGeometry.js +17 -17
- package/Build/Workers/createSphereOutlineGeometry.js +16 -16
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +13 -13
- package/Build/Workers/createVectorTileGeometries.js +22 -22
- package/Build/Workers/createVectorTilePoints.js +12 -12
- package/Build/Workers/createVectorTilePolygons.js +20 -20
- package/Build/Workers/createVectorTilePolylines.js +13 -13
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +20 -20
- package/Build/Workers/createVerticesFromHeightmap.js +20 -20
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +17 -17
- package/Build/Workers/createWallGeometry.js +22 -22
- package/Build/Workers/createWallOutlineGeometry.js +21 -21
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +10 -10
- package/Build/Workers/transcodeKTX2.js +50 -43
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -20
- package/Source/Core/EllipsoidRhumbLine.js +1 -1
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/PolygonGeometryLibrary.js +26 -4
- package/Source/Core/TexturePacker.js +166 -0
- package/Source/DataSources/BillboardVisualizer.js +3 -3
- package/Source/DataSources/EntityCluster.js +44 -19
- package/Source/Renderer/Context.js +0 -4
- package/Source/Renderer/Texture.js +6 -5
- package/Source/Renderer/TextureAtlas.js +802 -0
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Billboard.js +86 -141
- package/Source/Scene/BillboardCollection.js +132 -202
- package/Source/Scene/BillboardLoadState.js +44 -0
- package/Source/Scene/BillboardTexture.js +348 -0
- package/Source/Scene/Camera.js +2 -2
- package/Source/Scene/Cesium3DTilesVoxelProvider.js +380 -126
- package/Source/Scene/Cesium3DTilesetStatistics.js +0 -1
- package/Source/Scene/Expression.js +1 -0
- package/Source/Scene/GltfLoader.js +5 -7
- package/Source/Scene/ImplicitSubtree.js +2 -0
- package/Source/Scene/KeyframeNode.js +16 -2
- package/Source/Scene/LabelCollection.js +212 -182
- package/Source/Scene/Megatexture.js +145 -81
- package/Source/Scene/Model/CustomShader.js +0 -2
- package/Source/Scene/Model/Model.js +1 -1
- package/Source/Scene/Model/ModelUtility.js +5 -1
- package/Source/Scene/Scene.js +39 -15
- package/Source/Scene/ScreenSpaceCameraController.js +0 -8
- package/Source/Scene/SpatialNode.js +4 -11
- package/Source/Scene/Vector3DTilePoints.js +2 -5
- package/Source/Scene/VoxelBoxShape.js +12 -5
- package/Source/Scene/VoxelCell.js +6 -5
- package/Source/Scene/VoxelContent.js +171 -107
- package/Source/Scene/VoxelCylinderShape.js +65 -58
- package/Source/Scene/VoxelEllipsoidShape.js +15 -5
- package/Source/Scene/VoxelMetadataOrder.js +12 -0
- package/Source/Scene/VoxelPrimitive.js +122 -54
- package/Source/Scene/VoxelProvider.js +34 -29
- package/Source/Scene/VoxelRenderResources.js +30 -7
- package/Source/Scene/VoxelShape.js +10 -3
- package/Source/Scene/VoxelTraversal.js +264 -180
- package/Source/Scene/processVoxelProperties.js +3 -0
- package/Source/Shaders/GlobeFS.glsl +10 -1
- package/Source/Shaders/GlobeFS.js +10 -1
- package/Source/Shaders/Voxels/Megatexture.glsl +4 -16
- package/Source/Shaders/Voxels/Megatexture.js +4 -16
- package/Source/Shaders/Voxels/Octree.glsl +44 -7
- package/Source/Shaders/Voxels/Octree.js +44 -7
- package/Source/Shaders/Voxels/VoxelFS.glsl +9 -15
- package/Source/Shaders/Voxels/VoxelFS.js +9 -15
- package/Source/Shaders/Voxels/convertUvToCylinder.glsl +15 -15
- package/Source/Shaders/Voxels/convertUvToCylinder.js +15 -15
- package/index.d.ts +176 -79
- package/index.js +413 -409
- package/package.json +2 -2
- package/Source/Scene/TextureAtlas.js +0 -558
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import Check from "../Core/Check.js";
|
|
2
|
+
import defined from "../Core/defined.js";
|
|
3
|
+
import BillboardLoadState from "./BillboardLoadState.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Tracks a reference to an image and it's loading state, as used in a BillboardCollection and stored in a texture atlas.
|
|
7
|
+
* @constructor
|
|
8
|
+
* @private
|
|
9
|
+
* @see BillboardCollection
|
|
10
|
+
* @see Billboard#image
|
|
11
|
+
* @alias BillboardTexture
|
|
12
|
+
* @param {BillboardCollection} billboardCollection The associated billboard collecion.
|
|
13
|
+
*/
|
|
14
|
+
function BillboardTexture(billboardCollection) {
|
|
15
|
+
//>>includeStart('debug', pragmas.debug);
|
|
16
|
+
Check.defined("billboardCollection", billboardCollection);
|
|
17
|
+
//>>includeEnd('debug');
|
|
18
|
+
|
|
19
|
+
this._billboardCollection = billboardCollection;
|
|
20
|
+
|
|
21
|
+
this._id = undefined;
|
|
22
|
+
this._loadState = BillboardLoadState.NONE;
|
|
23
|
+
this._loadError = undefined;
|
|
24
|
+
|
|
25
|
+
this._index = -1;
|
|
26
|
+
this._width = undefined;
|
|
27
|
+
this._height = undefined;
|
|
28
|
+
|
|
29
|
+
this._hasSubregion = false;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Used by billboardCollection to track whcih billboards to update.
|
|
33
|
+
* @type {boolean}
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
this.dirty = false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
Object.defineProperties(BillboardTexture.prototype, {
|
|
40
|
+
/**
|
|
41
|
+
* If defined, this error was encountered during the loading process.
|
|
42
|
+
* @memberof BillboardTexture.prototype
|
|
43
|
+
* @type {Error|undefined}
|
|
44
|
+
* @readonly
|
|
45
|
+
* @private
|
|
46
|
+
*/
|
|
47
|
+
loadError: {
|
|
48
|
+
get: function () {
|
|
49
|
+
return this._loadError;
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The current status of the image load. When <code>BillboardLoadState.LOADED</code>, this billboard is ready to render, i.e., the image
|
|
55
|
+
* has been downloaded and the WebGL resources are created.
|
|
56
|
+
* @memberof BillboardTexture.prototype
|
|
57
|
+
* @type {BillboardLoadState}
|
|
58
|
+
* @readonly
|
|
59
|
+
* @default BillboardLoadState.NONE
|
|
60
|
+
* @private
|
|
61
|
+
*/
|
|
62
|
+
loadState: {
|
|
63
|
+
get: function () {
|
|
64
|
+
return this._loadState;
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* When <code>true</code>, this texture is ready to render, i.e., the image
|
|
70
|
+
* has been downloaded and the WebGL resources are created.
|
|
71
|
+
* @memberof BillboardTexture.prototype
|
|
72
|
+
* @type {boolean}
|
|
73
|
+
* @readonly
|
|
74
|
+
* @default false
|
|
75
|
+
* @private
|
|
76
|
+
*/
|
|
77
|
+
ready: {
|
|
78
|
+
get: function () {
|
|
79
|
+
return this._loadState === BillboardLoadState.LOADED;
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Returns <code>true</code> if there is image data associated with this instance.
|
|
85
|
+
* @memberof BillboardTexture.prototype
|
|
86
|
+
* @type {boolean}
|
|
87
|
+
* @readonly
|
|
88
|
+
* @private
|
|
89
|
+
*/
|
|
90
|
+
hasImage: {
|
|
91
|
+
get: function () {
|
|
92
|
+
return this._loadState !== BillboardLoadState.NONE;
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* A unique identifier for the image, or undefined if no image data has been associated with this instance.
|
|
98
|
+
* @memberof BillboardTexture.prototype
|
|
99
|
+
* @type {string|undefined}
|
|
100
|
+
* @readonly
|
|
101
|
+
* @private
|
|
102
|
+
*/
|
|
103
|
+
id: {
|
|
104
|
+
get: function () {
|
|
105
|
+
return this._id;
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The width of the associated image. Before the instance is <code>ready</code>, this will be <code>undefined</code>.
|
|
111
|
+
* @memberof BillboardTexture.prototype
|
|
112
|
+
* @type {number|undefined}
|
|
113
|
+
* @readonly
|
|
114
|
+
* @private
|
|
115
|
+
*/
|
|
116
|
+
width: {
|
|
117
|
+
get: function () {
|
|
118
|
+
return this._width;
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The height of the associated image. Before the instance is <code>ready</code>, this will be <code>undefined</code>.
|
|
124
|
+
* @memberof BillboardTexture.prototype
|
|
125
|
+
* @type {number|undefined}
|
|
126
|
+
* @readonly
|
|
127
|
+
* @private
|
|
128
|
+
*/
|
|
129
|
+
height: {
|
|
130
|
+
get: function () {
|
|
131
|
+
return this._height;
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Releases reference to any associated image data.
|
|
138
|
+
* @private
|
|
139
|
+
*/
|
|
140
|
+
BillboardTexture.prototype.unload = async function () {
|
|
141
|
+
if (this._loadState === BillboardLoadState.NONE) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
this._id = undefined;
|
|
146
|
+
this._loadError = undefined;
|
|
147
|
+
this._loadState = BillboardLoadState.NONE;
|
|
148
|
+
|
|
149
|
+
this._index = -1;
|
|
150
|
+
this._width = undefined;
|
|
151
|
+
this._height = undefined;
|
|
152
|
+
|
|
153
|
+
this.dirty = true;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Starts loading an image into the texture atlas.
|
|
158
|
+
* @see {TextureAtlas#addImage}
|
|
159
|
+
* @private
|
|
160
|
+
* @param {string} id An identifier to detect whether the image already exists in the atlas.
|
|
161
|
+
* @param {HTMLImageElement|HTMLCanvasElement|string|Resource|Promise|TextureAtlas.CreateImageCallback} image An image or canvas to add to the texture atlas,
|
|
162
|
+
* or a URL to an Image, or a Promise for an image, or a function that creates an image.
|
|
163
|
+
*/
|
|
164
|
+
BillboardTexture.prototype.loadImage = async function (id, image) {
|
|
165
|
+
if (this._id === id) {
|
|
166
|
+
// This image has already been loaded
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const collection = this._billboardCollection;
|
|
171
|
+
const cache = collection.billboardTextureCache;
|
|
172
|
+
let billboardTexture = cache.get(id);
|
|
173
|
+
if (
|
|
174
|
+
(defined(billboardTexture) &&
|
|
175
|
+
image.loadState === BillboardLoadState.LOADING) ||
|
|
176
|
+
image.loadState === BillboardLoadState.LOADED
|
|
177
|
+
) {
|
|
178
|
+
// Use the cached texture if it is in progress or successful.
|
|
179
|
+
BillboardTexture.clone(billboardTexture, this);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
// Otherwise, load if not yet assigned an image, and try the load again if anything failed during the last billboard creation
|
|
183
|
+
if (!defined(billboardTexture)) {
|
|
184
|
+
billboardTexture = new BillboardTexture(collection);
|
|
185
|
+
cache.set(id, billboardTexture);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
billboardTexture._id = this._id = id;
|
|
189
|
+
billboardTexture._loadState = this._loadState = BillboardLoadState.LOADING;
|
|
190
|
+
billboardTexture._loadError = this._loadError = undefined;
|
|
191
|
+
|
|
192
|
+
let index;
|
|
193
|
+
const atlas = this._billboardCollection.textureAtlas;
|
|
194
|
+
try {
|
|
195
|
+
index = await atlas.addImage(id, image);
|
|
196
|
+
} catch (error) {
|
|
197
|
+
// There was an error loading the image
|
|
198
|
+
billboardTexture._loadState = BillboardLoadState.ERROR;
|
|
199
|
+
billboardTexture._loadError = error;
|
|
200
|
+
|
|
201
|
+
if (this._id !== id) {
|
|
202
|
+
// Another load was initiated and resolved resolved before this one. This operation is cancelled.
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
this._loadState = BillboardLoadState.ERROR;
|
|
207
|
+
this._loadError = error;
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (!defined(index) || index === -1) {
|
|
212
|
+
// Resources destroyed or otherwise
|
|
213
|
+
billboardTexture._loadState = BillboardLoadState.FAILED;
|
|
214
|
+
billboardTexture._index = -1;
|
|
215
|
+
|
|
216
|
+
if (this._id !== id) {
|
|
217
|
+
// Another load was initiated and resolved resolved before this one. This operation is cancelled.
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
this._loadState = BillboardLoadState.FAILED;
|
|
222
|
+
this._index = -1;
|
|
223
|
+
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
billboardTexture._index = index;
|
|
228
|
+
billboardTexture._loadState = BillboardLoadState.LOADED;
|
|
229
|
+
|
|
230
|
+
const rectangle = atlas.rectangles[index];
|
|
231
|
+
billboardTexture._width = rectangle.width;
|
|
232
|
+
billboardTexture._height = rectangle.height;
|
|
233
|
+
|
|
234
|
+
if (this._id !== id) {
|
|
235
|
+
// Another load was initiated and resolved resolved before this one. This operation is cancelled.
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
this._index = index;
|
|
240
|
+
this._loadState = BillboardLoadState.LOADED;
|
|
241
|
+
this._width = rectangle.width;
|
|
242
|
+
this._height = rectangle.height;
|
|
243
|
+
|
|
244
|
+
this.dirty = true;
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Track a reference to a sub-region of an existing image.
|
|
249
|
+
* @see {TextureAtlas#addImageSubRegion}
|
|
250
|
+
* @private
|
|
251
|
+
* @param {string} id An identifier to detect whether the image already exists in the atlas.
|
|
252
|
+
* @param {BoundingRectangle} subRegion An {@link BoundingRectangle} defining a region of an existing image, measured in pixels from the bottom-left of the image.
|
|
253
|
+
*/
|
|
254
|
+
BillboardTexture.prototype.addImageSubRegion = async function (id, subRegion) {
|
|
255
|
+
this._id = id;
|
|
256
|
+
this._loadState = BillboardLoadState.LOADING;
|
|
257
|
+
this._loadError = undefined;
|
|
258
|
+
this._hasSubregion = true;
|
|
259
|
+
|
|
260
|
+
let index;
|
|
261
|
+
const atlas = this._billboardCollection.textureAtlas;
|
|
262
|
+
try {
|
|
263
|
+
index = await atlas.addImageSubRegion(id, subRegion);
|
|
264
|
+
} catch (error) {
|
|
265
|
+
// There was an error loading the referenced image
|
|
266
|
+
this._loadState = BillboardLoadState.ERROR;
|
|
267
|
+
this._loadError = error;
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (!defined(index) || index === -1) {
|
|
272
|
+
this._loadState = BillboardLoadState.FAILED;
|
|
273
|
+
this._index = -1;
|
|
274
|
+
this._width = undefined;
|
|
275
|
+
this._height = undefined;
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
this._width = subRegion.width;
|
|
280
|
+
this._height = subRegion.height;
|
|
281
|
+
|
|
282
|
+
this._index = index;
|
|
283
|
+
this._loadState = BillboardLoadState.LOADED;
|
|
284
|
+
|
|
285
|
+
this.dirty = true;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Get the texture coordinates for reading the loaded texture in shaders.
|
|
290
|
+
* @private
|
|
291
|
+
* @param {BoundingRectangle} [result] The modified result parameter or a new BoundingRectangle instance if one was not provided.
|
|
292
|
+
* @return {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided.
|
|
293
|
+
*/
|
|
294
|
+
BillboardTexture.prototype.computeTextureCoordinates = function (result) {
|
|
295
|
+
const atlas = this._billboardCollection.textureAtlas;
|
|
296
|
+
return atlas.computeTextureCoordinates(this._index, result);
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Clones an existing billboard texture, inlcuding any in-flight tracking, into the target billboard texture.
|
|
301
|
+
* @param {BillboardTexture} billboardTexture
|
|
302
|
+
* @param {BillboardTexture} target
|
|
303
|
+
* @returns {BillboardTexture} target
|
|
304
|
+
*/
|
|
305
|
+
BillboardTexture.clone = function (billboardTexture, target) {
|
|
306
|
+
target._id = billboardTexture._id;
|
|
307
|
+
target._loadState = billboardTexture._loadState;
|
|
308
|
+
target._loadError = undefined;
|
|
309
|
+
target._index = billboardTexture._index;
|
|
310
|
+
target._width = billboardTexture._width;
|
|
311
|
+
target._height = billboardTexture._height;
|
|
312
|
+
target._hasSubregion = billboardTexture._hasSubregion;
|
|
313
|
+
|
|
314
|
+
if (billboardTexture.ready) {
|
|
315
|
+
target.dirty = true;
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const completeLoad = async () => {
|
|
320
|
+
const id = billboardTexture._id;
|
|
321
|
+
const atlas = billboardTexture._billboardCollection.textureAtlas;
|
|
322
|
+
await atlas._indexPromiseById.get(id);
|
|
323
|
+
|
|
324
|
+
// Any errors should have already been handled
|
|
325
|
+
if (target._id !== id) {
|
|
326
|
+
// Another load was initiated and resolved resolved before this one. This operation is cancelled.
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (billboardTexture._hasSubregion) {
|
|
331
|
+
// Subregions must wait an additional frame to be ready
|
|
332
|
+
await Promise.resolve();
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
target._id = id;
|
|
336
|
+
target._loadState = billboardTexture._loadState;
|
|
337
|
+
target._loadError = billboardTexture._loadError;
|
|
338
|
+
target._index = billboardTexture._index;
|
|
339
|
+
target._width = billboardTexture._width;
|
|
340
|
+
target._height = billboardTexture._height;
|
|
341
|
+
target.dirty = true;
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
completeLoad();
|
|
345
|
+
return target;
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
export default BillboardTexture;
|
package/Source/Scene/Camera.js
CHANGED
|
@@ -3270,7 +3270,7 @@ const newOptions = {
|
|
|
3270
3270
|
|
|
3271
3271
|
/**
|
|
3272
3272
|
* Cancels the current camera flight and leaves the camera at its current location.
|
|
3273
|
-
* If no flight is in progress, this
|
|
3273
|
+
* If no flight is in progress, this function does nothing.
|
|
3274
3274
|
*/
|
|
3275
3275
|
Camera.prototype.cancelFlight = function () {
|
|
3276
3276
|
if (defined(this._currentFlight)) {
|
|
@@ -3281,7 +3281,7 @@ Camera.prototype.cancelFlight = function () {
|
|
|
3281
3281
|
|
|
3282
3282
|
/**
|
|
3283
3283
|
* Completes the current camera flight and moves the camera immediately to its final destination.
|
|
3284
|
-
* If no flight is in progress, this
|
|
3284
|
+
* If no flight is in progress, this function does nothing.
|
|
3285
3285
|
*/
|
|
3286
3286
|
Camera.prototype.completeFlight = function () {
|
|
3287
3287
|
if (defined(this._currentFlight)) {
|