Document IndexBuffer storage can be ArrayBuffer or typed array#8988
Merged
Conversation
The GLB parser passes typed arrays as IndexBuffer initial data, while other callers pass an ArrayBuffer, so storage/lock() can be either. Update the JSDoc for the constructor's initialData, lock() return, and setData() to reflect this, and fix a typo in the constructor example (UInt16Array -> Uint16Array). Closes #5869
Build size reportThis PR does not change the size of the minified bundles.
|
Public API reportThis PR changes the public API surface (+2 / −2), per the docs' rules (@ignore / @Private / undocumented are excluded). Show API diff-IndexBuffer.constructor(graphicsDevice: GraphicsDevice, format: number, numIndices: number, usage?: number, initialData?: ArrayBuffer, options?: { storage: boolean })
+IndexBuffer.constructor(graphicsDevice: GraphicsDevice, format: number, numIndices: number, usage?: number, initialData?: ArrayBuffer | ArrayBufferView<ArrayBufferLike>, options?: { storage: boolean })
-IndexBuffer.lock(): ArrayBuffer
+IndexBuffer.lock(): ArrayBuffer | ArrayBufferView<ArrayBufferLike>Informational only — this never fails the build. |
mvaligursky
added a commit
that referenced
this pull request
Jun 30, 2026
The GLB parser passes typed arrays as IndexBuffer initial data, while other callers pass an ArrayBuffer, so storage/lock() can be either. Update the JSDoc for the constructor's initialData, lock() return, and setData() to reflect this, and fix a typo in the constructor example (UInt16Array -> Uint16Array). Closes #5869 Co-authored-by: Martin Valigursky <mvaligursky@snapchat.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.
Closes #5869.
IndexBufferstores itsinitialDataby reference. The GLB parser passes typed arrays (Uint8/16/32Array) as initial data, while other callers pass anArrayBuffer, sostorage(andlock()) can be either form. The JSDoc previously documented onlyArrayBuffer, which is what the reporter ran into. Per discussion on the issue, the agreed fix is to document the actual contract rather than copy data or add new API surface.Changes:
initialDataas{ArrayBuffer|ArrayBufferView}, noting it is stored by reference (a typed array that is a view into a larger buffer is kept as-is).lock()as returning{ArrayBuffer|ArrayBufferView}, advising callers to useArrayBuffer.isViewto distinguish the two.setData()'sdataparam likewise (internal@ignoremethod).@example(UInt16Array->Uint16Array).API Changes:
lock(): ArrayBuffer | ArrayBufferViewandinitialData?: ArrayBuffer | ArrayBufferView.