examples icon indicating copy to clipboard operation
examples copied to clipboard

Screen to world for perspective camera

Open aglitchman opened this issue 9 months ago • 6 comments

Describe the example you'd like The current example is for the ortographic mode. We need an example for the perspective camera mode.

Additional context (optional) I've already implemented the code, will be used for entity picking, orbit camera (panning requires it) etc - the issue is like a reminder to make an example.

aglitchman avatar May 12 '25 12:05 aglitchman

Plus, I'll update the manual to add and to state that the current function is for ortho camera, and there is a new function for perspective.

https://defold.com/manuals/camera/#converting-mouse-to-world-coordinates

aglitchman avatar May 13 '25 20:05 aglitchman

For the future - use code from https://github.com/defold/examples/blob/master/input/entity_picking/example/camera_math.lua

aglitchman avatar Jul 08 '25 16:07 aglitchman

Maybe we should have a shared folder/library project with this kind of stuff (camera controls, extra math functions, materials).

britzl avatar Jul 09 '25 05:07 britzl

Maybe we should have a shared folder/library project with this kind of stuff (camera controls, extra math functions, materials).

I don't even know. I like that each project in the examples uses only what it really needs to work and is completely isolated. I know that when a project references a dependency or a large library, even experienced programmers view it as a black box, which makes the overall study of the engine harder.

aglitchman avatar Jul 09 '25 10:07 aglitchman

I can see both sides. Perhaps we can have a project with "best practices" code, and we can copy files manually into examples to avoid dependencies.

JCash avatar Jul 09 '25 10:07 JCash

Maybe we should have a shared folder/library project with this kind of stuff (camera controls, extra math functions, materials).

I don't even know. I like that each project in the examples uses only what it really needs to work and is completely isolated. I know that when a project references a dependency or a large library, even experienced programmers view it as a black box, which makes the overall study of the engine harder.

This is a valid argument. The inconvenience of having duplicated files is not too bad. Let's keep it as-is for now.

britzl avatar Jul 09 '25 20:07 britzl