After updating to 6.2.8, parsing 3D models with interleaved buffer always gives the following error.
TypeError: Cannot set property count of #<InterleavedBufferAttribute> which has only a getter
at file:///<redacted>/node_modules/.pnpm/gltfjsx@6.2.8/node_modules/gltfjsx/src/bin/GLTFLoader.js:1675:27
at async Promise.all (index 0)
at async Promise.all (index 0)
at async Promise.all (index 0)
at async Promise.all (index 1)
at async Promise.all (index 0)
at async Promise.all (index 1)
at async Promise.all (index 0)
at async Promise.all (index 0)
However, in InterleavedBufferAttribute, count is just a getter that returns the count of the underlying InterleavedBuffer. Attempting to assign a new value to count will throw an error.
Issue
After updating to 6.2.8, parsing 3D models with interleaved buffer always gives the following error.
Investigation
In /src/bin/GLTFLoader.js#L1675, the
count
property ofbufferAttribute
is assigned an updated value.Prior to the assignment,
bufferAttribute
was instantiated as eitherBufferAttribute
orInterleavedBufferAttribute
. This is fine forBufferAttribute
as itscount
property is mutable.However, in
InterleavedBufferAttribute
,count
is just a getter that returns the count of the underlyingInterleavedBuffer
. Attempting to assign a new value tocount
will throw an error.https://github.com/mrdoob/three.js/blob/master/src/core/InterleavedBufferAttribute.js#L23
This issue doesn't apply to versions prior to 6.2.8 because the line was newly added to this version.
Solution
I made a very small fix to update
count
differently if thebufferAttribute
is aInterleavedBufferAttribute
.