import * as THREE from 'three' import common from './common.js' import Vectors from './Vectors.js' import math from './math.js' const rot90 = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), -Math.PI / 2) class Panorama extends THREE.EventDispatcher { constructor(model, sweepuuid, sweepLocation) { super() this.id = sweepuuid this.panoType = sweepLocation.panoType //标记特殊 如 'assistant'校准热点时的相机协助点 '360view' 独立全景 this.appId = sweepLocation.index + 1 this.origin = sweepLocation.position.clone() this.position = sweepLocation.position.clone() this.quaternion = sweepLocation.quaternion.clone() this.model = model this.floorPosition = sweepLocation.puck ? sweepLocation.puck.clone() : null this.marker = null this.tiled = sweepLocation.tiled != void 0 ? sweepLocation.tiled : this.model.supportsTiles var rot90qua = new THREE.Quaternion().multiplyQuaternions(this.quaternion, rot90) //改 为球目全景照片而改 let rot90Matrix = new THREE.Matrix4().compose(this.position, rot90qua, new THREE.Vector3(1, 1, 1)) //转90度后的 if (this.tiled) { this.rot90Matrix = rot90Matrix // 给热点校准用 因为热点求点时所右乘的matrix必须是单张全景照片时用的转90度的matrix才行 this.matrixWorld = new THREE.Matrix4().compose(this.position, this.quaternion, new THREE.Vector3(1, 1, 1)) } else { this.quaternion = rot90qua this.matrixWorld = rot90Matrix } } /* build1() { this.floor = this.floor || this.model.floors.get(this.floorIndex) || this.raycastToFindFloor() || this.model.floors.list[0] //this.model.getFloorAtPoint(this.position) this.floor.addPano(this) this.floorPosition = this.floorPosition || this.raycastFloorPosition() this.neighbourPanos = this.neighbourPanos || this.findNeighourPanos() if (settings.colorMarkerByFloor && this.marker) { this.marker.material.color.set(this.floor.debugColor) } } build2() { this.floorPosition = this.floorPosition || this.interpolateFloorPosition() this.height = this.position.distanceTo(this.floorPosition) if (this.isAligned()) { this.$app.config.view || this.addLabel() setTimeout(() => { addLabel && this.addLabel2() }, 1) } } */ isAligned(){return true} } export default Panorama