Skip to content

Fix glTF voxel ordering for ellipsoid shapes #12544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
{
"tileAvailability": {
"availableCount": 1,
"constant": 1
},
"contentAvailability": {
"availableCount": 1,
"contentAvailability": [{
"constant": 1
},
}],
"childSubtreeAvailability": {
"availableCount": 0,
"constant": 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,40 @@
"asset": {
"version": "2.0"
},
"extensionsUsed": [
"EXT_primitive_voxels",
"EXT_structural_metadata"
],
"extensionsRequired": [
"EXT_primitive_voxels",
"EXT_structural_metadata"
],
"extensions": {
"EXT_structural_metadata": {
"schema": {
"classes": {
"voxel": {
"properties": {
"a": {
"type": "VEC4",
"componentType": "FLOAT32"
}
}
}
}
},
"propertyAttributes": [
{
"class": "voxel",
"properties": {
"a": {
"attribute": "_DATA"
}
}
}
]
}
},
"scene": 0,
"scenes": [
{
Expand All @@ -19,82 +53,53 @@
{
"primitives": [
{
"mode": 2147483649,
"attributes": {
"_a": 0
"_DATA": 0
},
"mode": 2147483647,
"extensions": {
"EXT_primitive_voxels": {
"shape": 0,
"dimensions": [
2,
2,
2
],
"bounds": {
"min": [
0.0,
0.0,
-1.0
],
"max": [
1.0,
1.0,
0.0
]
}
]
},
"EXT_structural_metadata": {
"propertyAttributes": [0]
}
}
}
]
}
],
"extensionsUsed": [
"EXT_primitive_voxels",
"EXT_structural_metadata"
],
"extensionsRequired": [
"EXT_primitive_voxels",
"EXT_structural_metadata"
],
"extensions": {
"EXT_structural_metadata": {
"schemaUri": "../../../../schema.json",
"propertyAttributes": [
{
"class": "voxel",
"properties": {
"a": {
"attribute": "_a"
}
}
}
]
}
},
"accessors": [
{
"bufferView": 0,
"type": "SCALAR",
"byteOffset": 0,
"componentType": 5126,
"min": [
0.0
],
"count": 8,
"max": [
1.0
1.0, 1.0, 1.0, 1.0
],
"min": [
0.0, 0.0, 0.0, 0.0
],
"count": 8
"type": "VEC4"
}
],
"bufferViews": [
{
"buffer": 0,
"byteLength": 32
"byteOffset": 0,
"byteLength": 128
}
],
"buffers": [
{
"uri": "a.bin",
"byteLength": 32
"byteLength": 128
}
]
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@
"asset": {
"version": "1.1"
},
"schemaUri": "schema.json",
"schema": {
"id": "voxel",
"classes": {
"voxel": {
"properties": {
"a": {
"type": "VEC4",
"componentType": "FLOAT32"
}
}
}
}
},
"statistics": {
"classes": {
"voxel": {
Expand All @@ -28,7 +40,7 @@
500000.0
]
},
"geometricError": 0.0,
"geometricError": 16.0,
"refine": "REPLACE",
"content": {
"uri": "tiles/{level}/{x}/{y}/{z}.gltf",
Expand All @@ -45,7 +57,7 @@
},
"implicitTiling": {
"subdivisionScheme": "OCTREE",
"subtreeLevels": 3,
"subtreeLevels": 1,
"availableLevels": 1,
"subtrees": {
"uri": "subtrees/{level}/{x}/{y}/{z}.json"
Expand Down
18 changes: 5 additions & 13 deletions Apps/Sandcastle/gallery/Voxels in 3D Tiles.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@
viewer.extend(Cesium.viewerVoxelInspectorMixin);
viewer.scene.debugShowFramesPerSecond = true;

const customShaderWhite = new Cesium.CustomShader({
fragmentShaderText: `void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material)
{
material.diffuse = vec3(1.0);
material.alpha = 1.0;
}`,
});

const customShaderColor = new Cesium.CustomShader({
fragmentShaderText: `void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material)
{
Expand All @@ -60,13 +52,13 @@
}`,
});

function createPrimitive(provider, customShader) {
function createPrimitive(provider) {
viewer.scene.primitives.removeAll();

const voxelPrimitive = viewer.scene.primitives.add(
new Cesium.VoxelPrimitive({
provider: provider,
customShader: customShader,
customShader: customShaderColor,
}),
);

Expand All @@ -87,7 +79,7 @@
const provider = await Cesium.Cesium3DTilesVoxelProvider.fromUrl(
"../../SampleData/Cesium3DTiles/Voxel/VoxelBox3DTiles/tileset.json",
);
const primitive = createPrimitive(provider, customShaderColor);
const primitive = createPrimitive(provider);
},
},
{
Expand All @@ -96,7 +88,7 @@
const provider = await Cesium.Cesium3DTilesVoxelProvider.fromUrl(
"../../SampleData/Cesium3DTiles/Voxel/VoxelCylinder3DTiles/tileset.json",
);
const primitive = createPrimitive(provider, customShaderColor);
const primitive = createPrimitive(provider);
},
},
{
Expand All @@ -105,7 +97,7 @@
const provider = await Cesium.Cesium3DTilesVoxelProvider.fromUrl(
"../../SampleData/Cesium3DTiles/Voxel/VoxelEllipsoid3DTiles/tileset.json",
);
const primitive = createPrimitive(provider, customShaderWhite);
const primitive = createPrimitive(provider);
},
},
]);
Expand Down
Binary file modified Apps/Sandcastle/gallery/Voxels in 3D Tiles.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#### Breaking Changes :mega:

- `Camera.getPickRay` was erroneously returning a result in camera coordinates. It is now returned in world coordinates as stated in the documentation. The result can be transformed using `Camera.inverseViewMatrix` to achieve the previous behavior.
- `VoxelMetadataOrder` has been made private, and the `metadataOrder` property has been removed from the `VoxelProvider` interface.

#### Additions :tada:

Expand All @@ -23,6 +24,7 @@
- Fixed camera zooming in 3D orthographic mode when pixelRatio is not 1. [#12487](https://github.com/CesiumGS/cesium/pull/12487)
- Fixed VaryingType.MAT3: "mat2" significant typo. [#12524](https://github.com/CesiumGS/cesium/issues/12524)
- Fixed shape bounds and transforms for cylinder-shaped voxels. [#12522](https://github.com/CesiumGS/cesium/pull/12522)
- Fixed metadata ordering for ellipsoid voxel tilesets. [#12544](https://github.com/CesiumGS/cesium/pull/12544)
- Fixed an issue where clamped entities' height updates could stall when using high-resolution terrain due to a growing queue of tiles in `updateHeights` in `QuadtreePrimitive`. [#12476](https://github.com/CesiumGS/cesium/issues/12476)

## 1.127 - 2025-03-03
Expand Down
6 changes: 5 additions & 1 deletion packages/engine/Source/Scene/Cesium3DTilesVoxelProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ function Cesium3DTilesVoxelProvider(options) {
this._names = names;
this._types = types;
this._componentTypes = componentTypes;
this._metadataOrder = VoxelMetadataOrder.GLTF;
this._metadataOrder =
shape === VoxelShapeType.ELLIPSOID
? VoxelMetadataOrder.Z_UP
: VoxelMetadataOrder.Y_UP;
this._minimumValues = minimumValues;
this._maximumValues = maximumValues;
this._maximumTileCount = maximumTileCount;
Expand Down Expand Up @@ -288,6 +291,7 @@ Object.defineProperties(Cesium3DTilesVoxelProvider.prototype, {
* @memberof Cesium3DTilesVoxelProvider.prototype
* @type {VoxelMetadataOrder}
* @readonly
* @private
*/
metadataOrder: {
get: function () {
Expand Down
16 changes: 14 additions & 2 deletions packages/engine/Source/Scene/VoxelMetadataOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@
* In all cases, x data is contiguous in strides along the y axis,
* and each group of y strides represents a z slice.
* However, the orientation of the axes follows different conventions.
*
* @enum {number}
* @private
*/
const VoxelMetadataOrder = {
XYZ: 0, // Default ordering following the 3D Tiles convention. Z-axis points upward.
GLTF: 1, // Ordering following the glTF convention. Y-axis points upward.
/**
* The default ordering following the 3D Tiles convention. Z-axis points upward.
* @type {number}
* @constant
*/
Z_UP: 0,
/**
* The ordering following the glTF convention. Y-axis points upward.
* @type {number}
* @constant
*/
Y_UP: 1,
};
export default Object.freeze(VoxelMetadataOrder);
2 changes: 1 addition & 1 deletion packages/engine/Source/Scene/VoxelPrimitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,7 @@ function initFromProvider(primitive, provider, context) {
primitive._paddingAfter,
primitive._inputDimensions,
);
if (provider.metadataOrder === VoxelMetadataOrder.GLTF) {
if (provider.metadataOrder === VoxelMetadataOrder.Y_UP) {
const inputDimensionsY = primitive._inputDimensions.y;
primitive._inputDimensions.y = primitive._inputDimensions.z;
primitive._inputDimensions.z = inputDimensionsY;
Expand Down
12 changes: 0 additions & 12 deletions packages/engine/Source/Scene/VoxelProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,6 @@ Object.defineProperties(VoxelProvider.prototype, {
get: DeveloperError.throwInstantiationError,
},

/**
* Gets the ordering of the metadata in the buffers.
*
* @memberof VoxelProvider.prototype
* @type {VoxelMetadataOrder}
* @default VoxelMetadataOrder.XYZ
* @readonly
*/
metadataOrder: {
get: DeveloperError.throwInstantiationError,
},

/**
* Gets the metadata minimum values.
*
Expand Down
Loading