Cesium and pnts file without 3D Tiles

Continuing the discussion from Generate 3D tiles in CPP:

@Marco13

Thx it works perfectly, now I’m trying to not use 3D tiles, and watched how the files is read.

I wanted to do something like that :

const response = await fetch('http://localhost:8080/content.pnts');
const arrayBuffer = await response.arrayBuffer();

const model = await Cesium.Model.fromPnts({
    arrayBuffer,
    byteOffset: 0
});
viewer.scene.primitives.add(model);

but it’s not working, there are options missing fromPnts , by example content :

backFaceCulling: true
byteOffset: 0
clippingPlanes: undefined
colorBlendAmount: 0.5
colorBlendMode: 0
content: Model3DTileContent {_tileset: Cesium3DTileset, _tile: Cesium3DTile, _resource: Resource, _model: undefined, _metadata: undefined, …}
cull: false
customShader: CustomShader {mode: "MODIFY_MATERIAL", lightingModel: undefined, uniforms: {…}, varyings: {…}, vertexShaderText: undefined, …}
debugWireframe: false
enableDebugWireframe: false
enablePick: false
enableShowOutline: true
featureIdLabel: "featureId_0"
forwardAxis: 0
imageBasedLighting: ImageBasedLighting {_imageBasedLightingFactor: Cartesian2, _sphericalHarmonicCoefficients: undefined, _specularEnvironmentMaps: undefined, _specularEnvironmentCubeMap: undefined, _specularEnvironmentCubeMapDirty: true, …}
incrementallyLoadTextures: false
instanceFeatureIdLabel: "instanceFeatureId_0"
lightColor: undefined
modelMatrix: Matrix4 {0: 1, 1: 0, 2: 0, 3: 0, 4: 0, 5: 1, 6: 0, 7: 0, 8: 0, 9: 0, 10: 1, 11: 0, 12: 0, 13: 0, 14: 0, 15: 1}
opaquePass: 4
outlineColor: Color {red: 0, green: 0, blue: 0, alpha: 1}
pointCloudShading: PointCloudShading {attenuation: false, geometricErrorScale: 1, maximumAttenuation: undefined, baseResolution: undefined, eyeDomeLighting: true, …}
projectTo2D: false
releaseGltfJson: true
resource: Resource {_url: "http://localhost:8080/content.pnts", _templateValues: {…}, _queryParameters: {…}, headers: {…}, request: Request, …}
shadows: 1
showCreditsOnScreen: false
showOutline: true
splitDirection: 0
upAxis: 1

any idea what are the important options ?
modelMatrix, customShader are logical to be included.

but content, I don’t know what to put instead of Model3DTileContent.

The Model.fromPnts function is marked as @private. It is not supposed to be called by clients. It is only called internally, when building the visual structures for a tileset where the PNTS file is only a ‘content’. (As part of this process of building the structures, the things that you referred to as “missing” are filled in accordingly).


Taking a few steps back, some more general points:

Most of the functionality that is offered by PNTS can be emulated with glTF, and this includes the metadata, which is handed via extensions. And when you have a glTF file, the you can create a standalone model from that. But for PNTS, the most simple solution for displaying that is to wrap a minimalistic tileset.json around that.

The 3d-tiles-tools contain some functionalities that may be useful here. For example, in order to create a tileset JSON for a given PNTS file, you can put that PNTS file into a directory, and then run
npx 3d-tiles-tools createTilesetJson -i ./data -o ./data/tileset.json
The tools also offer basic conversion functionalities, to convert PNTS files into glTF. (With some caveats, but for the majority of cases, this is pretty easy)

(I’m just mentioning that, although, referring to your previous thread, it looks like you are currently building some general “3D Tiles Tools” functionality in C++)

My team don’t want to use 3dtiles, even if i’ve made a simple tileset.json.

I’ve done this, and I don’t have an error :

    const resource = new Cesium.Resource({
        url: 'http://localhost:8080/content.pnts'
    });
    const response = await fetch(resource.url);
    const arrayBuffer = await response.arrayBuffer();
    const center = Cesium.Cartesian3.fromDegrees(2.3522, 48.8566, 100.0);
    const model = await Cesium.Model.fromPnts({
        arrayBuffer,
        resource,
        modelMatrix: Cesium.Transforms.eastNorthUpToFixedFrame(center),
        enablePick: false
    });
    model.backFaceCulling = false;
    model.shadows = Cesium.ShadowMode.DISABLED;
    model.show = true;
    model.type="GLTF"; // fix error

    viewer.scene.primitives.add(model);
    viewer.scene.requestRender();

but nothing

OK, I’ll still repeat the disclaimer: The fromPnts function is @private, and you should be aware of the implications of using it. Even if it “works” today, it might not work with the next release. (This is somewhat unlikely, because it’s unlikely that there will be significant changes, but I wanted to mention it).

That said… from the snippet that you posted, it looks like it should render the data. What might be missing there is a step to zoom to that data, so that you can actually see it…

const viewer = new Cesium.Viewer("cesiumContainer");

const resource = new Cesium.Resource({
    url: 'http://localhost:8003/content.pnts'
});
const response = await fetch(resource.url);
const arrayBuffer = await response.arrayBuffer();
const center = Cesium.Cartesian3.fromDegrees(2.3522, 48.8566, 100.0);
const model = await Cesium.Model.fromPnts({
    arrayBuffer,
    resource,
    modelMatrix: Cesium.Transforms.eastNorthUpToFixedFrame(center),
    enablePick: false
});
model.backFaceCulling = false;
model.shadows = Cesium.ShadowMode.DISABLED;
model.show = true;
model.type="GLTF"; // fix error

viewer.scene.primitives.add(model);

// Zoom to the model when it is ready...
model.readyEvent.addEventListener(() => {
  const boundingSphere = model.boundingSphere;
  viewer.scene.camera.flyToBoundingSphere(boundingSphere);
});
1 Like

thx , have a good day.
I will not used glb because it’s not optimized has ptns, no rtc_center, no compression options.

As pointed out in the Migration Guide:

  • The RTC_CENTER can simply be represented with a translation of the root node of the glTF
  • There is the option to use EXT_meshopt_compression (and quantization) for glTF that contain point cloud data

But of course, there are several engineering factors coming together that may affect your decision here.

1 Like