pitch gefixt
This commit is contained in:
49
main.js
49
main.js
@@ -106,77 +106,46 @@ function syncCamera() {
|
||||
// -----------------------------------------
|
||||
// Abstand abhängig vom Zoom
|
||||
// -----------------------------------------
|
||||
|
||||
const earthCircumference = 40075016.686;
|
||||
|
||||
const metersPerPixel =
|
||||
earthCircumference *
|
||||
Math.cos(center.lat * Math.PI / 180) /
|
||||
Math.pow(2, zoom + 8);
|
||||
|
||||
const distance =
|
||||
metersPerPixel * map.getCanvas().height;
|
||||
const metersPerPixel = earthCircumference * Math.cos(center.lat * Math.PI / 180) / Math.pow(2, zoom + 8);
|
||||
const distance = metersPerPixel * map.getCanvas().height;
|
||||
|
||||
// -----------------------------------------
|
||||
// Zielpunkt = Kartenzentrum
|
||||
// -----------------------------------------
|
||||
|
||||
const target = new THREE.Vector3(
|
||||
x,
|
||||
y,
|
||||
0
|
||||
);
|
||||
const target = new THREE.Vector3(x, y, 0);
|
||||
|
||||
// -----------------------------------------
|
||||
// Kameraoffset
|
||||
// -----------------------------------------
|
||||
|
||||
const offset = new THREE.Vector3(
|
||||
0,
|
||||
-distance * Math.cos(pitch),
|
||||
distance * Math.sin(pitch)
|
||||
const offset = new THREE.Vector3(0, -distance * Math.sin(pitch), distance * Math.cos(pitch)
|
||||
);
|
||||
|
||||
// Bearing rotieren
|
||||
offset.applyAxisAngle(
|
||||
new THREE.Vector3(0, 0, 1),
|
||||
-bearing
|
||||
);
|
||||
offset.applyAxisAngle(new THREE.Vector3(0, 0, 1), -bearing);
|
||||
|
||||
// -----------------------------------------
|
||||
// Kameraposition
|
||||
// -----------------------------------------
|
||||
|
||||
const cameraPosition =
|
||||
target.clone().add(offset);
|
||||
const cameraPosition = target.clone().add(offset);
|
||||
|
||||
// -----------------------------------------
|
||||
// Potree Kamera setzen
|
||||
// -----------------------------------------
|
||||
|
||||
const camera =
|
||||
viewer.scene.getActiveCamera();
|
||||
|
||||
const camera = viewer.scene.getActiveCamera();
|
||||
camera.position.copy(cameraPosition);
|
||||
|
||||
camera.lookAt(target);
|
||||
|
||||
viewer.scene.view.position.copy(cameraPosition);
|
||||
|
||||
viewer.scene.view.lookAt(target);
|
||||
|
||||
camera.updateMatrixWorld();
|
||||
|
||||
viewer.renderer.render(
|
||||
viewer.scene.scene,
|
||||
camera
|
||||
);
|
||||
}
|
||||
|
||||
map.on('move', ()=>{
|
||||
console.log(viewer.scene.view)
|
||||
syncCamera();
|
||||
});
|
||||
// Kameras bei jeder Kartenbewegung synchronisieren
|
||||
map.on('move', syncCamera);
|
||||
map.on('zoom', syncCamera);
|
||||
map.on('pitch', syncCamera);
|
||||
map.on('rotate', syncCamera);
|
||||
|
||||
Reference in New Issue
Block a user