Panorama.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import * as THREE from 'three'
  2. import common from './common.js'
  3. import Vectors from './Vectors.js'
  4. import math from './math.js'
  5. const rot90 = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), -Math.PI / 2)
  6. class Panorama extends THREE.EventDispatcher {
  7. constructor(model, sweepuuid, sweepLocation) {
  8. super()
  9. this.id = sweepuuid
  10. this.panoType = sweepLocation.panoType //标记特殊 如 'assistant'校准热点时的相机协助点 '360view' 独立全景
  11. this.appId = sweepLocation.index + 1
  12. this.origin = sweepLocation.position.clone()
  13. this.position = sweepLocation.position.clone()
  14. this.quaternion = sweepLocation.quaternion.clone()
  15. this.model = model
  16. this.floorPosition = sweepLocation.puck ? sweepLocation.puck.clone() : null
  17. this.marker = null
  18. this.tiled = sweepLocation.tiled != void 0 ? sweepLocation.tiled : this.model.supportsTiles
  19. var rot90qua = new THREE.Quaternion().multiplyQuaternions(this.quaternion, rot90) //改 为球目全景照片而改
  20. let rot90Matrix = new THREE.Matrix4().compose(this.position, rot90qua, new THREE.Vector3(1, 1, 1)) //转90度后的
  21. if (this.tiled) {
  22. this.rot90Matrix = rot90Matrix // 给热点校准用 因为热点求点时所右乘的matrix必须是单张全景照片时用的转90度的matrix才行
  23. this.matrixWorld = new THREE.Matrix4().compose(this.position, this.quaternion, new THREE.Vector3(1, 1, 1))
  24. } else {
  25. this.quaternion = rot90qua
  26. this.matrixWorld = rot90Matrix
  27. }
  28. }
  29. /* build1() {
  30. this.floor = this.floor || this.model.floors.get(this.floorIndex) || this.raycastToFindFloor() || this.model.floors.list[0] //this.model.getFloorAtPoint(this.position)
  31. this.floor.addPano(this)
  32. this.floorPosition = this.floorPosition || this.raycastFloorPosition()
  33. this.neighbourPanos = this.neighbourPanos || this.findNeighourPanos()
  34. if (settings.colorMarkerByFloor && this.marker) {
  35. this.marker.material.color.set(this.floor.debugColor)
  36. }
  37. }
  38. build2() {
  39. this.floorPosition = this.floorPosition || this.interpolateFloorPosition()
  40. this.height = this.position.distanceTo(this.floorPosition)
  41. if (this.isAligned()) {
  42. this.$app.config.view || this.addLabel()
  43. setTimeout(() => {
  44. addLabel && this.addLabel2()
  45. }, 1)
  46. }
  47. } */
  48. isAligned(){return true}
  49. }
  50. export default Panorama