# Have an error when I want to use array of vertexDataArray\[i\].applyToMesh(customMeshArr\[i\])

**URL:** <https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372>\
**Category:** Questions\
**Tags:** material\
**Created:** [September 23, 2020, 11:17am UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372 "2020-09-23T11:17:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [September 23, 2020, 11:17am UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372/1 "2020-09-23T11:17:35Z")

</div>

Hello everyone

I want to build the following model:

 ![image_2020_09_16T14_20_09_342Z](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/e/ecac38605e14177373d67f732ae24ad522eb59fa.png)

and I have Geojson file as an input data which consists of coordinates.

I have make an arrays of vertex data, indices and positions.  
when I wanted to set vertexDataArray[i].applyToMesh(customMeshArr[i]) in the for loop, I have got 250 error, Is it possible to help me know how should I set vertexDataArray[i].applyToMesh(customMeshArr[i])

this is my PG for a tiny section of my Geojson:

[https://www.babylonjs-playground.com/#VKBJN#923](https://www.babylonjs-playground.com/#VKBJN#923)

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [September 23, 2020, 2:03pm UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372/2 "2020-09-23T14:03:35Z")

</div>

You should have a look at this doc: [Create Custom Meshes - Babylon.js Documentation](https://doc.babylonjs.com/how_to/custom) as it details the procedure for this.

I am not seeing the errors in the log

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [September 23, 2020, 3:14pm UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372/3 "2020-09-23T15:14:59Z")

</div>

![Screen Shot 1399-07-02 at 18.43.51](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/9/93fb254a828e795fa195f1bae7802a48fe62fcf2.png)

these are the errors in my console.

I have read the documentation but there is not any example same as my problem

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [September 23, 2020, 3:43pm UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372/4 "2020-09-23T15:43:08Z")

</div>

I see no error as well

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/3/384e8fdf1634909089351e6462650b0319440df6.png)

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [September 23, 2020, 3:51pm UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372/5 "2020-09-23T15:51:45Z")

</div>

Hi , I have solve it , The problem was indices and I should divided them by 3, and now I face to another problem.

I didn’t have any triangle : [https://www.babylonjs-playground.com/#VKBJN#923](https://www.babylonjs-playground.com/#VKBJN#923)

and I don’t understand what is my mistake.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [September 23, 2020, 3:59pm UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372/6 "2020-09-23T15:59:14Z")

</div>

I see triangles but I guess this is not what you expect:  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/7/7b6d3544d52460518041124f0af6e3a2309ba886.png)

What do you expect?

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [September 23, 2020, 4:00pm UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372/7 "2020-09-23T16:00:14Z")

</div>

how did you get that angle?  
i think if I got that angle I can got the model  
because I can not see even this triangle.

and the positions array in the PG is just a tiny part of original Geojson

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [September 23, 2020, 6:33pm UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372/8 "2020-09-23T18:33:36Z")

</div>

how can I rotate my model to get this ?

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [September 23, 2020, 7:33pm UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372/9 "2020-09-23T19:33:35Z")

</div>

i just rotated the camera 🙂

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [September 23, 2020, 7:40pm UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372/10 "2020-09-23T19:40:37Z")

</div>

I rotate it But always I got the just line

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [September 23, 2020, 7:44pm UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372/11 "2020-09-23T19:44:37Z")

</div>

well I rotate it a bit 🙂

 ![temp](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/6/6beb72c2c472028af7067d0075cadf993bbd1fd9.gif)

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [September 23, 2020, 7:51pm UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372/12 "2020-09-23T19:51:33Z")

</div>

Thanks a lot for your screen recording 🙏🏻 🙏🏻

again with the Original Geojson I couldn’t get the model, what is wrong in my code?

this is the model that I should build with Geojson, is it other way to build it?

 ![image_2020_09_16T14_20_09_342Z](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/e/ecac38605e14177373d67f732ae24ad522eb59fa.png)

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [September 23, 2020, 8:19pm UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372/13 "2020-09-23T20:19:39Z")

</div>

Are you sure your data contains triangle lists? maybe they are triangle fans

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [September 23, 2020, 8:22pm UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372/14 "2020-09-23T20:22:14Z")

</div>

what is Triangle fans?

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [September 23, 2020, 8:26pm UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372/16 "2020-09-23T20:26:27Z")

</div>

The question you have to answer if that: is each face made of 3 vertex OR are they packed in a triangle fan fashion:

> **[Triangle fan](https://en.wikipedia.org/wiki/Triangle_fan)**
>
> A triangle fan is a primitive in 3D computer graphics that saves on storage and processing time. It describes a set of connected triangles that share one central vertex (unlike the triangle strip that connects the next vertex point to the last two used vertices to form a triangle). If N is the number of triangles in the fan, the number of vertices describing it is N+2. This is a considerable improvement over the 3N vertices that are necessary to describe the triangles separately. The graphics pip...

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [September 23, 2020, 8:33pm UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372/17 "2020-09-23T20:33:32Z")

</div>

This is the part of the Geojson that I should build The model , but I don’t know is it triangle fan or triangle mesh, how can I found?

[  
{  
“type”: “Feature”,  
“geometry”: {  
“type”: “GeometryCollection”,  
“geometries”: [  
{  
“type”: “Polygon”,  
“coordinates”: [  
[  
[-4.67365, 58.43086, 5247.6],  
[-4.68345, 58.43669, 3850.5],  
[-4.66852, 58.42488, 2523.2],  
[-4.67365, 58.43086, 5247.6]  
]  
]  
},  
{  
“type”: “Polygon”,  
“coordinates”: [  
[  
[-4.67365, 58.43086, 5247.6],  
[-4.66889, 58.42739, 5176.2],  
[-4.66852, 58.42488, 2523.2],  
[-4.67365, 58.43086, 5247.6]  
]  
]  
},  
…  
“properties”: {  
“name”: “FZRU-MYCFB”,  
“description”: “\<tr bgcolor=”#E3E3F3"\>\n\n\n\<tr bgcolor=""\>\n\n\n\<tr bgcolor="#E3E3F3"\>\n\n\n\<tr bgcolor=""\>\n\n\n\<tr bgcolor="#E3E3F3"\>\n\n\n\<tr bgcolor=""\>\n\n\n\<tr bgcolor="#E3E3F3"\>\n\n\n

| _Attributes_ |
| --- |
| SECTION | UK\_Reg02\_Section\_394 |
| LEX\_RCS | FZRU-MYCFB |
| LEX\_D | FAULT ZONE ROCKS, UNASSIGNED - MYLONITIC-ROCK AND FAULT-BRECCIA |
| RCS\_D | MYLONITIC-ROCK AND FAULT-BRECCIA |
| HYDRO\_D | Predominantly fracture-low productivity |
| AQUIFER\_D | NULL |
| PERIOD | NULL |

",  
“stroke”: “#93b000”,  
“stroke-opacity”: 0,  
“stroke-width”: 1,  
“fill”: “#93b000”,  
“fill-opacity”: 0.8,  
“SECTION”: “UK\_Reg02\_Section\_394”,  
“LEX\_RCS”: “FZRU-MYCFB”,  
“LEX\_D”: “FAULT ZONE ROCKS, UNASSIGNED - MYLONITIC-ROCK AND FAULT-BRECCIA”,  
“RCS\_D”: “MYLONITIC-ROCK AND FAULT-BRECCIA”,  
“HYDRO\_D”: “Predominantly fracture-low productivity”,  
“AQUIFER\_D”: “NULL”,  
“PERIOD”: “NULL”  
},  
“id”: “kml\_1”  
},

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [September 23, 2020, 8:40pm UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372/18 "2020-09-23T20:40:43Z")

</div>

In the geojson its like each face made of 3 vertex, and the 4th vertex is the duplicate of first vertex

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [September 23, 2020, 10:35pm UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372/19 "2020-09-23T22:35:11Z")

</div>

I have searched on the forum and I found :  
matArr[i].fillMode = BABYLON.Material.TriangleFillMode;

I use this but again nothing happened

[https://www.babylonjs-playground.com/#VKBJN#926](https://www.babylonjs-playground.com/#VKBJN#926)

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [September 24, 2020, 3:38pm UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372/20 "2020-09-24T15:38:08Z")

</div>

Ok let’s do it step by step. Can we start with a geoJSON containing only one or two triangles?  
Because there is also thet problem about you creating a mesh per triangle which seems wrong to me

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [September 24, 2020, 7:33pm UTC](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372/21 "2020-09-24T19:33:04Z")

</div>

> [@Deltakosh](#):
>
> Ok let’s do it step by step. Can we start with a geoJSON containing only one or two triangles?

You’re too kind. I cannot express my appreciation.

there is one triangle, it means there is 4 vertices in each brackets but the 4th vertex is the same as the first vertex, and also there are 24 cluster which each cluster has some coordinates and specific id to build triangles and also each cluster has specific color and some other properties, because of that I made 24 custom mesh. is it any mistake in my code?

I upload the geojson file:  
[test.zip](https://forum.babylonjs.com/uploads/short-url/z6D4CXBX0HUIevHDE1MNiJSFqFz.zip) (38.7 KB)

I think there are something wrong in the geoJSON file, because the numbers in the Z axis are so big number in terms of X and Y. (e.g. [-4.67365, 58.43086, 5247.6]).

I said to my supervisor to revision the GeoJSON file, but she didn’t inform me until now yet.

[Next page](https://forum.babylonjs.com/t/have-an-error-when-i-want-to-use-array-of-vertexdataarray-i-applytomesh-custommesharr-i/14372.md?page=2)
