فهرست منبع

Merge branch 'dev' of https://github.com/mrdoob/three.js into dev

Mr.doob 10 سال پیش
والد
کامیت
18fc0e89bb

+ 6 - 4
docs/api/math/Vector2.html

@@ -152,7 +152,8 @@
 		max -- [page:Vector2] containing the max x and y values in the desired range
 		</div>
 		<div>
-		If this vector's x or y value is greater than the max vector's x or y value, it is replaced by the corresponding value. <br />	If this vector's x or y value is less than the min vector's x or y value, it is replaced by the corresponding value.
+		If this vector's x or y value is greater than the max vector's x or y value, it is replaced by the corresponding value. <br /><br />
+		If this vector's x or y value is less than the min vector's x or y value, it is replaced by the corresponding value.
 		</div>
 
 		<h3>[method:Vector2 clampScalar]([page:Float min], [page:Float max]) [page:Vector2 this]</h3>
@@ -161,7 +162,8 @@
 		max -- [page:Float] the maximum value the components will be clamped to
 		</div>
 		<div>
-		If this vector's x or y values are greater than the max value, they are replaced by the max value. <br />  If this vector's x or y values are less than the min value, they are replaced by the min value.
+		If this vector's x or y values are greater than the max value, they are replaced by the max value. <br /><br />
+		If this vector's x or y values are less than the min value, they are replaced by the min value.
 		</div>
 
 		<h3>[method:Vector2 floor]()</h3>
@@ -251,7 +253,7 @@
 		v -- [page:Vector2]
 		</div>
 		<div>
-		If this vector's x or y value is less than v's x or y value, replace that value with the corresponding min value.
+		If this vector's x or y value is greater than v's x or y value, replace that value with the corresponding min value.
 		</div>
 
 		<h3>[method:Vector2 max]([page:Vector2 v]) [page:Vector2 this]</h3>
@@ -259,7 +261,7 @@
 		v -- [page:Vector2]
 		</div>
 		<div>
-		If this vector's x or y value is greater than v's x or y value, replace that value with the corresponding max value.
+		If this vector's x or y value is less than v's x or y value, replace that value with the corresponding max value.
 		</div>
 
 		<h3>[method:Vector2 setX]([page:Float x]) [page:Vector2 this]</h3>

+ 4 - 3
docs/api/math/Vector3.html

@@ -202,7 +202,8 @@
 		max -- [page:Float] the maximum value the components will be clamped to
 		</div>
 		<div>
-		If this vector's x, y or z values are greater than the max value, they are replaced by the max value. <br />  If this vector's x, y or z values are less than the min value, they are replaced by the min value.
+		If this vector's x, y or z values are greater than the max value, they are replaced by the max value. <br /><br />
+		If this vector's x, y or z values are less than the min value, they are replaced by the min value.
 		</div>
 
 		<h3>[method:Vector3 floor]()</h3>
@@ -278,7 +279,7 @@
 		v -- [page:Vector3]
 		</div>
 		<div>
-		If this vector's x, y, or z value is less than vector v's x, y, or z value, that value is replaced by the corresponding vector v value.
+		If this vector's x, y, or z value is greater than vector v's x, y, or z value, that value is replaced by the corresponding vector v value.
 		</div>
 
 		<h3>[method:Vector3 max]([page:Vector3 v]) [page:Vector3 this]</h3>
@@ -286,7 +287,7 @@
 		v -- [page:Vector3]
 		</div>
 		<div>
-		If this vector's x, y, or z value is greater than vector v's x, y, or z value, that value is replaced by the corresponding vector v value.
+		If this vector's x, y, or z value is less than vector v's x, y, or z value, that value is replaced by the corresponding vector v value.
 		</div>
 
 		<h3>[method:Vector3 setComponent]([page:Integer index], [page:Float value]) [page:Vector3 this]</h3>

+ 4 - 5
docs/api/math/Vector4.html

@@ -137,8 +137,7 @@
 		</div>
 		<div>
 		If this vector's x, y, z, or w value is greater than the max vector's x, y, z, or w value, it is replaced by the corresponding value.<br/><br/>
-
-		If this vector's x, y, z, or w value is less than the min vector's x, y, z, or w value, it is replace by the corresponding value.
+		If this vector's x, y, z, or w value is less than the min vector's x, y, z, or w value, it is replaced by the corresponding value.
 		</div>
 
 		<h3>[method:Vector4 clampScalar]([page:Float min], [page:Float max]) [page:Vector4 this]</h3>
@@ -147,7 +146,7 @@
 		max -- [page:Float] the maximum value the components will be clamped to
 		</div>
 		<div>
-		If this vector's x, y, z or w values are greater than the max value, they are replaced by the max value. <br />
+		If this vector's x, y, z or w values are greater than the max value, they are replaced by the max value. <br /><br />
 		If this vector's x, y, z or w values are less than the min value, they are replaced by the min value.
 		</div>
 
@@ -184,7 +183,7 @@
 		v -- [page:Vector4]
 		</div>
 		<div>
-		If this vector's x, y, z, or w value is less than vector v's x, y, z, or w value, that value is replaced by the corresponding vector v value.
+		If this vector's x, y, z, or w value is greater than vector v's x, y, z, or w value, that value is replaced by the corresponding vector v value.
 		</div>
 
 		<h3>[method:Vector4 max]([page:Vector4 v]) [page:Vector4 this]</h3>
@@ -192,7 +191,7 @@
 		v -- [page:Vector4]
 		</div>
 		<div>
-		If this vector's x, y, z, or w value is greater than vector v's x, y, z, or w value, that value is replaced by the corresponding vector v value.
+		If this vector's x, y, z, or w value is less than vector v's x, y, z, or w value, that value is replaced by the corresponding vector v value.
 		</div>
 
 		<h3>[method:Vector4 addScalar]([page:Float s]) [page:Vector4 this]</h3>

+ 4 - 4
examples/js/exporters/SceneExporter.js

@@ -402,10 +402,10 @@ THREE.SceneExporter.prototype = {
 
 				'\t' + LabelString( getGeometryName( g ) ) + ': {',
 				'	"type"    : "plane",',
-				'	"width"  : '  + g.width  + ',',
-				'	"height"  : ' + g.height + ',',
-				'	"widthSegments"  : ' + g.widthSegments + ',',
-				'	"heightSegments" : ' + g.heightSegments,
+				'	"width"  : '  + g.parameters.width  + ',',
+				'	"height"  : ' + g.parameters.height + ',',
+				'	"widthSegments"  : ' + g.parameters.widthSegments + ',',
+				'	"heightSegments" : ' + g.parameters.heightSegments,
 				'}'
 
 				];

+ 6 - 6
src/core/Object3D.js

@@ -172,7 +172,7 @@ THREE.Object3D.prototype = {
 
 			return this;
 
-		}
+		};
 
 	}(),
 
@@ -227,7 +227,7 @@ THREE.Object3D.prototype = {
 
 			return this;
 
-		}
+		};
 
 	}(),
 
@@ -443,7 +443,7 @@ THREE.Object3D.prototype = {
 
 			return result;
 
-		}
+		};
 
 	}(),
 
@@ -459,7 +459,7 @@ THREE.Object3D.prototype = {
 
 			return result.setFromQuaternion( quaternion, this.rotation.order, false );
 
-		}
+		};
 
 	}(),
 
@@ -478,7 +478,7 @@ THREE.Object3D.prototype = {
 
 			return result;
 
-		}
+		};
 
 	}(),
 
@@ -494,7 +494,7 @@ THREE.Object3D.prototype = {
 
 			return result.set( 0, 0, 1 ).applyQuaternion( quaternion );
 
-		}
+		};
 
 	}(),
 

+ 2 - 0
src/lights/DirectionalLight.js

@@ -10,6 +10,8 @@ THREE.DirectionalLight = function ( color, intensity ) {
 	this.type = 'DirectionalLight';
 
 	this.position.set( 0, 1, 0 );
+	this.updateMatrix();
+
 	this.target = new THREE.Object3D();
 
 	this.intensity = ( intensity !== undefined ) ? intensity : 1;

+ 1 - 0
src/lights/HemisphereLight.js

@@ -9,6 +9,7 @@ THREE.HemisphereLight = function ( skyColor, groundColor, intensity ) {
 	this.type = 'HemisphereLight';
 
 	this.position.set( 0, 100, 0 );
+	this.updateMatrix();
 
 	this.groundColor = new THREE.Color( groundColor );
 	this.intensity = ( intensity !== undefined ) ? intensity : 1;

+ 2 - 0
src/lights/SpotLight.js

@@ -9,6 +9,8 @@ THREE.SpotLight = function ( color, intensity, distance, angle, exponent, decay
 	this.type = 'SpotLight';
 
 	this.position.set( 0, 1, 0 );
+	this.updateMatrix();
+
 	this.target = new THREE.Object3D();
 
 	this.intensity = ( intensity !== undefined ) ? intensity : 1;

+ 7 - 0
src/loaders/ObjectLoader.js

@@ -519,6 +519,13 @@ THREE.ObjectLoader.prototype = {
 
 					break;
 
+
+				case 'AreaLight':
+
+					object = new THREE.AreaLight( data.color, data.intensity );
+
+					break;
+
 				case 'DirectionalLight':
 
 					object = new THREE.DirectionalLight( data.color, data.intensity );

+ 27 - 0
test/unit/lights/AmbientLight.tests.js

@@ -0,0 +1,27 @@
+(function () {
+
+	'use strict';
+
+	var lights;
+
+	QUnit.module( "Lights - AmbientLight", {
+
+		beforeEach: function() {
+
+			lights = [
+
+				new THREE.AmbientLight( 0xaaaaaa ),
+
+			];
+
+		}
+
+	});
+
+	QUnit.test( "standard light tests", function( assert ) {
+
+		runStdLightTests( assert, lights );
+
+	});
+
+})();

+ 28 - 0
test/unit/lights/AreaLight.tests.js

@@ -0,0 +1,28 @@
+(function () {
+
+	'use strict';
+
+	var lights;
+
+	QUnit.module( "Lights - AreaLight", {
+
+		beforeEach: function() {
+
+			lights = [
+
+				new THREE.AreaLight( 0xaaaaaa ),
+				new THREE.AreaLight( 0xaaaaaa, 0.7 ),
+
+			];
+
+		}
+
+	});
+
+	QUnit.test( "standard light tests", function( assert ) {
+
+		runStdLightTests( assert, lights );
+
+	});
+
+})();

+ 28 - 0
test/unit/lights/DirectionalLight.tests.js

@@ -0,0 +1,28 @@
+(function () {
+
+	'use strict';
+
+	var lights;
+
+	QUnit.module( "Lights - DirectionalLight", {
+
+		beforeEach: function() {
+
+			lights = [
+
+				new THREE.DirectionalLight( 0xaaaaaa ),
+				new THREE.DirectionalLight( 0xaaaaaa, 0.8 ),
+
+			];
+
+		}
+
+	});
+
+	QUnit.test( "standard light tests", function( assert ) {
+
+		runStdLightTests( assert, lights );
+
+	});
+
+})();

+ 35 - 0
test/unit/lights/HemisphereLight.tests.js

@@ -0,0 +1,35 @@
+(function () {
+
+	'use strict';
+
+	var parameters = {
+		skyColor: 0x123456,
+		groundColor: 0xabc012,
+		intensity: 0.6
+	};
+
+	var lights;
+
+	QUnit.module( "Lights - HemisphereLight", {
+
+		beforeEach: function() {
+
+			lights = [
+
+				new THREE.HemisphereLight( parameters.skyColor ),
+				new THREE.HemisphereLight( parameters.skyColor, parameters.groundColor ),
+				new THREE.HemisphereLight( parameters.skyColor, parameters.groundColor, parameters.intensity ),
+
+			];
+
+		}
+
+	});
+
+	QUnit.test( "standard light tests", function( assert ) {
+
+		runStdLightTests( assert, lights );
+
+	});
+
+})();

+ 27 - 0
test/unit/lights/PointLight.tests.js

@@ -0,0 +1,27 @@
+(function () {
+
+	'use strict';
+
+	var lights;
+
+	QUnit.module( "Lights - PointLight", {
+
+		beforeEach: function() {
+
+			lights = [
+
+				new THREE.PointLight( 0xaaaaaa ),
+
+			];
+
+		}
+
+	});
+
+	QUnit.test( "standard light tests", function( assert ) {
+
+		runStdLightTests( assert, lights );
+
+	});
+
+})();

+ 41 - 0
test/unit/lights/SpotLight.tests.js

@@ -0,0 +1,41 @@
+(function () {
+
+	'use strict';
+
+	var parameters = {
+		color: 0xaaaaaa,
+		intensity: 0.5,
+		distance: 100,
+		angle: 0.8,
+		exponent: 8,
+		decay: 2
+	};
+
+	var lights;
+
+	QUnit.module( "Lights - SpotLight", {
+
+		beforeEach: function() {
+
+			lights = [
+
+				new THREE.SpotLight( parameters.color ),
+				new THREE.SpotLight( parameters.color, parameters.intensity ),
+				new THREE.SpotLight( parameters.color, parameters.intensity, parameters.distance ),
+				new THREE.SpotLight( parameters.color, parameters.intensity, parameters.distance, parameters.angle ),
+				new THREE.SpotLight( parameters.color, parameters.intensity, parameters.distance, parameters.angle, parameters.exponent ),
+				new THREE.SpotLight( parameters.color, parameters.intensity, parameters.distance, parameters.angle, parameters.exponent, parameters.decay ),
+
+			];
+
+		}
+
+	});
+
+	QUnit.test( "standard light tests", function( assert ) {
+
+		runStdLightTests( assert, lights );
+
+	});
+
+})();

+ 67 - 0
test/unit/qunit-utils.js

@@ -143,3 +143,70 @@ function runStdGeometryTests( assert, geometries ) {
 	});
 
 }
+
+
+
+
+//
+//	LIGHT TEST HELPERS
+//
+
+// Run common light tests.
+function runStdLightTests( assert, lights ) {
+
+	_.each( lights, function( light ) {
+
+		// Clone
+		checkLightClone( light );
+
+		// json round trip
+		checkLightJsonRoundtrip( light );
+
+	});
+
+}
+
+
+function checkLightClone( light ) {
+
+	// Clone
+	var copy = light.clone();
+	QUnit.assert.notEqual( copy.uuid, light.uuid, "clone uuid should differ from original" );
+	QUnit.assert.notEqual( copy.id, light.id, "clone id should differ from original" );
+	QUnit.assert.smartEqual( copy, light, "clone is equal to original" );
+
+
+	// json round trip with clone
+	checkLightJsonRoundtrip( copy );
+
+}
+
+// Compare json file with its source Light.
+function checkLightJsonWriting( light, json ) {
+
+	QUnit.assert.equal( json.metadata.version, "4.4", "check metadata version" );
+	QUnit.assert.equalKey( light, json, 'type' );
+	QUnit.assert.equalKey( light, json, 'uuid' );
+	QUnit.assert.equal( json.id, undefined, "should not persist id" );
+
+}
+
+// Check parsing and reconstruction of json Light
+function checkLightJsonReading( json, light ) {
+
+	var loader = new THREE.ObjectLoader();
+	var outputLight = loader.parse( json );
+
+	QUnit.assert.smartEqual( outputLight, light, 'Reconstruct Light from ObjectLoader' );
+
+}
+
+// Verify light -> json -> light
+function checkLightJsonRoundtrip( light ) {
+
+	var json = light.toJSON();
+	checkLightJsonWriting( light, json.object );
+	checkLightJsonReading( json, light );
+
+}
+

+ 6 - 0
test/unit/unittests_three.html

@@ -38,6 +38,12 @@
 
   <script src="geometry/EdgesGeometry.js"></script>
   <script src="extras/ImageUtils.test.js"></script>
+  <script src="lights/AmbientLight.tests.js"></script>
+  <script src="lights/AreaLight.tests.js"></script>
+  <script src="lights/DirectionalLight.tests.js"></script>
+  <script src="lights/HemisphereLight.tests.js"></script>
+  <script src="lights/PointLight.tests.js"></script>
+  <script src="lights/SpotLight.tests.js"></script>
 
   <script src="extras/geometries/BoxGeometry.tests.js"></script>
   <script src="extras/geometries/CircleBufferGeometry.tests.js"></script>

+ 4 - 4
utils/build/build.py

@@ -47,19 +47,19 @@ def main(argv=None):
 	sources = []
 		
 	if args.amd:
-		tmp.write('( 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')
 
 	for include in args.include:
 		with open('includes/' + include + '.json','r', encoding='utf-8') as f:
 			files = json.load(f)
 		for filename in files:
-			tmp.write('// File:' + filename)
+			tmp.write(u'// File:' + filename)
 			tmp.write(u'\n\n')
 			filename = '../../' + filename
 			sources.append(filename)
 			with open(filename, 'r', encoding='utf-8') as f:
 				if filename.endswith(".glsl"):
-					tmp.write('THREE.ShaderChunk[ \'' + os.path.splitext(os.path.basename(filename))[0] + '\'] = "')
+					tmp.write(u'THREE.ShaderChunk[ \'' + os.path.splitext(os.path.basename(filename))[0] + u'\'] = "')
 					tmp.write(f.read().replace('\n','\\n'))
 					tmp.write(u'";\n\n')
 				else:
@@ -67,7 +67,7 @@ def main(argv=None):
 					tmp.write(u'\n')
 
 	if args.amd:
-		tmp.write('exports.THREE = THREE;\n\n} ) );')
+		tmp.write(u'exports.THREE = THREE;\n\n} ) );')
 
 	tmp.close()
 

+ 5 - 0
utils/exporters/blender/README.md

@@ -8,6 +8,9 @@ The exporter (r69 and earlier) has been completely replaced. Please ensure you h
 
 ## Installation
 
+
+Recommended Blender version **>= 2.73.0**
+
 Copy the io_three folder to the scripts/addons folder. If it doesn't exist, create it. The full path is OS-dependent (see below).
 
 Once that is done, you need to activate the plugin. Open Blender preferences, look for
@@ -52,8 +55,10 @@ Activate the Import-Export addon under "User Preferences" > "Addons" and then us
 
 
 ## Enabling msgpack
+
 To enable msgpack compression copy the msgpack to scripts/modules.
 
 
 ## Importer
+
 Currently there is no import functionality available.

+ 1 - 1
utils/exporters/blender/addons/io_three/__init__.py

@@ -40,7 +40,7 @@ bl_info = {
     'name': "Three.js Format",
     'author': "repsac, mrdoob, yomotsu, mpk, jpweeks, rkusa, tschw",
     'version': (1, 4, 0),
-    'blender': (2, 7, 3),
+    'blender': (2, 73, 0),
     'location': "File > Export",
     'description': "Export Three.js formatted JSON files.",
     'warning': "Importer not included.",