Browse Source

Added worker closing to JSON template in 3ds max exporter.

alteredq 14 years ago
parent
commit
bafa6ec100
1 changed files with 118 additions and 118 deletions
  1. 118 118
      utils/exporters/max/ThreeJSExporter.ms

+ 118 - 118
utils/exporters/max/ThreeJSExporter.ms

@@ -34,34 +34,34 @@ rollout ThreeJSExporter "ThreeJSExporter"
 	triNFormat = "%,%,%,%,%,%,%",
 	triNFormat = "%,%,%,%,%,%,%",
 	triUVNFormat = "%,%,%,%,%,%,%,%,%,%",
 	triUVNFormat = "%,%,%,%,%,%,%,%,%,%",
 
 
-	footerFormat = "}\n\npostMessage( model );"
+	footerFormat = "}\n\npostMessage( model );\nclose();"
 
 
 	-------------------------------------------------------------------------------------
 	-------------------------------------------------------------------------------------
 	-- User interface
 	-- User interface
 
 
 
 
-	group "ThreeJSExporter  v0.6"
+	group "ThreeJSExporter  v0.7"
 	(
 	(
 
 
 		label msg "Exports selected meshes in Three.js ascii JSON format" align:#left
 		label msg "Exports selected meshes in Three.js ascii JSON format" align:#left
 		hyperLink lab1 "Original source at GitHub" address:"https://github.com/alteredq/three.js/blob/master/utils/exporters/max/ThreeJSExporter.ms" color:(color 255 120 0) align:#left
 		hyperLink lab1 "Original source at GitHub" address:"https://github.com/alteredq/three.js/blob/master/utils/exporters/max/ThreeJSExporter.ms" color:(color 255 120 0) align:#left
 
 
 		label dummy1 "--------------------------------------------------------" align:#left
 		label dummy1 "--------------------------------------------------------" align:#left
-		
+
 		checkbox exportColor "Export vertex colors" checked:false enabled:true
 		checkbox exportColor "Export vertex colors" checked:false enabled:true
 		checkbox exportUv "Export uvs" checked:true enabled:true
 		checkbox exportUv "Export uvs" checked:true enabled:true
 		checkbox exportNormal "Export normals" checked:true enabled:true
 		checkbox exportNormal "Export normals" checked:true enabled:true
 		checkbox smoothNormal "Use vertex normals" checked:false enabled:true
 		checkbox smoothNormal "Use vertex normals" checked:false enabled:true
-		
+
 		label dummy2 "--------------------------------------------------------" align:#left
 		label dummy2 "--------------------------------------------------------" align:#left
-		
+
 		checkbox flipYZ "Flip YZ" checked:true enabled:true
 		checkbox flipYZ "Flip YZ" checked:true enabled:true
 		checkbox flipUV "Flip UV" checked:true enabled:true
 		checkbox flipUV "Flip UV" checked:true enabled:true
 		checkbox flipFace "Flip all faces" checked:false enabled:true
 		checkbox flipFace "Flip all faces" checked:false enabled:true
 		checkbox autoflipFace "Try fixing flipped faces" checked:false enabled:true
 		checkbox autoflipFace "Try fixing flipped faces" checked:false enabled:true
 
 
 		label dummy3 "--------------------------------------------------------" align:#left
 		label dummy3 "--------------------------------------------------------" align:#left
-		
+
 		button btn_export "Export selected objects"
 		button btn_export "Export selected objects"
 
 
 	)
 	)
@@ -70,7 +70,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 	-------------------------------------------------------------------------------------
 	-------------------------------------------------------------------------------------
 	-- Dump vertices
 	-- Dump vertices
 
 
-	function DumpVertices src = 
+	function DumpVertices src =
 	(
 	(
 
 
 		Format "\"vertices\": [" to:ostream
 		Format "\"vertices\": [" to:ostream
@@ -102,9 +102,9 @@ rollout ThreeJSExporter "ThreeJSExporter"
 					z = vert.z
 					z = vert.z
 
 
 				)
 				)
-				
+
 				Format vertexFormat x y z to:ostream
 				Format vertexFormat x y z to:ostream
-				
+
 				if i < num then Format "," to:ostream
 				if i < num then Format "," to:ostream
 
 
 			)
 			)
@@ -114,11 +114,11 @@ rollout ThreeJSExporter "ThreeJSExporter"
 		Format "],\n\n" to:ostream
 		Format "],\n\n" to:ostream
 
 
 	)
 	)
-	
+
 	-------------------------------------------------------------------------------------
 	-------------------------------------------------------------------------------------
 	-- Dump colors
 	-- Dump colors
 
 
-	function DumpColors src useColors = 
+	function DumpColors src useColors =
 	(
 	(
 
 
 		Format "\"colors\": [" to:ostream
 		Format "\"colors\": [" to:ostream
@@ -132,19 +132,19 @@ rollout ThreeJSExporter "ThreeJSExporter"
 			(
 			(
 
 
 				col = src[i]
 				col = src[i]
-				
+
 				r = col.r as Integer
 				r = col.r as Integer
 				g = col.g as Integer
 				g = col.g as Integer
 				b = col.b as Integer
 				b = col.b as Integer
-				
+
 				hexNum = ( bit.shift r 16 ) + ( bit.shift g 8 ) + b
 				hexNum = ( bit.shift r 16 ) + ( bit.shift g 8 ) + b
-				
+
 				-- hexColor = formattedPrint hexNum format:"#x"
 				-- hexColor = formattedPrint hexNum format:"#x"
 				-- Format "%" hexColor to:ostream
 				-- Format "%" hexColor to:ostream
 
 
 				decColor = formattedPrint hexNum format:"#d"
 				decColor = formattedPrint hexNum format:"#d"
 				Format "%" decColor to:ostream
 				Format "%" decColor to:ostream
-				
+
 				if i < num then Format "," to:ostream
 				if i < num then Format "," to:ostream
 
 
 			)
 			)
@@ -153,12 +153,12 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 
 		Format "],\n\n" to:ostream
 		Format "],\n\n" to:ostream
 
 
-	)	
+	)
 
 
 	-------------------------------------------------------------------------------------
 	-------------------------------------------------------------------------------------
 	-- Dump normals
 	-- Dump normals
 
 
-	function DumpNormals src = 
+	function DumpNormals src =
 	(
 	(
 
 
 		Format "\"normals\": [" to:ostream
 		Format "\"normals\": [" to:ostream
@@ -180,9 +180,9 @@ rollout ThreeJSExporter "ThreeJSExporter"
 					x = normal.x
 					x = normal.x
 					y = normal.z
 					y = normal.z
 					z = normal.y
 					z = normal.y
-					
+
 					z *= -1
 					z *= -1
-					
+
 				)
 				)
 				else
 				else
 				(
 				(
@@ -208,7 +208,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 	-------------------------------------------------------------------------------------
 	-------------------------------------------------------------------------------------
 	-- Dump uvs
 	-- Dump uvs
 
 
-	function DumpUvs src = 
+	function DumpUvs src =
 	(
 	(
 
 
 		Format "\"uvs\": [[" to:ostream
 		Format "\"uvs\": [[" to:ostream
@@ -225,7 +225,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 
 				u = uvw.x
 				u = uvw.x
 
 
-				if flipUV.checked then 
+				if flipUV.checked then
 				(
 				(
 					v = 1 - uvw.y
 					v = 1 - uvw.y
 				)
 				)
@@ -249,11 +249,11 @@ rollout ThreeJSExporter "ThreeJSExporter"
 	-------------------------------------------------------------------------------------
 	-------------------------------------------------------------------------------------
 	-- Dump faces
 	-- Dump faces
 
 
-	function DumpFaces src useColors = 
+	function DumpFaces src useColors =
 	(
 	(
 
 
 		Format "\"faces\": [" to:ostream
 		Format "\"faces\": [" to:ostream
-		
+
 		num = src.count
 		num = src.count
 
 
 		if num > 0 then
 		if num > 0 then
@@ -268,9 +268,9 @@ rollout ThreeJSExporter "ThreeJSExporter"
 				fuv = zface[2]
 				fuv = zface[2]
 				m   = zface[3] - 1
 				m   = zface[3] - 1
 				fc  = zface[4]
 				fc  = zface[4]
-				
+
 				needsFlip = zface[5]
 				needsFlip = zface[5]
-				
+
 				isTriangle = true
 				isTriangle = true
 				hasMaterial = true
 				hasMaterial = true
 				hasFaceUvs = false
 				hasFaceUvs = false
@@ -289,12 +289,12 @@ rollout ThreeJSExporter "ThreeJSExporter"
 				faceType = bit.set faceType 6 hasFaceVertexNormals
 				faceType = bit.set faceType 6 hasFaceVertexNormals
 				faceType = bit.set faceType 7 hasFaceColors
 				faceType = bit.set faceType 7 hasFaceColors
 				faceType = bit.set faceType 8 hasFaceVertexColors
 				faceType = bit.set faceType 8 hasFaceVertexColors
-				
+
 				if i > 1 then
 				if i > 1 then
 				(
 				(
 					Format "," faceType to:ostream
 					Format "," faceType to:ostream
 				)
 				)
-				
+
 				Format "%" faceType to:ostream
 				Format "%" faceType to:ostream
 
 
 				if isTriangle then
 				if isTriangle then
@@ -303,8 +303,8 @@ rollout ThreeJSExporter "ThreeJSExporter"
 					va = (fv.x - 1) as Integer
 					va = (fv.x - 1) as Integer
 					vb = (fv.y - 1) as Integer
 					vb = (fv.y - 1) as Integer
 					vc = (fv.z - 1) as Integer
 					vc = (fv.z - 1) as Integer
-					
-					if flipFace.checked or needsFlip then 
+
+					if flipFace.checked or needsFlip then
 					(
 					(
 
 
 						tmp = vb
 						tmp = vb
@@ -312,26 +312,26 @@ rollout ThreeJSExporter "ThreeJSExporter"
 						vc = tmp
 						vc = tmp
 
 
 					)
 					)
-					
-					
+
+
 					Format ",%,%,%" va vb vc to:ostream
 					Format ",%,%,%" va vb vc to:ostream
 
 
-				
-					if hasMaterial then 
+
+					if hasMaterial then
 					(
 					(
 
 
 						Format ",%" m to:ostream
 						Format ",%" m to:ostream
 
 
 					)
 					)
-					
+
 					if hasFaceVertexUvs then
 					if hasFaceVertexUvs then
 					(
 					(
 
 
 						ua = (fuv.x - 1) as Integer
 						ua = (fuv.x - 1) as Integer
 						ub = (fuv.y - 1) as Integer
 						ub = (fuv.y - 1) as Integer
 						uc = (fuv.z - 1) as Integer
 						uc = (fuv.z - 1) as Integer
-						
-						if flipFace.checked or needsFlip then 
+
+						if flipFace.checked or needsFlip then
 						(
 						(
 
 
 							tmp = ub
 							tmp = ub
@@ -339,15 +339,15 @@ rollout ThreeJSExporter "ThreeJSExporter"
 							uc = tmp
 							uc = tmp
 
 
 						)
 						)
-						
+
 						Format ",%,%,%" ua ub uc to:ostream
 						Format ",%,%,%" ua ub uc to:ostream
 
 
 					)
 					)
-				
+
 					if hasFaceVertexNormals then
 					if hasFaceVertexNormals then
 					(
 					(
 
 
-						if smoothNormal.checked then 
+						if smoothNormal.checked then
 						(
 						(
 
 
 							-- normals have the same indices as vertices
 							-- normals have the same indices as vertices
@@ -357,7 +357,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 							nc = vc
 							nc = vc
 
 
 						)
 						)
-						else 
+						else
 						(
 						(
 							-- normals have the same indices as face
 							-- normals have the same indices as face
 
 
@@ -366,8 +366,8 @@ rollout ThreeJSExporter "ThreeJSExporter"
 							nc = na
 							nc = na
 
 
 						)
 						)
-						
-						if flipFace.checked or needsFlip then 
+
+						if flipFace.checked or needsFlip then
 						(
 						(
 
 
 							tmp = nb
 							tmp = nb
@@ -375,20 +375,20 @@ rollout ThreeJSExporter "ThreeJSExporter"
 							nc = tmp
 							nc = tmp
 
 
 						)
 						)
-						
+
 						Format ",%,%,%" na nb nc to:ostream
 						Format ",%,%,%" na nb nc to:ostream
 
 
 					)
 					)
 
 
-				
+
 					if hasFaceVertexColors then
 					if hasFaceVertexColors then
 					(
 					(
 
 
 						ca = (fc.x - 1) as Integer
 						ca = (fc.x - 1) as Integer
 						cb = (fc.y - 1) as Integer
 						cb = (fc.y - 1) as Integer
 						cc = (fc.z - 1) as Integer
 						cc = (fc.z - 1) as Integer
-						
-						if flipFace.checked or needsFlip then 
+
+						if flipFace.checked or needsFlip then
 						(
 						(
 
 
 							tmp = cb
 							tmp = cb
@@ -396,13 +396,13 @@ rollout ThreeJSExporter "ThreeJSExporter"
 							cc = tmp
 							cc = tmp
 
 
 						)
 						)
-						
+
 						Format ",%,%,%" ca cb cc to:ostream
 						Format ",%,%,%" ca cb cc to:ostream
 
 
 					)
 					)
 
 
 				)
 				)
-				
+
 			)
 			)
 
 
 		)
 		)
@@ -414,7 +414,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 	-------------------------------------------------------------------------------------
 	-------------------------------------------------------------------------------------
 	-- Dump color
 	-- Dump color
 
 
-	function DumpColor pcolor label = 
+	function DumpColor pcolor label =
 	(
 	(
 		r = pcolor.r / 255
 		r = pcolor.r / 255
 		g = pcolor.g / 255
 		g = pcolor.g / 255
@@ -426,19 +426,19 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 
 		Format "\"%\"  : [%, %, %],\n" label fr fg fb to:ostream
 		Format "\"%\"  : [%, %, %],\n" label fr fg fb to:ostream
 
 
-	)	
+	)
 
 
 	-------------------------------------------------------------------------------------
 	-------------------------------------------------------------------------------------
 	-- Dump map
 	-- Dump map
 
 
-	function DumpMap pmap label = 
+	function DumpMap pmap label =
 	(
 	(
 
 
 		if classof pmap == BitmapTexture then
 		if classof pmap == BitmapTexture then
 		(
 		(
 			bm = pmap.bitmap
 			bm = pmap.bitmap
 
 
-			if bm != undefined then 
+			if bm != undefined then
 			(
 			(
 
 
 				fname = filenameFromPath bm.filename
 				fname = filenameFromPath bm.filename
@@ -453,7 +453,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 	-------------------------------------------------------------------------------------
 	-------------------------------------------------------------------------------------
 	-- Export materials
 	-- Export materials
 
 
-	function ExportMaterials zmaterials zcolors = 
+	function ExportMaterials zmaterials zcolors =
 	(
 	(
 
 
 		Format "\"materials\": [\n" to:ostream
 		Format "\"materials\": [\n" to:ostream
@@ -474,9 +474,9 @@ rollout ThreeJSExporter "ThreeJSExporter"
 			(
 			(
 
 
 				useVertexColors = zcolors[i]
 				useVertexColors = zcolors[i]
-				
+
 				Format "\"DbgName\"  : \"%\",\n" mat.name to:ostream
 				Format "\"DbgName\"  : \"%\",\n" mat.name to:ostream
-				
+
 				-- colors
 				-- colors
 
 
 				DumpColor mat.diffuse  "colorDiffuse"
 				DumpColor mat.diffuse  "colorDiffuse"
@@ -485,7 +485,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 
 				t = mat.opacity / 100
 				t = mat.opacity / 100
 				s = mat.glossiness
 				s = mat.glossiness
-				
+
 				Format "\"transparency\"  : %,\n" t to:ostream
 				Format "\"transparency\"  : %,\n" t to:ostream
 				Format "\"specularCoef\"  : %,\n" s to:ostream
 				Format "\"specularCoef\"  : %,\n" s to:ostream
 
 
@@ -498,24 +498,24 @@ rollout ThreeJSExporter "ThreeJSExporter"
 				DumpMap mat.opacityMap 	"mapAlpha"
 				DumpMap mat.opacityMap 	"mapAlpha"
 
 
 			)
 			)
-			else 
+			else
 			(
 			(
-				
+
 				useVertexColors = false
 				useVertexColors = false
-				
+
 				Format "\"DbgName\"  : \"%\",\n" "dummy" to:ostream
 				Format "\"DbgName\"  : \"%\",\n" "dummy" to:ostream
-				
+
 				DumpColor red "colorDiffuse"
 				DumpColor red "colorDiffuse"
-				
+
 			)
 			)
-				
+
 			Format "\"vertexColors\" : %\n" useVertexColors to:ostream
 			Format "\"vertexColors\" : %\n" useVertexColors to:ostream
 			Format "}" to:ostream
 			Format "}" to:ostream
 
 
 			if ( i < totalMaterials ) then Format "," to:ostream
 			if ( i < totalMaterials ) then Format "," to:ostream
 			Format "\n\n" to:ostream
 			Format "\n\n" to:ostream
 
 
-		)		
+		)
 
 
 		Format "],\n\n" to:ostream
 		Format "],\n\n" to:ostream
 
 
@@ -546,7 +546,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 	(
 	(
 
 
 		nColors = GetNumCPVVerts obj
 		nColors = GetNumCPVVerts obj
-		
+
 		if nColors > 0 then
 		if nColors > 0 then
 		(
 		(
 
 
@@ -573,8 +573,8 @@ rollout ThreeJSExporter "ThreeJSExporter"
 		(
 		(
 
 
 			num = obj.numVerts
 			num = obj.numVerts
-			
-			for i = 1 to num do 
+
+			for i = 1 to num do
 			(
 			(
 
 
 				n = GetNormal obj i
 				n = GetNormal obj i
@@ -596,7 +596,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 
 			num = obj.numFaces
 			num = obj.numFaces
 
 
-			for i = 1 to num do 
+			for i = 1 to num do
 			(
 			(
 
 
 				n = GetFaceNormal obj i
 				n = GetFaceNormal obj i
@@ -622,8 +622,8 @@ rollout ThreeJSExporter "ThreeJSExporter"
 	function ExtractUvs obj whereto =
 	function ExtractUvs obj whereto =
 	(
 	(
 		n = obj.numTVerts
 		n = obj.numTVerts
-		
-		for i = 1 to n do 
+
+		for i = 1 to n do
 		(
 		(
 
 
 			v = GetTVert obj i
 			v = GetTVert obj i
@@ -643,10 +643,10 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 
 		useMultiMaterial = false
 		useMultiMaterial = false
 		materialIDList = #()
 		materialIDList = #()
-		
+
 		materialClass = classof objMaterial
 		materialClass = classof objMaterial
-		
-		if materialClass == StandardMaterial then 
+
+		if materialClass == StandardMaterial then
 		(
 		(
 
 
 			fm = findItem allMaterials objMaterial
 			fm = findItem allMaterials objMaterial
@@ -657,12 +657,12 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 
 			useMultiMaterial = true
 			useMultiMaterial = true
 
 
-			for i = 1 to n do 
+			for i = 1 to n do
 			(
 			(
 
 
 				mID = GetFaceMatID objMesh i
 				mID = GetFaceMatID objMesh i
 				materialIndex = findItem objMaterial.materialIDList mID
 				materialIndex = findItem objMaterial.materialIDList mID
-				
+
 				if materialIndex > 0 then
 				if materialIndex > 0 then
 				(
 				(
 
 
@@ -670,7 +670,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 
 					mMergedIndex = findItem allMaterials subMaterial
 					mMergedIndex = findItem allMaterials subMaterial
 
 
-					if mMergedIndex > 0 then 
+					if mMergedIndex > 0 then
 					(
 					(
 
 
 						materialIDList[mID] = mMergedIndex
 						materialIDList[mID] = mMergedIndex
@@ -696,29 +696,29 @@ rollout ThreeJSExporter "ThreeJSExporter"
 		)
 		)
 		else
 		else
 		(
 		(
-			
+
 			-- undefined material
 			-- undefined material
-			
+
 			fm = findItem allMaterials false
 			fm = findItem allMaterials false
-			
+
 		)
 		)
-		
-		for i = 1 to n do 
+
+		for i = 1 to n do
 		(
 		(
 
 
 			zface = #()
 			zface = #()
-			
+
 			fv = GetFace objMesh i
 			fv = GetFace objMesh i
 
 
 			fv.x += offsetVert
 			fv.x += offsetVert
 			fv.y += offsetVert
 			fv.y += offsetVert
 			fv.z += offsetVert
 			fv.z += offsetVert
 
 
-			if useMultiMaterial then 
+			if useMultiMaterial then
 			(
 			(
 
 
 				mID = GetFaceMatID objMesh i
 				mID = GetFaceMatID objMesh i
-				fm = materialIDList[mID]				
+				fm = materialIDList[mID]
 
 
 			)
 			)
 
 
@@ -726,7 +726,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 			(
 			(
 
 
 				fuv = GetTVFace objMesh i
 				fuv = GetTVFace objMesh i
-				
+
 				fuv.x += offsetUv
 				fuv.x += offsetUv
 				fuv.y += offsetUv
 				fuv.y += offsetUv
 				fuv.z += offsetUv
 				fuv.z += offsetUv
@@ -738,12 +738,12 @@ rollout ThreeJSExporter "ThreeJSExporter"
 				fuv = false
 				fuv = false
 
 
 			)
 			)
-			
+
 			if hasVColors then
 			if hasVColors then
 			(
 			(
 
 
 				fc = GetVCFace objMesh i
 				fc = GetVCFace objMesh i
-				
+
 				fc.x += offsetColor
 				fc.x += offsetColor
 				fc.y += offsetColor
 				fc.y += offsetColor
 				fc.z += offsetColor
 				fc.z += offsetColor
@@ -756,7 +756,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 
 			)
 			)
 
 
-			append zface fv 
+			append zface fv
 			append zface fuv
 			append zface fuv
 			append zface fm
 			append zface fm
 			append zface fc
 			append zface fc
@@ -770,10 +770,10 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 
 	-------------------------------------------------------------------------------------
 	-------------------------------------------------------------------------------------
 	-- Extract materials from eventual multi-material
 	-- Extract materials from eventual multi-material
-	
+
 	function ExtractMaterials objMesh objMaterial whereto wheretoColors zname hasVColors =
 	function ExtractMaterials objMesh objMaterial whereto wheretoColors zname hasVColors =
 	(
 	(
-		
+
 		materialClass = classof objMaterial
 		materialClass = classof objMaterial
 
 
 		if materialClass == StandardMaterial then
 		if materialClass == StandardMaterial then
@@ -792,13 +792,13 @@ rollout ThreeJSExporter "ThreeJSExporter"
 		(
 		(
 
 
 			n = objMesh.numFaces
 			n = objMesh.numFaces
-			
-			for i = 1 to n do 
+
+			for i = 1 to n do
 			(
 			(
-			
+
 				mID = getFaceMatId objMesh i
 				mID = getFaceMatId objMesh i
 				materialIndex = findItem objMaterial.materialIDList mID
 				materialIndex = findItem objMaterial.materialIDList mID
-				
+
 				if materialIndex > 0 then
 				if materialIndex > 0 then
 				(
 				(
 
 
@@ -812,16 +812,16 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 
 					)
 					)
 
 
-				)				
+				)
 
 
 			)
 			)
 
 
 		)
 		)
 		else
 		else
 		(
 		(
-			
+
 			-- unknown or undefined material
 			-- unknown or undefined material
-			
+
 			append whereto false
 			append whereto false
 			append wheretoColors false
 			append wheretoColors false
 
 
@@ -831,8 +831,8 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 
 	-------------------------------------------------------------------------------------
 	-------------------------------------------------------------------------------------
 	-- Hack to figure out if normals are messed up
 	-- Hack to figure out if normals are messed up
-	
-	function NeedsFaceFlip node = 
+
+	function NeedsFaceFlip node =
 	(
 	(
 		needsFlip = false
 		needsFlip = false
 
 
@@ -865,29 +865,29 @@ rollout ThreeJSExporter "ThreeJSExporter"
 		(
 		(
 			needsFlip = false
 			needsFlip = false
 			hasVColors = false
 			hasVColors = false
-			
+
 			zmesh = SnapshotAsMesh node
 			zmesh = SnapshotAsMesh node
-			
+
 			if autoflipFace.checked then
 			if autoflipFace.checked then
 			(
 			(
 
 
 				needsFlip = NeedsFaceFlip node
 				needsFlip = NeedsFaceFlip node
 
 
 			)
 			)
-			
+
 			if exportColor.checked and ( getNumCPVVerts zmesh ) > 0 then
 			if exportColor.checked and ( getNumCPVVerts zmesh ) > 0 then
 			(
 			(
 
 
 				hasVColors = true
 				hasVColors = true
 
 
 			)
 			)
-			
+
 			return #( zmesh, node.name, node.material, needsFlip, hasVColors )
 			return #( zmesh, node.name, node.material, needsFlip, hasVColors )
 
 
 		)
 		)
 
 
 		-- Not geometry ... could be a camera, light, etc.
 		-- Not geometry ... could be a camera, light, etc.
-		
+
 		return #( false, node.name, 0, false, false )
 		return #( false, node.name, 0, false, false )
 
 
 	)
 	)
@@ -905,31 +905,31 @@ rollout ThreeJSExporter "ThreeJSExporter"
 		mergedVertices = #()
 		mergedVertices = #()
 		mergedNormals = #()
 		mergedNormals = #()
 		mergedColors = #()
 		mergedColors = #()
-		
+
 		mergedUvs = #()
 		mergedUvs = #()
 		mergedFaces = #()
 		mergedFaces = #()
-		
+
 		mergedMaterials = #()
 		mergedMaterials = #()
 		mergedMaterialsColors = #()
 		mergedMaterialsColors = #()
-		
+
 		sceneHasVColors = false
 		sceneHasVColors = false
-		
-		for obj in selection do 
+
+		for obj in selection do
 		(
 		(
 
 
 			result = ExtractMesh obj
 			result = ExtractMesh obj
 			meshObj = result[1]
 			meshObj = result[1]
 
 
-			if ClassOf meshObj == TriMesh then 
+			if ClassOf meshObj == TriMesh then
 			(
 			(
 
 
 				meshName     = result[2]
 				meshName     = result[2]
 				meshMaterial = result[3]
 				meshMaterial = result[3]
 				needsFlip    = result[4]
 				needsFlip    = result[4]
 				hasVColors   = result[5]
 				hasVColors   = result[5]
-				
+
 				sceneHasVColors = sceneHasVColors or hasVColors
 				sceneHasVColors = sceneHasVColors or hasVColors
-				
+
 				append meshObjects result
 				append meshObjects result
 
 
 				vertexOffset = mergedVertices.count
 				vertexOffset = mergedVertices.count
@@ -941,7 +941,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 				ExtractVertices meshObj mergedVertices
 				ExtractVertices meshObj mergedVertices
 				ExtractNormals meshObj mergedNormals needsFlip
 				ExtractNormals meshObj mergedNormals needsFlip
 				ExtractColors meshObj mergedColors
 				ExtractColors meshObj mergedColors
-				
+
 				ExtractUvs meshObj mergedUvs
 				ExtractUvs meshObj mergedUvs
 
 
 				ExtractFaces meshObj meshMaterial mergedFaces mergedMaterials needsFlip hasVColors vertexOffset uvOffset colorOffset
 				ExtractFaces meshObj meshMaterial mergedFaces mergedMaterials needsFlip hasVColors vertexOffset uvOffset colorOffset
@@ -953,13 +953,13 @@ rollout ThreeJSExporter "ThreeJSExporter"
 		totalVertices = mergedVertices.count
 		totalVertices = mergedVertices.count
 		totalFaces = mergedFaces.count
 		totalFaces = mergedFaces.count
 		totalMaterials = mergedMaterials.count
 		totalMaterials = mergedMaterials.count
-		
+
 		totalColors = 0
 		totalColors = 0
 		totalNormals = 0
 		totalNormals = 0
 		totalUvs = 0
 		totalUvs = 0
-		
+
 		useColors = false
 		useColors = false
-		
+
 		if sceneHasVColors and exportColor.checked then
 		if sceneHasVColors and exportColor.checked then
 		(
 		(
 
 
@@ -968,7 +968,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 
 		)
 		)
 
 
-		if exportNormal.checked then 
+		if exportNormal.checked then
 		(
 		(
 
 
 			totalNormals = mergedNormals.count
 			totalNormals = mergedNormals.count
@@ -993,7 +993,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 
 		i = 0
 		i = 0
 
 
-		for obj in meshObjects do 
+		for obj in meshObjects do
 		(
 		(
 
 
 			meshName = obj[2]
 			meshName = obj[2]
@@ -1070,5 +1070,5 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 
 	)
 	)
 
 
-) 
+)
 createDialog ThreeJSExporter width:300
 createDialog ThreeJSExporter width:300