Skip to content

Commit

Permalink
WebGLAttributes: Strict buffer size check when updating data. (mrdoob…
Browse files Browse the repository at this point in the history
…#27188)

* Update WebGLAttributes.js

Strict check for buffer size while upload..

* fix: lint, pads

* Update WebGLAttributes.js

Implement the check even more strict. Clarify error message.

* Update WebGLAttributes.js

* Update WebGLAttributes.js

Fix typo.

---------

Co-authored-by: Michael Herzog <michael.herzog@human-interactive.org>
  • Loading branch information
2 people authored and AdaRoseCannon committed Jan 15, 2024
1 parent e4bfc5d commit 136a3ea
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/renderers/webgl/WebGLAttributes.js
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

0 comments on commit 136a3ea

Please sign in to comment.