Finish topography overlay
This commit is contained in:
parent
f2cb1ce9e2
commit
832c958fba
4 changed files with 117 additions and 104 deletions
|
@ -62,7 +62,7 @@ export function buildScene(container: HTMLElement, extent: Extent) {
|
|||
renderer.setSize(width, height);
|
||||
renderer.localClippingEnabled = true;
|
||||
renderer.autoClear = false;
|
||||
renderer.setAnimationLoop(animate);
|
||||
// renderer.setAnimationLoop(animate);
|
||||
|
||||
// Handle window resize event to adapt the aspect ratio
|
||||
window.addEventListener("resize", () => onWindowResize(container));
|
||||
|
@ -121,14 +121,19 @@ function onWindowResize(container: HTMLElement) {
|
|||
controls.update();
|
||||
}
|
||||
|
||||
function animate() {
|
||||
// Update controls for main camera
|
||||
controls.update();
|
||||
// Callback for animation loop
|
||||
export function animate(cb: () => void) {
|
||||
return () => {
|
||||
// Update controls for main camera
|
||||
controls.update();
|
||||
|
||||
renderer.render(scene, camera);
|
||||
renderer.render(scene, camera);
|
||||
|
||||
// Render the UI overlay
|
||||
renderOverlay();
|
||||
// Render the UI overlay
|
||||
renderOverlay();
|
||||
|
||||
cb();
|
||||
};
|
||||
}
|
||||
|
||||
// Render the overlay scene as an overlay
|
||||
|
|
|
@ -90,9 +90,14 @@ export function tileBounds(zoom: number, x: number, y: number): number[] {
|
|||
|
||||
const plane = new Plane(new Vector3(0, 0, 1), 0);
|
||||
|
||||
const corners = [new Vector2(-1, -1), new Vector2(1, 1)];
|
||||
const corners = [
|
||||
new Vector2(-1, -1),
|
||||
new Vector2(1, 1),
|
||||
new Vector2(-1, 1),
|
||||
new Vector2(1, -1),
|
||||
];
|
||||
|
||||
export const getFrustumIntersections = (camera: PerspectiveCamera) => {
|
||||
export const getFrustumBoundingBox = (camera: PerspectiveCamera) => {
|
||||
const points = [];
|
||||
|
||||
const raycaster = new Raycaster();
|
||||
|
@ -112,13 +117,13 @@ export const getFrustumIntersections = (camera: PerspectiveCamera) => {
|
|||
if (points.length > 1) {
|
||||
return [
|
||||
new Vector3(
|
||||
Math.min(points[0].x, points[1].x),
|
||||
Math.min(points[0].y, points[1].y),
|
||||
Math.min(points[0].x, points[1].x, points[2].x, points[3].x),
|
||||
Math.min(points[0].y, points[1].y, points[2].y, points[3].y),
|
||||
0
|
||||
),
|
||||
new Vector3(
|
||||
Math.max(points[0].x, points[1].x),
|
||||
Math.max(points[0].y, points[1].y),
|
||||
Math.max(points[0].x, points[1].x, points[2].x, points[3].x),
|
||||
Math.max(points[0].y, points[1].y, points[2].y, points[3].y),
|
||||
0
|
||||
),
|
||||
];
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue