Are there any developers here with experience in resium

1. A concise explanation of the problem you’re experiencing.

I’m building a big app all based on react and resium. i’m getting trouble with the 3D tilesset. the component’s url doesnt receive anything and nothing happens in the component. i see the viewer but none of the dunctions are fired from the Cesium3Dtileset component.

looked for solutions in webpack and didnt find any.

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

const tileSet = () => {

const ref = useRef(null);

return

<Cesium3DTileset

url="./tileset.json"

onAllTilesLoad={(…args) => console.log(“onAllTilesLoad”, …args)}

onInitialTilesLoad={(…args) => console.log(“onInitialTilesLoad”, …args)}

onTileFailed={(…args) => console.log(“onTileFailed”, …args)}

onTileLoad={(…args) => console.log(“onTileLoad”, …args)}

onTileUnload={(…args) => console.log(“onTileUnload”, …args)}

onReady={tileset => {

console.log(“onReady”, tileset);

ref.current.cesiumElement.zoomTo(tileset);

}}

/>

;

}

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

4. The Cesium version you’re using, your operating system and browser.

Did you get any help with this yet?

Nope. Not yet

בתאריך יום ה׳, 8 ביולי 2021, 12:11, מאת Pontus Nilsson via Cesium Community ‏<cesium@discoursemail.com>:

So you are importing your component inside the viewer and nothing fires?

No. My problem is with destroying the viewer, models and primitives. I allways get an error which crashes my app.
The models are created by resium Model component.
In general. I combign resium and cesiums javascript so i trying to find the right way to leave the cesium enviroment without getting any errors

בתאריך יום ה׳, 8 ביולי 2021, 12:31, מאת Pontus Nilsson via Cesium Community ‏<cesium@discoursemail.com>:

What error is it? so you are destroying the viewer with viewer.destroy() ? In general i use resium components and for the code and functions i use the viewer variable that you create. Not sure i can help you but will try.

yes. this is exacly how i use resium too. i attached the error.
I think it happens because the viewer is destroyed and then a functionality is called in the Model component in it. which i know doesnt make sense because the model component is inside the viewer compoment. so i tried “viewer.pimitives.removeAll” before destroying the viewer and that doesnt help.
Can you share the right way to close a Resium environment with Model components inside it?

I dont know the right way to close a Resium environment with Model components inside it.

In my head this should work:

const App = ( ) => {
  let viewer = null;
  
  handleDestroy = () => {
    if (viewer) {
      viewer.destroy();
    }
  }

  return (
  <Viewer ref={e => { viewer = e ? e.cesiumElement : null; }}>
    <button onClick={handleDestroy}>Destroy!</button>
  </Viewer>
 )
}

But i doubt this will work if you have more resium components inside the viewer already.

I did some research i didn’t find much but maybe this could help you a bit:

Thank you. i managed to do a work arround. i first remove all the Models components and then destroy. sothe errors are gone:)

Nice! :slight_smile: