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
4 changes: 4 additions & 0 deletions src/core/RenderTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,10 @@ class RenderTarget extends EventDispatcher {

}

} else {

this.depthTexture = null;

}

this.samples = source.samples;
Expand Down
6 changes: 5 additions & 1 deletion src/objects/BatchedMesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -1487,11 +1487,15 @@ class BatchedMesh extends Mesh {
this._matricesTexture = source._matricesTexture.clone();
this._matricesTexture.image.data = this._matricesTexture.image.data.slice();

if ( this._colorsTexture !== null ) {
if ( source._colorsTexture !== null ) {

this._colorsTexture = source._colorsTexture.clone();
this._colorsTexture.image.data = this._colorsTexture.image.data.slice();

} else {

this._colorsTexture = null;

}

return this;
Expand Down
8 changes: 4 additions & 4 deletions src/objects/InstancedMesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ class InstancedMesh extends Mesh {

this.instanceMatrix.copy( source.instanceMatrix );

if ( source.morphTexture !== null ) this.morphTexture = source.morphTexture.clone();
if ( source.instanceColor !== null ) this.instanceColor = source.instanceColor.clone();
this.morphTexture = source.morphTexture !== null ? source.morphTexture.clone() : null;
this.instanceColor = source.instanceColor !== null ? source.instanceColor.clone() : null;

this.count = source.count;

if ( source.boundingBox !== null ) this.boundingBox = source.boundingBox.clone();
if ( source.boundingSphere !== null ) this.boundingSphere = source.boundingSphere.clone();
this.boundingBox = source.boundingBox !== null ? source.boundingBox.clone() : null;
this.boundingSphere = source.boundingSphere !== null ? source.boundingSphere.clone() : null;

return this;

Expand Down
8 changes: 8 additions & 0 deletions src/objects/Mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,20 @@ class Mesh extends Object3D {

this.morphTargetInfluences = source.morphTargetInfluences.slice();

} else {

this.morphTargetInfluences = undefined;

}

if ( source.morphTargetDictionary !== undefined ) {

this.morphTargetDictionary = Object.assign( {}, source.morphTargetDictionary );

} else {

this.morphTargetDictionary = undefined;

}

this.material = Array.isArray( source.material ) ? source.material.slice() : source.material;
Expand Down
4 changes: 2 additions & 2 deletions src/objects/SkinnedMesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ class SkinnedMesh extends Mesh {

this.skeleton = source.skeleton;

if ( source.boundingBox !== null ) this.boundingBox = source.boundingBox.clone();
if ( source.boundingSphere !== null ) this.boundingSphere = source.boundingSphere.clone();
this.boundingBox = source.boundingBox !== null ? source.boundingBox.clone() : null;
this.boundingSphere = source.boundingSphere !== null ? source.boundingSphere.clone() : null;

return this;

Expand Down
27 changes: 5 additions & 22 deletions src/renderers/common/Attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Attributes extends DataMap {
/**
* Deletes the data for the given attribute.
*
* @param {BufferAttribute} attribute - The attribute.
* @param {BufferAttribute|InterleavedBuffer} attribute - The attribute.
* @return {?Object} The deleted attribute data.
*/
delete( attribute ) {
Expand Down Expand Up @@ -90,7 +90,7 @@ class Attributes extends DataMap {
* Updates the given attribute. This method creates attribute buffers
* for new attributes and updates data for existing ones.
*
* @param {BufferAttribute} attribute - The attribute to update.
* @param {BufferAttribute|InterleavedBuffer} attribute - The attribute to update.
* @param {number} type - The attribute type.
*/
update( attribute, type ) {
Expand Down Expand Up @@ -121,7 +121,7 @@ class Attributes extends DataMap {

}

data.version = this._getBufferAttribute( attribute ).version;
data.version = attribute.version;

// only storage buffer attributes support disposal

Expand All @@ -145,35 +145,18 @@ class Attributes extends DataMap {

} else {

const bufferAttribute = this._getBufferAttribute( attribute );

if ( data.version < bufferAttribute.version || bufferAttribute.usage === DynamicDrawUsage ) {
if ( data.version < attribute.version || attribute.usage === DynamicDrawUsage ) {

this.backend.updateAttribute( attribute );

data.version = bufferAttribute.version;
data.version = attribute.version;

}

}

}

/**
* Utility method for handling interleaved buffer attributes correctly.
* To process them, their `InterleavedBuffer` is returned.
*
* @param {BufferAttribute} attribute - The attribute.
* @return {BufferAttribute|InterleavedBuffer}
*/
_getBufferAttribute( attribute ) {

if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;

return attribute;

}

dispose() {

for ( const ref of this._tracked ) {
Expand Down
15 changes: 15 additions & 0 deletions src/renderers/common/Backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,21 @@ class Backend {
*/
destroyAttribute( /*attribute*/ ) { }

/**
* Utility method for handling interleaved buffer attributes correctly.
* To process them, their `InterleavedBuffer` is returned.
*
* @param {BufferAttribute|InterleavedBufferAttribute} attribute - The attribute.
* @return {BufferAttribute|InterleavedBuffer}
*/
getBufferAttribute( attribute ) {

if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;

return attribute;

}

// canvas

/**
Expand Down
32 changes: 6 additions & 26 deletions src/renderers/common/Geometries.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class Geometries extends DataMap {

for ( const attribute of Object.values( geometry.attributes ) ) {

this.attributes.delete( attribute );
this.attributes.delete( this.backend.getBufferAttribute( attribute ) );

}

Expand Down Expand Up @@ -313,33 +313,13 @@ class Geometries extends DataMap {

const callId = this.info.render.calls;

if ( ! attribute.isInterleavedBufferAttribute ) {
const bufferAttribute = this.backend.getBufferAttribute( attribute );

if ( this.attributeCall.get( attribute ) !== callId ) {
if ( this.attributeCall.get( bufferAttribute ) !== callId ) {

this.attributes.update( attribute, type );
this.attributes.update( bufferAttribute, type );

this.attributeCall.set( attribute, callId );

}

} else {

if ( this.attributeCall.get( attribute ) === undefined ) {

this.attributes.update( attribute, type );

this.attributeCall.set( attribute, callId );

} else if ( this.attributeCall.get( attribute.data ) !== callId ) {

this.attributes.update( attribute, type );

this.attributeCall.set( attribute.data, callId );

this.attributeCall.set( attribute, callId );

}
this.attributeCall.set( bufferAttribute, callId );

}

Expand Down Expand Up @@ -425,7 +405,7 @@ class Geometries extends DataMap {

if ( currentAttributes.has( attribute ) === false ) {

this.attributes.delete( attribute );
this.attributes.delete( this.backend.getBufferAttribute( attribute ) );

}

Expand Down
13 changes: 7 additions & 6 deletions src/renderers/common/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1839,10 +1839,6 @@ class Renderer {

}

this.getDrawingBufferSize( _drawingBufferSize );

_screen.set( 0, 0, _drawingBufferSize.width, _drawingBufferSize.height );

const minDepth = ( viewport.minDepth === undefined ) ? 0 : viewport.minDepth;
const maxDepth = ( viewport.maxDepth === undefined ) ? 1 : viewport.maxDepth;

Expand All @@ -1851,10 +1847,8 @@ class Renderer {
renderContext.viewportValue.height >>= activeMipmapLevel;
renderContext.viewportValue.minDepth = minDepth;
renderContext.viewportValue.maxDepth = maxDepth;
renderContext.viewport = renderContext.viewportValue.equals( _screen ) === false;

renderContext.scissorValue.copy( scissor ).multiplyScalar( pixelRatio ).floor();
renderContext.scissor = canvasTarget._scissorTest && renderContext.scissorValue.equals( _screen ) === false;
renderContext.scissorValue.width >>= activeMipmapLevel;
renderContext.scissorValue.height >>= activeMipmapLevel;

Expand Down Expand Up @@ -1912,6 +1906,8 @@ class Renderer {

} else {

this.getDrawingBufferSize( _drawingBufferSize );

renderContext.textures = null;
renderContext.depthTexture = null;
renderContext.width = _drawingBufferSize.width;
Expand Down Expand Up @@ -1944,6 +1940,11 @@ class Renderer {

}

_screen.set( 0, 0, renderContext.width, renderContext.height );

renderContext.viewport = renderContext.viewportValue.equals( _screen ) === false;
renderContext.scissor = canvasTarget._scissorTest && renderContext.scissorValue.equals( _screen ) === false;

//

this._background.update( sceneRef, renderList, renderContext );
Expand Down
16 changes: 10 additions & 6 deletions src/renderers/webgl-fallback/WebGLBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ class WebGLBackend extends Backend {

} else {

const { width, height } = this.getDrawingBufferSize();
const { width, height } = renderContext;
state.viewport( 0, 0, width, height );

}
Expand All @@ -502,7 +502,7 @@ class WebGLBackend extends Backend {

} else {

const { width, height } = this.getDrawingBufferSize();
const { width, height } = renderContext;
state.scissor( 0, 0, width, height );

}
Expand Down Expand Up @@ -603,7 +603,7 @@ class WebGLBackend extends Backend {

} else {

const { width, height } = this.getDrawingBufferSize();
const { width, height } = previousContext;
state.viewport( 0, 0, width, height );

}
Expand All @@ -614,7 +614,7 @@ class WebGLBackend extends Backend {

} else {

const { width, height } = this.getDrawingBufferSize();
const { width, height } = previousContext;
state.scissor( 0, 0, width, height );

}
Expand Down Expand Up @@ -2873,8 +2873,12 @@ class WebGLBackend extends Backend {
if ( this.vertexArrayUtils !== null ) this.vertexArrayUtils.dispose();
if ( this.textureUtils !== null ) this.textureUtils.dispose();

const extension = this.extensions.get( 'WEBGL_lose_context' );
if ( extension ) extension.loseContext();
if ( this.parameters.canvas === undefined ) {

const extension = this.extensions.get( 'WEBGL_lose_context' );
if ( extension ) extension.loseContext();

}

this.renderer.domElement.removeEventListener( 'webglcontextlost', this._onContextLost );

Expand Down
Loading
Loading