-
-
Couldn't load subscription status.
- Fork 182
Closed
Labels
bugSomething isn't workingSomething isn't workingcurrent releaseissues to do with the current release of Threeissues to do with the current release of Threerequest for commentsDiscussion about changes to the libraryDiscussion about changes to the library
Description
Problem description:
Documented as BufferAttributes only being able to be given a TypedArray, but when you call attribute.array the return type is ArrayLike instead of a version of TypedArray – https://threejs.org/docs/#api/en/core/BufferAttribute
this becomes a problem in code like estimateBytesUsed in BufferGeometryUtils:
export function estimateBytesUsed(geometry: BufferGeometry) {
let mem = 0
for (let name in geometry.attributes) {
const attr = geometry.getAttribute(name)
mem += attr.count * attr.itemSize * (attr.array as TypedArray).BYTES_PER_ELEMENT // you have to typecase to get BYTES_PER_ELEMENT because it's not on ArrayLike
}
const indices = geometry.getIndex()
mem += indices ? indices.count * indices.itemSize * (indices.array as TypedArray).BYTES_PER_ELEMENT : 0
return mem
}Suggested solution:
Could we use a generic to detect the type of TypedArray passed to the Attribute so that type is returned when we call attribute.array?
ycw and kmannislands
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingcurrent releaseissues to do with the current release of Threeissues to do with the current release of Threerequest for commentsDiscussion about changes to the libraryDiscussion about changes to the library