Skip to content

Commit 136a3ea

Browse files
eXponentaMugen87
authored andcommitted
WebGLAttributes: Strict buffer size check when updating data. (mrdoob#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 <[email protected]>
1 parent e4bfc5d commit 136a3ea

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/renderers/webgl/WebGLAttributes.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function WebGLAttributes( gl, capabilities ) {
88

99
const array = attribute.array;
1010
const usage = attribute.usage;
11+
const size = array.byteLength;
1112

1213
const buffer = gl.createBuffer();
1314

@@ -76,7 +77,8 @@ function WebGLAttributes( gl, capabilities ) {
7677
buffer: buffer,
7778
type: type,
7879
bytesPerElement: array.BYTES_PER_ELEMENT,
79-
version: attribute.version
80+
version: attribute.version,
81+
size: size
8082
};
8183

8284
}
@@ -199,6 +201,12 @@ function WebGLAttributes( gl, capabilities ) {
199201

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

204+
if ( data.size !== attribute.array.byteLength ) {
205+
206+
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.' );
207+
208+
}
209+
202210
updateBuffer( data.buffer, attribute, bufferType );
203211

204212
data.version = attribute.version;

0 commit comments

Comments
 (0)