Skip to content

Scene: InterleavedBuffer and InterleavedBufferAttribute, as three.js has them - #231

Closed
kvnloo wants to merge 1 commit into
meshy-dev:mainfrom
kvnloo:swarm/a14-parity-geometry-interleaved
Closed

kvnloo wants to merge 1 commit into
meshy-dev:mainfrom
kvnloo:swarm/a14-parity-geometry-interleaved

Conversation

@kvnloo

@kvnloo kvnloo commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Adds three.js r187's InterleavedBuffer and InterleavedBufferAttribute to the scene package (new interleaved.ts, exported from the index). The package had neither, so three.js code that packs position, normal and uv into one array failed to import. That includes hand-built vertex buffers and loader output.

  • InterleavedBuffer: array, stride, count, usage/setUsage, version/needsUpdate, updateRanges with addUpdateRange/clearUpdateRanges, copy, copyAt, set, clone.
  • InterleavedBufferAttribute: data, itemSize, offset, normalized, count/array from its buffer, and needsUpdate that bumps the buffer's version. It has every component getter and setter (normalized integers in 0..1 or -1..1, as three's), plus applyMatrix4, transformDirection, and clone(), which de-interleaves into a BufferAttribute the way three's clone() does when called without data.
  • BufferGeometry.setAttribute accepts an interleaved attribute and stores it de-interleaved (its clone()). This matches how the geometry already converts non-float positions, and the engine keeps reading plain per-attribute arrays. After editing the buffer, set the attribute again. That limitation is documented on the class.

Rendering paths are unchanged for existing scenes (no frame or ΔE numbers needed).

Tests: packages/scene/test/three-compat-interleaved.test.ts checks reads, writes, offsets and applyMatrix4 against three r187's classes, including a normalized Uint8 attribute. It also covers needsUpdate, clone, copyAt, and a geometry built from interleaved position and uv. npm run typecheck and npm test pass (203 pass, 1 skipped, 0 fail).

Drafted with AI assistance.

🤖 Generated with Claude Code

…has them

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kvnloo

kvnloo commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Folded into #247 so these review together; closing this one.

@kvnloo kvnloo closed this Nov 24, 2026
doodlewind added a commit that referenced this pull request Nov 24, 2026
… buffers, Euler in all six orders, and more (#256)

One commit for 21 small three.js-parity PRs by Kevin Rajan, each with its own test file:

- #210 Matrix4.scale, getMaxScaleOnAxis and multiplyScalar, as three.js has them
- #211 PerspectiveCamera.getFocalLength, getFilmWidth and getFilmHeight, as three.js has them
- #213 a normalized BufferAttribute's getters and setters work in 0..1, as three.js does
- #215 Euler.setFromQuaternion and setFromRotationMatrix in all six orders, as three.js has them
- #216 Light.dispose and LightShadow.dispose, as three.js has them
- #218 Box3.clampPoint, distanceToPoint, intersectsSphere and getBoundingSphere, as three.js has them
- #219 Matrix4.makeBasis, extractBasis, extractRotation and makeRotationAxis, as three.js has them
- #221 Int8, Uint8, Uint8Clamped, Int16 and Int32 BufferAttribute, as three.js has them
- #222 Quaternion identity, conjugate, length and slerpQuaternions, as three.js has them
- #223 MathUtils scalar helpers, as three.js has them
- #225 MeshPhysicalMaterial.reflectivity, as three.js has it
- #226 Plane, and Ray.intersectPlane / distanceToPlane / intersectsPlane, as three.js has them
- #228 Sphere.set, copy, isEmpty, containsPoint, intersectsSphere, applyMatrix4 and translate, as three.js has them
- #230 Object3D.copy and clone keep the source's rotation order, as three.js does
- #231 InterleavedBuffer and InterleavedBufferAttribute, as three.js has them
- #232 Color arithmetic and accessors, as three.js has them
- #234 Matrix3, Matrix4.setFromMatrix3 and Vector3.applyNormalMatrix, as three.js has them
- #235 Vector3's component-wise arithmetic, as three.js has it
- #236 Layers, Object3D.layers and Raycaster.layers, as three.js has them
- #238 Color sRGB conversions and the CSS color keywords, as three.js has them
- #239 Vector2's component-wise arithmetic, angle and rotateAround, as three.js has them

Co-authored-by: Kevin Rajan <7121943+kvnloo@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant