xeolabs / xeogl

A WebGL-based 3D engine for technical visualization. Not actively maintained.
http://xeogl.org
Other
1.14k stars 264 forks source link

Getting help on camera positioning #310

Open mimooh opened 5 years ago

mimooh commented 5 years ago

Hi, awesome lib. Seems faster than threejs for basic buliding models. Perhaps it's not the right place, but since I cannot find any forum: what would be the procedure (if it's possible) to achieve this: Say I have a cube. Find the position for the ortho camera, so that the rendered image is say 30x30 pixels square (camera looking at my cube from the top, displaying a single face of the cube, rendered at the size given). I am not asking for the code if that's not quick one, just for the idea.

SoulDesignerTom commented 3 years ago

I would like to second that. I'm trying to move camera along CameraAnimationPath - but with no success - it's almost impossible to guess the numbers for settings. It took me long time just to position static camera in the scene the way i wanted. But for animation? How can i do this? Maybe some generator or some way i can mesure that? I was already trying to getCameraMatrix to identify current camera position - but i don't really get the array... maybe i'm to dumb for it.

Anyhow - the plugin is great i believe it will beat three.js - much better performance.

SoulDesignerTom commented 3 years ago

Ok i'll find a way for that. Just add to your script:

camera.on("matrix", function(matrix) { console.log(camera.eye); console.log(camera.look); console.log(camera.up); });

Then when you set your camera with mouse you will get parameters for all those variables :)

mhoelzner commented 3 years ago

I use this function to get the current camera position

function _getCameraPos() {
        return {
            eye: [..._camera.eye],
            look: [..._camera.look],
            up: [..._camera.up],
        };
    }

where _camera = scene.camera;