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

Collision offset changes needed for Editor integration #4916

Merged
merged 2 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/framework/components/collision/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const _quat = new Quat();
* Defaults to "box".
* @property {Vec3} halfExtents The half-extents of the
* box-shaped collision volume in the x, y and z axes. Defaults to [0.5, 0.5, 0.5].
* @property {Vec3} linearOffset The positional offset of the collision shape from the Entity position in local space.
* @property {Vec3} linearOffset The positional offset of the collision shape from the Entity position along the local axes.
* Defaults to [0, 0, 0].
* @property {Quat} angularOffset The rotational offset of the collision shape from the Entity rotation in local space.
* Defaults to identity.
Expand Down
8 changes: 7 additions & 1 deletion src/framework/components/collision/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,13 @@ class CollisionComponentSystem extends ComponentSystem {
}

if (Array.isArray(data.angularOffset)) {
data.angularOffset = new Quat(data.angularOffset);
// Allow for euler angles to be passed as a 3 length array
const values = data.angularOffset;
if (values.length === 3) {
data.angularOffset = new Quat().setFromEulerAngles(values[0], values[1], values[2]);
} else {
data.angularOffset = new Quat(data.angularOffset);
}
}

const impl = this._createImplementation(data.type);
Expand Down