Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provides world position that are converted to up,right,forward direction #6287

Merged
merged 8 commits into from Mar 20, 2020
Merged

provides world position that are converted to up,right,forward direction #6287

merged 8 commits into from Mar 20, 2020

Conversation

zhefengzhang
Copy link
Contributor

@zhefengzhang zhefengzhang commented Mar 5, 2020

Re: cocos/2d-tasks#2181

Changes:
*
新增三个接口 getUpWorldPositiongetRightWorldPositiongetForwardWorldPosition

Add three new interfaces getUpWorld Position , getRightWorldPosition, getForwardWorld Position.

@cocos-robot cocos-robot changed the base branch from v2.3.1-release to v2.3.2 Mar 6, 2020
Copy link
Contributor

@cocos-robot cocos-robot left a comment

@Jno1995, v2.3.1-release branch will be deleted, so we edited the base branch to v2.3.2, or this PR will be killed by GitHub.
Please review the commits history to ensure that the PR does not polluted by unneeded commits from your origin branch.
If you need to merge to other branch, you can first click the Edit button on the right side of the PR title, then switch the base branch.
If necessary, welcome to resubmit a new PR. Thanks!

* @method getUpWorldPosition
* @return {Vec3}
*/
getUpWorldPosition () {
Copy link
Contributor

@holycanvas holycanvas Mar 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥叫worldPosition, 应该是获取局部空间中的 UP 轴在世界坐标系中的向量,直接用 up, left, forward 就行

Copy link
Contributor Author

@zhefengzhang zhefengzhang Mar 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你是说只提供一个接口,然后让用户自己选择传递 up、left 或者 forward ?

cocos2d/core/CCNode.js Outdated Show resolved Hide resolved
cocos2d/core/CCNode.js Outdated Show resolved Hide resolved
cocos2d/core/CCNode.js Outdated Show resolved Hide resolved
cocos2d/core/CCNode.js Outdated Show resolved Hide resolved

/**
* !#en Get the node vector of the nodes that are converted to the forward direction.
* !#zh 获取转换到正前方的节点向量
Copy link
Member

@jareguo jareguo Mar 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量

cocos2d/core/CCNode.js Outdated Show resolved Hide resolved
cocos2d/core/CCNode.js Outdated Show resolved Hide resolved
cocos2d/core/CCNode.js Outdated Show resolved Hide resolved
cocos2d/core/CCNode.js Outdated Show resolved Hide resolved
@zhefengzhang
Copy link
Contributor Author

@zhefengzhang zhefengzhang commented Mar 6, 2020

@cocos-robot cocos-robot changed the base branch from v2.3.2 to v2.3.3-release Mar 9, 2020
Copy link
Contributor

@cocos-robot cocos-robot left a comment

@Jno1995, v2.3.2 branch will be deleted, so we edited the base branch to v2.3.3-release, or this PR will be killed by GitHub.
Please review the commits history to ensure that the PR does not polluted by unneeded commits from your origin branch.
If you need to merge to other branch, you can first click the Edit button on the right side of the PR title, then switch the base branch.
If necessary, welcome to resubmit a new PR. Thanks!

//up、right、forward temp var
var _uVec3 = new Vec3();
var _rVec3 = new Vec3();
var _fVec3 = new vec3();
Copy link
Contributor

@holycanvas holycanvas Mar 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vec3 大小写写错了

Copy link
Contributor Author

@zhefengzhang zhefengzhang Mar 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯嗯

@zhefengzhang
Copy link
Contributor Author

@zhefengzhang zhefengzhang commented Mar 14, 2020

up: {
get () {
this._up = Vec3.transformQuat(_uVec3, Vec3.UP, this.getWorldRotation(new Quat()));
return this._up;
Copy link
Contributor Author

@zhefengzhang zhefengzhang Mar 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里输出结果为 Vec3 类型,与 2D 节点的 position 类型保持一致。

cocos2d/core/CCNode.js Outdated Show resolved Hide resolved
cocos2d/core/CCNode.js Outdated Show resolved Hide resolved
cocos2d/core/CCNode.js Outdated Show resolved Hide resolved
cocos2d/core/CCNode.js Outdated Show resolved Hide resolved
cocos2d/core/CCNode.js Outdated Show resolved Hide resolved
@holycanvas holycanvas merged commit dea50cd into cocos:v2.3.3-release Mar 20, 2020
1 check passed
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.

None yet

4 participants