Skip to content

feat(node): 使setWorldPosition方法的z参数变为可选参数 - #32

Merged
star-e merged 2 commits into
cocos:v4.0.0from
orchid-world:v4.0.0-patch
Jan 19, 2026
Merged

feat(node): 使setWorldPosition方法的z参数变为可选参数#32
star-e merged 2 commits into
cocos:v4.0.0from
orchid-world:v4.0.0-patch

Conversation

@orchid-world

Copy link
Copy Markdown
Contributor

使Node类的setWorldPosition方法的z轴参数变为可选参数,当z参数未提供时,
默认使用当前节点的世界位置的z值。这增强了API的灵活性,允许开发者在
设置世界位置时只指定x和y坐标。

Re: #

Changelog


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

使Node类的setWorldPosition方法的z轴参数变为可选参数,当z参数未提供时,
默认使用当前节点的世界位置的z值。这增强了API的灵活性,允许开发者在
设置世界位置时只指定x和y坐标。
Fix lint
@github-actions

Copy link
Copy Markdown

Code Size Check Report

Wechat (WASM) Before After Diff
2D Empty (legacy pipeline) 1010278 bytes 1010300 bytes ⚠️ +22 bytes
2D All (legacy pipeline) 2675898 bytes 2675920 bytes ⚠️ +22 bytes
2D All (new pipeline) 2767635 bytes 2767657 bytes ⚠️ +22 bytes
(2D + 3D) All 10024632 bytes 10024654 bytes ⚠️ +22 bytes
Web (WASM + ASMJS) Before After Diff
(2D + 3D) All 16843200 bytes 16843222 bytes ⚠️ +22 bytes

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -25064,9 +25064,9 @@
          * @param x X axis position
          * @param y Y axis position
          * @param z Z axis position
          */
-        setWorldPosition(x: number, y: number, z: number): void;
+        setWorldPosition(x: number, y: number, z?: number): void;
         /**
          * @en Get position in world coordinate system, please try to pass `out` vector and reuse it to avoid garbage.
          * @zh 获取世界坐标,注意,尽可能传递复用的 [[Vec3]] 以避免产生垃圾。
          * @param out Set the result to out vector

Comment thread cocos/scene-graph/node.ts
@star-e
star-e merged commit 9997cb6 into cocos:v4.0.0 Jan 19, 2026
14 checks passed
@github-actions

Copy link
Copy Markdown

@orchid-world ❗ There was an error during the execution of the tasks. Please check the logs for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants