Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGLAttributes: Strict buffer size check when updating data. #27188

Merged
merged 5 commits into from
Nov 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/renderers/webgl/WebGLAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function WebGLAttributes( gl, capabilities ) {

const array = attribute.array;
const usage = attribute.usage;
const size = array.byteLength;

const buffer = gl.createBuffer();

Expand Down Expand Up @@ -76,7 +77,8 @@ function WebGLAttributes( gl, capabilities ) {
buffer: buffer,
type: type,
bytesPerElement: array.BYTES_PER_ELEMENT,
version: attribute.version
version: attribute.version,
size: size
};

}
Expand Down Expand Up @@ -199,6 +201,12 @@ function WebGLAttributes( gl, capabilities ) {

} else if ( data.version < attribute.version ) {

if ( data.size !== attribute.array.byteLength ) {

throw new Error( 'THREE.WebGLAttributes: The size of the buffer attribute\'s array buffer does not match the original size. Resizing buffer attributes is not supported.' );

}

updateBuffer( data.buffer, attribute, bufferType );

data.version = attribute.version;
Expand Down