提交 ea0054a1 编写于 作者: M Mr.doob

Updated builds.

上级 76c66400
......@@ -6927,7 +6927,6 @@ THREE.EventDispatcher.prototype = {
var material = object.material;
if ( material === undefined ) return intersects;
if ( geometry.dynamic === false ) return intersects;
var a, b, c;
var precision = raycaster.precision;
......@@ -9533,10 +9532,6 @@ THREE.BufferGeometry = function () {
this.attributes = {};
// attributes typed arrays are kept only if dynamic flag is set
this.dynamic = true;
// offsets for chunks when using indexed elements
this.offsets = [];
......@@ -20174,6 +20169,8 @@ THREE.WebGLRenderer = function ( parameters ) {
_precision = parameters.precision !== undefined ? parameters.precision : 'highp',
_buffers = {},
_alpha = parameters.alpha !== undefined ? parameters.alpha : false,
_premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true,
_antialias = parameters.antialias !== undefined ? parameters.antialias : false,
......@@ -20301,7 +20298,7 @@ THREE.WebGLRenderer = function ( parameters ) {
_currentWidth = 0,
_currentHeight = 0,
_enabledAttributes = {},
_enabledAttributes = new Uint8Array( 16 ),
// frustum
......@@ -21241,6 +21238,27 @@ THREE.WebGLRenderer = function ( parameters ) {
};
function initGeometry2Buffers( geometry ) {
var buffers = {};
var attributes = [ 'vertices', 'normals', 'uvs' ];
for ( var key in attributes ) {
var array = geometry[ attributes[ key ] ];
var buffer = _gl.createBuffer();
_gl.bindBuffer( _gl.ARRAY_BUFFER, buffer );
_gl.bufferData( _gl.ARRAY_BUFFER, array, _gl.STATIC_DRAW );
buffers[ attributes[ key ] ] = buffer;
}
_buffers[ geometry.id ] = buffers;
};
// Buffer setting
function setParticleBuffers ( geometry, hint, object ) {
......@@ -22579,7 +22597,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
function setDirectBuffers ( geometry, hint, dispose ) {
function setDirectBuffers( geometry, hint ) {
var attributes = geometry.attributes;
......@@ -22607,14 +22625,29 @@ THREE.WebGLRenderer = function ( parameters ) {
}
if ( dispose && ! attributeItem.dynamic ) {
}
attributeItem.array = null;
}
}
function setGeometry2Buffers( geometry, hint ) {
if ( geometry.needsUpdate === false ) return;
var attributes = [ 'vertices', 'normals', 'uvs' ];
var buffers = _buffers[ geometry.id ];
for ( var key in attributes ) {
var array = geometry[ attributes[ key ] ];
var buffer = buffers[ attributes[ key ] ];
_gl.bindBuffer( _gl.ARRAY_BUFFER, buffer );
_gl.bufferData( _gl.ARRAY_BUFFER, array, hint );
}
geometry.needsUpdate = false;
};
// Buffer rendering
......@@ -22712,6 +22745,56 @@ THREE.WebGLRenderer = function ( parameters ) {
};
this.renderBufferGeometry2 = function ( camera, lights, fog, material, geometry, object ) {
var program = setProgram( camera, lights, fog, material, object );
var programAttributes = program.attributes;
var attributes = { 'position': 'vertices', 'normal': 'normals', 'uv': 'uvs' };
var itemSizes = { 'position': 3, 'normal': 3, 'uv': 2 };
var buffers = _buffers[ geometry.id ];
disableAttributes();
for ( var name in programAttributes ) {
var attributePointer = programAttributes[ name ];
if ( attributePointer >= 0 ) {
var array = geometry[ attributes[ name ] ];
if ( array !== undefined && array.length > 0 ) {
_gl.bindBuffer( _gl.ARRAY_BUFFER, buffers[ attributes[ name ] ] );
enableAttribute( attributePointer );
_gl.vertexAttribPointer( attributePointer, itemSizes[ name ], _gl.FLOAT, false, 0, 0 );
} else {
if ( itemSizes[ name ] === 3 ) {
_gl.vertexAttrib3fv( attributePointer, [ 0, 0, 0 ] );
} else if ( itemSizes[ name ] === 2 ) {
_gl.vertexAttrib2fv( attributePointer, [ 0, 0 ] );
}
}
}
}
_gl.drawArrays( _gl.TRIANGLES, 0, geometry.vertices.length / 3 );
};
this.renderBufferDirect = function ( camera, lights, fog, material, geometry, object ) {
if ( material.visible === false ) return;
......@@ -23210,10 +23293,10 @@ THREE.WebGLRenderer = function ( parameters ) {
function enableAttribute( attribute ) {
if ( ! _enabledAttributes[ attribute ] ) {
if ( _enabledAttributes[ attribute ] === 0 ) {
_gl.enableVertexAttribArray( attribute );
_enabledAttributes[ attribute ] = true;
_enabledAttributes[ attribute ] = 1;
}
......@@ -23223,10 +23306,10 @@ THREE.WebGLRenderer = function ( parameters ) {
for ( var attribute in _enabledAttributes ) {
if ( _enabledAttributes[ attribute ] ) {
if ( _enabledAttributes[ attribute ] === 1 ) {
_gl.disableVertexAttribArray( attribute );
_enabledAttributes[ attribute ] = false;
_enabledAttributes[ attribute ] = 0;
}
......@@ -23626,7 +23709,7 @@ THREE.WebGLRenderer = function ( parameters ) {
};
function renderObjects ( renderList, reverse, materialType, camera, lights, fog, useBlending, overrideMaterial ) {
function renderObjects( renderList, reverse, materialType, camera, lights, fog, useBlending, overrideMaterial ) {
var webglObject, object, buffer, material, start, end, delta;
......@@ -23676,6 +23759,10 @@ THREE.WebGLRenderer = function ( parameters ) {
_this.renderBufferDirect( camera, lights, fog, material, buffer, object );
} else if ( buffer instanceof THREE.Geometry2 ) {
_this.renderBufferGeometry2( camera, lights, fog, material, buffer, object );
} else {
_this.renderBuffer( camera, lights, fog, material, buffer, object );
......@@ -23960,6 +24047,10 @@ THREE.WebGLRenderer = function ( parameters ) {
initDirectBuffers( geometry );
} else if ( geometry instanceof THREE.Geometry2 ) {
initGeometry2Buffers( geometry );
} else if ( object instanceof THREE.Mesh ) {
material = object.material;
......@@ -24034,6 +24125,10 @@ THREE.WebGLRenderer = function ( parameters ) {
addBuffer( scene.__webglObjects, geometry, object );
} else if ( geometry instanceof THREE.Geometry2 ) {
addBuffer( scene.__webglObjects, geometry, object );
} else if ( geometry instanceof THREE.Geometry ) {
for ( g in geometry.geometryGroups ) {
......@@ -24110,7 +24205,11 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( geometry instanceof THREE.BufferGeometry ) {
setDirectBuffers( geometry, _gl.DYNAMIC_DRAW, !geometry.dynamic );
setDirectBuffers( geometry, _gl.DYNAMIC_DRAW );
} else if ( geometry instanceof THREE.Geometry2 ) {
setGeometry2Buffers( geometry, _gl.DYNAMIC_DRAW );
} else if ( object instanceof THREE.Mesh ) {
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册