objects_3d: use the xb BVH helper instead of patching THREE inline - #378
Merged
Conversation
… THREE inline google#372 landed the BVH helpers in the SDK (utils/BVHRaycast). drop the direct three-mesh-bvh import + manual Mesh/BufferGeometry prototype patch and call xb.enableAcceleratedRaycast() instead, which installs the same computeBoundsTree / disposeBoundsTree helpers via the SDK's dynamic import. the per-detect computeBoundsTree() / disposeBoundsTree() calls stay, they now resolve to the SDK-installed helpers. computeBoundsTree() is guarded since enableAcceleratedRaycast() is async (dynamic import), so an early Detect press before it resolves falls back to the stock raycaster instead of throwing. importmap keeps three-mesh-bvh (the SDK dynamic-imports it from the page's module graph at runtime), bumped to 0.9.10 to match the version the SDK is built against.
…press race enableAcceleratedRaycast() is async (dynamic import), so the previous guard only degraded gracefully on an early press, it still ran the stock raycaster for that press. store the kickoff promise and await it at the top of detect() (already async) before building the per-press bounds tree. normally already resolved since it's fired at init, so this is a no-op wait; a very early press now waits the import out and gets the accelerated path too. the computeBoundsTree guard stays for the genuine failure case: if three-mesh-bvh is unreachable the promise resolves false, the helper is never installed, and the build is skipped (stock raycaster).
salmanmkc
force-pushed
the
feat/objects-3d-followup
branch
from
June 16, 2026 07:10
de18b7d to
f215ec4
Compare
ruofeidu
approved these changes
Jun 17, 2026
salmanmkc
marked this pull request as ready for review
June 17, 2026 05:50
ruofeidu
approved these changes
Jun 17, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
objects_3d was wiring three-mesh-bvh onto
THREE.BufferGeometryitself to speed up the per-object raycasts in detect. now that #372 landed the SDK helper, switch toxb.enableAcceleratedRaycast()so the demo doesn't carry its own copy of that.also awaits BVH readiness in detect() before raycasting:
enableAcceleratedRaycast()imports three-mesh-bvh dynamically, so the first press used to race the import and fall back to the slow path.stacks on #363, rebase once that lands. (the draggable panel work moved to #379.)