How to access the list of vertices and triangular faces in the following code?

I would like to basically know how do I access the list of vertices and triangular faces from the scene of gltf file. What I have currently is this.

return from(fetch(targetUrl.toString(), {
                method: 'GET',
                headers: {
                  'Content-Type': 'application/json'
                }
              }).then(response => {
                  response.arrayBuffer()
                    .then(data => {
                      const loader = new GLTFLoader();
                      loader.parse(data, "", gltf => {
                        this.scene.add(gltf.scene);
                      })
                    })
                })).pipe(
                    map((surfaceMesh) => {
                        this.surfaceMeshes.set(surfaceMeshKey, surfaceMesh);
                    }
                ))
        }  

I would like to have the array of vertices and triangular faces in this regard, not the count! Can somebody please help me out in this case?

Look at

scene.children.$MESH.geometry.attributes.position.array[] for the vertex positions, and
scene.children.$MESH.index.array[] for the triangle definitions

1 Like