Function to load ASE file function loadASEFile fileData Split file data into lines const lines fileData split n Initialize variables to store parsed data let vertices let faces let currentMaterial null let materials textureCoords Loop through each line in the file for let i 0 i lines length i const line lines i trim console log line line Skip comments if line startsWith continue Check for material definition if line startsWith MATERIAL Extract material name const materialName line split 1 Create new material object currentMaterial name materialName faces Push material object to materials array materials push currentMaterial Check for vertex definition if line startsWith MESH_VERTEX Extract vertex data const index x y z line split Push vertex data to vertices array vertices push x parseFloat x y parseFloat y z parseFloat z Check for face definition if line startsWith MESH_FACE Extract face data const v1 v2 v3 line split Push face data to faces array faces push v1 parseInt v1 v2 parseInt v2 v3 parseInt v3 material currentMaterial Store face in current material currentMaterial faces push faces length 1 Check for texture coordinate definition if line startsWith MESH_TVERT Extract texture coordinate data const index u v w line split Push texture coordinate data to textureCoords array textureCoords push u parseFloat u v parseFloat v w parseFloat w Check for face definition if line startsWith MESH_FACE Extract face data const v1 v2 v3 line split Push face data to faces array faces push v1 parseInt v1 v2 parseInt v2 v3 parseInt v3 material currentMaterial Store face in current material currentMaterial faces push faces length 1 Return parsed data return vertices faces Example usage const aseData 3DSMAX_ASCIIEXPORT 200 COMMENT Generated by 3ds Max SCENE SCENE_FILENAME Untitled max SCENE_FIRSTFRAME 0 SCENE_LASTFRAME 100 SCENE_FRAMESPEED 30 SCENE_TICKSPERFRAME 160 SCENE_BACKGROUND_STATIC 0 0000 0 0000 0 0000 SCENE_AMBIENT_STATIC 0 0000 0 0000 0 0000 SCENE_AMBIENT_ANIM 0 0000 0 0000 0 0000 MATERIAL_LIST MATERIAL_COUNT 1 MATERIAL 0 MATERIAL_NAME Material 2 MATERIAL_CLASS Standard MATERIAL_DIFFUSE 0 8000 0 8000 0 8000 MATERIAL_SPECULAR 0 0000 0 0000 0 0000 MATERIAL_SHINE 0 0000 MATERIAL_SHINESTRENGTH 0 0000 MATERIAL_TRANSPARENCY 0 0000 MATERIAL_WIRESIZE 1 0000 MATERIAL_SHADING Blinn MATERIAL_XP_FALLOFF 0 0000 0 0000 MATERIAL_SELFILLUM 0 0000 MATERIAL_FALLOFF In MATERIAL_XP_TYPE Filter MATERIAL_COLOR 0 5882 0 5882 0 5882 MATERIAL_MAP_DIFFUSE MAP_NAME MAP_CLASS Bitmap MAP_SUBNO 1 MAP_AMOUNT 1 0000 BITMAP texture jpg MESH Box01 MESH_VERTEX_LIST MESH_VERTEX 0 1 0000 1 0000 0 0000 MESH_VERTEX 1 1 0000 1 0000 0 0000 MESH_VERTEX 2 1 0000 1 0000 0 0000 MESH_VERTEX 3 1 0000 1 0000 0 0000 MESH_VERTEX 4 1 0000 1 0000 2 0000 MESH_VERTEX 5 1 0000 1 0000 2 0000 MESH_VERTEX 6 1 0000 1 0000 2 0000 MESH_VERTEX 7 1 0000 1 0000 2 0000 MESH_FACE_LIST MESH_FACE 0 A 0 B 1 C 2 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 1 A 2 B 3 C 0 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 2 A 4 B 5 C 6 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 3 A 6 B 7 C 4 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 4 A 0 B 4 C 7 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 5 A 7 B 3 C 0 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 6 A 1 B 5 C 6 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 7 A 6 B 2 C 1 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 8 A 0 B 4 C 5 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 9 A 5 B 1 C 0 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 10 A 3 B 7 C 6 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 11 A 6 B 2 C 3 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_NUMTVERTEX 4 MESH_TVERTLIST MESH_TVERT 0 0 0 0 0 0 0 MESH_TVERT 1 1 0 0 0 0 0 MESH_TVERT 2 1 0 1 0 0 0 MESH_TVERT 3 0 0 1 0 0 0 let ase loadASEFile aseData console log ase vertices length console log ase faces length
Return parsed data return vertices faces Example usage const aseData 3DSMAX_ASCIIEXPORT 200 COMMENT Generated by 3ds Max SCENE SCENE_FILENAME Untitled max SCENE_FIRSTFRAME 0 SCENE_LASTFRAME 100 SCENE_FRAMESPEED 30 SCENE_TICKSPERFRAME 160 SCENE_BACKGROUND_STATIC 0 0000 0 0000 0 0000 SCENE_AMBIENT_STATIC 0 0000 0 0000 0 0000 SCENE_AMBIENT_ANIM 0 0000 0 0000 0 0000 MATERIAL_LIST MATERIAL_COUNT 1 MATERIAL 0 MATERIAL_NAME Material 2 MATERIAL_CLASS Standard MATERIAL_DIFFUSE 0 8000 0 8000 0 8000 MATERIAL_SPECULAR 0 0000 0 0000 0 0000 MATERIAL_SHINE 0 0000 MATERIAL_SHINESTRENGTH 0 0000 MATERIAL_TRANSPARENCY 0 0000 MATERIAL_WIRESIZE 1 0000 MATERIAL_SHADING Blinn MATERIAL_XP_FALLOFF 0 0000 0 0000 MATERIAL_SELFILLUM 0 0000 MATERIAL_FALLOFF In MATERIAL_XP_TYPE Filter MATERIAL_COLOR 0 5882 0 5882 0 5882 MATERIAL_MAP_DIFFUSE MAP_NAME MAP_CLASS Bitmap MAP_SUBNO 1 MAP_AMOUNT 1 0000 BITMAP texture jpg MESH Box01 MESH_VERTEX_LIST MESH_VERTEX 0 1 0000 1 0000 0 0000 MESH_VERTEX 1 1 0000 1 0000 0 0000 MESH_VERTEX 2 1 0000 1 0000 0 0000 MESH_VERTEX 3 1 0000 1 0000 0 0000 MESH_VERTEX 4 1 0000 1 0000 2 0000 MESH_VERTEX 5 1 0000 1 0000 2 0000 MESH_VERTEX 6 1 0000 1 0000 2 0000 MESH_VERTEX 7 1 0000 1 0000 2 0000 MESH_FACE_LIST MESH_FACE 0 A 0 B 1 C 2 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 1 A 2 B 3 C 0 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 2 A 4 B 5 C 6 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 3 A 6 B 7 C 4 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 4 A 0 B 4 C 7 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 5 A 7 B 3 C 0 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 6 A 1 B 5 C 6 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 7 A 6 B 2 C 1 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 8 A 0 B 4 C 5 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 9 A 5 B 1 C 0 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 10 A 3 B 7 C 6 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_FACE 11 A 6 B 2 C 3 AB 1 BC 1 CA 1 MESH_SMOOTHING 1 MESH_MTLID 0 MESH_NUMTVERTEX 4 MESH_TVERTLIST MESH_TVERT 0 0 0 0 0 0 0 MESH_TVERT 1 1 0 0 0 0 0 MESH_TVERT 2 1 0 1 0 0 0 MESH_TVERT 3 0 0 1 0 0 0 let ase loadASEFile aseData console log ase vertices length console log ase faces length