Pārlūkot izejas kodu

html5 param & coordinates convertion (#428)

* linux-faq.md update

* 4.28.2021 updates

* Basis Universal format

* sound & mesh

* gamepad event mapping

* admob url

* Minor edit to building blocks intro text

* update gamepad & ios

* project settings

* libffi version

* scaling

* image compression

* update gamepads

* increase memory

* caching assets

* update 2021/10/6

* update 2021/10/16
blend-modes.md

* update 2021/11/12

* allow dynamic transforms update

* Bundle update

* update faq

* bullet & bob

* script properties update

* editor-styling

* build server url

* editor templates

* spine extension update

* Fix typo in the "optimizations" word in Chinese docs

* Update to material.md - Constants buffers

* Verify Graphics Calls

* H5 parameters

* OpenJDK downloads

* cn update corresponds to [pull 259](https://github.com/defold/doc/pull/259)

* application security

* porting guidelines

* update for 8f1651f

* cn update for 094bf6f

* cn update for 20fdfc5 & 6263317

* cn update for 7/19/2022

* title

* profiling update

* update editor.md

* update bob.md

* update shortcuts

* update fixed update note

* Update properties.md

* Update material.md

* Updates links

* Update bob help with the latest info

* camera & renderer

* Updated android keystore info zh_cn

* bundling.md release vs debug zh_cn

* update bob.md & gui-clipping.md

* contentless bundle

* consoles update

* model animation link

* gamepad & faq

* remove a camera lib

* font shadow render mode fix

* updates about app-manifest and others

* Update script.md

* includes in shaders

* editor scripts

* material updates

* Added dynamic atlas and texture creation

* fixes for atlas and some others

* update screenshots and add explanations (CN)

* add a line about Dynamic Prototype (CN)

* remove "inline" marks in pics

* de-translate the subtitle "Running the debugger" & images fix

* bundle identifier restrictions

* node properties Enabled and Visible (CN)

* release checklist & slice-9

* Update project-settings.md (CN)

* Update camera.md (CN)

* Update project-settings.md (CN)

* culling of meshes (CN)

* Update project-settings.md (CN)

* gltf model file support (CN)

* updates about factory (CN)

* Update bob.md (CN)

* Update bob.jar help (CN)

* Update about renderer and other things

* Update PS4 development and other things

* Dynamic prototype part of the collection factory.

* sync to atlas.md

* sync to design.md

* sync to gpgs.md

* sync to hot-reload.md

* sync to linux.md

* sync to live-update.md

* sync to lua.md

* sync to networking.md

* sync to physics-shapes.md

* sync to push.md

* sync to test.md

* sync to working-offline.md

* update material.md

* update zerobrane.md

* all done

* Splitting .zip archives in live-update.md

* manual for collision events

* Updated sprite documentation to include info about multiple textures

* update editor-scripts.md & physics-events.md

* update buffer.md & physics-shapes.md

* screen blend mode

* Update camera manual for zh with new function.

* Fix texture profile documentation for 1.7.0 zh

* update material.md & render.md

* notice about physics-events

* script-properties notes & PS5

* Clarified collision messages

* Update 3rd party camera list

* Fixed links in live update manual zh

* Update lua.md

* Update html5 manual with new information about CUSTOM_PARAMETERS. zh

* Added note on Apple Privacy Manifests zh

* typo

* Add info about collection proxies for zh

* fix minor mistakes

* typo

* custom resource & physics.set_shape

* Add missing type property in the physics.set_shape for zh

* html5 param & coordinates convertion
COCO 1 gadu atpakaļ
vecāks
revīzija
6275131d6c
2 mainītis faili ar 35 papildinājumiem un 14 dzēšanām
  1. 26 12
      docs/zh/manuals/camera.md
  2. 9 2
      docs/zh/manuals/html5.md

+ 26 - 12
docs/zh/manuals/camera.md

@@ -113,27 +113,41 @@ go.set("#camera", "orthographic_zoom", 2)
 
 ### 鼠标位置转换为世界坐标
 
-摄像机平移缩放后 `on_input()` 函数提供的鼠标位置就不再与世界坐标匹配了. 此时需要进行手动矫正. 默认渲染脚本里把鼠标/屏幕坐标转换为世界坐标的代码如下:
+摄像机平移缩放后 `on_input()` 函数提供的鼠标位置就不再与世界坐标匹配了. 此时需要进行手动矫正. 把鼠标/屏幕坐标转换到世界坐标的代码如下:
 
 ::: sidenote
 [本教程第三方摄像机解决方案部分](/manuals/camera/#第三方摄像机解决方案) 提供了坐标转换方法.
 :::
 
 ```Lua
--- builtins/render/default.render_script
---
-local function screen_to_world(x, y, z)
-	local inv = vmath.inv(self.projection * self.view)
-	x = (2 * x / render.get_width()) - 1
-	y = (2 * y / render.get_height()) - 1
-	z = (2 * z) - 1
-	local x1 = x * inv.m00 + y * inv.m01 + z * inv.m02 + inv.m03
-	local y1 = x * inv.m10 + y * inv.m11 + z * inv.m12 + inv.m13
-	local z1 = x * inv.m20 + y * inv.m21 + z * inv.m22 + inv.m23
-	return x1, y1, z1
+-- 从屏幕坐标变换到世界坐标
+-- @param sx 屏幕 x
+-- @param sy 屏幕 y
+-- @param sz 屏幕 z
+-- @param window_width 窗口宽度 (使用 render.get_width() 或 window.get_size().x)
+-- @param window_height 窗口高度 (使用 render.get_height() 或 window.get_size().y)
+-- @param projection Camera/render 映射 (使用 go.get("#camera", "projection"))
+-- @param view Camera/render 视口 (使用 go.get("#camera", "view"))
+-- @return wx 世界 x
+-- @return wy 世界 y
+-- @return wz 世界 z
+local function screen_to_world(sx, sy, sz, window_width, window_height, projection, view)
+	local inv = vmath.inv(projection * view)
+	sx = (2 * sx / window_width) - 1
+	sy = (2 * sy / window_height) - 1
+	sz = (2 * sz) - 1
+	local wx = sx * inv.m00 + sy * inv.m01 + sz * inv.m02 + inv.m03
+	local wy = sx * inv.m10 + sy * inv.m11 + sz * inv.m12 + inv.m13
+	local wz = sx * inv.m20 + sy * inv.m21 + sz * inv.m22 + inv.m23
+	return wx, wy, wz
 end
 ```
 
+参见 [示例页面](https://defold.com/examples/render/screen_to_world/) 的屏幕坐标到世界坐标转换实例. 还有一个 [实例项目](https://github.com/defold/sample-screen-to-world-coordinates/) 介绍了屏幕坐标到世界坐标的转换.
+
+::: sidenote
+[本教程使用的第三方摄像机库](/manuals/camera/#third-party-camera-solutions) 提供了自屏幕坐标和到屏幕坐标的转换功能.
+:::
 
 ## 运行时控制
 可以通过一些消息和属性控制运行时的摄像机 (用法参考 [API 文档](/ref/camera/)).

+ 9 - 2
docs/zh/manuals/html5.md

@@ -185,7 +185,11 @@ DEFOLD_ENGINE_ARGUMENTS
 
 ## 额外参数
 
-要创建自定义模板, 可以为引擎加载预定义额外参数. 预定义参数需要在 `<script>` 标签下, 把参数定义到 `CUSTOM_PARAMETERS`里, 例如:
+要创建自定义模板, 可以为引擎加载预定义额外参数. 预定义参数需要在 `<script>` 标签下, 把参数定义到 `CUSTOM_PARAMETERS`里. 
+::: important
+你的 `<script>` 要放在引用 dmloader.js 的`<script>`之后, 调用 `EngineLoader.load` 函数之前.
+:::
+例如:
 ```
     <script id='custom_setup' type='text/javascript'>
         CUSTOM_PARAMETERS['disable_context_menu'] = false;
@@ -197,6 +201,7 @@ DEFOLD_ENGINE_ARGUMENTS
 
 `CUSTOM_PARAMETERS` 可包含如下参数:
 
+```
 'archive_location_filter':
     包地址过滤.
 
@@ -220,7 +225,9 @@ DEFOLD_ENGINE_ARGUMENTS
 
 'can_not_download_file_callback':
     如果重试次数已满但是仍没有得到文件则需调用的回调函数.
-*/
+
+'resize_window_callback':
+    当屏幕 改变大小/改变方向/改变焦点 时调用.
 ```
 
 ## HTML5 的文件操作