Conversation
|
A zero-copy bridge to three.js and a scene-wide drop-in that lets math drive three's transforms. - bridge: Matrix4.elements is math's Mat4 as-is; helpers for instance buffers, attributes, camera frustums and world-space bounding spheres - extend(scene): every object gets a Transform record of tuples, with Vector3/Quaternion/Euler views over them so three's API keeps working. The scene's updateMatrixWorld becomes one flat parents-first pass. Objects added later join via childadded, subclasses that override updateMatrixWorld (Camera, SkinnedMesh) are delegated to, per-node matrixAutoUpdate/matrixWorldAutoUpdate/pivot are honored, and explicitly written Euler angles survive until the quaternion changes - transformOf(object), extendObject(object), release, propagate, unextend - three is an optional peer dependency (>=0.166, where forced updates respect matrixWorldAutoUpdate); rollup keeps it external - labs benches under benches/three (@three) comparing against three's own API with outputs asserted equal, plus a vite page for browser runs - vitest coverage in tst/unit/three against plain three Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
krispya
force-pushed
the
feat/three-bridge
branch
from
September 7, 2026 07:57
57e16b9 to
102c6f2
Compare
krispya
added a commit
to krispya/threejs-conf-talk
that referenced
this pull request
Sep 11, 2026
The benchmark overlay now renders inside the stone portal on a dark backing instead of floating in front of the camera. A benchmarkVariant on Screen switches between the spider IK comparison with bar columns and a new math-three-benchmark screen showing instanced transforms, scene graph updates, and frustum culling timings from pmndrs/math#50. Timeline tests cover the new screen order through Games and the closing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Adds a zero-copy bridge for Three while keeping the usual Object3D math interfaces like position, scale, rotation and quaternion synced. No patching, all userland code.
Basically, we take advantage of the fact that the Three Matrix4 are already array backed and directly copied for GPU buffers. We take this over and then replace the Object3D math objects with our own that access the Math tuples via getters and setters. This makes using Math path very fast with a small hit to perf (the cost of accessors) on the Object3D path. In hot paths we get a 1.4-2.7x speedup.
extend)The API uses a handle to get the Math tuples associated with the Object3D.