 			mesh: "meshes/#{data.Name}.mesh"
 
 
+convertRotation = (matrix) ->
+	#Taken and rewritten from Matrix3x3.toAngles
+	EPSILON = 0.0000001
+	result = []
+	if (matrix[3] > 1 - EPSILON)  # singularity at north pole
+		result[1] = Math.atan2(matrix[2], matrix[8])
+		result[2] = Math.PI / 2
+		result[0] = 0
+	else if (matrix[3] < -1 + EPSILON) # singularity at south pole
+		result[1] = Math.atan2(matrix[2], matrix[8])
+		result[2] = -Math.PI / 2
+		result[0] = 0
+	else
+		result[1] = Math.atan2(-matrix[2], matrix[0])
+		result[0] = Math.atan2(-matrix[7], matrix[4])
+		result[2] = Math.asin(matrix[1])
+		
+	return result
+
+
 convertChildren = (children, parent, entities, compression) ->
 	for child in children
 		entity =

			components:
				transform:
					translation: child.Transform.Translation
					rotation: child.Transform.Rotation
					scale: child.Transform.Scale
			
		if child.Material?
			_.extend entity.components,
				meshRenderer:

			transform:
				translation: transform.Translation
				scale: transform.Scale
				rotation: convertRotation transform.Rotation
				
	entities.push rootObject
	
