Hello All
I am having an error (TypeError: cannot read properties of (undefined reading ‘updateTransform’). It throws the error in console on catch error ‘There was an error while creating the 3D tileset’
This is a sample of my code:
const viewer = new Cesium.Viewer(“cesiumGlobeContainer”, {
scene3DOnly: true,
imageryProvider: Cesium.OpenStreetMapImageryProvider({
url: ‘https://tile.openstreetmap.org/’,
}),
});
/**
- Add a tileset containing buildings
- @param {String} urlTiles URL of the 3DTiles to be loaded
- @returns {Object} The tileset dataset
*/
const createBuildingTileset = async function (urlTiles) {
return await new Cesium.Cesium3DTileset({
url: urlTiles,
});
};
// 3D tileset with all buildings
const nonDetailedBuilding225Tileset = await createBuildingTileset(
“data_3d/3dtiles/1_full/tileset.json”
);
// 3D tileset with all buildings except Bau 225
const detailedBuilding225Tileset = await createBuildingTileset(
“data_3d/3dtiles/2_partial/tileset.json”
);
/**
- Load and zoom to the extents of 3DTiles
- @param {Object} buildingTileset The 3D tileset to be loaded
*/
const loadTiles = async function (buildingTileset) {
try{
viewer.scene.primitives.add(buildingTileset);
viewer.zoomTo(
buildingTileset,
new Cesium.HeadingPitchRange(
0.0,
-0.5,
buildingTileset.boundingSphere.radius / 0.5 //Notice: if range is changed to 0, it throws An error occurred while rendering. Rendering has stopped//
)
);
}catch (err) {
console.log(There was an error while creating the 3D tileset.${err}
) ;
}
// Override the default home homeButton; doesn’t work perfectly
viewer.homeButton.viewModel.command.beforeExecute.addEventListener(function (e) {
e.cancel = true;
viewer.camera.flyTo(buildingTileset.Boundingsphere);
});
}
/**
- Load 3DTiles for all the buildings; ignore any glTF models
- @param{*}
- @returns {undefined} undefined
*/
const loadNonDetailedBuilding225 = function () {
// 3D tileset with all buildings
loadTiles(nonDetailedBuilding225Tileset);
};
/**
- Load glTF models
- @param {String} gltfUrl Path to the folder containing the glTF models
- @param {String} gltfId Name of the glTF model file without the extension i.e. exclude the
.gltf
suffix - @returns {undefined} undefined
*/
const gltfLoad = function (gltfUrl, gltfId) {
try{
const modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
Cesium.Cartesian3.fromDegrees(9.083385, 48.881342, 0)
);viewer.scene.primitives.add(
Cesium.Model.fromGltfAsync({
url:${gltfUrl}/${gltfId}.gltf
,
modelMatrix: modelMatrix,
scale: 0.0254,
allowPicking: true,
})
);
}catch (error){
console.log(Failed to load model.${error}
)
};
Cesium.Cartesian3.fromDegrees(9.083385, 48.881342, 0)
}