COLLADA DAE 3D Model Format One file format for storing 3 D digital content is the open source COLLADA Collaborative Design Activity format Many popular modeling tools can read and modify COLLADA data including Blender Maya and SketchUp This format is based on XML Extensible Markup Language so applications need to parse XML to access COLLADA s vertex information This demo just focuses on fetching the file parsing the data xml and extracting the mesh data dae contents example just xml COLLADA library_geometries geometry mesh mesh geometry library_geometries COLLADA Mesh Every mesh element must contain one or more source elements that provide the raw data for an object s mesh The sphere dae file contains two source elements one containing vertex coordinates and one containing the normal vector at each vertex The structure of the first source element is given as follows source id ID5 float_array id ID8 count 798 5 551e 017 2 608 float_array technique_common accessor count 266 source ID8 stride 3 accessor technique_common source Vertices vertices id ID7 input semantic POSITION source ID5 input semantic NORMAL source ID6 vertices Indices triangles count 528 material Material2 input offset 0 semantic VERTEX source ID7 p 0 1 2 1 0 3 p triangles References Further Reading https en wikipedia org wiki COLLADA https www khronos org files collada_spec_1_5 pdf https www codeproject com Articles 625701 COLLADA TinyXML and OpenGL https docs fileformat com 3d dae Fetch 3d model in collada 3d file format dae extension Simply xml so can be parsed to extra useful information e g just the mesh data const daeurl https raw githubusercontent com mrdoob three js dev examples models collada elf elf dae let response await fetch daeurl let xmlraw await response text console log length xmlraw length let parser new DOMParser let xml parser parseFromString xmlraw text xml let root xml getRootNode console log xml root children 0 nodeName or console log collada xml getElementsByTagName COLLADA let mesh xml querySelector mesh console log mesh mesh let floatarray mesh querySelectorAll float_array console log floatarray floatarray length let vertices mesh querySelectorAll float_array 0 textContent split let normals mesh querySelectorAll float_array 1 textContent split let indicesList mesh querySelectorAll polylist p 0 textContent split console log vertices vertices length console log normals normals length console log indicesList indicesList length console log ready
ERTEX source ID7 p 0 1 2 1 0 3 p triangles References Further Reading https en wikipedia org wiki COLLADA https www khronos org files collada_spec_1_5 pdf https www codeproject com Articles 625701 COLLADA TinyXML and OpenGL https docs fileformat com 3d dae Fetch 3d model in collada 3d file format dae extension Simply xml so can be parsed to extra useful information e g just the mesh data const daeurl https raw githubusercontent com mrdoob three js dev examples models collada elf elf dae let response await fetch daeurl let xmlraw await response text console log length xmlraw length let parser new DOMParser let xml parser parseFromString xmlraw text xml let root xml getRootNode console log xml root children 0 nodeName or console log collada xml getElementsByTagName COLLADA let mesh xml querySelector mesh console log mesh mesh let floatarray mesh querySelectorAll float_array console log floatarray floatarray length let vertices mesh querySelectorAll float_array 0 textContent split let normals mesh querySelectorAll float_array 1 textContent split let indicesList mesh querySelectorAll polylist p 0 textContent split console log vertices vertices length console log normals normals length console log indicesList indicesList length console log ready