|
@@ -660,77 +660,6 @@ function WebGLRenderer( parameters = {} ) {
|
|
|
|
|
|
// Buffer rendering
|
|
|
|
|
|
- function renderObjectImmediate( object, program ) {
|
|
|
-
|
|
|
- object.render( function ( object ) {
|
|
|
-
|
|
|
- _this.renderBufferImmediate( object, program );
|
|
|
-
|
|
|
- } );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- this.renderBufferImmediate = function ( object, program ) {
|
|
|
-
|
|
|
- bindingStates.initAttributes();
|
|
|
-
|
|
|
- const buffers = properties.get( object );
|
|
|
-
|
|
|
- if ( object.hasPositions && ! buffers.position ) buffers.position = _gl.createBuffer();
|
|
|
- if ( object.hasNormals && ! buffers.normal ) buffers.normal = _gl.createBuffer();
|
|
|
- if ( object.hasUvs && ! buffers.uv ) buffers.uv = _gl.createBuffer();
|
|
|
- if ( object.hasColors && ! buffers.color ) buffers.color = _gl.createBuffer();
|
|
|
-
|
|
|
- const programAttributes = program.getAttributes();
|
|
|
-
|
|
|
- if ( object.hasPositions ) {
|
|
|
-
|
|
|
- _gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.position );
|
|
|
- _gl.bufferData( _gl.ARRAY_BUFFER, object.positionArray, _gl.DYNAMIC_DRAW );
|
|
|
-
|
|
|
- bindingStates.enableAttribute( programAttributes.position.location );
|
|
|
- _gl.vertexAttribPointer( programAttributes.position.location, 3, _gl.FLOAT, false, 0, 0 );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if ( object.hasNormals ) {
|
|
|
-
|
|
|
- _gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.normal );
|
|
|
- _gl.bufferData( _gl.ARRAY_BUFFER, object.normalArray, _gl.DYNAMIC_DRAW );
|
|
|
-
|
|
|
- bindingStates.enableAttribute( programAttributes.normal.location );
|
|
|
- _gl.vertexAttribPointer( programAttributes.normal.location, 3, _gl.FLOAT, false, 0, 0 );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if ( object.hasUvs ) {
|
|
|
-
|
|
|
- _gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.uv );
|
|
|
- _gl.bufferData( _gl.ARRAY_BUFFER, object.uvArray, _gl.DYNAMIC_DRAW );
|
|
|
-
|
|
|
- bindingStates.enableAttribute( programAttributes.uv.location );
|
|
|
- _gl.vertexAttribPointer( programAttributes.uv.location, 2, _gl.FLOAT, false, 0, 0 );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if ( object.hasColors ) {
|
|
|
-
|
|
|
- _gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.color );
|
|
|
- _gl.bufferData( _gl.ARRAY_BUFFER, object.colorArray, _gl.DYNAMIC_DRAW );
|
|
|
-
|
|
|
- bindingStates.enableAttribute( programAttributes.color.location );
|
|
|
- _gl.vertexAttribPointer( programAttributes.color.location, 3, _gl.FLOAT, false, 0, 0 );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- bindingStates.disableUnusedAttributes();
|
|
|
-
|
|
|
- _gl.drawArrays( _gl.TRIANGLES, 0, object.count );
|
|
|
-
|
|
|
- object.count = 0;
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
this.renderBufferDirect = function ( camera, scene, geometry, material, object, group ) {
|
|
|
|
|
|
if ( scene === null ) scene = _emptyScene; // renderBufferDirect second parameter used to be fog (could be null)
|
|
@@ -1166,17 +1095,6 @@ function WebGLRenderer( parameters = {} ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- } else if ( object.isImmediateRenderObject ) {
|
|
|
-
|
|
|
- if ( sortObjects ) {
|
|
|
-
|
|
|
- _vector3.setFromMatrixPosition( object.matrixWorld )
|
|
|
- .applyMatrix4( _projScreenMatrix );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- currentRenderList.push( object, null, object.material, groupOrder, _vector3.z, null );
|
|
|
-
|
|
|
} else if ( object.isMesh || object.isLine || object.isPoints ) {
|
|
|
|
|
|
if ( object.isSkinnedMesh ) {
|
|
@@ -1331,35 +1249,21 @@ function WebGLRenderer( parameters = {} ) {
|
|
|
|
|
|
material.onBeforeRender( _this, scene, camera, geometry, object, group );
|
|
|
|
|
|
- if ( object.isImmediateRenderObject ) {
|
|
|
+ if ( material.transparent === true && material.side === DoubleSide ) {
|
|
|
|
|
|
- const program = setProgram( camera, scene, geometry, material, object );
|
|
|
+ material.side = BackSide;
|
|
|
+ material.needsUpdate = true;
|
|
|
+ _this.renderBufferDirect( camera, scene, geometry, material, object, group );
|
|
|
|
|
|
- state.setMaterial( material );
|
|
|
+ material.side = FrontSide;
|
|
|
+ material.needsUpdate = true;
|
|
|
+ _this.renderBufferDirect( camera, scene, geometry, material, object, group );
|
|
|
|
|
|
- bindingStates.reset();
|
|
|
-
|
|
|
- renderObjectImmediate( object, program );
|
|
|
+ material.side = DoubleSide;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- if ( material.transparent === true && material.side === DoubleSide ) {
|
|
|
-
|
|
|
- material.side = BackSide;
|
|
|
- material.needsUpdate = true;
|
|
|
- _this.renderBufferDirect( camera, scene, geometry, material, object, group );
|
|
|
-
|
|
|
- material.side = FrontSide;
|
|
|
- material.needsUpdate = true;
|
|
|
- _this.renderBufferDirect( camera, scene, geometry, material, object, group );
|
|
|
-
|
|
|
- material.side = DoubleSide;
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- _this.renderBufferDirect( camera, scene, geometry, material, object, group );
|
|
|
-
|
|
|
- }
|
|
|
+ _this.renderBufferDirect( camera, scene, geometry, material, object, group );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1508,11 +1412,11 @@ function WebGLRenderer( parameters = {} ) {
|
|
|
const environment = material.isMeshStandardMaterial ? scene.environment : null;
|
|
|
const encoding = ( _currentRenderTarget === null ) ? _this.outputEncoding : _currentRenderTarget.texture.encoding;
|
|
|
const envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || environment );
|
|
|
- const vertexAlphas = material.vertexColors === true && !! geometry && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4;
|
|
|
- const vertexTangents = !! material.normalMap && !! geometry && !! geometry.attributes.tangent;
|
|
|
- const morphTargets = !! geometry && !! geometry.morphAttributes.position;
|
|
|
- const morphNormals = !! geometry && !! geometry.morphAttributes.normal;
|
|
|
- const morphTargetsCount = ( !! geometry && !! geometry.morphAttributes.position ) ? geometry.morphAttributes.position.length : 0;
|
|
|
+ const vertexAlphas = material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4;
|
|
|
+ const vertexTangents = !! material.normalMap && !! geometry.attributes.tangent;
|
|
|
+ const morphTargets = !! geometry.morphAttributes.position;
|
|
|
+ const morphNormals = !! geometry.morphAttributes.normal;
|
|
|
+ const morphTargetsCount = !! geometry.morphAttributes.position ? geometry.morphAttributes.position.length : 0;
|
|
|
|
|
|
const materialProperties = properties.get( material );
|
|
|
const lights = currentRenderState.state.lights;
|