Heya, I’m trying to create and equirectangular image of the current scene. I’ve seen this post - but can’t get it to work properly - I end up with the subsequent samples not aligning correctly.
captureEquirectangular () {
let orientations = []
for (let x = 0 ; x < 32; x ++) {
for (let y = 0 ; y < 16; y++) {
orientations.push({ x, y })
}
}
let camera = new B.ArcRotateCamera('equirectangular', 0, 0, 1, scene.activeCamera.position, scene)
scene.activeCamera = camera
const cv = document.querySelector('#renderCanvas') as HTMLCanvasElement
cv.width = 64
cv.height = 64
cv.style.width = '64px'
cv.style.height = '64px'
scene.getEngine().resize()
while (orientations.length > 0 ) {
let o = orientations.pop()
camera.alpha = (32 - o.x) / 16 * Math.PI
camera.beta = (16 - o.y) / 16 * Math.PI
camera.fov = 0.2
scene.render()
const im = document.createElement('img')
im.src = cv.toDataURL()
im.style.cssText = `position: absolute; width: 64px; height: 64px; left: ${o.x * 64}px; top: ${o.y * 64}px`
document.body.appendChild(im)
}
}
Any ideas how to do the maths properly, or magic values I can use to make this work?