@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
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import defined from "../Core/defined.js";
|
|
2
|
+
import PrimitiveType from "../Core/PrimitiveType.js";
|
|
3
|
+
import BlendingState from "./BlendingState.js";
|
|
4
|
+
import CullFace from "./CullFace.js";
|
|
5
|
+
import getClippingFunction from "./getClippingFunction.js";
|
|
6
|
+
import DrawCommand from "../Renderer/DrawCommand.js";
|
|
7
|
+
import Pass from "../Renderer/Pass.js";
|
|
8
|
+
import RenderState from "../Renderer/RenderState.js";
|
|
9
|
+
import ShaderDestination from "../Renderer/ShaderDestination.js";
|
|
10
|
+
import VoxelRenderResources from "./VoxelRenderResources.js";
|
|
11
|
+
import processVoxelProperties from "./processVoxelProperties.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @function
|
|
15
|
+
*
|
|
16
|
+
* @param {VoxelPrimitive} primitive
|
|
17
|
+
* @param {Context} context
|
|
18
|
+
*
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
function buildVoxelDrawCommands(primitive, context) {
|
|
22
|
+
const renderResources = new VoxelRenderResources(primitive);
|
|
23
|
+
|
|
24
|
+
processVoxelProperties(renderResources, primitive);
|
|
25
|
+
|
|
26
|
+
const {
|
|
27
|
+
shaderBuilder,
|
|
28
|
+
clippingPlanes,
|
|
29
|
+
clippingPlanesLength,
|
|
30
|
+
} = renderResources;
|
|
31
|
+
|
|
32
|
+
if (clippingPlanesLength > 0) {
|
|
33
|
+
// Extract the getClippingPlane function from the getClippingFunction string.
|
|
34
|
+
// This is a bit of a hack.
|
|
35
|
+
const functionId = "getClippingPlane";
|
|
36
|
+
const entireFunction = getClippingFunction(clippingPlanes, context);
|
|
37
|
+
const functionSignatureBegin = 0;
|
|
38
|
+
const functionSignatureEnd = entireFunction.indexOf(")") + 1;
|
|
39
|
+
const functionBodyBegin =
|
|
40
|
+
entireFunction.indexOf("{", functionSignatureEnd) + 1;
|
|
41
|
+
const functionBodyEnd = entireFunction.indexOf("}", functionBodyBegin);
|
|
42
|
+
const functionSignature = entireFunction.slice(
|
|
43
|
+
functionSignatureBegin,
|
|
44
|
+
functionSignatureEnd
|
|
45
|
+
);
|
|
46
|
+
const functionBody = entireFunction.slice(
|
|
47
|
+
functionBodyBegin,
|
|
48
|
+
functionBodyEnd
|
|
49
|
+
);
|
|
50
|
+
shaderBuilder.addFunction(
|
|
51
|
+
functionId,
|
|
52
|
+
functionSignature,
|
|
53
|
+
ShaderDestination.FRAGMENT
|
|
54
|
+
);
|
|
55
|
+
shaderBuilder.addFunctionLines(functionId, [functionBody]);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Compile shaders
|
|
59
|
+
const shaderBuilderPick = shaderBuilder.clone();
|
|
60
|
+
shaderBuilderPick.addDefine("PICKING", undefined, ShaderDestination.FRAGMENT);
|
|
61
|
+
const shaderProgram = shaderBuilder.buildShaderProgram(context);
|
|
62
|
+
const shaderProgramPick = shaderBuilderPick.buildShaderProgram(context);
|
|
63
|
+
const renderState = RenderState.fromCache({
|
|
64
|
+
cull: {
|
|
65
|
+
enabled: true,
|
|
66
|
+
face: CullFace.BACK,
|
|
67
|
+
},
|
|
68
|
+
depthTest: {
|
|
69
|
+
enabled: false,
|
|
70
|
+
},
|
|
71
|
+
depthMask: false,
|
|
72
|
+
// internally the shader does premultiplied alpha, so it makes sense to blend that way too
|
|
73
|
+
blending: BlendingState.PRE_MULTIPLIED_ALPHA_BLEND,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Create the draw commands
|
|
77
|
+
const viewportQuadVertexArray = context.getViewportQuadVertexArray();
|
|
78
|
+
const depthTest = primitive._depthTest;
|
|
79
|
+
const drawCommand = new DrawCommand({
|
|
80
|
+
vertexArray: viewportQuadVertexArray,
|
|
81
|
+
primitiveType: PrimitiveType.TRIANGLES,
|
|
82
|
+
renderState: renderState,
|
|
83
|
+
shaderProgram: shaderProgram,
|
|
84
|
+
uniformMap: renderResources.uniformMap,
|
|
85
|
+
pass: Pass.VOXELS,
|
|
86
|
+
executeInClosestFrustum: true,
|
|
87
|
+
owner: this,
|
|
88
|
+
cull: depthTest, // don't cull or occlude if depth testing is off
|
|
89
|
+
occlude: depthTest, // don't cull or occlude if depth testing is off
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Create the pick draw command
|
|
93
|
+
const drawCommandPick = DrawCommand.shallowClone(
|
|
94
|
+
drawCommand,
|
|
95
|
+
new DrawCommand()
|
|
96
|
+
);
|
|
97
|
+
drawCommandPick.shaderProgram = shaderProgramPick;
|
|
98
|
+
drawCommandPick.pickOnly = true;
|
|
99
|
+
|
|
100
|
+
// Delete the old shader programs
|
|
101
|
+
if (defined(primitive._drawCommand)) {
|
|
102
|
+
const command = primitive._drawCommand;
|
|
103
|
+
command.shaderProgram =
|
|
104
|
+
command.shaderProgram && command.shaderProgram.destroy();
|
|
105
|
+
}
|
|
106
|
+
if (defined(primitive._drawCommandPick)) {
|
|
107
|
+
const command = primitive._drawCommandPick;
|
|
108
|
+
command.shaderProgram =
|
|
109
|
+
command.shaderProgram && command.shaderProgram.destroy();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
primitive._drawCommand = drawCommand;
|
|
113
|
+
primitive._drawCommandPick = drawCommandPick;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export default buildVoxelDrawCommands;
|
|
@@ -16,6 +16,7 @@ import MetadataSchema from "./MetadataSchema.js";
|
|
|
16
16
|
import MetadataTable from "./MetadataTable.js";
|
|
17
17
|
import ModelComponents from "./ModelComponents.js";
|
|
18
18
|
import ModelUtility from "./Model/ModelUtility.js";
|
|
19
|
+
import oneTimeWarning from "../Core/oneTimeWarning.js";
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* An object that parses the the 3D Tiles 1.0 batch table and transcodes it to
|
|
@@ -263,7 +264,7 @@ function transcodeBinaryProperties(
|
|
|
263
264
|
properties: classProperties,
|
|
264
265
|
};
|
|
265
266
|
|
|
266
|
-
const transcodedSchema =
|
|
267
|
+
const transcodedSchema = MetadataSchema.fromJson(schemaJson);
|
|
267
268
|
|
|
268
269
|
const featureTableJson = {
|
|
269
270
|
class: className,
|
|
@@ -353,6 +354,20 @@ function transcodeBinaryPropertiesAsPropertyAttributes(
|
|
|
353
354
|
attribute.name = customAttributeName;
|
|
354
355
|
attribute.count = featureCount;
|
|
355
356
|
attribute.type = property.type;
|
|
357
|
+
const componentDatatype = ComponentDatatype.fromTypedArray(
|
|
358
|
+
attributeTypedArray
|
|
359
|
+
);
|
|
360
|
+
if (
|
|
361
|
+
componentDatatype === ComponentDatatype.INT ||
|
|
362
|
+
componentDatatype === ComponentDatatype.UNSIGNED_INT ||
|
|
363
|
+
componentDatatype === ComponentDatatype.DOUBLE
|
|
364
|
+
) {
|
|
365
|
+
parseBatchTable._oneTimeWarning(
|
|
366
|
+
"Cast pnts property to floats",
|
|
367
|
+
`Point cloud property "${customAttributeName}" will be cast to a float array because INT, UNSIGNED_INT, and DOUBLE are not valid WebGL vertex attribute types. Some precision may be lost.`
|
|
368
|
+
);
|
|
369
|
+
attributeTypedArray = new Float32Array(attributeTypedArray);
|
|
370
|
+
}
|
|
356
371
|
attribute.componentDatatype = ComponentDatatype.fromTypedArray(
|
|
357
372
|
attributeTypedArray
|
|
358
373
|
);
|
|
@@ -372,7 +387,7 @@ function transcodeBinaryPropertiesAsPropertyAttributes(
|
|
|
372
387
|
properties: classProperties,
|
|
373
388
|
};
|
|
374
389
|
|
|
375
|
-
const transcodedSchema =
|
|
390
|
+
const transcodedSchema = MetadataSchema.fromJson(schemaJson);
|
|
376
391
|
|
|
377
392
|
const propertyAttributeJson = {
|
|
378
393
|
properties: propertyAttributeProperties,
|
|
@@ -435,5 +450,6 @@ function transcodeComponentType(componentType) {
|
|
|
435
450
|
|
|
436
451
|
// exposed for testing
|
|
437
452
|
parseBatchTable._deprecationWarning = deprecationWarning;
|
|
453
|
+
parseBatchTable._oneTimeWarning = oneTimeWarning;
|
|
438
454
|
|
|
439
455
|
export default parseBatchTable;
|
|
@@ -76,6 +76,14 @@ function preprocess3DTileContent(arrayBuffer) {
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
if (defined(json.voxelTable)) {
|
|
80
|
+
// Most likely a voxel JSON
|
|
81
|
+
return {
|
|
82
|
+
contentType: Cesium3DTileContentType.VOXEL_JSON,
|
|
83
|
+
jsonPayload: json,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
79
87
|
throw new RuntimeError("Invalid tile content.");
|
|
80
88
|
}
|
|
81
89
|
|
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
import defined from "../Core/defined.js";
|
|
2
|
+
import MetadataType from "./MetadataType.js";
|
|
3
|
+
import ShaderDestination from "../Renderer/ShaderDestination.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Update the shader with defines, structs, and functions to handle
|
|
7
|
+
* voxel properties and statistics
|
|
8
|
+
* @function
|
|
9
|
+
*
|
|
10
|
+
* @param {VoxelRenderResources} renderResources
|
|
11
|
+
* @param {VoxelPrimitive} primitive
|
|
12
|
+
*
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
function processVoxelProperties(renderResources, primitive) {
|
|
16
|
+
const { shaderBuilder } = renderResources;
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
names,
|
|
20
|
+
types,
|
|
21
|
+
componentTypes,
|
|
22
|
+
minimumValues,
|
|
23
|
+
maximumValues,
|
|
24
|
+
} = primitive._provider;
|
|
25
|
+
|
|
26
|
+
const attributeLength = types.length;
|
|
27
|
+
const hasStatistics = defined(minimumValues) && defined(maximumValues);
|
|
28
|
+
|
|
29
|
+
shaderBuilder.addDefine(
|
|
30
|
+
"METADATA_COUNT",
|
|
31
|
+
attributeLength,
|
|
32
|
+
ShaderDestination.FRAGMENT
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
if (hasStatistics) {
|
|
36
|
+
shaderBuilder.addDefine(
|
|
37
|
+
"STATISTICS",
|
|
38
|
+
undefined,
|
|
39
|
+
ShaderDestination.FRAGMENT
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// PropertyStatistics structs
|
|
44
|
+
for (let i = 0; i < attributeLength; i++) {
|
|
45
|
+
const name = names[i];
|
|
46
|
+
const type = types[i];
|
|
47
|
+
const propertyStatisticsStructId = `PropertyStatistics_${name}`;
|
|
48
|
+
const propertyStatisticsStructName = `PropertyStatistics_${name}`;
|
|
49
|
+
shaderBuilder.addStruct(
|
|
50
|
+
propertyStatisticsStructId,
|
|
51
|
+
propertyStatisticsStructName,
|
|
52
|
+
ShaderDestination.FRAGMENT
|
|
53
|
+
);
|
|
54
|
+
const glslType = getGlslType(type);
|
|
55
|
+
shaderBuilder.addStructField(propertyStatisticsStructId, glslType, "min");
|
|
56
|
+
shaderBuilder.addStructField(propertyStatisticsStructId, glslType, "max");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Statistics struct
|
|
60
|
+
const statisticsStructId = "Statistics";
|
|
61
|
+
const statisticsStructName = "Statistics";
|
|
62
|
+
const statisticsFieldName = "statistics";
|
|
63
|
+
shaderBuilder.addStruct(
|
|
64
|
+
statisticsStructId,
|
|
65
|
+
statisticsStructName,
|
|
66
|
+
ShaderDestination.FRAGMENT
|
|
67
|
+
);
|
|
68
|
+
for (let i = 0; i < attributeLength; i++) {
|
|
69
|
+
const name = names[i];
|
|
70
|
+
const propertyStructName = `PropertyStatistics_${name}`;
|
|
71
|
+
const propertyFieldName = name;
|
|
72
|
+
shaderBuilder.addStructField(
|
|
73
|
+
statisticsStructId,
|
|
74
|
+
propertyStructName,
|
|
75
|
+
propertyFieldName
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Metadata struct
|
|
80
|
+
const metadataStructId = "Metadata";
|
|
81
|
+
const metadataStructName = "Metadata";
|
|
82
|
+
const metadataFieldName = "metadata";
|
|
83
|
+
shaderBuilder.addStruct(
|
|
84
|
+
metadataStructId,
|
|
85
|
+
metadataStructName,
|
|
86
|
+
ShaderDestination.FRAGMENT
|
|
87
|
+
);
|
|
88
|
+
shaderBuilder.addStructField(
|
|
89
|
+
metadataStructId,
|
|
90
|
+
statisticsStructName,
|
|
91
|
+
statisticsFieldName
|
|
92
|
+
);
|
|
93
|
+
for (let i = 0; i < attributeLength; i++) {
|
|
94
|
+
const name = names[i];
|
|
95
|
+
const type = types[i];
|
|
96
|
+
const glslType = getGlslType(type);
|
|
97
|
+
shaderBuilder.addStructField(metadataStructId, glslType, name);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// VoxelProperty structs
|
|
101
|
+
for (let i = 0; i < attributeLength; i++) {
|
|
102
|
+
const name = names[i];
|
|
103
|
+
const type = types[i];
|
|
104
|
+
const glslType = getGlslPartialDerivativeType(type);
|
|
105
|
+
const voxelPropertyStructId = `VoxelProperty_${name}`;
|
|
106
|
+
const voxelPropertyStructName = `VoxelProperty_${name}`;
|
|
107
|
+
shaderBuilder.addStruct(
|
|
108
|
+
voxelPropertyStructId,
|
|
109
|
+
voxelPropertyStructName,
|
|
110
|
+
ShaderDestination.FRAGMENT
|
|
111
|
+
);
|
|
112
|
+
shaderBuilder.addStructField(
|
|
113
|
+
voxelPropertyStructId,
|
|
114
|
+
glslType,
|
|
115
|
+
"partialDerivativeLocal"
|
|
116
|
+
);
|
|
117
|
+
shaderBuilder.addStructField(
|
|
118
|
+
voxelPropertyStructId,
|
|
119
|
+
glslType,
|
|
120
|
+
"partialDerivativeWorld"
|
|
121
|
+
);
|
|
122
|
+
shaderBuilder.addStructField(
|
|
123
|
+
voxelPropertyStructId,
|
|
124
|
+
glslType,
|
|
125
|
+
"partialDerivativeView"
|
|
126
|
+
);
|
|
127
|
+
shaderBuilder.addStructField(
|
|
128
|
+
voxelPropertyStructId,
|
|
129
|
+
glslType,
|
|
130
|
+
"partialDerivativeValid"
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Voxel struct
|
|
135
|
+
const voxelStructId = "Voxel";
|
|
136
|
+
const voxelStructName = "Voxel";
|
|
137
|
+
const voxelFieldName = "voxel";
|
|
138
|
+
shaderBuilder.addStruct(
|
|
139
|
+
voxelStructId,
|
|
140
|
+
voxelStructName,
|
|
141
|
+
ShaderDestination.FRAGMENT
|
|
142
|
+
);
|
|
143
|
+
for (let i = 0; i < attributeLength; i++) {
|
|
144
|
+
const name = names[i];
|
|
145
|
+
const voxelPropertyStructName = `VoxelProperty_${name}`;
|
|
146
|
+
shaderBuilder.addStructField(voxelStructId, voxelPropertyStructName, name);
|
|
147
|
+
}
|
|
148
|
+
shaderBuilder.addStructField(voxelStructId, "vec3", "positionEC");
|
|
149
|
+
shaderBuilder.addStructField(voxelStructId, "vec3", "positionUv");
|
|
150
|
+
shaderBuilder.addStructField(voxelStructId, "vec3", "positionShapeUv");
|
|
151
|
+
shaderBuilder.addStructField(voxelStructId, "vec3", "positionUvLocal");
|
|
152
|
+
shaderBuilder.addStructField(voxelStructId, "vec3", "viewDirUv");
|
|
153
|
+
shaderBuilder.addStructField(voxelStructId, "vec3", "viewDirWorld");
|
|
154
|
+
shaderBuilder.addStructField(voxelStructId, "float", "travelDistance");
|
|
155
|
+
|
|
156
|
+
// FragmentInput struct
|
|
157
|
+
const fragmentInputStructId = "FragmentInput";
|
|
158
|
+
const fragmentInputStructName = "FragmentInput";
|
|
159
|
+
shaderBuilder.addStruct(
|
|
160
|
+
fragmentInputStructId,
|
|
161
|
+
fragmentInputStructName,
|
|
162
|
+
ShaderDestination.FRAGMENT
|
|
163
|
+
);
|
|
164
|
+
shaderBuilder.addStructField(
|
|
165
|
+
fragmentInputStructId,
|
|
166
|
+
metadataStructName,
|
|
167
|
+
metadataFieldName
|
|
168
|
+
);
|
|
169
|
+
shaderBuilder.addStructField(
|
|
170
|
+
fragmentInputStructId,
|
|
171
|
+
voxelStructName,
|
|
172
|
+
voxelFieldName
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
// Properties struct
|
|
176
|
+
const propertiesStructId = "Properties";
|
|
177
|
+
const propertiesStructName = "Properties";
|
|
178
|
+
const propertiesFieldName = "properties";
|
|
179
|
+
shaderBuilder.addStruct(
|
|
180
|
+
propertiesStructId,
|
|
181
|
+
propertiesStructName,
|
|
182
|
+
ShaderDestination.FRAGMENT
|
|
183
|
+
);
|
|
184
|
+
for (let i = 0; i < attributeLength; i++) {
|
|
185
|
+
const name = names[i];
|
|
186
|
+
const type = types[i];
|
|
187
|
+
const glslType = getGlslType(type);
|
|
188
|
+
shaderBuilder.addStructField(propertiesStructId, glslType, name);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Fragment shader functions
|
|
192
|
+
|
|
193
|
+
// clearProperties function
|
|
194
|
+
{
|
|
195
|
+
const functionId = "clearProperties";
|
|
196
|
+
shaderBuilder.addFunction(
|
|
197
|
+
functionId,
|
|
198
|
+
`${propertiesStructName} clearProperties()`,
|
|
199
|
+
ShaderDestination.FRAGMENT
|
|
200
|
+
);
|
|
201
|
+
shaderBuilder.addFunctionLines(functionId, [
|
|
202
|
+
`${propertiesStructName} ${propertiesFieldName};`,
|
|
203
|
+
]);
|
|
204
|
+
for (let i = 0; i < attributeLength; i++) {
|
|
205
|
+
const name = names[i];
|
|
206
|
+
const type = types[i];
|
|
207
|
+
const componentType = componentTypes[i];
|
|
208
|
+
const glslType = getGlslType(type, componentType);
|
|
209
|
+
shaderBuilder.addFunctionLines(functionId, [
|
|
210
|
+
`${propertiesFieldName}.${name} = ${glslType}(0.0);`,
|
|
211
|
+
]);
|
|
212
|
+
}
|
|
213
|
+
shaderBuilder.addFunctionLines(functionId, [
|
|
214
|
+
`return ${propertiesFieldName};`,
|
|
215
|
+
]);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// sumProperties function
|
|
219
|
+
{
|
|
220
|
+
const functionId = "sumProperties";
|
|
221
|
+
shaderBuilder.addFunction(
|
|
222
|
+
functionId,
|
|
223
|
+
`${propertiesStructName} sumProperties(${propertiesStructName} propertiesA, ${propertiesStructName} propertiesB)`,
|
|
224
|
+
ShaderDestination.FRAGMENT
|
|
225
|
+
);
|
|
226
|
+
shaderBuilder.addFunctionLines(functionId, [
|
|
227
|
+
`${propertiesStructName} ${propertiesFieldName};`,
|
|
228
|
+
]);
|
|
229
|
+
for (let i = 0; i < attributeLength; i++) {
|
|
230
|
+
const name = names[i];
|
|
231
|
+
shaderBuilder.addFunctionLines(functionId, [
|
|
232
|
+
`${propertiesFieldName}.${name} = propertiesA.${name} + propertiesB.${name};`,
|
|
233
|
+
]);
|
|
234
|
+
}
|
|
235
|
+
shaderBuilder.addFunctionLines(functionId, [
|
|
236
|
+
`return ${propertiesFieldName};`,
|
|
237
|
+
]);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// scaleProperties function
|
|
241
|
+
{
|
|
242
|
+
const functionId = "scaleProperties";
|
|
243
|
+
shaderBuilder.addFunction(
|
|
244
|
+
functionId,
|
|
245
|
+
`${propertiesStructName} scaleProperties(${propertiesStructName} ${propertiesFieldName}, float scale)`,
|
|
246
|
+
ShaderDestination.FRAGMENT
|
|
247
|
+
);
|
|
248
|
+
shaderBuilder.addFunctionLines(functionId, [
|
|
249
|
+
`${propertiesStructName} scaledProperties = ${propertiesFieldName};`,
|
|
250
|
+
]);
|
|
251
|
+
for (let i = 0; i < attributeLength; i++) {
|
|
252
|
+
const name = names[i];
|
|
253
|
+
shaderBuilder.addFunctionLines(functionId, [
|
|
254
|
+
`scaledProperties.${name} *= scale;`,
|
|
255
|
+
]);
|
|
256
|
+
}
|
|
257
|
+
shaderBuilder.addFunctionLines(functionId, [`return scaledProperties;`]);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// mixProperties
|
|
261
|
+
{
|
|
262
|
+
const functionId = "mixProperties";
|
|
263
|
+
shaderBuilder.addFunction(
|
|
264
|
+
functionId,
|
|
265
|
+
`${propertiesStructName} mixProperties(${propertiesStructName} propertiesA, ${propertiesStructName} propertiesB, float mixFactor)`,
|
|
266
|
+
ShaderDestination.FRAGMENT
|
|
267
|
+
);
|
|
268
|
+
shaderBuilder.addFunctionLines(functionId, [
|
|
269
|
+
`${propertiesStructName} ${propertiesFieldName};`,
|
|
270
|
+
]);
|
|
271
|
+
for (let i = 0; i < attributeLength; i++) {
|
|
272
|
+
const name = names[i];
|
|
273
|
+
shaderBuilder.addFunctionLines(functionId, [
|
|
274
|
+
`${propertiesFieldName}.${name} = mix(propertiesA.${name}, propertiesB.${name}, mixFactor);`,
|
|
275
|
+
]);
|
|
276
|
+
}
|
|
277
|
+
shaderBuilder.addFunctionLines(functionId, [
|
|
278
|
+
`return ${propertiesFieldName};`,
|
|
279
|
+
]);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// copyPropertiesToMetadata
|
|
283
|
+
{
|
|
284
|
+
const functionId = "copyPropertiesToMetadata";
|
|
285
|
+
shaderBuilder.addFunction(
|
|
286
|
+
functionId,
|
|
287
|
+
`void copyPropertiesToMetadata(in ${propertiesStructName} ${propertiesFieldName}, inout ${metadataStructName} ${metadataFieldName})`,
|
|
288
|
+
ShaderDestination.FRAGMENT
|
|
289
|
+
);
|
|
290
|
+
for (let i = 0; i < attributeLength; i++) {
|
|
291
|
+
const name = names[i];
|
|
292
|
+
shaderBuilder.addFunctionLines(functionId, [
|
|
293
|
+
`${metadataFieldName}.${name} = ${propertiesFieldName}.${name};`,
|
|
294
|
+
]);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// setStatistics function
|
|
299
|
+
if (hasStatistics) {
|
|
300
|
+
const functionId = "setStatistics";
|
|
301
|
+
shaderBuilder.addFunction(
|
|
302
|
+
functionId,
|
|
303
|
+
`void setStatistics(inout ${statisticsStructName} ${statisticsFieldName})`,
|
|
304
|
+
ShaderDestination.FRAGMENT
|
|
305
|
+
);
|
|
306
|
+
for (let i = 0; i < attributeLength; i++) {
|
|
307
|
+
const name = names[i];
|
|
308
|
+
const type = types[i];
|
|
309
|
+
const componentCount = MetadataType.getComponentCount(type);
|
|
310
|
+
for (let j = 0; j < componentCount; j++) {
|
|
311
|
+
const glslField = getGlslField(type, j);
|
|
312
|
+
const minimumValue = minimumValues[i][j];
|
|
313
|
+
const maximumValue = maximumValues[i][j];
|
|
314
|
+
shaderBuilder.addFunctionLines(functionId, [
|
|
315
|
+
`${statisticsFieldName}.${name}.min${glslField} = ${getGlslNumberAsFloat(
|
|
316
|
+
minimumValue
|
|
317
|
+
)};`,
|
|
318
|
+
`${statisticsFieldName}.${name}.max${glslField} = ${getGlslNumberAsFloat(
|
|
319
|
+
maximumValue
|
|
320
|
+
)};`,
|
|
321
|
+
]);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// getPropertiesFromMegatextureAtUv
|
|
327
|
+
{
|
|
328
|
+
const functionId = "getPropertiesFromMegatextureAtUv";
|
|
329
|
+
shaderBuilder.addFunction(
|
|
330
|
+
functionId,
|
|
331
|
+
`${propertiesStructName} getPropertiesFromMegatextureAtUv(vec2 texcoord)`,
|
|
332
|
+
ShaderDestination.FRAGMENT
|
|
333
|
+
);
|
|
334
|
+
shaderBuilder.addFunctionLines(functionId, [
|
|
335
|
+
`${propertiesStructName} ${propertiesFieldName};`,
|
|
336
|
+
]);
|
|
337
|
+
for (let i = 0; i < attributeLength; i++) {
|
|
338
|
+
const name = names[i];
|
|
339
|
+
const type = types[i];
|
|
340
|
+
const componentType = componentTypes[i];
|
|
341
|
+
const glslTextureSwizzle = getGlslTextureSwizzle(type, componentType);
|
|
342
|
+
shaderBuilder.addFunctionLines(functionId, [
|
|
343
|
+
`properties.${name} = texture2D(u_megatextureTextures[${i}], texcoord)${glslTextureSwizzle};`,
|
|
344
|
+
]);
|
|
345
|
+
}
|
|
346
|
+
shaderBuilder.addFunctionLines(functionId, [
|
|
347
|
+
`return ${propertiesFieldName};`,
|
|
348
|
+
]);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Converts a {@link MetadataType} to a GLSL type.
|
|
354
|
+
*
|
|
355
|
+
* @function
|
|
356
|
+
*
|
|
357
|
+
* @param {MetadataType} type The {@link MetadataType}.
|
|
358
|
+
* @returns {String} The GLSL type.
|
|
359
|
+
*
|
|
360
|
+
* @private
|
|
361
|
+
*/
|
|
362
|
+
function getGlslType(type) {
|
|
363
|
+
if (type === MetadataType.SCALAR) {
|
|
364
|
+
return "float";
|
|
365
|
+
} else if (type === MetadataType.VEC2) {
|
|
366
|
+
return "vec2";
|
|
367
|
+
} else if (type === MetadataType.VEC3) {
|
|
368
|
+
return "vec3";
|
|
369
|
+
} else if (type === MetadataType.VEC4) {
|
|
370
|
+
return "vec4";
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Gets the GLSL swizzle when reading data from a texture.
|
|
376
|
+
*
|
|
377
|
+
* @function
|
|
378
|
+
*
|
|
379
|
+
* @param {MetadataType} type The {@link MetadataType}.
|
|
380
|
+
* @returns {String} The GLSL swizzle.
|
|
381
|
+
*
|
|
382
|
+
* @private
|
|
383
|
+
*/
|
|
384
|
+
function getGlslTextureSwizzle(type) {
|
|
385
|
+
if (type === MetadataType.SCALAR) {
|
|
386
|
+
return ".r";
|
|
387
|
+
} else if (type === MetadataType.VEC2) {
|
|
388
|
+
return ".ra";
|
|
389
|
+
} else if (type === MetadataType.VEC3) {
|
|
390
|
+
return ".rgb";
|
|
391
|
+
} else if (type === MetadataType.VEC4) {
|
|
392
|
+
return "";
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Gets the GLSL type of the partial derivative of {@link MetadataType}.
|
|
398
|
+
*
|
|
399
|
+
* @function
|
|
400
|
+
*
|
|
401
|
+
* @param {MetadataType} type The {@link MetadataType}.
|
|
402
|
+
* @returns {String} The GLSL type.
|
|
403
|
+
*
|
|
404
|
+
* @private
|
|
405
|
+
*/
|
|
406
|
+
function getGlslPartialDerivativeType(type) {
|
|
407
|
+
if (type === MetadataType.SCALAR) {
|
|
408
|
+
return "vec3";
|
|
409
|
+
} else if (type === MetadataType.VEC2) {
|
|
410
|
+
return "mat2";
|
|
411
|
+
} else if (type === MetadataType.VEC3) {
|
|
412
|
+
return "mat3";
|
|
413
|
+
} else if (type === MetadataType.VEC4) {
|
|
414
|
+
return "mat4";
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* GLSL needs to have `.0` at the end of whole number floats or else it's
|
|
420
|
+
* treated like an integer.
|
|
421
|
+
*
|
|
422
|
+
* @function
|
|
423
|
+
*
|
|
424
|
+
* @param {Number} number The number to convert.
|
|
425
|
+
* @returns {String} The number as floating point in GLSL.
|
|
426
|
+
*
|
|
427
|
+
* @private
|
|
428
|
+
*/
|
|
429
|
+
function getGlslNumberAsFloat(number) {
|
|
430
|
+
let numberString = number.toString();
|
|
431
|
+
if (numberString.indexOf(".") === -1) {
|
|
432
|
+
numberString = `${number}.0`;
|
|
433
|
+
}
|
|
434
|
+
return numberString;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Gets the GLSL field
|
|
439
|
+
*
|
|
440
|
+
* @function
|
|
441
|
+
*
|
|
442
|
+
* @param {MetadataType} type
|
|
443
|
+
* @param {Number} index
|
|
444
|
+
* @returns {String}
|
|
445
|
+
*
|
|
446
|
+
* @private
|
|
447
|
+
*/
|
|
448
|
+
function getGlslField(type, index) {
|
|
449
|
+
if (type === MetadataType.SCALAR) {
|
|
450
|
+
return "";
|
|
451
|
+
}
|
|
452
|
+
return `[${index}]`;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
export default processVoxelProperties;
|
|
@@ -67,7 +67,7 @@ vec4 addScreenSpaceOffset(vec4 positionEC, vec2 imageSize, float scale, vec2 dir
|
|
|
67
67
|
float angle = rotation;
|
|
68
68
|
if (validAlignedAxis)
|
|
69
69
|
{
|
|
70
|
-
vec4 projectedAlignedAxis =
|
|
70
|
+
vec4 projectedAlignedAxis = czm_modelView3D * vec4(alignedAxis, 0.0);
|
|
71
71
|
angle += sign(-projectedAlignedAxis.x) * acos(sign(projectedAlignedAxis.y) * (projectedAlignedAxis.y * projectedAlignedAxis.y) /
|
|
72
72
|
(projectedAlignedAxis.x * projectedAlignedAxis.x + projectedAlignedAxis.y * projectedAlignedAxis.y));
|
|
73
73
|
}
|
|
@@ -68,7 +68,7 @@ vec4 addScreenSpaceOffset(vec4 positionEC, vec2 imageSize, float scale, vec2 dir
|
|
|
68
68
|
float angle = rotation;\n\
|
|
69
69
|
if (validAlignedAxis)\n\
|
|
70
70
|
{\n\
|
|
71
|
-
vec4 projectedAlignedAxis =
|
|
71
|
+
vec4 projectedAlignedAxis = czm_modelView3D * vec4(alignedAxis, 0.0);\n\
|
|
72
72
|
angle += sign(-projectedAlignedAxis.x) * acos(sign(projectedAlignedAxis.y) * (projectedAlignedAxis.y * projectedAlignedAxis.y) /\n\
|
|
73
73
|
(projectedAlignedAxis.x * projectedAlignedAxis.x + projectedAlignedAxis.y * projectedAlignedAxis.y));\n\
|
|
74
74
|
}\n\
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "/**\n\
|
|
3
|
+
* The automatic GLSL constant for {@link Pass#VOXELS}\n\
|
|
4
|
+
*\n\
|
|
5
|
+
* @name czm_passVoxels\n\
|
|
6
|
+
* @glslConstant\n\
|
|
7
|
+
*\n\
|
|
8
|
+
* @see czm_pass\n\
|
|
9
|
+
*/\n\
|
|
10
|
+
const float czm_passVoxels = 9.0;\n\
|
|
11
|
+
";
|