mrdoob/three.js — pull request #1030 by niklasvh (2012-01-05 19:06:39+00:00)
Title: Cloning sprites throws a 404 error

Cloning sprite throws a 404 error that the file name undefined was not found. To reproduce just make a texture, apply it to a sprite, and clone that sprite:

var texture = THREE.ImageUtils.loadTexture( "sprite2.jpg" );

// var texture = new THREE.Texture( canvas, new THREE.UVMapping(), THREE.ClampToEdgeWrapping, THREE.ClampToEdgeWrapping, THREE.NearestFilter, THREE.LinearMipMapLinearFilter );

var sprite = new THREE.Sprite( { map: texture, useScreenCoordinates: false, color: 0xffffff } );
var clonedSprite = THREE.SceneUtils.cloneObject( sprite ) ;

As the sprite is generated without map defined, the new sprite object assumes that the map property is a url (as it isn't instanceof THREE.Texture, but typeof undefined).

As with the current way sprites are created, it requires map to be defined, so when cloning the object, it needs to be defined right during creation.

Note that it currently functions correctly in the sense that it displays the texture as you would expect (as it does change the map to correct one, but by then the request for the undefined has been created), so it ends up throwing the 404 error.