Parcourir la source

Added support for material blending parameter to scene loader.

alteredq il y a 14 ans
Parent
commit
feed283804

Fichier diff supprimé car celui-ci est trop grand
+ 5 - 5
build/ThreeExtras.js


+ 1 - 1
examples/scenes/test_scene.js

@@ -255,7 +255,7 @@ var scene = {
 	
 	"lambert_green": {
 		"type": "MeshLambertMaterial",
-		"parameters": { color: 0x007711 } 
+		"parameters": { color: 0x007711, blending: "AdditiveBlending" } 
 	},
 
 	"lambert_blue": {

+ 4 - 0
src/extras/SceneUtils.js

@@ -369,6 +369,10 @@ var SceneUtils = {
 						
 						m.parameters[ pp ] = ( m.parameters[ pp ] == "flat" ) ? THREE.FlatShading : THREE.SmoothShading;
 						
+					} else if ( pp == "blending" ) {
+						
+						m.parameters[ pp ] = THREE[ m.parameters[ pp ] ] ? THREE[ m.parameters[ pp ] ] : THREE.NormalBlending;
+						
 					} else if ( pp == "combine" ) {
 						
 						m.parameters[ pp ] = ( m.parameters[ pp ] == "MixOperation" ) ? THREE.MixOperation : THREE.MultiplyOperation;

+ 34 - 30
utils/exporters/fbx/convert_fbx_three.py

@@ -238,28 +238,28 @@ TEMPLATE_MATERIAL_SCENE = """\
     }"""
 
 TEMPLATE_CAMERA_PERSPECTIVE = """\
-	%(camera_id)s : {
-		"type"  : "perspective",
-		"fov"   : %(fov)f,
-		"aspect": %(aspect)f,
-		"near"  : %(near)f,
-		"far"   : %(far)f,
-		"position": %(position)s,
-		"target"  : %(target)s
-	}"""
+    %(camera_id)s : {
+        "type"  : "perspective",
+        "fov"   : %(fov)f,
+        "aspect": %(aspect)f,
+        "near"  : %(near)f,
+        "far"   : %(far)f,
+        "position": %(position)s,
+        "target"  : %(target)s
+    }"""
 
 TEMPLATE_CAMERA_ORTHO = """\
-	%(camera_id)s: {
-		"type"  : "ortho",
-		"left"  : %(left)f,
-		"right" : %(right)f,
-		"top"   : %(top)f,
-		"bottom": %(bottom)f,
-		"near"  : %(near)f,
-		"far"   : %(far)f,
-		"position": %(position)s,
-		"target"  : %(target)s
-	}"""
+    %(camera_id)s: {
+        "type"  : "ortho",
+        "left"  : %(left)f,
+        "right" : %(right)f,
+        "top"   : %(top)f,
+        "bottom": %(bottom)f,
+        "near"  : %(near)f,
+        "far"   : %(far)f,
+        "position": %(position)s,
+        "target"  : %(target)s
+    }"""
 
 TEMPLATE_VEC3 = '[ %f, %f, %f ]'  
 TEMPLATE_VEC2 = '[ %f, %f ]'  
@@ -1458,9 +1458,13 @@ def generate_ascii_model(data):
         
         vertex_index = indices_vertex[vi]
         
+        material_index = 0
+        if vi < len(data["faces"]["indices_material"][0]):
+            material_index = data["faces"]["indices_material"][0][vi]
+            
         face = {
         'vertex'   : vertex_index,
-        'material' : data["faces"]["indices_material"][0][vi]
+        'material' : material_index
         }
     
         if normals:
@@ -1534,15 +1538,15 @@ def generate_ascii_model(data):
 # Helpers
 # #####################################################
 def sanitize(text):
-	chunks = []
-	for ch in text:
-		if ch in (string.ascii_letters + string.digits + "_."):
-			chunks.append(ch)
-		else:
-			chunks.append("_")
-			
-	return "".join(chunks)
-	
+    chunks = []
+    for ch in text:
+        if ch in (string.ascii_letters + string.digits + "_."):
+            chunks.append(ch)
+        else:
+            chunks.append("_")
+            
+    return "".join(chunks)
+    
 def base_filename(path):
     return os.path.basename(path)
     

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff