|
@@ -74,15 +74,14 @@ class DepthImageSampler {
|
|
|
//console.log('depth', depth, uv.y)
|
|
|
if (!distance){
|
|
|
const margin = 0.1
|
|
|
- if(uv.y > 0.75){//漫游点底部识别不到的区域,给一个地板高度
|
|
|
- //let height = origin.distanceTo(currentPano.floorPosition);
|
|
|
+ if(uv.y > 1-Potree.config.depthTexUVyLimit){//漫游点底部识别不到的区域,给一个地板高度
|
|
|
|
|
|
distance = (currentPano.floorPosition.z - origin.z - margin) / dir.z
|
|
|
location.copy(dir).multiplyScalar(distance).add(origin);
|
|
|
let normal = new THREE.Vector3(0,0,1)
|
|
|
|
|
|
return {location, normal, distance}
|
|
|
- }else if(uv.y < 0.25){
|
|
|
+ }else if(uv.y < Potree.config.depthTexUVyLimit){
|
|
|
let ceilZ = currentPano.getCeilHeight()
|
|
|
if(ceilZ == Infinity)return !1
|
|
|
else{
|
|
@@ -91,11 +90,11 @@ class DepthImageSampler {
|
|
|
let normal = new THREE.Vector3(0,0,-1)
|
|
|
return {location, normal, distance}
|
|
|
}
|
|
|
- }return !1; //应该是天空或模型外 , 因为很少有漫游点的地方还拍不到地板
|
|
|
+ }
|
|
|
+ //console.log('无穷远')
|
|
|
+ return !1; //应该是天空或模型外 , 因为很少有漫游点的地方还拍不到地板
|
|
|
}
|
|
|
-
|
|
|
- //this.mainDepth = depth
|
|
|
-
|
|
|
+
|
|
|
location.copy(dir).multiplyScalar(distance).add(origin);
|
|
|
|
|
|
if(!onlyPos){
|
|
@@ -116,10 +115,7 @@ class DepthImageSampler {
|
|
|
, pB = this.getNearbyPoint(origin, uv, 0, -1)
|
|
|
, pT = this.getNearbyPoint(origin, uv, 0, 1);
|
|
|
|
|
|
- } */
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ } */
|
|
|
//console.log(location, normal, distance)
|
|
|
|
|
|
return {location, normal, distance}
|
|
@@ -182,153 +178,20 @@ class DepthImageSampler {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /* 四个面拼成一个菱形 */
|
|
|
-
|
|
|
+ /* 四个面拼成一个菱形 */
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /* makeUvToPosMap(intersect, matrix1, vec1, vec2) {
|
|
|
- var o = intersect.object.geometry
|
|
|
- , a = o.attributes.position.array
|
|
|
- , s = new THREE.Vector3(a[3 * intersect.face.a],a[3 * intersect.face.a + 1],a[3 * intersect.face.a + 2]).applyMatrix4(intersect.object.matrixWorld)
|
|
|
- , c = new THREE.Vector3(a[3 * intersect.face.b],a[3 * intersect.face.b + 1],a[3 * intersect.face.b + 2]).applyMatrix4(intersect.object.matrixWorld)
|
|
|
- , l = new THREE.Vector3(a[3 * intersect.face.c],a[3 * intersect.face.c + 1],a[3 * intersect.face.c + 2]).applyMatrix4(intersect.object.matrixWorld);
|
|
|
- vec1.subVectors(s, c),
|
|
|
- vec2.subVectors(l, c);
|
|
|
- var u = o.attributes.uv.array
|
|
|
- , d = new THREE.Vector2(u[2 * intersect.face.a],u[2 * intersect.face.a + 1])
|
|
|
- , p = new THREE.Vector2(u[2 * intersect.face.b],u[2 * intersect.face.b + 1])
|
|
|
- , h = new THREE.Vector2(u[2 * intersect.face.c],u[2 * intersect.face.c + 1])
|
|
|
- , f = d.sub(p)
|
|
|
- , g = h.sub(p);
|
|
|
- matrix1.set(f.x, g.x, 0, f.y, g.y, 0, 0, 0, 1),
|
|
|
- matrix1.getInverse(matrix1)
|
|
|
- } */
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /* getNearbyPoint( point, origin, uv, o, a, s, x, y) {
|
|
|
- var add = new THREE.Vector3(x, y , 0 )
|
|
|
- , depth = this.getDepth(uv.x + add.x, uv.y + add.y );
|
|
|
-
|
|
|
- if (void 0 !== depth) {
|
|
|
- var f = add.applyMatrix3(o);
|
|
|
- return (new THREE.Vector3).addScaledVector(a, f.x).addScaledVector(s, f.y).add(point).sub(origin).normalize().multiplyScalar(depth).add(origin)
|
|
|
- }
|
|
|
- } */
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
注:
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
由于有时候获取intersect需要知道是哪个点云,所以还是不能用这个。如加测量线。
|
|
|
|
|
|
*/
|
|
|
|
|
|
export default DepthImageSampler
|
|
|
|
|
|
-
|
|
|
- /* var i = n(4)
|
|
|
- , r = function() {
|
|
|
- function t(t) {
|
|
|
-
|
|
|
- }
|
|
|
- return t.prototype.getDepth = function(t, e) {
|
|
|
- var n = Math.round(t)
|
|
|
- , i = Math.round(e);
|
|
|
- if (!(n < 0 || i < 0 || n >= this.width || i >= this.height)) {
|
|
|
- var r = this.context.getImageData(n, i, 1, 1).data;
|
|
|
- return r[1] + r[0] / 256
|
|
|
- }
|
|
|
- }
|
|
|
- ,
|
|
|
- Object.defineProperty(t.prototype, "width", {
|
|
|
- get: function() {
|
|
|
- return this.context.canvas.width
|
|
|
- },
|
|
|
- enumerable: !0,
|
|
|
- configurable: !0
|
|
|
- }),
|
|
|
- Object.defineProperty(t.prototype, "height", {
|
|
|
- get: function() {
|
|
|
- return this.context.canvas.height
|
|
|
- },
|
|
|
- enumerable: !0,
|
|
|
- configurable: !0
|
|
|
- }),
|
|
|
- t
|
|
|
- }();
|
|
|
- e.CanvasDepthImage = r;
|
|
|
- var o = function() {
|
|
|
- function t() {}
|
|
|
- return t.sample = function(e, n, r, o, a) {
|
|
|
- var s = n.uv
|
|
|
- , c = s.x * (e.width - 1)
|
|
|
- , l = (1 - s.y) * (e.height - 1)
|
|
|
- , u = e.getDepth(c, l);
|
|
|
- if (!u)
|
|
|
- return !1;
|
|
|
- o.copy(n.point).sub(r).normalize().multiplyScalar(u).add(r);
|
|
|
- var d = new i.Matrix3
|
|
|
- , p = new i.Vector3
|
|
|
- , h = new i.Vector3;
|
|
|
- t.makeUvToPosMap(n, d, p, h);
|
|
|
- var f = this.getNearbyPoint(e, n.point, r, s, d, p, h, -1, 0)
|
|
|
- , g = this.getNearbyPoint(e, n.point, r, s, d, p, h, 1, 0)
|
|
|
- , m = this.getNearbyPoint(e, n.point, r, s, d, p, h, 0, -1)
|
|
|
- , v = this.getNearbyPoint(e, n.point, r, s, d, p, h, 0, 1);
|
|
|
- return this.planeFit(o, r, f, g, m, v, a)
|
|
|
- }
|
|
|
- ,
|
|
|
- t.makeUvToPosMap = function(t, e, n, r) {
|
|
|
- var o = t.object.geometry
|
|
|
- , a = o.attributes.position.array
|
|
|
- , s = new i.Vector3(a[3 * t.face.a],a[3 * t.face.a + 1],a[3 * t.face.a + 2]).applyMatrix4(t.object.matrixWorld)
|
|
|
- , c = new i.Vector3(a[3 * t.face.b],a[3 * t.face.b + 1],a[3 * t.face.b + 2]).applyMatrix4(t.object.matrixWorld)
|
|
|
- , l = new i.Vector3(a[3 * t.face.c],a[3 * t.face.c + 1],a[3 * t.face.c + 2]).applyMatrix4(t.object.matrixWorld);
|
|
|
- n.subVectors(s, c),
|
|
|
- r.subVectors(l, c);
|
|
|
- var u = o.attributes.uv.array
|
|
|
- , d = new i.Vector2(u[2 * t.face.a],u[2 * t.face.a + 1])
|
|
|
- , p = new i.Vector2(u[2 * t.face.b],u[2 * t.face.b + 1])
|
|
|
- , h = new i.Vector2(u[2 * t.face.c],u[2 * t.face.c + 1])
|
|
|
- , f = d.sub(p)
|
|
|
- , g = h.sub(p);
|
|
|
- e.set(f.x, g.x, 0, f.y, g.y, 0, 0, 0, 1),
|
|
|
- e.getInverse(e)
|
|
|
- }
|
|
|
- ,
|
|
|
- t.getNearbyPoint = function(t, e, n, r, o, a, s, c, l) {
|
|
|
- var u = new i.Vector3(c / (t.width - 1),l / (t.height - 1))
|
|
|
- , d = (r.x + u.x) * (t.width - 1)
|
|
|
- , p = (1 - (r.y + u.y)) * (t.height - 1)
|
|
|
- , h = t.getDepth(d, p);
|
|
|
- if (void 0 !== h) {
|
|
|
- var f = u.applyMatrix3(o);
|
|
|
- return (new i.Vector3).addScaledVector(a, f.x).addScaledVector(s, f.y).add(e).sub(n).normalize().multiplyScalar(h).add(n)
|
|
|
- }
|
|
|
- }
|
|
|
- ,
|
|
|
- t.planeFit = function(t, e, n, r, o, a, s) {
|
|
|
- s.set(0, 0, 0);
|
|
|
- var c = t.clone().sub(e)
|
|
|
- , l = new i.Plane;
|
|
|
- function u(e, n) {
|
|
|
- e && n && (l.setFromCoplanarPoints(t, e, n),
|
|
|
- s.addScaledVector(l.normal, c.dot(l.normal) < 0 ? 1 : -1))
|
|
|
- }
|
|
|
- return u(n, o),
|
|
|
- u(n, a),
|
|
|
- u(r, o),
|
|
|
- u(r, a),
|
|
|
- (0 !== s.x || 0 !== s.y || 0 !== s.z) && (s.normalize(),
|
|
|
- !0)
|
|
|
- }
|
|
|
- ,
|
|
|
- t
|
|
|
- }();
|
|
|
- */
|
|
|
+
|