27 lines
650 B
JavaScript
27 lines
650 B
JavaScript
/*!
|
|
* Tectum
|
|
* Copyright © 2026 Machiel Heinen.
|
|
* Alle rechten voorbehouden. Gebruik uitsluitend met schriftelijke toestemming.
|
|
* Zie LICENTIE.md.
|
|
*/
|
|
|
|
window.CameraMemory = (() => {
|
|
const store = new Map();
|
|
|
|
function save(key, camera, controls) {
|
|
if (!key) return;
|
|
store.set(key, { position: camera.position.toArray(), target: controls.target.toArray() });
|
|
}
|
|
|
|
function restore(key, camera, controls) {
|
|
const m = key && store.get(key);
|
|
if (!m) return false;
|
|
camera.position.fromArray(m.position);
|
|
controls.target.fromArray(m.target);
|
|
controls.update();
|
|
return true;
|
|
}
|
|
|
|
return { save, restore };
|
|
})();
|