# Computed radius is NaN

**URL:** <https://discourse.threejs.org/t/computed-radius-is-nan/9047>\
**Category:** Questions\
**Created:** [August 14, 2019, 2:17pm UTC](https://discourse.threejs.org/t/computed-radius-is-nan/9047 "2019-08-14T14:17:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![3DGraphics](https://avatars.discourse-cdn.com/v4/letter/3/97f17d/32.png) [@3DGraphics](https://discourse.threejs.org/u/3DGraphics)\
**Post date:** [August 14, 2019, 2:17pm UTC](https://discourse.threejs.org/t/computed-radius-is-nan/9047/1 "2019-08-14T14:17:55Z")

</div>

I’m looking for some insight into the type of issues that would cause the following error so that I can resolve the problem. I’m using R107.

```auto
three.js:11903 THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values. BufferGeometry {uuid: "1F4641CE-9004-452A-838E-1DC69F07A323", name: "CrodGeometry", type: "BufferGeometry", index: null, attributes: {…}, …}attributes: {position: Float32BufferAttribute, color: Float32BufferAttribute}boundingBox: nullboundingSphere: Spherecenter: Vector3 {x: 722.9655294418335, y: 0, z: 278.7619934082031}radius: NaN __proto__ : ObjectdrawRange: {start: 0, count: Infinity}groups: []index: nullmorphAttributes: {}name: "CrodGeometry"type: "BufferGeometry"userData: {}uuid: "1F4641CE-9004-452A-838E-1DC69F07A323"drawcalls: (...)id: 11offsets: (...) __proto__ : EventDispatcher
computeBoundingSphere @ three.js:11903
drawCRods @ app.js:873
init @ app.js:1197
(anonymous) @ app.js:317
processModel @ model-loader.js:47
(anonymous) @ model-loader.js:35
(anonymous) @ three.js:34525
load (async)
load @ three.js:34505
(anonymous) @ model-loader.js:33
Promise.then (async)
load @ model-loader.js:28
mounted @ app.js:312
callHook @ vuejs-2.0.js:2878
mountComponent @ vuejs-2.0.js:2762
Vue$3.$mount @ vuejs-2.0.js:8349
Vue$3.$mount @ vuejs-2.0.js:10689
Vue._init @ vuejs-2.0.js:4524
Vue$3 @ vuejs-2.0.js:4609
renderDrawing @ app.js:306
BDF @ (index):410
onchange @ (index):446

```

---

<div class="post-metadata">

**Author:** ![looeee](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/looeee/32/59_2.png) [@looeee](https://discourse.threejs.org/u/looeee)\
**Post date:** [August 14, 2019, 2:31pm UTC](https://discourse.threejs.org/t/computed-radius-is-nan/9047/2 "2019-08-14T14:31:08Z")

</div>

## Please add more detail to your post

### Your post has been flagged since it is lacking detail, has already been asked or is easily answered using a search engine.

Please add more detail, for example:

- a [minimal working example](https://en.wikipedia.org/wiki/Minimal_Working_Example) using [Codepen](https://codepen.io/looeee/pen/PpEyJv) or [Jsfiddle](http://jsfiddle.net/akmcv7Lh/)
- screenshots or any models that you are using
- what you have tried so far and the issues you have run into

#### Your post will be reviewed in 24 hours and if it has not improved it will be deleted.

You will, of course, be free to make a new post in that case.

---

<div class="post-metadata">

**Author:** ![3DGraphics](https://avatars.discourse-cdn.com/v4/letter/3/97f17d/32.png) [@3DGraphics](https://discourse.threejs.org/u/3DGraphics)\
**Post date:** [August 15, 2019, 11:18am UTC](https://discourse.threejs.org/t/computed-radius-is-nan/9047/3 "2019-08-15T11:18:28Z")

</div>

I’ve included a code example. The code works with 12 vertices (used to test algorithm correctness) but I have over 600k vertices representing line segments. The problem occurs when computeBoundingSphere is invoked. A single geometry is used for performance reasons. The full source code is part of a propriety application.

```auto
for (var i = 0; i < tauGeometry.vertices.length; i += 2) {
p1 = new THREE.Vector3(tauGeometry.vertices[i].x,
tauGeometry.vertices[i].y,
tauGeometry.vertices[i].z)
positions.push(p1)
colors.push(255)
colors.push(255)
colors.push(255)
p2 = new THREE.Vector3(tauGeometry.vertices[i + 1].x,
tauGeometry.vertices[i + 1].y,
tauGeometry.vertices[i + 1].z)
positions.push(p2)
colors.push(255)
colors.push(255)
colors.push(255)
}

lineSegGeo = new THREE.BufferGeometry().setFromPoints(positions)
lineSegGeo.addAttribute(‘color’, new THREE.Float32BufferAttribute(colors, 3))
lineSegGeo.computeBoundingBox()
lineSegGeo.computeBoundingSphere()
lineSegtau = new THREE.LineSegments(lineSegGeo, tauMaterial)
lineSegtau.name = ‘tau’
lineSegtau.etype = ’ ’
scene.add(lineSegtau)

```
