diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index e079890440b69d..f5db620a9e8e16 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -278,7 +278,7 @@ function WebGLRenderer( parameters ) { info = new WebGLInfo( _gl ); properties = new WebGLProperties(); textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ); - attributes = new WebGLAttributes( _gl ); + attributes = new WebGLAttributes( _gl, capabilities ); geometries = new WebGLGeometries( _gl, attributes, info ); objects = new WebGLObjects( _gl, geometries, attributes, info ); morphtargets = new WebGLMorphtargets( _gl ); diff --git a/src/renderers/webgl/WebGLAttributes.d.ts b/src/renderers/webgl/WebGLAttributes.d.ts index b338e979118369..fcd74a3e6a6f56 100644 --- a/src/renderers/webgl/WebGLAttributes.d.ts +++ b/src/renderers/webgl/WebGLAttributes.d.ts @@ -1,9 +1,10 @@ +import { WebGLCapabilities } from "./WebGLCapabilities"; import { BufferAttribute } from "../../core/BufferAttribute"; import { InterleavedBufferAttribute } from "../../core/InterleavedBufferAttribute"; export class WebGLAttributes { - constructor( gl: WebGLRenderingContext | WebGL2RenderingContext ); + constructor( gl: WebGLRenderingContext | WebGL2RenderingContext, capabilities: WebGLCapabilities ); get( attribute: BufferAttribute | InterleavedBufferAttribute ): { buffer: WebGLBuffer, diff --git a/src/renderers/webgl/WebGLAttributes.js b/src/renderers/webgl/WebGLAttributes.js index 059d1f49c14670..81e123bf08f4f0 100644 --- a/src/renderers/webgl/WebGLAttributes.js +++ b/src/renderers/webgl/WebGLAttributes.js @@ -2,7 +2,7 @@ * @author mrdoob / http://mrdoob.com/ */ -function WebGLAttributes( gl ) { +function WebGLAttributes( gl, capabilities ) { var buffers = new WeakMap(); @@ -78,8 +78,17 @@ function WebGLAttributes( gl ) { } else { - gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT, - array.subarray( updateRange.offset, updateRange.offset + updateRange.count ) ); + if ( capabilities.isWebGL2 ) { + + gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT, + array, updateRange.offset, updateRange.count ); + + } else { + + gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT, + array.subarray( updateRange.offset, updateRange.offset + updateRange.count ) ); + + } updateRange.count = - 1; // reset range