This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!Array.prototype.at) { | |
Array.prototype.at = function (index) { | |
if (!this.length) return undefined; | |
let number = Number(index) || 0; // if NaN, affect 0 | |
let intIndex = Math.sign(number) * Math.floor(Math.abs(number)); | |
let relativeIndex = intIndex >= 0 ? intIndex : this.length + intIndex; | |
if (relativeIndex < 0 || relativeIndex >= this.length) return undefined; | |
return this[relativeIndex]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// When creating the camera | |
const storedCamera = JSON.parse(localStorage.getItem('camera')); | |
if (storedCamera) { | |
camera.position.set( | |
storedCamera.position.x, | |
storedCamera.position.y, | |
storedCamera.position.z, | |
); | |
controls.target.set( | |
storedCamera.target.x, |