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

Fix transformtranslate and rotate space bug #847

Merged
merged 2 commits into from
Jun 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/core/src/Transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ export class Transform extends Component {
/**
* Translate in the direction and distance of the translation.
* @param translation - Direction and distance of translation
* @param relativeToLocal - Is relative to the local coordinate system
* @param relativeToLocal = `true` - Is relative to the local coordinate system
*/
translate(translation: Vector3, relativeToLocal?: boolean): void;

Expand All @@ -438,7 +438,7 @@ export class Transform extends Component {
* @param x - Distance along the x axis
* @param y - Distance along the y axis
* @param z - Distance along the z axis
* @param relativeToLocal - Is relative to the local coordinate system
* @param relativeToLocal = `true` - Is relative to the local coordinate system
*/
translate(x: number, y: number, z: number, relativeToLocal?: boolean): void;

Expand All @@ -460,7 +460,7 @@ export class Transform extends Component {
/**
* Rotate around the passed Vector3.
* @param rotation - Euler angle in degrees
* @param relativeToLocal - Is relative to the local coordinate system
* @param relativeToLocal = `true` - Is relative to the local coordinate system
*/
rotate(rotation: Vector3, relativeToLocal?: boolean): void;

Expand All @@ -469,7 +469,7 @@ export class Transform extends Component {
* @param x - Rotation along x axis, in degrees
* @param y - Rotation along y axis, in degrees
* @param z - Rotation along z axis, in degrees
* @param relativeToLocal - Is relative to the local coordinate system
* @param relativeToLocal = `true` - Is relative to the local coordinate system
*/
rotate(x: number, y: number, z: number, relativeToLocal?: boolean): void;

Expand All @@ -490,7 +490,7 @@ export class Transform extends Component {
* Rotate around the specified axis according to the specified angle.
* @param axis - Rotate axis
* @param angle - Rotate angle in degrees
* @param relativeToLocal - Relative to local space
* @param relativeToLocal = `true` - Relative to local space
*/
rotateByAxis(axis: Vector3, angle: number, relativeToLocal: boolean = true): void {
const rad = angle * MathUtil.degreeToRadFactor;
Expand Down Expand Up @@ -719,7 +719,7 @@ export class Transform extends Component {
}
}

private _translate(translation: Vector3, relativeToLocal: boolean): void {
private _translate(translation: Vector3, relativeToLocal: boolean = true): void {
if (relativeToLocal) {
const { _tempVec30 } = Transform;
Vector3.transformByQuat(translation, this.worldRotationQuaternion, _tempVec30);
Expand All @@ -729,7 +729,7 @@ export class Transform extends Component {
}
}

private _rotateXYZ(x: number, y: number, z: number, relativeToLocal: boolean): void {
private _rotateXYZ(x: number, y: number, z: number, relativeToLocal: boolean = true): void {
const radFactor = MathUtil.degreeToRadFactor;
const rotQuat = Transform._tempQuat0;
Quaternion.rotationEuler(x * radFactor, y * radFactor, z * radFactor, rotQuat);
Expand Down