Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
169 changes: 120 additions & 49 deletions build/three.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -60656,7 +60656,7 @@ function WebGLBindingStates( gl, attributes ) {

let updateBuffers = false;

const state = getBindingState( geometry, program, material );
const state = getBindingState( object, geometry, program, material );

if ( currentState !== state ) {

Expand Down Expand Up @@ -60709,16 +60709,28 @@ function WebGLBindingStates( gl, attributes ) {

}

function getBindingState( geometry, program, material ) {
function getBindingState( object, geometry, program, material ) {

const wireframe = ( material.wireframe === true );

let programMap = bindingStates[ geometry.id ];
let objectMap = bindingStates[ geometry.id ];

if ( objectMap === undefined ) {

objectMap = {};
bindingStates[ geometry.id ] = objectMap;

}

// Each InstancedMesh requires unique binding states because it contains instanced attributes.
const objectId = ( object.isInstancedMesh === true ) ? object.id : 0;

let programMap = objectMap[ objectId ];

if ( programMap === undefined ) {

programMap = {};
bindingStates[ geometry.id ] = programMap;
objectMap[ objectId ] = programMap;

}

Expand Down Expand Up @@ -61119,21 +61131,27 @@ function WebGLBindingStates( gl, attributes ) {

for ( const geometryId in bindingStates ) {

const programMap = bindingStates[ geometryId ];
const objectMap = bindingStates[ geometryId ];

for ( const programId in programMap ) {
for ( const objectId in objectMap ) {

const stateMap = programMap[ programId ];
const programMap = objectMap[ objectId ];

for ( const wireframe in stateMap ) {
for ( const programId in programMap ) {

deleteVertexArrayObject( stateMap[ wireframe ].object );
const stateMap = programMap[ programId ];

delete stateMap[ wireframe ];
for ( const wireframe in stateMap ) {

}
deleteVertexArrayObject( stateMap[ wireframe ].object );

delete programMap[ programId ];
delete stateMap[ wireframe ];

}

delete programMap[ programId ];

}

}

Expand All @@ -61147,21 +61165,27 @@ function WebGLBindingStates( gl, attributes ) {

if ( bindingStates[ geometry.id ] === undefined ) return;

const programMap = bindingStates[ geometry.id ];
const objectMap = bindingStates[ geometry.id ];

for ( const programId in programMap ) {
for ( const objectId in objectMap ) {

const stateMap = programMap[ programId ];
const programMap = objectMap[ objectId ];

for ( const wireframe in stateMap ) {
for ( const programId in programMap ) {

deleteVertexArrayObject( stateMap[ wireframe ].object );
const stateMap = programMap[ programId ];

delete stateMap[ wireframe ];
for ( const wireframe in stateMap ) {

}
deleteVertexArrayObject( stateMap[ wireframe ].object );

delete stateMap[ wireframe ];

delete programMap[ programId ];
}

delete programMap[ programId ];

}

}

Expand All @@ -61173,26 +61197,73 @@ function WebGLBindingStates( gl, attributes ) {

for ( const geometryId in bindingStates ) {

const programMap = bindingStates[ geometryId ];
const objectMap = bindingStates[ geometryId ];

for ( const objectId in objectMap ) {

const programMap = objectMap[ objectId ];

if ( programMap[ program.id ] === undefined ) continue;

if ( programMap[ program.id ] === undefined ) continue;
const stateMap = programMap[ program.id ];

const stateMap = programMap[ program.id ];
for ( const wireframe in stateMap ) {

deleteVertexArrayObject( stateMap[ wireframe ].object );

for ( const wireframe in stateMap ) {
delete stateMap[ wireframe ];

deleteVertexArrayObject( stateMap[ wireframe ].object );
}

delete stateMap[ wireframe ];
delete programMap[ program.id ];

}

delete programMap[ program.id ];
}

}

function releaseStatesOfObject( object ) {

for ( const geometryId in bindingStates ) {

const objectMap = bindingStates[ geometryId ];

const objectId = ( object.isInstancedMesh === true ) ? object.id : 0;

const programMap = objectMap[ objectId ];

if ( programMap === undefined ) continue;

for ( const programId in programMap ) {

const stateMap = programMap[ programId ];

for ( const wireframe in stateMap ) {

deleteVertexArrayObject( stateMap[ wireframe ].object );

delete stateMap[ wireframe ];

}

delete programMap[ programId ];

}

delete objectMap[ objectId ];

if ( Object.keys( objectMap ).length === 0 ) {

delete bindingStates[ geometryId ];

}

}

}


function reset() {

resetDefaultState();
Expand Down Expand Up @@ -61222,6 +61293,7 @@ function WebGLBindingStates( gl, attributes ) {
resetDefaultState: resetDefaultState,
dispose: dispose,
releaseStatesOfGeometry: releaseStatesOfGeometry,
releaseStatesOfObject: releaseStatesOfObject,
releaseStatesOfProgram: releaseStatesOfProgram,

initAttributes: initAttributes,
Expand Down Expand Up @@ -63556,7 +63628,7 @@ function WebGLMorphtargets( gl, capabilities, textures ) {

}

function WebGLObjects( gl, geometries, attributes, info ) {
function WebGLObjects( gl, geometries, attributes, bindingStates, info ) {

let updateMap = new WeakMap();

Expand Down Expand Up @@ -63631,6 +63703,8 @@ function WebGLObjects( gl, geometries, attributes, info ) {

instancedMesh.removeEventListener( 'dispose', onInstancedMeshDispose );

bindingStates.releaseStatesOfObject( instancedMesh );

attributes.remove( instancedMesh.instanceMatrix );

if ( instancedMesh.instanceColor !== null ) attributes.remove( instancedMesh.instanceColor );
Expand Down Expand Up @@ -66953,6 +67027,10 @@ function painterSortStable( a, b ) {

return a.material.id - b.material.id;

} else if ( a.materialVariant !== b.materialVariant ) {

return a.materialVariant - b.materialVariant;

} else if ( a.z !== b.z ) {

return a.z - b.z;
Expand Down Expand Up @@ -67007,6 +67085,15 @@ function WebGLRenderList() {

}

function materialVariant( object ) {

let variant = 0;
if ( object.isInstancedMesh ) variant += 2;
if ( object.isSkinnedMesh ) variant += 1;
return variant;

}

function getNextRenderItem( object, geometry, material, groupOrder, z, group ) {

let renderItem = renderItems[ renderItemsIndex ];
Expand All @@ -67018,6 +67105,7 @@ function WebGLRenderList() {
object: object,
geometry: geometry,
material: material,
materialVariant: materialVariant( object ),
groupOrder: groupOrder,
renderOrder: object.renderOrder,
z: z,
Expand All @@ -67032,6 +67120,7 @@ function WebGLRenderList() {
renderItem.object = object;
renderItem.geometry = geometry;
renderItem.material = material;
renderItem.materialVariant = materialVariant( object );
renderItem.groupOrder = groupOrder;
renderItem.renderOrder = object.renderOrder;
renderItem.z = z;
Expand Down Expand Up @@ -75021,7 +75110,7 @@ class WebGLRenderer {
attributes = new WebGLAttributes( _gl );
bindingStates = new WebGLBindingStates( _gl, attributes );
geometries = new WebGLGeometries( _gl, attributes, info, bindingStates );
objects = new WebGLObjects( _gl, geometries, attributes, info );
objects = new WebGLObjects( _gl, geometries, attributes, bindingStates, info );
morphtargets = new WebGLMorphtargets( _gl, capabilities, textures );
clipping = new WebGLClipping( properties );
programCache = new WebGLPrograms( _this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping );
Expand Down Expand Up @@ -77747,27 +77836,9 @@ class WebGLRenderer {
* @param {?(Box2|Box3)} [srcRegion=null] - A bounding box which describes the source region. Can be two or three-dimensional.
* @param {?(Vector2|Vector3)} [dstPosition=null] - A vector that represents the origin of the destination region. Can be two or three-dimensional.
* @param {number} [srcLevel=0] - The source mipmap level to copy.
* @param {?number} [dstLevel=null] - The destination mipmap level.
* @param {?number} [dstLevel=0] - The destination mipmap level.
*/
this.copyTextureToTexture = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, srcLevel = 0, dstLevel = null ) {

// support the previous signature with just a single dst mipmap level
if ( dstLevel === null ) {

if ( srcLevel !== 0 ) {

// @deprecated, r171
warnOnce( 'WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels.' );
dstLevel = srcLevel;
srcLevel = 0;

} else {

dstLevel = 0;

}

}
this.copyTextureToTexture = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, srcLevel = 0, dstLevel = 0 ) {

// gather the necessary dimensions to copy
let width, height, depth, minX, minY, minZ;
Expand Down
Loading
Loading