When you initialize an OrbitViewer you can tell it what position to orbit, and the allowable range of distance from that position, and the starting distance from that position.
But can you tell it where to position itself to start the scene?
For example say I have a plane like the ground in the Learn Craft project, and I want to use an OrbitViewer in the scene, but I want the camera to start the scene at a position high above the plane, looking down on it.
Can that be done?
No matter how I define its position beforehand, in setup or in parameters or what have you, OrbitViewer seems to always set itself back to 0,0,0 when a scene starts.
As for positioning I can think of a kludge where I set the center of the orbit viewer to be an invisible entity that’s exactly where I want the viewer, and then set all of the proximity values to 0…
But then I have to change it once the scene starts, is that possible?
The kludge works. Define an invisible entity and initialize the viewer at 0 distance from it, and presto, viewer is in custom position.
Note: I actually had to define it as 0.05 from it with minimum distance at 0.005, or else the viewer would not zoom.
viewer.rx and viewer.ry seem to work as expected in this situation–meaning they work exactly like eulerAngles. Whatever values they are set to will become the main camera entity’s eulerAngles.
You cannot apparently change a viewer’s center on the fly, so whatever starting position you set, you’re stuck with
If you replace the viewer with a different viewer, the camera’s position resets. So unless that’s the effect you want, you’re still stuck with whatever position you start with.
Not to beat a dead horse here, but I spent so much time struggling with this that I hope I can help someone else get a handle on it as fast possible.
To which end I’m attaching a project that demonstrates how to do this. Position the camera anywhere you like, then tap the “save position” button and exit. When you restart, the camera will be in the same position as it was when you quit.
@UberGoober Apparently you have to import the zip file into Codea for it to work. If you unzip the file in the Files app and run the program from there, you get the above error.