Good morning: I’m trying to create a cesium that reads point clouds through a tileset.json (I exported this file from my ceisum ion to test with formats that are well structured), but I can’t get the points to be seen or the camera to point to that side const fileInput = document.getElementById(‘fileInput’);
(index.js)
// Initialize the Cesium viewer
const viewer = new Cesium.Viewer("cesiumContainer", {
terrainProvider: Cesium.createWorldTerrain(),
});
// Handle the loading of the tileset.json file
fileInput.addEventListener("change", async (event) => {
const file = event.target.files[0];
if (!file) return;
try {
const fileContent = await file.text();
const tilesetJson = JSON.parse(fileContent);
// Create a Blob URL to handle the file as a local resource
const blob = new Blob([JSON.stringify(tilesetJson)], {
type: "application/json",
});
const blobUrl = URL.createObjectURL(blob);
// Load the tileset in Cesium
const tileset = new Cesium.Cesium3DTileset({ url: blobUrl });
// Add the tileset to the scene
viewer.scene.primitives.add(tileset);
// Make sure the camera is focused correctly
tileset.readyPromise
.then(() => {
// Check if the boundingSphere is defined and move the camera
const boundingSphere = tileset.boundingSphere;
if (boundingSphere) {
viewer.scene.camera.flyToBoundingSphere(boundingSphere, {
duration: 2, // Flight duration
});
} else {
console.warn("Could not find boundingSphere in the tileset.");
}
})
.catch((error) => {
console.error("Error loading tileset:", error);
});
} catch (error) {
console.error("Error reading file:", error);
}
});
Edited for formatting