Skip to content
Draft
Show file tree
Hide file tree
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
84 changes: 43 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"bugs": "https://github.com/decentraland/js-sdk-toolchain/issues",
"dependencies": {
"@actions/core": "^1.10.0",
"@dcl/protocol": "1.0.0-24513643863.commit-4851fd6",
"@dcl/protocol": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-26316313514.commit-8ee7c54.tgz",
"@dcl/quickjs-emscripten": "^0.21.0-3680274614.commit-1808aa1",
"@dcl/ts-proto": "1.153.0",
"@types/fs-extra": "^9.0.12",
Expand Down
4 changes: 2 additions & 2 deletions packages/@dcl/ecs/src/components/extended/TriggerArea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ export interface TriggerAreaComponentDefinitionExtended
* @public
* Set a box in the MeshCollider component
* @param entity - entity to create or replace the TriggerArea component
* @param collisionMask - the collision layers mask for the trigger to react, default: Player
* @param collisionMask - the collision layers mask for the trigger to react, default: CL_PLAYER
*/
setBox(entity: Entity, collisionMask?: ColliderLayer | ColliderLayer[]): void

/**
* @public
* Set a sphere in the MeshCollider component
* @param entity - entity to create or replace the TriggerArea component
* @param collisionMask - the collision layers mask for the trigger to react, default: Player
* @param collisionMask - the collision layers mask for the trigger to react, default: CL_PLAYER
*/
setSphere(entity: Entity, collisionMask?: ColliderLayer | ColliderLayer[]): void
}
Expand Down
3 changes: 1 addition & 2 deletions packages/@dcl/playground-assets/etc/playground-assets.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,12 @@ export const enum ColliderLayer {
CL_CUSTOM7 = 16384,
// (undocumented)
CL_CUSTOM8 = 32768,
CL_MAIN_PLAYER = 8,
CL_NONE = 0,
CL_PHYSICS = 2,
CL_PLAYER = 4,
CL_POINTER = 1,
// (undocumented)
CL_RESERVED2 = 8,
// (undocumented)
CL_RESERVED3 = 16,
// (undocumented)
CL_RESERVED4 = 32,
Expand Down
17 changes: 17 additions & 0 deletions test/ecs/components/MeshCollider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,21 @@ describe('Generated MeshCollider ProtoBuf', () => {
}
})
})

it('getCollisionMask combines CL_PLAYER and CL_MAIN_PLAYER into bitfield 12', () => {
const newEngine = Engine()
const entity = newEngine.addEntity()
const MeshCollider = components.MeshCollider(newEngine)

// CL_PLAYER = 4, CL_MAIN_PLAYER = 8 => OR = 12
MeshCollider.setBox(entity, [ColliderLayer.CL_PLAYER, ColliderLayer.CL_MAIN_PLAYER])
expect(MeshCollider.get(entity)).toStrictEqual({
collisionMask: 12,
mesh: {
$case: 'box',
box: {}
}
})
expect(ColliderLayer.CL_PLAYER | ColliderLayer.CL_MAIN_PLAYER).toBe(12)
})
})
15 changes: 15 additions & 0 deletions test/ecs/events/raycastHelperSystem.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,21 @@ describe('Raycast Helper System should', () => {
expect(fn).toHaveBeenCalled()
})

it('round-trips CL_MAIN_PLAYER collision mask through raycast helper', async () => {
const raycastEntity = engine.addEntity()
raycastHelperSystem.registerLocalDirectionRaycast(raycastEntity, (_result) => {}, {
direction: Vector3.Forward(),
queryType: RaycastQueryType.RQT_HIT_FIRST,
collisionMask: ColliderLayer.CL_MAIN_PLAYER
})

await engine.update(1)

const attachedRaycast = raycastComponent.get(raycastEntity)
expect(attachedRaycast.collisionMask).toBe(ColliderLayer.CL_MAIN_PLAYER)
expect(attachedRaycast.collisionMask).toBe(8)
})

it('attach raycast component after 1 frame', async () => {
const raycastEntity = engine.addEntity()
raycastHelperSystem.registerGlobalDirectionRaycast({ entity: raycastEntity }, (_result) => {})
Expand Down