Creating equirectangular panorama from the camera

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? :smiley:

Hiya bn! Sorry about slow replies. Just for an idea… do you have your camera.minZ = 0;?

I see it at line 15 in pg #20… it sort of “stood-out” like a blow torch in a popsicle factory. :slight_smile:

No promises… likely not pertinent - just a reach-in-the-dark. :slight_smile: Maybe fov at line 209? (another reach)

Tomorrow, forum will be more active, I suspect.

Heya, I tried this method a bit longer, changing the fov as a factor of sin(beta) but it felt like a losing path. I think the proper way it to create a render target and a shader to render to the render target, but I don’t really understand that yet, so I’m using a reflection probe and saving out 6 images as a cubemap. Works really well (even though I have to handle more images). :slight_smile:

Yeah cubemap render is a good one as you only need to set the fov to 90deg and shoot in all 6 directions :slight_smile: