-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Merge branch 'master' into addons (likely breaks the branch)"
Revert the changes from the last merge as the functionality from the "Scene grabbables support" PR is expected to be present in this branch and has stuff built on top of it. This reverts commit e449f66, reversing changes made to 7a99b6f.
- Loading branch information
Showing
28 changed files
with
496 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { addComponent, defineQuery, enterQuery } from "bitecs"; | ||
import { HubsWorld } from "../app"; | ||
import { Holdable, MediaContentBounds, Networked, Rigidbody } from "../bit-components"; | ||
import { getBox } from "../utils/auto-box-collider"; | ||
import { Mesh, Vector3 } from "three"; | ||
import { takeSoftOwnership } from "../utils/take-soft-ownership"; | ||
import { EntityID } from "../utils/networking-types"; | ||
import { COLLISION_LAYERS } from "../constants"; | ||
|
||
const tmpVector = new Vector3(); | ||
|
||
const interactableQuery = defineQuery([Holdable, Rigidbody, Networked]); | ||
const interactableEnterQuery = enterQuery(interactableQuery); | ||
export function interactableSystem(world: HubsWorld) { | ||
interactableEnterQuery(world).forEach((eid: EntityID) => { | ||
// Somebody must own a scene grabbable otherwise the networked transform will fight with physics. | ||
if (Networked.creator[eid] === APP.getSid("scene") && Networked.owner[eid] === APP.getSid("reticulum")) { | ||
takeSoftOwnership(world, eid); | ||
} | ||
|
||
const obj = world.eid2obj.get(eid); | ||
let hasMesh = false; | ||
obj?.traverse(child => { | ||
if ((child as Mesh).isMesh) { | ||
hasMesh = true; | ||
} | ||
}); | ||
|
||
// If it has media frame collision mask, it needs to have content bounds | ||
if (hasMesh && Rigidbody.collisionFilterMask[eid] & COLLISION_LAYERS.MEDIA_FRAMES) { | ||
const box = getBox(obj, obj); | ||
if (!box.isEmpty()) { | ||
box.getSize(tmpVector); | ||
addComponent(world, MediaContentBounds, eid); | ||
MediaContentBounds.bounds[eid].set(tmpVector.toArray()); | ||
} else { | ||
console.error(`Couldn't create content bounds for entity ${eid}. It seems to be empty or have negative scale.`); | ||
} | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.