|
@@ -1009,28 +1009,6 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
- //
|
|
|
|
-
|
|
|
|
- function initDirectBuffers( geometry ) {
|
|
|
|
-
|
|
|
|
- var keys = Object.keys( geometry.attributes );
|
|
|
|
-
|
|
|
|
- for ( var i = 0; i < keys.length; i ++ ) {
|
|
|
|
-
|
|
|
|
- var name = keys[ i ];
|
|
|
|
-
|
|
|
|
- var bufferType = ( name === 'index' ) ? _gl.ELEMENT_ARRAY_BUFFER : _gl.ARRAY_BUFFER;
|
|
|
|
-
|
|
|
|
- var attribute = geometry.attributes[ name ];
|
|
|
|
- attribute.buffer = _gl.createBuffer();
|
|
|
|
-
|
|
|
|
- _gl.bindBuffer( bufferType, attribute.buffer );
|
|
|
|
- _gl.bufferData( bufferType, attribute.array, _gl.STATIC_DRAW );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// Buffer setting
|
|
// Buffer setting
|
|
|
|
|
|
function setParticleBuffers ( geometry, hint, object ) {
|
|
function setParticleBuffers ( geometry, hint, object ) {
|
|
@@ -2325,7 +2303,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
- function setDirectBuffers( geometry, hint ) {
|
|
|
|
|
|
+ function setDirectBuffers( geometry ) {
|
|
|
|
|
|
var attributes = geometry.attributes;
|
|
var attributes = geometry.attributes;
|
|
|
|
|
|
@@ -2336,19 +2314,19 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
var attributeName = keys[ i ];
|
|
var attributeName = keys[ i ];
|
|
var attributeItem = attributes[ attributeName ];
|
|
var attributeItem = attributes[ attributeName ];
|
|
|
|
|
|
- if ( attributeItem.needsUpdate ) {
|
|
|
|
|
|
+ if ( attributeItem.buffer === undefined ) {
|
|
|
|
|
|
- if ( attributeName === 'index' ) {
|
|
|
|
|
|
+ attributeItem.buffer = _gl.createBuffer();
|
|
|
|
+ attributeItem.needsUpdate = true;
|
|
|
|
|
|
- _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, attributeItem.buffer );
|
|
|
|
- _gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, attributeItem.array, hint );
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
|
|
|
+ if ( attributeItem.needsUpdate === true ) {
|
|
|
|
|
|
- _gl.bindBuffer( _gl.ARRAY_BUFFER, attributeItem.buffer );
|
|
|
|
- _gl.bufferData( _gl.ARRAY_BUFFER, attributeItem.array, hint );
|
|
|
|
|
|
+ var bufferType = ( attributeName === 'index' ) ? _gl.ELEMENT_ARRAY_BUFFER : _gl.ARRAY_BUFFER;
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ _gl.bindBuffer( bufferType, attributeItem.buffer );
|
|
|
|
+ _gl.bufferData( bufferType, attributeItem.array, _gl.STATIC_DRAW );
|
|
|
|
|
|
attributeItem.needsUpdate = false;
|
|
attributeItem.needsUpdate = false;
|
|
|
|
|
|
@@ -3634,7 +3612,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
if ( geometry instanceof THREE.BufferGeometry ) {
|
|
if ( geometry instanceof THREE.BufferGeometry ) {
|
|
|
|
|
|
- initDirectBuffers( geometry );
|
|
|
|
|
|
+ //
|
|
|
|
|
|
} else if ( object instanceof THREE.Mesh ) {
|
|
} else if ( object instanceof THREE.Mesh ) {
|
|
|
|
|
|
@@ -3801,22 +3779,14 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
if ( geometry instanceof THREE.BufferGeometry ) {
|
|
if ( geometry instanceof THREE.BufferGeometry ) {
|
|
|
|
|
|
- setDirectBuffers( geometry, _gl.DYNAMIC_DRAW );
|
|
|
|
|
|
+ setDirectBuffers( geometry );
|
|
|
|
|
|
} else if ( object instanceof THREE.Mesh ) {
|
|
} else if ( object instanceof THREE.Mesh ) {
|
|
|
|
|
|
// check all geometry groups
|
|
// check all geometry groups
|
|
if ( geometry.buffersNeedUpdate || geometry.groupsNeedUpdate ) {
|
|
if ( geometry.buffersNeedUpdate || geometry.groupsNeedUpdate ) {
|
|
|
|
|
|
- if ( geometry instanceof THREE.BufferGeometry ) {
|
|
|
|
-
|
|
|
|
- initDirectBuffers( geometry );
|
|
|
|
-
|
|
|
|
- } else if ( object instanceof THREE.Mesh ) {
|
|
|
|
-
|
|
|
|
- initGeometryGroups(scene, object,geometry);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ initGeometryGroups(scene, object,geometry);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|