浏览代码

Object.assign()ed lights and objects.

Mr.doob 9 年之前
父节点
当前提交
141e514d06

+ 6 - 6
examples/canvas_interactive_cubes.html

@@ -90,9 +90,9 @@
 					}
 					}
 
 
 				} );
 				} );
-				
+
 				//
 				//
-				
+
 				raycaster = new THREE.Raycaster();
 				raycaster = new THREE.Raycaster();
 				mouse = new THREE.Vector2();
 				mouse = new THREE.Vector2();
 
 
@@ -122,16 +122,16 @@
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 
 
 			}
 			}
-			
+
 			function onDocumentTouchStart( event ) {
 			function onDocumentTouchStart( event ) {
-				
+
 				event.preventDefault();
 				event.preventDefault();
-				
+
 				event.clientX = event.touches[0].clientX;
 				event.clientX = event.touches[0].clientX;
 				event.clientY = event.touches[0].clientY;
 				event.clientY = event.touches[0].clientY;
 				onDocumentMouseDown( event );
 				onDocumentMouseDown( event );
 
 
-			}	
+			}
 
 
 			function onDocumentMouseDown( event ) {
 			function onDocumentMouseDown( event ) {
 
 

+ 2 - 0
src/Three.Legacy.js

@@ -8,6 +8,8 @@ Object.assign( THREE, {
 		console.warn( 'THREE.Face4 has been removed. A THREE.Face3 will be created instead.' );
 		console.warn( 'THREE.Face4 has been removed. A THREE.Face3 will be created instead.' );
 		return new THREE.Face3( a, b, c, normal, color, materialIndex );
 		return new THREE.Face3( a, b, c, normal, color, materialIndex );
 	},
 	},
+	LineStrip: 0,
+	LinePieces: 1,
 	MeshFaceMaterial: THREE.MultiMaterial,
 	MeshFaceMaterial: THREE.MultiMaterial,
 	PointCloud: function ( geometry, material ) {
 	PointCloud: function ( geometry, material ) {
 		console.warn( 'THREE.PointCloud has been renamed to THREE.Points.' );
 		console.warn( 'THREE.PointCloud has been renamed to THREE.Points.' );

+ 5 - 2
src/lights/AmbientLight.js

@@ -12,5 +12,8 @@ THREE.AmbientLight = function ( color, intensity ) {
 
 
 };
 };
 
 
-THREE.AmbientLight.prototype = Object.create( THREE.Light.prototype );
-THREE.AmbientLight.prototype.constructor = THREE.AmbientLight;
+THREE.AmbientLight.prototype = Object.assign( Object.create( THREE.Light.prototype ), {
+
+	constructor: THREE.AmbientLight
+
+} );

+ 11 - 8
src/lights/DirectionalLight.js

@@ -18,17 +18,20 @@ THREE.DirectionalLight = function ( color, intensity ) {
 
 
 };
 };
 
 
-THREE.DirectionalLight.prototype = Object.create( THREE.Light.prototype );
-THREE.DirectionalLight.prototype.constructor = THREE.DirectionalLight;
+THREE.DirectionalLight.prototype = Object.assign( Object.create( THREE.Light.prototype ), {
 
 
-THREE.DirectionalLight.prototype.copy = function ( source ) {
+	constructor: THREE.DirectionalLight,
 
 
-	THREE.Light.prototype.copy.call( this, source );
+	copy: function ( source ) {
 
 
-	this.target = source.target.clone();
+		THREE.Light.prototype.copy.call( this, source );
 
 
-	this.shadow = source.shadow.clone();
+		this.target = source.target.clone();
 
 
-	return this;
+		this.shadow = source.shadow.clone();
 
 
-};
+		return this;
+
+	}
+
+} );

+ 5 - 2
src/lights/DirectionalLightShadow.js

@@ -8,5 +8,8 @@ THREE.DirectionalLightShadow = function ( light ) {
 
 
 };
 };
 
 
-THREE.DirectionalLightShadow.prototype = Object.create( THREE.LightShadow.prototype );
-THREE.DirectionalLightShadow.prototype.constructor = THREE.DirectionalLightShadow;
+THREE.DirectionalLightShadow.prototype = Object.assign( Object.create( THREE.LightShadow.prototype ), {
+
+	constructor: THREE.DirectionalLightShadow
+
+} );

+ 10 - 7
src/lights/HemisphereLight.js

@@ -17,15 +17,18 @@ THREE.HemisphereLight = function ( skyColor, groundColor, intensity ) {
 
 
 };
 };
 
 
-THREE.HemisphereLight.prototype = Object.create( THREE.Light.prototype );
-THREE.HemisphereLight.prototype.constructor = THREE.HemisphereLight;
+THREE.HemisphereLight.prototype = Object.assign( Object.create( THREE.Light.prototype ), {
 
 
-THREE.HemisphereLight.prototype.copy = function ( source ) {
+	constructor: THREE.HemisphereLight,
 
 
-	THREE.Light.prototype.copy.call( this, source );
+	copy: function ( source ) {
 
 
-	this.groundColor.copy( source.groundColor );
+		THREE.Light.prototype.copy.call( this, source );
 
 
-	return this;
+		this.groundColor.copy( source.groundColor );
 
 
-};
+		return this;
+
+	}
+
+} );

+ 22 - 19
src/lights/Light.js

@@ -16,34 +16,37 @@ THREE.Light = function ( color, intensity ) {
 
 
 };
 };
 
 
-THREE.Light.prototype = Object.create( THREE.Object3D.prototype );
-THREE.Light.prototype.constructor = THREE.Light;
+THREE.Light.prototype = Object.assign( Object.create( THREE.Object3D.prototype ), {
 
 
-THREE.Light.prototype.copy = function ( source ) {
+	constructor: THREE.Light,
 
 
-	THREE.Object3D.prototype.copy.call( this, source );
+	copy: function ( source ) {
 
 
-	this.color.copy( source.color );
-	this.intensity = source.intensity;
+		THREE.Object3D.prototype.copy.call( this, source );
 
 
-	return this;
+		this.color.copy( source.color );
+		this.intensity = source.intensity;
 
 
-};
+		return this;
 
 
-THREE.Light.prototype.toJSON = function ( meta ) {
+	},
 
 
-	var data = THREE.Object3D.prototype.toJSON.call( this, meta );
+	toJSON: function ( meta ) {
 
 
-	data.object.color = this.color.getHex();
-	data.object.intensity = this.intensity;
+		var data = THREE.Object3D.prototype.toJSON.call( this, meta );
 
 
-	if ( this.groundColor !== undefined ) data.object.groundColor = this.groundColor.getHex();
+		data.object.color = this.color.getHex();
+		data.object.intensity = this.intensity;
 
 
-	if ( this.distance !== undefined ) data.object.distance = this.distance;
-	if ( this.angle !== undefined ) data.object.angle = this.angle;
-	if ( this.decay !== undefined ) data.object.decay = this.decay;
-	if ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra;
+		if ( this.groundColor !== undefined ) data.object.groundColor = this.groundColor.getHex();
 
 
-	return data;
+		if ( this.distance !== undefined ) data.object.distance = this.distance;
+		if ( this.angle !== undefined ) data.object.angle = this.angle;
+		if ( this.decay !== undefined ) data.object.decay = this.decay;
+		if ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra;
 
 
-};
+		return data;
+
+	}
+
+} );

+ 2 - 4
src/lights/LightShadow.js

@@ -16,9 +16,7 @@ THREE.LightShadow = function ( camera ) {
 
 
 };
 };
 
 
-THREE.LightShadow.prototype = {
-
-	constructor: THREE.LightShadow,
+Object.assign( THREE.LightShadow.prototype, {
 
 
 	copy: function ( source ) {
 	copy: function ( source ) {
 
 
@@ -39,4 +37,4 @@ THREE.LightShadow.prototype = {
 
 
 	}
 	}
 
 
-};
+} );

+ 22 - 25
src/lights/PointLight.js

@@ -9,6 +9,20 @@ THREE.PointLight = function ( color, intensity, distance, decay ) {
 
 
 	this.type = 'PointLight';
 	this.type = 'PointLight';
 
 
+	Object.defineProperty( this, 'power', {
+		get: function () {
+			// intensity = power per solid angle.
+			// ref: equation (15) from http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf
+			return this.intensity * 4 * Math.PI;
+
+		},
+		set: function ( power ) {
+			// intensity = power per solid angle.
+			// ref: equation (15) from http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf
+			this.intensity = power / ( 4 * Math.PI );
+		}
+	} );
+
 	this.distance = ( distance !== undefined ) ? distance : 0;
 	this.distance = ( distance !== undefined ) ? distance : 0;
 	this.decay = ( decay !== undefined ) ? decay : 1;	// for physically correct lights, should be 2.
 	this.decay = ( decay !== undefined ) ? decay : 1;	// for physically correct lights, should be 2.
 
 
@@ -16,38 +30,21 @@ THREE.PointLight = function ( color, intensity, distance, decay ) {
 
 
 };
 };
 
 
-THREE.PointLight.prototype = Object.create( THREE.Light.prototype );
-THREE.PointLight.prototype.constructor = THREE.PointLight;
+THREE.PointLight.prototype = Object.assign( Object.create( THREE.Light.prototype ), {
 
 
-Object.defineProperty( THREE.PointLight.prototype, "power", {
+	constructor: THREE.PointLight,
 
 
-	get: function () {
+	copy: function ( source ) {
 
 
-		// intensity = power per solid angle.
-		// ref: equation (15) from http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf
-		return this.intensity * 4 * Math.PI;
+		THREE.Light.prototype.copy.call( this, source );
 
 
-	},
+		this.distance = source.distance;
+		this.decay = source.decay;
 
 
-	set: function ( power ) {
+		this.shadow = source.shadow.clone();
 
 
-		// intensity = power per solid angle.
-		// ref: equation (15) from http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf
-		this.intensity = power / ( 4 * Math.PI );
+		return this;
 
 
 	}
 	}
 
 
 } );
 } );
-
-THREE.PointLight.prototype.copy = function ( source ) {
-
-	THREE.Light.prototype.copy.call( this, source );
-
-	this.distance = source.distance;
-	this.decay = source.decay;
-
-	this.shadow = source.shadow.clone();
-
-	return this;
-
-};

+ 25 - 29
src/lights/SpotLight.js

@@ -13,6 +13,19 @@ THREE.SpotLight = function ( color, intensity, distance, angle, penumbra, decay
 
 
 	this.target = new THREE.Object3D();
 	this.target = new THREE.Object3D();
 
 
+	Object.defineProperty( this, 'power', {
+		get: function () {
+			// intensity = power per solid angle.
+			// ref: equation (17) from http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf
+			return this.intensity * Math.PI;
+		},
+		set: function ( power ) {
+			// intensity = power per solid angle.
+			// ref: equation (17) from http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf
+			this.intensity = power / Math.PI;
+		}
+	} );
+
 	this.distance = ( distance !== undefined ) ? distance : 0;
 	this.distance = ( distance !== undefined ) ? distance : 0;
 	this.angle = ( angle !== undefined ) ? angle : Math.PI / 3;
 	this.angle = ( angle !== undefined ) ? angle : Math.PI / 3;
 	this.penumbra = ( penumbra !== undefined ) ? penumbra : 0;
 	this.penumbra = ( penumbra !== undefined ) ? penumbra : 0;
@@ -22,42 +35,25 @@ THREE.SpotLight = function ( color, intensity, distance, angle, penumbra, decay
 
 
 };
 };
 
 
-THREE.SpotLight.prototype = Object.create( THREE.Light.prototype );
-THREE.SpotLight.prototype.constructor = THREE.SpotLight;
+THREE.SpotLight.prototype = Object.assign( Object.create( THREE.Light.prototype ), {
+
+	constructor: THREE.SpotLight,
 
 
-Object.defineProperty( THREE.SpotLight.prototype, "power", {
+	copy: function ( source ) {
 
 
-	get: function () {
+		THREE.Light.prototype.copy.call( this, source );
 
 
-		// intensity = power per solid angle.
-		// ref: equation (17) from http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf
-		return this.intensity * Math.PI;
+		this.distance = source.distance;
+		this.angle = source.angle;
+		this.penumbra = source.penumbra;
+		this.decay = source.decay;
 
 
-	},
+		this.target = source.target.clone();
 
 
-	set: function ( power ) {
+		this.shadow = source.shadow.clone();
 
 
-		// intensity = power per solid angle.
-		// ref: equation (17) from http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf
-		this.intensity = power / Math.PI;
+		return this;
 
 
 	}
 	}
 
 
 } );
 } );
-
-THREE.SpotLight.prototype.copy = function ( source ) {
-
-	THREE.Light.prototype.copy.call( this, source );
-
-	this.distance = source.distance;
-	this.angle = source.angle;
-	this.penumbra = source.penumbra;
-	this.decay = source.decay;
-
-	this.target = source.target.clone();
-
-	this.shadow = source.shadow.clone();
-
-	return this;
-
-};

+ 16 - 13
src/lights/SpotLightShadow.js

@@ -8,24 +8,27 @@ THREE.SpotLightShadow = function () {
 
 
 };
 };
 
 
-THREE.SpotLightShadow.prototype = Object.create( THREE.LightShadow.prototype );
-THREE.SpotLightShadow.prototype.constructor = THREE.SpotLightShadow;
+THREE.SpotLightShadow.prototype = Object.assign( Object.create( THREE.LightShadow.prototype ), {
 
 
-THREE.SpotLightShadow.prototype.update = function ( light ) {
+	constructor: THREE.SpotLightShadow,
 
 
-	var fov = THREE.Math.RAD2DEG * 2 * light.angle;
-	var aspect = this.mapSize.width / this.mapSize.height;
-	var far = light.distance || 500;
+	update: function ( light ) {
 
 
-	var camera = this.camera;
+		var fov = THREE.Math.RAD2DEG * 2 * light.angle;
+		var aspect = this.mapSize.width / this.mapSize.height;
+		var far = light.distance || 500;
 
 
-	if ( fov !== camera.fov || aspect !== camera.aspect || far !== camera.far ) {
+		var camera = this.camera;
 
 
-		camera.fov = fov;
-		camera.aspect = aspect;
-		camera.far = far;
-		camera.updateProjectionMatrix();
+		if ( fov !== camera.fov || aspect !== camera.aspect || far !== camera.far ) {
+
+			camera.fov = fov;
+			camera.aspect = aspect;
+			camera.far = far;
+			camera.updateProjectionMatrix();
+
+		}
 
 
 	}
 	}
 
 
-};
+} );

+ 10 - 7
src/objects/Bone.js

@@ -14,15 +14,18 @@ THREE.Bone = function ( skin ) {
 
 
 };
 };
 
 
-THREE.Bone.prototype = Object.create( THREE.Object3D.prototype );
-THREE.Bone.prototype.constructor = THREE.Bone;
+THREE.Bone.prototype = Object.assign( Object.create( THREE.Object3D.prototype ), {
 
 
-THREE.Bone.prototype.copy = function ( source ) {
+	constructor: THREE.Bone,
 
 
-	THREE.Object3D.prototype.copy.call( this, source );
+	copy: function ( source ) {
 
 
-	this.skin = source.skin;
+		THREE.Object3D.prototype.copy.call( this, source );
 
 
-	return this;
+		this.skin = source.skin;
 
 
-};
+		return this;
+
+	}
+
+} );

+ 5 - 2
src/objects/Group.js

@@ -10,5 +10,8 @@ THREE.Group = function () {
 
 
 };
 };
 
 
-THREE.Group.prototype = Object.create( THREE.Object3D.prototype );
-THREE.Group.prototype.constructor = THREE.Group;
+THREE.Group.prototype = Object.assign( Object.create( THREE.Object3D.prototype ), {
+
+	constructor: THREE.Group
+
+} );

+ 78 - 75
src/objects/LOD.js

@@ -20,149 +20,152 @@ THREE.LOD = function () {
 };
 };
 
 
 
 
-THREE.LOD.prototype = Object.create( THREE.Object3D.prototype );
-THREE.LOD.prototype.constructor = THREE.LOD;
+THREE.LOD.prototype = Object.assign( Object.create( THREE.Object3D.prototype ), {
 
 
-THREE.LOD.prototype.addLevel = function ( object, distance ) {
+	constructor: THREE.LOD,
 
 
-	if ( distance === undefined ) distance = 0;
+	copy: function ( source ) {
 
 
-	distance = Math.abs( distance );
+		THREE.Object3D.prototype.copy.call( this, source, false );
 
 
-	var levels = this.levels;
+		var levels = source.levels;
 
 
-	for ( var l = 0; l < levels.length; l ++ ) {
+		for ( var i = 0, l = levels.length; i < l; i ++ ) {
 
 
-		if ( distance < levels[ l ].distance ) {
+			var level = levels[ i ];
 
 
-			break;
+			this.addLevel( level.object.clone(), level.distance );
 
 
 		}
 		}
 
 
-	}
+		return this;
 
 
-	levels.splice( l, 0, { distance: distance, object: object } );
+	},
 
 
-	this.add( object );
+	addLevel: function ( object, distance ) {
 
 
-};
+		if ( distance === undefined ) distance = 0;
 
 
-THREE.LOD.prototype.getObjectForDistance = function ( distance ) {
+		distance = Math.abs( distance );
 
 
-	var levels = this.levels;
+		var levels = this.levels;
 
 
-	for ( var i = 1, l = levels.length; i < l; i ++ ) {
+		for ( var l = 0; l < levels.length; l ++ ) {
 
 
-		if ( distance < levels[ i ].distance ) {
+			if ( distance < levels[ l ].distance ) {
 
 
-			break;
+				break;
+
+			}
 
 
 		}
 		}
 
 
-	}
+		levels.splice( l, 0, { distance: distance, object: object } );
 
 
-	return levels[ i - 1 ].object;
+		this.add( object );
 
 
-};
+	},
 
 
-THREE.LOD.prototype.raycast = ( function () {
+	getObjectForDistance: function ( distance ) {
 
 
-	var matrixPosition = new THREE.Vector3();
+		var levels = this.levels;
 
 
-	return function raycast( raycaster, intersects ) {
+		for ( var i = 1, l = levels.length; i < l; i ++ ) {
 
 
-		matrixPosition.setFromMatrixPosition( this.matrixWorld );
+			if ( distance < levels[ i ].distance ) {
 
 
-		var distance = raycaster.ray.origin.distanceTo( matrixPosition );
+				break;
 
 
-		this.getObjectForDistance( distance ).raycast( raycaster, intersects );
+			}
 
 
-	};
+		}
 
 
-}() );
+		return levels[ i - 1 ].object;
 
 
-THREE.LOD.prototype.update = function () {
+	},
 
 
-	var v1 = new THREE.Vector3();
-	var v2 = new THREE.Vector3();
+	raycast: ( function () {
 
 
-	return function update( camera ) {
+		var matrixPosition = new THREE.Vector3();
 
 
-		var levels = this.levels;
+		return function raycast( raycaster, intersects ) {
 
 
-		if ( levels.length > 1 ) {
+			matrixPosition.setFromMatrixPosition( this.matrixWorld );
 
 
-			v1.setFromMatrixPosition( camera.matrixWorld );
-			v2.setFromMatrixPosition( this.matrixWorld );
+			var distance = raycaster.ray.origin.distanceTo( matrixPosition );
 
 
-			var distance = v1.distanceTo( v2 );
+			this.getObjectForDistance( distance ).raycast( raycaster, intersects );
 
 
-			levels[ 0 ].object.visible = true;
+		};
 
 
-			for ( var i = 1, l = levels.length; i < l; i ++ ) {
+	}() ),
 
 
-				if ( distance >= levels[ i ].distance ) {
+	update: function () {
 
 
-					levels[ i - 1 ].object.visible = false;
-					levels[ i ].object.visible = true;
+		var v1 = new THREE.Vector3();
+		var v2 = new THREE.Vector3();
 
 
-				} else {
+		return function update( camera ) {
 
 
-					break;
+			var levels = this.levels;
 
 
-				}
+			if ( levels.length > 1 ) {
 
 
-			}
+				v1.setFromMatrixPosition( camera.matrixWorld );
+				v2.setFromMatrixPosition( this.matrixWorld );
 
 
-			for ( ; i < l; i ++ ) {
+				var distance = v1.distanceTo( v2 );
 
 
-				levels[ i ].object.visible = false;
+				levels[ 0 ].object.visible = true;
 
 
-			}
+				for ( var i = 1, l = levels.length; i < l; i ++ ) {
 
 
-		}
+					if ( distance >= levels[ i ].distance ) {
 
 
-	};
+						levels[ i - 1 ].object.visible = false;
+						levels[ i ].object.visible = true;
 
 
-}();
+					} else {
 
 
-THREE.LOD.prototype.copy = function ( source ) {
+						break;
 
 
-	THREE.Object3D.prototype.copy.call( this, source, false );
+					}
 
 
-	var levels = source.levels;
+				}
 
 
-	for ( var i = 0, l = levels.length; i < l; i ++ ) {
+				for ( ; i < l; i ++ ) {
 
 
-		var level = levels[ i ];
+					levels[ i ].object.visible = false;
 
 
-		this.addLevel( level.object.clone(), level.distance );
+				}
 
 
-	}
+			}
 
 
-	return this;
+		};
 
 
-};
+	}(),
 
 
-THREE.LOD.prototype.toJSON = function ( meta ) {
+	toJSON: function ( meta ) {
 
 
-	var data = THREE.Object3D.prototype.toJSON.call( this, meta );
+		var data = THREE.Object3D.prototype.toJSON.call( this, meta );
 
 
-	data.object.levels = [];
+		data.object.levels = [];
 
 
-	var levels = this.levels;
+		var levels = this.levels;
 
 
-	for ( var i = 0, l = levels.length; i < l; i ++ ) {
+		for ( var i = 0, l = levels.length; i < l; i ++ ) {
 
 
-		var level = levels[ i ];
+			var level = levels[ i ];
 
 
-		data.object.levels.push( {
-			object: level.object.uuid,
-			distance: level.distance
-		} );
+			data.object.levels.push( {
+				object: level.object.uuid,
+				distance: level.distance
+			} );
 
 
-	}
+		}
 
 
-	return data;
+		return data;
 
 
-};
+	}
+
+} );

+ 48 - 50
src/objects/LensFlare.js

@@ -20,77 +20,75 @@ THREE.LensFlare = function ( texture, size, distance, blending, color ) {
 
 
 };
 };
 
 
-THREE.LensFlare.prototype = Object.create( THREE.Object3D.prototype );
-THREE.LensFlare.prototype.constructor = THREE.LensFlare;
+THREE.LensFlare.prototype = Object.assign( Object.create( THREE.Object3D.prototype ), {
 
 
+	constructor: THREE.LensFlare,
 
 
-/*
- * Add: adds another flare
- */
+	copy: function ( source ) {
 
 
-THREE.LensFlare.prototype.add = function ( texture, size, distance, blending, color, opacity ) {
+		THREE.Object3D.prototype.copy.call( this, source );
 
 
-	if ( size === undefined ) size = - 1;
-	if ( distance === undefined ) distance = 0;
-	if ( opacity === undefined ) opacity = 1;
-	if ( color === undefined ) color = new THREE.Color( 0xffffff );
-	if ( blending === undefined ) blending = THREE.NormalBlending;
+		this.positionScreen.copy( source.positionScreen );
+		this.customUpdateCallback = source.customUpdateCallback;
 
 
-	distance = Math.min( distance, Math.max( 0, distance ) );
+		for ( var i = 0, l = source.lensFlares.length; i < l; i ++ ) {
 
 
-	this.lensFlares.push( {
-		texture: texture,	// THREE.Texture
-		size: size, 		// size in pixels (-1 = use texture.width)
-		distance: distance, 	// distance (0-1) from light source (0=at light source)
-		x: 0, y: 0, z: 0,	// screen position (-1 => 1) z = 0 is in front z = 1 is back
-		scale: 1, 		// scale
-		rotation: 0, 		// rotation
-		opacity: opacity,	// opacity
-		color: color,		// color
-		blending: blending	// blending
-	} );
+			this.lensFlares.push( source.lensFlares[ i ] );
 
 
-};
+		}
 
 
-/*
- * Update lens flares update positions on all flares based on the screen position
- * Set myLensFlare.customUpdateCallback to alter the flares in your project specific way.
- */
+		return this;
 
 
-THREE.LensFlare.prototype.updateLensFlares = function () {
+	},
 
 
-	var f, fl = this.lensFlares.length;
-	var flare;
-	var vecX = - this.positionScreen.x * 2;
-	var vecY = - this.positionScreen.y * 2;
+	add: function ( texture, size, distance, blending, color, opacity ) {
 
 
-	for ( f = 0; f < fl; f ++ ) {
+		if ( size === undefined ) size = - 1;
+		if ( distance === undefined ) distance = 0;
+		if ( opacity === undefined ) opacity = 1;
+		if ( color === undefined ) color = new THREE.Color( 0xffffff );
+		if ( blending === undefined ) blending = THREE.NormalBlending;
 
 
-		flare = this.lensFlares[ f ];
+		distance = Math.min( distance, Math.max( 0, distance ) );
 
 
-		flare.x = this.positionScreen.x + vecX * flare.distance;
-		flare.y = this.positionScreen.y + vecY * flare.distance;
+		this.lensFlares.push( {
+			texture: texture,	// THREE.Texture
+			size: size, 		// size in pixels (-1 = use texture.width)
+			distance: distance, 	// distance (0-1) from light source (0=at light source)
+			x: 0, y: 0, z: 0,	// screen position (-1 => 1) z = 0 is in front z = 1 is back
+			scale: 1, 		// scale
+			rotation: 0, 		// rotation
+			opacity: opacity,	// opacity
+			color: color,		// color
+			blending: blending	// blending
+		} );
 
 
-		flare.wantedRotation = flare.x * Math.PI * 0.25;
-		flare.rotation += ( flare.wantedRotation - flare.rotation ) * 0.25;
+	},
 
 
-	}
+	/*
+	 * Update lens flares update positions on all flares based on the screen position
+	 * Set myLensFlare.customUpdateCallback to alter the flares in your project specific way.
+	 */
 
 
-};
+	updateLensFlares: function () {
 
 
-THREE.LensFlare.prototype.copy = function ( source ) {
+		var f, fl = this.lensFlares.length;
+		var flare;
+		var vecX = - this.positionScreen.x * 2;
+		var vecY = - this.positionScreen.y * 2;
 
 
-	THREE.Object3D.prototype.copy.call( this, source );
+		for ( f = 0; f < fl; f ++ ) {
 
 
-	this.positionScreen.copy( source.positionScreen );
-	this.customUpdateCallback = source.customUpdateCallback;
+			flare = this.lensFlares[ f ];
 
 
-	for ( var i = 0, l = source.lensFlares.length; i < l; i ++ ) {
+			flare.x = this.positionScreen.x + vecX * flare.distance;
+			flare.y = this.positionScreen.y + vecY * flare.distance;
 
 
-		this.lensFlares.push( source.lensFlares[ i ] );
+			flare.wantedRotation = flare.x * Math.PI * 0.25;
+			flare.rotation += ( flare.wantedRotation - flare.rotation ) * 0.25;
 
 
-	}
+		}
 
 
-	return this;
+	}
 
 
-};
+} );

+ 96 - 98
src/objects/Line.js

@@ -20,94 +20,129 @@ THREE.Line = function ( geometry, material, mode ) {
 
 
 };
 };
 
 
-THREE.Line.prototype = Object.create( THREE.Object3D.prototype );
-THREE.Line.prototype.constructor = THREE.Line;
+THREE.Line.prototype = Object.assign( Object.create( THREE.Object3D.prototype ), {
 
 
-THREE.Line.prototype.raycast = ( function () {
+	constructor: THREE.Line,
 
 
-	var inverseMatrix = new THREE.Matrix4();
-	var ray = new THREE.Ray();
-	var sphere = new THREE.Sphere();
+	raycast: ( function () {
 
 
-	return function raycast( raycaster, intersects ) {
+		var inverseMatrix = new THREE.Matrix4();
+		var ray = new THREE.Ray();
+		var sphere = new THREE.Sphere();
 
 
-		var precision = raycaster.linePrecision;
-		var precisionSq = precision * precision;
+		return function raycast( raycaster, intersects ) {
 
 
-		var geometry = this.geometry;
-		var matrixWorld = this.matrixWorld;
+			var precision = raycaster.linePrecision;
+			var precisionSq = precision * precision;
 
 
-		// Checking boundingSphere distance to ray
+			var geometry = this.geometry;
+			var matrixWorld = this.matrixWorld;
 
 
-		if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
+			// Checking boundingSphere distance to ray
 
 
-		sphere.copy( geometry.boundingSphere );
-		sphere.applyMatrix4( matrixWorld );
+			if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
 
 
-		if ( raycaster.ray.intersectsSphere( sphere ) === false ) return;
+			sphere.copy( geometry.boundingSphere );
+			sphere.applyMatrix4( matrixWorld );
 
 
-		//
+			if ( raycaster.ray.intersectsSphere( sphere ) === false ) return;
 
 
-		inverseMatrix.getInverse( matrixWorld );
-		ray.copy( raycaster.ray ).applyMatrix4( inverseMatrix );
+			//
 
 
-		var vStart = new THREE.Vector3();
-		var vEnd = new THREE.Vector3();
-		var interSegment = new THREE.Vector3();
-		var interRay = new THREE.Vector3();
-		var step = this instanceof THREE.LineSegments ? 2 : 1;
+			inverseMatrix.getInverse( matrixWorld );
+			ray.copy( raycaster.ray ).applyMatrix4( inverseMatrix );
 
 
-		if ( geometry instanceof THREE.BufferGeometry ) {
+			var vStart = new THREE.Vector3();
+			var vEnd = new THREE.Vector3();
+			var interSegment = new THREE.Vector3();
+			var interRay = new THREE.Vector3();
+			var step = this instanceof THREE.LineSegments ? 2 : 1;
 
 
-			var index = geometry.index;
-			var attributes = geometry.attributes;
-			var positions = attributes.position.array;
+			if ( geometry instanceof THREE.BufferGeometry ) {
 
 
-			if ( index !== null ) {
+				var index = geometry.index;
+				var attributes = geometry.attributes;
+				var positions = attributes.position.array;
 
 
-				var indices = index.array;
+				if ( index !== null ) {
 
 
-				for ( var i = 0, l = indices.length - 1; i < l; i += step ) {
+					var indices = index.array;
 
 
-					var a = indices[ i ];
-					var b = indices[ i + 1 ];
+					for ( var i = 0, l = indices.length - 1; i < l; i += step ) {
 
 
-					vStart.fromArray( positions, a * 3 );
-					vEnd.fromArray( positions, b * 3 );
+						var a = indices[ i ];
+						var b = indices[ i + 1 ];
 
 
-					var distSq = ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );
+						vStart.fromArray( positions, a * 3 );
+						vEnd.fromArray( positions, b * 3 );
 
 
-					if ( distSq > precisionSq ) continue;
+						var distSq = ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );
 
 
-					interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation
+						if ( distSq > precisionSq ) continue;
 
 
-					var distance = raycaster.ray.origin.distanceTo( interRay );
+						interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation
 
 
-					if ( distance < raycaster.near || distance > raycaster.far ) continue;
+						var distance = raycaster.ray.origin.distanceTo( interRay );
 
 
-					intersects.push( {
+						if ( distance < raycaster.near || distance > raycaster.far ) continue;
 
 
-						distance: distance,
-						// What do we want? intersection point on the ray or on the segment??
-						// point: raycaster.ray.at( distance ),
-						point: interSegment.clone().applyMatrix4( this.matrixWorld ),
-						index: i,
-						face: null,
-						faceIndex: null,
-						object: this
+						intersects.push( {
 
 
-					} );
+							distance: distance,
+							// What do we want? intersection point on the ray or on the segment??
+							// point: raycaster.ray.at( distance ),
+							point: interSegment.clone().applyMatrix4( this.matrixWorld ),
+							index: i,
+							face: null,
+							faceIndex: null,
+							object: this
+
+						} );
+
+					}
+
+				} else {
+
+					for ( var i = 0, l = positions.length / 3 - 1; i < l; i += step ) {
+
+						vStart.fromArray( positions, 3 * i );
+						vEnd.fromArray( positions, 3 * i + 3 );
+
+						var distSq = ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );
+
+						if ( distSq > precisionSq ) continue;
+
+						interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation
+
+						var distance = raycaster.ray.origin.distanceTo( interRay );
+
+						if ( distance < raycaster.near || distance > raycaster.far ) continue;
+
+						intersects.push( {
+
+							distance: distance,
+							// What do we want? intersection point on the ray or on the segment??
+							// point: raycaster.ray.at( distance ),
+							point: interSegment.clone().applyMatrix4( this.matrixWorld ),
+							index: i,
+							face: null,
+							faceIndex: null,
+							object: this
+
+						} );
+
+					}
 
 
 				}
 				}
 
 
-			} else {
+			} else if ( geometry instanceof THREE.Geometry ) {
 
 
-				for ( var i = 0, l = positions.length / 3 - 1; i < l; i += step ) {
+				var vertices = geometry.vertices;
+				var nbVertices = vertices.length;
 
 
-					vStart.fromArray( positions, 3 * i );
-					vEnd.fromArray( positions, 3 * i + 3 );
+				for ( var i = 0; i < nbVertices - 1; i += step ) {
 
 
-					var distSq = ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );
+					var distSq = ray.distanceSqToSegment( vertices[ i ], vertices[ i + 1 ], interRay, interSegment );
 
 
 					if ( distSq > precisionSq ) continue;
 					if ( distSq > precisionSq ) continue;
 
 
@@ -134,51 +169,14 @@ THREE.Line.prototype.raycast = ( function () {
 
 
 			}
 			}
 
 
-		} else if ( geometry instanceof THREE.Geometry ) {
-
-			var vertices = geometry.vertices;
-			var nbVertices = vertices.length;
-
-			for ( var i = 0; i < nbVertices - 1; i += step ) {
-
-				var distSq = ray.distanceSqToSegment( vertices[ i ], vertices[ i + 1 ], interRay, interSegment );
-
-				if ( distSq > precisionSq ) continue;
-
-				interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation
-
-				var distance = raycaster.ray.origin.distanceTo( interRay );
-
-				if ( distance < raycaster.near || distance > raycaster.far ) continue;
-
-				intersects.push( {
-
-					distance: distance,
-					// What do we want? intersection point on the ray or on the segment??
-					// point: raycaster.ray.at( distance ),
-					point: interSegment.clone().applyMatrix4( this.matrixWorld ),
-					index: i,
-					face: null,
-					faceIndex: null,
-					object: this
-
-				} );
-
-			}
-
-		}
-
-	};
+		};
 
 
-}() );
+	}() ),
 
 
-THREE.Line.prototype.clone = function () {
+	clone: function () {
 
 
-	return new this.constructor( this.geometry, this.material ).copy( this );
+		return new this.constructor( this.geometry, this.material ).copy( this );
 
 
-};
-
-// DEPRECATED
+	}
 
 
-THREE.LineStrip = 0;
-THREE.LinePieces = 1;
+} );

+ 5 - 2
src/objects/LineSegments.js

@@ -10,5 +10,8 @@ THREE.LineSegments = function ( geometry, material ) {
 
 
 };
 };
 
 
-THREE.LineSegments.prototype = Object.create( THREE.Line.prototype );
-THREE.LineSegments.prototype.constructor = THREE.LineSegments;
+THREE.LineSegments.prototype = Object.assign( Object.create( THREE.Line.prototype ), {
+
+	constructor: THREE.LineSegments
+
+} );

+ 184 - 182
src/objects/Mesh.js

@@ -20,321 +20,323 @@ THREE.Mesh = function ( geometry, material ) {
 
 
 };
 };
 
 
-THREE.Mesh.prototype = Object.create( THREE.Object3D.prototype );
-THREE.Mesh.prototype.constructor = THREE.Mesh;
+THREE.Mesh.prototype = Object.assign( Object.create( THREE.Object3D.prototype ), {
 
 
-THREE.Mesh.prototype.setDrawMode = function ( value ) {
+	constructor: THREE.Mesh,
 
 
-	this.drawMode = value;
+	setDrawMode: function ( value ) {
 
 
-};
+		this.drawMode = value;
+
+	},
+
+	updateMorphTargets: function () {
 
 
-THREE.Mesh.prototype.updateMorphTargets = function () {
+		if ( this.geometry.morphTargets !== undefined && this.geometry.morphTargets.length > 0 ) {
 
 
-	if ( this.geometry.morphTargets !== undefined && this.geometry.morphTargets.length > 0 ) {
+			this.morphTargetBase = - 1;
+			this.morphTargetInfluences = [];
+			this.morphTargetDictionary = {};
 
 
-		this.morphTargetBase = - 1;
-		this.morphTargetInfluences = [];
-		this.morphTargetDictionary = {};
+			for ( var m = 0, ml = this.geometry.morphTargets.length; m < ml; m ++ ) {
 
 
-		for ( var m = 0, ml = this.geometry.morphTargets.length; m < ml; m ++ ) {
+				this.morphTargetInfluences.push( 0 );
+				this.morphTargetDictionary[ this.geometry.morphTargets[ m ].name ] = m;
 
 
-			this.morphTargetInfluences.push( 0 );
-			this.morphTargetDictionary[ this.geometry.morphTargets[ m ].name ] = m;
+			}
 
 
 		}
 		}
 
 
-	}
+	},
 
 
-};
+	getMorphTargetIndexByName: function ( name ) {
 
 
-THREE.Mesh.prototype.getMorphTargetIndexByName = function ( name ) {
+		if ( this.morphTargetDictionary[ name ] !== undefined ) {
 
 
-	if ( this.morphTargetDictionary[ name ] !== undefined ) {
+			return this.morphTargetDictionary[ name ];
 
 
-		return this.morphTargetDictionary[ name ];
+		}
 
 
-	}
+		console.warn( 'THREE.Mesh.getMorphTargetIndexByName: morph target ' + name + ' does not exist. Returning 0.' );
 
 
-	console.warn( 'THREE.Mesh.getMorphTargetIndexByName: morph target ' + name + ' does not exist. Returning 0.' );
+		return 0;
 
 
-	return 0;
+	},
 
 
-};
+	raycast: ( function () {
 
 
+		var inverseMatrix = new THREE.Matrix4();
+		var ray = new THREE.Ray();
+		var sphere = new THREE.Sphere();
 
 
-THREE.Mesh.prototype.raycast = ( function () {
+		var vA = new THREE.Vector3();
+		var vB = new THREE.Vector3();
+		var vC = new THREE.Vector3();
 
 
-	var inverseMatrix = new THREE.Matrix4();
-	var ray = new THREE.Ray();
-	var sphere = new THREE.Sphere();
+		var tempA = new THREE.Vector3();
+		var tempB = new THREE.Vector3();
+		var tempC = new THREE.Vector3();
 
 
-	var vA = new THREE.Vector3();
-	var vB = new THREE.Vector3();
-	var vC = new THREE.Vector3();
+		var uvA = new THREE.Vector2();
+		var uvB = new THREE.Vector2();
+		var uvC = new THREE.Vector2();
 
 
-	var tempA = new THREE.Vector3();
-	var tempB = new THREE.Vector3();
-	var tempC = new THREE.Vector3();
+		var barycoord = new THREE.Vector3();
 
 
-	var uvA = new THREE.Vector2();
-	var uvB = new THREE.Vector2();
-	var uvC = new THREE.Vector2();
+		var intersectionPoint = new THREE.Vector3();
+		var intersectionPointWorld = new THREE.Vector3();
 
 
-	var barycoord = new THREE.Vector3();
+		function uvIntersection( point, p1, p2, p3, uv1, uv2, uv3 ) {
 
 
-	var intersectionPoint = new THREE.Vector3();
-	var intersectionPointWorld = new THREE.Vector3();
+			THREE.Triangle.barycoordFromPoint( point, p1, p2, p3, barycoord );
 
 
-	function uvIntersection( point, p1, p2, p3, uv1, uv2, uv3 ) {
+			uv1.multiplyScalar( barycoord.x );
+			uv2.multiplyScalar( barycoord.y );
+			uv3.multiplyScalar( barycoord.z );
 
 
-		THREE.Triangle.barycoordFromPoint( point, p1, p2, p3, barycoord );
+			uv1.add( uv2 ).add( uv3 );
 
 
-		uv1.multiplyScalar( barycoord.x );
-		uv2.multiplyScalar( barycoord.y );
-		uv3.multiplyScalar( barycoord.z );
+			return uv1.clone();
 
 
-		uv1.add( uv2 ).add( uv3 );
+		}
 
 
-		return uv1.clone();
+		function checkIntersection( object, raycaster, ray, pA, pB, pC, point ) {
 
 
-	}
+			var intersect;
+			var material = object.material;
 
 
-	function checkIntersection( object, raycaster, ray, pA, pB, pC, point ) {
+			if ( material.side === THREE.BackSide ) {
 
 
-		var intersect;
-		var material = object.material;
+				intersect = ray.intersectTriangle( pC, pB, pA, true, point );
 
 
-		if ( material.side === THREE.BackSide ) {
+			} else {
 
 
-			intersect = ray.intersectTriangle( pC, pB, pA, true, point );
+				intersect = ray.intersectTriangle( pA, pB, pC, material.side !== THREE.DoubleSide, point );
 
 
-		} else {
+			}
 
 
-			intersect = ray.intersectTriangle( pA, pB, pC, material.side !== THREE.DoubleSide, point );
+			if ( intersect === null ) return null;
 
 
-		}
+			intersectionPointWorld.copy( point );
+			intersectionPointWorld.applyMatrix4( object.matrixWorld );
 
 
-		if ( intersect === null ) return null;
+			var distance = raycaster.ray.origin.distanceTo( intersectionPointWorld );
 
 
-		intersectionPointWorld.copy( point );
-		intersectionPointWorld.applyMatrix4( object.matrixWorld );
+			if ( distance < raycaster.near || distance > raycaster.far ) return null;
 
 
-		var distance = raycaster.ray.origin.distanceTo( intersectionPointWorld );
+			return {
+				distance: distance,
+				point: intersectionPointWorld.clone(),
+				object: object
+			};
 
 
-		if ( distance < raycaster.near || distance > raycaster.far ) return null;
+		}
 
 
-		return {
-			distance: distance,
-			point: intersectionPointWorld.clone(),
-			object: object
-		};
+		function checkBufferGeometryIntersection( object, raycaster, ray, positions, uvs, a, b, c ) {
 
 
-	}
+			vA.fromArray( positions, a * 3 );
+			vB.fromArray( positions, b * 3 );
+			vC.fromArray( positions, c * 3 );
 
 
-	function checkBufferGeometryIntersection( object, raycaster, ray, positions, uvs, a, b, c ) {
+			var intersection = checkIntersection( object, raycaster, ray, vA, vB, vC, intersectionPoint );
 
 
-		vA.fromArray( positions, a * 3 );
-		vB.fromArray( positions, b * 3 );
-		vC.fromArray( positions, c * 3 );
+			if ( intersection ) {
 
 
-		var intersection = checkIntersection( object, raycaster, ray, vA, vB, vC, intersectionPoint );
+				if ( uvs ) {
 
 
-		if ( intersection ) {
+					uvA.fromArray( uvs, a * 2 );
+					uvB.fromArray( uvs, b * 2 );
+					uvC.fromArray( uvs, c * 2 );
 
 
-			if ( uvs ) {
+					intersection.uv = uvIntersection( intersectionPoint,  vA, vB, vC,  uvA, uvB, uvC );
 
 
-				uvA.fromArray( uvs, a * 2 );
-				uvB.fromArray( uvs, b * 2 );
-				uvC.fromArray( uvs, c * 2 );
+				}
 
 
-				intersection.uv = uvIntersection( intersectionPoint,  vA, vB, vC,  uvA, uvB, uvC );
+				intersection.face = new THREE.Face3( a, b, c, THREE.Triangle.normal( vA, vB, vC ) );
+				intersection.faceIndex = a;
 
 
 			}
 			}
 
 
-			intersection.face = new THREE.Face3( a, b, c, THREE.Triangle.normal( vA, vB, vC ) );
-			intersection.faceIndex = a;
+			return intersection;
 
 
 		}
 		}
 
 
-		return intersection;
+		return function raycast( raycaster, intersects ) {
 
 
-	}
+			var geometry = this.geometry;
+			var material = this.material;
+			var matrixWorld = this.matrixWorld;
 
 
-	return function raycast( raycaster, intersects ) {
+			if ( material === undefined ) return;
 
 
-		var geometry = this.geometry;
-		var material = this.material;
-		var matrixWorld = this.matrixWorld;
+			// Checking boundingSphere distance to ray
 
 
-		if ( material === undefined ) return;
+			if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
 
 
-		// Checking boundingSphere distance to ray
+			sphere.copy( geometry.boundingSphere );
+			sphere.applyMatrix4( matrixWorld );
 
 
-		if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
+			if ( raycaster.ray.intersectsSphere( sphere ) === false ) return;
 
 
-		sphere.copy( geometry.boundingSphere );
-		sphere.applyMatrix4( matrixWorld );
+			//
 
 
-		if ( raycaster.ray.intersectsSphere( sphere ) === false ) return;
+			inverseMatrix.getInverse( matrixWorld );
+			ray.copy( raycaster.ray ).applyMatrix4( inverseMatrix );
 
 
-		//
+			// Check boundingBox before continuing
 
 
-		inverseMatrix.getInverse( matrixWorld );
-		ray.copy( raycaster.ray ).applyMatrix4( inverseMatrix );
+			if ( geometry.boundingBox !== null ) {
 
 
-		// Check boundingBox before continuing
+				if ( ray.intersectsBox( geometry.boundingBox ) === false ) return;
 
 
-		if ( geometry.boundingBox !== null ) {
-
-			if ( ray.intersectsBox( geometry.boundingBox ) === false ) return;
+			}
 
 
-		}
+			var uvs, intersection;
 
 
-		var uvs, intersection;
+			if ( geometry instanceof THREE.BufferGeometry ) {
 
 
-		if ( geometry instanceof THREE.BufferGeometry ) {
+				var a, b, c;
+				var index = geometry.index;
+				var attributes = geometry.attributes;
+				var positions = attributes.position.array;
 
 
-			var a, b, c;
-			var index = geometry.index;
-			var attributes = geometry.attributes;
-			var positions = attributes.position.array;
+				if ( attributes.uv !== undefined ) {
 
 
-			if ( attributes.uv !== undefined ) {
+					uvs = attributes.uv.array;
 
 
-				uvs = attributes.uv.array;
+				}
 
 
-			}
+				if ( index !== null ) {
 
 
-			if ( index !== null ) {
+					var indices = index.array;
 
 
-				var indices = index.array;
+					for ( var i = 0, l = indices.length; i < l; i += 3 ) {
 
 
-				for ( var i = 0, l = indices.length; i < l; i += 3 ) {
+						a = indices[ i ];
+						b = indices[ i + 1 ];
+						c = indices[ i + 2 ];
 
 
-					a = indices[ i ];
-					b = indices[ i + 1 ];
-					c = indices[ i + 2 ];
+						intersection = checkBufferGeometryIntersection( this, raycaster, ray, positions, uvs, a, b, c );
 
 
-					intersection = checkBufferGeometryIntersection( this, raycaster, ray, positions, uvs, a, b, c );
+						if ( intersection ) {
 
 
-					if ( intersection ) {
+							intersection.faceIndex = Math.floor( i / 3 ); // triangle number in indices buffer semantics
+							intersects.push( intersection );
 
 
-						intersection.faceIndex = Math.floor( i / 3 ); // triangle number in indices buffer semantics
-						intersects.push( intersection );
+						}
 
 
 					}
 					}
 
 
-				}
+				} else {
 
 
-			} else {
 
 
+					for ( var i = 0, l = positions.length; i < l; i += 9 ) {
 
 
-				for ( var i = 0, l = positions.length; i < l; i += 9 ) {
+						a = i / 3;
+						b = a + 1;
+						c = a + 2;
 
 
-					a = i / 3;
-					b = a + 1;
-					c = a + 2;
+						intersection = checkBufferGeometryIntersection( this, raycaster, ray, positions, uvs, a, b, c );
 
 
-					intersection = checkBufferGeometryIntersection( this, raycaster, ray, positions, uvs, a, b, c );
+						if ( intersection ) {
 
 
-					if ( intersection ) {
+							intersection.index = a; // triangle number in positions buffer semantics
+							intersects.push( intersection );
 
 
-						intersection.index = a; // triangle number in positions buffer semantics
-						intersects.push( intersection );
+						}
 
 
 					}
 					}
 
 
 				}
 				}
 
 
-			}
+			} else if ( geometry instanceof THREE.Geometry ) {
 
 
-		} else if ( geometry instanceof THREE.Geometry ) {
+				var fvA, fvB, fvC;
+				var isFaceMaterial = material instanceof THREE.MultiMaterial;
+				var materials = isFaceMaterial === true ? material.materials : null;
 
 
-			var fvA, fvB, fvC;
-			var isFaceMaterial = material instanceof THREE.MultiMaterial;
-			var materials = isFaceMaterial === true ? material.materials : null;
+				var vertices = geometry.vertices;
+				var faces = geometry.faces;
+				var faceVertexUvs = geometry.faceVertexUvs[ 0 ];
+				if ( faceVertexUvs.length > 0 ) uvs = faceVertexUvs;
 
 
-			var vertices = geometry.vertices;
-			var faces = geometry.faces;
-			var faceVertexUvs = geometry.faceVertexUvs[ 0 ];
-			if ( faceVertexUvs.length > 0 ) uvs = faceVertexUvs;
+				for ( var f = 0, fl = faces.length; f < fl; f ++ ) {
 
 
-			for ( var f = 0, fl = faces.length; f < fl; f ++ ) {
+					var face = faces[ f ];
+					var faceMaterial = isFaceMaterial === true ? materials[ face.materialIndex ] : material;
 
 
-				var face = faces[ f ];
-				var faceMaterial = isFaceMaterial === true ? materials[ face.materialIndex ] : material;
+					if ( faceMaterial === undefined ) continue;
 
 
-				if ( faceMaterial === undefined ) continue;
+					fvA = vertices[ face.a ];
+					fvB = vertices[ face.b ];
+					fvC = vertices[ face.c ];
 
 
-				fvA = vertices[ face.a ];
-				fvB = vertices[ face.b ];
-				fvC = vertices[ face.c ];
+					if ( faceMaterial.morphTargets === true ) {
 
 
-				if ( faceMaterial.morphTargets === true ) {
+						var morphTargets = geometry.morphTargets;
+						var morphInfluences = this.morphTargetInfluences;
 
 
-					var morphTargets = geometry.morphTargets;
-					var morphInfluences = this.morphTargetInfluences;
+						vA.set( 0, 0, 0 );
+						vB.set( 0, 0, 0 );
+						vC.set( 0, 0, 0 );
 
 
-					vA.set( 0, 0, 0 );
-					vB.set( 0, 0, 0 );
-					vC.set( 0, 0, 0 );
+						for ( var t = 0, tl = morphTargets.length; t < tl; t ++ ) {
 
 
-					for ( var t = 0, tl = morphTargets.length; t < tl; t ++ ) {
+							var influence = morphInfluences[ t ];
 
 
-						var influence = morphInfluences[ t ];
+							if ( influence === 0 ) continue;
 
 
-						if ( influence === 0 ) continue;
+							var targets = morphTargets[ t ].vertices;
 
 
-						var targets = morphTargets[ t ].vertices;
+							vA.addScaledVector( tempA.subVectors( targets[ face.a ], fvA ), influence );
+							vB.addScaledVector( tempB.subVectors( targets[ face.b ], fvB ), influence );
+							vC.addScaledVector( tempC.subVectors( targets[ face.c ], fvC ), influence );
 
 
-						vA.addScaledVector( tempA.subVectors( targets[ face.a ], fvA ), influence );
-						vB.addScaledVector( tempB.subVectors( targets[ face.b ], fvB ), influence );
-						vC.addScaledVector( tempC.subVectors( targets[ face.c ], fvC ), influence );
+						}
 
 
-					}
+						vA.add( fvA );
+						vB.add( fvB );
+						vC.add( fvC );
 
 
-					vA.add( fvA );
-					vB.add( fvB );
-					vC.add( fvC );
+						fvA = vA;
+						fvB = vB;
+						fvC = vC;
 
 
-					fvA = vA;
-					fvB = vB;
-					fvC = vC;
+					}
 
 
-				}
+					intersection = checkIntersection( this, raycaster, ray, fvA, fvB, fvC, intersectionPoint );
 
 
-				intersection = checkIntersection( this, raycaster, ray, fvA, fvB, fvC, intersectionPoint );
+					if ( intersection ) {
 
 
-				if ( intersection ) {
+						if ( uvs ) {
 
 
-					if ( uvs ) {
+							var uvs_f = uvs[ f ];
+							uvA.copy( uvs_f[ 0 ] );
+							uvB.copy( uvs_f[ 1 ] );
+							uvC.copy( uvs_f[ 2 ] );
 
 
-						var uvs_f = uvs[ f ];
-						uvA.copy( uvs_f[ 0 ] );
-						uvB.copy( uvs_f[ 1 ] );
-						uvC.copy( uvs_f[ 2 ] );
+							intersection.uv = uvIntersection( intersectionPoint, fvA, fvB, fvC, uvA, uvB, uvC );
 
 
-						intersection.uv = uvIntersection( intersectionPoint, fvA, fvB, fvC, uvA, uvB, uvC );
+						}
 
 
-					}
+						intersection.face = face;
+						intersection.faceIndex = f;
+						intersects.push( intersection );
 
 
-					intersection.face = face;
-					intersection.faceIndex = f;
-					intersects.push( intersection );
+					}
 
 
 				}
 				}
 
 
 			}
 			}
 
 
-		}
+		};
 
 
-	};
+	}() ),
 
 
-}() );
+	clone: function () {
 
 
-THREE.Mesh.prototype.clone = function () {
+		return new this.constructor( this.geometry, this.material ).copy( this );
 
 
-	return new this.constructor( this.geometry, this.material ).copy( this );
+	}
 
 
-};
+} );

+ 67 - 64
src/objects/Points.js

@@ -13,118 +13,121 @@ THREE.Points = function ( geometry, material ) {
 
 
 };
 };
 
 
-THREE.Points.prototype = Object.create( THREE.Object3D.prototype );
-THREE.Points.prototype.constructor = THREE.Points;
+THREE.Points.prototype = Object.assign( Object.create( THREE.Object3D.prototype ), {
 
 
-THREE.Points.prototype.raycast = ( function () {
+	constructor: THREE.Points,
 
 
-	var inverseMatrix = new THREE.Matrix4();
-	var ray = new THREE.Ray();
-	var sphere = new THREE.Sphere();
+	raycast: ( function () {
 
 
-	return function raycast( raycaster, intersects ) {
+		var inverseMatrix = new THREE.Matrix4();
+		var ray = new THREE.Ray();
+		var sphere = new THREE.Sphere();
 
 
-		var object = this;
-		var geometry = this.geometry;
-		var matrixWorld = this.matrixWorld;
-		var threshold = raycaster.params.Points.threshold;
+		return function raycast( raycaster, intersects ) {
 
 
-		// Checking boundingSphere distance to ray
+			var object = this;
+			var geometry = this.geometry;
+			var matrixWorld = this.matrixWorld;
+			var threshold = raycaster.params.Points.threshold;
 
 
-		if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
+			// Checking boundingSphere distance to ray
 
 
-		sphere.copy( geometry.boundingSphere );
-		sphere.applyMatrix4( matrixWorld );
+			if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
 
 
-		if ( raycaster.ray.intersectsSphere( sphere ) === false ) return;
+			sphere.copy( geometry.boundingSphere );
+			sphere.applyMatrix4( matrixWorld );
 
 
-		//
+			if ( raycaster.ray.intersectsSphere( sphere ) === false ) return;
 
 
-		inverseMatrix.getInverse( matrixWorld );
-		ray.copy( raycaster.ray ).applyMatrix4( inverseMatrix );
+			//
 
 
-		var localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );
-		var localThresholdSq = localThreshold * localThreshold;
-		var position = new THREE.Vector3();
+			inverseMatrix.getInverse( matrixWorld );
+			ray.copy( raycaster.ray ).applyMatrix4( inverseMatrix );
 
 
-		function testPoint( point, index ) {
+			var localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );
+			var localThresholdSq = localThreshold * localThreshold;
+			var position = new THREE.Vector3();
 
 
-			var rayPointDistanceSq = ray.distanceSqToPoint( point );
+			function testPoint( point, index ) {
 
 
-			if ( rayPointDistanceSq < localThresholdSq ) {
+				var rayPointDistanceSq = ray.distanceSqToPoint( point );
 
 
-				var intersectPoint = ray.closestPointToPoint( point );
-				intersectPoint.applyMatrix4( matrixWorld );
+				if ( rayPointDistanceSq < localThresholdSq ) {
 
 
-				var distance = raycaster.ray.origin.distanceTo( intersectPoint );
+					var intersectPoint = ray.closestPointToPoint( point );
+					intersectPoint.applyMatrix4( matrixWorld );
 
 
-				if ( distance < raycaster.near || distance > raycaster.far ) return;
+					var distance = raycaster.ray.origin.distanceTo( intersectPoint );
 
 
-				intersects.push( {
+					if ( distance < raycaster.near || distance > raycaster.far ) return;
 
 
-					distance: distance,
-					distanceToRay: Math.sqrt( rayPointDistanceSq ),
-					point: intersectPoint.clone(),
-					index: index,
-					face: null,
-					object: object
+					intersects.push( {
 
 
-				} );
+						distance: distance,
+						distanceToRay: Math.sqrt( rayPointDistanceSq ),
+						point: intersectPoint.clone(),
+						index: index,
+						face: null,
+						object: object
+
+					} );
+
+				}
 
 
 			}
 			}
 
 
-		}
+			if ( geometry instanceof THREE.BufferGeometry ) {
 
 
-		if ( geometry instanceof THREE.BufferGeometry ) {
+				var index = geometry.index;
+				var attributes = geometry.attributes;
+				var positions = attributes.position.array;
 
 
-			var index = geometry.index;
-			var attributes = geometry.attributes;
-			var positions = attributes.position.array;
+				if ( index !== null ) {
 
 
-			if ( index !== null ) {
+					var indices = index.array;
 
 
-				var indices = index.array;
+					for ( var i = 0, il = indices.length; i < il; i ++ ) {
 
 
-				for ( var i = 0, il = indices.length; i < il; i ++ ) {
+						var a = indices[ i ];
 
 
-					var a = indices[ i ];
+						position.fromArray( positions, a * 3 );
 
 
-					position.fromArray( positions, a * 3 );
+						testPoint( position, a );
 
 
-					testPoint( position, a );
+					}
 
 
-				}
+				} else {
 
 
-			} else {
+					for ( var i = 0, l = positions.length / 3; i < l; i ++ ) {
 
 
-				for ( var i = 0, l = positions.length / 3; i < l; i ++ ) {
+						position.fromArray( positions, i * 3 );
 
 
-					position.fromArray( positions, i * 3 );
+						testPoint( position, i );
 
 
-					testPoint( position, i );
+					}
 
 
 				}
 				}
 
 
-			}
+			} else {
 
 
-		} else {
+				var vertices = geometry.vertices;
 
 
-			var vertices = geometry.vertices;
+				for ( var i = 0, l = vertices.length; i < l; i ++ ) {
 
 
-			for ( var i = 0, l = vertices.length; i < l; i ++ ) {
+					testPoint( vertices[ i ], i );
 
 
-				testPoint( vertices[ i ], i );
+				}
 
 
 			}
 			}
 
 
-		}
+		};
 
 
-	};
+	}() ),
 
 
-}() );
+	clone: function () {
 
 
-THREE.Points.prototype.clone = function () {
+		return new this.constructor( this.geometry, this.material ).copy( this );
 
 
-	return new this.constructor( this.geometry, this.material ).copy( this );
+	}
 
 
-};
+} );

+ 54 - 50
src/objects/Skeleton.js

@@ -28,7 +28,7 @@ THREE.Skeleton = function ( bones, boneInverses, useVertexTexture ) {
 		//       32x32 pixel texture max  256 bones * 4 pixels = (32 * 32)
 		//       32x32 pixel texture max  256 bones * 4 pixels = (32 * 32)
 		//       64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)
 		//       64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)
 
 
-		
+
 		var size = Math.sqrt( this.bones.length * 4 ); // 4 pixels needed for 1 matrix
 		var size = Math.sqrt( this.bones.length * 4 ); // 4 pixels needed for 1 matrix
 		size = THREE.Math.nextPowerOfTwo( Math.ceil( size ) );
 		size = THREE.Math.nextPowerOfTwo( Math.ceil( size ) );
 		size = Math.max( size, 4 );
 		size = Math.max( size, 4 );
@@ -75,102 +75,106 @@ THREE.Skeleton = function ( bones, boneInverses, useVertexTexture ) {
 
 
 };
 };
 
 
-THREE.Skeleton.prototype.calculateInverses = function () {
+Object.assign( THREE.Skeleton.prototype, {
 
 
-	this.boneInverses = [];
+	calculateInverses: function () {
 
 
-	for ( var b = 0, bl = this.bones.length; b < bl; b ++ ) {
+		this.boneInverses = [];
 
 
-		var inverse = new THREE.Matrix4();
+		for ( var b = 0, bl = this.bones.length; b < bl; b ++ ) {
 
 
-		if ( this.bones[ b ] ) {
+			var inverse = new THREE.Matrix4();
 
 
-			inverse.getInverse( this.bones[ b ].matrixWorld );
+			if ( this.bones[ b ] ) {
 
 
-		}
+				inverse.getInverse( this.bones[ b ].matrixWorld );
 
 
-		this.boneInverses.push( inverse );
+			}
 
 
-	}
+			this.boneInverses.push( inverse );
 
 
-};
+		}
 
 
-THREE.Skeleton.prototype.pose = function () {
+	},
 
 
-	var bone;
+	pose: function () {
 
 
-	// recover the bind-time world matrices
+		var bone;
 
 
-	for ( var b = 0, bl = this.bones.length; b < bl; b ++ ) {
+		// recover the bind-time world matrices
 
 
-		bone = this.bones[ b ];
+		for ( var b = 0, bl = this.bones.length; b < bl; b ++ ) {
+
+			bone = this.bones[ b ];
+
+			if ( bone ) {
 
 
-		if ( bone ) {
+				bone.matrixWorld.getInverse( this.boneInverses[ b ] );
 
 
-			bone.matrixWorld.getInverse( this.boneInverses[ b ] );
+			}
 
 
 		}
 		}
 
 
-	}
+		// compute the local matrices, positions, rotations and scales
 
 
-	// compute the local matrices, positions, rotations and scales
+		for ( var b = 0, bl = this.bones.length; b < bl; b ++ ) {
 
 
-	for ( var b = 0, bl = this.bones.length; b < bl; b ++ ) {
+			bone = this.bones[ b ];
 
 
-		bone = this.bones[ b ];
+			if ( bone ) {
 
 
-		if ( bone ) {
+				if ( bone.parent ) {
 
 
-			if ( bone.parent ) {
+					bone.matrix.getInverse( bone.parent.matrixWorld );
+					bone.matrix.multiply( bone.matrixWorld );
 
 
-				bone.matrix.getInverse( bone.parent.matrixWorld );
-				bone.matrix.multiply( bone.matrixWorld );
+				} else {
 
 
-			} else {
+					bone.matrix.copy( bone.matrixWorld );
 
 
-				bone.matrix.copy( bone.matrixWorld );
+				}
 
 
-			}
+				bone.matrix.decompose( bone.position, bone.quaternion, bone.scale );
 
 
-			bone.matrix.decompose( bone.position, bone.quaternion, bone.scale );
+			}
 
 
 		}
 		}
 
 
-	}
+	},
 
 
-};
+	update: ( function () {
 
 
-THREE.Skeleton.prototype.update = ( function () {
+		var offsetMatrix = new THREE.Matrix4();
 
 
-	var offsetMatrix = new THREE.Matrix4();
+		return function update() {
 
 
-	return function update() {
+			// flatten bone matrices to array
 
 
-		// flatten bone matrices to array
+			for ( var b = 0, bl = this.bones.length; b < bl; b ++ ) {
 
 
-		for ( var b = 0, bl = this.bones.length; b < bl; b ++ ) {
+				// compute the offset between the current and the original transform
 
 
-			// compute the offset between the current and the original transform
+				var matrix = this.bones[ b ] ? this.bones[ b ].matrixWorld : this.identityMatrix;
 
 
-			var matrix = this.bones[ b ] ? this.bones[ b ].matrixWorld : this.identityMatrix;
+				offsetMatrix.multiplyMatrices( matrix, this.boneInverses[ b ] );
+				offsetMatrix.toArray( this.boneMatrices, b * 16 );
 
 
-			offsetMatrix.multiplyMatrices( matrix, this.boneInverses[ b ] );
-			offsetMatrix.toArray( this.boneMatrices, b * 16 );
+			}
 
 
-		}
+			if ( this.useVertexTexture ) {
 
 
-		if ( this.useVertexTexture ) {
+				this.boneTexture.needsUpdate = true;
 
 
-			this.boneTexture.needsUpdate = true;
+			}
 
 
-		}
+		};
 
 
-	};
+	} )(),
 
 
-} )();
+	clone: function () {
 
 
-THREE.Skeleton.prototype.clone = function () {
+		return new THREE.Skeleton( this.bones, this.boneInverses, this.useVertexTexture );
 
 
-	return new THREE.Skeleton( this.bones, this.boneInverses, this.useVertexTexture );
+	}
 
 
-};
+} );

+ 58 - 55
src/objects/SkinnedMesh.js

@@ -66,111 +66,114 @@ THREE.SkinnedMesh = function ( geometry, material, useVertexTexture ) {
 };
 };
 
 
 
 
-THREE.SkinnedMesh.prototype = Object.create( THREE.Mesh.prototype );
-THREE.SkinnedMesh.prototype.constructor = THREE.SkinnedMesh;
+THREE.SkinnedMesh.prototype = Object.assign( Object.create( THREE.Mesh.prototype ), {
 
 
-THREE.SkinnedMesh.prototype.bind = function( skeleton, bindMatrix ) {
+	constructor: THREE.SkinnedMesh,
 
 
-	this.skeleton = skeleton;
+	bind: function( skeleton, bindMatrix ) {
 
 
-	if ( bindMatrix === undefined ) {
+		this.skeleton = skeleton;
 
 
-		this.updateMatrixWorld( true );
+		if ( bindMatrix === undefined ) {
 
 
-		this.skeleton.calculateInverses();
+			this.updateMatrixWorld( true );
 
 
-		bindMatrix = this.matrixWorld;
+			this.skeleton.calculateInverses();
 
 
-	}
+			bindMatrix = this.matrixWorld;
 
 
-	this.bindMatrix.copy( bindMatrix );
-	this.bindMatrixInverse.getInverse( bindMatrix );
+		}
 
 
-};
+		this.bindMatrix.copy( bindMatrix );
+		this.bindMatrixInverse.getInverse( bindMatrix );
 
 
-THREE.SkinnedMesh.prototype.pose = function () {
+	},
 
 
-	this.skeleton.pose();
+	pose: function () {
 
 
-};
+		this.skeleton.pose();
 
 
-THREE.SkinnedMesh.prototype.normalizeSkinWeights = function () {
+	},
 
 
-	if ( this.geometry instanceof THREE.Geometry ) {
+	normalizeSkinWeights: function () {
 
 
-		for ( var i = 0; i < this.geometry.skinWeights.length; i ++ ) {
+		if ( this.geometry instanceof THREE.Geometry ) {
 
 
-			var sw = this.geometry.skinWeights[ i ];
+			for ( var i = 0; i < this.geometry.skinWeights.length; i ++ ) {
 
 
-			var scale = 1.0 / sw.lengthManhattan();
+				var sw = this.geometry.skinWeights[ i ];
 
 
-			if ( scale !== Infinity ) {
+				var scale = 1.0 / sw.lengthManhattan();
 
 
-				sw.multiplyScalar( scale );
+				if ( scale !== Infinity ) {
 
 
-			} else {
+					sw.multiplyScalar( scale );
 
 
-				sw.set( 1, 0, 0, 0 ); // do something reasonable
+				} else {
+
+					sw.set( 1, 0, 0, 0 ); // do something reasonable
+
+				}
 
 
 			}
 			}
 
 
-		}
+		} else if ( this.geometry instanceof THREE.BufferGeometry ) {
 
 
-	} else if ( this.geometry instanceof THREE.BufferGeometry ) {
+			var vec = new THREE.Vector4();
 
 
-		var vec = new THREE.Vector4();
+			var skinWeight = this.geometry.attributes.skinWeight;
 
 
-		var skinWeight = this.geometry.attributes.skinWeight;
+			for ( var i = 0; i < skinWeight.count; i ++ ) {
 
 
-		for ( var i = 0; i < skinWeight.count; i ++ ) {
+				vec.x = skinWeight.getX( i );
+				vec.y = skinWeight.getY( i );
+				vec.z = skinWeight.getZ( i );
+				vec.w = skinWeight.getW( i );
 
 
-			vec.x = skinWeight.getX( i );
-			vec.y = skinWeight.getY( i );
-			vec.z = skinWeight.getZ( i );
-			vec.w = skinWeight.getW( i );
+				var scale = 1.0 / vec.lengthManhattan();
 
 
-			var scale = 1.0 / vec.lengthManhattan();
+				if ( scale !== Infinity ) {
 
 
-			if ( scale !== Infinity ) {
+					vec.multiplyScalar( scale );
 
 
-				vec.multiplyScalar( scale );
+				} else {
 
 
-			} else {
+					vec.set( 1, 0, 0, 0 ); // do something reasonable
 
 
-				vec.set( 1, 0, 0, 0 ); // do something reasonable
+				}
 
 
-			}
+				skinWeight.setXYZW( i, vec.x, vec.y, vec.z, vec.w );
 
 
-			skinWeight.setXYZW( i, vec.x, vec.y, vec.z, vec.w );
+			}
 
 
 		}
 		}
 
 
-	}
+	},
 
 
-};
+	updateMatrixWorld: function( force ) {
 
 
-THREE.SkinnedMesh.prototype.updateMatrixWorld = function( force ) {
+		THREE.Mesh.prototype.updateMatrixWorld.call( this, true );
 
 
-	THREE.Mesh.prototype.updateMatrixWorld.call( this, true );
+		if ( this.bindMode === "attached" ) {
 
 
-	if ( this.bindMode === "attached" ) {
+			this.bindMatrixInverse.getInverse( this.matrixWorld );
 
 
-		this.bindMatrixInverse.getInverse( this.matrixWorld );
+		} else if ( this.bindMode === "detached" ) {
 
 
-	} else if ( this.bindMode === "detached" ) {
+			this.bindMatrixInverse.getInverse( this.bindMatrix );
 
 
-		this.bindMatrixInverse.getInverse( this.bindMatrix );
+		} else {
 
 
-	} else {
+			console.warn( 'THREE.SkinnedMesh unrecognized bindMode: ' + this.bindMode );
 
 
-		console.warn( 'THREE.SkinnedMesh unrecognized bindMode: ' + this.bindMode );
+		}
 
 
-	}
+	},
 
 
-};
+	clone: function() {
 
 
-THREE.SkinnedMesh.prototype.clone = function() {
+		return new this.constructor( this.geometry, this.material, this.useVertexTexture ).copy( this );
 
 
-	return new this.constructor( this.geometry, this.material, this.useVertexTexture ).copy( this );
+	}
 
 
-};
+} );

+ 25 - 22
src/objects/Sprite.js

@@ -13,41 +13,44 @@ THREE.Sprite = function ( material ) {
 
 
 };
 };
 
 
-THREE.Sprite.prototype = Object.create( THREE.Object3D.prototype );
-THREE.Sprite.prototype.constructor = THREE.Sprite;
+THREE.Sprite.prototype = Object.assign( Object.create( THREE.Object3D.prototype ), {
 
 
-THREE.Sprite.prototype.raycast = ( function () {
+	constructor: THREE.Sprite,
 
 
-	var matrixPosition = new THREE.Vector3();
+	raycast: ( function () {
 
 
-	return function raycast( raycaster, intersects ) {
+		var matrixPosition = new THREE.Vector3();
 
 
-		matrixPosition.setFromMatrixPosition( this.matrixWorld );
+		return function raycast( raycaster, intersects ) {
 
 
-		var distanceSq = raycaster.ray.distanceSqToPoint( matrixPosition );
-		var guessSizeSq = this.scale.x * this.scale.y / 4;
+			matrixPosition.setFromMatrixPosition( this.matrixWorld );
 
 
-		if ( distanceSq > guessSizeSq ) {
+			var distanceSq = raycaster.ray.distanceSqToPoint( matrixPosition );
+			var guessSizeSq = this.scale.x * this.scale.y / 4;
 
 
-			return;
+			if ( distanceSq > guessSizeSq ) {
 
 
-		}
+				return;
 
 
-		intersects.push( {
+			}
 
 
-			distance: Math.sqrt( distanceSq ),
-			point: this.position,
-			face: null,
-			object: this
+			intersects.push( {
 
 
-		} );
+				distance: Math.sqrt( distanceSq ),
+				point: this.position,
+				face: null,
+				object: this
 
 
-	};
+			} );
 
 
-}() );
+		};
 
 
-THREE.Sprite.prototype.clone = function () {
+	}() ),
 
 
-	return new this.constructor( this.material ).copy( this );
+	clone: function () {
 
 
-};
+		return new this.constructor( this.material ).copy( this );
+
+	}
+
+} );