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
3 changes: 1 addition & 2 deletions src/loaders/FileLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class FileLoader extends Loader {
* @param {function(any)} onLoad - Executed when the loading process has been finished.
* @param {onProgressCallback} [onProgress] - Executed while the loading is in progress.
* @param {onErrorCallback} [onError] - Executed when errors occur.
* @return {any|undefined} The cached resource if available.
*/
load( url, onLoad, onProgress, onError ) {

Expand All @@ -98,7 +97,7 @@ class FileLoader extends Loader {

}, 0 );

return cached;
return;

}

Expand Down
7 changes: 1 addition & 6 deletions src/loaders/ImageBitmapLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ class ImageBitmapLoader extends Loader {
* @param {function(ImageBitmap)} onLoad - Executed when the loading process has been finished.
* @param {onProgressCallback} onProgress - Unsupported in this loader.
* @param {onErrorCallback} onError - Executed when errors occur.
* @return {ImageBitmap|undefined} The image bitmap.
*/
load( url, onLoad, onProgress, onError ) {

Expand Down Expand Up @@ -145,8 +144,6 @@ class ImageBitmapLoader extends Loader {

scope.manager.itemEnd( url );

return imageBitmap;

}

} );
Expand All @@ -164,7 +161,7 @@ class ImageBitmapLoader extends Loader {

}, 0 );

return cached;
return;

}

Expand All @@ -189,8 +186,6 @@ class ImageBitmapLoader extends Loader {

scope.manager.itemEnd( url );

return imageBitmap;

} ).catch( function ( e ) {

if ( onError ) onError( e );
Expand Down
32 changes: 27 additions & 5 deletions src/renderers/shaders/UniformsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ export function cloneUniforms( src ) {

const property = src[ u ][ p ];

if ( property && ( property.isColor ||
property.isMatrix3 || property.isMatrix4 ||
property.isVector2 || property.isVector3 || property.isVector4 ||
property.isTexture || property.isQuaternion ) ) {
if ( isThreeObject( property ) ) {

if ( property.isRenderTargetTexture ) {

Expand All @@ -45,7 +42,23 @@ export function cloneUniforms( src ) {

} else if ( Array.isArray( property ) ) {

dst[ u ][ p ] = property.slice();
if ( isThreeObject( property[ 0 ] ) ) {

const clonedProperty = [];

for ( let i = 0, l = property.length; i < l; i ++ ) {

clonedProperty[ i ] = property[ i ].clone();

}

dst[ u ][ p ] = clonedProperty;

} else {

dst[ u ][ p ] = property.slice();

}

} else {

Expand Down Expand Up @@ -89,6 +102,15 @@ export function mergeUniforms( uniforms ) {

}

function isThreeObject( property ) {

return ( property && ( property.isColor ||
property.isMatrix3 || property.isMatrix4 ||
property.isVector2 || property.isVector3 || property.isVector4 ||
property.isTexture || property.isQuaternion ) );

}

export function cloneUniformsGroups( src ) {

const dst = [];
Expand Down
23 changes: 23 additions & 0 deletions test/unit/src/renderers/shaders/UniformsUtils.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,29 @@ export default QUnit.module( 'Renderers', () => {

} );

QUnit.test( 'cloneUniforms clones arrays of objects', ( assert ) => {

const uniforms = {
vector3Array: { value: [ new Vector3( 1, 2, 3 ), new Vector3( 4, 5, 6 ) ] },
};

const uniformClones = UniformsUtils.clone( uniforms );

// Cloned array is a different reference and contains different object references
assert.ok( uniforms.vector3Array.value !== uniformClones.vector3Array.value );
assert.ok( uniforms.vector3Array.value[ 0 ] !== uniformClones.vector3Array.value[ 0 ] );
assert.ok( uniforms.vector3Array.value[ 1 ] !== uniformClones.vector3Array.value[ 1 ] );

// Values are equal after cloning
assert.ok( uniforms.vector3Array.value[ 0 ].equals( uniformClones.vector3Array.value[ 0 ] ) );
assert.ok( uniforms.vector3Array.value[ 1 ].equals( uniformClones.vector3Array.value[ 1 ] ) );

// Mutating the original does not affect the clone
uniforms.vector3Array.value[ 0 ].x = 123.0;
assert.ok( ! uniforms.vector3Array.value[ 0 ].equals( uniformClones.vector3Array.value[ 0 ] ) );

} );

QUnit.test( 'cloneUniforms skips render target textures', ( assert ) => {

const uniforms = {
Expand Down
Loading