Skip to content

Commit

Permalink
The collider's rotation changes from radians to degrees (#319)
Browse files Browse the repository at this point in the history
* feat: collider shape rotation change radians to degrees
  • Loading branch information
luzhuang authored Jan 2, 2025
1 parent bbb2f88 commit a9231a5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
24 changes: 20 additions & 4 deletions packages/auxiliary-lines/src/WireframeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import {
CircleShape,
ConeShape,
HemisphereShape,
SphereShape
SphereShape,
MathUtil
} from "@galacean/engine";
import { PlainColorMaterial } from "@galacean/engine-toolkit-custom-material";
import { WireframePrimitive } from "./WireframePrimitive";
Expand Down Expand Up @@ -350,7 +351,12 @@ export class WireframeManager extends Script {
indices,
this._indicesCount
);
Quaternion.rotationYawPitchRoll(rotation.x, rotation.y, rotation.z, tempRotation);
Quaternion.rotationYawPitchRoll(
MathUtil.degreeToRadian(rotation.y),
MathUtil.degreeToRadian(rotation.x),
MathUtil.degreeToRadian(rotation.z),
tempRotation
);
this._localRotation(positionsOffset, tempRotation);
Vector3.multiply(position, worldScale, tempVector);
this._localTranslate(positionsOffset, tempVector);
Expand Down Expand Up @@ -382,7 +388,12 @@ export class WireframeManager extends Script {
indices,
this._indicesCount
);
Quaternion.rotationYawPitchRoll(rotation.x, rotation.y, rotation.z, tempRotation);
Quaternion.rotationYawPitchRoll(
MathUtil.degreeToRadian(rotation.y),
MathUtil.degreeToRadian(rotation.x),
MathUtil.degreeToRadian(rotation.z),
tempRotation
);
this._localRotation(positionsOffset, tempRotation);
Vector3.multiply(position, worldScale, tempVector);
this._localTranslate(positionsOffset, tempVector);
Expand Down Expand Up @@ -431,7 +442,12 @@ export class WireframeManager extends Script {
case ColliderShapeUpAxis.Z:
tempAxis.set(halfSqrt, 0, 0, halfSqrt);
}
Quaternion.rotationYawPitchRoll(rotation.x, rotation.y, rotation.z, tempRotation);
Quaternion.rotationYawPitchRoll(
MathUtil.degreeToRadian(rotation.y),
MathUtil.degreeToRadian(rotation.x),
MathUtil.degreeToRadian(rotation.z),
tempRotation
);
Quaternion.multiply(tempRotation, tempAxis, tempRotation);
this._localRotation(positionsOffset, tempRotation);
Vector3.multiply(position, worldScale, tempVector);
Expand Down
2 changes: 1 addition & 1 deletion packages/navigation-gizmo/src/SphereScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export class SphereScript extends Script {
const { _tempQuat: tempQuat, _tempQuat2: tempQuat2 } = this;

Quaternion.rotationAxisAngle(SphereScript._startAxis, y, tempQuat);
Quaternion.rotationYawPitchRoll(x, 0, 0, tempQuat2);
Quaternion.rotationYawPitchRoll(0, x, 0, tempQuat2);
Quaternion.multiply(tempQuat, tempQuat2, tempQuat);
Vector3.subtract(SphereScript._startPos, this._target, this._rotateVec);

Expand Down

0 comments on commit a9231a5

Please sign in to comment.