Просмотр исходного кода

Merge remote-tracking branch 'mrdoob/dev' into dev

Conflicts:
	editor/js/Sidebar.Object3D.js
Daniel 9 лет назад
Родитель
Сommit
d2edf11777
76 измененных файлов с 1259 добавлено и 1833 удалено
  1. 257 274
      build/three.js
  2. 64 69
      build/three.min.js
  3. 0 7
      docs/api/core/Geometry.html
  4. 1 0
      editor/js/Config.js
  5. 1 0
      editor/js/Editor.js
  6. 23 1
      editor/js/Sidebar.Geometry.CircleGeometry.js
  7. 52 1
      editor/js/Sidebar.Object3D.js
  8. 50 16
      editor/js/Sidebar.Project.js
  9. 21 21
      editor/js/libs/app.js
  10. 0 160
      editor/js/libs/tern-threejs/threejs.js
  11. 70 52
      editor/js/libs/ui.js
  12. 0 1
      examples/canvas_materials.html
  13. 0 238
      examples/canvas_materials_depth.html
  14. 10 4
      examples/canvas_morphtargets_horse.html
  15. 0 1
      examples/index.html
  16. 0 10
      examples/js/renderers/CanvasRenderer.js
  17. 0 6
      examples/js/renderers/SVGRenderer.js
  18. 3 3
      examples/js/utils/ShadowMapViewer.js
  19. 0 0
      examples/models/obj/tree.obj
  20. 0 2
      examples/obj/female02/Female02_slim.js
  21. 0 2
      examples/obj/leeperrysmith/LeePerrySmith.js
  22. 0 2
      examples/obj/lucy/Lucy100k_slim.js
  23. 0 2
      examples/obj/male02/Male02_dds.js
  24. 0 2
      examples/obj/male02/Male02_slim.js
  25. 0 7
      examples/obj/tree/.htaccess
  26. 0 23
      examples/obj/tree/tree.js
  27. 0 2
      examples/obj/walt/WaltHead_slim.js
  28. 1 19
      examples/webgl_lights_hemisphere.html
  29. 0 2
      examples/webgl_lights_pointlights.html
  30. 2 22
      examples/webgl_morphnormals.html
  31. 7 4
      examples/webgl_morphtargets_horse.html
  32. 9 18
      examples/webgl_postprocessing_godrays.html
  33. 1 22
      examples/webgl_shadowmap.html
  34. 2 27
      examples/webgl_shadowmap_performance.html
  35. 10 20
      examples/webgl_shadowmap_pointlight.html
  36. 9 8
      examples/webgl_shadowmap_viewer.html
  37. 0 19
      examples/webgl_terrain_dynamic.html
  38. 0 1
      src/core/Geometry.js
  39. 3 1
      src/core/Object3D.js
  40. 127 127
      src/extras/core/Curve.js
  41. 21 26
      src/extras/core/CurvePath.js
  42. 53 56
      src/extras/core/Path.js
  43. 19 19
      src/extras/core/Shape.js
  44. 9 9
      src/extras/geometries/BoxGeometry.js
  45. 8 12
      src/extras/geometries/CircleBufferGeometry.js
  46. 8 44
      src/extras/geometries/CircleGeometry.js
  47. 11 11
      src/extras/geometries/CylinderGeometry.js
  48. 5 7
      src/extras/geometries/DodecahedronGeometry.js
  49. 5 7
      src/extras/geometries/IcosahedronGeometry.js
  50. 5 7
      src/extras/geometries/OctahedronGeometry.js
  51. 7 9
      src/extras/geometries/PlaneBufferGeometry.js
  52. 7 7
      src/extras/geometries/PlaneGeometry.js
  53. 7 14
      src/extras/geometries/PolyhedronGeometry.js
  54. 9 9
      src/extras/geometries/RingGeometry.js
  55. 10 12
      src/extras/geometries/SphereBufferGeometry.js
  56. 10 10
      src/extras/geometries/SphereGeometry.js
  57. 5 7
      src/extras/geometries/TetrahedronGeometry.js
  58. 8 8
      src/extras/geometries/TorusGeometry.js
  59. 10 10
      src/extras/geometries/TorusKnotGeometry.js
  60. 2 0
      src/extras/helpers/CameraHelper.js
  61. 2 41
      src/lights/DirectionalLight.js
  62. 70 0
      src/lights/Light.js
  63. 40 0
      src/lights/LightShadow.js
  64. 2 37
      src/lights/PointLight.js
  65. 2 33
      src/lights/SpotLight.js
  66. 12 23
      src/loaders/JSONLoader.js
  67. 6 4
      src/math/Color.js
  68. 8 0
      src/math/Vector2.js
  69. 108 133
      src/objects/Mesh.js
  70. 35 30
      src/renderers/WebGLRenderer.js
  71. 2 2
      src/renderers/webgl/WebGLGeometries.js
  72. 4 4
      src/renderers/webgl/WebGLPrograms.js
  73. 1 1
      src/renderers/webgl/WebGLProperties.js
  74. 21 43
      src/renderers/webgl/WebGLShadowMap.js
  75. 3 2
      utils/build/build.py
  76. 1 0
      utils/build/includes/common.json

Разница между файлами не показана из-за своего большого размера
+ 257 - 274
build/three.js


Разница между файлами не показана из-за своего большого размера
+ 64 - 69
build/three.min.js


+ 0 - 7
docs/api/core/Geometry.html

@@ -88,13 +88,6 @@
 		Morph vertices match number and order of primary vertices.
 		Morph vertices match number and order of primary vertices.
 		</div>
 		</div>
 
 
-		<h3>[property:Array morphColors]</h3>
-		<div>
-		Array of morph colors. Morph colors have similar structure as morph targets, each color set is a Javascript object:
-		<code>morphColor = { name: "colorName", colors: [ new THREE.Color(), ... ] }</code>
-		Morph colors can match either the number and order of faces (face colors) or the number of vertices (vertex colors).
-		</div>
-
 		<h3>[property:Array morphNormals]</h3>
 		<h3>[property:Array morphNormals]</h3>
 		<div>
 		<div>
 		Array of morph normals. Morph normals have similar structure as morph targets, each normal set is a Javascript object:
 		Array of morph normals. Morph normals have similar structure as morph targets, each normal set is a Javascript object:

+ 1 - 0
editor/js/Config.js

@@ -12,6 +12,7 @@ var Config = function () {
 
 
 		'project/renderer': 'WebGLRenderer',
 		'project/renderer': 'WebGLRenderer',
 		'project/renderer/antialias': true,
 		'project/renderer/antialias': true,
+		'project/renderer/shadows': true,
 		'project/vr': false,
 		'project/vr': false,
 
 
 		'ui/sidebar/animation/collapsed': true,
 		'ui/sidebar/animation/collapsed': true,

+ 1 - 0
editor/js/Editor.js

@@ -474,6 +474,7 @@ Editor.prototype = {
 		return {
 		return {
 
 
 			project: {
 			project: {
+				shadows: this.config.getKey( 'project/renderer/shadows' ),
 				vr: this.config.getKey( 'project/vr' )
 				vr: this.config.getKey( 'project/vr' )
 			},
 			},
 			camera: this.camera.toJSON(),
 			camera: this.camera.toJSON(),

+ 23 - 1
editor/js/Sidebar.Geometry.CircleGeometry.js

@@ -30,13 +30,35 @@ Sidebar.Geometry.CircleGeometry = function ( editor, object ) {
 
 
 	container.add( segmentsRow );
 	container.add( segmentsRow );
 
 
+	// thetaStart
+
+	var thetaStartRow = new UI.Panel();
+	var thetaStart = new UI.Number( parameters.thetaStart ).onChange( update );
+
+	thetaStartRow.add( new UI.Text( 'Theta start' ).setWidth( '90px' ) );
+	thetaStartRow.add( thetaStart );
+
+	container.add( thetaStartRow );
+
+	// thetaLength
+
+	var thetaLengthRow = new UI.Panel();
+	var thetaLength = new UI.Number( parameters.thetaLength ).onChange( update );
+
+	thetaLengthRow.add( new UI.Text( 'Theta length' ).setWidth( '90px' ) );
+	thetaLengthRow.add( thetaLength );
+
+	container.add( thetaLengthRow );
+
 	//
 	//
 
 
 	function update() {
 	function update() {
 
 
 		editor.execute( new CmdSetGeometry( object, new THREE.CircleGeometry(
 		editor.execute( new CmdSetGeometry( object, new THREE.CircleGeometry(
 			radius.getValue(),
 			radius.getValue(),
-			segments.getValue()
+			segments.getValue(),
+			thetaStart.getValue(),
+			thetaLength.getValue()
 		) ) );
 		) ) );
 
 
 	}
 	}

+ 52 - 1
editor/js/Sidebar.Object3D.js

@@ -243,6 +243,30 @@ Sidebar.Object3D = function ( editor ) {
 
 
 	container.add( objectDecayRow );
 	container.add( objectDecayRow );
 
 
+	// shadow
+
+	var objectShadowRow = new UI.Panel();
+
+	objectShadowRow.add( new UI.Text( 'Shadow' ).setWidth( '90px' ) );
+
+	var objectCastShadowSpan = new UI.Span().setMarginRight( '10px' );
+	var objectCastShadow = new UI.Checkbox().onChange( update );
+
+	objectCastShadowSpan.add( objectCastShadow );
+	objectCastShadowSpan.add( new UI.Text( 'cast' ) );
+
+	objectShadowRow.add( objectCastShadowSpan );
+
+	var objectReceiveShadowSpan = new UI.Span();
+	var objectReceiveShadow = new UI.Checkbox().onChange( update );
+
+	objectReceiveShadowSpan.add( objectReceiveShadow );
+	objectReceiveShadowSpan.add( new UI.Text( 'receive' ) );
+
+	objectShadowRow.add( objectReceiveShadowSpan );
+
+	container.add( objectShadowRow );
+
 	// visible
 	// visible
 
 
 	var objectVisibleRow = new UI.Panel();
 	var objectVisibleRow = new UI.Panel();
@@ -444,6 +468,19 @@ Sidebar.Object3D = function ( editor ) {
 
 
 			}
 			}
 
 
+			if ( object.castShadow !== objectCastShadow.getValue() ) {
+
+				editor.execute( new CmdSetValue( object, 'castShadow', objectCastShadow.getValue() ) );
+
+			}
+
+			if ( object.receiveShadow !== objectReceiveShadow.getValue() ) {
+
+				editor.execute( new CmdSetValue( object, 'receiveShadow', objectReceiveShadow.getValue() ) );
+				object.material.needsUpdate = true;
+
+			}
+
 			try {
 			try {
 
 
 				var userData = JSON.parse( objectUserData.getValue() );
 				var userData = JSON.parse( objectUserData.getValue() );
@@ -476,7 +513,9 @@ Sidebar.Object3D = function ( editor ) {
 			'distance' : objectDistanceRow,
 			'distance' : objectDistanceRow,
 			'angle' : objectAngleRow,
 			'angle' : objectAngleRow,
 			'exponent' : objectExponentRow,
 			'exponent' : objectExponentRow,
-			'decay' : objectDecayRow
+			'decay' : objectDecayRow,
+			'castShadow' : objectShadowRow,
+			'receiveShadow' : objectReceiveShadowSpan
 		};
 		};
 
 
 		for ( var property in properties ) {
 		for ( var property in properties ) {
@@ -643,6 +682,18 @@ Sidebar.Object3D = function ( editor ) {
 
 
 		}
 		}
 
 
+		if ( object.castShadow !== undefined ) {
+
+			objectCastShadow.setValue( object.castShadow );
+
+		}
+
+		if ( object.receiveShadow !== undefined ) {
+
+			objectReceiveShadow.setValue( object.receiveShadow );
+
+		}
+
 		objectVisible.setValue( object.visible );
 		objectVisible.setValue( object.visible );
 
 
 		try {
 		try {

+ 50 - 16
editor/js/Sidebar.Project.js

@@ -4,6 +4,7 @@
 
 
 Sidebar.Project = function ( editor ) {
 Sidebar.Project = function ( editor ) {
 
 
+	var config = editor.config;
 	var signals = editor.signals;
 	var signals = editor.signals;
 
 
 	var rendererTypes = {
 	var rendererTypes = {
@@ -17,10 +18,10 @@ Sidebar.Project = function ( editor ) {
 	};
 	};
 
 
 	var container = new UI.CollapsiblePanel();
 	var container = new UI.CollapsiblePanel();
-	container.setCollapsed( editor.config.getKey( 'ui/sidebar/project/collapsed' ) );
+	container.setCollapsed( config.getKey( 'ui/sidebar/project/collapsed' ) );
 	container.onCollapsedChange( function ( boolean ) {
 	container.onCollapsedChange( function ( boolean ) {
 
 
-		editor.config.setKey( 'ui/sidebar/project/collapsed', boolean );
+		config.setKey( 'ui/sidebar/project/collapsed', boolean );
 
 
 	} );
 	} );
 
 
@@ -42,7 +43,19 @@ Sidebar.Project = function ( editor ) {
 	var rendererTypeRow = new UI.Panel();
 	var rendererTypeRow = new UI.Panel();
 	var rendererType = new UI.Select().setOptions( options ).setWidth( '150px' ).onChange( function () {
 	var rendererType = new UI.Select().setOptions( options ).setWidth( '150px' ).onChange( function () {
 
 
-		editor.config.setKey( 'project/renderer', this.getValue() );
+		var value = this.getValue();
+
+		if ( value === 'WebGLRenderer' ) {
+
+			rendererPropertiesRow.setDisplay( '' );
+
+		} else {
+
+			rendererPropertiesRow.setDisplay( 'none' );
+
+		}
+
+		config.setKey( 'project/renderer', value );
 		updateRenderer();
 		updateRenderer();
 
 
 	} );
 	} );
@@ -52,33 +65,53 @@ Sidebar.Project = function ( editor ) {
 
 
 	container.add( rendererTypeRow );
 	container.add( rendererTypeRow );
 
 
-	if ( editor.config.getKey( 'project/renderer' ) !== undefined ) {
+	if ( config.getKey( 'project/renderer' ) !== undefined ) {
 
 
-		rendererType.setValue( editor.config.getKey( 'project/renderer' ) );
+		rendererType.setValue( config.getKey( 'project/renderer' ) );
 
 
 	}
 	}
 
 
 	// antialiasing
 	// antialiasing
 
 
-	var rendererAntialiasRow = new UI.Panel();
-	var rendererAntialias = new UI.Checkbox( editor.config.getKey( 'project/renderer/antialias' ) ).setLeft( '100px' ).onChange( function () {
+	var rendererPropertiesRow = new UI.Panel();
+	rendererPropertiesRow.add( new UI.Text( '' ).setWidth( '90px' ) );
 
 
-		editor.config.setKey( 'project/renderer/antialias', this.getValue() );
+	var rendererAntialiasSpan = new UI.Span().setMarginRight( '10px' );
+	var rendererAntialias = new UI.Checkbox( config.getKey( 'project/renderer/antialias' ) ).setLeft( '100px' ).onChange( function () {
+
+		config.setKey( 'project/renderer/antialias', this.getValue() );
 		updateRenderer();
 		updateRenderer();
 
 
 	} );
 	} );
 
 
-	rendererAntialiasRow.add( new UI.Text( 'Antialias' ).setWidth( '90px' ) );
-	rendererAntialiasRow.add( rendererAntialias );
+	rendererAntialiasSpan.add( rendererAntialias );
+	rendererAntialiasSpan.add( new UI.Text( 'antialias' ) );
+
+	rendererPropertiesRow.add( rendererAntialiasSpan );
+
+	// shadow
+
+	var rendererShadowsSpan = new UI.Span();
+	var rendererShadows = new UI.Checkbox( config.getKey( 'project/renderer/shadows' ) ).setLeft( '100px' ).onChange( function () {
+
+		config.setKey( 'project/renderer/shadows', this.getValue() );
+		updateRenderer();
+
+	} );
+
+	rendererShadowsSpan.add( rendererShadows );
+	rendererShadowsSpan.add( new UI.Text( 'shadows' ) );
+
+	rendererPropertiesRow.add( rendererShadowsSpan );
 
 
-	container.add( rendererAntialiasRow );
+	container.add( rendererPropertiesRow );
 
 
 	// VR
 	// VR
 
 
 	var vrRow = new UI.Panel();
 	var vrRow = new UI.Panel();
-	var vr = new UI.Checkbox( editor.config.getKey( 'project/vr' ) ).setLeft( '100px' ).onChange( function () {
+	var vr = new UI.Checkbox( config.getKey( 'project/vr' ) ).setLeft( '100px' ).onChange( function () {
 
 
-		editor.config.setKey( 'project/vr', this.getValue() );
+		config.setKey( 'project/vr', this.getValue() );
 		// updateRenderer();
 		// updateRenderer();
 
 
 	} );
 	} );
@@ -92,11 +125,11 @@ Sidebar.Project = function ( editor ) {
 
 
 	function updateRenderer() {
 	function updateRenderer() {
 
 
-		createRenderer( rendererType.getValue(), rendererAntialias.getValue() );
+		createRenderer( rendererType.getValue(), rendererAntialias.getValue(), rendererShadows.getValue() );
 
 
 	}
 	}
 
 
-	function createRenderer( type, antialias ) {
+	function createRenderer( type, antialias, shadows ) {
 
 
 		if ( type === 'WebGLRenderer' && System.support.webgl === false ) {
 		if ( type === 'WebGLRenderer' && System.support.webgl === false ) {
 
 
@@ -105,11 +138,12 @@ Sidebar.Project = function ( editor ) {
 		}
 		}
 
 
 		var renderer = new rendererTypes[ type ]( { antialias: antialias } );
 		var renderer = new rendererTypes[ type ]( { antialias: antialias } );
+		if ( shadows && renderer.shadowMap ) renderer.shadowMap.enabled = true;
 		signals.rendererChanged.dispatch( renderer );
 		signals.rendererChanged.dispatch( renderer );
 
 
 	}
 	}
 
 
-	createRenderer( editor.config.getKey( 'project/renderer' ), editor.config.getKey( 'project/renderer/antialias' ) );
+	createRenderer( config.getKey( 'project/renderer' ), config.getKey( 'project/renderer/antialias' ), config.getKey( 'project/renderer/shadows' ) );
 
 
 	return container;
 	return container;
 
 

+ 21 - 21
editor/js/libs/app.js

@@ -27,6 +27,7 @@ var APP = {
 			renderer = new THREE.WebGLRenderer( { antialias: true } );
 			renderer = new THREE.WebGLRenderer( { antialias: true } );
 			renderer.setClearColor( 0x000000 );
 			renderer.setClearColor( 0x000000 );
 			renderer.setPixelRatio( window.devicePixelRatio );
 			renderer.setPixelRatio( window.devicePixelRatio );
+			if ( json.project.shadows ) renderer.shadowMap.enabled = true;
 			this.dom = renderer.domElement;
 			this.dom = renderer.domElement;
 
 
 			this.setScene( loader.parse( json.scene ) );
 			this.setScene( loader.parse( json.scene ) );
@@ -98,7 +99,6 @@ var APP = {
 			camera.aspect = this.width / this.height;
 			camera.aspect = this.width / this.height;
 			camera.updateProjectionMatrix();
 			camera.updateProjectionMatrix();
 
 
-
 			if ( vr === true ) {
 			if ( vr === true ) {
 
 
 				if ( camera.parent === null ) {
 				if ( camera.parent === null ) {
@@ -157,7 +157,7 @@ var APP = {
 
 
 		};
 		};
 
 
-		var dispatch = function ( array, event ) {
+		function dispatch( array, event ) {
 
 
 			for ( var i = 0, l = array.length; i < l; i ++ ) {
 			for ( var i = 0, l = array.length; i < l; i ++ ) {
 
 
@@ -173,11 +173,11 @@ var APP = {
 
 
 			}
 			}
 
 
-		};
+		}
 
 
 		var prevTime, request;
 		var prevTime, request;
 
 
-		var animate = function ( time ) {
+		function animate( time ) {
 
 
 			request = requestAnimationFrame( animate );
 			request = requestAnimationFrame( animate );
 
 
@@ -196,7 +196,7 @@ var APP = {
 
 
 			prevTime = time;
 			prevTime = time;
 
 
-		};
+		}
 
 
 		this.play = function () {
 		this.play = function () {
 
 
@@ -233,53 +233,53 @@ var APP = {
 
 
 		//
 		//
 
 
-		var onDocumentKeyDown = function ( event ) {
+		function onDocumentKeyDown( event ) {
 
 
 			dispatch( events.keydown, event );
 			dispatch( events.keydown, event );
 
 
-		};
+		}
 
 
-		var onDocumentKeyUp = function ( event ) {
+		function onDocumentKeyUp( event ) {
 
 
 			dispatch( events.keyup, event );
 			dispatch( events.keyup, event );
 
 
-		};
+		}
 
 
-		var onDocumentMouseDown = function ( event ) {
+		function onDocumentMouseDown( event ) {
 
 
 			dispatch( events.mousedown, event );
 			dispatch( events.mousedown, event );
 
 
-		};
+		}
 
 
-		var onDocumentMouseUp = function ( event ) {
+		function onDocumentMouseUp( event ) {
 
 
 			dispatch( events.mouseup, event );
 			dispatch( events.mouseup, event );
 
 
-		};
+		}
 
 
-		var onDocumentMouseMove = function ( event ) {
+		function onDocumentMouseMove( event ) {
 
 
 			dispatch( events.mousemove, event );
 			dispatch( events.mousemove, event );
 
 
-		};
+		}
 
 
-		var onDocumentTouchStart = function ( event ) {
+		function onDocumentTouchStart( event ) {
 
 
 			dispatch( events.touchstart, event );
 			dispatch( events.touchstart, event );
 
 
-		};
+		}
 
 
-		var onDocumentTouchEnd = function ( event ) {
+		function onDocumentTouchEnd( event ) {
 
 
 			dispatch( events.touchend, event );
 			dispatch( events.touchend, event );
 
 
-		};
+		}
 
 
-		var onDocumentTouchMove = function ( event ) {
+		function onDocumentTouchMove( event ) {
 
 
 			dispatch( events.touchmove, event );
 			dispatch( events.touchmove, event );
 
 
-		};
+		}
 
 
 	}
 	}
 
 

+ 0 - 160
editor/js/libs/tern-threejs/threejs.js

@@ -409,10 +409,6 @@
           "!type": "[]",
           "!type": "[]",
           "!doc": "Array of morph targets. Each morph target is a Javascript object:\n\t\t<code>{ name: \"targetName\", vertices: [ new THREE.Vector3(), ... ] }</code>\n\t\tMorph vertices match number and order of primary vertices."
           "!doc": "Array of morph targets. Each morph target is a Javascript object:\n\t\t<code>{ name: \"targetName\", vertices: [ new THREE.Vector3(), ... ] }</code>\n\t\tMorph vertices match number and order of primary vertices."
         },
         },
-        "morphColors": {
-          "!type": "[]",
-          "!doc": "Array of morph colors. Morph colors have similar structure as morph targets, each color set is a Javascript object:\n\t\t<code>morphColor = { name: \"colorName\", colors: [ new THREE.Color(), ... ] }</code>\n\t\tMorph colors can match either the number and order of faces (face colors) or the number of vertices (vertex colors)."
-        },
         "morphNormals": {
         "morphNormals": {
           "!type": "[]",
           "!type": "[]",
           "!doc": "Array of morph normals. Morph normals have similar structure as morph targets, each normal set is a Javascript object:\n\t\t<code>morphNormal = { name: \"NormalName\", normals: [ new THREE.Vector3(), ... ] }</code>"
           "!doc": "Array of morph normals. Morph normals have similar structure as morph targets, each normal set is a Javascript object:\n\t\t<code>morphNormal = { name: \"NormalName\", normals: [ new THREE.Vector3(), ... ] }</code>"
@@ -2088,106 +2084,6 @@
         "intensity": {
         "intensity": {
           "!type": "number",
           "!type": "number",
           "!doc": "Light's intensity.<br>\n\t\t\tDefault — *1.0*."
           "!doc": "Light's intensity.<br>\n\t\t\tDefault — *1.0*."
-        },
-        "onlyShadow": {
-          "!type": "bool",
-          "!doc": "If set to *true* light will only cast shadow but not contribute any lighting (as if *intensity* was 0 but cheaper to compute).<br>\n\t\t\tDefault — *false*."
-        },
-        "shadowCameraNear": {
-          "!type": "number",
-          "!doc": "Orthographic shadow camera frustum parameter.<br>\n\t\t\tDefault — *50*."
-        },
-        "shadowCameraFar": {
-          "!type": "number",
-          "!doc": "Orthographic shadow camera frustum parameter.<br>\n\t\t\tDefault — *5000*."
-        },
-        "shadowCameraLeft": {
-          "!type": "number",
-          "!doc": "Orthographic shadow camera frustum parameter.<br>\n\t\t\tDefault — *-500*."
-        },
-        "shadowCameraRight": {
-          "!type": "number",
-          "!doc": "Orthographic shadow camera frustum parameter.<br>\n\t\t\tDefault — *500*."
-        },
-        "shadowCameraTop": {
-          "!type": "number",
-          "!doc": "Orthographic shadow camera frustum parameter.<br>\n\t\t\tDefault — *500*."
-        },
-        "shadowCameraBottom": {
-          "!type": "number",
-          "!doc": "Orthographic shadow camera frustum parameter.<br>\n\t\t\tDefault — *-500*."
-        },
-        "shadowCameraVisible": {
-          "!type": "bool",
-          "!doc": "Show debug shadow camera frustum.<br>\n\t\t\tDefault — *false*."
-        },
-        "shadowBias": {
-          "!type": "number",
-          "!doc": "Shadow map bias, how much to add or subtract from the normalized depth when deciding whether a surface is in shadow.<br>\n\t\t\tDefault — *0*."
-        },
-        "shadowDarkness": {
-          "!type": "number",
-          "!doc": "Darkness of shadow casted by this light (from *0* to *1*).<br>\n\t\t\tDefault — *0.5*."
-        },
-        "shadowMapWidth": {
-          "!type": "number",
-          "!doc": "Shadow map texture width in pixels.<br>\n\t\t\tDefault — *512*."
-        },
-        "shadowMapHeight": {
-          "!type": "number",
-          "!doc": "Shadow map texture height in pixels.<br>\n\t\t\tDefault — *512*."
-        },
-        "shadowCascade": {
-          "!type": "bool",
-          "!doc": "**Experimental** If true, use a series of shadow maps in a cascade. This can give better z-depth resolution for a directional light. <br>\n\t\t\tDefault — *false*."
-        },
-        "shadowCascadeCount": {
-          "!type": "number",
-          "!doc": "Number of shadow maps to allocate in a cascade (one after another). <br>\n\t\t\tDefault — *2*."
-        },
-        "shadowCascadeOffset": {
-          "!type": "+THREE.Vector3",
-          "!doc": "A relative position to real camera where virtual shadow cameras are attached. A magic vector; scene and light orientation dependent. <br>\n\t\t\tDefault — *Three.Vector3( 0, 0, -1000 )*."
-        },
-        "shadowCascadeBias": {
-          "!type": "[]",
-          "!doc": "An array of shadowMapBias values for the corresponding shadow map in the cascade, near to far. <br>\n\t\t\tDefault — <strong>[ 0, 0, 0 ]</strong>."
-        },
-        "shadowCascadeWidth": {
-          "!type": "[]",
-          "!doc": "An array of shadowMapWidth values for the corresponding shadow map in the cascade, near to far. <br>\n\t\t\tDefault — <strong>[ 512, 512, 512 ]</strong>."
-        },
-        "shadowCascadeHeight": {
-          "!type": "[]",
-          "!doc": "An array of shadowMapHeight values for the corresponding shadow map in the cascade, near to far. <br>\n\t\t\tDefault — <strong>[ 512, 512, 512 ]</strong>."
-        },
-        "shadowCascadeNearZ": {
-          "!type": "[]",
-          "!doc": "An array of shadowMapNear values for the corresponding shadow map in the cascade, near to far. These typically start with -1.0 (near plane) and match with the previous shadowCascadeFarZ array value.<br>\n\t\t\tDefault — <strong>[ -1.000, 0.990, 0.998 ]</strong>."
-        },
-        "shadowCascadeFarZ": {
-          "!type": "[]",
-          "!doc": "An array of shadowMapFar values for the corresponding shadow map in the cascade, near to far. These typically match with the next shadowCascadeNearZ array value, ending in 1.0.<br>\n\t\t\tDefault — <strong>[ 0.990, 0.998, 1.000 ]</strong>."
-        },
-        "shadowCascadeArray": {
-          "!type": "[]",
-          "!doc": "Array of size shadowCascadeCount of [page:DirectionalLight THREE.DirectionalLight] objects. This holds the series of separate shadow maps in a cascade, near to far. Created internally."
-        },
-        "shadowMapSize": {
-          "!type": "+THREE.Vector2",
-          "!doc": "The shadowMapWidth and shadowMapHeight stored in a [page:Vector2 THREE.Vector2]. Set internally during rendering."
-        },
-        "shadowCamera": {
-          "!type": "+THREE.OrthographicCamera",
-          "!doc": "The shadow's view of the world. Computed internally during rendering from the shadowCamera* settings."
-        },
-        "shadowMatrix": {
-          "!type": "+THREE.Matrix4",
-          "!doc": "Model to shadow camera space, to compute location and depth in shadow map. Computed internally during rendering."
-        },
-        "shadowMap": {
-          "!type": "+THREE.WebGLRenderTarget",
-          "!doc": "The depth map generated using the shadowCamera; a location beyond a pixel's depth is in shadow. Computed internally during rendering."
         }
         }
       },
       },
       "!doc": "Affects objects using [page:MeshLambertMaterial] or [page:MeshPhongMaterial].",
       "!doc": "Affects objects using [page:MeshLambertMaterial] or [page:MeshPhongMaterial].",
@@ -2260,62 +2156,6 @@
         "exponent": {
         "exponent": {
           "!type": "number",
           "!type": "number",
           "!doc": "Rapidity of the falloff of light from its target direction.<br>\n\t\t\tDefault — *10.0*."
           "!doc": "Rapidity of the falloff of light from its target direction.<br>\n\t\t\tDefault — *10.0*."
-        },
-        "castShadow": {
-          "!type": "bool",
-          "!doc": "If set to *true* light will cast dynamic shadows. *Warning*: This is expensive and requires tweaking to get shadows looking right.<br>\n\t\t\tDefault — *false*."
-        },
-        "onlyShadow": {
-          "!type": "bool",
-          "!doc": "If set to *true* light will only cast shadow but not contribute any lighting (as if *intensity* was 0 but cheaper to compute).<br>\n\t\t\tDefault — *false*."
-        },
-        "shadowCameraNear": {
-          "!type": "number",
-          "!doc": "Perspective shadow camera frustum <em>near</em> parameter.<br>\n\t\t\tDefault — *50*."
-        },
-        "shadowCameraFar": {
-          "!type": "number",
-          "!doc": "Perspective shadow camera frustum <em>far</em> parameter.<br>\n\t\t\tDefault — *5000*."
-        },
-        "shadowCameraFov": {
-          "!type": "number",
-          "!doc": "Perspective shadow camera frustum <em>field of view</em> parameter.<br>\n\t\t\tDefault — *50*."
-        },
-        "shadowCameraVisible": {
-          "!type": "bool",
-          "!doc": "Show debug shadow camera frustum.<br>\n\t\t\tDefault — *false*."
-        },
-        "shadowBias": {
-          "!type": "number",
-          "!doc": "Shadow map bias, how much to add or subtract from the normalized depth when deciding whether a surface is in shadow.<br>\n\t\t\tDefault — *0*."
-        },
-        "shadowDarkness": {
-          "!type": "number",
-          "!doc": "Darkness of shadow casted by this light (from *0* to *1*).<br>\n\t\t\tDefault — *0.5*."
-        },
-        "shadowMapWidth": {
-          "!type": "number",
-          "!doc": "Shadow map texture width in pixels.<br>\n\t\t\tDefault — *512*."
-        },
-        "shadowMapHeight": {
-          "!type": "number",
-          "!doc": "Shadow map texture height in pixels.<br>\n\t\t\tDefault — *512*."
-        },
-        "shadowMapSize": {
-          "!type": "+THREE.Vector2",
-          "!doc": "The shadowMapWidth and shadowMapHeight stored in a [page:Vector2 THREE.Vector2]. Set internally during rendering."
-        },
-        "shadowCamera": {
-          "!type": "+THREE.PerspectiveCamera",
-          "!doc": "The shadow's view of the world. Computed internally during rendering from the shadowCamera* settings."
-        },
-        "shadowMatrix": {
-          "!type": "+THREE.Matrix4",
-          "!doc": "Model to shadow camera space, to compute location and depth in shadow map. Computed internally during rendering."
-        },
-        "shadowMap": {
-          "!type": "+THREE.WebGLRenderTarget",
-          "!doc": "The depth map generated using the shadowCamera; a location beyond a pixel's depth is in shadow. Computed internally during rendering."
         }
         }
       },
       },
       "!doc": "A point light that can cast shadow in one direction.",
       "!doc": "A point light that can cast shadow in one direction.",

+ 70 - 52
editor/js/libs/ui.js

@@ -12,6 +12,60 @@ UI.Element = function ( dom ) {
 
 
 UI.Element.prototype = {
 UI.Element.prototype = {
 
 
+	add: function () {
+
+		for ( var i = 0; i < arguments.length; i ++ ) {
+
+			var argument = arguments[ i ];
+
+			if ( argument instanceof UI.Element ) {
+
+				this.dom.appendChild( argument.dom );
+
+			} else {
+
+				console.error( 'UI.Element:', argument, 'is not an instance of UI.Element.' )
+
+			}
+
+		}
+
+		return this;
+
+	},
+
+	remove: function () {
+
+		for ( var i = 0; i < arguments.length; i ++ ) {
+
+			var argument = arguments[ i ];
+
+			if ( argument instanceof UI.Element ) {
+
+				this.dom.removeChild( argument.dom );
+
+			} else {
+
+				console.error( 'UI.Element:', argument, 'is not an instance of UI.Element.' )
+
+			}
+
+		}
+
+		return this;
+
+	},
+
+	clear: function () {
+
+		while ( this.dom.children.length ) {
+
+			this.dom.removeChild( this.dom.lastChild );
+
+		}
+
+	},
+
 	setId: function ( id ) {
 	setId: function ( id ) {
 
 
 		this.dom.id = id;
 		this.dom.id = id;
@@ -36,6 +90,8 @@ UI.Element.prototype = {
 
 
 		}
 		}
 
 
+		return this;
+
 	},
 	},
 
 
 	setDisabled: function ( value ) {
 	setDisabled: function ( value ) {
@@ -69,6 +125,7 @@ properties.forEach( function ( property ) {
 	UI.Element.prototype[ method ] = function () {
 	UI.Element.prototype[ method ] = function () {
 
 
 		this.setStyle( property, arguments );
 		this.setStyle( property, arguments );
+
 		return this;
 		return this;
 
 
 	};
 	};
@@ -93,78 +150,39 @@ events.forEach( function ( event ) {
 
 
 } );
 } );
 
 
+// Span
 
 
-// Panel
-
-UI.Panel = function () {
+UI.Span = function () {
 
 
 	UI.Element.call( this );
 	UI.Element.call( this );
 
 
-	var dom = document.createElement( 'div' );
-	dom.className = 'Panel';
-
-	this.dom = dom;
-
-	return this;
-};
-
-UI.Panel.prototype = Object.create( UI.Element.prototype );
-UI.Panel.prototype.constructor = UI.Panel;
-
-UI.Panel.prototype.add = function () {
-
-	for ( var i = 0; i < arguments.length; i ++ ) {
-
-		var argument = arguments[ i ];
-
-		if ( argument instanceof UI.Element ) {
-
-			this.dom.appendChild( argument.dom );
-
-		} else {
-
-			console.error( 'UI.Panel:', argument, 'is not an instance of UI.Element.' )
-
-		}
-
-	}
+	this.dom = document.createElement( 'span' );
 
 
 	return this;
 	return this;
 
 
 };
 };
 
 
+UI.Span.prototype = Object.create( UI.Element.prototype );
+UI.Span.prototype.constructor = UI.Span;
 
 
-UI.Panel.prototype.remove = function () {
-
-	for ( var i = 0; i < arguments.length; i ++ ) {
-
-		var argument = arguments[ i ];
 
 
-		if ( argument instanceof UI.Element ) {
-
-			this.dom.removeChild( argument.dom );
+// Panel
 
 
-		} else {
+UI.Panel = function () {
 
 
-			console.error( 'UI.Panel:', argument, 'is not an instance of UI.Element.' )
+	UI.Element.call( this );
 
 
-		}
+	var dom = document.createElement( 'div' );
+	dom.className = 'Panel';
 
 
-	}
+	this.dom = dom;
 
 
 	return this;
 	return this;
 
 
 };
 };
 
 
-UI.Panel.prototype.clear = function () {
-
-	while ( this.dom.children.length ) {
-
-		this.dom.removeChild( this.dom.lastChild );
-
-	}
-
-};
+UI.Panel.prototype = Object.create( UI.Element.prototype );
+UI.Panel.prototype.constructor = UI.Panel;
 
 
 
 
 // Collapsible Panel
 // Collapsible Panel

+ 0 - 1
examples/canvas_materials.html

@@ -73,7 +73,6 @@
 					new THREE.MeshBasicMaterial( { color: 0xff0000, blending: THREE.AdditiveBlending } ),
 					new THREE.MeshBasicMaterial( { color: 0xff0000, blending: THREE.AdditiveBlending } ),
 					new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading, overdraw: 0.5 } ),
 					new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading, overdraw: 0.5 } ),
 					new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.SmoothShading, overdraw: 0.5 } ),
 					new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.SmoothShading, overdraw: 0.5 } ),
-					new THREE.MeshDepthMaterial( { overdraw: 0.5 } ),
 					new THREE.MeshNormalMaterial( { overdraw: 0.5 } ),
 					new THREE.MeshNormalMaterial( { overdraw: 0.5 } ),
 					new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ),
 					new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ),
 					new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/envmap.png', THREE.SphericalReflectionMapping ), overdraw: 0.5 } )
 					new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/envmap.png', THREE.SphericalReflectionMapping ), overdraw: 0.5 } )

+ 0 - 238
examples/canvas_materials_depth.html

@@ -1,238 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-	<head>
-		<title>three.js canvas - depth material</title>
-		<meta charset="utf-8">
-		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
-		<style>
-			body {
-				font-family: Monospace;
-				background-color: #000000;
-				margin: 0px;
-				overflow: hidden;
-			}
-		</style>
-	</head>
-	<body>
-
-		<script src="../build/three.min.js"></script>
-
-		<script src="js/renderers/Projector.js"></script>
-		<script src="js/renderers/CanvasRenderer.js"></script>
-
-		<script src="js/libs/stats.min.js"></script>
-
-		<script>
-
-			var container, stats;
-
-			var camera, scene, renderer;
-
-			var cube, plane, objects = [];
-
-			var targetRotation = 0;
-			var targetRotationOnMouseDown = 0;
-
-			var mouseX = 0;
-			var mouseXOnMouseDown = 0;
-
-			var moveForward = false;
-			var moveBackwards = false;
-			var moveLeft = false;
-			var moveRight = false;
-			var moveUp = false;
-			var moveDown = false;
-
-			var targetMoveLeft = false;
-			var targetMoveRight = false;
-
-			var debugContext;
-
-			init();
-			animate();
-
-			function init() {
-
-				container = document.createElement( 'div' );
-				document.body.appendChild( container );
-
-				camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
-				camera.position.set( 1000, 1000, 1000 );
-				camera.target = new THREE.Vector3( 0, 150, 0 );
-
-				scene = new THREE.Scene();
-
-				// Plane
-
-				var material = new THREE.MeshDepthMaterial( { side: THREE.DoubleSide, overdraw: 0.5 } );
-
-				plane = new THREE.Mesh( new THREE.PlaneBufferGeometry( 1000, 1000, 10, 10 ), material );
-				plane.position.y = - 100;
-				plane.rotation.x = - Math.PI / 2;
-				scene.add( plane );
-
-				// Cubes
-
-				geometry = new THREE.BoxGeometry( 100, 100, 100 );
-				material = new THREE.MeshDepthMaterial( { overdraw: 0.5 } );
-
-				for ( var i = 0; i < 20; i ++ ) {
-
-					cube = new THREE.Mesh( geometry, material );
-
-					cube.position.x = ( i % 5 ) * 200 - 400;
-					cube.position.z = Math.floor( i / 5 ) * 200 - 350;
-
-					cube.rotation.x = Math.random() * 200 - 100;
-					cube.rotation.y = Math.random() * 200 - 100;
-					cube.rotation.z = Math.random() * 200 - 100;
-
-					scene.add( cube );
-
-					objects.push( cube );
-
-				}
-
-				renderer = new THREE.CanvasRenderer();
-				renderer.setPixelRatio( window.devicePixelRatio );
-				renderer.setSize( window.innerWidth, window.innerHeight );
-				container.appendChild( renderer.domElement );
-
-				var debugCanvas = document.createElement( 'canvas' );
-				debugCanvas.width = 512;
-				debugCanvas.height = 512;
-				debugCanvas.style.position = 'absolute';
-				debugCanvas.style.top = '0px';
-				debugCanvas.style.left = '0px';
-
-				container.appendChild( debugCanvas );
-
-				debugContext = debugCanvas.getContext( '2d' );
-				debugContext.setTransform( 1, 0, 0, 1, 256, 256 );
-				debugContext.strokeStyle = '#808080';
-
-				stats = new Stats();
-				stats.domElement.style.position = 'absolute';
-				stats.domElement.style.top = '0px';
-				container.appendChild(stats.domElement);
-
-				document.addEventListener( 'keydown', onDocumentKeyDown, false );
-				document.addEventListener( 'keyup', onDocumentKeyUp, false );
-
-				//
-
-				window.addEventListener( 'resize', onWindowResize, false );
-
-			}
-
-			function onWindowResize() {
-
-				camera.aspect = window.innerWidth / window.innerHeight;
-				camera.updateProjectionMatrix();
-
-				renderer.setSize( window.innerWidth, window.innerHeight );
-
-			}
-
-			function onDocumentKeyDown( event ) {
-
-				switch ( event.keyCode ) {
-
-					case 38: moveForward = true; break; // up
-					case 40: moveBackwards = true; break; // down
-					case 37: moveLeft = true; break; // left
-					case 39: moveRight = true; break; // right
-					case 87: moveUp = true; break; // w
-					case 83: moveDown = true; break; // s
-					case 65: targetMoveLeft = true; break; // a
-					case 68: targetMoveRight = true; break; // d
-
-				}
-
-			}
-
-			function onDocumentKeyUp( event ) {
-
-				switch ( event.keyCode ) {
-
-					case 38: moveForward = false; break; // up
-					case 40: moveBackwards = false; break; // down
-					case 37: moveLeft = false; break; // left
-					case 39: moveRight = false; break; // right
-					case 87: moveUp = false; break; // w
-					case 83: moveDown = false; break; // s
-					case 65: targetMoveLeft = false; break; // a
-					case 68: targetMoveRight = false; break; // d
-
-				}
-
-			}
-
-			//
-
-			function animate() {
-
-				requestAnimationFrame( animate );
-
-				render();
-				stats.update();
-
-			}
-
-			function render() {
-
-				if ( moveForward ) camera.position.z -= 10;
-				if ( moveBackwards ) camera.position.z += 10;
-
-				if ( moveLeft ) camera.position.x -= 10;
-				if ( moveRight ) camera.position.x += 10;
-
-				if ( moveUp ) camera.position.y += 10;
-				if ( moveDown ) camera.position.y -= 10;
-
-				if ( targetMoveLeft ) camera.target.x -= 10;
-				if ( targetMoveRight ) camera.target.x += 10;
-
-				camera.lookAt( camera.target );
-
-				debugContext.clearRect( - 256, - 256, 512, 512 );
-
-				debugContext.beginPath();
-
-				// center
-				debugContext.moveTo( - 10, 0 );
-				debugContext.lineTo( 10, 0 );
-				debugContext.moveTo( 0, - 10 );
-				debugContext.lineTo( 0, 10 );
-
-				// camera
-
-				debugContext.moveTo( camera.position.x * 0.1, camera.position.z * 0.1 );
-				debugContext.lineTo( camera.target.x * 0.1, camera.target.z * 0.1 );
-				debugContext.rect( camera.position.x * 0.1 - 5, camera.position.z * 0.1 - 5, 10, 10 );
-				debugContext.rect( camera.target.x * 0.1 - 5, camera.target.z * 0.1 - 5, 10, 10 );
-				debugContext.rect( - 50, - 50, 100, 100 );
-
-				for ( var i = 0; i < objects.length; i++ ) {
-
-					var object = objects[ i ];
-
-					object.rotation.x += 0.01;
-					object.rotation.y += 0.005;
-					object.position.y = Math.sin( object.rotation.x ) * 200 + 200;
-
-					debugContext.rect( object.position.x * 0.1 - 5, object.position.z * 0.1 - 5, 10, 10 );
-
-				}
-
-				debugContext.closePath();
-				debugContext.stroke();
-
-				renderer.render( scene, camera );
-
-			}
-
-		</script>
-
-	</body>
-</html>

+ 10 - 4
examples/canvas_morphtargets_horse.html

@@ -54,25 +54,31 @@
 
 
 				//
 				//
 
 
-				var light = new THREE.DirectionalLight( 0xefefff, 2 );
+				var light = new THREE.DirectionalLight( 0xefefff, 1.5 );
 				light.position.set( 1, 1, 1 ).normalize();
 				light.position.set( 1, 1, 1 ).normalize();
 				scene.add( light );
 				scene.add( light );
 
 
-				var light = new THREE.DirectionalLight( 0xffefef, 2 );
+				var light = new THREE.DirectionalLight( 0xffefef, 1.5 );
 				light.position.set( -1, -1, -1 ).normalize();
 				light.position.set( -1, -1, -1 ).normalize();
 				scene.add( light );
 				scene.add( light );
 
 
 				var loader = new THREE.JSONLoader();
 				var loader = new THREE.JSONLoader();
 				loader.load( "models/animated/horse.js", function ( geometry ) {
 				loader.load( "models/animated/horse.js", function ( geometry ) {
 
 
-					mesh = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { color: 0x606060, morphTargets: true, overdraw: 0.5 } ) );
+					var material = new THREE.MeshLambertMaterial( {
+						vertexColors: THREE.FaceColors,
+						morphTargets: true,
+						overdraw: 0.5
+					} );
+
+					mesh = new THREE.Mesh( geometry, material );
 					mesh.scale.set( 1.5, 1.5, 1.5 );
 					mesh.scale.set( 1.5, 1.5, 1.5 );
 					scene.add( mesh );
 					scene.add( mesh );
 
 
 					mixer = new THREE.AnimationMixer( mesh );
 					mixer = new THREE.AnimationMixer( mesh );
 
 
 					var clip = THREE.AnimationClip.CreateFromMorphTargetSequence( 'gallop', geometry.morphTargets, 30 );
 					var clip = THREE.AnimationClip.CreateFromMorphTargetSequence( 'gallop', geometry.morphTargets, 30 );
-					mixer.addAction( new THREE.AnimationAction( clip ).warpToDuration( 1.5 ) );
+					mixer.addAction( new THREE.AnimationAction( clip ).warpToDuration( 1 ) );
 
 
 				} );
 				} );
 
 

+ 0 - 1
examples/index.html

@@ -450,7 +450,6 @@
 				"canvas_lines_dashed",
 				"canvas_lines_dashed",
 				"canvas_lines_sphere",
 				"canvas_lines_sphere",
 				"canvas_materials",
 				"canvas_materials",
-				"canvas_materials_depth",
 				"canvas_materials_normal",
 				"canvas_materials_normal",
 				"canvas_materials_reflection",
 				"canvas_materials_reflection",
 				"canvas_materials_video",
 				"canvas_materials_video",

+ 0 - 10
examples/js/renderers/CanvasRenderer.js

@@ -36,8 +36,6 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 
 	console.log( 'THREE.CanvasRenderer', THREE.REVISION );
 	console.log( 'THREE.CanvasRenderer', THREE.REVISION );
 
 
-	var smoothstep = THREE.Math.smoothstep;
-
 	parameters = parameters || {};
 	parameters = parameters || {};
 
 
 	var _this = this,
 	var _this = this,
@@ -760,14 +758,6 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 
 			}
 			}
 
 
-		} else if ( material instanceof THREE.MeshDepthMaterial ) {
-
-			_color.r = _color.g = _color.b = 1 - smoothstep( v1.positionScreen.z * v1.positionScreen.w, _camera.near, _camera.far );
-
-			material.wireframe === true
-					 ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin )
-					 : fillPath( _color );
-
 		} else if ( material instanceof THREE.MeshNormalMaterial ) {
 		} else if ( material instanceof THREE.MeshNormalMaterial ) {
 
 
 			_normal.copy( element.normalModel ).applyMatrix3( _normalViewMatrix );
 			_normal.copy( element.normalModel ).applyMatrix3( _normalViewMatrix );

+ 0 - 6
examples/js/renderers/SVGRenderer.js

@@ -36,7 +36,6 @@ THREE.SVGRenderer = function () {
 	_clearColor = new THREE.Color(),
 	_clearColor = new THREE.Color(),
 	_clearAlpha = 1,
 	_clearAlpha = 1,
 
 
-	_w, // z-buffer to w-buffer
 	_vector3 = new THREE.Vector3(), // Needed for PointLight
 	_vector3 = new THREE.Vector3(), // Needed for PointLight
 	_centroid = new THREE.Vector3(),
 	_centroid = new THREE.Vector3(),
 	_normal = new THREE.Vector3(),
 	_normal = new THREE.Vector3(),
@@ -383,11 +382,6 @@ THREE.SVGRenderer = function () {
 
 
 			_color.multiply( _diffuseColor ).add( material.emissive );
 			_color.multiply( _diffuseColor ).add( material.emissive );
 
 
-		} else if ( material instanceof THREE.MeshDepthMaterial ) {
-
-			_w = 1 - ( material.__2near / ( material.__farPlusNear - element.z * material.__farMinusNear ) );
-			_color.setRGB( _w, _w, _w );
-
 		} else if ( material instanceof THREE.MeshNormalMaterial ) {
 		} else if ( material instanceof THREE.MeshNormalMaterial ) {
 
 
 			_normal.copy( element.normalModel ).applyMatrix3( _normalViewMatrix );
 			_normal.copy( element.normalModel ).applyMatrix3( _normalViewMatrix );

+ 3 - 3
examples/js/utils/ShadowMapViewer.js

@@ -35,7 +35,7 @@ THREE.ShadowMapViewer = function ( light ) {
 	var userAutoClearSetting;
 	var userAutoClearSetting;
 
 
 	//Holds the initial position and dimension of the HUD
 	//Holds the initial position and dimension of the HUD
-	var frame = { 
+	var frame = {
 		x: 10,
 		x: 10,
 		y: 10,
 		y: 10,
 		width: 256,
 		width: 256,
@@ -103,7 +103,7 @@ THREE.ShadowMapViewer = function ( light ) {
 
 
 	//- API
 	//- API
 	// Set to false to disable displaying this shadow map
 	// Set to false to disable displaying this shadow map
-	this.enabled = true; 
+	this.enabled = true;
 
 
 	// Set the size of the displayed shadow map on the HUD
 	// Set the size of the displayed shadow map on the HUD
 	this.size = {
 	this.size = {
@@ -150,7 +150,7 @@ THREE.ShadowMapViewer = function ( light ) {
 			//always end up with the scene's first added shadow casting light's shadowMap
 			//always end up with the scene's first added shadow casting light's shadowMap
 			//in the shader
 			//in the shader
 			//See: https://github.com/mrdoob/three.js/issues/5932
 			//See: https://github.com/mrdoob/three.js/issues/5932
-			uniforms.tDiffuse.value = light.shadowMap;
+			uniforms.tDiffuse.value = light.shadow.map;
 
 
 			userAutoClearSetting = renderer.autoClear;
 			userAutoClearSetting = renderer.autoClear;
 			renderer.autoClear = false; // To allow render overlay
 			renderer.autoClear = false; // To allow render overlay

+ 0 - 0
examples/obj/tree/tree.obj → examples/models/obj/tree.obj


Разница между файлами не показана из-за своего большого размера
+ 0 - 2
examples/obj/female02/Female02_slim.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 2
examples/obj/leeperrysmith/LeePerrySmith.js


+ 0 - 2
examples/obj/lucy/Lucy100k_slim.js

@@ -25,8 +25,6 @@
 
 
     "morphTargets": [],
     "morphTargets": [],
 
 
-    "morphColors": [],
-
     "normals": [],
     "normals": [],
 
 
     "colors": [],
     "colors": [],

Разница между файлами не показана из-за своего большого размера
+ 0 - 2
examples/obj/male02/Male02_dds.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 2
examples/obj/male02/Male02_slim.js


+ 0 - 7
examples/obj/tree/.htaccess

@@ -1,7 +0,0 @@
-<Files *.js>
-SetOutputFilter DEFLATE
-</Files>
-
-<Files *.bin>
-SetOutputFilter DEFLATE
-</Files>

Разница между файлами не показана из-за своего большого размера
+ 0 - 23
examples/obj/tree/tree.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 2
examples/obj/walt/WaltHead_slim.js


+ 1 - 19
examples/webgl_lights_hemisphere.html

@@ -201,8 +201,6 @@
 
 
 				loader.load( "models/animated/flamingo.js", function( geometry ) {
 				loader.load( "models/animated/flamingo.js", function( geometry ) {
 
 
-					morphColorsToFaceColors( geometry );
-
 					var material = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0xffffff, shininess: 20, morphTargets: true, vertexColors: THREE.FaceColors, shading: THREE.FlatShading } );
 					var material = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0xffffff, shininess: 20, morphTargets: true, vertexColors: THREE.FaceColors, shading: THREE.FlatShading } );
 					var mesh = new THREE.Mesh( geometry, material );
 					var mesh = new THREE.Mesh( geometry, material );
 
 
@@ -217,7 +215,7 @@
 					scene.add( mesh );
 					scene.add( mesh );
 
 
 					var mixer = new THREE.AnimationMixer( mesh );
 					var mixer = new THREE.AnimationMixer( mesh );
-					mixer.addAction( new THREE.AnimationAction( geometry.animations[0] ).warpToDuration( 5 ) );
+					mixer.addAction( new THREE.AnimationAction( geometry.animations[ 0 ] ).warpToDuration( 1 ) );
 					mixers.push( mixer );
 					mixers.push( mixer );
 
 
 				} );
 				} );
@@ -248,22 +246,6 @@
 
 
 			}
 			}
 
 
-			function morphColorsToFaceColors( geometry ) {
-
-				if ( geometry.morphColors && geometry.morphColors.length ) {
-
-					var colorMap = geometry.morphColors[ 0 ];
-
-					for ( var i = 0; i < colorMap.colors.length; i ++ ) {
-
-						geometry.faces[ i ].color = colorMap.colors[ i ];
-
-					}
-
-				}
-
-			}
-
 			function onWindowResize() {
 			function onWindowResize() {
 
 
 				camera.aspect = window.innerWidth / window.innerHeight;
 				camera.aspect = window.innerWidth / window.innerHeight;

+ 0 - 2
examples/webgl_lights_pointlights.html

@@ -80,8 +80,6 @@
 
 
 				loader.load( "obj/walt/WaltHead_bin.js", callback );
 				loader.load( "obj/walt/WaltHead_bin.js", callback );
 
 
-				scene.add( new THREE.AmbientLight( 0x000000 ) );
-
 				var sphere = new THREE.SphereGeometry( 0.5, 16, 8 );
 				var sphere = new THREE.SphereGeometry( 0.5, 16, 8 );
 
 
 				light1 = new THREE.PointLight( 0xff0040, 2, 50 );
 				light1 = new THREE.PointLight( 0xff0040, 2, 50 );

+ 2 - 22
examples/webgl_morphnormals.html

@@ -87,12 +87,10 @@
 
 
 				//
 				//
 
 
-				
+
 				var loader = new THREE.JSONLoader();
 				var loader = new THREE.JSONLoader();
 				loader.load( "models/animated/flamingo.js", function( geometry ) {
 				loader.load( "models/animated/flamingo.js", function( geometry ) {
 
 
-					morphColorsToFaceColors( geometry );
-
 					var material = new THREE.MeshPhongMaterial( { color: 0xffffff, morphTargets: true, vertexColors: THREE.FaceColors, shading: THREE.FlatShading } );
 					var material = new THREE.MeshPhongMaterial( { color: 0xffffff, morphTargets: true, vertexColors: THREE.FaceColors, shading: THREE.FlatShading } );
 					var mesh = new THREE.Mesh( geometry, material );
 					var mesh = new THREE.Mesh( geometry, material );
 
 
@@ -110,13 +108,12 @@
 
 
 				loader.load( "models/animated/flamingo.js", function( geometry ) {
 				loader.load( "models/animated/flamingo.js", function( geometry ) {
 
 
-					morphColorsToFaceColors( geometry );
 					geometry.computeVertexNormals();
 					geometry.computeVertexNormals();
 					geometry.computeMorphNormals();
 					geometry.computeMorphNormals();
 
 
 					var material = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0xffffff, shininess: 20, morphTargets: true, morphNormals: true, vertexColors: THREE.FaceColors, shading: THREE.SmoothShading } );
 					var material = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0xffffff, shininess: 20, morphTargets: true, morphNormals: true, vertexColors: THREE.FaceColors, shading: THREE.SmoothShading } );
 					var mesh = new THREE.Mesh( geometry, material );
 					var mesh = new THREE.Mesh( geometry, material );
-					
+
 					mesh.scale.set( 1.5, 1.5, 1.5 );
 					mesh.scale.set( 1.5, 1.5, 1.5 );
 					mesh.position.y = 150;
 					mesh.position.y = 150;
 
 
@@ -154,23 +151,6 @@
 
 
 			}
 			}
 
 
-			function morphColorsToFaceColors( geometry ) {
-
-				if ( geometry.morphColors && geometry.morphColors.length ) {
-
-					var colorMap = geometry.morphColors[ 0 ];
-
-					for ( var i = 0; i < colorMap.colors.length; i ++ ) {
-
-						geometry.faces[ i ].color = colorMap.colors[ i ];
-						geometry.faces[ i ].color.offsetHSL( 0, 0.3, 0 );
-
-					}
-
-				}
-
-			}
-
 			//
 			//
 
 
 			function onWindowResize( event ) {
 			function onWindowResize( event ) {

+ 7 - 4
examples/webgl_morphtargets_horse.html

@@ -51,25 +51,28 @@
 
 
 				//
 				//
 
 
-				var light = new THREE.DirectionalLight( 0xefefff, 2 );
+				var light = new THREE.DirectionalLight( 0xefefff, 1.5 );
 				light.position.set( 1, 1, 1 ).normalize();
 				light.position.set( 1, 1, 1 ).normalize();
 				scene.add( light );
 				scene.add( light );
 
 
-				var light = new THREE.DirectionalLight( 0xffefef, 2 );
+				var light = new THREE.DirectionalLight( 0xffefef, 1.5 );
 				light.position.set( -1, -1, -1 ).normalize();
 				light.position.set( -1, -1, -1 ).normalize();
 				scene.add( light );
 				scene.add( light );
 
 
 				var loader = new THREE.JSONLoader();
 				var loader = new THREE.JSONLoader();
 				loader.load( "models/animated/horse.js", function( geometry ) {
 				loader.load( "models/animated/horse.js", function( geometry ) {
 
 
-					mesh = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { color: 0x606060, morphTargets: true } ) );
+					mesh = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( {
+						vertexColors: THREE.FaceColors,
+						morphTargets: true
+					} ) );
 					mesh.scale.set( 1.5, 1.5, 1.5 );
 					mesh.scale.set( 1.5, 1.5, 1.5 );
 					scene.add( mesh );
 					scene.add( mesh );
 
 
 					mixer = new THREE.AnimationMixer( mesh );
 					mixer = new THREE.AnimationMixer( mesh );
 
 
 					var clip = THREE.AnimationClip.CreateFromMorphTargetSequence( 'gallop', geometry.morphTargets, 30 );
 					var clip = THREE.AnimationClip.CreateFromMorphTargetSequence( 'gallop', geometry.morphTargets, 30 );
-					mixer.addAction( new THREE.AnimationAction( clip ).warpToDuration( 1.5 ) );
+					mixer.addAction( new THREE.AnimationAction( clip ).warpToDuration( 1 ) );
 
 
 				} );
 				} );
 
 

+ 9 - 18
examples/webgl_postprocessing_godrays.html

@@ -37,6 +37,7 @@
 
 
 	<body>
 	<body>
 		<script src="../build/three.min.js"></script>
 		<script src="../build/three.min.js"></script>
+		<script src="js/loaders/OBJLoader.js"></script>
 		<script src="js/ShaderGodRays.js"></script>
 		<script src="js/ShaderGodRays.js"></script>
 
 
 		<script src="js/Detector.js"></script>
 		<script src="js/Detector.js"></script>
@@ -54,7 +55,7 @@
 			var container, stats;
 			var container, stats;
 			var camera, scene, renderer, materialDepth;
 			var camera, scene, renderer, materialDepth;
 
 
-			var treeMesh, sphereMesh;
+			var sphereMesh;
 
 
 			var sunPosition = new THREE.Vector3( 0, 1000, -1000 );
 			var sunPosition = new THREE.Vector3( 0, 1000, -1000 );
 			var screenSpacePosition = new THREE.Vector3();
 			var screenSpacePosition = new THREE.Vector3();
@@ -94,20 +95,13 @@
 
 
 				// tree
 				// tree
 
 
-				var loader = new THREE.JSONLoader();
+				var loader = new THREE.OBJLoader();
+				loader.load( "models/obj/tree.obj", function ( object ) {
 
 
-				loader.load( "obj/tree/tree.js", function( geometry ) {
-
-					treeMesh = new THREE.Mesh( geometry, materialScene );
-					treeMesh.position.set( 0, -150, -150 );
-
-					var sc = 400;
-					treeMesh.scale.set( sc, sc, sc );
-
-					treeMesh.matrixAutoUpdate = false;
-					treeMesh.updateMatrix();
-
-					scene.add( treeMesh );
+					object.material = materialScene;
+					object.position.set( 0, -150, -150 );
+					object.scale.multiplyScalar( 400 );
+					scene.add( object );
 
 
 				} );
 				} );
 
 
@@ -115,10 +109,7 @@
 
 
 				var geo = new THREE.SphereGeometry( 1, 20, 10 );
 				var geo = new THREE.SphereGeometry( 1, 20, 10 );
 				sphereMesh = new THREE.Mesh( geo, materialScene );
 				sphereMesh = new THREE.Mesh( geo, materialScene );
-
-				var sc = 20;
-				sphereMesh.scale.set( sc, sc, sc );
-
+				sphereMesh.scale.multiplyScalar( 20 );
 				scene.add( sphereMesh );
 				scene.add( sphereMesh );
 
 
 				//
 				//

+ 1 - 22
examples/webgl_shadowmap.html

@@ -328,35 +328,17 @@
 
 
 					mesh.castShadow = true;
 					mesh.castShadow = true;
 					mesh.receiveShadow = true;
 					mesh.receiveShadow = true;
-				
+
 					scene.add( mesh );
 					scene.add( mesh );
 
 
 					morphs.push( mesh );
 					morphs.push( mesh );
 
 
 				}
 				}
 
 
-				function morphColorsToFaceColors( geometry ) {
-
-					if ( geometry.morphColors && geometry.morphColors.length ) {
-
-						var colorMap = geometry.morphColors[ 0 ];
-
-						for ( var i = 0; i < colorMap.colors.length; i ++ ) {
-
-							geometry.faces[ i ].color = colorMap.colors[ i ];
-
-						}
-
-					}
-
-				}
-
 				var loader = new THREE.JSONLoader();
 				var loader = new THREE.JSONLoader();
 
 
 				loader.load( "models/animated/horse.js", function( geometry ) {
 				loader.load( "models/animated/horse.js", function( geometry ) {
 
 
-					morphColorsToFaceColors( geometry );
-
 					addMorph( geometry, 550, 1, 100 - Math.random() * 1000, FLOOR, 300, true );
 					addMorph( geometry, 550, 1, 100 - Math.random() * 1000, FLOOR, 300, true );
 					addMorph( geometry, 550, 1, 100 - Math.random() * 1000, FLOOR, 450, true );
 					addMorph( geometry, 550, 1, 100 - Math.random() * 1000, FLOOR, 450, true );
 					addMorph( geometry, 550, 1, 100 - Math.random() * 1000, FLOOR, 600, true );
 					addMorph( geometry, 550, 1, 100 - Math.random() * 1000, FLOOR, 600, true );
@@ -369,21 +351,18 @@
 
 
 				loader.load( "models/animated/flamingo.js", function( geometry ) {
 				loader.load( "models/animated/flamingo.js", function( geometry ) {
 
 
-					morphColorsToFaceColors( geometry );
 					addMorph( geometry, 500, 1, 500 - Math.random() * 500, FLOOR + 350, 40 );
 					addMorph( geometry, 500, 1, 500 - Math.random() * 500, FLOOR + 350, 40 );
 
 
 				} );
 				} );
 
 
 				loader.load( "models/animated/stork.js", function( geometry ) {
 				loader.load( "models/animated/stork.js", function( geometry ) {
 
 
-					morphColorsToFaceColors( geometry );
 					addMorph( geometry, 350, 1, 500 - Math.random() * 500, FLOOR + 350, 340 );
 					addMorph( geometry, 350, 1, 500 - Math.random() * 500, FLOOR + 350, 340 );
 
 
 				} );
 				} );
 
 
 				loader.load( "models/animated/parrot.js", function( geometry ) {
 				loader.load( "models/animated/parrot.js", function( geometry ) {
 
 
-					morphColorsToFaceColors( geometry );
 					addMorph( geometry, 450, 0.5, 500 - Math.random() * 500, FLOOR + 300, 700 );
 					addMorph( geometry, 450, 0.5, 500 - Math.random() * 500, FLOOR + 300, 700 );
 
 
 				} );
 				} );

+ 2 - 27
examples/webgl_shadowmap_performance.html

@@ -238,7 +238,7 @@
 				scene.add( mesh );
 				scene.add( mesh );
 
 
 				mixer = new THREE.AnimationMixer( scene );
 				mixer = new THREE.AnimationMixer( scene );
-					
+
 				// MORPHS
 				// MORPHS
 
 
 				function addMorph( geometry, speed, duration, x, y, z, fudgeColor ) {
 				function addMorph( geometry, speed, duration, x, y, z, fudgeColor ) {
@@ -255,7 +255,7 @@
 					mesh.speed = speed;
 					mesh.speed = speed;
 
 
 					mixer.addAction( new THREE.AnimationAction( geometry.animations[0], Math.random() ).warpToDuration( duration ).setLocalRoot( mesh ) );
 					mixer.addAction( new THREE.AnimationAction( geometry.animations[0], Math.random() ).warpToDuration( duration ).setLocalRoot( mesh ) );
-				
+
 					mesh.position.set( x, y, z );
 					mesh.position.set( x, y, z );
 					mesh.rotation.y = Math.PI/2;
 					mesh.rotation.y = Math.PI/2;
 
 
@@ -268,28 +268,10 @@
 
 
 				}
 				}
 
 
-				function morphColorsToFaceColors( geometry ) {
-
-					if ( geometry.morphColors && geometry.morphColors.length ) {
-
-						var colorMap = geometry.morphColors[ 0 ];
-
-						for ( var i = 0; i < colorMap.colors.length; i ++ ) {
-
-							geometry.faces[ i ].color = colorMap.colors[ i ];
-
-						}
-
-					}
-
-				}
-
 				var loader = new THREE.JSONLoader();
 				var loader = new THREE.JSONLoader();
 
 
 				loader.load( "models/animated/horse.js", function( geometry ) {
 				loader.load( "models/animated/horse.js", function( geometry ) {
 
 
-					morphColorsToFaceColors( geometry );
-
 					for ( var i = - 600; i < 601; i += 2 ) {
 					for ( var i = - 600; i < 601; i += 2 ) {
 
 
 						addMorph( geometry, 550, 1, 100 - Math.random() * 3000, FLOOR, i, true );
 						addMorph( geometry, 550, 1, 100 - Math.random() * 3000, FLOOR, i, true );
@@ -301,49 +283,42 @@
 				/*
 				/*
 				loader.load( "obj/morphs/fox.js", function( geometry ) {
 				loader.load( "obj/morphs/fox.js", function( geometry ) {
 
 
-					morphColorsToFaceColors( geometry );
 					addMorph( geometry, 200, 1000, 100 - Math.random() * 500, FLOOR - 5, 600 );
 					addMorph( geometry, 200, 1000, 100 - Math.random() * 500, FLOOR - 5, 600 );
 
 
 				} );
 				} );
 
 
 				loader.load( "obj/morphs/shdw3walk.js", function( geometry ) {
 				loader.load( "obj/morphs/shdw3walk.js", function( geometry ) {
 
 
-					morphColorsToFaceColors( geometry );
 					addMorph( geometry, 40, 2000, -500, FLOOR + 60, 245 );
 					addMorph( geometry, 40, 2000, -500, FLOOR + 60, 245 );
 
 
 				} );
 				} );
 
 
 				loader.load( "obj/morphs/flamingo.js", function( geometry ) {
 				loader.load( "obj/morphs/flamingo.js", function( geometry ) {
 
 
-					morphColorsToFaceColors( geometry );
 					addMorph( geometry, 500, 1000, 500 - Math.random() * 500, FLOOR + 350, 40 );
 					addMorph( geometry, 500, 1000, 500 - Math.random() * 500, FLOOR + 350, 40 );
 
 
 				} );
 				} );
 
 
 				loader.load( "obj/morphs/stork.js", function( geometry ) {
 				loader.load( "obj/morphs/stork.js", function( geometry ) {
 
 
-					morphColorsToFaceColors( geometry );
 					addMorph( geometry, 350, 1000, 500 - Math.random() * 500, FLOOR + 350, 340 );
 					addMorph( geometry, 350, 1000, 500 - Math.random() * 500, FLOOR + 350, 340 );
 
 
 				} );
 				} );
 
 
 				loader.load( "obj/morphs/mountainlion.js", function( geometry ) {
 				loader.load( "obj/morphs/mountainlion.js", function( geometry ) {
 
 
-					morphColorsToFaceColors( geometry );
 					addMorph( geometry, 400, 1000, 500 - Math.random() * 500, FLOOR - 5, 700 );
 					addMorph( geometry, 400, 1000, 500 - Math.random() * 500, FLOOR - 5, 700 );
 
 
 				} );
 				} );
 
 
 				loader.load( "obj/morphs/bearBrown.js", function( geometry ) {
 				loader.load( "obj/morphs/bearBrown.js", function( geometry ) {
 
 
-					morphColorsToFaceColors( geometry );
 					addMorph( geometry, 300, 2500, -500, FLOOR - 5, -750 );
 					addMorph( geometry, 300, 2500, -500, FLOOR - 5, -750 );
 
 
 				} );
 				} );
 
 
 				loader.load( "obj/morphs/parrot.js", function( geometry ) {
 				loader.load( "obj/morphs/parrot.js", function( geometry ) {
 
 
-					morphColorsToFaceColors( geometry );
 					addMorph( geometry, 450, 500, 500 - Math.random() * 500, FLOOR + 300, 700 );
 					addMorph( geometry, 450, 500, 500 - Math.random() * 500, FLOOR + 300, 700 );
 
 
 				} );
 				} );

+ 10 - 20
examples/webgl_shadowmap_pointlight.html

@@ -64,12 +64,9 @@
 
 
 				// Lights
 				// Lights
 
 
-				var ambient = new THREE.AmbientLight( 0x404040 );
-				scene.add( ambient );
-
 				function createLight( color ) {
 				function createLight( color ) {
 
 
-					var pointLight = new THREE.PointLight( color );
+					var pointLight = new THREE.PointLight( color, 1, 30 );
 					pointLight.castShadow = true;
 					pointLight.castShadow = true;
 					pointLight.shadowCameraNear = 1;
 					pointLight.shadowCameraNear = 1;
 					pointLight.shadowCameraFar = 30;
 					pointLight.shadowCameraFar = 30;
@@ -82,8 +79,6 @@
 					var geometry = new THREE.SphereGeometry( 0.3, 32, 32 );
 					var geometry = new THREE.SphereGeometry( 0.3, 32, 32 );
 					var material = new THREE.MeshBasicMaterial( { color: color } );
 					var material = new THREE.MeshBasicMaterial( { color: color } );
 					var sphere = new THREE.Mesh( geometry, material );
 					var sphere = new THREE.Mesh( geometry, material );
-					sphere.castShadow = false;
-					sphere.receiveShadow = false;
 					pointLight.add( sphere );
 					pointLight.add( sphere );
 
 
 					return pointLight
 					return pointLight
@@ -118,43 +113,38 @@
 
 
 				var wallGeometry = new THREE.BoxGeometry( 10, 0.15, 10 );
 				var wallGeometry = new THREE.BoxGeometry( 10, 0.15, 10 );
 				ground = new THREE.Mesh( wallGeometry, wallMaterial );
 				ground = new THREE.Mesh( wallGeometry, wallMaterial );
+				ground.position.set( 0, -5, 0 );
 				ground.scale.multiplyScalar( 3 );
 				ground.scale.multiplyScalar( 3 );
-				ground.castShadow = false;
 				ground.receiveShadow = true;
 				ground.receiveShadow = true;
 				scene.add( ground );
 				scene.add( ground );
-				ground.position.set( 0, -5, 0 );
 
 
 				var ceiling = new THREE.Mesh( wallGeometry, wallMaterial );
 				var ceiling = new THREE.Mesh( wallGeometry, wallMaterial );
+				ceiling.position.set( 0, 24, 0 );
 				ceiling.scale.multiplyScalar( 3 );
 				ceiling.scale.multiplyScalar( 3 );
-				ceiling.castShadow = false;
 				ceiling.receiveShadow = true;
 				ceiling.receiveShadow = true;
 				scene.add( ceiling );
 				scene.add( ceiling );
-				ceiling.position.set( 0, 24, 0 );
 
 
 				var wall = new THREE.Mesh( wallGeometry, wallMaterial );
 				var wall = new THREE.Mesh( wallGeometry, wallMaterial );
-				wall.scale.multiplyScalar( 3 );
-				wall.castShadow = false;
-				wall.receiveShadow = true;
-				scene.add( wall );
 				wall.position.set( -14, 10, 0 );
 				wall.position.set( -14, 10, 0 );
 				wall.rotation.z = Math.PI / 2;
 				wall.rotation.z = Math.PI / 2;
-
-				wall = new THREE.Mesh( wallGeometry, wallMaterial );
 				wall.scale.multiplyScalar( 3 );
 				wall.scale.multiplyScalar( 3 );
-				wall.castShadow = false;
 				wall.receiveShadow = true;
 				wall.receiveShadow = true;
 				scene.add( wall );
 				scene.add( wall );
-				wall.position.set(14,10,0);
-				wall.rotation.z = Math.PI / 2;
 
 
 				wall = new THREE.Mesh( wallGeometry, wallMaterial );
 				wall = new THREE.Mesh( wallGeometry, wallMaterial );
+				wall.position.set( 14, 10, 0 );
+				wall.rotation.z = Math.PI / 2;
 				wall.scale.multiplyScalar( 3 );
 				wall.scale.multiplyScalar( 3 );
-				wall.castShadow = false;
 				wall.receiveShadow = true;
 				wall.receiveShadow = true;
 				scene.add( wall );
 				scene.add( wall );
+
+				wall = new THREE.Mesh( wallGeometry, wallMaterial );
 				wall.position.set( 0, 10, -14 );
 				wall.position.set( 0, 10, -14 );
 				wall.rotation.y = Math.PI / 2;
 				wall.rotation.y = Math.PI / 2;
 				wall.rotation.z = Math.PI / 2;
 				wall.rotation.z = Math.PI / 2;
+				wall.scale.multiplyScalar( 3 );
+				wall.receiveShadow = true;
+				scene.add( wall );
 
 
 				/*
 				/*
 				wall = new THREE.Mesh( wallGeometry, wallMaterial );
 				wall = new THREE.Mesh( wallGeometry, wallMaterial );

+ 9 - 8
examples/webgl_shadowmap_viewer.html

@@ -36,11 +36,11 @@
 		<script src="js/utils/ShadowMapViewer.js"></script>
 		<script src="js/utils/ShadowMapViewer.js"></script>
 
 
 		<script src="js/Detector.js"></script>
 		<script src="js/Detector.js"></script>
-		
+
 		<script src="js/libs/stats.min.js"></script>
 		<script src="js/libs/stats.min.js"></script>
 
 
 		<script>
 		<script>
-		
+
 			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
 			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
 
 
 			var camera, scene, renderer, clock, stats;
 			var camera, scene, renderer, clock, stats;
@@ -71,22 +71,24 @@
 				scene = new THREE.Scene();
 				scene = new THREE.Scene();
 
 
 				// Lights
 				// Lights
-				var ambient = new THREE.AmbientLight( 0x404040 );
-				scene.add( ambient );
+
+				scene.add( new THREE.AmbientLight( 0x404040 ) );
 
 
 				spotLight = new THREE.SpotLight( 0xffffff );
 				spotLight = new THREE.SpotLight( 0xffffff );
+				spotLight.name = 'Spot Light';
 				spotLight.position.set( 10, 10, 5 );
 				spotLight.position.set( 10, 10, 5 );
 				spotLight.castShadow = true;
 				spotLight.castShadow = true;
 				spotLight.shadowCameraNear = 8;
 				spotLight.shadowCameraNear = 8;
 				spotLight.shadowCameraFar = 30;
 				spotLight.shadowCameraFar = 30;
 				spotLight.shadowDarkness = 0.5;
 				spotLight.shadowDarkness = 0.5;
-				spotLight.shadowCameraVisible = true;
 				spotLight.shadowMapWidth = 1024;
 				spotLight.shadowMapWidth = 1024;
 				spotLight.shadowMapHeight = 1024;
 				spotLight.shadowMapHeight = 1024;
-				spotLight.name = 'Spot Light';
 				scene.add( spotLight );
 				scene.add( spotLight );
 
 
+				scene.add( new THREE.CameraHelper( spotLight.shadow.camera ) );
+
 				dirLight = new THREE.DirectionalLight( 0xffffff, 1 );
 				dirLight = new THREE.DirectionalLight( 0xffffff, 1 );
+				dirLight.name = 'Dir. Light';
 				dirLight.position.set( 0, 10, 0 );
 				dirLight.position.set( 0, 10, 0 );
 				dirLight.castShadow = true;
 				dirLight.castShadow = true;
 				dirLight.shadowCameraNear = 1;
 				dirLight.shadowCameraNear = 1;
@@ -96,12 +98,11 @@
 				dirLight.shadowCameraTop	= 15;
 				dirLight.shadowCameraTop	= 15;
 				dirLight.shadowCameraBottom = -15;
 				dirLight.shadowCameraBottom = -15;
 				dirLight.shadowDarkness = 0.5;
 				dirLight.shadowDarkness = 0.5;
-				dirLight.shadowCameraVisible = true;
 				dirLight.shadowMapWidth = 1024;
 				dirLight.shadowMapWidth = 1024;
 				dirLight.shadowMapHeight = 1024;
 				dirLight.shadowMapHeight = 1024;
-				dirLight.name = 'Dir. Light';
 				scene.add( dirLight );
 				scene.add( dirLight );
 
 
+				scene.add( new THREE.CameraHelper( dirLight.shadow.camera ) );
 
 
 				// Geometry
 				// Geometry
 				var geometry = new THREE.TorusKnotGeometry( 25, 8, 75, 20 );
 				var geometry = new THREE.TorusKnotGeometry( 25, 8, 75, 20 );

+ 0 - 19
examples/webgl_terrain_dynamic.html

@@ -518,29 +518,12 @@
 
 
 				}
 				}
 
 
-				function morphColorsToFaceColors( geometry ) {
-
-					if ( geometry.morphColors && geometry.morphColors.length ) {
-
-						var colorMap = geometry.morphColors[ 0 ];
-
-						for ( var i = 0; i < colorMap.colors.length; i ++ ) {
-
-							geometry.faces[ i ].color = colorMap.colors[ i ];
-
-						}
-
-					}
-
-				}
-
 				var loader = new THREE.JSONLoader();
 				var loader = new THREE.JSONLoader();
 
 
 				var startX = -3000;
 				var startX = -3000;
 
 
 				loader.load( "models/animated/parrot.js", function( geometry ) {
 				loader.load( "models/animated/parrot.js", function( geometry ) {
 
 
-					morphColorsToFaceColors( geometry );
 					addMorph( geometry, 250, 0.5, startX -500, 500, 700 );
 					addMorph( geometry, 250, 0.5, startX -500, 500, 700 );
 					addMorph( geometry, 250, 0.5, startX - Math.random() * 500, 500, -200 );
 					addMorph( geometry, 250, 0.5, startX - Math.random() * 500, 500, -200 );
 					addMorph( geometry, 250, 0.5, startX - Math.random() * 500, 500, 200 );
 					addMorph( geometry, 250, 0.5, startX - Math.random() * 500, 500, 200 );
@@ -550,14 +533,12 @@
 
 
 				loader.load( "models/animated/flamingo.js", function( geometry ) {
 				loader.load( "models/animated/flamingo.js", function( geometry ) {
 
 
-					morphColorsToFaceColors( geometry );
 					addMorph( geometry, 500, 1, startX - Math.random() * 500, 350, 40 );
 					addMorph( geometry, 500, 1, startX - Math.random() * 500, 350, 40 );
 
 
 				} );
 				} );
 
 
 				loader.load( "models/animated/stork.js", function( geometry ) {
 				loader.load( "models/animated/stork.js", function( geometry ) {
 
 
-					morphColorsToFaceColors( geometry );
 					addMorph( geometry, 350, 1, startX - Math.random() * 500, 350, 340 );
 					addMorph( geometry, 350, 1, startX - Math.random() * 500, 350, 340 );
 
 
 				} );
 				} );

+ 0 - 1
src/core/Geometry.js

@@ -22,7 +22,6 @@ THREE.Geometry = function () {
 	this.faceVertexUvs = [ [] ];
 	this.faceVertexUvs = [ [] ];
 
 
 	this.morphTargets = [];
 	this.morphTargets = [];
-	this.morphColors = [];
 	this.morphNormals = [];
 	this.morphNormals = [];
 
 
 	this.skinWeights = [];
 	this.skinWeights = [];

+ 3 - 1
src/core/Object3D.js

@@ -629,7 +629,9 @@ THREE.Object3D.prototype = {
 
 
 		if ( this.name !== '' ) object.name = this.name;
 		if ( this.name !== '' ) object.name = this.name;
 		if ( JSON.stringify( this.userData ) !== '{}' ) object.userData = this.userData;
 		if ( JSON.stringify( this.userData ) !== '{}' ) object.userData = this.userData;
-		if ( this.visible !== true ) object.visible = this.visible;
+		if ( this.castShadow === true ) object.castShadow = true;
+		if ( this.receiveShadow === true ) object.receiveShadow = true;
+		if ( this.visible === false ) object.visible = false;
 
 
 		object.matrix = this.matrix.toArray();
 		object.matrix = this.matrix.toArray();
 
 

+ 127 - 127
src/extras/core/Curve.js

@@ -38,233 +38,233 @@ THREE.Curve = function () {
 
 
 };
 };
 
 
-// Virtual base class method to overwrite and implement in subclasses
-//	- t [0 .. 1]
+THREE.Curve.prototype = {
 
 
-THREE.Curve.prototype.getPoint = function ( t ) {
+	constructor: THREE.Curve,
 
 
-	console.warn( "THREE.Curve: Warning, getPoint() not implemented!" );
-	return null;
+	// Virtual base class method to overwrite and implement in subclasses
+	//	- t [0 .. 1]
 
 
-};
+	getPoint: function ( t ) {
 
 
-// Get point at relative position in curve according to arc length
-// - u [0 .. 1]
+		console.warn( "THREE.Curve: Warning, getPoint() not implemented!" );
+		return null;
 
 
-THREE.Curve.prototype.getPointAt = function ( u ) {
+	},
 
 
-	var t = this.getUtoTmapping( u );
-	return this.getPoint( t );
+	// Get point at relative position in curve according to arc length
+	// - u [0 .. 1]
 
 
-};
+	getPointAt: function ( u ) {
 
 
-// Get sequence of points using getPoint( t )
+		var t = this.getUtoTmapping( u );
+		return this.getPoint( t );
 
 
-THREE.Curve.prototype.getPoints = function ( divisions ) {
+	},
 
 
-	if ( ! divisions ) divisions = 5;
+	// Get sequence of points using getPoint( t )
 
 
-	var d, pts = [];
+	getPoints: function ( divisions ) {
 
 
-	for ( d = 0; d <= divisions; d ++ ) {
+		if ( ! divisions ) divisions = 5;
 
 
-		pts.push( this.getPoint( d / divisions ) );
+		var d, pts = [];
 
 
-	}
+		for ( d = 0; d <= divisions; d ++ ) {
 
 
-	return pts;
+			pts.push( this.getPoint( d / divisions ) );
 
 
-};
+		}
 
 
-// Get sequence of points using getPointAt( u )
+		return pts;
 
 
-THREE.Curve.prototype.getSpacedPoints = function ( divisions ) {
+	},
 
 
-	if ( ! divisions ) divisions = 5;
+	// Get sequence of points using getPointAt( u )
 
 
-	var d, pts = [];
+	getSpacedPoints: function ( divisions ) {
 
 
-	for ( d = 0; d <= divisions; d ++ ) {
+		if ( ! divisions ) divisions = 5;
 
 
-		pts.push( this.getPointAt( d / divisions ) );
+		var d, pts = [];
 
 
-	}
+		for ( d = 0; d <= divisions; d ++ ) {
 
 
-	return pts;
-
-};
+			pts.push( this.getPointAt( d / divisions ) );
 
 
-// Get total curve arc length
-
-THREE.Curve.prototype.getLength = function () {
+		}
 
 
-	var lengths = this.getLengths();
-	return lengths[ lengths.length - 1 ];
+		return pts;
 
 
-};
-
-// Get list of cumulative segment lengths
+	},
 
 
-THREE.Curve.prototype.getLengths = function ( divisions ) {
+	// Get total curve arc length
 
 
-	if ( ! divisions ) divisions = ( this.__arcLengthDivisions ) ? ( this.__arcLengthDivisions ) : 200;
+	getLength: function () {
 
 
-	if ( this.cacheArcLengths
-		&& ( this.cacheArcLengths.length === divisions + 1 )
-		&& ! this.needsUpdate ) {
+		var lengths = this.getLengths();
+		return lengths[ lengths.length - 1 ];
 
 
-		//console.log( "cached", this.cacheArcLengths );
-		return this.cacheArcLengths;
+	},
 
 
-	}
+	// Get list of cumulative segment lengths
 
 
-	this.needsUpdate = false;
+	getLengths: function ( divisions ) {
 
 
-	var cache = [];
-	var current, last = this.getPoint( 0 );
-	var p, sum = 0;
+		if ( ! divisions ) divisions = ( this.__arcLengthDivisions ) ? ( this.__arcLengthDivisions ) : 200;
 
 
-	cache.push( 0 );
+		if ( this.cacheArcLengths
+			&& ( this.cacheArcLengths.length === divisions + 1 )
+			&& ! this.needsUpdate ) {
 
 
-	for ( p = 1; p <= divisions; p ++ ) {
+			//console.log( "cached", this.cacheArcLengths );
+			return this.cacheArcLengths;
 
 
-		current = this.getPoint ( p / divisions );
-		sum += current.distanceTo( last );
-		cache.push( sum );
-		last = current;
+		}
 
 
-	}
+		this.needsUpdate = false;
 
 
-	this.cacheArcLengths = cache;
+		var cache = [];
+		var current, last = this.getPoint( 0 );
+		var p, sum = 0;
 
 
-	return cache; // { sums: cache, sum:sum }; Sum is in the last element.
+		cache.push( 0 );
 
 
-};
+		for ( p = 1; p <= divisions; p ++ ) {
 
 
+			current = this.getPoint ( p / divisions );
+			sum += current.distanceTo( last );
+			cache.push( sum );
+			last = current;
 
 
-THREE.Curve.prototype.updateArcLengths = function() {
+		}
 
 
-	this.needsUpdate = true;
-	this.getLengths();
+		this.cacheArcLengths = cache;
 
 
-};
+		return cache; // { sums: cache, sum:sum }; Sum is in the last element.
 
 
-// Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant
+	},
 
 
-THREE.Curve.prototype.getUtoTmapping = function ( u, distance ) {
+	updateArcLengths: function() {
 
 
-	var arcLengths = this.getLengths();
+		this.needsUpdate = true;
+		this.getLengths();
 
 
-	var i = 0, il = arcLengths.length;
+	},
 
 
-	var targetArcLength; // The targeted u distance value to get
+	// Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant
 
 
-	if ( distance ) {
+	getUtoTmapping: function ( u, distance ) {
 
 
-		targetArcLength = distance;
+		var arcLengths = this.getLengths();
 
 
-	} else {
+		var i = 0, il = arcLengths.length;
 
 
-		targetArcLength = u * arcLengths[ il - 1 ];
+		var targetArcLength; // The targeted u distance value to get
 
 
-	}
+		if ( distance ) {
 
 
-	//var time = Date.now();
+			targetArcLength = distance;
 
 
-	// binary search for the index with largest value smaller than target u distance
+		} else {
 
 
-	var low = 0, high = il - 1, comparison;
+			targetArcLength = u * arcLengths[ il - 1 ];
 
 
-	while ( low <= high ) {
+		}
 
 
-		i = Math.floor( low + ( high - low ) / 2 ); // less likely to overflow, though probably not issue here, JS doesn't really have integers, all numbers are floats
+		//var time = Date.now();
 
 
-		comparison = arcLengths[ i ] - targetArcLength;
+		// binary search for the index with largest value smaller than target u distance
 
 
-		if ( comparison < 0 ) {
+		var low = 0, high = il - 1, comparison;
 
 
-			low = i + 1;
+		while ( low <= high ) {
 
 
-		} else if ( comparison > 0 ) {
+			i = Math.floor( low + ( high - low ) / 2 ); // less likely to overflow, though probably not issue here, JS doesn't really have integers, all numbers are floats
 
 
-			high = i - 1;
+			comparison = arcLengths[ i ] - targetArcLength;
 
 
-		} else {
+			if ( comparison < 0 ) {
 
 
-			high = i;
-			break;
+				low = i + 1;
 
 
-			// DONE
+			} else if ( comparison > 0 ) {
 
 
-		}
+				high = i - 1;
 
 
-	}
+			} else {
 
 
-	i = high;
+				high = i;
+				break;
 
 
-	//console.log('b' , i, low, high, Date.now()- time);
+				// DONE
 
 
-	if ( arcLengths[ i ] === targetArcLength ) {
+			}
 
 
-		var t = i / ( il - 1 );
-		return t;
+		}
 
 
-	}
+		i = high;
 
 
-	// we could get finer grain at lengths, or use simple interpolation between two points
+		//console.log('b' , i, low, high, Date.now()- time);
 
 
-	var lengthBefore = arcLengths[ i ];
-	var lengthAfter = arcLengths[ i + 1 ];
+		if ( arcLengths[ i ] === targetArcLength ) {
 
 
-	var segmentLength = lengthAfter - lengthBefore;
+			var t = i / ( il - 1 );
+			return t;
 
 
-	// determine where we are between the 'before' and 'after' points
+		}
 
 
-	var segmentFraction = ( targetArcLength - lengthBefore ) / segmentLength;
+		// we could get finer grain at lengths, or use simple interpolation between two points
 
 
-	// add that fractional amount to t
+		var lengthBefore = arcLengths[ i ];
+		var lengthAfter = arcLengths[ i + 1 ];
 
 
-	var t = ( i + segmentFraction ) / ( il - 1 );
+		var segmentLength = lengthAfter - lengthBefore;
 
 
-	return t;
+		// determine where we are between the 'before' and 'after' points
 
 
-};
+		var segmentFraction = ( targetArcLength - lengthBefore ) / segmentLength;
 
 
-// Returns a unit vector tangent at t
-// In case any sub curve does not implement its tangent derivation,
-// 2 points a small delta apart will be used to find its gradient
-// which seems to give a reasonable approximation
+		// add that fractional amount to t
 
 
-THREE.Curve.prototype.getTangent = function( t ) {
+		var t = ( i + segmentFraction ) / ( il - 1 );
 
 
-	var delta = 0.0001;
-	var t1 = t - delta;
-	var t2 = t + delta;
+		return t;
 
 
-	// Capping in case of danger
+	},
 
 
-	if ( t1 < 0 ) t1 = 0;
-	if ( t2 > 1 ) t2 = 1;
+	// Returns a unit vector tangent at t
+	// In case any sub curve does not implement its tangent derivation,
+	// 2 points a small delta apart will be used to find its gradient
+	// which seems to give a reasonable approximation
 
 
-	var pt1 = this.getPoint( t1 );
-	var pt2 = this.getPoint( t2 );
+	getTangent: function( t ) {
 
 
-	var vec = pt2.clone().sub( pt1 );
-	return vec.normalize();
+		var delta = 0.0001;
+		var t1 = t - delta;
+		var t2 = t + delta;
 
 
-};
+		// Capping in case of danger
 
 
+		if ( t1 < 0 ) t1 = 0;
+		if ( t2 > 1 ) t2 = 1;
 
 
-THREE.Curve.prototype.getTangentAt = function ( u ) {
+		var pt1 = this.getPoint( t1 );
+		var pt2 = this.getPoint( t2 );
 
 
-	var t = this.getUtoTmapping( u );
-	return this.getTangent( t );
+		var vec = pt2.clone().sub( pt1 );
+		return vec.normalize();
 
 
-};
+	},
 
 
+	getTangentAt: function ( u ) {
 
 
+		var t = this.getUtoTmapping( u );
+		return this.getTangent( t );
 
 
+	}
 
 
+}
 
 
 /**************************************************************
 /**************************************************************
  *	Utils
  *	Utils

+ 21 - 26
src/extras/core/CurvePath.js

@@ -26,11 +26,13 @@ THREE.CurvePath.prototype.add = function ( curve ) {
 
 
 };
 };
 
 
+/*
 THREE.CurvePath.prototype.checkConnection = function() {
 THREE.CurvePath.prototype.checkConnection = function() {
 	// TODO
 	// TODO
 	// If the ending of curve is not connected to the starting
 	// If the ending of curve is not connected to the starting
 	// or the next curve, then, this is not a real path
 	// or the next curve, then, this is not a real path
 };
 };
+*/
 
 
 THREE.CurvePath.prototype.closePath = function() {
 THREE.CurvePath.prototype.closePath = function() {
 
 
@@ -61,7 +63,7 @@ THREE.CurvePath.prototype.getPoint = function( t ) {
 
 
 	var d = t * this.getLength();
 	var d = t * this.getLength();
 	var curveLengths = this.getCurveLengths();
 	var curveLengths = this.getCurveLengths();
-	var i = 0, diff, curve;
+	var i = 0;
 
 
 	// To think about boundaries points.
 	// To think about boundaries points.
 
 
@@ -69,8 +71,8 @@ THREE.CurvePath.prototype.getPoint = function( t ) {
 
 
 		if ( curveLengths[ i ] >= d ) {
 		if ( curveLengths[ i ] >= d ) {
 
 
-			diff = curveLengths[ i ] - d;
-			curve = this.curves[ i ];
+			var diff = curveLengths[ i ] - d;
+			var curve = this.curves[ i ];
 
 
 			var u = 1 - diff / curve.getLength();
 			var u = 1 - diff / curve.getLength();
 
 
@@ -90,8 +92,8 @@ THREE.CurvePath.prototype.getPoint = function( t ) {
 
 
 /*
 /*
 THREE.CurvePath.prototype.getTangent = function( t ) {
 THREE.CurvePath.prototype.getTangent = function( t ) {
-};*/
-
+};
+*/
 
 
 // We cannot use the default THREE.Curve getPoint() with getLength() because in
 // We cannot use the default THREE.Curve getPoint() with getLength() because in
 // THREE.Curve, getLength() depends on getPoint() but in THREE.CurvePath
 // THREE.Curve, getLength() depends on getPoint() but in THREE.CurvePath
@@ -121,9 +123,8 @@ THREE.CurvePath.prototype.getCurveLengths = function() {
 	// Push sums into cached array
 	// Push sums into cached array
 
 
 	var lengths = [], sums = 0;
 	var lengths = [], sums = 0;
-	var i, il = this.curves.length;
 
 
-	for ( i = 0; i < il; i ++ ) {
+	for ( var i = 0, l = this.curves.length; i < l; i ++ ) {
 
 
 		sums += this.curves[ i ].getLength();
 		sums += this.curves[ i ].getLength();
 		lengths.push( sums );
 		lengths.push( sums );
@@ -150,15 +151,13 @@ THREE.CurvePath.prototype.getBoundingBox = function () {
 	maxX = maxY = Number.NEGATIVE_INFINITY;
 	maxX = maxY = Number.NEGATIVE_INFINITY;
 	minX = minY = Number.POSITIVE_INFINITY;
 	minX = minY = Number.POSITIVE_INFINITY;
 
 
-	var p, i, il, sum;
-
 	var v3 = points[ 0 ] instanceof THREE.Vector3;
 	var v3 = points[ 0 ] instanceof THREE.Vector3;
 
 
-	sum = v3 ? new THREE.Vector3() : new THREE.Vector2();
+	var sum = v3 ? new THREE.Vector3() : new THREE.Vector2();
 
 
-	for ( i = 0, il = points.length; i < il; i ++ ) {
+	for ( var i = 0, l = points.length; i < l; i ++ ) {
 
 
-		p = points[ i ];
+		var p = points[ i ];
 
 
 		if ( p.x > maxX ) maxX = p.x;
 		if ( p.x > maxX ) maxX = p.x;
 		else if ( p.x < minX ) minX = p.x;
 		else if ( p.x < minX ) minX = p.x;
@@ -223,9 +222,10 @@ THREE.CurvePath.prototype.createGeometry = function( points ) {
 
 
 	var geometry = new THREE.Geometry();
 	var geometry = new THREE.Geometry();
 
 
-	for ( var i = 0; i < points.length; i ++ ) {
+	for ( var i = 0, l = points.length; i < l; i ++ ) {
 
 
-		geometry.vertices.push( new THREE.Vector3( points[ i ].x, points[ i ].y, points[ i ].z || 0 ) );
+		var point = points[ i ];
+		geometry.vertices.push( new THREE.Vector3( point.x, point.y, point.z || 0 ) );
 
 
 	}
 	}
 
 
@@ -249,7 +249,6 @@ THREE.CurvePath.prototype.addWrapPath = function ( bendpath ) {
 THREE.CurvePath.prototype.getTransformedPoints = function( segments, bends ) {
 THREE.CurvePath.prototype.getTransformedPoints = function( segments, bends ) {
 
 
 	var oldPts = this.getPoints( segments ); // getPoints getSpacedPoints
 	var oldPts = this.getPoints( segments ); // getPoints getSpacedPoints
-	var i, il;
 
 
 	if ( ! bends ) {
 	if ( ! bends ) {
 
 
@@ -257,7 +256,7 @@ THREE.CurvePath.prototype.getTransformedPoints = function( segments, bends ) {
 
 
 	}
 	}
 
 
-	for ( i = 0, il = bends.length; i < il; i ++ ) {
+	for ( var i = 0, l = bends.length; i < l; i ++ ) {
 
 
 		oldPts = this.getWrapPoints( oldPts, bends[ i ] );
 		oldPts = this.getWrapPoints( oldPts, bends[ i ] );
 
 
@@ -271,15 +270,13 @@ THREE.CurvePath.prototype.getTransformedSpacedPoints = function( segments, bends
 
 
 	var oldPts = this.getSpacedPoints( segments );
 	var oldPts = this.getSpacedPoints( segments );
 
 
-	var i, il;
-
 	if ( ! bends ) {
 	if ( ! bends ) {
 
 
 		bends = this.bends;
 		bends = this.bends;
 
 
 	}
 	}
 
 
-	for ( i = 0, il = bends.length; i < il; i ++ ) {
+	for ( var i = 0, l = bends.length; i < l; i ++ ) {
 
 
 		oldPts = this.getWrapPoints( oldPts, bends[ i ] );
 		oldPts = this.getWrapPoints( oldPts, bends[ i ] );
 
 
@@ -296,16 +293,14 @@ THREE.CurvePath.prototype.getWrapPoints = function ( oldPts, path ) {
 
 
 	var bounds = this.getBoundingBox();
 	var bounds = this.getBoundingBox();
 
 
-	var i, il, p, oldX, oldY, xNorm;
-
-	for ( i = 0, il = oldPts.length; i < il; i ++ ) {
+	for ( var i = 0, l = oldPts.length; i < l; i ++ ) {
 
 
-		p = oldPts[ i ];
+		var p = oldPts[ i ];
 
 
-		oldX = p.x;
-		oldY = p.y;
+		var oldX = p.x;
+		var oldY = p.y;
 
 
-		xNorm = oldX / bounds.maxX;
+		var xNorm = oldX / bounds.maxX;
 
 
 		// If using actual distance, for length > path, requires line extrusions
 		// If using actual distance, for length > path, requires line extrusions
 		//xNorm = path.getUtoTmapping(xNorm, oldX); // 3 styles. 1) wrap stretched. 2) wrap stretch by arc length 3) warp by actual distance
 		//xNorm = path.getUtoTmapping(xNorm, oldX); // 3 styles. 1) wrap stretched. 2) wrap stretch by arc length 3) warp by actual distance

+ 53 - 56
src/extras/core/Path.js

@@ -22,7 +22,6 @@ THREE.Path.prototype = Object.create( THREE.CurvePath.prototype );
 THREE.Path.prototype.constructor = THREE.Path;
 THREE.Path.prototype.constructor = THREE.Path;
 
 
 THREE.PathActions = {
 THREE.PathActions = {
-
 	MOVE_TO: 'moveTo',
 	MOVE_TO: 'moveTo',
 	LINE_TO: 'lineTo',
 	LINE_TO: 'lineTo',
 	QUADRATIC_CURVE_TO: 'quadraticCurveTo', // Bezier quadratic curve
 	QUADRATIC_CURVE_TO: 'quadraticCurveTo', // Bezier quadratic curve
@@ -41,9 +40,9 @@ THREE.Path.prototype.fromPoints = function ( vectors ) {
 
 
 	this.moveTo( vectors[ 0 ].x, vectors[ 0 ].y );
 	this.moveTo( vectors[ 0 ].x, vectors[ 0 ].y );
 
 
-	for ( var v = 1, vlen = vectors.length; v < vlen; v ++ ) {
+	for ( var i = 1, l = vectors.length; i < l; i ++ ) {
 
 
-		this.lineTo( vectors[ v ].x, vectors[ v ].y );
+		this.lineTo( vectors[ i ].x, vectors[ i ].y );
 
 
 	}
 	}
 
 
@@ -83,18 +82,19 @@ THREE.Path.prototype.quadraticCurveTo = function( aCPx, aCPy, aX, aY ) {
 	var x0 = lastargs[ lastargs.length - 2 ];
 	var x0 = lastargs[ lastargs.length - 2 ];
 	var y0 = lastargs[ lastargs.length - 1 ];
 	var y0 = lastargs[ lastargs.length - 1 ];
 
 
-	var curve = new THREE.QuadraticBezierCurve( new THREE.Vector2( x0, y0 ),
-												new THREE.Vector2( aCPx, aCPy ),
-												new THREE.Vector2( aX, aY ) );
+	var curve = new THREE.QuadraticBezierCurve(
+		new THREE.Vector2( x0, y0 ),
+		new THREE.Vector2( aCPx, aCPy ),
+		new THREE.Vector2( aX, aY )
+	);
+
 	this.curves.push( curve );
 	this.curves.push( curve );
 
 
 	this.actions.push( { action: THREE.PathActions.QUADRATIC_CURVE_TO, args: args } );
 	this.actions.push( { action: THREE.PathActions.QUADRATIC_CURVE_TO, args: args } );
 
 
 };
 };
 
 
-THREE.Path.prototype.bezierCurveTo = function( aCP1x, aCP1y,
-											   aCP2x, aCP2y,
-											   aX, aY ) {
+THREE.Path.prototype.bezierCurveTo = function( aCP1x, aCP1y, aCP2x, aCP2y, aX, aY ) {
 
 
 	var args = Array.prototype.slice.call( arguments );
 	var args = Array.prototype.slice.call( arguments );
 
 
@@ -103,10 +103,13 @@ THREE.Path.prototype.bezierCurveTo = function( aCP1x, aCP1y,
 	var x0 = lastargs[ lastargs.length - 2 ];
 	var x0 = lastargs[ lastargs.length - 2 ];
 	var y0 = lastargs[ lastargs.length - 1 ];
 	var y0 = lastargs[ lastargs.length - 1 ];
 
 
-	var curve = new THREE.CubicBezierCurve( new THREE.Vector2( x0, y0 ),
-											new THREE.Vector2( aCP1x, aCP1y ),
-											new THREE.Vector2( aCP2x, aCP2y ),
-											new THREE.Vector2( aX, aY ) );
+	var curve = new THREE.CubicBezierCurve(
+		new THREE.Vector2( x0, y0 ),
+		new THREE.Vector2( aCP1x, aCP1y ),
+		new THREE.Vector2( aCP2x, aCP2y ),
+		new THREE.Vector2( aX, aY )
+	);
+
 	this.curves.push( curve );
 	this.curves.push( curve );
 
 
 	this.actions.push( { action: THREE.PathActions.BEZIER_CURVE_TO, args: args } );
 	this.actions.push( { action: THREE.PathActions.BEZIER_CURVE_TO, args: args } );
@@ -120,7 +123,7 @@ THREE.Path.prototype.splineThru = function( pts /*Array of Vector*/ ) {
 
 
 	var x0 = lastargs[ lastargs.length - 2 ];
 	var x0 = lastargs[ lastargs.length - 2 ];
 	var y0 = lastargs[ lastargs.length - 1 ];
 	var y0 = lastargs[ lastargs.length - 1 ];
-	//---
+
 	var npts = [ new THREE.Vector2( x0, y0 ) ];
 	var npts = [ new THREE.Vector2( x0, y0 ) ];
 	Array.prototype.push.apply( npts, pts );
 	Array.prototype.push.apply( npts, pts );
 
 
@@ -133,8 +136,7 @@ THREE.Path.prototype.splineThru = function( pts /*Array of Vector*/ ) {
 
 
 // FUTURE: Change the API or follow canvas API?
 // FUTURE: Change the API or follow canvas API?
 
 
-THREE.Path.prototype.arc = function ( aX, aY, aRadius,
-									  aStartAngle, aEndAngle, aClockwise ) {
+THREE.Path.prototype.arc = function ( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) {
 
 
 	var lastargs = this.actions[ this.actions.length - 1 ].args;
 	var lastargs = this.actions[ this.actions.length - 1 ].args;
 	var x0 = lastargs[ lastargs.length - 2 ];
 	var x0 = lastargs[ lastargs.length - 2 ];
@@ -145,28 +147,24 @@ THREE.Path.prototype.arc = function ( aX, aY, aRadius,
 
 
  };
  };
 
 
- THREE.Path.prototype.absarc = function ( aX, aY, aRadius,
-									  aStartAngle, aEndAngle, aClockwise ) {
+ THREE.Path.prototype.absarc = function ( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) {
 
 
 	this.absellipse( aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise );
 	this.absellipse( aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise );
 
 
  };
  };
 
 
-THREE.Path.prototype.ellipse = function ( aX, aY, xRadius, yRadius,
-									  aStartAngle, aEndAngle, aClockwise, aRotation ) {
+THREE.Path.prototype.ellipse = function ( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ) {
 
 
 	var lastargs = this.actions[ this.actions.length - 1 ].args;
 	var lastargs = this.actions[ this.actions.length - 1 ].args;
 	var x0 = lastargs[ lastargs.length - 2 ];
 	var x0 = lastargs[ lastargs.length - 2 ];
 	var y0 = lastargs[ lastargs.length - 1 ];
 	var y0 = lastargs[ lastargs.length - 1 ];
 
 
-	this.absellipse( aX + x0, aY + y0, xRadius, yRadius,
-		aStartAngle, aEndAngle, aClockwise, aRotation );
+	this.absellipse( aX + x0, aY + y0, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation );
 
 
  };
  };
 
 
 
 
-THREE.Path.prototype.absellipse = function ( aX, aY, xRadius, yRadius,
-									  aStartAngle, aEndAngle, aClockwise, aRotation ) {
+THREE.Path.prototype.absellipse = function ( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ) {
 
 
 	var args = [
 	var args = [
 		aX, aY,
 		aX, aY,
@@ -175,8 +173,8 @@ THREE.Path.prototype.absellipse = function ( aX, aY, xRadius, yRadius,
 		aClockwise,
 		aClockwise,
 		aRotation || 0 // aRotation is optional.
 		aRotation || 0 // aRotation is optional.
 	];
 	];
-	var curve = new THREE.EllipseCurve( aX, aY, xRadius, yRadius,
-									aStartAngle, aEndAngle, aClockwise, aRotation );
+
+	var curve = new THREE.EllipseCurve( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation );
 	this.curves.push( curve );
 	this.curves.push( curve );
 
 
 	var lastPoint = curve.getPoint( 1 );
 	var lastPoint = curve.getPoint( 1 );
@@ -225,17 +223,15 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
 
 
 	var points = [];
 	var points = [];
 
 
-	var i, il, item, action, args;
 	var cpx, cpy, cpx2, cpy2, cpx1, cpy1, cpx0, cpy0,
 	var cpx, cpy, cpx2, cpy2, cpx1, cpy1, cpx0, cpy0,
-		laste, j,
-		t, tx, ty;
+		laste, tx, ty;
 
 
-	for ( i = 0, il = this.actions.length; i < il; i ++ ) {
+	for ( var i = 0, l = this.actions.length; i < l; i ++ ) {
 
 
-		item = this.actions[ i ];
+		var item = this.actions[ i ];
 
 
-		action = item.action;
-		args = item.args;
+		var action = item.action;
+		var args = item.args;
 
 
 		switch ( action ) {
 		switch ( action ) {
 
 
@@ -275,9 +271,9 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
 
 
 			}
 			}
 
 
-			for ( j = 1; j <= divisions; j ++ ) {
+			for ( var j = 1; j <= divisions; j ++ ) {
 
 
-				t = j / divisions;
+				var t = j / divisions;
 
 
 				tx = THREE.Shape.Utils.b2( t, cpx0, cpx1, cpx );
 				tx = THREE.Shape.Utils.b2( t, cpx0, cpx1, cpx );
 				ty = THREE.Shape.Utils.b2( t, cpy0, cpy1, cpy );
 				ty = THREE.Shape.Utils.b2( t, cpy0, cpy1, cpy );
@@ -316,9 +312,9 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
 			}
 			}
 
 
 
 
-			for ( j = 1; j <= divisions; j ++ ) {
+			for ( var j = 1; j <= divisions; j ++ ) {
 
 
-				t = j / divisions;
+				var t = j / divisions;
 
 
 				tx = THREE.Shape.Utils.b3( t, cpx0, cpx1, cpx2, cpx );
 				tx = THREE.Shape.Utils.b3( t, cpx0, cpx1, cpx2, cpx );
 				ty = THREE.Shape.Utils.b3( t, cpy0, cpy1, cpy2, cpy );
 				ty = THREE.Shape.Utils.b3( t, cpy0, cpy1, cpy2, cpy );
@@ -342,7 +338,7 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
 
 
 			var spline = new THREE.SplineCurve( spts );
 			var spline = new THREE.SplineCurve( spts );
 
 
-			for ( j = 1; j <= n; j ++ ) {
+			for ( var j = 1; j <= n; j ++ ) {
 
 
 				points.push( spline.getPointAt( j / n ) );
 				points.push( spline.getPointAt( j / n ) );
 
 
@@ -361,9 +357,9 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
 			var angle;
 			var angle;
 			var tdivisions = divisions * 2;
 			var tdivisions = divisions * 2;
 
 
-			for ( j = 1; j <= tdivisions; j ++ ) {
+			for ( var j = 1; j <= tdivisions; j ++ ) {
 
 
-				t = j / tdivisions;
+				var t = j / tdivisions;
 
 
 				if ( ! aClockwise ) {
 				if ( ! aClockwise ) {
 
 
@@ -402,15 +398,15 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
 
 
 			var cos, sin;
 			var cos, sin;
 			if ( aRotation !== 0 ) {
 			if ( aRotation !== 0 ) {
-		
+
 				cos = Math.cos( aRotation );
 				cos = Math.cos( aRotation );
 				sin = Math.sin( aRotation );
 				sin = Math.sin( aRotation );
 
 
 			}
 			}
 
 
-			for ( j = 1; j <= tdivisions; j ++ ) {
+			for ( var j = 1; j <= tdivisions; j ++ ) {
 
 
-				t = j / tdivisions;
+				var t = j / tdivisions;
 
 
 				if ( ! aClockwise ) {
 				if ( ! aClockwise ) {
 
 
@@ -481,16 +477,14 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) {
 
 
 	function extractSubpaths( inActions ) {
 	function extractSubpaths( inActions ) {
 
 
-		var i, il, item, action, args;
-
 		var subPaths = [], lastPath = new THREE.Path();
 		var subPaths = [], lastPath = new THREE.Path();
 
 
-		for ( i = 0, il = inActions.length; i < il; i ++ ) {
+		for ( var i = 0, l = inActions.length; i < l; i ++ ) {
 
 
-			item = inActions[ i ];
+			var item = inActions[ i ];
 
 
-			args = item.args;
-			action = item.action;
+			var args = item.args;
+			var action = item.action;
 
 
 			if ( action === THREE.PathActions.MOVE_TO ) {
 			if ( action === THREE.PathActions.MOVE_TO ) {
 
 
@@ -523,7 +517,7 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) {
 
 
 		var shapes = [];
 		var shapes = [];
 
 
-		for ( var i = 0, il = inSubpaths.length; i < il; i ++ ) {
+		for ( var i = 0, l = inSubpaths.length; i < l; i ++ ) {
 
 
 			var tmpPath = inSubpaths[ i ];
 			var tmpPath = inSubpaths[ i ];
 
 
@@ -636,9 +630,7 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) {
 	newShapes[ mainIdx ] = undefined;
 	newShapes[ mainIdx ] = undefined;
 	newShapeHoles[ mainIdx ] = [];
 	newShapeHoles[ mainIdx ] = [];
 
 
-	var i, il;
-
-	for ( i = 0, il = subPaths.length; i < il; i ++ ) {
+	for ( var i = 0, l = subPaths.length; i < l; i ++ ) {
 
 
 		tmpPath = subPaths[ i ];
 		tmpPath = subPaths[ i ];
 		tmpPoints = tmpPath.getPoints();
 		tmpPoints = tmpPath.getPoints();
@@ -682,13 +674,16 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) {
 			betterShapeHoles[ sIdx ] = [];
 			betterShapeHoles[ sIdx ] = [];
 
 
 		}
 		}
+
 		for ( var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx ++ ) {
 		for ( var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx ++ ) {
 
 
 			var sho = newShapeHoles[ sIdx ];
 			var sho = newShapeHoles[ sIdx ];
+
 			for ( var hIdx = 0; hIdx < sho.length; hIdx ++ ) {
 			for ( var hIdx = 0; hIdx < sho.length; hIdx ++ ) {
 
 
 				var ho = sho[ hIdx ];
 				var ho = sho[ hIdx ];
 				var hole_unassigned = true;
 				var hole_unassigned = true;
+
 				for ( var s2Idx = 0; s2Idx < newShapes.length; s2Idx ++ ) {
 				for ( var s2Idx = 0; s2Idx < newShapes.length; s2Idx ++ ) {
 
 
 					if ( isPointInsidePolygon( ho.p, newShapes[ s2Idx ].p ) ) {
 					if ( isPointInsidePolygon( ho.p, newShapes[ s2Idx ].p ) ) {
@@ -727,13 +722,15 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) {
 
 
 	}
 	}
 
 
-	var tmpHoles, j, jl;
-	for ( i = 0, il = newShapes.length; i < il; i ++ ) {
+	var tmpHoles;
+
+	for ( var i = 0, il = newShapes.length; i < il; i ++ ) {
 
 
 		tmpShape = newShapes[ i ].s;
 		tmpShape = newShapes[ i ].s;
 		shapes.push( tmpShape );
 		shapes.push( tmpShape );
 		tmpHoles = newShapeHoles[ i ];
 		tmpHoles = newShapeHoles[ i ];
-		for ( j = 0, jl = tmpHoles.length; j < jl; j ++ ) {
+
+		for ( var j = 0, jl = tmpHoles.length; j < jl; j ++ ) {
 
 
 			tmpShape.holes.push( tmpHoles[ j ].h );
 			tmpShape.holes.push( tmpHoles[ j ].h );
 
 

+ 19 - 19
src/extras/core/Shape.js

@@ -12,6 +12,7 @@
 THREE.Shape = function () {
 THREE.Shape = function () {
 
 
 	THREE.Path.apply( this, arguments );
 	THREE.Path.apply( this, arguments );
+
 	this.holes = [];
 	this.holes = [];
 
 
 };
 };
@@ -23,8 +24,7 @@ THREE.Shape.prototype.constructor = THREE.Shape;
 
 
 THREE.Shape.prototype.extrude = function ( options ) {
 THREE.Shape.prototype.extrude = function ( options ) {
 
 
-	var extruded = new THREE.ExtrudeGeometry( this, options );
-	return extruded;
+	return new THREE.ExtrudeGeometry( this, options );
 
 
 };
 };
 
 
@@ -32,8 +32,7 @@ THREE.Shape.prototype.extrude = function ( options ) {
 
 
 THREE.Shape.prototype.makeGeometry = function ( options ) {
 THREE.Shape.prototype.makeGeometry = function ( options ) {
 
 
-	var geometry = new THREE.ShapeGeometry( this, options );
-	return geometry;
+	return new THREE.ShapeGeometry( this, options );
 
 
 };
 };
 
 
@@ -41,9 +40,9 @@ THREE.Shape.prototype.makeGeometry = function ( options ) {
 
 
 THREE.Shape.prototype.getPointsHoles = function ( divisions ) {
 THREE.Shape.prototype.getPointsHoles = function ( divisions ) {
 
 
-	var i, il = this.holes.length, holesPts = [];
+	var holesPts = [];
 
 
-	for ( i = 0; i < il; i ++ ) {
+	for ( var i = 0, l = this.holes.length; i < l; i ++ ) {
 
 
 		holesPts[ i ] = this.holes[ i ].getTransformedPoints( divisions, this.bends );
 		holesPts[ i ] = this.holes[ i ].getTransformedPoints( divisions, this.bends );
 
 
@@ -57,9 +56,9 @@ THREE.Shape.prototype.getPointsHoles = function ( divisions ) {
 
 
 THREE.Shape.prototype.getSpacedPointsHoles = function ( divisions ) {
 THREE.Shape.prototype.getSpacedPointsHoles = function ( divisions ) {
 
 
-	var i, il = this.holes.length, holesPts = [];
+	var holesPts = [];
 
 
-	for ( i = 0; i < il; i ++ ) {
+	for ( var i = 0, l = this.holes.length; i < l; i ++ ) {
 
 
 		holesPts[ i ] = this.holes[ i ].getTransformedSpacedPoints( divisions, this.bends );
 		holesPts[ i ] = this.holes[ i ].getTransformedSpacedPoints( divisions, this.bends );
 
 
@@ -95,17 +94,18 @@ THREE.Shape.prototype.extractPoints = function ( divisions ) {
 
 
 };
 };
 
 
-//
-// THREE.Shape.prototype.extractAllPointsWithBend = function ( divisions, bend ) {
-//
-// 	return {
-//
-// 		shape: this.transform( bend, divisions ),
-// 		holes: this.getPointsHoles( divisions, bend )
-//
-// 	};
-//
-// };
+/*
+THREE.Shape.prototype.extractAllPointsWithBend = function ( divisions, bend ) {
+
+	return {
+
+		shape: this.transform( bend, divisions ),
+		holes: this.getPointsHoles( divisions, bend )
+
+	};
+
+};
+*/
 
 
 // Get points of shape and holes (spaced by regular distance)
 // Get points of shape and holes (spaced by regular distance)
 
 

+ 9 - 9
src/extras/geometries/BoxGeometry.js

@@ -128,17 +128,17 @@ THREE.BoxGeometry.prototype.constructor = THREE.BoxGeometry;
 
 
 THREE.BoxGeometry.prototype.clone = function () {
 THREE.BoxGeometry.prototype.clone = function () {
 
 
-	var geometry = new THREE.BoxGeometry(
-		this.parameters.width,
-		this.parameters.height,
-		this.parameters.depth,
-		this.parameters.widthSegments,
-		this.parameters.heightSegments,
-		this.parameters.depthSegments
+	var parameters = this.parameters;
+
+	return new THREE.BoxGeometry(
+		parameters.width,
+		parameters.height,
+		parameters.depth,
+		parameters.widthSegments,
+		parameters.heightSegments,
+		parameters.depthSegments
 	);
 	);
 
 
-	return geometry;
-
 };
 };
 
 
 THREE.CubeGeometry = THREE.BoxGeometry; // backwards compatibility
 THREE.CubeGeometry = THREE.BoxGeometry; // backwards compatibility

+ 8 - 12
src/extras/geometries/CircleBufferGeometry.js

@@ -50,9 +50,7 @@ THREE.CircleBufferGeometry = function ( radius, segments, thetaStart, thetaLengt
 
 
 	for ( var i = 1; i <= segments; i ++ ) {
 	for ( var i = 1; i <= segments; i ++ ) {
 
 
-		indices.push( i );
-		indices.push( i + 1 );
-		indices.push( 0 );
+		indices.push( i, i + 1, 0 );
 
 
 	}
 	}
 
 
@@ -70,15 +68,13 @@ THREE.CircleBufferGeometry.prototype.constructor = THREE.CircleBufferGeometry;
 
 
 THREE.CircleBufferGeometry.prototype.clone = function () {
 THREE.CircleBufferGeometry.prototype.clone = function () {
 
 
-	var geometry = new THREE.CircleBufferGeometry(
-		this.parameters.radius,
-		this.parameters.segments,
-		this.parameters.thetaStart,
-		this.parameters.thetaLength
-	);
-
-	geometry.copy( this );
+	var parameters = this.parameters;
 
 
-	return geometry;
+	return new THREE.CircleBufferGeometry(
+		parameters.radius,
+		parameters.segments,
+		parameters.thetaStart,
+		parameters.thetaLength
+	);
 
 
 };
 };

+ 8 - 44
src/extras/geometries/CircleGeometry.js

@@ -15,43 +15,7 @@ THREE.CircleGeometry = function ( radius, segments, thetaStart, thetaLength ) {
 		thetaLength: thetaLength
 		thetaLength: thetaLength
 	};
 	};
 
 
-	radius = radius || 50;
-	segments = segments !== undefined ? Math.max( 3, segments ) : 8;
-
-	thetaStart = thetaStart !== undefined ? thetaStart : 0;
-	thetaLength = thetaLength !== undefined ? thetaLength : Math.PI * 2;
-
-	var i, uvs = [],
-	center = new THREE.Vector3(), centerUV = new THREE.Vector2( 0.5, 0.5 );
-
-	this.vertices.push( center );
-	uvs.push( centerUV );
-
-	for ( i = 0; i <= segments; i ++ ) {
-
-		var vertex = new THREE.Vector3();
-		var segment = thetaStart + i / segments * thetaLength;
-
-		vertex.x = radius * Math.cos( segment );
-		vertex.y = radius * Math.sin( segment );
-
-		this.vertices.push( vertex );
-		uvs.push( new THREE.Vector2( ( vertex.x / radius + 1 ) / 2, ( vertex.y / radius + 1 ) / 2 ) );
-
-	}
-
-	var n = new THREE.Vector3( 0, 0, 1 );
-
-	for ( i = 1; i <= segments; i ++ ) {
-
-		this.faces.push( new THREE.Face3( i, i + 1, 0, [ n.clone(), n.clone(), n.clone() ] ) );
-		this.faceVertexUvs[ 0 ].push( [ uvs[ i ].clone(), uvs[ i + 1 ].clone(), centerUV.clone() ] );
-
-	}
-
-	this.computeFaceNormals();
-
-	this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius );
+	this.fromBufferGeometry( new THREE.CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) );
 
 
 };
 };
 
 
@@ -60,13 +24,13 @@ THREE.CircleGeometry.prototype.constructor = THREE.CircleGeometry;
 
 
 THREE.CircleGeometry.prototype.clone = function () {
 THREE.CircleGeometry.prototype.clone = function () {
 
 
-	var geometry = new THREE.CircleGeometry(
-		this.parameters.radius,
-		this.parameters.segments,
-		this.parameters.thetaStart,
-		this.parameters.thetaLength
-	);
+	var parameters = this.parameters;
 
 
-	return geometry;
+	return new THREE.CircleGeometry(
+		parameters.radius,
+		parameters.segments,
+		parameters.thetaStart,
+		parameters.thetaLength
+	);
 
 
 };
 };

+ 11 - 11
src/extras/geometries/CylinderGeometry.js

@@ -173,17 +173,17 @@ THREE.CylinderGeometry.prototype.constructor = THREE.CylinderGeometry;
 
 
 THREE.CylinderGeometry.prototype.clone = function () {
 THREE.CylinderGeometry.prototype.clone = function () {
 
 
-	var geometry = new THREE.CylinderGeometry(
-		this.parameters.radiusTop,
-		this.parameters.radiusBottom,
-		this.parameters.height,
-		this.parameters.radialSegments,
-		this.parameters.heightSegments,
-		this.parameters.openEnded,
-		this.parameters.thetaStart,
-		this.parameters.thetaLength
+	var parameters = this.parameters;
+
+	return new THREE.CylinderGeometry(
+		parameters.radiusTop,
+		parameters.radiusBottom,
+		parameters.height,
+		parameters.radialSegments,
+		parameters.heightSegments,
+		parameters.openEnded,
+		parameters.thetaStart,
+		parameters.thetaLength
 	);
 	);
 
 
-	return geometry;
-
 };
 };

+ 5 - 7
src/extras/geometries/DodecahedronGeometry.js

@@ -59,13 +59,11 @@ THREE.DodecahedronGeometry.prototype.constructor = THREE.DodecahedronGeometry;
 
 
 THREE.DodecahedronGeometry.prototype.clone = function () {
 THREE.DodecahedronGeometry.prototype.clone = function () {
 
 
-	var geometry = new THREE.DodecahedronGeometry(
-		this.parameters.radius,
-		this.parameters.detail
-	);
-
-	geometry.copy( this );
+	var parameters = this.parameters;
 
 
-	return geometry;
+	return new THREE.DodecahedronGeometry(
+		parameters.radius,
+		parameters.detail
+	);
 
 
 };
 };

+ 5 - 7
src/extras/geometries/IcosahedronGeometry.js

@@ -35,13 +35,11 @@ THREE.IcosahedronGeometry.prototype.constructor = THREE.IcosahedronGeometry;
 
 
 THREE.IcosahedronGeometry.prototype.clone = function () {
 THREE.IcosahedronGeometry.prototype.clone = function () {
 
 
-	var geometry = new THREE.IcosahedronGeometry(
-		this.parameters.radius,
-		this.parameters.detail
-	);
-
-	geometry.copy( this );
+	var parameters = this.parameters;
 
 
-	return geometry;
+	return new THREE.IcosahedronGeometry(
+		parameters.radius,
+		parameters.detail
+	);
 
 
 };
 };

+ 5 - 7
src/extras/geometries/OctahedronGeometry.js

@@ -28,13 +28,11 @@ THREE.OctahedronGeometry.prototype.constructor = THREE.OctahedronGeometry;
 
 
 THREE.OctahedronGeometry.prototype.clone = function () {
 THREE.OctahedronGeometry.prototype.clone = function () {
 
 
-	var geometry = new THREE.OctahedronGeometry(
-		this.parameters.radius,
-		this.parameters.detail
-	);
-
-	geometry.copy( this );
+	var parameters = this.parameters;
 
 
-	return geometry;
+	return new THREE.OctahedronGeometry(
+		parameters.radius,
+		parameters.detail
+	);
 
 
 };
 };

+ 7 - 9
src/extras/geometries/PlaneBufferGeometry.js

@@ -97,15 +97,13 @@ THREE.PlaneBufferGeometry.prototype.constructor = THREE.PlaneBufferGeometry;
 
 
 THREE.PlaneBufferGeometry.prototype.clone = function () {
 THREE.PlaneBufferGeometry.prototype.clone = function () {
 
 
-	var geometry = new THREE.PlaneBufferGeometry(
-		this.parameters.width,
-		this.parameters.height,
-		this.parameters.widthSegments,
-		this.parameters.heightSegments
-	);
-
-	geometry.copy( this );
+	var parameters = this.parameters;
 
 
-	return geometry;
+	return new THREE.PlaneBufferGeometry(
+		parameters.width,
+		parameters.height,
+		parameters.widthSegments,
+		parameters.heightSegments
+	);
 
 
 };
 };

+ 7 - 7
src/extras/geometries/PlaneGeometry.js

@@ -25,13 +25,13 @@ THREE.PlaneGeometry.prototype.constructor = THREE.PlaneGeometry;
 
 
 THREE.PlaneGeometry.prototype.clone = function () {
 THREE.PlaneGeometry.prototype.clone = function () {
 
 
-	var geometry = new THREE.PlaneGeometry(
-		this.parameters.width,
-		this.parameters.height,
-		this.parameters.widthSegments,
-		this.parameters.heightSegments
-	);
+	var parameters = this.parameters;
 
 
-	return geometry;
+	return new THREE.PlaneGeometry(
+		parameters.width,
+		parameters.height,
+		parameters.widthSegments,
+		parameters.heightSegments
+	);
 
 
 };
 };

+ 7 - 14
src/extras/geometries/PolyhedronGeometry.js

@@ -242,20 +242,13 @@ THREE.PolyhedronGeometry.prototype.constructor = THREE.PolyhedronGeometry;
 
 
 THREE.PolyhedronGeometry.prototype.clone = function () {
 THREE.PolyhedronGeometry.prototype.clone = function () {
 
 
-	var geometry = new THREE.PolyhedronGeometry(
-		this.parameters.vertices,
-		this.parameters.indices,
-		this.parameters.radius,
-		this.parameters.detail
-	);
-
-	return geometry.copy( this );
-
-};
-
-THREE.PolyhedronGeometry.prototype.copy = function ( source ) {
+	var parameters = this.parameters;
 
 
-	THREE.Geometry.prototype.copy.call( this, source );
-	return this;
+	return new THREE.PolyhedronGeometry(
+		parameters.vertices,
+		parameters.indices,
+		parameters.radius,
+		parameters.detail
+	);
 
 
 };
 };

+ 9 - 9
src/extras/geometries/RingGeometry.js

@@ -93,15 +93,15 @@ THREE.RingGeometry.prototype.constructor = THREE.RingGeometry;
 
 
 THREE.RingGeometry.prototype.clone = function () {
 THREE.RingGeometry.prototype.clone = function () {
 
 
-	var geometry = new THREE.RingGeometry(
-		this.parameters.innerRadius,
-		this.parameters.outerRadius,
-		this.parameters.thetaSegments,
-		this.parameters.phiSegments,
-		this.parameters.thetaStart,
-		this.parameters.thetaLength
+	var parameters = this.parameters;
+
+	return new THREE.RingGeometry(
+		parameters.innerRadius,
+		parameters.outerRadius,
+		parameters.thetaSegments,
+		parameters.phiSegments,
+		parameters.thetaStart,
+		parameters.thetaLength
 	);
 	);
 
 
-	return geometry;
-
 };
 };

+ 10 - 12
src/extras/geometries/SphereBufferGeometry.js

@@ -102,18 +102,16 @@ THREE.SphereBufferGeometry.prototype.constructor = THREE.SphereBufferGeometry;
 
 
 THREE.SphereBufferGeometry.prototype.clone = function () {
 THREE.SphereBufferGeometry.prototype.clone = function () {
 
 
-	var geometry = new THREE.SphereBufferGeometry(
-		this.parameters.radius,
-		this.parameters.widthSegments,
-		this.parameters.heightSegments,
-		this.parameters.phiStart,
-		this.parameters.phiLength,
-		this.parameters.thetaStart,
-		this.parameters.thetaLength
+	var parameters = this.parameters;
+
+	return new THREE.SphereBufferGeometry(
+		parameters.radius,
+		parameters.widthSegments,
+		parameters.heightSegments,
+		parameters.phiStart,
+		parameters.phiLength,
+		parameters.thetaStart,
+		parameters.thetaLength
 	);
 	);
 
 
-	geometry.copy( this );
-
-	return geometry;
-
 };
 };

+ 10 - 10
src/extras/geometries/SphereGeometry.js

@@ -27,16 +27,16 @@ THREE.SphereGeometry.prototype.constructor = THREE.SphereGeometry;
 
 
 THREE.SphereGeometry.prototype.clone = function () {
 THREE.SphereGeometry.prototype.clone = function () {
 
 
-	var geometry = new THREE.SphereGeometry(
-		this.parameters.radius,
-		this.parameters.widthSegments,
-		this.parameters.heightSegments,
-		this.parameters.phiStart,
-		this.parameters.phiLength,
-		this.parameters.thetaStart,
-		this.parameters.thetaLength
+	var parameters = this.parameters;
+
+	return new THREE.SphereGeometry(
+		parameters.radius,
+		parameters.widthSegments,
+		parameters.heightSegments,
+		parameters.phiStart,
+		parameters.phiLength,
+		parameters.thetaStart,
+		parameters.thetaLength
 	);
 	);
 
 
-	return geometry;
-
 };
 };

+ 5 - 7
src/extras/geometries/TetrahedronGeometry.js

@@ -28,13 +28,11 @@ THREE.TetrahedronGeometry.prototype.constructor = THREE.TetrahedronGeometry;
 
 
 THREE.TetrahedronGeometry.prototype.clone = function () {
 THREE.TetrahedronGeometry.prototype.clone = function () {
 
 
-	var geometry = new THREE.TetrahedronGeometry(
-		this.parameters.radius,
-		this.parameters.detail
-	);
-
-	geometry.copy( this );
+	var parameters = this.parameters;
 
 
-	return geometry;
+	return new THREE.TetrahedronGeometry(
+		parameters.radius,
+		parameters.detail
+	);
 
 
 };
 };

+ 8 - 8
src/extras/geometries/TorusGeometry.js

@@ -80,14 +80,14 @@ THREE.TorusGeometry.prototype.constructor = THREE.TorusGeometry;
 
 
 THREE.TorusGeometry.prototype.clone = function () {
 THREE.TorusGeometry.prototype.clone = function () {
 
 
-	var geometry = new THREE.TorusGeometry(
-		this.parameters.radius,
-		this.parameters.tube,
-		this.parameters.radialSegments,
-		this.parameters.tubularSegments,
-		this.parameters.arc
+	var parameters = this.parameters;
+
+	return new THREE.TorusGeometry(
+		parameters.radius,
+		parameters.tube,
+		parameters.radialSegments,
+		parameters.tubularSegments,
+		parameters.arc
 	);
 	);
 
 
-	return geometry;
-
 };
 };

+ 10 - 10
src/extras/geometries/TorusKnotGeometry.js

@@ -115,16 +115,16 @@ THREE.TorusKnotGeometry.prototype.constructor = THREE.TorusKnotGeometry;
 
 
 THREE.TorusKnotGeometry.prototype.clone = function () {
 THREE.TorusKnotGeometry.prototype.clone = function () {
 
 
-	var geometry = new THREE.TorusKnotGeometry(
-		this.parameters.radius,
-		this.parameters.tube,
-		this.parameters.radialSegments,
-		this.parameters.tubularSegments,
-		this.parameters.p,
-		this.parameters.q,
-		this.parameters.heightScale
+	var parameters = this.parameters;
+
+	return new THREE.TorusKnotGeometry(
+		parameters.radius,
+		parameters.tube,
+		parameters.radialSegments,
+		parameters.tubularSegments,
+		parameters.p,
+		parameters.q,
+		parameters.heightScale
 	);
 	);
 
 
-	return geometry;
-
 };
 };

+ 2 - 0
src/extras/helpers/CameraHelper.js

@@ -94,6 +94,8 @@ THREE.CameraHelper = function ( camera ) {
 	THREE.LineSegments.call( this, geometry, material );
 	THREE.LineSegments.call( this, geometry, material );
 
 
 	this.camera = camera;
 	this.camera = camera;
+	this.camera.updateProjectionMatrix();
+
 	this.matrix = camera.matrixWorld;
 	this.matrix = camera.matrixWorld;
 	this.matrixAutoUpdate = false;
 	this.matrixAutoUpdate = false;
 
 

+ 2 - 41
src/lights/DirectionalLight.js

@@ -16,29 +16,7 @@ THREE.DirectionalLight = function ( color, intensity ) {
 
 
 	this.intensity = ( intensity !== undefined ) ? intensity : 1;
 	this.intensity = ( intensity !== undefined ) ? intensity : 1;
 
 
-	this.castShadow = false;
-	this.onlyShadow = false;
-
-	this.shadowCameraNear = 50;
-	this.shadowCameraFar = 5000;
-
-	this.shadowCameraLeft = - 500;
-	this.shadowCameraRight = 500;
-	this.shadowCameraTop = 500;
-	this.shadowCameraBottom = - 500;
-
-	this.shadowCameraVisible = false;
-
-	this.shadowBias = 0;
-	this.shadowDarkness = 0.5;
-
-	this.shadowMapWidth = 512;
-	this.shadowMapHeight = 512;
-
-	this.shadowMap = null;
-	this.shadowMapSize = null;
-	this.shadowCamera = null;
-	this.shadowMatrix = null;
+	this.shadow = new THREE.LightShadow( new THREE.OrthographicCamera( - 500, 500, 500, - 500, 50, 5000 ) );
 
 
 };
 };
 
 
@@ -52,24 +30,7 @@ THREE.DirectionalLight.prototype.copy = function ( source ) {
 	this.intensity = source.intensity;
 	this.intensity = source.intensity;
 	this.target = source.target.clone();
 	this.target = source.target.clone();
 
 
-	this.castShadow = source.castShadow;
-	this.onlyShadow = source.onlyShadow;
-
-	this.shadowCameraNear = source.shadowCameraNear;
-	this.shadowCameraFar = source.shadowCameraFar;
-
-	this.shadowCameraLeft = source.shadowCameraLeft;
-	this.shadowCameraRight = source.shadowCameraRight;
-	this.shadowCameraTop = source.shadowCameraTop;
-	this.shadowCameraBottom = source.shadowCameraBottom;
-
-	this.shadowCameraVisible = source.shadowCameraVisible;
-
-	this.shadowBias = source.shadowBias;
-	this.shadowDarkness = source.shadowDarkness;
-
-	this.shadowMapWidth = source.shadowMapWidth;
-	this.shadowMapHeight = source.shadowMapHeight;
+	this.shadow = source.shadow.clone();
 
 
 	return this;
 	return this;
 
 

+ 70 - 0
src/lights/Light.js

@@ -11,11 +11,81 @@ THREE.Light = function ( color ) {
 
 
 	this.color = new THREE.Color( color );
 	this.color = new THREE.Color( color );
 
 
+	this.receiveShadow = undefined;
+
 };
 };
 
 
 THREE.Light.prototype = Object.create( THREE.Object3D.prototype );
 THREE.Light.prototype = Object.create( THREE.Object3D.prototype );
 THREE.Light.prototype.constructor = THREE.Light;
 THREE.Light.prototype.constructor = THREE.Light;
 
 
+Object.defineProperties( THREE.Light.prototype, {
+	onlyShadow: {
+		set: function ( value ) {
+			console.warn( 'THREE.Light: .onlyShadow has been removed.' );
+		}
+	},
+	shadowCameraFov: {
+		set: function ( value ) {
+			this.shadow.camera.fov = value;
+		}
+	},
+	shadowCameraLeft: {
+		set: function ( value ) {
+			this.shadow.camera.left = value;
+		}
+	},
+	shadowCameraRight: {
+		set: function ( value ) {
+			this.shadow.camera.right = value;
+		}
+	},
+	shadowCameraTop: {
+		set: function ( value ) {
+			this.shadow.camera.top = value;
+		}
+	},
+	shadowCameraBottom: {
+		set: function ( value ) {
+			this.shadow.camera.bottom = value;
+		}
+	},
+	shadowCameraNear: {
+		set: function ( value ) {
+			this.shadow.camera.near = value;
+		}
+	},
+	shadowCameraFar: {
+		set: function ( value ) {
+			this.shadow.camera.far = value;
+		}
+	},
+	shadowCameraVisible: {
+		set: function ( value ) {
+			console.warn( 'THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow ) instead.' );
+		}
+	},
+	shadowBias: {
+		set: function ( value ) {
+			this.shadow.bias = value;
+		}
+	},
+	shadowDarkness: {
+		set: function ( value ) {
+			this.shadow.darkness = value;
+		}
+	},
+	shadowMapWidth: {
+		set: function ( value ) {
+			this.shadow.mapSize.width = value;
+		}
+	},
+	shadowMapHeight: {
+		set: function ( value ) {
+			this.shadow.mapSize.height = value;
+		}
+	}
+} );
+
 THREE.Light.prototype.copy = function ( source ) {
 THREE.Light.prototype.copy = function ( source ) {
 
 
 	THREE.Object3D.prototype.copy.call( this, source );
 	THREE.Object3D.prototype.copy.call( this, source );

+ 40 - 0
src/lights/LightShadow.js

@@ -0,0 +1,40 @@
+/**
+ * @author mrdoob / http://mrdoob.com/
+ */
+
+THREE.LightShadow = function ( camera ) {
+
+	this.camera = camera;
+
+	this.bias = 0;
+	this.darkness = 0.5;
+
+	this.mapSize = new THREE.Vector2( 512, 512 );
+
+	this.map = null;
+	this.matrix = null;
+
+};
+
+THREE.LightShadow.prototype = {
+
+	constructor: THREE.LightShadow,
+
+	copy: function ( source ) {
+
+		this.camera = source.camera.clone();
+
+		this.bias = source.bias;
+		this.darkness = source.darkness;
+
+		this.mapSize.copy( source.mapSize );
+
+	},
+
+	clone: function () {
+
+		return new this.constructor().copy( this );
+
+	}
+
+};

+ 2 - 37
src/lights/PointLight.js

@@ -13,29 +13,7 @@ THREE.PointLight = function ( color, intensity, distance, decay ) {
 	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.
 
 
-	this.castShadow = false;
-	this.onlyShadow = false;
-
-	//
-
-	this.shadowCameraNear = 1;
-	this.shadowCameraFar = 500;
-	this.shadowCameraFov = 90;
-
-	this.shadowCameraVisible = false;
-
-	this.shadowBias = 0;
-	this.shadowDarkness = 0.5;
-
-	this.shadowMapWidth = 512;
-	this.shadowMapHeight = 512;
-
-	//
-
-	this.shadowMap = null;
-	this.shadowMapSize = null;
-	this.shadowCamera = null;
-	this.shadowMatrix = null;
+	this.shadow = new THREE.LightShadow( new THREE.PerspectiveCamera( 90, 1, 1, 500 ) );
 
 
 };
 };
 
 
@@ -50,20 +28,7 @@ THREE.PointLight.prototype.copy = function ( source ) {
 	this.distance = source.distance;
 	this.distance = source.distance;
 	this.decay = source.decay;
 	this.decay = source.decay;
 
 
-	this.castShadow = source.castShadow;
-	this.onlyShadow = source.onlyShadow;
-
-	this.shadowCameraNear = source.shadowCameraNear;
-	this.shadowCameraFar = source.shadowCameraFar;
-	this.shadowCameraFov = source.shadowCameraFov;
-
-	this.shadowCameraVisible = source.shadowCameraVisible;
-
-	this.shadowBias = source.shadowBias;
-	this.shadowDarkness = source.shadowDarkness;
-
-	this.shadowMapWidth = source.shadowMapWidth;
-	this.shadowMapHeight = source.shadowMapHeight;
+	this.shadow = source.shadow.clone();
 
 
 	return this;
 	return this;
 
 

+ 2 - 33
src/lights/SpotLight.js

@@ -19,25 +19,7 @@ THREE.SpotLight = function ( color, intensity, distance, angle, exponent, decay
 	this.exponent = ( exponent !== undefined ) ? exponent : 10;
 	this.exponent = ( exponent !== undefined ) ? exponent : 10;
 	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.
 
 
-	this.castShadow = false;
-	this.onlyShadow = false;
-
-	this.shadowCameraNear = 50;
-	this.shadowCameraFar = 5000;
-	this.shadowCameraFov = 50;
-
-	this.shadowCameraVisible = false;
-
-	this.shadowBias = 0;
-	this.shadowDarkness = 0.5;
-
-	this.shadowMapWidth = 512;
-	this.shadowMapHeight = 512;
-
-	this.shadowMap = null;
-	this.shadowMapSize = null;
-	this.shadowCamera = null;
-	this.shadowMatrix = null;
+	this.shadow = new THREE.LightShadow( new THREE.PerspectiveCamera( 50, 1, 50, 5000 ) );
 
 
 };
 };
 
 
@@ -56,20 +38,7 @@ THREE.SpotLight.prototype.copy = function ( source ) {
 
 
 	this.target = source.target.clone();
 	this.target = source.target.clone();
 
 
-	this.castShadow = source.castShadow;
-	this.onlyShadow = source.onlyShadow;
-
-	this.shadowCameraNear = source.shadowCameraNear;
-	this.shadowCameraFar = source.shadowCameraFar;
-	this.shadowCameraFov = source.shadowCameraFov;
-
-	this.shadowCameraVisible = source.shadowCameraVisible;
-
-	this.shadowBias = source.shadowBias;
-	this.shadowDarkness = source.shadowDarkness;
-
-	this.shadowMapWidth = source.shadowMapWidth;
-	this.shadowMapHeight = source.shadowMapHeight;
+	this.shadow = source.shadow.clone();
 
 
 	return this;
 	return this;
 
 

+ 12 - 23
src/loaders/JSONLoader.js

@@ -23,7 +23,7 @@ THREE.JSONLoader.prototype = {
 	constructor: THREE.JSONLoader,
 	constructor: THREE.JSONLoader,
 
 
 	// Deprecated
 	// Deprecated
-	
+
 	get statusDomElement () {
 	get statusDomElement () {
 
 
 		if ( this._statusDomElement === undefined ) {
 		if ( this._statusDomElement === undefined ) {
@@ -451,18 +451,16 @@ THREE.JSONLoader.prototype = {
 
 
 			if ( json.morphTargets !== undefined ) {
 			if ( json.morphTargets !== undefined ) {
 
 
-				var i, l, v, vl, dstVertices, srcVertices;
-
-				for ( i = 0, l = json.morphTargets.length; i < l; i ++ ) {
+				for ( var i = 0, l = json.morphTargets.length; i < l; i ++ ) {
 
 
 					geometry.morphTargets[ i ] = {};
 					geometry.morphTargets[ i ] = {};
 					geometry.morphTargets[ i ].name = json.morphTargets[ i ].name;
 					geometry.morphTargets[ i ].name = json.morphTargets[ i ].name;
 					geometry.morphTargets[ i ].vertices = [];
 					geometry.morphTargets[ i ].vertices = [];
 
 
-					dstVertices = geometry.morphTargets[ i ].vertices;
-					srcVertices = json.morphTargets[ i ].vertices;
+					var dstVertices = geometry.morphTargets[ i ].vertices;
+					var srcVertices = json.morphTargets[ i ].vertices;
 
 
-					for ( v = 0, vl = srcVertices.length; v < vl; v += 3 ) {
+					for ( var v = 0, vl = srcVertices.length; v < vl; v += 3 ) {
 
 
 						var vertex = new THREE.Vector3();
 						var vertex = new THREE.Vector3();
 						vertex.x = srcVertices[ v ] * scale;
 						vertex.x = srcVertices[ v ] * scale;
@@ -477,30 +475,21 @@ THREE.JSONLoader.prototype = {
 
 
 			}
 			}
 
 
-			if ( json.morphColors !== undefined ) {
-
-				var i, l, c, cl, dstColors, srcColors, color;
-
-				for ( i = 0, l = json.morphColors.length; i < l; i ++ ) {
+			if ( json.morphColors !== undefined && json.morphColors.length > 0 ) {
 
 
-					geometry.morphColors[ i ] = {};
-					geometry.morphColors[ i ].name = json.morphColors[ i ].name;
-					geometry.morphColors[ i ].colors = [];
+				console.warn( 'THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.' );
 
 
-					dstColors = geometry.morphColors[ i ].colors;
-					srcColors = json.morphColors[ i ].colors;
+				var faces = geometry.faces;
+				var morphColors = json.morphColors[ 0 ].colors;
 
 
-					for ( c = 0, cl = srcColors.length; c < cl; c += 3 ) {
+				for ( var i = 0, l = faces.length; i < l; i ++ ) {
 
 
-						color = new THREE.Color( 0xffaa00 );
-						color.setRGB( srcColors[ c ], srcColors[ c + 1 ], srcColors[ c + 2 ] );
-						dstColors.push( color );
-
-					}
+					faces[ i ].color.fromArray( morphColors, i * 3 );
 
 
 				}
 				}
 
 
 			}
 			}
+
 		}
 		}
 
 
 		function parseAnimations() {
 		function parseAnimations() {

+ 6 - 4
src/math/Color.js

@@ -476,11 +476,13 @@ THREE.Color.prototype = {
 
 
 	},
 	},
 
 
-	fromArray: function ( array ) {
+	fromArray: function ( array, offset ) {
 
 
-		this.r = array[ 0 ];
-		this.g = array[ 1 ];
-		this.b = array[ 2 ];
+		if ( offset === undefined ) offset = 0;
+
+		this.r = array[ offset ];
+		this.g = array[ offset + 1 ];
+		this.b = array[ offset + 2 ];
 
 
 		return this;
 		return this;
 
 

+ 8 - 0
src/math/Vector2.js

@@ -16,6 +16,14 @@ THREE.Vector2.prototype = {
 
 
 	constructor: THREE.Vector2,
 	constructor: THREE.Vector2,
 
 
+	get width() { return this.x },
+	set width( value ) { this.x = value },
+
+	get height() { return this.y },
+	set height( value ) { this.y = value },
+
+	//
+
 	set: function ( x, y ) {
 	set: function ( x, y ) {
 
 
 		this.x = x;
 		this.x = x;

+ 108 - 133
src/objects/Mesh.js

@@ -92,158 +92,149 @@ THREE.Mesh.prototype.raycast = ( function () {
 
 
 	}
 	}
 
 
-	return function raycast( raycaster, intersects ) {
+	function checkIntersection( object, raycaster, ray, pA, pB, pC, point ){
 
 
-		var geometry = this.geometry;
-		var material = this.material;
+		var intersect;
+		var material = object.material;
 
 
-		if ( material === undefined ) return;
+		if ( material.side === THREE.BackSide ) {
 
 
-		// Checking boundingSphere distance to ray
+			intersect = ray.intersectTriangle( pC, pB, pA, true, point );
 
 
-		if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
+		} else {
 
 
-		sphere.copy( geometry.boundingSphere );
-		sphere.applyMatrix4( this.matrixWorld );
+			intersect = ray.intersectTriangle( pA, pB, pC, material.side !== THREE.DoubleSide, point );
 
 
-		if ( raycaster.ray.isIntersectionSphere( sphere ) === false ) {
+		}
 
 
-			return;
+		if ( intersect === null ) return null;
 
 
-		}
+		intersectionPointWorld.copy( point );
+		intersectionPointWorld.applyMatrix4( object.matrixWorld );
 
 
-		// Check boundingBox before continuing
+		var distance = raycaster.ray.origin.distanceTo( intersectionPointWorld );
 
 
-		inverseMatrix.getInverse( this.matrixWorld );
-		ray.copy( raycaster.ray ).applyMatrix4( inverseMatrix );
+		if ( distance < raycaster.near || distance > raycaster.far ) return null;
 
 
-		if ( geometry.boundingBox !== null ) {
+		return {
+			distance: distance,
+			point: intersectionPointWorld.clone(),
+			object: object
+		};
 
 
-			if ( ray.isIntersectionBox( geometry.boundingBox ) === false ) {
+	}
 
 
-				return;
+	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 );
 
 
-		}
+		var intersection = checkIntersection( object, raycaster, ray, vA, vB, vC, intersectionPoint );
 
 
-		var a, b, c;
+		if ( intersection ) {
 
 
-		if ( geometry instanceof THREE.BufferGeometry ) {
+			if ( uvs ) {
 
 
-			var index = geometry.index;
-			var attributes = geometry.attributes;
+				uvA.fromArray( uvs, a * 2 );
+				uvB.fromArray( uvs, b * 2 );
+				uvC.fromArray( uvs, c * 2 );
 
 
-			if ( index !== null ) {
+				intersection.uv = uvIntersection( intersectionPoint,  vA, vB, vC,  uvA, uvB, uvC );
 
 
-				var indices = index.array;
-				var positions = attributes.position.array;
+			}
 
 
-				for ( var i = 0, l = indices.length; i < l; i += 3 ) {
+			intersection.face = new THREE.Face3( a, b, c, THREE.Triangle.normal( vA, vB, vC ) );
+			intersection.faceIndex = a;
 
 
-					a = indices[ i ];
-					b = indices[ i + 1 ];
-					c = indices[ i + 2 ];
+		}
 
 
-					vA.fromArray( positions, a * 3 );
-					vB.fromArray( positions, b * 3 );
-					vC.fromArray( positions, c * 3 );
+		return intersection;
 
 
-					if ( material.side === THREE.BackSide ) {
+	}
 
 
-						if ( ray.intersectTriangle( vC, vB, vA, true, intersectionPoint ) === null ) continue;
+	return function raycast( raycaster, intersects ) {
 
 
-					} else {
+		var geometry = this.geometry;
+		var material = this.material;
 
 
-						if ( ray.intersectTriangle( vA, vB, vC, material.side !== THREE.DoubleSide, intersectionPoint ) === null ) continue;
+		if ( material === undefined ) return;
 
 
-					}
+		// Checking boundingSphere distance to ray
 
 
-					intersectionPointWorld.copy( intersectionPoint );
-					intersectionPointWorld.applyMatrix4( this.matrixWorld );
+		if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
 
 
-					var distance = raycaster.ray.origin.distanceTo( intersectionPointWorld );
+		var matrixWorld = this.matrixWorld;
 
 
-					if ( distance < raycaster.near || distance > raycaster.far ) continue;
+		sphere.copy( geometry.boundingSphere );
+		sphere.applyMatrix4( matrixWorld );
 
 
-					var uv;
+		if ( raycaster.ray.isIntersectionSphere( sphere ) === false ) return;
 
 
-					if ( attributes.uv !== undefined ) {
+		// Check boundingBox before continuing
 
 
-						var uvs = attributes.uv.array;
-						uvA.fromArray( uvs, a * 2 );
-						uvB.fromArray( uvs, b * 2 );
-						uvC.fromArray( uvs, c * 2 );
-						uv = uvIntersection( intersectionPoint, vA, vB, vC, uvA, uvB, uvC );
+		inverseMatrix.getInverse( matrixWorld );
+		ray.copy( raycaster.ray ).applyMatrix4( inverseMatrix );
 
 
-					}
+		if ( geometry.boundingBox !== null ) {
 
 
-					intersects.push( {
+			if ( ray.isIntersectionBox( geometry.boundingBox ) === false ) return;
 
 
-						distance: distance,
-						point: intersectionPointWorld.clone(),
-						uv: uv,
-						face: new THREE.Face3( a, b, c, THREE.Triangle.normal( vA, vB, vC ) ),
-						faceIndex: Math.floor( i / 3 ), // triangle number in indices buffer semantics
-						object: this
+		}
 
 
-					} );
+		var uvs, intersection;
 
 
-				}
+		if ( geometry instanceof THREE.BufferGeometry ) {
 
 
-			} else {
+			var a, b, c;
+			var index = geometry.index;
+			var attributes = geometry.attributes;
+			var positions = attributes.position.array;
 
 
-				var positions = attributes.position.array;
+			if ( attributes.uv !== undefined ){
 
 
-				for ( var i = 0, l = positions.length; i < l; i += 9 ) {
+				uvs = attributes.uv.array;
 
 
-					vA.fromArray( positions, i );
-					vB.fromArray( positions, i + 3 );
-					vC.fromArray( positions, i + 6 );
+			}
 
 
-					if ( material.side === THREE.BackSide ) {
+			if ( index !== null ) {
 
 
-						if ( ray.intersectTriangle( vC, vB, vA, true, intersectionPoint ) === null ) continue;
+				var indices = index.array;
 
 
-					} else {
+				for ( var i = 0, l = indices.length; i < l; i += 3 ) {
 
 
-						if ( ray.intersectTriangle( vA, vB, vC, material.side !== THREE.DoubleSide, intersectionPoint ) === null ) continue;
+					a = indices[ i ];
+					b = indices[ i + 1 ];
+					c = indices[ i + 2 ];
 
 
-					}
+					intersection = checkBufferGeometryIntersection( this, raycaster, ray, positions, uvs, a, b, c );
 
 
-					intersectionPointWorld.copy( intersectionPoint );
-					intersectionPointWorld.applyMatrix4( this.matrixWorld );
+					if ( intersection ) {
 
 
-					var distance = raycaster.ray.origin.distanceTo( intersectionPointWorld );
+						intersection.faceIndex = Math.floor( i / 3 ); // triangle number in indices buffer semantics
+						intersects.push( intersection );
 
 
-					if ( distance < raycaster.near || distance > raycaster.far ) continue;
+					}
 
 
-					var uv;
+				}
 
 
-					if ( attributes.uv !== undefined ) {
+			} else {
 
 
-						var uvs = attributes.uv.array;
-						uvA.fromArray( uvs, i );
-						uvB.fromArray( uvs, i + 2 );
-						uvC.fromArray( uvs, i + 4 );
-						uv = uvIntersection( intersectionPoint, vA, vB, vC, uvA, uvB, uvC );
 
 
-					}
+				for ( var i = 0, l = positions.length; i < l; i += 9 ) {
 
 
 					a = i / 3;
 					a = i / 3;
 					b = a + 1;
 					b = a + 1;
 					c = a + 2;
 					c = a + 2;
 
 
-					intersects.push( {
+					intersection = checkBufferGeometryIntersection( this, raycaster, ray, positions, uvs, a, b, c );
+
+					if ( intersection ) {
 
 
-						distance: distance,
-						point: intersectionPointWorld.clone(),
-						uv: uv,
-						face: new THREE.Face3( a, b, c, THREE.Triangle.normal( vA, vB, vC ) ),
-						index: a, // triangle number in positions buffer semantics
-						object: this
+						intersection.index = a; // triangle number in positions buffer semantics
+						intersects.push( intersection );
 
 
-					} );
+					}
 
 
 				}
 				}
 
 
@@ -251,11 +242,14 @@ THREE.Mesh.prototype.raycast = ( function () {
 
 
 		} else if ( geometry instanceof THREE.Geometry ) {
 		} else if ( geometry instanceof THREE.Geometry ) {
 
 
+			var fvA, fvB, fvC;
 			var isFaceMaterial = material instanceof THREE.MeshFaceMaterial;
 			var isFaceMaterial = material instanceof THREE.MeshFaceMaterial;
 			var materials = isFaceMaterial === true ? material.materials : null;
 			var materials = isFaceMaterial === true ? material.materials : null;
 
 
 			var vertices = geometry.vertices;
 			var vertices = geometry.vertices;
 			var faces = geometry.faces;
 			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 ++ ) {
 
 
@@ -264,9 +258,9 @@ THREE.Mesh.prototype.raycast = ( function () {
 
 
 				if ( faceMaterial === undefined ) continue;
 				if ( faceMaterial === undefined ) continue;
 
 
-				a = vertices[ face.a ];
-				b = vertices[ face.b ];
-				c = vertices[ face.c ];
+				fvA = vertices[ face.a ];
+				fvB = vertices[ face.b ];
+				fvC = vertices[ face.c ];
 
 
 				if ( faceMaterial.morphTargets === true ) {
 				if ( faceMaterial.morphTargets === true ) {
 
 
@@ -285,62 +279,43 @@ THREE.Mesh.prototype.raycast = ( function () {
 
 
 						var targets = morphTargets[ t ].vertices;
 						var targets = morphTargets[ t ].vertices;
 
 
-						vA.addScaledVector( tempA.subVectors( targets[ face.a ], a ), influence );
-						vB.addScaledVector( tempB.subVectors( targets[ face.b ], b ), influence );
-						vC.addScaledVector( tempC.subVectors( targets[ face.c ], c ), 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( a );
-					vB.add( b );
-					vC.add( c );
+					vA.add( fvA );
+					vB.add( fvB );
+					vC.add( fvC );
 
 
-					a = vA;
-					b = vB;
-					c = vC;
+					fvA = vA;
+					fvB = vB;
+					fvC = vC;
 
 
 				}
 				}
 
 
-				if ( faceMaterial.side === THREE.BackSide ) {
+				intersection = checkIntersection( this, raycaster, ray, fvA, fvB, fvC, intersectionPoint );
 
 
-					if ( ray.intersectTriangle( c, b, a, true, intersectionPoint ) === null ) continue;
+				if ( intersection ) {
 
 
-				} else {
+					if ( uvs ) {
 
 
-					if ( ray.intersectTriangle( a, b, c, faceMaterial.side !== THREE.DoubleSide, intersectionPoint ) === null ) continue;
+						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 );
 
 
-				intersectionPointWorld.copy( intersectionPoint );
-				intersectionPointWorld.applyMatrix4( this.matrixWorld );
-
-				var distance = raycaster.ray.origin.distanceTo( intersectionPointWorld );
-
-				if ( distance < raycaster.near || distance > raycaster.far ) continue;
-
-				var uv;
-
-				if ( geometry.faceVertexUvs[ 0 ].length > 0 ) {
+					}
 
 
-					var uvs = geometry.faceVertexUvs[ 0 ][ f ];
-					uvA.copy( uvs[ 0 ] );
-					uvB.copy( uvs[ 1 ] );
-					uvC.copy( uvs[ 2 ] );
-					uv = uvIntersection( intersectionPoint, a, b, c, uvA, uvB, uvC );
+					intersection.face = face;
+					intersection.faceIndex = f;
+					intersects.push( intersection );
 
 
 				}
 				}
 
 
-				intersects.push( {
-
-					distance: distance,
-					point: intersectionPointWorld.clone(),
-					uv: uv,
-					face: face,
-					faceIndex: f,
-					object: this
-
-				} );
-
 			}
 			}
 
 
 		}
 		}

+ 35 - 30
src/renderers/WebGLRenderer.js

@@ -551,7 +551,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		}
 		}
 
 
 		// remove all webgl properties
 		// remove all webgl properties
-		properties.remove( texture );
+		properties.delete( texture );
 
 
 	}
 	}
 
 
@@ -580,8 +580,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		}
 		}
 
 
-		properties.remove( renderTarget.texture );
-		properties.remove( renderTarget );
+		properties.delete( renderTarget.texture );
+		properties.delete( renderTarget );
 
 
 	}
 	}
 
 
@@ -589,7 +589,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		releaseMaterialProgramReference( material );
 		releaseMaterialProgramReference( material );
 
 
-		properties.remove( material );
+		properties.delete( material );
 
 
 	}
 	}
 
 
@@ -811,28 +811,33 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		}
 		}
 
 
-		if ( group === null ) {
+		//
 
 
-			var count;
+		var dataStart = 0;
+		var dataCount = Infinity;
 
 
-			if ( index !== null ) {
+		if ( index !== null ) {
 
 
-				count = index.array.length;
+			dataCount = index.count
 
 
-			} else {
+		} else if ( position !== undefined ) {
 
 
-				count = position.count;
+			dataCount = position.count;
 
 
-			}
+		}
 
 
-			var drawRange = geometry.drawRange;
+		var rangeStart = geometry.drawRange.start;
+		var rangeCount = geometry.drawRange.count;
 
 
-			group = {
-				start: drawRange.start,
-				count: Math.min( drawRange.count, count )
-			};
+		var groupStart = group !== null ? group.start : 0;
+		var groupCount = group !== null ? group.count : Infinity;
 
 
-		}
+		var drawStart = Math.max( dataStart, rangeStart, groupStart );
+		var drawEnd = Math.min( dataStart + dataCount, rangeStart + rangeCount, groupStart + groupCount ) - 1;
+
+		var drawCount = Math.max( 0, drawEnd - drawStart + 1 );
+
+		//
 
 
 		if ( object instanceof THREE.Mesh ) {
 		if ( object instanceof THREE.Mesh ) {
 
 
@@ -853,7 +858,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			} else {
 			} else {
 
 
-				renderer.render( group.start, group.count );
+				renderer.render( drawStart, drawCount );
 
 
 			}
 			}
 
 
@@ -875,12 +880,12 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			}
 			}
 
 
-			renderer.render( group.start, group.count );
+			renderer.render( drawStart, drawCount );
 
 
 		} else if ( object instanceof THREE.Points ) {
 		} else if ( object instanceof THREE.Points ) {
 
 
 			renderer.setMode( _gl.POINTS );
 			renderer.setMode( _gl.POINTS );
-			renderer.render( group.start, group.count );
+			renderer.render( drawStart, drawCount );
 
 
 		}
 		}
 
 
@@ -1983,30 +1988,32 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 				var light = lights[ i ];
 				var light = lights[ i ];
 
 
-				if ( ! light.castShadow ) continue;
+				if ( light.castShadow === false ) continue;
 
 
 				if ( light instanceof THREE.PointLight || light instanceof THREE.SpotLight || light instanceof THREE.DirectionalLight ) {
 				if ( light instanceof THREE.PointLight || light instanceof THREE.SpotLight || light instanceof THREE.DirectionalLight ) {
 
 
+					var shadow = light.shadow;
+
 					if ( light instanceof THREE.PointLight ) {
 					if ( light instanceof THREE.PointLight ) {
 
 
 						// for point lights we set the shadow matrix to be a translation-only matrix
 						// for point lights we set the shadow matrix to be a translation-only matrix
 						// equal to inverse of the light's position
 						// equal to inverse of the light's position
 						_vector3.setFromMatrixPosition( light.matrixWorld ).negate();
 						_vector3.setFromMatrixPosition( light.matrixWorld ).negate();
-						light.shadowMatrix.identity().setPosition( _vector3 );
+						shadow.matrix.identity().setPosition( _vector3 );
 
 
 						// for point lights we set the sign of the shadowDarkness uniform to be negative
 						// for point lights we set the sign of the shadowDarkness uniform to be negative
-						uniforms.shadowDarkness.value[ j ] = - light.shadowDarkness;
+						uniforms.shadowDarkness.value[ j ] = - shadow.darkness;
 
 
 					} else {
 					} else {
 
 
-						uniforms.shadowDarkness.value[ j ] = light.shadowDarkness;
+						uniforms.shadowDarkness.value[ j ] = shadow.darkness;
 
 
 					}
 					}
 
 
-					uniforms.shadowMatrix.value[ j ] = light.shadowMatrix;
-					uniforms.shadowMap.value[ j ] = light.shadowMap;
-					uniforms.shadowMapSize.value[ j ] = light.shadowMapSize;
-					uniforms.shadowBias.value[ j ] = light.shadowBias;
+					uniforms.shadowMatrix.value[ j ] = shadow.matrix;
+					uniforms.shadowMap.value[ j ] = shadow.map;
+					uniforms.shadowMapSize.value[ j ] = shadow.mapSize;
+					uniforms.shadowBias.value[ j ] = shadow.bias;
 
 
 					j ++;
 					j ++;
 
 
@@ -2462,8 +2469,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			light = lights[ l ];
 			light = lights[ l ];
 
 
-			if ( light.onlyShadow ) continue;
-
 			color = light.color;
 			color = light.color;
 			intensity = light.intensity;
 			intensity = light.intensity;
 			distance = light.distance;
 			distance = light.distance;

+ 2 - 2
src/renderers/webgl/WebGLGeometries.js

@@ -101,11 +101,11 @@ THREE.WebGLGeometries = function ( gl, properties, info ) {
 
 
 		if ( attribute instanceof THREE.InterleavedBufferAttribute ) {
 		if ( attribute instanceof THREE.InterleavedBufferAttribute ) {
 
 
-			properties.remove( attribute.data );
+			properties.delete( attribute.data );
 
 
 		} else {
 		} else {
 
 
-			properties.remove( attribute );
+			properties.delete( attribute );
 
 
 		}
 		}
 
 

+ 4 - 4
src/renderers/webgl/WebGLPrograms.js

@@ -15,12 +15,12 @@ THREE.WebGLPrograms = function ( renderer, capabilities ) {
 
 
 	var parameterNames = [
 	var parameterNames = [
 		"precision", "supportsVertexTextures", "map", "envMap", "envMapMode",
 		"precision", "supportsVertexTextures", "map", "envMap", "envMapMode",
-		"lightMap", "aoMap", "emissiveMap", "bumpMap", "normalMap", "specularMap",
+		"lightMap", "aoMap", "emissiveMap", "bumpMap", "normalMap", "displacementMap", "specularMap",
 		"alphaMap", "combine", "vertexColors", "fog", "useFog", "fogExp",
 		"alphaMap", "combine", "vertexColors", "fog", "useFog", "fogExp",
 		"flatShading", "sizeAttenuation", "logarithmicDepthBuffer", "skinning",
 		"flatShading", "sizeAttenuation", "logarithmicDepthBuffer", "skinning",
 		"maxBones", "useVertexTexture", "morphTargets", "morphNormals",
 		"maxBones", "useVertexTexture", "morphTargets", "morphNormals",
 		"maxMorphTargets", "maxMorphNormals", "maxDirLights", "maxPointLights",
 		"maxMorphTargets", "maxMorphNormals", "maxDirLights", "maxPointLights",
-		"maxSpotLights", "maxHemiLights", "maxShadows", "shadowMapEnabled", "pointLightShadows", 
+		"maxSpotLights", "maxHemiLights", "maxShadows", "shadowMapEnabled", "pointLightShadows",
 		"shadowMapType", "shadowMapDebug", "alphaTest", "metal", "doubleSided",
 		"shadowMapType", "shadowMapDebug", "alphaTest", "metal", "doubleSided",
 		"flipSided"
 		"flipSided"
 	];
 	];
@@ -75,7 +75,7 @@ THREE.WebGLPrograms = function ( renderer, capabilities ) {
 
 
 			var light = lights[ l ];
 			var light = lights[ l ];
 
 
-			if ( light.onlyShadow || light.visible === false ) continue;
+			if ( light.visible === false ) continue;
 
 
 			if ( light instanceof THREE.DirectionalLight ) dirLights ++;
 			if ( light instanceof THREE.DirectionalLight ) dirLights ++;
 			if ( light instanceof THREE.PointLight ) pointLights ++;
 			if ( light instanceof THREE.PointLight ) pointLights ++;
@@ -105,7 +105,7 @@ THREE.WebGLPrograms = function ( renderer, capabilities ) {
 				maxShadows ++;
 				maxShadows ++;
 				pointLightShadows ++;
 				pointLightShadows ++;
 
 
-			} 
+			}
 
 
 		}
 		}
 
 

+ 1 - 1
src/renderers/webgl/WebGLProperties.js

@@ -22,7 +22,7 @@ THREE.WebGLProperties = function () {
 
 
 	};
 	};
 
 
-	this.remove = function ( object ) {
+	this.delete = function ( object ) {
 
 
 		delete properties[ object.uuid ];
 		delete properties[ object.uuid ];
 
 

+ 21 - 43
src/renderers/webgl/WebGLShadowMap.js

@@ -56,7 +56,6 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
 		var useMorphing = ( i & _MorphingFlag ) !== 0;
 		var useMorphing = ( i & _MorphingFlag ) !== 0;
 		var useSkinning = ( i & _SkinningFlag ) !== 0;
 		var useSkinning = ( i & _SkinningFlag ) !== 0;
 
 
-
 		var depthMaterial = new THREE.ShaderMaterial( {
 		var depthMaterial = new THREE.ShaderMaterial( {
 			uniforms: depthUniforms,
 			uniforms: depthUniforms,
 			vertexShader: depthShader.vertexShader,
 			vertexShader: depthShader.vertexShader,
@@ -100,15 +99,15 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
 		var faceCount, isPointLight;
 		var faceCount, isPointLight;
 
 
 		if ( scope.enabled === false ) return;
 		if ( scope.enabled === false ) return;
-		if ( scope.autoUpdate === false && scope.needsUpdate === false ) return;	
+		if ( scope.autoUpdate === false && scope.needsUpdate === false ) return;
 
 
-		// Set GL state for depth map. 
+		// Set GL state for depth map.
 		_gl.clearColor( 1, 1, 1, 1 );
 		_gl.clearColor( 1, 1, 1, 1 );
 		_state.disable( _gl.BLEND );
 		_state.disable( _gl.BLEND );
 		_state.enable( _gl.CULL_FACE );
 		_state.enable( _gl.CULL_FACE );
 		_gl.frontFace( _gl.CCW );
 		_gl.frontFace( _gl.CCW );
 		_gl.cullFace( scope.cullFace === THREE.CullFaceFront ? _gl.FRONT : _gl.BACK );
 		_gl.cullFace( scope.cullFace === THREE.CullFaceFront ? _gl.FRONT : _gl.BACK );
-		_state.setDepthTest( true );			
+		_state.setDepthTest( true );
 
 
 		// save the existing viewport so it can be restored later
 		// save the existing viewport so it can be restored later
 		_renderer.getViewport( _vector4 );
 		_renderer.getViewport( _vector4 );
@@ -119,15 +118,19 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
 
 
 			var light = _lights[ i ];
 			var light = _lights[ i ];
 
 
-			if ( ! light.castShadow ) continue;
+			if ( light.castShadow === false ) continue;
+
+			var shadow = light.shadow;
+			var shadowCamera = shadow.camera;
+			var shadowMapSize = shadow.mapSize;
 
 
 			if ( light instanceof THREE.PointLight ) {
 			if ( light instanceof THREE.PointLight ) {
 
 
 				faceCount = 6;
 				faceCount = 6;
 				isPointLight = true;
 				isPointLight = true;
 
 
-				var vpWidth = light.shadowMapWidth / 4.0;
-				var vpHeight = light.shadowMapHeight / 2.0;
+				var vpWidth = shadowMapSize.x / 4.0;
+				var vpHeight = shadowMapSize.y / 2.0;
 
 
 				// These viewports map a cube-map onto a 2D texture with the
 				// These viewports map a cube-map onto a 2D texture with the
 				// following orientation:
 				// following orientation:
@@ -162,7 +165,7 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
 
 
 			}
 			}
 
 
-			if ( ! light.shadowMap ) {
+			if ( shadow.map === null ) {
 
 
 				var shadowFilter = THREE.LinearFilter;
 				var shadowFilter = THREE.LinearFilter;
 
 
@@ -174,45 +177,23 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
 
 
 				var pars = { minFilter: shadowFilter, magFilter: shadowFilter, format: THREE.RGBAFormat };
 				var pars = { minFilter: shadowFilter, magFilter: shadowFilter, format: THREE.RGBAFormat };
 
 
-				light.shadowMap = new THREE.WebGLRenderTarget( light.shadowMapWidth, light.shadowMapHeight, pars );
-				light.shadowMapSize = new THREE.Vector2( light.shadowMapWidth, light.shadowMapHeight );
-
-				light.shadowMatrix = new THREE.Matrix4();
-
-			}
+				shadow.map = new THREE.WebGLRenderTarget( shadowMapSize.x, shadowMapSize.y, pars );
+				shadow.matrix = new THREE.Matrix4();
 
 
-			if ( ! light.shadowCamera ) {
+				//
 
 
 				if ( light instanceof THREE.SpotLight ) {
 				if ( light instanceof THREE.SpotLight ) {
 
 
-					light.shadowCamera = new THREE.PerspectiveCamera( light.shadowCameraFov, light.shadowMapWidth / light.shadowMapHeight, light.shadowCameraNear, light.shadowCameraFar );
-
-				} else if ( light instanceof THREE.DirectionalLight ) {
-
-					light.shadowCamera = new THREE.OrthographicCamera( light.shadowCameraLeft, light.shadowCameraRight, light.shadowCameraTop, light.shadowCameraBottom, light.shadowCameraNear, light.shadowCameraFar );
-
-				} else {
-
-					light.shadowCamera = new THREE.PerspectiveCamera( light.shadowCameraFov, 1.0, light.shadowCameraNear, light.shadowCameraFar );
+					shadowCamera.aspect = shadowMapSize.x / shadowMapSize.y;
 
 
 				}
 				}
 
 
-				scene.add( light.shadowCamera );
-
-				if ( scene.autoUpdate === true ) scene.updateMatrixWorld();
-
-			}
-
-			if ( light.shadowCameraVisible && ! light.cameraHelper ) {
-
-				light.cameraHelper = new THREE.CameraHelper( light.shadowCamera );
-				scene.add( light.cameraHelper );
+				shadowCamera.updateProjectionMatrix();
 
 
 			}
 			}
 
 
-			var shadowMap = light.shadowMap;
-			var shadowMatrix = light.shadowMatrix;
-			var shadowCamera = light.shadowCamera;
+			var shadowMap = shadow.map;
+			var shadowMatrix = shadow.matrix;
 
 
 			_lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
 			_lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
 			shadowCamera.position.copy( _lightPositionWorld );
 			shadowCamera.position.copy( _lightPositionWorld );
@@ -244,9 +225,6 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
 				shadowCamera.updateMatrixWorld();
 				shadowCamera.updateMatrixWorld();
 				shadowCamera.matrixWorldInverse.getInverse( shadowCamera.matrixWorld );
 				shadowCamera.matrixWorldInverse.getInverse( shadowCamera.matrixWorld );
 
 
-				if ( light.cameraHelper ) light.cameraHelper.visible = light.shadowCameraVisible;
-				if ( light.shadowCameraVisible ) light.cameraHelper.update();
-
 				// compute shadow matrix
 				// compute shadow matrix
 
 
 				shadowMatrix.set(
 				shadowMatrix.set(
@@ -311,13 +289,13 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
 
 
 			//We must call _renderer.resetGLState() at the end of each iteration of
 			//We must call _renderer.resetGLState() at the end of each iteration of
 			// the light loop in order to force material updates for each light.
 			// the light loop in order to force material updates for each light.
-			_renderer.resetGLState();			
+			_renderer.resetGLState();
 
 
 		}
 		}
 
 
 		_renderer.setViewport( _vector4.x, _vector4.y, _vector4.z, _vector4.w );
 		_renderer.setViewport( _vector4.x, _vector4.y, _vector4.z, _vector4.w );
 
 
-		// Restore GL state. 
+		// Restore GL state.
 		var clearColor = _renderer.getClearColor(),
 		var clearColor = _renderer.getClearColor(),
 		clearAlpha = _renderer.getClearAlpha();
 		clearAlpha = _renderer.getClearAlpha();
 		_renderer.setClearColor( clearColor, clearAlpha );
 		_renderer.setClearColor( clearColor, clearAlpha );
@@ -329,7 +307,7 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
 
 
 		}
 		}
 
 
-		_renderer.resetGLState();			
+		_renderer.resetGLState();
 
 
 		scope.needsUpdate = false;
 		scope.needsUpdate = false;
 
 

+ 3 - 2
utils/build/build.py

@@ -10,6 +10,7 @@ if sys.version_info < (2, 7):
 import argparse
 import argparse
 import json
 import json
 import os
 import os
+import re
 import shutil
 import shutil
 import tempfile
 import tempfile
 
 
@@ -45,7 +46,7 @@ def main(argv=None):
 	fd, path = tempfile.mkstemp()
 	fd, path = tempfile.mkstemp()
 	tmp = open(path, 'w', encoding='utf-8')
 	tmp = open(path, 'w', encoding='utf-8')
 	sources = []
 	sources = []
-		
+
 	if args.amd:
 	if args.amd:
 		tmp.write(u'( function ( root, factory ) {\n\n\tif ( typeof define === \'function\' && define.amd ) {\n\n\t\tdefine( [ \'exports\' ], factory );\n\n\t} else if ( typeof exports === \'object\' ) {\n\n\t\tfactory( exports );\n\n\t} else {\n\n\t\tfactory( root );\n\n\t}\n\n}( this, function ( exports ) {\n\n')
 		tmp.write(u'( function ( root, factory ) {\n\n\tif ( typeof define === \'function\' && define.amd ) {\n\n\t\tdefine( [ \'exports\' ], factory );\n\n\t} else if ( typeof exports === \'object\' ) {\n\n\t\tfactory( exports );\n\n\t} else {\n\n\t\tfactory( root );\n\n\t}\n\n}( this, function ( exports ) {\n\n')
 
 
@@ -60,7 +61,7 @@ def main(argv=None):
 			with open(filename, 'r', encoding='utf-8') as f:
 			with open(filename, 'r', encoding='utf-8') as f:
 				if filename.endswith(".glsl"):
 				if filename.endswith(".glsl"):
 					tmp.write(u'THREE.ShaderChunk[ \'' + os.path.splitext(os.path.basename(filename))[0] + u'\'] = "')
 					tmp.write(u'THREE.ShaderChunk[ \'' + os.path.splitext(os.path.basename(filename))[0] + u'\'] = "')
-					tmp.write(f.read().replace('\n','\\n'))
+					tmp.write(re.sub(r"\t*//.*\n", "", f.read()).replace('\n','\\n'))
 					tmp.write(u'";\n\n')
 					tmp.write(u'";\n\n')
 				else:
 				else:
 					tmp.write(f.read())
 					tmp.write(f.read())

+ 1 - 0
utils/build/includes/common.json

@@ -49,6 +49,7 @@
 	"src/cameras/OrthographicCamera.js",
 	"src/cameras/OrthographicCamera.js",
 	"src/cameras/PerspectiveCamera.js",
 	"src/cameras/PerspectiveCamera.js",
 	"src/lights/Light.js",
 	"src/lights/Light.js",
+	"src/lights/LightShadow.js",
 	"src/lights/AmbientLight.js",
 	"src/lights/AmbientLight.js",
 	"src/lights/DirectionalLight.js",
 	"src/lights/DirectionalLight.js",
 	"src/lights/HemisphereLight.js",
 	"src/lights/HemisphereLight.js",

Некоторые файлы не были показаны из-за большого количества измененных файлов