@cesium/engine 0.1.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/decodeGoogleEarthEnterprisePacket.js +95 -76
- 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/README.md +9 -9
- 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 +230 -177
- 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/I3SDataProvider.js +2 -1
- package/Source/Scene/I3SFeature.js +1 -1
- package/Source/Scene/I3SLayer.js +64 -2
- package/Source/Scene/I3SNode.js +50 -6
- 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 +38 -6
- 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 +20 -50
- 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 +2 -0
- 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/draco_decoder_nodejs.js +100 -101
- package/Source/ThirdParty/Workers/pako_deflate.min.js +2 -2
- package/Source/ThirdParty/Workers/pako_inflate.min.js +2 -2
- package/Source/ThirdParty/draco_decoder.wasm +0 -0
- package/Source/Widget/CesiumWidget.js +1 -1
- package/index.d.ts +961 -56
- package/index.js +92 -60
- package/package.json +6 -4
- package/Build/ThirdParty/Workers/basis_transcoder.js +0 -2233
- package/Build/ThirdParty/Workers/draco_decoder_nodejs.js +0 -1872
- package/Build/ThirdParty/Workers/package.json +0 -1
- package/Build/ThirdParty/Workers/pako_deflate.min.js +0 -589
- package/Build/ThirdParty/Workers/pako_inflate.min.js +0 -798
- package/Build/ThirdParty/Workers/z-worker-pako.js +0 -503
- package/Build/ThirdParty/basis_transcoder.wasm +0 -0
- package/Build/ThirdParty/draco_decoder.wasm +0 -0
- package/Build/ThirdParty/google-earth-dbroot-parser.js +0 -8019
- package/Build/Widget/CesiumWidget.css +0 -120
- package/Build/Widget/lighter.css +0 -13
- package/Build/Workers/PolygonPipeline-774a8aaf.js +0 -1341
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import Check from "../Core/Check.js";
|
|
2
|
-
import clone from "../Core/clone.js";
|
|
3
2
|
import Color from "../Core/Color.js";
|
|
4
3
|
import ComponentDatatype from "../Core/ComponentDatatype.js";
|
|
5
4
|
import createGuid from "../Core/createGuid.js";
|
|
6
5
|
import defaultValue from "../Core/defaultValue.js";
|
|
7
6
|
import defined from "../Core/defined.js";
|
|
7
|
+
import deprecationWarning from "../Core/deprecationWarning.js";
|
|
8
8
|
import destroyObject from "../Core/destroyObject.js";
|
|
9
9
|
import DeveloperError from "../Core/DeveloperError.js";
|
|
10
10
|
import Geometry from "../Core/Geometry.js";
|
|
@@ -31,183 +31,52 @@ import TextureCache from "./TextureCache.js";
|
|
|
31
31
|
import UniformState from "./UniformState.js";
|
|
32
32
|
import VertexArray from "./VertexArray.js";
|
|
33
33
|
|
|
34
|
-
function errorToString(gl, error) {
|
|
35
|
-
let message = "WebGL Error: ";
|
|
36
|
-
switch (error) {
|
|
37
|
-
case gl.INVALID_ENUM:
|
|
38
|
-
message += "INVALID_ENUM";
|
|
39
|
-
break;
|
|
40
|
-
case gl.INVALID_VALUE:
|
|
41
|
-
message += "INVALID_VALUE";
|
|
42
|
-
break;
|
|
43
|
-
case gl.INVALID_OPERATION:
|
|
44
|
-
message += "INVALID_OPERATION";
|
|
45
|
-
break;
|
|
46
|
-
case gl.OUT_OF_MEMORY:
|
|
47
|
-
message += "OUT_OF_MEMORY";
|
|
48
|
-
break;
|
|
49
|
-
case gl.CONTEXT_LOST_WEBGL:
|
|
50
|
-
message += "CONTEXT_LOST_WEBGL lost";
|
|
51
|
-
break;
|
|
52
|
-
default:
|
|
53
|
-
message += `Unknown (${error})`;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return message;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function createErrorMessage(gl, glFunc, glFuncArguments, error) {
|
|
60
|
-
let message = `${errorToString(gl, error)}: ${glFunc.name}(`;
|
|
61
|
-
|
|
62
|
-
for (let i = 0; i < glFuncArguments.length; ++i) {
|
|
63
|
-
if (i !== 0) {
|
|
64
|
-
message += ", ";
|
|
65
|
-
}
|
|
66
|
-
message += glFuncArguments[i];
|
|
67
|
-
}
|
|
68
|
-
message += ");";
|
|
69
|
-
|
|
70
|
-
return message;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function throwOnError(gl, glFunc, glFuncArguments) {
|
|
74
|
-
const error = gl.getError();
|
|
75
|
-
if (error !== gl.NO_ERROR) {
|
|
76
|
-
throw new RuntimeError(
|
|
77
|
-
createErrorMessage(gl, glFunc, glFuncArguments, error)
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function makeGetterSetter(gl, propertyName, logFunction) {
|
|
83
|
-
return {
|
|
84
|
-
get: function () {
|
|
85
|
-
const value = gl[propertyName];
|
|
86
|
-
logFunction(gl, `get: ${propertyName}`, value);
|
|
87
|
-
return gl[propertyName];
|
|
88
|
-
},
|
|
89
|
-
set: function (value) {
|
|
90
|
-
gl[propertyName] = value;
|
|
91
|
-
logFunction(gl, `set: ${propertyName}`, value);
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function wrapGL(gl, logFunction) {
|
|
97
|
-
if (!defined(logFunction)) {
|
|
98
|
-
return gl;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function wrapFunction(property) {
|
|
102
|
-
return function () {
|
|
103
|
-
const result = property.apply(gl, arguments);
|
|
104
|
-
logFunction(gl, property, arguments);
|
|
105
|
-
return result;
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const glWrapper = {};
|
|
110
|
-
|
|
111
|
-
// JavaScript linters normally demand that a for..in loop must directly contain an if,
|
|
112
|
-
// but in our loop below, we actually intend to iterate all properties, including
|
|
113
|
-
// those in the prototype.
|
|
114
|
-
/*eslint-disable guard-for-in*/
|
|
115
|
-
for (const propertyName in gl) {
|
|
116
|
-
const property = gl[propertyName];
|
|
117
|
-
|
|
118
|
-
// wrap any functions we encounter, otherwise just copy the property to the wrapper.
|
|
119
|
-
if (property instanceof Function) {
|
|
120
|
-
glWrapper[propertyName] = wrapFunction(property);
|
|
121
|
-
} else {
|
|
122
|
-
Object.defineProperty(
|
|
123
|
-
glWrapper,
|
|
124
|
-
propertyName,
|
|
125
|
-
makeGetterSetter(gl, propertyName, logFunction)
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
/*eslint-enable guard-for-in*/
|
|
130
|
-
|
|
131
|
-
return glWrapper;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function getExtension(gl, names) {
|
|
135
|
-
const length = names.length;
|
|
136
|
-
for (let i = 0; i < length; ++i) {
|
|
137
|
-
const extension = gl.getExtension(names[i]);
|
|
138
|
-
if (extension) {
|
|
139
|
-
return extension;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return undefined;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
34
|
/**
|
|
147
35
|
* @private
|
|
148
36
|
* @constructor
|
|
37
|
+
*
|
|
38
|
+
* @param {HTMLCanvasElement} canvas The canvas element to which the context will be associated
|
|
39
|
+
* @param {ContextOptions} [options] Options to control WebGL settings for the context
|
|
149
40
|
*/
|
|
150
41
|
function Context(canvas, options) {
|
|
151
|
-
// this check must use typeof, not defined, because defined doesn't work with undeclared variables.
|
|
152
|
-
if (typeof WebGLRenderingContext === "undefined") {
|
|
153
|
-
throw new RuntimeError(
|
|
154
|
-
"The browser does not support WebGL. Visit http://get.webgl.org."
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
42
|
//>>includeStart('debug', pragmas.debug);
|
|
159
43
|
Check.defined("canvas", canvas);
|
|
160
44
|
//>>includeEnd('debug');
|
|
161
45
|
|
|
162
|
-
|
|
46
|
+
let requestWebgl2 = false;
|
|
47
|
+
if (defined(options) && defined(options.requestWebgl2)) {
|
|
48
|
+
requestWebgl2 = options.requestWebgl2;
|
|
49
|
+
Context._deprecationWarning(
|
|
50
|
+
"ContextOptions.requestWebgl2",
|
|
51
|
+
"Cesium.requestWebgl2 was deprecated in CesiumJS 1.101 and will be removed in 1.102. Use Cesium.requestWebgl1 to request a WebGL1 or WebGL2 context."
|
|
52
|
+
);
|
|
53
|
+
}
|
|
163
54
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
);
|
|
171
|
-
const webglOptions = defaultValue(options.webgl, {});
|
|
55
|
+
const {
|
|
56
|
+
getWebGLStub,
|
|
57
|
+
requestWebgl1 = !requestWebgl2,
|
|
58
|
+
webgl: webglOptions = {},
|
|
59
|
+
allowTextureFilterAnisotropic = true,
|
|
60
|
+
} = defaultValue(options, {});
|
|
172
61
|
|
|
173
62
|
// Override select WebGL defaults
|
|
174
63
|
webglOptions.alpha = defaultValue(webglOptions.alpha, false); // WebGL default is true
|
|
175
64
|
webglOptions.stencil = defaultValue(webglOptions.stencil, true); // WebGL default is false
|
|
65
|
+
webglOptions.powerPreference = defaultValue(
|
|
66
|
+
webglOptions.powerPreference,
|
|
67
|
+
"high-performance"
|
|
68
|
+
); // WebGL default is "default"
|
|
176
69
|
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (!defined(getWebGLStub)) {
|
|
186
|
-
if (requestWebgl2) {
|
|
187
|
-
glContext =
|
|
188
|
-
canvas.getContext("webgl2", webglOptions) ||
|
|
189
|
-
canvas.getContext("experimental-webgl2", webglOptions) ||
|
|
190
|
-
undefined;
|
|
191
|
-
if (defined(glContext)) {
|
|
192
|
-
webgl2 = true;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
if (!defined(glContext)) {
|
|
196
|
-
glContext =
|
|
197
|
-
canvas.getContext("webgl", webglOptions) ||
|
|
198
|
-
canvas.getContext("experimental-webgl", webglOptions) ||
|
|
199
|
-
undefined;
|
|
200
|
-
}
|
|
201
|
-
if (!defined(glContext)) {
|
|
202
|
-
throw new RuntimeError(
|
|
203
|
-
"The browser supports WebGL, but initialization failed."
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
} else {
|
|
207
|
-
// Use WebGL stub when requested for unit tests
|
|
208
|
-
glContext = getWebGLStub(canvas, webglOptions);
|
|
209
|
-
}
|
|
70
|
+
const glContext = defined(getWebGLStub)
|
|
71
|
+
? getWebGLStub(canvas, webglOptions)
|
|
72
|
+
: getWebGLContext(canvas, webglOptions, requestWebgl1);
|
|
73
|
+
|
|
74
|
+
// Get context type. instanceof will throw if WebGL2 is not supported
|
|
75
|
+
const webgl2 =
|
|
76
|
+
typeof WebGL2RenderingContext !== "undefined" &&
|
|
77
|
+
glContext instanceof WebGL2RenderingContext;
|
|
210
78
|
|
|
79
|
+
this._canvas = canvas;
|
|
211
80
|
this._originalGLContext = glContext;
|
|
212
81
|
this._gl = glContext;
|
|
213
82
|
this._webgl2 = webgl2;
|
|
@@ -335,7 +204,7 @@ function Context(canvas, options) {
|
|
|
335
204
|
this._bc7
|
|
336
205
|
);
|
|
337
206
|
|
|
338
|
-
const textureFilterAnisotropic =
|
|
207
|
+
const textureFilterAnisotropic = allowTextureFilterAnisotropic
|
|
339
208
|
? getExtension(gl, [
|
|
340
209
|
"EXT_texture_filter_anisotropic",
|
|
341
210
|
"WEBKIT_EXT_texture_filter_anisotropic",
|
|
@@ -502,21 +371,16 @@ function Context(canvas, options) {
|
|
|
502
371
|
this._nextPickColor = new Uint32Array(1);
|
|
503
372
|
|
|
504
373
|
/**
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
* alpha : false,
|
|
509
|
-
* depth : true,
|
|
510
|
-
* stencil : false,
|
|
511
|
-
* antialias : true,
|
|
512
|
-
* premultipliedAlpha : true,
|
|
513
|
-
* preserveDrawingBuffer : false,
|
|
514
|
-
* failIfMajorPerformanceCaveat : true
|
|
515
|
-
* },
|
|
516
|
-
* allowTextureFilterAnisotropic : true
|
|
517
|
-
* }
|
|
374
|
+
* The options used to construct this context
|
|
375
|
+
*
|
|
376
|
+
* @type {ContextOptions}
|
|
518
377
|
*/
|
|
519
|
-
this.options =
|
|
378
|
+
this.options = {
|
|
379
|
+
getWebGLStub: getWebGLStub,
|
|
380
|
+
requestWebgl1: requestWebgl1,
|
|
381
|
+
webgl: webglOptions,
|
|
382
|
+
allowTextureFilterAnisotropic: allowTextureFilterAnisotropic,
|
|
383
|
+
};
|
|
520
384
|
|
|
521
385
|
/**
|
|
522
386
|
* A cache of objects tied to this context. Just before the Context is destroyed,
|
|
@@ -532,6 +396,191 @@ function Context(canvas, options) {
|
|
|
532
396
|
RenderState.apply(gl, rs, ps);
|
|
533
397
|
}
|
|
534
398
|
|
|
399
|
+
/**
|
|
400
|
+
* @typedef {Object} ContextOptions
|
|
401
|
+
*
|
|
402
|
+
* Options to control the setting up of a WebGL Context.
|
|
403
|
+
* <p>
|
|
404
|
+
* <code>allowTextureFilterAnisotropic</code> defaults to true, which enables
|
|
405
|
+
* anisotropic texture filtering when the WebGL extension is supported.
|
|
406
|
+
* Setting this to false will improve performance, but hurt visual quality,
|
|
407
|
+
* especially for horizon views.
|
|
408
|
+
* </p>
|
|
409
|
+
*
|
|
410
|
+
* @property {Boolean} [requestWebgl1 = true] If true and the browser supports it, use a WebGL 1 rendering context
|
|
411
|
+
* @property {Boolean} [allowTextureFilterAnisotropic=true] If true, use anisotropic filtering during texture sampling
|
|
412
|
+
* @property {WebGLOptions} [webgl] WebGL options to be passed on to canvas.getContext
|
|
413
|
+
* @property {Function} [getWebGLStub] A function to create a WebGL stub for testing
|
|
414
|
+
*/
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* @private
|
|
418
|
+
* @param {HTMLCanvasElement} canvas The canvas element to which the context will be associated
|
|
419
|
+
* @param {WebGLOptions} webglOptions WebGL options to be passed on to HTMLCanvasElement.getContext()
|
|
420
|
+
* @param {Boolean} requestWebgl1 Whether to request a WebGLRenderingContext or a WebGL2RenderingContext.
|
|
421
|
+
* @returns {WebGLRenderingContext|WebGL2RenderingContext}
|
|
422
|
+
*/
|
|
423
|
+
function getWebGLContext(canvas, webglOptions, requestWebgl1) {
|
|
424
|
+
if (typeof WebGLRenderingContext === "undefined") {
|
|
425
|
+
throw new RuntimeError(
|
|
426
|
+
"The browser does not support WebGL. Visit http://get.webgl.org."
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// Ensure that WebGL 2 is supported when it is requested. Otherwise, fall back to WebGL 1.
|
|
431
|
+
const webgl2Supported = typeof WebGL2RenderingContext !== "undefined";
|
|
432
|
+
if (!requestWebgl1 && !webgl2Supported) {
|
|
433
|
+
requestWebgl1 = true;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
const contextType = requestWebgl1 ? "webgl" : "webgl2";
|
|
437
|
+
const glContext = canvas.getContext(contextType, webglOptions);
|
|
438
|
+
|
|
439
|
+
if (!defined(glContext)) {
|
|
440
|
+
throw new RuntimeError(
|
|
441
|
+
"The browser supports WebGL, but initialization failed."
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
return glContext;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* @typedef {Object} WebGLOptions
|
|
450
|
+
*
|
|
451
|
+
* WebGL options to be passed on to HTMLCanvasElement.getContext().
|
|
452
|
+
* See {@link https://registry.khronos.org/webgl/specs/latest/1.0/#5.2|WebGLContextAttributes}
|
|
453
|
+
* but note the modified defaults for 'alpha', 'stencil', and 'powerPreference'
|
|
454
|
+
*
|
|
455
|
+
* <p>
|
|
456
|
+
* <code>alpha</code> defaults to false, which can improve performance
|
|
457
|
+
* compared to the standard WebGL default of true. If an application needs
|
|
458
|
+
* to composite Cesium above other HTML elements using alpha-blending, set
|
|
459
|
+
* <code>alpha</code> to true.
|
|
460
|
+
* </p>
|
|
461
|
+
*
|
|
462
|
+
* @property {Boolean} [alpha=false]
|
|
463
|
+
* @property {Boolean} [depth=true]
|
|
464
|
+
* @property {Boolean} [stencil=false]
|
|
465
|
+
* @property {Boolean} [antialias=true]
|
|
466
|
+
* @property {Boolean} [premultipliedAlpha=true]
|
|
467
|
+
* @property {Boolean} [preserveDrawingBuffer=false]
|
|
468
|
+
* @property {("default"|"low-power"|"high-performance")} [powerPreference="high-performance"]
|
|
469
|
+
* @property {Boolean} [failIfMajorPerformanceCaveat=false]
|
|
470
|
+
*/
|
|
471
|
+
|
|
472
|
+
function errorToString(gl, error) {
|
|
473
|
+
let message = "WebGL Error: ";
|
|
474
|
+
switch (error) {
|
|
475
|
+
case gl.INVALID_ENUM:
|
|
476
|
+
message += "INVALID_ENUM";
|
|
477
|
+
break;
|
|
478
|
+
case gl.INVALID_VALUE:
|
|
479
|
+
message += "INVALID_VALUE";
|
|
480
|
+
break;
|
|
481
|
+
case gl.INVALID_OPERATION:
|
|
482
|
+
message += "INVALID_OPERATION";
|
|
483
|
+
break;
|
|
484
|
+
case gl.OUT_OF_MEMORY:
|
|
485
|
+
message += "OUT_OF_MEMORY";
|
|
486
|
+
break;
|
|
487
|
+
case gl.CONTEXT_LOST_WEBGL:
|
|
488
|
+
message += "CONTEXT_LOST_WEBGL lost";
|
|
489
|
+
break;
|
|
490
|
+
default:
|
|
491
|
+
message += `Unknown (${error})`;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
return message;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
function createErrorMessage(gl, glFunc, glFuncArguments, error) {
|
|
498
|
+
let message = `${errorToString(gl, error)}: ${glFunc.name}(`;
|
|
499
|
+
|
|
500
|
+
for (let i = 0; i < glFuncArguments.length; ++i) {
|
|
501
|
+
if (i !== 0) {
|
|
502
|
+
message += ", ";
|
|
503
|
+
}
|
|
504
|
+
message += glFuncArguments[i];
|
|
505
|
+
}
|
|
506
|
+
message += ");";
|
|
507
|
+
|
|
508
|
+
return message;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
function throwOnError(gl, glFunc, glFuncArguments) {
|
|
512
|
+
const error = gl.getError();
|
|
513
|
+
if (error !== gl.NO_ERROR) {
|
|
514
|
+
throw new RuntimeError(
|
|
515
|
+
createErrorMessage(gl, glFunc, glFuncArguments, error)
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function makeGetterSetter(gl, propertyName, logFunction) {
|
|
521
|
+
return {
|
|
522
|
+
get: function () {
|
|
523
|
+
const value = gl[propertyName];
|
|
524
|
+
logFunction(gl, `get: ${propertyName}`, value);
|
|
525
|
+
return gl[propertyName];
|
|
526
|
+
},
|
|
527
|
+
set: function (value) {
|
|
528
|
+
gl[propertyName] = value;
|
|
529
|
+
logFunction(gl, `set: ${propertyName}`, value);
|
|
530
|
+
},
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
function wrapGL(gl, logFunction) {
|
|
535
|
+
if (!defined(logFunction)) {
|
|
536
|
+
return gl;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
function wrapFunction(property) {
|
|
540
|
+
return function () {
|
|
541
|
+
const result = property.apply(gl, arguments);
|
|
542
|
+
logFunction(gl, property, arguments);
|
|
543
|
+
return result;
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
const glWrapper = {};
|
|
548
|
+
|
|
549
|
+
// JavaScript linters normally demand that a for..in loop must directly contain an if,
|
|
550
|
+
// but in our loop below, we actually intend to iterate all properties, including
|
|
551
|
+
// those in the prototype.
|
|
552
|
+
/*eslint-disable guard-for-in*/
|
|
553
|
+
for (const propertyName in gl) {
|
|
554
|
+
const property = gl[propertyName];
|
|
555
|
+
|
|
556
|
+
// wrap any functions we encounter, otherwise just copy the property to the wrapper.
|
|
557
|
+
if (property instanceof Function) {
|
|
558
|
+
glWrapper[propertyName] = wrapFunction(property);
|
|
559
|
+
} else {
|
|
560
|
+
Object.defineProperty(
|
|
561
|
+
glWrapper,
|
|
562
|
+
propertyName,
|
|
563
|
+
makeGetterSetter(gl, propertyName, logFunction)
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
/*eslint-enable guard-for-in*/
|
|
568
|
+
|
|
569
|
+
return glWrapper;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
function getExtension(gl, names) {
|
|
573
|
+
const length = names.length;
|
|
574
|
+
for (let i = 0; i < length; ++i) {
|
|
575
|
+
const extension = gl.getExtension(names[i]);
|
|
576
|
+
if (extension) {
|
|
577
|
+
return extension;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
return undefined;
|
|
582
|
+
}
|
|
583
|
+
|
|
535
584
|
const defaultFramebufferMarker = {};
|
|
536
585
|
|
|
537
586
|
Object.defineProperties(Context.prototype, {
|
|
@@ -1598,4 +1647,8 @@ Context.prototype.destroy = function () {
|
|
|
1598
1647
|
|
|
1599
1648
|
return destroyObject(this);
|
|
1600
1649
|
};
|
|
1650
|
+
|
|
1651
|
+
// Used for specs.
|
|
1652
|
+
Context._deprecationWarning = deprecationWarning;
|
|
1653
|
+
|
|
1601
1654
|
export default Context;
|
package/Source/Renderer/Pass.js
CHANGED
|
@@ -132,6 +132,24 @@ const Cesium3DTileContentType = {
|
|
|
132
132
|
* @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
|
|
133
133
|
*/
|
|
134
134
|
GEOJSON: "geoJson",
|
|
135
|
+
/**
|
|
136
|
+
* Binary voxel content for <code>3DTILES_content_voxels</code> extension.
|
|
137
|
+
*
|
|
138
|
+
* @type {String}
|
|
139
|
+
* @constant
|
|
140
|
+
* @private
|
|
141
|
+
* @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
|
|
142
|
+
*/
|
|
143
|
+
VOXEL_BINARY: "voxl",
|
|
144
|
+
/**
|
|
145
|
+
* Binary voxel content for <code>3DTILES_content_voxels</code> extension.
|
|
146
|
+
*
|
|
147
|
+
* @type {String}
|
|
148
|
+
* @constant
|
|
149
|
+
* @private
|
|
150
|
+
* @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
|
|
151
|
+
*/
|
|
152
|
+
VOXEL_JSON: "voxelJson",
|
|
135
153
|
};
|
|
136
154
|
|
|
137
155
|
/**
|
|
@@ -150,6 +168,7 @@ Cesium3DTileContentType.isBinaryFormat = function (contentType) {
|
|
|
150
168
|
case Cesium3DTileContentType.VECTOR:
|
|
151
169
|
case Cesium3DTileContentType.GEOMETRY:
|
|
152
170
|
case Cesium3DTileContentType.IMPLICIT_SUBTREE:
|
|
171
|
+
case Cesium3DTileContentType.VOXEL_BINARY:
|
|
153
172
|
case Cesium3DTileContentType.GLTF_BINARY:
|
|
154
173
|
return true;
|
|
155
174
|
default:
|