NGL@1.0.0-beta.7 Home Manual Reference Source Gallery

src/viewer/geometry-group.js

/**
 * @file Geometry Group
 * @author Alexander Rose <alexander.rose@weirdbyte.de>
 * @private
 */

import { Box3 } from '../../lib/three.es6.js'

class GeometryGroup {
  constructor (geometryList) {
    this.geometryList = geometryList
    this.boundingBox = null
  }

  computeBoundingBox () {
    if (!this.boundingBox) {
      this.boundingBox = new Box3()
    } else {
      this.boundingBox.empty()
    }

    this.geometryList.forEach(geo => {
      if (!geo.boundingBox) geo.computeBoundingBox()
      this.boundingBox.union(geo.boundingBox)
    })
  }
}

export default GeometryGroup