Skip to content

Commit ec2555f

Browse files
yaustarsteveny-sc
andauthored
Collision offset changes needed for Editor integration (#4916)
* Fixed jsdocs about linear offset not being in local space * Allows the creation of the new collision components to be given Euler values Makes Editor a lot simpler to do Co-authored-by: Steven Yau <syau@snapchat.com>
1 parent eb09f39 commit ec2555f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/framework/components/collision/component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const _quat = new Quat();
3939
* Defaults to "box".
4040
* @property {Vec3} halfExtents The half-extents of the
4141
* box-shaped collision volume in the x, y and z axes. Defaults to [0.5, 0.5, 0.5].
42-
* @property {Vec3} linearOffset The positional offset of the collision shape from the Entity position in local space.
42+
* @property {Vec3} linearOffset The positional offset of the collision shape from the Entity position along the local axes.
4343
* Defaults to [0, 0, 0].
4444
* @property {Quat} angularOffset The rotational offset of the collision shape from the Entity rotation in local space.
4545
* Defaults to identity.

src/framework/components/collision/system.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,13 @@ class CollisionComponentSystem extends ComponentSystem {
650650
}
651651

652652
if (Array.isArray(data.angularOffset)) {
653-
data.angularOffset = new Quat(data.angularOffset);
653+
// Allow for euler angles to be passed as a 3 length array
654+
const values = data.angularOffset;
655+
if (values.length === 3) {
656+
data.angularOffset = new Quat().setFromEulerAngles(values[0], values[1], values[2]);
657+
} else {
658+
data.angularOffset = new Quat(data.angularOffset);
659+
}
654660
}
655661

656662
const impl = this._createImplementation(data.type);

0 commit comments

Comments
 (0)