@cesium/engine 16.0.0 → 18.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Build/ThirdParty/Workers/z-worker-pako.js +1 -1
- package/Build/Workers/{chunk-OWLBD6BL.js → chunk-2AXPWBJG.js} +1 -1
- package/Build/Workers/{chunk-PB6SE3SZ.js → chunk-2CAYUY2B.js} +8 -8
- package/Build/Workers/{chunk-SCUQTTCN.js → chunk-2NKHPWDY.js} +12 -12
- package/Build/Workers/{chunk-YA4XALD5.js → chunk-2QNKQVUT.js} +5 -5
- package/Build/Workers/{chunk-WGIOUM2S.js → chunk-3RKVDGRF.js} +8 -8
- package/Build/Workers/{chunk-RWAFHSX3.js → chunk-4DSTDGY3.js} +2 -2
- package/Build/Workers/{chunk-YL26OJCG.js → chunk-4MIY63FM.js} +13 -13
- package/Build/Workers/{chunk-34EWMUFG.js → chunk-5OL6XFNS.js} +1 -1
- package/Build/Workers/{chunk-B75OO2DU.js → chunk-5WVF4BK7.js} +5 -5
- package/Build/Workers/{chunk-EAWYQ44R.js → chunk-AEGAQ6FD.js} +12 -12
- package/Build/Workers/{chunk-4LHK6E47.js → chunk-CES6DHHV.js} +1 -1
- package/Build/Workers/{chunk-S3IQBSIB.js → chunk-DINSLSJD.js} +6 -6
- package/Build/Workers/{chunk-KV6TEHXY.js → chunk-EHB2OCQX.js} +4 -4
- package/Build/Workers/{chunk-NREPBWCX.js → chunk-EXEZHW3P.js} +4 -4
- package/Build/Workers/{chunk-ICU72UPR.js → chunk-F4ZAKN4V.js} +2 -2
- package/Build/Workers/{chunk-S2NKKWYE.js → chunk-FPYBD2P5.js} +1 -1
- package/Build/Workers/{chunk-KKV6XBF5.js → chunk-GAUF4F5A.js} +16 -16
- package/Build/Workers/{chunk-ERKJ7IWJ.js → chunk-GM55YFOB.js} +14 -14
- package/Build/Workers/{chunk-NB6D74SQ.js → chunk-GS55WTRX.js} +6 -6
- package/Build/Workers/{chunk-5TN3LG2T.js → chunk-HQE7KSR4.js} +2 -2
- package/Build/Workers/{chunk-EO44CO62.js → chunk-HS76VTVY.js} +2 -2
- package/Build/Workers/{chunk-TL5YKZJF.js → chunk-I3BAKR4S.js} +16 -16
- package/Build/Workers/{chunk-OMFZ4IN6.js → chunk-IWGMVQGG.js} +9 -9
- package/Build/Workers/{chunk-VVTAI2TN.js → chunk-IWZK2AIH.js} +5 -5
- package/Build/Workers/{chunk-GQVSADCI.js → chunk-J4MAVE6J.js} +6 -6
- package/Build/Workers/{chunk-XF6EBVKV.js → chunk-JF4IYQYC.js} +7 -7
- package/Build/Workers/{chunk-CUJH7PS5.js → chunk-KGXTCGX3.js} +12 -12
- package/Build/Workers/{chunk-TBSA4MNF.js → chunk-KNA65INJ.js} +4 -4
- package/Build/Workers/{chunk-EOIUWEAK.js → chunk-LIPZUYNR.js} +11 -11
- package/Build/Workers/{chunk-TEUGW455.js → chunk-LWJWWCZ4.js} +6 -6
- package/Build/Workers/{chunk-ORIMMEHO.js → chunk-LZFUG3GO.js} +10 -10
- package/Build/Workers/{chunk-COOLDICB.js → chunk-MFGVMUN3.js} +5 -5
- package/Build/Workers/{chunk-FW2OX42E.js → chunk-NR7KSD56.js} +3 -3
- package/Build/Workers/{chunk-2TQ64T4I.js → chunk-NVJ5JRIM.js} +2 -2
- package/Build/Workers/{chunk-OMZGZVHI.js → chunk-NWSAYFZG.js} +6 -6
- package/Build/Workers/{chunk-PT6U7UNY.js → chunk-OATG6PKE.js} +12 -12
- package/Build/Workers/{chunk-M5J3S3HY.js → chunk-OIHAAHBK.js} +10 -10
- package/Build/Workers/{chunk-LCSH4ZOB.js → chunk-QN7JEOQV.js} +5 -5
- package/Build/Workers/{chunk-XMKE4XB2.js → chunk-QUSP3NWA.js} +5 -5
- package/Build/Workers/{chunk-ZLJDDRGB.js → chunk-RWFYLWSF.js} +9 -9
- package/Build/Workers/{chunk-OD4Q7HE5.js → chunk-SIOVJ4L5.js} +4 -4
- package/Build/Workers/{chunk-EJJDBH5W.js → chunk-T6B6H3GR.js} +7 -7
- package/Build/Workers/{chunk-YFXXUW6U.js → chunk-UK33ZN4K.js} +4 -4
- package/Build/Workers/{chunk-V4Y7C25O.js → chunk-VGJSKEIB.js} +4 -4
- package/Build/Workers/{chunk-VXAAIRJ7.js → chunk-W6CPO62M.js} +6 -6
- package/Build/Workers/{chunk-ILVAXLMC.js → chunk-WGHUCZMX.js} +7 -7
- package/Build/Workers/{chunk-GH6I7PBY.js → chunk-WTFZHPUW.js} +5 -5
- package/Build/Workers/{chunk-VNDECE6N.js → chunk-WYCR5DWQ.js} +2 -2
- package/Build/Workers/{chunk-6B7KGA5P.js → chunk-YV37YFUM.js} +9 -9
- package/Build/Workers/{chunk-CQNYYX3N.js → chunk-ZADJ6FRX.js} +4 -4
- package/Build/Workers/{chunk-ESED7XBA.js → chunk-ZIP27IX6.js} +6 -6
- package/Build/Workers/combineGeometry.js +21 -21
- package/Build/Workers/createBoxGeometry.js +15 -15
- package/Build/Workers/createBoxOutlineGeometry.js +13 -13
- package/Build/Workers/createCircleGeometry.js +23 -23
- package/Build/Workers/createCircleOutlineGeometry.js +16 -16
- package/Build/Workers/createCoplanarPolygonGeometry.js +30 -30
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +28 -28
- package/Build/Workers/createCorridorGeometry.js +26 -26
- package/Build/Workers/createCorridorOutlineGeometry.js +25 -25
- package/Build/Workers/createCylinderGeometry.js +17 -17
- package/Build/Workers/createCylinderOutlineGeometry.js +15 -15
- package/Build/Workers/createEllipseGeometry.js +23 -23
- package/Build/Workers/createEllipseOutlineGeometry.js +16 -16
- package/Build/Workers/createEllipsoidGeometry.js +16 -16
- package/Build/Workers/createEllipsoidOutlineGeometry.js +15 -15
- package/Build/Workers/createFrustumGeometry.js +15 -15
- package/Build/Workers/createFrustumOutlineGeometry.js +15 -15
- package/Build/Workers/createGeometry.js +21 -21
- package/Build/Workers/createGroundPolylineGeometry.js +19 -19
- package/Build/Workers/createPlaneGeometry.js +13 -13
- package/Build/Workers/createPlaneOutlineGeometry.js +12 -12
- package/Build/Workers/createPolygonGeometry.js +29 -29
- package/Build/Workers/createPolygonOutlineGeometry.js +27 -27
- package/Build/Workers/createPolylineGeometry.js +22 -22
- package/Build/Workers/createPolylineVolumeGeometry.js +28 -28
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +24 -24
- package/Build/Workers/createRectangleGeometry.js +24 -24
- package/Build/Workers/createRectangleOutlineGeometry.js +17 -17
- package/Build/Workers/createSimplePolylineGeometry.js +20 -20
- package/Build/Workers/createSphereGeometry.js +16 -16
- package/Build/Workers/createSphereOutlineGeometry.js +15 -15
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +12 -12
- package/Build/Workers/createVectorTileGeometries.js +21 -21
- package/Build/Workers/createVectorTilePoints.js +11 -11
- package/Build/Workers/createVectorTilePolygons.js +19 -19
- package/Build/Workers/createVectorTilePolylines.js +12 -12
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +19 -19
- package/Build/Workers/createVerticesFromHeightmap.js +19 -19
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +16 -16
- package/Build/Workers/createWallGeometry.js +21 -21
- package/Build/Workers/createWallOutlineGeometry.js +20 -20
- package/Build/Workers/decodeDraco.js +10 -10
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +9 -9
- package/Build/Workers/transcodeKTX2.js +25 -6
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +19 -19
- package/Source/Core/Check.d.ts +4 -1
- package/Source/Core/ITwinPlatform.js +6 -3
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/PixelFormat.js +36 -0
- package/Source/Core/PolygonGeometry.js +1 -0
- package/Source/Core/RectangleOutlineGeometry.js +1 -1
- package/Source/Renderer/Texture3D.js +568 -0
- package/Source/Renderer/createUniform.js +1 -0
- package/Source/Renderer/createUniformArray.js +1 -0
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Cesium3DTilesVoxelProvider.js +18 -23
- package/Source/Scene/Cesium3DTileset.js +138 -0
- package/Source/Scene/GlobeSurfaceShaderSet.js +4 -5
- package/Source/Scene/ImageryLayer.js +21 -6
- package/Source/Scene/ImageryLayerCollection.js +3 -2
- package/Source/Scene/Model/CartesianRectangle.js +108 -0
- package/Source/Scene/Model/ImageryConfiguration.js +25 -0
- package/Source/Scene/Model/ImageryCoverage.js +488 -0
- package/Source/Scene/Model/ImageryFlags.js +31 -0
- package/Source/Scene/Model/ImageryInput.js +60 -0
- package/Source/Scene/Model/ImageryPipelineStage.js +1040 -0
- package/Source/Scene/Model/MappedPositions.js +84 -0
- package/Source/Scene/Model/Model.js +38 -0
- package/Source/Scene/Model/ModelImagery.js +403 -0
- package/Source/Scene/Model/ModelImageryMapping.js +489 -0
- package/Source/Scene/Model/ModelPrimitiveImagery.js +972 -0
- package/Source/Scene/Model/ModelReader.js +810 -0
- package/Source/Scene/Model/ModelRenderResources.js +13 -0
- package/Source/Scene/Model/ModelRuntimePrimitive.js +19 -0
- package/Source/Scene/Model/ModelSceneGraph.js +133 -27
- package/Source/Scene/Model/NodeRenderResources.js +10 -0
- package/Source/Scene/ModelComponents.js +10 -0
- package/Source/Scene/QuadtreePrimitive.js +5 -1
- package/Source/Scene/VoxelBoxShape.js +38 -81
- package/Source/Scene/VoxelCylinderShape.js +128 -262
- package/Source/Scene/VoxelPrimitive.js +24 -39
- package/Source/Scene/VoxelRenderResources.js +1 -1
- package/Source/Scene/processVoxelProperties.js +41 -100
- package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.glsl +0 -1
- package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.js +0 -1
- package/Source/Shaders/GlobeFS.glsl +22 -0
- package/Source/Shaders/GlobeFS.js +22 -0
- package/Source/Shaders/Model/MaterialStageFS.glsl +4 -0
- package/Source/Shaders/Model/MaterialStageFS.js +4 -0
- package/Source/Shaders/Model/ModelVS.glsl +4 -0
- package/Source/Shaders/Model/ModelVS.js +4 -0
- package/Source/Shaders/PolylineCommon.glsl +1 -1
- package/Source/Shaders/PolylineCommon.js +1 -1
- package/Source/Shaders/Voxels/IntersectDepth.glsl +10 -3
- package/Source/Shaders/Voxels/IntersectDepth.js +10 -3
- package/Source/Shaders/Voxels/Intersection.glsl +1 -3
- package/Source/Shaders/Voxels/Intersection.js +1 -3
- package/Source/Shaders/Voxels/IntersectionUtils.glsl +1 -0
- package/Source/Shaders/Voxels/IntersectionUtils.js +1 -0
- package/Source/Shaders/Voxels/VoxelFS.glsl +37 -24
- package/Source/Shaders/Voxels/VoxelFS.js +37 -24
- package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
- package/index.d.ts +59 -7
- package/index.js +74 -62
- package/package.json +3 -3
|
@@ -0,0 +1,568 @@
|
|
|
1
|
+
import Cartesian3 from "../Core/Cartesian3.js";
|
|
2
|
+
import Check from "../Core/Check.js";
|
|
3
|
+
import createGuid from "../Core/createGuid.js";
|
|
4
|
+
import Frozen from "../Core/Frozen.js";
|
|
5
|
+
import defined from "../Core/defined.js";
|
|
6
|
+
import destroyObject from "../Core/destroyObject.js";
|
|
7
|
+
import DeveloperError from "../Core/DeveloperError.js";
|
|
8
|
+
import PixelFormat from "../Core/PixelFormat.js";
|
|
9
|
+
import ContextLimits from "./ContextLimits.js";
|
|
10
|
+
import MipmapHint from "./MipmapHint.js";
|
|
11
|
+
import PixelDatatype from "./PixelDatatype.js";
|
|
12
|
+
import Sampler from "./Sampler.js";
|
|
13
|
+
import TextureMagnificationFilter from "./TextureMagnificationFilter.js";
|
|
14
|
+
import TextureMinificationFilter from "./TextureMinificationFilter.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {object} Texture3D.ConstructorOptions
|
|
18
|
+
*
|
|
19
|
+
* @property {Context} context
|
|
20
|
+
* @property {object} [source] The source for texel values to be loaded into the texture3D.
|
|
21
|
+
* @property {PixelFormat} [pixelFormat=PixelFormat.RGBA] The format of each pixel, i.e., the number of components it has and what they represent.
|
|
22
|
+
* @property {PixelDatatype} [pixelDatatype=PixelDatatype.UNSIGNED_BYTE] The data type of each pixel.
|
|
23
|
+
* @property {boolean} [flipY=true] If true, the source values will be read as if the y-axis is inverted (y=0 at the top).
|
|
24
|
+
* @property {boolean} [skipColorSpaceConversion=false] If true, color space conversions will be skipped when reading the texel values.
|
|
25
|
+
* @property {Sampler} [sampler] Information about how to sample the texture3D.
|
|
26
|
+
* @property {number} [width] The pixel width of the texture3D. If not supplied, must be available from the source.
|
|
27
|
+
* @property {number} [height] The pixel height of the texture3D. If not supplied, must be available from the source.
|
|
28
|
+
* @property {number} [depth] The pixel depth of the texture3D. If not supplied, must be available from the source.
|
|
29
|
+
* @property {boolean} [preMultiplyAlpha] If true, the alpha channel will be multiplied into the other channels.
|
|
30
|
+
* @property {string} [id] A unique identifier for the texture3D. If this is not given, then a GUID will be created.
|
|
31
|
+
*
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A wrapper for a {@link https://developer.mozilla.org/en-US/docs/Web/API/WebGLTexture|WebGLTexture}
|
|
37
|
+
* to abstract away the verbose GL calls associated with setting up a texture3D.
|
|
38
|
+
*
|
|
39
|
+
* @alias Texture3D
|
|
40
|
+
* @constructor
|
|
41
|
+
*
|
|
42
|
+
* @param {Texture3D.ConstructorOptions} options
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
function Texture3D(options) {
|
|
46
|
+
options = options ?? Frozen.EMPTY_OBJECT;
|
|
47
|
+
|
|
48
|
+
//>>includeStart('debug', pragmas.debug);
|
|
49
|
+
Check.defined("options.context", options.context);
|
|
50
|
+
//>>includeEnd('debug');
|
|
51
|
+
|
|
52
|
+
const {
|
|
53
|
+
context,
|
|
54
|
+
source,
|
|
55
|
+
pixelFormat = PixelFormat.RGBA,
|
|
56
|
+
pixelDatatype = PixelDatatype.UNSIGNED_BYTE,
|
|
57
|
+
flipY = true,
|
|
58
|
+
skipColorSpaceConversion = false,
|
|
59
|
+
sampler = new Sampler(),
|
|
60
|
+
} = options;
|
|
61
|
+
|
|
62
|
+
if (!context.webgl2) {
|
|
63
|
+
throw new DeveloperError(
|
|
64
|
+
"WebGL1 does not support texture3D. Please use a WebGL2 context.",
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let { width, height, depth } = options;
|
|
69
|
+
if (defined(source)) {
|
|
70
|
+
// Make sure we are using the element's intrinsic width and height where available
|
|
71
|
+
if (!defined(width)) {
|
|
72
|
+
width = source.width;
|
|
73
|
+
}
|
|
74
|
+
if (!defined(height)) {
|
|
75
|
+
height = source.height;
|
|
76
|
+
}
|
|
77
|
+
// depth is not used for 2D textures, but is required for 3D textures
|
|
78
|
+
if (!defined(depth)) {
|
|
79
|
+
depth = source.depth;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Use premultiplied alpha for opaque textures should perform better on Chrome:
|
|
84
|
+
// http://media.tojicode.com/webglCamp4/#20
|
|
85
|
+
const preMultiplyAlpha =
|
|
86
|
+
options.preMultiplyAlpha ||
|
|
87
|
+
pixelFormat === PixelFormat.RGB ||
|
|
88
|
+
pixelFormat === PixelFormat.LUMINANCE;
|
|
89
|
+
|
|
90
|
+
const internalFormat = PixelFormat.toInternalFormat(
|
|
91
|
+
pixelFormat,
|
|
92
|
+
pixelDatatype,
|
|
93
|
+
context,
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const isCompressed = PixelFormat.isCompressedFormat(internalFormat);
|
|
97
|
+
|
|
98
|
+
//>>includeStart('debug', pragmas.debug);
|
|
99
|
+
if (!defined(width) || !defined(height) || !defined(depth)) {
|
|
100
|
+
throw new DeveloperError(
|
|
101
|
+
"options requires a source field to create an initialized texture3D or width, height and depth fields to create a blank texture3D.",
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
Check.typeOf.number.greaterThan("width", width, 0);
|
|
106
|
+
|
|
107
|
+
if (width > ContextLimits.maximumTextureSize) {
|
|
108
|
+
throw new DeveloperError(
|
|
109
|
+
`Width must be less than or equal to the maximum texture3D size (${ContextLimits.maximumTextureSize}). Check maximumTextureSize.`,
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
Check.typeOf.number.greaterThan("height", height, 0);
|
|
114
|
+
|
|
115
|
+
if (height > ContextLimits.maximumTextureSize) {
|
|
116
|
+
throw new DeveloperError(
|
|
117
|
+
`Height must be less than or equal to the maximum texture3D size (${ContextLimits.maximumTextureSize}). Check maximumTextureSize.`,
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
Check.typeOf.number.greaterThan("depth", depth, 0);
|
|
122
|
+
|
|
123
|
+
if (depth > ContextLimits.maximumTextureSize) {
|
|
124
|
+
throw new DeveloperError(
|
|
125
|
+
`Depth must be less than or equal to the maximum texture3D size (${ContextLimits.maximumTextureSize}). Check maximumTextureSize.`,
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (!PixelFormat.validate(pixelFormat)) {
|
|
130
|
+
throw new DeveloperError("Invalid options.pixelFormat.");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (!isCompressed && !PixelDatatype.validate(pixelDatatype)) {
|
|
134
|
+
throw new DeveloperError("Invalid options.pixelDatatype.");
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (
|
|
138
|
+
pixelFormat === PixelFormat.DEPTH_COMPONENT &&
|
|
139
|
+
pixelDatatype !== PixelDatatype.UNSIGNED_SHORT &&
|
|
140
|
+
pixelDatatype !== PixelDatatype.UNSIGNED_INT
|
|
141
|
+
) {
|
|
142
|
+
throw new DeveloperError(
|
|
143
|
+
"When options.pixelFormat is DEPTH_COMPONENT, options.pixelDatatype must be UNSIGNED_SHORT or UNSIGNED_INT.",
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (
|
|
148
|
+
pixelFormat === PixelFormat.DEPTH_STENCIL &&
|
|
149
|
+
pixelDatatype !== PixelDatatype.UNSIGNED_INT_24_8
|
|
150
|
+
) {
|
|
151
|
+
throw new DeveloperError(
|
|
152
|
+
"When options.pixelFormat is DEPTH_STENCIL, options.pixelDatatype must be UNSIGNED_INT_24_8.",
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (pixelDatatype === PixelDatatype.FLOAT && !context.floatingPointTexture) {
|
|
157
|
+
throw new DeveloperError(
|
|
158
|
+
"When options.pixelDatatype is FLOAT, this WebGL implementation must support the OES_texture_float extension. Check context.floatingPointTexture.",
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (
|
|
163
|
+
pixelDatatype === PixelDatatype.HALF_FLOAT &&
|
|
164
|
+
!context.halfFloatingPointTexture
|
|
165
|
+
) {
|
|
166
|
+
throw new DeveloperError(
|
|
167
|
+
"When options.pixelDatatype is HALF_FLOAT, this WebGL implementation must support the OES_texture_half_float extension. Check context.halfFloatingPointTexture.",
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (PixelFormat.isDepthFormat(pixelFormat)) {
|
|
172
|
+
if (defined(source)) {
|
|
173
|
+
throw new DeveloperError(
|
|
174
|
+
"When options.pixelFormat is DEPTH_COMPONENT or DEPTH_STENCIL, source cannot be provided.",
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (!context.depthTexture) {
|
|
179
|
+
throw new DeveloperError(
|
|
180
|
+
"When options.pixelFormat is DEPTH_COMPONENT or DEPTH_STENCIL, this WebGL implementation must support WEBGL_depth_texture. Check context.depthTexture.",
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (isCompressed) {
|
|
186
|
+
throw new DeveloperError(
|
|
187
|
+
"Texture3D does not currently support compressed formats.",
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
//>>includeEnd('debug');
|
|
191
|
+
|
|
192
|
+
const gl = context._gl;
|
|
193
|
+
|
|
194
|
+
const sizeInBytes = PixelFormat.texture3DSizeInBytes(
|
|
195
|
+
pixelFormat,
|
|
196
|
+
pixelDatatype,
|
|
197
|
+
width,
|
|
198
|
+
height,
|
|
199
|
+
depth,
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
this._id = options.id ?? createGuid();
|
|
203
|
+
this._context = context;
|
|
204
|
+
this._textureFilterAnisotropic = context._textureFilterAnisotropic;
|
|
205
|
+
this._textureTarget = gl.TEXTURE_3D;
|
|
206
|
+
this._texture = gl.createTexture();
|
|
207
|
+
this._internalFormat = internalFormat;
|
|
208
|
+
this._pixelFormat = pixelFormat;
|
|
209
|
+
this._pixelDatatype = pixelDatatype;
|
|
210
|
+
this._width = width;
|
|
211
|
+
this._height = height;
|
|
212
|
+
this._depth = depth;
|
|
213
|
+
this._dimensions = new Cartesian3(width, height, depth);
|
|
214
|
+
this._hasMipmap = false;
|
|
215
|
+
this._sizeInBytes = sizeInBytes;
|
|
216
|
+
this._preMultiplyAlpha = preMultiplyAlpha;
|
|
217
|
+
this._flipY = flipY;
|
|
218
|
+
this._initialized = false;
|
|
219
|
+
this._sampler = undefined;
|
|
220
|
+
|
|
221
|
+
this._sampler = sampler;
|
|
222
|
+
setupSampler(this, sampler);
|
|
223
|
+
|
|
224
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
225
|
+
gl.bindTexture(this._textureTarget, this._texture);
|
|
226
|
+
|
|
227
|
+
if (defined(source)) {
|
|
228
|
+
if (skipColorSpaceConversion) {
|
|
229
|
+
gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE);
|
|
230
|
+
} else {
|
|
231
|
+
gl.pixelStorei(
|
|
232
|
+
gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,
|
|
233
|
+
gl.BROWSER_DEFAULT_WEBGL,
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
if (!defined(source.arrayBufferView)) {
|
|
237
|
+
throw new DeveloperError(
|
|
238
|
+
"For Texture3D, options.source.arrayBufferView must be defined",
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
loadBufferSource(this, source);
|
|
243
|
+
|
|
244
|
+
this._initialized = true;
|
|
245
|
+
} else {
|
|
246
|
+
loadNull(this);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
gl.bindTexture(this._textureTarget, null);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Load texel data from a buffer into a texture3D.
|
|
254
|
+
*
|
|
255
|
+
* @param {Texture3D} texture3D The texture3D to which texel values will be loaded.
|
|
256
|
+
* @param {object} source The source for texel values to be loaded into the texture3D.
|
|
257
|
+
*
|
|
258
|
+
* @private
|
|
259
|
+
*/
|
|
260
|
+
function loadBufferSource(texture3D, source) {
|
|
261
|
+
const context = texture3D._context;
|
|
262
|
+
const gl = context._gl;
|
|
263
|
+
const textureTarget = texture3D._textureTarget;
|
|
264
|
+
const internalFormat = texture3D._internalFormat;
|
|
265
|
+
|
|
266
|
+
const { width, height, depth, pixelFormat, pixelDatatype, flipY } = texture3D;
|
|
267
|
+
|
|
268
|
+
const unpackAlignment = PixelFormat.alignmentInBytes(
|
|
269
|
+
pixelFormat,
|
|
270
|
+
pixelDatatype,
|
|
271
|
+
width,
|
|
272
|
+
);
|
|
273
|
+
gl.pixelStorei(gl.UNPACK_ALIGNMENT, unpackAlignment);
|
|
274
|
+
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
|
|
275
|
+
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
276
|
+
|
|
277
|
+
const { arrayBufferView } = source;
|
|
278
|
+
if (flipY) {
|
|
279
|
+
console.warn("texture3D.flipY is not supported.");
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
let levels = 1;
|
|
283
|
+
if (source.mipLevels && source.mipLevels.length) {
|
|
284
|
+
levels = source.mipLevels.length + 1;
|
|
285
|
+
}
|
|
286
|
+
gl.texStorage3D(textureTarget, levels, internalFormat, width, height, depth);
|
|
287
|
+
|
|
288
|
+
gl.texSubImage3D(
|
|
289
|
+
textureTarget,
|
|
290
|
+
0,
|
|
291
|
+
0,
|
|
292
|
+
0,
|
|
293
|
+
0,
|
|
294
|
+
width,
|
|
295
|
+
height,
|
|
296
|
+
depth,
|
|
297
|
+
pixelFormat,
|
|
298
|
+
PixelDatatype.toWebGLConstant(pixelDatatype, context),
|
|
299
|
+
arrayBufferView,
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
if (levels > 1) {
|
|
303
|
+
let mipWidth = width;
|
|
304
|
+
let mipHeight = height;
|
|
305
|
+
let mipDepth = depth;
|
|
306
|
+
for (let i = 0; i < source.mipLevels.length; ++i) {
|
|
307
|
+
mipWidth = nextMipSize(mipWidth);
|
|
308
|
+
mipHeight = nextMipSize(mipHeight);
|
|
309
|
+
mipDepth = nextMipSize(mipDepth);
|
|
310
|
+
gl.texSubImage3D(
|
|
311
|
+
textureTarget,
|
|
312
|
+
i + 1,
|
|
313
|
+
0,
|
|
314
|
+
0,
|
|
315
|
+
0,
|
|
316
|
+
mipWidth,
|
|
317
|
+
mipHeight,
|
|
318
|
+
mipDepth,
|
|
319
|
+
pixelFormat,
|
|
320
|
+
PixelDatatype.toWebGLConstant(pixelDatatype, context),
|
|
321
|
+
source.mipLevels[i],
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Compute a dimension of the image for the next mip level.
|
|
329
|
+
*
|
|
330
|
+
* @param {number} currentSize The size of the current mip level.
|
|
331
|
+
* @returns {number} The size of the next mip level.
|
|
332
|
+
*
|
|
333
|
+
* @private
|
|
334
|
+
*/
|
|
335
|
+
function nextMipSize(currentSize) {
|
|
336
|
+
const nextSize = Math.floor(currentSize / 2) | 0;
|
|
337
|
+
return Math.max(nextSize, 1);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Allocate a texture3D in GPU memory, without providing any image data.
|
|
342
|
+
*
|
|
343
|
+
* @param {Texture3D} texture3D The texture3D to be initialized with null values.
|
|
344
|
+
*
|
|
345
|
+
* @private
|
|
346
|
+
*/
|
|
347
|
+
function loadNull(texture3D) {
|
|
348
|
+
const context = texture3D._context;
|
|
349
|
+
|
|
350
|
+
context._gl.texImage3D(
|
|
351
|
+
texture3D._textureTarget,
|
|
352
|
+
0,
|
|
353
|
+
texture3D._internalFormat,
|
|
354
|
+
texture3D._width,
|
|
355
|
+
texture3D._height,
|
|
356
|
+
texture3D._depth,
|
|
357
|
+
0,
|
|
358
|
+
texture3D._pixelFormat,
|
|
359
|
+
PixelDatatype.toWebGLConstant(texture3D._pixelDatatype, context),
|
|
360
|
+
null,
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* This function is identical to using the Texture3D constructor except that it can be
|
|
366
|
+
* replaced with a mock/spy in tests.
|
|
367
|
+
* @private
|
|
368
|
+
*/
|
|
369
|
+
Texture3D.create = function (options) {
|
|
370
|
+
return new Texture3D(options);
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
Object.defineProperties(Texture3D.prototype, {
|
|
374
|
+
/**
|
|
375
|
+
* A unique id for the texture3D
|
|
376
|
+
* @memberof Texture3D.prototype
|
|
377
|
+
* @type {string}
|
|
378
|
+
* @readonly
|
|
379
|
+
* @private
|
|
380
|
+
*/
|
|
381
|
+
id: {
|
|
382
|
+
get: function () {
|
|
383
|
+
return this._id;
|
|
384
|
+
},
|
|
385
|
+
},
|
|
386
|
+
/**
|
|
387
|
+
* The sampler to use when sampling this texture3D.
|
|
388
|
+
* Create a sampler by calling {@link Sampler}. If this
|
|
389
|
+
* parameter is not specified, a default sampler is used. The default sampler clamps texture3D
|
|
390
|
+
* coordinates in both directions, uses linear filtering for both magnification and minification,
|
|
391
|
+
* and uses a maximum anisotropy of 1.0.
|
|
392
|
+
* @memberof Texture3D.prototype
|
|
393
|
+
* @type {Sampler}
|
|
394
|
+
* @private
|
|
395
|
+
*/
|
|
396
|
+
sampler: {
|
|
397
|
+
get: function () {
|
|
398
|
+
return this._sampler;
|
|
399
|
+
},
|
|
400
|
+
set: function (sampler) {
|
|
401
|
+
setupSampler(this, sampler);
|
|
402
|
+
this._sampler = sampler;
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
pixelFormat: {
|
|
406
|
+
get: function () {
|
|
407
|
+
return this._pixelFormat;
|
|
408
|
+
},
|
|
409
|
+
},
|
|
410
|
+
pixelDatatype: {
|
|
411
|
+
get: function () {
|
|
412
|
+
return this._pixelDatatype;
|
|
413
|
+
},
|
|
414
|
+
},
|
|
415
|
+
dimensions: {
|
|
416
|
+
get: function () {
|
|
417
|
+
return this._dimensions;
|
|
418
|
+
},
|
|
419
|
+
},
|
|
420
|
+
preMultiplyAlpha: {
|
|
421
|
+
get: function () {
|
|
422
|
+
return this._preMultiplyAlpha;
|
|
423
|
+
},
|
|
424
|
+
},
|
|
425
|
+
flipY: {
|
|
426
|
+
get: function () {
|
|
427
|
+
return this._flipY;
|
|
428
|
+
},
|
|
429
|
+
},
|
|
430
|
+
width: {
|
|
431
|
+
get: function () {
|
|
432
|
+
return this._width;
|
|
433
|
+
},
|
|
434
|
+
},
|
|
435
|
+
height: {
|
|
436
|
+
get: function () {
|
|
437
|
+
return this._height;
|
|
438
|
+
},
|
|
439
|
+
},
|
|
440
|
+
depth: {
|
|
441
|
+
get: function () {
|
|
442
|
+
return this._depth;
|
|
443
|
+
},
|
|
444
|
+
},
|
|
445
|
+
sizeInBytes: {
|
|
446
|
+
get: function () {
|
|
447
|
+
if (this._hasMipmap) {
|
|
448
|
+
return Math.floor((this._sizeInBytes * 8) / 7);
|
|
449
|
+
}
|
|
450
|
+
return this._sizeInBytes;
|
|
451
|
+
},
|
|
452
|
+
},
|
|
453
|
+
_target: {
|
|
454
|
+
get: function () {
|
|
455
|
+
return this._textureTarget;
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Set up a sampler for use with a texture3D
|
|
462
|
+
* @param {Texture3D} texture3D The texture3D to be sampled by this sampler
|
|
463
|
+
* @param {Sampler} sampler Information about how to sample the texture3D
|
|
464
|
+
* @private
|
|
465
|
+
*/
|
|
466
|
+
function setupSampler(texture3D, sampler) {
|
|
467
|
+
let { minificationFilter, magnificationFilter } = sampler;
|
|
468
|
+
|
|
469
|
+
const mipmap = [
|
|
470
|
+
TextureMinificationFilter.NEAREST_MIPMAP_NEAREST,
|
|
471
|
+
TextureMinificationFilter.NEAREST_MIPMAP_LINEAR,
|
|
472
|
+
TextureMinificationFilter.LINEAR_MIPMAP_NEAREST,
|
|
473
|
+
TextureMinificationFilter.LINEAR_MIPMAP_LINEAR,
|
|
474
|
+
].includes(minificationFilter);
|
|
475
|
+
|
|
476
|
+
const context = texture3D._context;
|
|
477
|
+
const pixelFormat = texture3D._pixelFormat;
|
|
478
|
+
const pixelDatatype = texture3D._pixelDatatype;
|
|
479
|
+
|
|
480
|
+
// float textures only support nearest filtering unless the linear extensions are supported
|
|
481
|
+
if (
|
|
482
|
+
(pixelDatatype === PixelDatatype.FLOAT && !context.textureFloatLinear) ||
|
|
483
|
+
(pixelDatatype === PixelDatatype.HALF_FLOAT &&
|
|
484
|
+
!context.textureHalfFloatLinear)
|
|
485
|
+
) {
|
|
486
|
+
// override the sampler's settings
|
|
487
|
+
minificationFilter = mipmap
|
|
488
|
+
? TextureMinificationFilter.NEAREST_MIPMAP_NEAREST
|
|
489
|
+
: TextureMinificationFilter.NEAREST;
|
|
490
|
+
magnificationFilter = TextureMagnificationFilter.NEAREST;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// WebGL 2 depth texture3D only support nearest filtering. See section 3.8.13 OpenGL ES 3 spec
|
|
494
|
+
if (PixelFormat.isDepthFormat(pixelFormat)) {
|
|
495
|
+
minificationFilter = TextureMinificationFilter.NEAREST;
|
|
496
|
+
magnificationFilter = TextureMagnificationFilter.NEAREST;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
const gl = context._gl;
|
|
500
|
+
const target = texture3D._textureTarget;
|
|
501
|
+
|
|
502
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
503
|
+
gl.bindTexture(target, texture3D._texture);
|
|
504
|
+
gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, minificationFilter);
|
|
505
|
+
gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, magnificationFilter);
|
|
506
|
+
gl.texParameteri(target, gl.TEXTURE_WRAP_S, sampler.wrapS);
|
|
507
|
+
gl.texParameteri(target, gl.TEXTURE_WRAP_T, sampler.wrapT);
|
|
508
|
+
if (defined(texture3D._textureFilterAnisotropic)) {
|
|
509
|
+
gl.texParameteri(
|
|
510
|
+
target,
|
|
511
|
+
texture3D._textureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,
|
|
512
|
+
sampler.maximumAnisotropy,
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
gl.bindTexture(target, null);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* @param {MipmapHint} [hint=MipmapHint.DONT_CARE] optional.
|
|
520
|
+
* @private
|
|
521
|
+
* @exception {DeveloperError} Cannot call generateMipmap when the texture3D pixel format is DEPTH_COMPONENT or DEPTH_STENCIL.
|
|
522
|
+
* @exception {DeveloperError} Cannot call generateMipmap when the texture3D pixel format is a compressed format.
|
|
523
|
+
* @exception {DeveloperError} hint is invalid.
|
|
524
|
+
* @exception {DeveloperError} This texture3D's width must be a power of two to call generateMipmap() in a WebGL1 context.
|
|
525
|
+
* @exception {DeveloperError} This texture3D's height must be a power of two to call generateMipmap() in a WebGL1 context.
|
|
526
|
+
* @exception {DeveloperError} This texture3D was destroyed, i.e., destroy() was called.
|
|
527
|
+
*/
|
|
528
|
+
Texture3D.prototype.generateMipmap = function (hint) {
|
|
529
|
+
hint = hint ?? MipmapHint.DONT_CARE;
|
|
530
|
+
|
|
531
|
+
//>>includeStart('debug', pragmas.debug);
|
|
532
|
+
if (PixelFormat.isDepthFormat(this._pixelFormat)) {
|
|
533
|
+
throw new DeveloperError(
|
|
534
|
+
"Cannot call generateMipmap when the texture3D pixel format is DEPTH_COMPONENT or DEPTH_STENCIL.",
|
|
535
|
+
);
|
|
536
|
+
}
|
|
537
|
+
if (PixelFormat.isCompressedFormat(this._pixelFormat)) {
|
|
538
|
+
throw new DeveloperError(
|
|
539
|
+
"Cannot call generateMipmap with a compressed pixel format.",
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
if (!MipmapHint.validate(hint)) {
|
|
544
|
+
throw new DeveloperError("hint is invalid.");
|
|
545
|
+
}
|
|
546
|
+
//>>includeEnd('debug');
|
|
547
|
+
|
|
548
|
+
this._hasMipmap = true;
|
|
549
|
+
|
|
550
|
+
const gl = this._context._gl;
|
|
551
|
+
const target = this._textureTarget;
|
|
552
|
+
|
|
553
|
+
gl.hint(gl.GENERATE_MIPMAP_HINT, hint);
|
|
554
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
555
|
+
gl.bindTexture(target, this._texture);
|
|
556
|
+
gl.generateMipmap(target);
|
|
557
|
+
gl.bindTexture(target, null);
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
Texture3D.prototype.isDestroyed = function () {
|
|
561
|
+
return false;
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
Texture3D.prototype.destroy = function () {
|
|
565
|
+
this._context._gl.deleteTexture(this._texture);
|
|
566
|
+
return destroyObject(this);
|
|
567
|
+
};
|
|
568
|
+
export default Texture3D;
|
|
@@ -24,6 +24,7 @@ function createUniform(gl, activeUniform, uniformName, location) {
|
|
|
24
24
|
case gl.FLOAT_VEC4:
|
|
25
25
|
return new UniformFloatVec4(gl, activeUniform, uniformName, location);
|
|
26
26
|
case gl.SAMPLER_2D:
|
|
27
|
+
case gl.SAMPLER_3D:
|
|
27
28
|
case gl.SAMPLER_CUBE:
|
|
28
29
|
return new UniformSampler(gl, activeUniform, uniformName, location);
|
|
29
30
|
case gl.INT:
|
|
@@ -4,7 +4,7 @@ import Resource from "../Core/Resource.js";
|
|
|
4
4
|
|
|
5
5
|
let defaultTokenCredit;
|
|
6
6
|
const defaultAccessToken =
|
|
7
|
-
"
|
|
7
|
+
"AAPTxy8BH1VEsoebNVZXo8HurEOF051kAEKlhkOhBEc9BmTP0IZoWRBEdmOPutLUJ2JcHWgott0sjyyyJ6-Nu6O_MLmmkiswXG4qzrOMMu0N8VU2LUbsVXxF7KR041TgbHlgZPBYpt4LZXFH4jpS6NIBFm_JqZPzxLgFhbAYSs4yh_vDo1I7Qxr9dPzWiIPm5KHQ99Hs2uH4JH4356FxozccoIsuX2H4LyTBRUZ36FqFikI.AT1_FcZPNruQ";
|
|
8
8
|
/**
|
|
9
9
|
* Default options for accessing the ArcGIS image tile service.
|
|
10
10
|
*
|
|
@@ -9,6 +9,7 @@ import ImplicitSubtree from "./ImplicitSubtree.js";
|
|
|
9
9
|
import ImplicitSubtreeCache from "./ImplicitSubtreeCache.js";
|
|
10
10
|
import ImplicitTileCoordinates from "./ImplicitTileCoordinates.js";
|
|
11
11
|
import ImplicitTileset from "./ImplicitTileset.js";
|
|
12
|
+
import Matrix3 from "../Core/Matrix3.js";
|
|
12
13
|
import Matrix4 from "../Core/Matrix4.js";
|
|
13
14
|
import MetadataSemantic from "./MetadataSemantic.js";
|
|
14
15
|
import MetadataType from "./MetadataType.js";
|
|
@@ -17,7 +18,6 @@ import preprocess3DTileContent from "./preprocess3DTileContent.js";
|
|
|
17
18
|
import Resource from "../Core/Resource.js";
|
|
18
19
|
import ResourceCache from "./ResourceCache.js";
|
|
19
20
|
import RuntimeError from "../Core/RuntimeError.js";
|
|
20
|
-
import VoxelBoxShape from "./VoxelBoxShape.js";
|
|
21
21
|
import VoxelContent from "./VoxelContent.js";
|
|
22
22
|
import VoxelMetadataOrder from "./VoxelMetadataOrder.js";
|
|
23
23
|
import VoxelShapeType from "./VoxelShapeType.js";
|
|
@@ -411,6 +411,11 @@ Cesium3DTilesVoxelProvider.fromUrl = async function (url) {
|
|
|
411
411
|
|
|
412
412
|
const providerOptions = getAttributeInfo(tilesetMetadata, className);
|
|
413
413
|
Object.assign(providerOptions, getShape(root));
|
|
414
|
+
if (defined(root.transform)) {
|
|
415
|
+
providerOptions.globalTransform = Matrix4.unpack(root.transform);
|
|
416
|
+
} else {
|
|
417
|
+
providerOptions.globalTransform = Matrix4.clone(Matrix4.IDENTITY);
|
|
418
|
+
}
|
|
414
419
|
|
|
415
420
|
providerOptions.dimensions = Cartesian3.unpack(voxel.dimensions);
|
|
416
421
|
providerOptions.maximumTileCount = getTileCount(tilesetMetadata);
|
|
@@ -477,21 +482,13 @@ function validate(tileset) {
|
|
|
477
482
|
function getShape(tile) {
|
|
478
483
|
const boundingVolume = tile.boundingVolume;
|
|
479
484
|
|
|
480
|
-
let tileTransform;
|
|
481
|
-
if (defined(tile.transform)) {
|
|
482
|
-
tileTransform = Matrix4.unpack(tile.transform);
|
|
483
|
-
} else {
|
|
484
|
-
tileTransform = Matrix4.clone(Matrix4.IDENTITY);
|
|
485
|
-
}
|
|
486
|
-
|
|
487
485
|
if (defined(boundingVolume.box)) {
|
|
488
|
-
return getBoxShape(boundingVolume.box
|
|
486
|
+
return getBoxShape(boundingVolume.box);
|
|
489
487
|
} else if (defined(boundingVolume.region)) {
|
|
490
488
|
return getEllipsoidShape(boundingVolume.region);
|
|
491
489
|
} else if (hasExtension(boundingVolume, "3DTILES_bounding_volume_cylinder")) {
|
|
492
490
|
return getCylinderShape(
|
|
493
491
|
boundingVolume.extensions["3DTILES_bounding_volume_cylinder"],
|
|
494
|
-
tileTransform,
|
|
495
492
|
);
|
|
496
493
|
}
|
|
497
494
|
|
|
@@ -518,27 +515,26 @@ function getEllipsoidShape(region) {
|
|
|
518
515
|
minBounds: minBounds,
|
|
519
516
|
maxBounds: maxBounds,
|
|
520
517
|
shapeTransform: shapeTransform,
|
|
521
|
-
globalTransform: Matrix4.clone(Matrix4.IDENTITY),
|
|
522
518
|
};
|
|
523
519
|
}
|
|
524
520
|
|
|
525
|
-
|
|
521
|
+
const scratchScale = new Cartesian3();
|
|
522
|
+
const scratchRotation = new Matrix3();
|
|
523
|
+
|
|
524
|
+
function getBoxShape(box) {
|
|
526
525
|
const obb = OrientedBoundingBox.unpack(box);
|
|
527
|
-
const
|
|
528
|
-
|
|
529
|
-
obb.center,
|
|
530
|
-
);
|
|
526
|
+
const scale = Matrix3.getScale(obb.halfAxes, scratchScale);
|
|
527
|
+
const rotation = Matrix3.getRotation(obb.halfAxes, scratchRotation);
|
|
531
528
|
|
|
532
529
|
return {
|
|
533
530
|
shape: VoxelShapeType.BOX,
|
|
534
|
-
minBounds: Cartesian3.
|
|
535
|
-
maxBounds: Cartesian3.clone(
|
|
536
|
-
shapeTransform:
|
|
537
|
-
globalTransform: tileTransform,
|
|
531
|
+
minBounds: Cartesian3.negate(scale, new Cartesian3()),
|
|
532
|
+
maxBounds: Cartesian3.clone(scale),
|
|
533
|
+
shapeTransform: Matrix4.fromRotationTranslation(rotation, obb.center),
|
|
538
534
|
};
|
|
539
535
|
}
|
|
540
536
|
|
|
541
|
-
function getCylinderShape(cylinder
|
|
537
|
+
function getCylinderShape(cylinder) {
|
|
542
538
|
const {
|
|
543
539
|
minRadius,
|
|
544
540
|
maxRadius,
|
|
@@ -565,7 +561,7 @@ function getCylinderShape(cylinder, tileTransform) {
|
|
|
565
561
|
const shapeTransform = Matrix4.fromTranslationQuaternionRotationScale(
|
|
566
562
|
Cartesian3.unpack(translation),
|
|
567
563
|
Quaternion.unpack(rotation),
|
|
568
|
-
|
|
564
|
+
Cartesian3.ONE,
|
|
569
565
|
);
|
|
570
566
|
|
|
571
567
|
return {
|
|
@@ -573,7 +569,6 @@ function getCylinderShape(cylinder, tileTransform) {
|
|
|
573
569
|
minBounds: Cartesian3.fromElements(minRadius, minAngle, minHeight),
|
|
574
570
|
maxBounds: Cartesian3.fromElements(maxRadius, maxAngle, maxHeight),
|
|
575
571
|
shapeTransform: shapeTransform,
|
|
576
|
-
globalTransform: tileTransform,
|
|
577
572
|
};
|
|
578
573
|
}
|
|
579
574
|
|