Skip to content
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

.pnts loader for ModelExperimental #9978

Merged
merged 50 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
9649ca5
WIP: set up scaffolding for transcoding PNTS
ptrgags Dec 8, 2021
8e9d72d
WIP continue working on parser and loader
ptrgags Dec 8, 2021
b01f0ab
WIP build attribute components
ptrgags Dec 9, 2021
7eee81f
WIP - Handle the decoded draco attributes
ptrgags Dec 9, 2021
79b3c57
Get something rendering on the screen
ptrgags Dec 9, 2021
a5052f1
Get point cloud rendering on the screen
ptrgags Dec 10, 2021
c65c0f7
Add more details to parsed attributes
ptrgags Dec 10, 2021
f0cd412
Refactor parsedContent object
ptrgags Dec 10, 2021
398b677
Start working on unit tests
ptrgags Dec 13, 2021
d09f367
Start adding tests for PntsLoader
ptrgags Dec 13, 2021
8281e65
Add RGB565 decoding function
ptrgags Dec 14, 2021
b09142d
Parse RGB565 on the CPU
ptrgags Dec 14, 2021
ca1e80e
Handle oct-encoded normals
ptrgags Dec 14, 2021
22582e9
Fix batch table unit tests
ptrgags Dec 14, 2021
4697576
Fix oct encoded normal tests
ptrgags Dec 15, 2021
b6322a1
Add more tests to PntsLoader and PntsParser
ptrgags Dec 15, 2021
d2f62b9
b3dm is lowercase
ptrgags Dec 15, 2021
4310f5a
Update B3dm tests to use B3dmLoader & B3dmParser more directly
ptrgags Dec 15, 2021
d048bc9
Use separate MersenneTwister RNG for pnts
ptrgags Dec 15, 2021
8c3172d
Fix bounding spheres for quantized positions
ptrgags Dec 15, 2021
8bcfd85
Clean up buffers on unload
ptrgags Dec 15, 2021
a15cef5
Pass isTranslucent flag through
ptrgags Dec 16, 2021
cba1cb1
Fix bounding volume calculation
ptrgags Dec 16, 2021
3b597e3
Update documentation
ptrgags Dec 17, 2021
bb24378
Don't hold on to typed array
ptrgags Dec 17, 2021
b3f5264
Free memory from parsedContent when done
ptrgags Dec 17, 2021
1b7df45
Move MersenneTwister into function
ptrgags Dec 17, 2021
6a11330
Used quantized volume to compute min/max
ptrgags Dec 17, 2021
c5c9c8a
Merge branch 'main' into pnts-loader
ptrgags Dec 17, 2021
2b0e870
Update to use tileset.enableModelExperimental
ptrgags Dec 17, 2021
86e7409
Fix constant color
ptrgags Dec 17, 2021
9c87758
BATCH_LENGTH not BATCHES_LENGTH
ptrgags Dec 17, 2021
aca0b0b
add missing set index for batch ID
ptrgags Dec 17, 2021
518d834
Merge branch 'main' into pnts-loader
ptrgags Jan 4, 2022
54bd8d1
Tag .pnts models as TILE_PNTS
ptrgags Jan 4, 2022
251eddc
Update to use components.transform
ptrgags Jan 4, 2022
a34e169
Move sRGB conversion functions to builtins
ptrgags Jan 4, 2022
c7cc4a5
Handle sRGB colors from .pnts files
ptrgags Jan 4, 2022
19f72ec
Update sRgb conversion code
ptrgags Jan 4, 2022
9553044
Update unit tests
ptrgags Jan 5, 2022
41a1005
Add define for HAS_SRGB_COLOR
ptrgags Jan 5, 2022
9ac5fc2
Default to dark grey
ptrgags Jan 5, 2022
fb67acb
Fix translucency
ptrgags Jan 5, 2022
e5a3d08
Render as unlit unless normals are present
ptrgags Jan 5, 2022
0941231
Fix oct-encoded normals
ptrgags Jan 5, 2022
bfc91ea
Move quantized offset to model matrix
ptrgags Jan 5, 2022
a3748b3
Handle component data type of batch ID
ptrgags Jan 5, 2022
3595ab6
Fix compilation error
ptrgags Jan 6, 2022
7ca7747
Fix unit tests
ptrgags Jan 6, 2022
907caff
Don't destroy attribute buffers when styling is applied
ptrgags Jan 6, 2022
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
9 changes: 9 additions & 0 deletions Source/Scene/Cesium3DTileContentFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ var Cesium3DTileContentFactory = {
);
},
pnts: function (tileset, tile, resource, arrayBuffer, byteOffset) {
if (ExperimentalFeatures.enableModelExperimental) {
return ModelExperimental3DTileContent.fromPnts(
tileset,
tile,
resource,
arrayBuffer,
byteOffset
);
}
return new PointCloud3DTileContent(
tileset,
tile,
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/ModelComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function Quantization() {

/**
* The step size of the quantization volume, equal to
* quantizedVolumeDimensions / quantizedVolumeOffset (component-wise).
* quantizedVolumeDimensions / normalizationRange (component-wise).
* Not applicable for oct encoded attributes.
* The type should match the attribute type - e.g. if the attribute type
* is AttributeType.VEC4 the dimensions should be a Cartesian4.
Expand Down
40 changes: 39 additions & 1 deletion Source/Scene/ModelExperimental/ModelExperimental.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import destroyObject from "../../Core/destroyObject.js";
import Matrix4 from "../../Core/Matrix4.js";
import ModelFeatureTable from "./ModelFeatureTable.js";
import B3dmLoader from "./B3dmLoader.js";
import PntsLoader from "./PntsLoader.js";
import Color from "../../Core/Color.js";

/**
Expand Down Expand Up @@ -205,7 +206,12 @@ function initialize(model) {
ModelExperimentalUtility.getFailedLoadFunction(model, "model", resource)
);

loader.texturesLoadedPromise
// Transcoded .pnts models do not have textures
var texturesLoadedPromise = defaultValue(
loader.texturesLoadedPromise,
when.resolve()
);
texturesLoadedPromise
.then(function () {
model._texturesLoaded = true;
})
Expand Down Expand Up @@ -818,6 +824,38 @@ ModelExperimental.fromB3dm = function (options) {
featureIdAttributeIndex: options.featureIdAttributeIndex,
featureIdTextureIndex: options.featureIdTextureIndex,
};

var model = new ModelExperimental(modelOptions);
return model;
};

ModelExperimental.fromPnts = function (options) {
ptrgags marked this conversation as resolved.
Show resolved Hide resolved
var loaderOptions = {
pntsResource: options.resource,
arrayBuffer: options.arrayBuffer,
byteOffset: options.byteOffset,
releaseGltfJson: options.releaseGltfJson,
incrementallyLoadTextures: options.incrementallyLoadTextures,
upAxis: options.upAxis,
forwardAxis: options.forwardAxis,
ptrgags marked this conversation as resolved.
Show resolved Hide resolved
};
var loader = new PntsLoader(loaderOptions);

var modelOptions = {
loader: loader,
resource: loaderOptions.pntsResource,
modelMatrix: options.modelMatrix,
debugShowBoundingVolume: options.debugShowBoundingVolume,
cull: options.cull,
opaquePass: options.opaquePass,
allowPicking: options.allowPicking,
customShader: options.customShader,
content: options.content,
show: options.show,
featureIdAttributeIndex: options.featureIdAttributeIndex,
featureIdTextureIndex: options.featureIdTextureIndex,
};

var model = new ModelExperimental(modelOptions);
return model;
};
Expand Down
29 changes: 29 additions & 0 deletions Source/Scene/ModelExperimental/ModelExperimental3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,32 @@ ModelExperimental3DTileContent.fromB3dm = function (
content._model = ModelExperimental.fromB3dm(modelOptions);
return content;
};

ModelExperimental3DTileContent.fromPnts = function (
tileset,
tile,
resource,
arrayBuffer,
byteOffset
) {
var content = new ModelExperimental3DTileContent(tileset, tile, resource);

var modelOptions = {
arrayBuffer: arrayBuffer,
byteOffset: byteOffset,
resource: resource,
cull: false, // The model is already culled by 3D Tiles
releaseGltfJson: true, // Models are unique and will not benefit from caching so save memory
opaquePass: Pass.CESIUM_3D_TILE, // Draw opaque portions of the model during the 3D Tiles pass
modelMatrix: tile.computedTransform,
upAxis: tileset._gltfUpAxis,
forwardAxis: Axis.X,
incrementallyLoadTextures: false,
customShader: tileset.customShader,
content: content,
colorBlendMode: tileset.colorBlendMode,
colorBlendAmount: tileset.colorBlendAmount,
};
content._model = ModelExperimental.fromPnts(modelOptions);
return content;
};
Loading