+import cameraLight from '../../../utils/cameraLight.js'
+import math from '../../../utils/math.js'
+import Common from '../../../utils/Common.js'
+import * as THREE from "../../../../../libs/three.js/build/three.module.js";
+
+
+let {DownloadStatus} = Potree.defines
+
+var h = Object.freeze({
+ None: 0,
+ DirectionalFOV: 1
+});
+
+var u = function () {
+ var e = function e(t, i) {
+ var n = e._panoSpaceDir,
+ r = e._fovThreshold,
+ o = e._fovThresholdNarrow,
+ a = Math.max(Math.min(n.dot(t.direction), 1), -1),
+ s = Math.max(Math.min(n.dot(i.direction), 1), -1);
+ return t._dot = a,
+ i._dot = s,
+ a >= r && s < r ? -1 : a < r && s >= r ? 1 : a >= o && s < o ? -1 : a < o && s >= o ? 1 : t.panoSize > i.panoSize ? 1 : i.panoSize > t.panoSize ? -1 : -(a - s)
+ this.priorityCriteria = new TilePrioritizer.PriorityCriteria(null, new THREE.Vector3(0, 0, 0), new THREE.Vector3(0, 0, -1), new THREE.Vector3(0, 0, -1));
+ return TileUtils.isTileWithinFrustum(size, d, e.face, e.tileX, e.tileY, i, hFov, vFov)//在视野中的
+ };
+ return a(size, f, result)
+ }
+ var g = function(t) {//如果仅有hFov
+ return TileUtils.isTileWithinFOV(size, d, t.face, t.tileX, t.tileY, e, hFov)
+ };
+ return a(size, g, result)
+ }
+}(),
+
+/*
+ * 是否在屏幕范围内
+ */
+TileUtils.isTileWithinFrustum = function() {
+ var e = new MathLight.Vector3
+ , t = 1e-5;
+ return function(i, n, a, s, l, c, h, u) {
+ for (var d = Math.tan(.5 * u * MathLight.RADIANS_PER_DEGREE), p = -d, f = Math.tan(.5 * h * MathLight.RADIANS_PER_DEGREE), g = -f, m = TileUtils.mapFaceToCubemapFace(a), v = 0, A = 0, y = 0, C = 0, I = 0, E = 0, b = TileUtils.LocationOnTile.Center; b <= TileUtils.LocationOnTile.LowerLeft; b++){
+ TileUtils.getTileVector(i, n, m, s, l, b, 0, e),//get e // size, tileSize, cubeFace, tileX, tileY, Center, c, dir
+ MathLight.applyQuaternionToVector(c, e)
+ if (e.z >= -t)//似乎是在相机背面
+ I++;
+ else {
+ var w = -1 / e.z
+ , _ = e.x * w
+ , T = e.y * w;
+ T > d ? v++ : T < p && A++, //这四种似乎代表在这个画框之外,如在左、在上、在下、在右
+ _ > f ? y++ : _ < g && C++,
+ E++
+ }
+ }
+ return A !== E && v !== E && y !== E && C !== E //如果有一项和E相等代表要么是在相机背面要么是tile的四个顶点都画在画布的同一边,所以肯定不在画布上
+ let holesPoints = holes.filter(e=>e!=this && e.points.length>2).map(e=>e.points)
+ let inShape = math.isPointInArea(this.points, holesPoints, position)
+
+
+ return !!inShape
+ }
+
+}
+
+
+
+
+
+class MetricUVGenerator{
+ constructor(){
+ this.a = new THREE.Vector3,
+ this.b = new THREE.Vector3,
+ this.c = new THREE.Vector3,
+ this.d = new THREE.Vector3
+ }
+ generateTopUV(t, e, n, r, o) {
+ return [new THREE.Vector2(e[3 * n],e[3 * n + 1]), new THREE.Vector2(e[3 * r],e[3 * r + 1]), new THREE.Vector2(e[3 * o],e[3 * o + 1])]
+ }
+
+ generateSideWallUV(t, e, n, r, o, a) {
+ var s = e;
+ this.a.set(s[3 * n], s[3 * n + 1], s[3 * n + 2]),
+ this.b.set(s[3 * r], s[3 * r + 1], s[3 * r + 2]),
+ this.c.set(s[3 * o], s[3 * o + 1], s[3 * o + 2]),
+ this.d.set(s[3 * a], s[3 * a + 1], s[3 * a + 2]);
+ var c = this.a.x !== this.b.x
+ , l = c ? this.b : this.d
+ , u = this.a.distanceTo(l)
+ , d = l.distanceTo(this.c);
+ return [new THREE.Vector2(this.a.x,0), c ? new THREE.Vector2(this.a.x + u,0) : new THREE.Vector2(this.a.x,d), new THREE.Vector2(this.a.x + u,d), c ? new THREE.Vector2(this.a.x,d) : new THREE.Vector2(this.a.x + u,0)]
+ let cloudPath = `https://laser-oss.4dkankan.com/${Potree.settings.webSite}/${Potree.settings.number}/data/bundle_${Potree.settings.number}/building/uuidcloud/${pano.uuid}/cloud.js`
+
+ let name = datasetId + '-'+pano.uuid
+ let timeStamp = 0
+ pano.index = index //注意:index不等于uuid,因为有的uuid缺失。但是visibles中存的是下标!
+
+ Potree.loadPointCloud(cloudPath, name , name, timeStamp, e => { //开始加载点云