-
-
Notifications
You must be signed in to change notification settings - Fork 136
Description
Hi, i have this app, in which i load a local 3DTileset. The viewer loads right, but the zoom is not being made to the tileset location. This is my code
`import React, { useRef } from 'react';
import { Viewer, Cesium3DTileset, CesiumComponentRef } from 'resium';
import * as Cesium from 'cesium';
import 'cesium/Build/Cesium/Widgets/widgets.css';
function App() {
const viewerRef = useRef<CesiumComponentRef<Cesium.Viewer>>(null);
return (
<div style={{ height: '100vh', width: '100%' }}>
<Cesium3DTileset
url="/tiles2/tileset.json"
onReady={(tileset: Cesium.Cesium3DTileset) => {
tileset.readyPromise
.then(() => {
// Wait for the bounding sphere to be available
if (viewerRef.current?.cesiumElement && tileset.boundingSphere) {
viewerRef.current.cesiumElement.zoomTo(tileset,new Cesium.HeadingPitchRange(0.0, -0.5, tileset.boundingSphere.radius * 2.0));
}
})
.catch(error => {
console.error('Tileset failed to load:', error);
});
}}
/>
);
}
export default App;
`
i had tried another approachs like this
`import React, { useRef } from 'react';
import { Viewer, Cesium3DTileset, CesiumComponentRef } from 'resium';
import * as Cesium from 'cesium';
import 'cesium/Build/Cesium/Widgets/widgets.css';
function App() {
const viewerRef = useRef<CesiumComponentRef<Cesium.Viewer>>(null);
return (
<div style={{ height: '100vh', width: '100%' }}>
<Cesium3DTileset
url="/tiles/tileset.json"
onReady={(tileset: Cesium.Cesium3DTileset) => {
// When the tileset is ready, zoom to its bounding volume.
viewerRef.current?.cesiumElement?.zoomTo(tileset);
}}
/>
);
}
export default App;
`
but now i get this error
An error occurred while rendering. Rendering has stopped.
TypeError: Cannot read properties of undefined (reading 'updateTransform')
TypeError: Cannot read properties of undefined (reading 'updateTransform')
at Cesium3DTileset.get (http://localhost:5173/node_modules/.vite/deps/chunk-KGJW6GAO.js?v=94679f00:126338:18)
at updateZoomTarget (http://localhost:5173/node_modules/.vite/deps/chunk-KGJW6GAO.js?v=94679f00:226072:33)
at CesiumWidget._postRender (http://localhost:5173/node_modules/.vite/deps/chunk-KGJW6GAO.js?v=94679f00:226017:3)
at Event.raiseEvent (http://localhost:5173/node_modules/.vite/deps/chunk-KGJW6GAO.js?v=94679f00:17675:20)
at Scene4.render (http://localhost:5173/node_modules/.vite/deps/chunk-KGJW6GAO.js?v=94679f00:222594:22)
at CesiumWidget.render (http://localhost:5173/node_modules/.vite/deps/chunk-KGJW6GAO.js?v=94679f00:225835:17)
at render2 (http://localhost:5173/node_modules/.vite/deps/chunk-KGJW6GAO.js?v=94679f00:225081:18)