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

Display a specific area from Google Tiles #16

Closed
ebeaufay opened this issue Jun 20, 2023 · 0 comments
Closed

Display a specific area from Google Tiles #16

ebeaufay opened this issue Jun 20, 2023 · 0 comments

Comments

@ebeaufay
Copy link
Owner

Recently I was asked in this issue: ebeaufay/UltraGlobe#5 if it would be possible to display a specific area from google tiles rather than the entire globe.

Rather than implement this in the other project https://github.com/ebeaufay/UltraGlobe, I suggest this approach:

  1. load Google tiles via this project
  2. Compute the transformation that would bring the location you're interested in to 0,0,0
  3. add some clipping planes around the area you're interested in (https://threejs.org/examples/?q=clip#webgl_clipping)

That way, you'll have the area of interest, y-up, and you can use threejs standard controls.

Here's how you can transform the google 3DTiles tileset to bring the location of interest to the origin and rotate the model:

const pointOfInterestLLH = new THREE.Vector3(5,50,0);
const pointOfInterestCartesian = llhToCartesian(pointOfInterestLLH);

//quaternionRotation
const quaternionToEarthNormalOrientation = new THREE.Quaternion();
quaternionToEarthNormalOrientation.setFromUnitVectors(new THREE.Vector3(0, 1, 0), pointOfInterestCartesian.clone().normalize());
tileset.quaternion.copy(quaternionToEarthNormalOrientation.invert());
tileset.position.copy(cartesianLocation.negate());

you still need to implement #llhToCartesian (see proj4 library or just ask chat-gpt)

One more thing, the tiles outside of the clipping plane will still be loaded so, don't set the far plane too far.

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

1 participant