Model.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import * as THREE from 'three'
  2. import PanoramaCollection from './PanoramaCollection.js'
  3. import FloorCollection from './FloorCollection.js'
  4. export default class Model extends THREE.Object3D{
  5. constructor( ){
  6. super()
  7. this.panos = new PanoramaCollection(this)
  8. this.floors = new FloorCollection(this)
  9. this.boundingBox = new THREE.Box3
  10. this.supportsTiles = true
  11. }
  12. build(){
  13. /* this.panos.forEach(function (pano) {
  14. pano.build2()
  15. }) */
  16. this.floors.forEach(
  17. function (floor) {
  18. this.boundingBox.union(floor.boundingBox)
  19. }.bind(this)
  20. )
  21. var size = new THREE.Vector3()
  22. var center = new THREE.Vector3()
  23. this.boundingBox.getSize(size)
  24. this.boundingBox.getCenter(center)
  25. this.size = size
  26. this.center = center
  27. this.builded = true //xzw
  28. this.dispatchEvent({ type: 'builded' })
  29. }
  30. addChunk(floorIndex, chunk) {
  31. this.floors.getOrMakeFloor(floorIndex).addChunk(chunk)
  32. }
  33. }