@cesium/engine 1.0.0 → 1.1.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/{AttributeCompression-4589338a.js → AttributeCompression-b646d393.js} +1 -1
- package/Build/Workers/{AxisAlignedBoundingBox-bfb1234f.js → AxisAlignedBoundingBox-a4321399.js} +1 -1
- package/Build/Workers/{BoundingRectangle-7ffc2153.js → BoundingRectangle-80d8801f.js} +1 -1
- package/Build/Workers/{BoxGeometry-93f344a3.js → BoxGeometry-33c10a4f.js} +1 -1
- package/Build/Workers/{Color-0c5aaf47.js → Color-1bf9a6e0.js} +1 -1
- package/Build/Workers/{CoplanarPolygonGeometryLibrary-6597982a.js → CoplanarPolygonGeometryLibrary-5c5b981b.js} +1 -1
- package/Build/Workers/{CorridorGeometryLibrary-2119580e.js → CorridorGeometryLibrary-7cbae7a0.js} +1 -1
- package/Build/Workers/{CylinderGeometry-f9503c6d.js → CylinderGeometry-42740df0.js} +1 -1
- package/Build/Workers/{EllipseGeometry-fedf72d5.js → EllipseGeometry-49a3ac21.js} +1 -1
- package/Build/Workers/{EllipseGeometryLibrary-4ea68687.js → EllipseGeometryLibrary-b891b2f8.js} +1 -1
- package/Build/Workers/{EllipseOutlineGeometry-e2ae6a35.js → EllipseOutlineGeometry-fbd72e07.js} +1 -1
- package/Build/Workers/{EllipsoidGeodesic-16de63ea.js → EllipsoidGeodesic-98c62a56.js} +1 -1
- package/Build/Workers/{EllipsoidGeometry-95c0330e.js → EllipsoidGeometry-a351dba8.js} +1 -1
- package/Build/Workers/{EllipsoidOutlineGeometry-d6d2ceec.js → EllipsoidOutlineGeometry-3e8779bf.js} +1 -1
- package/Build/Workers/{EllipsoidRhumbLine-ae5e65e0.js → EllipsoidRhumbLine-19756602.js} +1 -1
- package/Build/Workers/{EllipsoidTangentPlane-bfc674bf.js → EllipsoidTangentPlane-cfb50678.js} +1 -1
- package/Build/Workers/{EncodedCartesian3-f473ea18.js → EncodedCartesian3-81f70735.js} +1 -1
- package/Build/Workers/{FrustumGeometry-3bf2e4eb.js → FrustumGeometry-c5754412.js} +1 -1
- package/Build/Workers/{GeometryAttribute-df5f473e.js → GeometryAttribute-0bfd05e8.js} +1 -1
- package/Build/Workers/{GeometryInstance-aa75b4cf.js → GeometryInstance-451dc1cd.js} +1 -1
- package/Build/Workers/{GeometryPipeline-f0e46c42.js → GeometryPipeline-0166905d.js} +1 -1
- package/Build/Workers/{IntersectionTests-9de29d51.js → IntersectionTests-a93d3de9.js} +1 -1
- package/Build/Workers/{Matrix2-ce637455.js → Matrix2-13178034.js} +4 -2
- package/Build/Workers/{Matrix3-4f4df527.js → Matrix3-315394f6.js} +2 -1
- package/Build/Workers/{OrientedBoundingBox-d3ff3d4d.js → OrientedBoundingBox-b450cb61.js} +5 -5
- package/Build/Workers/{Plane-b81241c2.js → Plane-900aa728.js} +1 -1
- package/Build/Workers/{PolygonGeometryLibrary-6f4937bb.js → PolygonGeometryLibrary-f918ac26.js} +1 -1
- package/Build/Workers/PolygonPipeline-f59a8f0a.js +1345 -0
- package/Build/Workers/{PolylinePipeline-2e2b015c.js → PolylinePipeline-d8e6bd9b.js} +1 -1
- package/Build/Workers/{PolylineVolumeGeometryLibrary-7ee1d449.js → PolylineVolumeGeometryLibrary-125d2edf.js} +1 -1
- package/Build/Workers/{PrimitivePipeline-a9b7aae0.js → PrimitivePipeline-0d7b5ed4.js} +1 -1
- package/Build/Workers/{RectangleGeometryLibrary-9aa6c8f6.js → RectangleGeometryLibrary-0768db63.js} +1 -1
- package/Build/Workers/{TerrainEncoding-b52dcfc5.js → TerrainEncoding-06470d7f.js} +1 -1
- package/Build/Workers/{Transforms-2f755df8.js → Transforms-26539bce.js} +97 -83
- package/Build/Workers/{WallGeometryLibrary-ab19a93d.js → WallGeometryLibrary-6167b0fc.js} +1 -1
- package/Build/Workers/{WebMercatorProjection-9f25de49.js → WebMercatorProjection-13a90d41.js} +1 -1
- package/Build/Workers/cesiumWorkerBootstrapper.js +25 -1
- package/Build/Workers/combineGeometry.js +1 -1
- package/Build/Workers/createBoxGeometry.js +1 -1
- package/Build/Workers/createBoxOutlineGeometry.js +1 -1
- package/Build/Workers/createCircleGeometry.js +1 -1
- package/Build/Workers/createCircleOutlineGeometry.js +1 -1
- package/Build/Workers/createCoplanarPolygonGeometry.js +1 -1
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +1 -1
- package/Build/Workers/createCorridorGeometry.js +1 -1
- package/Build/Workers/createCorridorOutlineGeometry.js +1 -1
- package/Build/Workers/createCylinderGeometry.js +1 -1
- package/Build/Workers/createCylinderOutlineGeometry.js +1 -1
- package/Build/Workers/createEllipseGeometry.js +1 -1
- package/Build/Workers/createEllipseOutlineGeometry.js +1 -1
- package/Build/Workers/createEllipsoidGeometry.js +1 -1
- package/Build/Workers/createEllipsoidOutlineGeometry.js +1 -1
- package/Build/Workers/createFrustumGeometry.js +1 -1
- package/Build/Workers/createFrustumOutlineGeometry.js +1 -1
- package/Build/Workers/createGeometry.js +1 -1
- package/Build/Workers/createGroundPolylineGeometry.js +1 -1
- package/Build/Workers/createPlaneGeometry.js +1 -1
- package/Build/Workers/createPlaneOutlineGeometry.js +1 -1
- package/Build/Workers/createPolygonGeometry.js +1 -1
- package/Build/Workers/createPolygonOutlineGeometry.js +1 -1
- package/Build/Workers/createPolylineGeometry.js +1 -1
- package/Build/Workers/createPolylineVolumeGeometry.js +1 -1
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +1 -1
- package/Build/Workers/createRectangleGeometry.js +1 -1
- package/Build/Workers/createRectangleOutlineGeometry.js +1 -1
- package/Build/Workers/createSimplePolylineGeometry.js +1 -1
- package/Build/Workers/createSphereGeometry.js +1 -1
- package/Build/Workers/createSphereOutlineGeometry.js +1 -1
- package/Build/Workers/createVectorTileClampedPolylines.js +1 -1
- package/Build/Workers/createVectorTileGeometries.js +1 -1
- package/Build/Workers/createVectorTilePoints.js +1 -1
- package/Build/Workers/createVectorTilePolygons.js +1 -1
- package/Build/Workers/createVectorTilePolylines.js +1 -1
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +1 -1
- package/Build/Workers/createVerticesFromHeightmap.js +7 -3
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +1 -1
- package/Build/Workers/createWallGeometry.js +1 -1
- package/Build/Workers/createWallOutlineGeometry.js +1 -1
- package/Build/Workers/decodeI3S.js +1 -1
- package/Build/Workers/package.js +25 -1
- package/Build/Workers/transferTypedArrayTest.js +25 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +1 -1
- package/Source/Core/EarthOrientationParameters.js +67 -63
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/Matrix2.js +2 -1
- package/Source/Core/Matrix3.js +2 -1
- package/Source/Core/Matrix4.js +1 -0
- package/Source/Core/OrientedBoundingBox.js +4 -4
- package/Source/Core/S2Cell.js +3 -3
- package/Source/Core/Transforms.js +3 -7
- package/Source/DataSources/GpxDataSource.js +4 -6
- package/Source/DataSources/KmlDataSource.js +3 -5
- package/Source/Renderer/Context.js +27 -9
- package/Source/Renderer/Pass.js +3 -2
- package/Source/Scene/Cesium3DTileContentType.js +19 -0
- package/Source/Scene/Cesium3DTilesVoxelProvider.js +482 -0
- package/Source/Scene/Cesium3DTilesetMetadata.js +2 -2
- package/Source/Scene/ContentMetadata.js +2 -2
- package/Source/Scene/DerivedCommand.js +7 -0
- package/Source/Scene/Expression.js +1 -1
- package/Source/Scene/Globe.js +10 -0
- package/Source/Scene/GlobeSurfaceTileProvider.js +7 -0
- package/Source/Scene/GltfImageLoader.js +1 -1
- package/Source/Scene/GltfVertexBufferLoader.js +10 -2
- package/Source/Scene/GroupMetadata.js +2 -2
- package/Source/Scene/ImplicitMetadataView.js +2 -2
- package/Source/Scene/ImplicitSubtreeCache.js +127 -0
- package/Source/Scene/ImplicitSubtreeMetadata.js +2 -2
- package/Source/Scene/ImplicitTileset.js +3 -2
- package/Source/Scene/KeyframeNode.js +47 -0
- package/Source/Scene/Megatexture.js +490 -0
- package/Source/Scene/MetadataClass.js +60 -25
- package/Source/Scene/MetadataClassProperty.js +132 -68
- package/Source/Scene/MetadataComponentType.js +78 -57
- package/Source/Scene/MetadataEnum.js +59 -23
- package/Source/Scene/MetadataEnumValue.js +49 -15
- package/Source/Scene/MetadataSchema.js +53 -24
- package/Source/Scene/MetadataSchemaLoader.js +2 -2
- package/Source/Scene/MetadataTableProperty.js +2 -2
- package/Source/Scene/MetadataType.js +6 -14
- package/Source/Scene/Model/GeoJsonLoader.js +1 -1
- package/Source/Scene/Model/Model.js +2 -3
- package/Source/Scene/Model/buildDrawCommand.js +19 -11
- package/Source/Scene/PointCloud.js +1 -1
- package/Source/Scene/PropertyAttribute.js +2 -2
- package/Source/Scene/PropertyAttributeProperty.js +2 -2
- package/Source/Scene/PropertyTable.js +2 -2
- package/Source/Scene/PropertyTexture.js +2 -2
- package/Source/Scene/PropertyTextureProperty.js +2 -2
- package/Source/Scene/ResourceCache.js +9 -1
- package/Source/Scene/ResourceCacheKey.js +9 -1
- package/Source/Scene/Scene.js +17 -0
- package/Source/Scene/SpatialNode.js +375 -0
- package/Source/Scene/StructuralMetadata.js +2 -2
- package/Source/Scene/TileMetadata.js +2 -2
- package/Source/Scene/TilesetMetadata.js +2 -2
- package/Source/Scene/VoxelBoxShape.js +527 -0
- package/Source/Scene/VoxelContent.js +169 -0
- package/Source/Scene/VoxelCylinderShape.js +937 -0
- package/Source/Scene/VoxelEllipsoidShape.js +937 -0
- package/Source/Scene/VoxelPrimitive.js +1919 -0
- package/Source/Scene/VoxelProvider.js +255 -0
- package/Source/Scene/VoxelRenderResources.js +224 -0
- package/Source/Scene/VoxelShape.js +152 -0
- package/Source/Scene/VoxelShapeType.js +105 -0
- package/Source/Scene/VoxelTraversal.js +1144 -0
- package/Source/Scene/buildVoxelDrawCommands.js +116 -0
- package/Source/Scene/parseBatchTable.js +18 -2
- package/Source/Scene/preprocess3DTileContent.js +8 -0
- package/Source/Scene/processVoxelProperties.js +455 -0
- package/Source/Shaders/BillboardCollectionVS.glsl +1 -1
- package/Source/Shaders/BillboardCollectionVS.js +1 -1
- package/Source/Shaders/Builtin/Constants/passOverlay.glsl +1 -1
- package/Source/Shaders/Builtin/Constants/passOverlay.js +1 -1
- package/Source/Shaders/Builtin/Constants/passVoxels.glsl +9 -0
- package/Source/Shaders/Builtin/Constants/passVoxels.js +11 -0
- package/Source/Shaders/Builtin/CzmBuiltins.js +17 -15
- package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.glsl +55 -43
- package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.js +55 -43
- package/Source/Shaders/GlobeFS.glsl +2 -1
- package/Source/Shaders/GlobeFS.js +2 -1
- package/Source/Shaders/PointPrimitiveCollectionVS.glsl +5 -2
- package/Source/Shaders/PointPrimitiveCollectionVS.js +5 -2
- package/Source/Shaders/Voxels/IntersectBox.glsl +79 -0
- package/Source/Shaders/Voxels/IntersectBox.js +81 -0
- package/Source/Shaders/Voxels/IntersectClippingPlanes.glsl +70 -0
- package/Source/Shaders/Voxels/IntersectClippingPlanes.js +72 -0
- package/Source/Shaders/Voxels/IntersectCylinder.glsl +273 -0
- package/Source/Shaders/Voxels/IntersectCylinder.js +275 -0
- package/Source/Shaders/Voxels/IntersectDepth.glsl +23 -0
- package/Source/Shaders/Voxels/IntersectDepth.js +25 -0
- package/Source/Shaders/Voxels/IntersectEllipsoid.glsl +337 -0
- package/Source/Shaders/Voxels/IntersectEllipsoid.js +339 -0
- package/Source/Shaders/Voxels/Intersection.glsl +54 -0
- package/Source/Shaders/Voxels/Intersection.js +56 -0
- package/Source/Shaders/Voxels/IntersectionUtils.glsl +151 -0
- package/Source/Shaders/Voxels/IntersectionUtils.js +153 -0
- package/Source/Shaders/Voxels/Megatexture.glsl +136 -0
- package/Source/Shaders/Voxels/Megatexture.js +138 -0
- package/Source/Shaders/Voxels/Octree.glsl +221 -0
- package/Source/Shaders/Voxels/Octree.js +223 -0
- package/Source/Shaders/Voxels/VoxelFS.glsl +150 -0
- package/Source/Shaders/Voxels/VoxelFS.js +152 -0
- package/Source/Shaders/Voxels/VoxelVS.glsl +11 -0
- package/Source/Shaders/Voxels/VoxelVS.js +13 -0
- package/Source/Shaders/Voxels/convertUvToBox.glsl +16 -0
- package/Source/Shaders/Voxels/convertUvToBox.js +18 -0
- package/Source/Shaders/Voxels/convertUvToCylinder.glsl +79 -0
- package/Source/Shaders/Voxels/convertUvToCylinder.js +81 -0
- package/Source/Shaders/Voxels/convertUvToEllipsoid.glsl +133 -0
- package/Source/Shaders/Voxels/convertUvToEllipsoid.js +135 -0
- package/Source/ThirdParty/Workers/z-worker-pako.js +0 -0
- package/index.d.ts +3124 -2287
- package/index.js +1117 -1085
- package/package.json +3 -4
- package/Build/Workers/PolygonPipeline-774a8aaf.js +0 -1341
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import defaultValue from "../Core/defaultValue.js";
|
|
2
|
+
import DeveloperError from "../Core/DeveloperError.js";
|
|
3
|
+
import DoubleEndedPriorityQueue from "../Core/DoubleEndedPriorityQueue.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @alias ImplicitSubtreeCache
|
|
7
|
+
* @constructor
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} [options] Object with the following properties
|
|
10
|
+
* @param {Number} [options.maximumSubtreeCount=0] The total number of subtrees this cache can store. If adding a new subtree would exceed this limit, the lowest priority subtrees will be removed until there is room, unless the subtree that is going to be removed is the parent of the new subtree, in which case it will not be removed and the new subtree will still be added, exceeding the memory limit.
|
|
11
|
+
*
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
function ImplicitSubtreeCache(options) {
|
|
15
|
+
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @type {Number}
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
this._maximumSubtreeCount = defaultValue(options.maximumSubtreeCount, 0);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A counter that goes up whenever a subtree is added. Used to sort subtrees by recency.
|
|
25
|
+
* @type {Number}
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
28
|
+
this._subtreeRequestCounter = 0;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @type {DoubleEndedPriorityQueue}
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
this._queue = new DoubleEndedPriorityQueue({
|
|
35
|
+
comparator: ImplicitSubtreeCache.comparator,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param {ImplicitSubtree} subtree
|
|
41
|
+
*/
|
|
42
|
+
ImplicitSubtreeCache.prototype.addSubtree = function (subtree) {
|
|
43
|
+
const cacheNode = new ImplicitSubtreeCacheNode(
|
|
44
|
+
subtree,
|
|
45
|
+
this._subtreeRequestCounter
|
|
46
|
+
);
|
|
47
|
+
this._subtreeRequestCounter++;
|
|
48
|
+
this._queue.insert(cacheNode);
|
|
49
|
+
|
|
50
|
+
// Make sure the parent subtree exists in the cache
|
|
51
|
+
const subtreeCoord = subtree.implicitCoordinates;
|
|
52
|
+
if (subtreeCoord.level > 0) {
|
|
53
|
+
const parentCoord = subtreeCoord.getParentSubtreeCoordinates();
|
|
54
|
+
const parentNode = this.find(parentCoord);
|
|
55
|
+
|
|
56
|
+
//>>includeStart('debug', pragmas.debug)
|
|
57
|
+
if (parentNode === undefined) {
|
|
58
|
+
throw new DeveloperError("parent node needs to exist");
|
|
59
|
+
}
|
|
60
|
+
//>>includeEnd('debug');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (this._maximumSubtreeCount > 0) {
|
|
64
|
+
while (this._queue.length > this._maximumSubtreeCount) {
|
|
65
|
+
const lowestPriorityNode = this._queue.getMinimum();
|
|
66
|
+
if (lowestPriorityNode === cacheNode) {
|
|
67
|
+
// Don't remove itself
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this._queue.removeMinimum();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @param {ImplicitTileCoordinates} subtreeCoord
|
|
78
|
+
* @returns {ImplicitSubtree|undefined}
|
|
79
|
+
*/
|
|
80
|
+
ImplicitSubtreeCache.prototype.find = function (subtreeCoord) {
|
|
81
|
+
const queue = this._queue;
|
|
82
|
+
const array = queue.internalArray;
|
|
83
|
+
const arrayLength = queue.length;
|
|
84
|
+
|
|
85
|
+
for (let i = 0; i < arrayLength; i++) {
|
|
86
|
+
const other = array[i];
|
|
87
|
+
const otherSubtree = other.subtree;
|
|
88
|
+
const otherCoord = otherSubtree.implicitCoordinates;
|
|
89
|
+
if (subtreeCoord.isEqual(otherCoord)) {
|
|
90
|
+
return other.subtree;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return undefined;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @param {ImplicitSubtreeCacheNode} a
|
|
98
|
+
* @param {ImplicitSubtreeCacheNode} b
|
|
99
|
+
* @returns {Number}
|
|
100
|
+
*/
|
|
101
|
+
ImplicitSubtreeCache.comparator = function (a, b) {
|
|
102
|
+
const aCoord = a.subtree.implicitCoordinates;
|
|
103
|
+
const bCoord = b.subtree.implicitCoordinates;
|
|
104
|
+
if (aCoord.isAncestor(bCoord)) {
|
|
105
|
+
// Technically this shouldn't happen because the ancestor subtree was supposed to be added to the cache first.
|
|
106
|
+
return +1.0;
|
|
107
|
+
} else if (bCoord.isAncestor(aCoord)) {
|
|
108
|
+
return -1.0;
|
|
109
|
+
}
|
|
110
|
+
return a.stamp - b.stamp;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @alias ImplicitSubtreeCacheNode
|
|
115
|
+
* @constructor
|
|
116
|
+
*
|
|
117
|
+
* @param {ImplicitSubtree} subtree
|
|
118
|
+
* @param {Number} stamp
|
|
119
|
+
*
|
|
120
|
+
* @private
|
|
121
|
+
*/
|
|
122
|
+
function ImplicitSubtreeCacheNode(subtree, stamp) {
|
|
123
|
+
this.subtree = subtree;
|
|
124
|
+
this.stamp = stamp;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export default ImplicitSubtreeCache;
|
|
@@ -54,7 +54,7 @@ Object.defineProperties(ImplicitSubtreeMetadata.prototype, {
|
|
|
54
54
|
},
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* Extra user-defined properties.
|
|
58
58
|
*
|
|
59
59
|
* @memberof ImplicitSubtreeMetadata.prototype
|
|
60
60
|
* @type {Object}
|
|
@@ -68,7 +68,7 @@ Object.defineProperties(ImplicitSubtreeMetadata.prototype, {
|
|
|
68
68
|
},
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
|
-
*
|
|
71
|
+
* An object containing extensions.
|
|
72
72
|
*
|
|
73
73
|
* @memberof ImplicitSubtreeMetadata.prototype
|
|
74
74
|
* @type {Object}
|
|
@@ -64,10 +64,11 @@ function ImplicitTileset(baseResource, tileJson, metadataSchema) {
|
|
|
64
64
|
if (
|
|
65
65
|
!defined(boundingVolume.box) &&
|
|
66
66
|
!defined(boundingVolume.region) &&
|
|
67
|
-
!hasExtension(boundingVolume, "3DTILES_bounding_volume_S2")
|
|
67
|
+
!hasExtension(boundingVolume, "3DTILES_bounding_volume_S2") &&
|
|
68
|
+
!hasExtension(boundingVolume, "3DTILES_bounding_volume_cylinder")
|
|
68
69
|
) {
|
|
69
70
|
throw new RuntimeError(
|
|
70
|
-
"Only box, region and
|
|
71
|
+
"Only box, region, 3DTILES_bounding_volume_S2, and 3DTILES_bounding_volume_cylinder are supported for implicit tiling"
|
|
71
72
|
);
|
|
72
73
|
}
|
|
73
74
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const LoadState = Object.freeze({
|
|
2
|
+
UNLOADED: 0, // Has no data and is in dormant state
|
|
3
|
+
RECEIVING: 1, // Is waiting on data from the provider
|
|
4
|
+
RECEIVED: 2, // Received data from the provider
|
|
5
|
+
LOADED: 3, // Processed data from provider
|
|
6
|
+
FAILED: 4, // Failed to receive data from the provider
|
|
7
|
+
UNAVAILABLE: 5, // No data available for this tile
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @alias KeyframeNode
|
|
12
|
+
* @constructor
|
|
13
|
+
*
|
|
14
|
+
* @param {SpatialNode} spatialNode
|
|
15
|
+
* @param {Number} keyframe
|
|
16
|
+
*
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
function KeyframeNode(spatialNode, keyframe) {
|
|
20
|
+
this.spatialNode = spatialNode;
|
|
21
|
+
this.keyframe = keyframe;
|
|
22
|
+
this.state = LoadState.UNLOADED;
|
|
23
|
+
this.metadatas = [];
|
|
24
|
+
this.megatextureIndex = -1;
|
|
25
|
+
this.priority = -Number.MAX_VALUE;
|
|
26
|
+
this.highPriorityFrameNumber = -1;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {KeyframeNode} a
|
|
31
|
+
* @param {KeyframeNode} b
|
|
32
|
+
*/
|
|
33
|
+
KeyframeNode.priorityComparator = function (a, b) {
|
|
34
|
+
return a.priority - b.priority;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @param {KeyframeNode} a
|
|
39
|
+
* @param {KeyframeNode} b
|
|
40
|
+
*/
|
|
41
|
+
KeyframeNode.searchComparator = function (a, b) {
|
|
42
|
+
return a.keyframe - b.keyframe;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
KeyframeNode.LoadState = LoadState;
|
|
46
|
+
|
|
47
|
+
export default KeyframeNode;
|
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
import Cartesian2 from "../Core/Cartesian2.js";
|
|
2
|
+
import Cartesian3 from "../Core/Cartesian3.js";
|
|
3
|
+
import ComponentDatatype from "../Core/ComponentDatatype.js";
|
|
4
|
+
import ContextLimits from "../Renderer/ContextLimits.js";
|
|
5
|
+
import defaultValue from "../Core/defaultValue.js";
|
|
6
|
+
import defined from "../Core/defined.js";
|
|
7
|
+
import destroyObject from "../Core/destroyObject.js";
|
|
8
|
+
import DeveloperError from "../Core/DeveloperError.js";
|
|
9
|
+
import CesiumMath from "../Core/Math.js";
|
|
10
|
+
import MetadataComponentType from "./MetadataComponentType.js";
|
|
11
|
+
import PixelDatatype from "../Renderer/PixelDatatype.js";
|
|
12
|
+
import PixelFormat from "../Core/PixelFormat.js";
|
|
13
|
+
import RuntimeError from "../Core/RuntimeError.js";
|
|
14
|
+
import Sampler from "../Renderer/Sampler.js";
|
|
15
|
+
import Texture from "../Renderer/Texture.js";
|
|
16
|
+
import TextureMagnificationFilter from "../Renderer/TextureMagnificationFilter.js";
|
|
17
|
+
import TextureMinificationFilter from "../Renderer/TextureMinificationFilter.js";
|
|
18
|
+
import TextureWrap from "../Renderer/TextureWrap.js";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @alias Megatexture
|
|
22
|
+
* @constructor
|
|
23
|
+
*
|
|
24
|
+
* @param {Context} context
|
|
25
|
+
* @param {Cartesian3} dimensions
|
|
26
|
+
* @param {Number} channelCount
|
|
27
|
+
* @param {MetadataComponentType} componentType
|
|
28
|
+
* @param {Number} [textureMemoryByteLength]
|
|
29
|
+
*
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
function Megatexture(
|
|
33
|
+
context,
|
|
34
|
+
dimensions,
|
|
35
|
+
channelCount,
|
|
36
|
+
componentType,
|
|
37
|
+
textureMemoryByteLength
|
|
38
|
+
) {
|
|
39
|
+
// TODO there are a lot of texture packing rules, see https://github.com/CesiumGS/cesium/issues/9572
|
|
40
|
+
// Unsigned short textures not allowed in webgl 1, so treat as float
|
|
41
|
+
if (componentType === MetadataComponentType.UNSIGNED_SHORT) {
|
|
42
|
+
componentType = MetadataComponentType.FLOAT32;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const supportsFloatingPointTexture = context.floatingPointTexture;
|
|
46
|
+
if (
|
|
47
|
+
componentType === MetadataComponentType.FLOAT32 &&
|
|
48
|
+
!supportsFloatingPointTexture
|
|
49
|
+
) {
|
|
50
|
+
throw new RuntimeError("Floating point texture not supported");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// TODO support more
|
|
54
|
+
let pixelType;
|
|
55
|
+
if (
|
|
56
|
+
componentType === MetadataComponentType.FLOAT32 ||
|
|
57
|
+
componentType === MetadataComponentType.FLOAT64
|
|
58
|
+
) {
|
|
59
|
+
pixelType = PixelDatatype.FLOAT;
|
|
60
|
+
} else if (componentType === MetadataComponentType.UINT8) {
|
|
61
|
+
pixelType = PixelDatatype.UNSIGNED_BYTE;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let pixelFormat;
|
|
65
|
+
if (channelCount === 1) {
|
|
66
|
+
pixelFormat = PixelFormat.LUMINANCE;
|
|
67
|
+
} else if (channelCount === 2) {
|
|
68
|
+
pixelFormat = PixelFormat.LUMINANCE_ALPHA;
|
|
69
|
+
} else if (channelCount === 3) {
|
|
70
|
+
pixelFormat = PixelFormat.RGB;
|
|
71
|
+
} else if (channelCount === 4) {
|
|
72
|
+
pixelFormat = PixelFormat.RGBA;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const maximumTextureMemoryByteLength = 512 * 1024 * 1024;
|
|
76
|
+
const defaultTextureMemoryByteLength = 128 * 1024 * 1024;
|
|
77
|
+
textureMemoryByteLength = Math.min(
|
|
78
|
+
defaultValue(textureMemoryByteLength, defaultTextureMemoryByteLength),
|
|
79
|
+
maximumTextureMemoryByteLength
|
|
80
|
+
);
|
|
81
|
+
const maximumTextureDimensionContext = ContextLimits.maximumTextureSize;
|
|
82
|
+
const componentTypeByteLength = MetadataComponentType.getSizeInBytes(
|
|
83
|
+
componentType
|
|
84
|
+
);
|
|
85
|
+
const texelCount = Math.floor(
|
|
86
|
+
textureMemoryByteLength / (channelCount * componentTypeByteLength)
|
|
87
|
+
);
|
|
88
|
+
const textureDimension = Math.min(
|
|
89
|
+
maximumTextureDimensionContext,
|
|
90
|
+
CesiumMath.previousPowerOfTwo(Math.floor(Math.sqrt(texelCount)))
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const sliceCountPerRegionX = Math.ceil(Math.sqrt(dimensions.x));
|
|
94
|
+
const sliceCountPerRegionY = Math.ceil(dimensions.z / sliceCountPerRegionX);
|
|
95
|
+
const voxelCountPerRegionX = sliceCountPerRegionX * dimensions.x;
|
|
96
|
+
const voxelCountPerRegionY = sliceCountPerRegionY * dimensions.y;
|
|
97
|
+
const regionCountPerMegatextureX = Math.floor(
|
|
98
|
+
textureDimension / voxelCountPerRegionX
|
|
99
|
+
);
|
|
100
|
+
const regionCountPerMegatextureY = Math.floor(
|
|
101
|
+
textureDimension / voxelCountPerRegionY
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
if (regionCountPerMegatextureX === 0 || regionCountPerMegatextureY === 0) {
|
|
105
|
+
throw new RuntimeError("Tileset is too large to fit into megatexture");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @type {Number}
|
|
110
|
+
* @readonly
|
|
111
|
+
*/
|
|
112
|
+
this.channelCount = channelCount;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @type {MetadataComponentType}
|
|
116
|
+
* @readonly
|
|
117
|
+
*/
|
|
118
|
+
this.componentType = componentType;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @type {Cartesian3}
|
|
122
|
+
* @readonly
|
|
123
|
+
*/
|
|
124
|
+
this.voxelCountPerTile = Cartesian3.clone(dimensions, new Cartesian3());
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @type {Number}
|
|
128
|
+
* @readonly
|
|
129
|
+
*/
|
|
130
|
+
this.maximumTileCount =
|
|
131
|
+
regionCountPerMegatextureX * regionCountPerMegatextureY;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @type {Cartesian2}
|
|
135
|
+
* @readonly
|
|
136
|
+
*/
|
|
137
|
+
this.regionCountPerMegatexture = new Cartesian2(
|
|
138
|
+
regionCountPerMegatextureX,
|
|
139
|
+
regionCountPerMegatextureY
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @type {Cartesian2}
|
|
144
|
+
* @readonly
|
|
145
|
+
*/
|
|
146
|
+
this.voxelCountPerRegion = new Cartesian2(
|
|
147
|
+
voxelCountPerRegionX,
|
|
148
|
+
voxelCountPerRegionY
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @type {Cartesian2}
|
|
153
|
+
* @readonly
|
|
154
|
+
*/
|
|
155
|
+
this.sliceCountPerRegion = new Cartesian2(
|
|
156
|
+
sliceCountPerRegionX,
|
|
157
|
+
sliceCountPerRegionY
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @type {Cartesian2}
|
|
162
|
+
* @readonly
|
|
163
|
+
*/
|
|
164
|
+
this.voxelSizeUv = new Cartesian2(
|
|
165
|
+
1.0 / textureDimension,
|
|
166
|
+
1.0 / textureDimension
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @type {Cartesian2}
|
|
171
|
+
* @readonly
|
|
172
|
+
*/
|
|
173
|
+
this.sliceSizeUv = new Cartesian2(
|
|
174
|
+
dimensions.x / textureDimension,
|
|
175
|
+
dimensions.y / textureDimension
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* @type {Cartesian2}
|
|
180
|
+
* @readonly
|
|
181
|
+
*/
|
|
182
|
+
this.regionSizeUv = new Cartesian2(
|
|
183
|
+
voxelCountPerRegionX / textureDimension,
|
|
184
|
+
voxelCountPerRegionY / textureDimension
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @type {Texture}
|
|
189
|
+
* @readonly
|
|
190
|
+
*/
|
|
191
|
+
this.texture = new Texture({
|
|
192
|
+
context: context,
|
|
193
|
+
pixelFormat: pixelFormat,
|
|
194
|
+
pixelDatatype: pixelType,
|
|
195
|
+
flipY: false,
|
|
196
|
+
width: textureDimension,
|
|
197
|
+
height: textureDimension,
|
|
198
|
+
sampler: new Sampler({
|
|
199
|
+
wrapS: TextureWrap.CLAMP_TO_EDGE,
|
|
200
|
+
wrapT: TextureWrap.CLAMP_TO_EDGE,
|
|
201
|
+
minificationFilter: TextureMinificationFilter.LINEAR,
|
|
202
|
+
magnificationFilter: TextureMagnificationFilter.LINEAR,
|
|
203
|
+
}),
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
const componentDatatype = MetadataComponentType.toComponentDatatype(
|
|
207
|
+
componentType
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* @type {Array}
|
|
212
|
+
*/
|
|
213
|
+
this.tileVoxelDataTemp = ComponentDatatype.createTypedArray(
|
|
214
|
+
componentDatatype,
|
|
215
|
+
voxelCountPerRegionX * voxelCountPerRegionY * channelCount
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* @type {MegatextureNode[]}
|
|
220
|
+
* @readonly
|
|
221
|
+
*/
|
|
222
|
+
this.nodes = new Array(this.maximumTileCount);
|
|
223
|
+
for (let tileIndex = 0; tileIndex < this.maximumTileCount; tileIndex++) {
|
|
224
|
+
this.nodes[tileIndex] = new MegatextureNode(tileIndex);
|
|
225
|
+
}
|
|
226
|
+
for (let tileIndex = 0; tileIndex < this.maximumTileCount; tileIndex++) {
|
|
227
|
+
const node = this.nodes[tileIndex];
|
|
228
|
+
node.previousNode = tileIndex > 0 ? this.nodes[tileIndex - 1] : undefined;
|
|
229
|
+
node.nextNode =
|
|
230
|
+
tileIndex < this.maximumTileCount - 1
|
|
231
|
+
? this.nodes[tileIndex + 1]
|
|
232
|
+
: undefined;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* @type {MegatextureNode}
|
|
237
|
+
* @readonly
|
|
238
|
+
*/
|
|
239
|
+
this.occupiedList = undefined;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* @type {MegatextureNode}
|
|
243
|
+
* @readonly
|
|
244
|
+
*/
|
|
245
|
+
this.emptyList = this.nodes[0];
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @type {Number}
|
|
249
|
+
* @readonly
|
|
250
|
+
*/
|
|
251
|
+
this.occupiedCount = 0;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* @alias MegatextureNode
|
|
256
|
+
* @constructor
|
|
257
|
+
*
|
|
258
|
+
* @param {Number} index
|
|
259
|
+
*
|
|
260
|
+
* @private
|
|
261
|
+
*/
|
|
262
|
+
function MegatextureNode(index) {
|
|
263
|
+
/**
|
|
264
|
+
* @type {Number}
|
|
265
|
+
*/
|
|
266
|
+
this.index = index;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* @type {MegatextureNode}
|
|
270
|
+
*/
|
|
271
|
+
this.nextNode = undefined;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* @type {MegatextureNode}
|
|
275
|
+
*/
|
|
276
|
+
this.previousNode = undefined;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* @param {Array} data
|
|
281
|
+
* @returns {Number}
|
|
282
|
+
*/
|
|
283
|
+
Megatexture.prototype.add = function (data) {
|
|
284
|
+
if (this.isFull()) {
|
|
285
|
+
throw new DeveloperError("Trying to add when there are no empty spots");
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// remove head of empty list
|
|
289
|
+
const node = this.emptyList;
|
|
290
|
+
this.emptyList = this.emptyList.nextNode;
|
|
291
|
+
if (defined(this.emptyList)) {
|
|
292
|
+
this.emptyList.previousNode = undefined;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// make head of occupied list
|
|
296
|
+
node.nextNode = this.occupiedList;
|
|
297
|
+
if (defined(node.nextNode)) {
|
|
298
|
+
node.nextNode.previousNode = node;
|
|
299
|
+
}
|
|
300
|
+
this.occupiedList = node;
|
|
301
|
+
|
|
302
|
+
const index = node.index;
|
|
303
|
+
this.writeDataToTexture(index, data);
|
|
304
|
+
|
|
305
|
+
this.occupiedCount++;
|
|
306
|
+
return index;
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* @param {Number} index
|
|
311
|
+
*/
|
|
312
|
+
Megatexture.prototype.remove = function (index) {
|
|
313
|
+
if (index < 0 || index >= this.maximumTileCount) {
|
|
314
|
+
throw new DeveloperError("Megatexture index out of bounds");
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// remove from list
|
|
318
|
+
const node = this.nodes[index];
|
|
319
|
+
if (defined(node.previousNode)) {
|
|
320
|
+
node.previousNode.nextNode = node.nextNode;
|
|
321
|
+
}
|
|
322
|
+
if (defined(node.nextNode)) {
|
|
323
|
+
node.nextNode.previousNode = node.previousNode;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// make head of empty list
|
|
327
|
+
node.nextNode = this.emptyList;
|
|
328
|
+
if (defined(node.nextNode)) {
|
|
329
|
+
node.nextNode.previousNode = node;
|
|
330
|
+
}
|
|
331
|
+
node.previousNode = undefined;
|
|
332
|
+
this.emptyList = node;
|
|
333
|
+
this.occupiedCount--;
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* @returns {Boolean}
|
|
338
|
+
*/
|
|
339
|
+
Megatexture.prototype.isFull = function () {
|
|
340
|
+
return this.emptyList === undefined;
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* @param {Number} tileCount
|
|
345
|
+
* @param {Cartesian3} dimensions
|
|
346
|
+
* @param {Number} channelCount number of channels in the metadata. Must be 1 to 4.
|
|
347
|
+
* @param {MetadataComponentType} componentType
|
|
348
|
+
* @returns {Number}
|
|
349
|
+
*/
|
|
350
|
+
Megatexture.getApproximateTextureMemoryByteLength = function (
|
|
351
|
+
tileCount,
|
|
352
|
+
dimensions,
|
|
353
|
+
channelCount,
|
|
354
|
+
componentType
|
|
355
|
+
) {
|
|
356
|
+
// TODO there's a lot of code duplicate with Megatexture constructor
|
|
357
|
+
|
|
358
|
+
// Unsigned short textures not allowed in webgl 1, so treat as float
|
|
359
|
+
if (componentType === MetadataComponentType.UNSIGNED_SHORT) {
|
|
360
|
+
componentType = MetadataComponentType.FLOAT32;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const datatypeSizeInBytes = MetadataComponentType.getSizeInBytes(
|
|
364
|
+
componentType
|
|
365
|
+
);
|
|
366
|
+
const voxelCountTotal =
|
|
367
|
+
tileCount * dimensions.x * dimensions.y * dimensions.z;
|
|
368
|
+
|
|
369
|
+
const sliceCountPerRegionX = Math.ceil(Math.sqrt(dimensions.z));
|
|
370
|
+
const sliceCountPerRegionY = Math.ceil(dimensions.z / sliceCountPerRegionX);
|
|
371
|
+
const voxelCountPerRegionX = sliceCountPerRegionX * dimensions.x;
|
|
372
|
+
const voxelCountPerRegionY = sliceCountPerRegionY * dimensions.y;
|
|
373
|
+
|
|
374
|
+
// Find the power of two that can fit all tile data, accounting for slices.
|
|
375
|
+
// There's probably a non-iterative solution for this, but this is good enough for now.
|
|
376
|
+
let textureDimension = CesiumMath.previousPowerOfTwo(
|
|
377
|
+
Math.floor(Math.sqrt(voxelCountTotal))
|
|
378
|
+
);
|
|
379
|
+
for (;;) {
|
|
380
|
+
const regionCountX = Math.floor(textureDimension / voxelCountPerRegionX);
|
|
381
|
+
const regionCountY = Math.floor(textureDimension / voxelCountPerRegionY);
|
|
382
|
+
const regionCount = regionCountX * regionCountY;
|
|
383
|
+
if (regionCount >= tileCount) {
|
|
384
|
+
break;
|
|
385
|
+
} else {
|
|
386
|
+
textureDimension *= 2;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const textureMemoryByteLength =
|
|
391
|
+
textureDimension * textureDimension * channelCount * datatypeSizeInBytes;
|
|
392
|
+
return textureMemoryByteLength;
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* @param {Number} index
|
|
397
|
+
* @param {Float32Array|Uint16Array|Uint8Array} data
|
|
398
|
+
*/
|
|
399
|
+
Megatexture.prototype.writeDataToTexture = function (index, data) {
|
|
400
|
+
// Unsigned short textures not allowed in webgl 1, so treat as float
|
|
401
|
+
const tileData =
|
|
402
|
+
data.constructor === Uint16Array ? new Float32Array(data) : data;
|
|
403
|
+
|
|
404
|
+
const voxelDimensionsPerTile = this.voxelCountPerTile;
|
|
405
|
+
const sliceDimensionsPerRegion = this.sliceCountPerRegion;
|
|
406
|
+
const voxelDimensionsPerRegion = this.voxelCountPerRegion;
|
|
407
|
+
const channelCount = this.channelCount;
|
|
408
|
+
|
|
409
|
+
const tileVoxelData = this.tileVoxelDataTemp;
|
|
410
|
+
for (let z = 0; z < voxelDimensionsPerTile.z; z++) {
|
|
411
|
+
const sliceVoxelOffsetX =
|
|
412
|
+
(z % sliceDimensionsPerRegion.x) * voxelDimensionsPerTile.x;
|
|
413
|
+
const sliceVoxelOffsetY =
|
|
414
|
+
Math.floor(z / sliceDimensionsPerRegion.x) * voxelDimensionsPerTile.y;
|
|
415
|
+
for (let y = 0; y < voxelDimensionsPerTile.y; y++) {
|
|
416
|
+
for (let x = 0; x < voxelDimensionsPerTile.x; x++) {
|
|
417
|
+
const readIndex =
|
|
418
|
+
z * voxelDimensionsPerTile.y * voxelDimensionsPerTile.x +
|
|
419
|
+
y * voxelDimensionsPerTile.x +
|
|
420
|
+
x;
|
|
421
|
+
const writeIndex =
|
|
422
|
+
(sliceVoxelOffsetY + y) * voxelDimensionsPerRegion.x +
|
|
423
|
+
(sliceVoxelOffsetX + x);
|
|
424
|
+
for (let c = 0; c < channelCount; c++) {
|
|
425
|
+
tileVoxelData[writeIndex * channelCount + c] =
|
|
426
|
+
tileData[readIndex * channelCount + c];
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
const regionDimensionsPerMegatexture = this.regionCountPerMegatexture;
|
|
433
|
+
const voxelWidth = voxelDimensionsPerRegion.x;
|
|
434
|
+
const voxelHeight = voxelDimensionsPerRegion.y;
|
|
435
|
+
const voxelOffsetX =
|
|
436
|
+
(index % regionDimensionsPerMegatexture.x) * voxelDimensionsPerRegion.x;
|
|
437
|
+
const voxelOffsetY =
|
|
438
|
+
Math.floor(index / regionDimensionsPerMegatexture.x) *
|
|
439
|
+
voxelDimensionsPerRegion.y;
|
|
440
|
+
|
|
441
|
+
const source = {
|
|
442
|
+
arrayBufferView: tileVoxelData,
|
|
443
|
+
width: voxelWidth,
|
|
444
|
+
height: voxelHeight,
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
const copyOptions = {
|
|
448
|
+
source: source,
|
|
449
|
+
xOffset: voxelOffsetX,
|
|
450
|
+
yOffset: voxelOffsetY,
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
this.texture.copyFrom(copyOptions);
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Returns true if this object was destroyed; otherwise, false.
|
|
458
|
+
* <br /><br />
|
|
459
|
+
* If this object was destroyed, it should not be used; calling any function other than
|
|
460
|
+
* <code>isDestroyed</code> will result in a {@link DeveloperError} exception.
|
|
461
|
+
*
|
|
462
|
+
* @returns {Boolean} <code>true</code> if this object was destroyed; otherwise, <code>false</code>.
|
|
463
|
+
*
|
|
464
|
+
* @see Megatexture#destroy
|
|
465
|
+
*/
|
|
466
|
+
Megatexture.prototype.isDestroyed = function () {
|
|
467
|
+
return false;
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Destroys the WebGL resources held by this object. Destroying an object allows for deterministic
|
|
472
|
+
* release of WebGL resources, instead of relying on the garbage collector to destroy this object.
|
|
473
|
+
* <br /><br />
|
|
474
|
+
* Once an object is destroyed, it should not be used; calling any function other than
|
|
475
|
+
* <code>isDestroyed</code> will result in a {@link DeveloperError} exception. Therefore,
|
|
476
|
+
* assign the return value (<code>undefined</code>) to the object as done in the example.
|
|
477
|
+
*
|
|
478
|
+
* @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
|
|
479
|
+
*
|
|
480
|
+
* @see Megatexture#isDestroyed
|
|
481
|
+
*
|
|
482
|
+
* @example
|
|
483
|
+
* megatexture = megatexture && megatexture.destroy();
|
|
484
|
+
*/
|
|
485
|
+
Megatexture.prototype.destroy = function () {
|
|
486
|
+
this.texture = this.texture && this.texture.destroy();
|
|
487
|
+
return destroyObject(this);
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
export default Megatexture;
|