Skip to content

Commit

Permalink
Fix transformtranslate and rotate space bug (galacean#847)
Browse files Browse the repository at this point in the history
* fix: transform`translate` and `rotate` space bug
* refactor: opt comments
  • Loading branch information
GuoLei1990 authored Jun 29, 2022
1 parent 5b32849 commit e19dc56
Showing 1 changed file with 7 additions and 7 deletions.
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

0 comments on commit e19dc56

Please sign in to comment.