Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maintaining cesium coordinate system #33

Closed
Eytanm opened this issue Mar 10, 2022 · 2 comments
Closed

maintaining cesium coordinate system #33

Eytanm opened this issue Mar 10, 2022 · 2 comments

Comments

@Eytanm
Copy link

Eytanm commented Mar 10, 2022

Is there a way to plot a model from cesium so it maintains its coordinates system?
for example, bringing in another map layer under my model? or another layer of photogrammetry that maintains the world positioning?

@Avnerus
Copy link
Collaborator

Avnerus commented Mar 14, 2022

Hi Eytan,
The loader was initially designed to be independent of geo coordinates so unfortunately there isn't currently an intuitive way to do this. It is, however, in the Roadmap and would appreciate a PR on the matter. Since the backend is loaders.gl, everything should be supported. For example adding a resetGeoTransformation: true/false option would be great. In the mean time, you could try this workaround which seems to work for me with Cesium tilesets:

      // The loaders.gl matrix type
      import { Matrix4 as MathGLMatrix4 } from '@math.gl/core';

      // The result from await Loader3DTiles.load()
      const {model, runtime} = result;

      // Get a reference to the loaders.gl tileset
      const tileset = runtime.getTileset();
    
      // Set the model and camera position to the cartesian center
      model.position.set(...tileset.cartesianCenter);
      camera.position.set(...tileset.cartesianCenter);
      camera.translateY(1000);
  
      // If using orbit controls
      controls.target.set(...tileset.cartesianCenter);
      controls.update();
    
      // Reset the loaders.gl model matrix, otherwise it is set by the loader to inverse the geo-transformation.
      tileset.modelMatrix = new MathGLMatrix4();

Let me know if that worked for you!
/Avner

@Avnerus
Copy link
Collaborator

Avnerus commented Mar 22, 2022

Closing due to inactivity.

@Avnerus Avnerus closed this as completed Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants