Pārlūkot izejas kodu

Added to scene loader support for Icosahedron primitive and material shading parameter.

alteredq 14 gadi atpakaļ
vecāks
revīzija
7bd3c4b7e0

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 127 - 126
build/ThreeExtras.js


+ 22 - 2
examples/scenes/test_scene.js

@@ -29,10 +29,20 @@ var scene = {
 		"visible"  : true
 	},
 
+	"icosahedron" : {
+		"geometry" : "icosahedron",
+		"materials": [ "faceted_white" ],
+		"position" : [ 20, 10, -60 ],
+		"rotation" : [ 0, 0, 0 ],
+		"scale"	   : [ 20, 20, 20 ],
+		"visible"  : true
+	},
+
+
 	"torus" : {
 		"geometry" : "torus",
 		"materials": [ "phong_orange" ],
-		"position" : [ 0, 5, -50 ],
+		"position" : [ -20, 5, -50 ],
 		"rotation" : [ 0, 0, 0 ],
 		"scale"	   : [ 2, 2, 2 ],
 		"visible"  : true
@@ -112,7 +122,12 @@ var scene = {
 		"segments_width"  : 32, 
 		"segments_height" : 16
 	},
- 
+
+	"icosahedron": {
+		"type"    : "icosahedron",
+		"subdivisions"  : 2
+	},
+	
 	"torus": {
 		"type"    : "torus",
 		"radius"  : 5,
@@ -180,6 +195,11 @@ var scene = {
 		"type": "MeshBasicMaterial",
 		"parameters": { color: 0xffffff, wireframe: true } 
 	},
+
+	"faceted_white": {
+		"type": "MeshLambertMaterial",
+		"parameters": { color: 0xffffff, shading: "flat" } 
+	},
 	
 	"basic_blue": {
 		"type": "MeshBasicMaterial",

+ 9 - 0
src/extras/SceneUtils.js

@@ -137,6 +137,11 @@ var SceneUtils = {
 					
 					geometry = new Torus( g.radius, g.tube, g.segmentsR, g.segmentsT );
 					result.geometries[ dg ] = geometry;
+
+				} else if ( g.type == "icosahedron" ) {
+					
+					geometry = new Icosahedron( g.subdivisions );
+					result.geometries[ dg ] = geometry;
 					
 				} else if ( g.type == "bin_mesh" ) {
 					
@@ -188,6 +193,10 @@ var SceneUtils = {
 						
 						m.parameters[ pp ] = result.textures[ m.parameters[ pp ] ];
 						
+					} else if ( pp == "shading" ) {
+						
+						m.parameters[ pp ] = ( m.parameters[ pp ] == "flat" ) ? THREE.FlatShading : THREE.SmoothShading;
+						
 					}
 					
 				}

+ 1 - 1
src/extras/primitives/Icosahedron.js

@@ -5,7 +5,7 @@
  * so it draws the entire texture on the seam-faces, I think...
  */
 
-var Icosahedron = function (subdivisions) {
+var Icosahedron = function ( subdivisions ) {
 
 	var scope = this;
 	var tempScope = new THREE.Geometry();

+ 1 - 0
utils/build.py

@@ -82,6 +82,7 @@ EXTRAS_FILES = [
 'extras/primitives/Plane.js',
 'extras/primitives/Sphere.js',
 'extras/primitives/Torus.js',
+'extras/primitives/Icosahedron.js',
 'extras/primitives/LathedObject.js',
 'extras/io/Loader.js'
 ]

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels