Skip to content

Commit 75aaa3b

Browse files
authored
Update camera.md (#559)
* Update camera.md * Update camera.md for `ru`
1 parent 12b3ac4 commit 75aaa3b

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

docs/en/manuals/camera.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,6 @@ function M.screen_to_world(camera, screen_x, screen_y, z)
229229
local projection = go.get(camera, "projection")
230230
local view = go.get(camera, "view")
231231
local w, h = window.get_size()
232-
-- The window.get_size() function will return the scaled window size,
233-
-- ie taking into account display scaling (Retina screens on macOS for
234-
-- instance). We need to adjust for display scaling in our calculation.
235-
local scale = window.get_display_scale()
236-
w = w / scale
237-
h = h / scale
238232

239233
-- https://defold.com/manuals/camera/#converting-mouse-to-world-coordinates
240234
local inv = vmath.inv(projection * view)
@@ -246,7 +240,7 @@ function M.screen_to_world(camera, screen_x, screen_y, z)
246240
end
247241
```
248242

249-
Visit the [Examples page](https://defold.com/examples/render/screen_to_world/) to see screen to world coordinate conversion in action. There is also a [sample project](https://github.com/defold/sample-screen-to-world-coordinates/) showing how to do screen to world coordinate conversion.
243+
Keep in mind that the values `action.screen_x` and `action.screen_y` from `on_input()` should be used as arguments for this function. Visit the [Examples page](https://defold.com/examples/render/screen_to_world/) to see screen to world coordinate conversion in action. There is also a [sample project](https://github.com/defold/sample-screen-to-world-coordinates/) showing how to do screen to world coordinate conversion.
250244

251245
::: sidenote
252246
The [third-party camera solutions mentioned in this manual](/manuals/camera/#third-party-camera-solutions) provides functions for converting to and from screen coordinates.

docs/ru/manuals/camera.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -226,17 +226,11 @@ end
226226
-- @return world_y мировая координата Y
227227
-- @return world_z мировая координата Z
228228
function M.screen_to_world(camera, screen_x, screen_y, z)
229-
local projection = go.get(camera, "projection")
230-
local view = go.get(camera, "view")
231-
local w, h = window.get_size()
232-
-- window.get_size() возвращает масштабированный размер окна,
233-
-- учитывая дисплейный масштаб (например, Retina на macOS).
234-
-- Нужно скорректировать размер с учётом масштаба.
235-
local scale = window.get_display_scale()
236-
w = w / scale
237-
h = h / scale
238-
239-
-- https://defold.com/manuals/camera/#converting-mouse-to-world-coordinates
229+
local projection = go.get(camera, "projection")
230+
local view = go.get(camera, "view")
231+
local w, h = window.get_size()
232+
233+
-- https://defold.com/manuals/camera/#converting-mouse-to-world-coordinates
240234
local inv = vmath.inv(projection * view)
241235
local x = (2 * screen_x / w) - 1
242236
local y = (2 * screen_y / h) - 1
@@ -246,7 +240,7 @@ function M.screen_to_world(camera, screen_x, screen_y, z)
246240
end
247241
```
248242

249-
На странице [Примеры](https://defold.com/examples/render/screen_to_world/) показано использование преобразования экранных координат в мировые. Также есть [примерный проект](https://github.com/defold/sample-screen-to-world-coordinates/) с демонстрацией этого процесса.
243+
Имейте в виду, что значения `action.screen_x` и `action.screen_y` из `on_input()` должны использоваться как аргументы для этой функции. На странице [Примеры](https://defold.com/examples/render/screen_to_world/) показано использование преобразования экранных координат в мировые. Также есть [примерный проект](https://github.com/defold/sample-screen-to-world-coordinates/) с демонстрацией этого процесса.
250244

251245
::: sidenote
252246
[Сторонние решения для камеры](/manuals/camera/#third-party-camera-solutions) предоставляют функции для преобразования координат между экраном и миром.

0 commit comments

Comments
 (0)