# THREE.Line2: TypeError: value is undefined / setIndex

**URL:** <https://discourse.threejs.org/t/three-line2-typeerror-value-is-undefined-setindex/2896>\
**Category:** Questions\
**Tags:** lines\
**Created:** [May 22, 2018, 12:35pm UTC](https://discourse.threejs.org/t/three-line2-typeerror-value-is-undefined-setindex/2896 "2018-05-22T12:35:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![weiserhei](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/weiserhei/32/1837_2.png) [@weiserhei](https://discourse.threejs.org/u/weiserhei)\
**Post date:** [May 22, 2018, 12:35pm UTC](https://discourse.threejs.org/t/three-line2-typeerror-value-is-undefined-setindex/2896/1 "2018-05-22T12:35:29Z")

</div>

When Im adding **more than one** line with `THREE.Line2` I am running into an Error on rendering (on CentOS, working on Windows).

> TypeError: value is undefined

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/2X/9/90a264b66fab77816c65f567a330d7bc06e78a82.png)

Im using the same code as I did before to create the `THREE.Line`.

```
        const geometry = new LineGeometry();
    geometry.setPositions( positions );		
    const lineMaterial = new LineMaterial( { color: 0xffffff } );
	
    const line = new Line2( geometry, lineMaterial );

```

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [May 22, 2018, 3:58pm UTC](https://discourse.threejs.org/t/three-line2-typeerror-value-is-undefined-setindex/2896/2 "2018-05-22T15:58:12Z")

</div>

Can you please reproduce the problem with a [live example](https://jsfiddle.net/f2Lommf5/)?

> [@weiserhei](#):
>
> on CentOS, working on Windows

If you provide a fiddle, I can make a test on Ubuntu.

BTW: Does the official example work on your machine?

[https://threejs.org/examples/#webgl\_lines\_fat](https://threejs.org/examples/#webgl_lines_fat)

---

<div class="post-metadata">

**Author:** ![weiserhei](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/weiserhei/32/1837_2.png) [@weiserhei](https://discourse.threejs.org/u/weiserhei)\
**Post date:** [May 22, 2018, 10:12pm UTC](https://discourse.threejs.org/t/three-line2-typeerror-value-is-undefined-setindex/2896/3 "2018-05-22T22:12:08Z")

</div>

The fat lines example does work.  
Here is a fiddle Ive built on windows, I verify tomorrow if ist working on CentOS: [https://jsfiddle.net/ogLq49rw/](https://jsfiddle.net/ogLq49rw/)

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [May 23, 2018, 8:40am UTC](https://discourse.threejs.org/t/three-line2-typeerror-value-is-undefined-setindex/2896/4 "2018-05-23T08:40:23Z")

</div>

Your fiddle works on my Ubuntu 16.04 LTS with Chromium 66.0.3359.139.

---

<div class="post-metadata">

**Author:** ![weiserhei](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/weiserhei/32/1837_2.png) [@weiserhei](https://discourse.threejs.org/u/weiserhei)\
**Post date:** [May 23, 2018, 12:02pm UTC](https://discourse.threejs.org/t/three-line2-typeerror-value-is-undefined-setindex/2896/5 "2018-05-23T12:02:54Z")

</div>

Everything is working without Errors on my machines too, includiing my current project in development. Which was the reason I asked this question in the first place, although I didnt change related code (AFAIR).

It seems like I cant reliable reproduce the Error, but it occured for some weeks, even on Windows sometimes.

---

<div class="post-metadata">

**Author:** ![weiserhei](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/weiserhei/32/1837_2.png) [@weiserhei](https://discourse.threejs.org/u/weiserhei)\
**Post date:** [May 23, 2018, 9:17pm UTC](https://discourse.threejs.org/t/three-line2-typeerror-value-is-undefined-setindex/2896/6 "2018-05-23T21:17:56Z")

</div>

**Small update**  
Ive stumbled upon this Error in my project again, and randomly discovered a Workaround by just creating a new BufferGeometry anywhere:  
`new THREE.BufferGeometry();`

Adding this line anywhere in my Code prevents the Error from Happening.  
I couldnt figure out whats the reason behind this, but for now I am OK going that way. If this is enough evidence for you to guess wheres the root of this Problem please let me know.

---

<div class="post-metadata">

**Author:** ![justStarted](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/juststarted/32/6904_2.png) [@justStarted](https://discourse.threejs.org/u/justStarted)\
**Post date:** [January 10, 2020, 7:31am UTC](https://discourse.threejs.org/t/three-line2-typeerror-value-is-undefined-setindex/2896/7 "2020-01-10T07:31:15Z")

</div>

In my case everything was working fine.But when i need to add box2djs(didnt used any part of it, just inserted in html) file in project. After that, “value is undefined at line16343” starts coming. Ran simple threejs tutorial code with having box2d script in html , works fine. Then at this [link](https://stackoverflow.com/questions/45123977/three-js-correct-way-to-setindex-indices-for-buffergeometry), it says to change geometry to buffergeometry, which then worked for me.  
P.S: I was using different materials for different faces.
