You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
13 KiB
29 lines
13 KiB
// All material copyright Esri, All Rights Reserved, unless otherwise specified. |
|
// See https://js.arcgis.com/4.30/esri/copyright.txt for details. |
|
//>>built |
|
define("exports ../../../core/arrayUtils ../../../core/mathUtils ../../../core/libs/gl-matrix-2/math/vec2 ../../../core/libs/gl-matrix-2/factories/vec2f64 ../../../chunks/vec32 ../../../core/libs/gl-matrix-2/factories/vec3f64 ../../../chunks/vec42 ../../../core/libs/gl-matrix-2/factories/vec4f64 ../../../geometry/support/geodesicConstants ../../../geometry/support/geodesicUtils ../../../geometry/support/plane ../../../chunks/sphere ../../3d/support/mathUtils ./normalizedPoint ../../support/geometry3dUtils ../../support/geometry2dUtils".split(" "), |
|
function(n,X,pa,F,Y,k,q,Z,qa,ra,H,l,J,sa,g,e,aa){function A(a,b){if(a instanceof K){var c=[];for(const d of a.constraints)(a=d.intersect(b))&&c.push(a);return N(c)}if(b instanceof K)return A(b,a);if(a instanceof L)return ba(a,b);if(b instanceof L)return ba(b,a);if(t(a)){({point:c}=a);if(t(b))return k.exactEquals(c,b.point)?a:void 0;b=b.closestTo(c);return k.equals(b,c)?a:void 0}if(w(a)){if(t(b))return A(b,a);if(w(b))return u(e.intersectLineLikes(a.lineLike,b.lineLike));if(B(b))return ta(a,b);if(x(b))return u(e.intersectVerticalPlaneAndLineLike(b.planeLike, |
|
a.lineLike));if(y(b))return u(e.intersectLineLikeAndVerticalCylinder(a.lineLike,b.center,b.radius));if(G(b))return u(e.intersectLineLikeAndCircle(a.lineLike,b));if(C(b))return ua(a,b);if(D(b))return va(a,b)}else if(B(a)){if(t(b)||w(b))return A(b,a);if(B(b))return e.isClose(a.z,b.z)?a:void 0;if(x(b))return wa(a,b);if(y(b)){const [d,f]=b.center;return new O(g.fromValues(d,f,a.z),b.radius)}if(G(b))return xa(a,b);if(C(b))return e.isClose(b.center[2],a.z)?b:void 0;if(D(b))return ya(a,b)}else if(x(a)){if(t(b)|| |
|
w(b)||B(b))return A(b,a);if(x(b))return S(e.intersectVerticalPlanes(a.planeLike,b.planeLike));if(y(b))return S(e.intersectVerticalPlaneAndVerticalCylinder(a.planeLike,b.center,b.radius));if(G(b))return za(a,b);if(C(b))return Aa(a,b);if(D(b))return Ba(a,b)}else if(y(a)){if(t(b)||w(b)||B(b)||x(b))return A(b,a);if(y(b))return S(e.intersectVerticalCylinders(g.asVec2(a.center),a.radius,g.asVec2(b.center),b.radius));if(!G(b)){if(C(b))return c=F.squaredDistance(g.asVec2(a.center),g.asVec2(b.center)),e.isClose(c, |
|
0)&&e.isClose(a.radius,b.radius)||(a=e.intersectVerticalCylinders(g.asVec2(a.center),a.radius,g.asVec2(b.center),b.radius),b=ca(a,b.center[2])),b;D(b)}}else if(G(a)){if(t(b)||w(b)||B(b)||x(b)||y(b))return A(b,a);G(b)||(C(b)?b.asCircle():D(b))}else if(C(a)){if(t(b)||w(b)||B(b)||x(b)||y(b)||G(b))return A(b,a);if(C(b))return e.vectorsHaveCloseZ(b.center,a.center)?(c=F.squaredDistance(g.asVec2(b.center),g.asVec2(a.center)),e.isClose(c,0)&&e.isClose(b.radius,a.radius)||(a=e.intersectVerticalCylinders(g.asVec2(b.center), |
|
b.radius,g.asVec2(a.center),a.radius),b=ca(a,b.center[2]))):b=void 0,b;D(b)}else if(D(a)){if(t(b)||w(b)||B(b)||x(b)||y(b)||C(b))return A(b,a);D(b)}}function ua({lineLike:a},{center:b,radius:c}){const d=b[2];a=e.intersectLineLikeAndVerticalCylinder(a,b,c).filter(f=>e.isClose(f[2],d));return u(a)}function va({lineLike:a},{sphere:b}){return u(J.intersectLine(b,a.start,a.end))}function wa({z:a},{planeLike:b}){const [c,d]=b.start,[f,h]=b.end,m=g.fromValues(c,d,a);a=g.fromValues(f,h,a);return b.type=== |
|
e.VerticalPlaneType.PLANE?new T(m,a):new da(m,a)}function ya(a,{center:b,radius:c}){const d=Math.abs(b[2]-a.z);if(!(d>c)||e.isClose(d,c))if(a=g.fromValues(b[0],b[1],a.z),c=Math.sqrt(c**2-d**2),!e.isClose(c,0))return new O(a,c)}function ba(a,b){const {planeLike:c,getZ:d}=a,f=[];if(t(b))a.addIfOnTheGround(f,e.intersectVerticalPlaneAndPoint(c,b.point));else if(w(b))a.addIfOnTheGround(f,e.intersectVerticalPlaneAndLineLike(c,b.lineLike));else if(y(b))for(const [h,m]of e.intersectVerticalPlaneAndVerticalCylinder(c, |
|
b.center,b.radius))a=d(h,m),null!=a&&f.push(q.fromValues(h,m,a));else if(x(b)||b instanceof L)for(const [h,m]of e.intersectVerticalPlanes(c,b.planeLike))a=d(h,m)??0,f.push(q.fromValues(h,m,a));return u(f)}function S(a){return N(a.map(([b,c])=>{const d=g.fromValues(b,c,0);b=g.fromValues(b,c,1);return new T(d,b)}))}function u(a){return N(a.map(b=>b?new I(g.fromVec3(b)):void 0))}function ca(a,b){return u(a.map(([c,d])=>[c,d,b]))}function N(a){if(0!==a.length)return 1===a.length?a[0]??void 0:new K(a.filter(X.isSome))} |
|
function t(a){return a instanceof I}function w(a){return a instanceof P}function B(a){return a instanceof ea}function x(a){return a instanceof Q}function y(a){return a instanceof fa}function C(a){return a instanceof O}function G(a){return a instanceof R}function D(a){return a instanceof ha}class r{intersect(a){return A(this,a)}closestPoints(a){return[this.closestTo(a)]}}class I extends r{constructor(a){super();this.point=a}equals(a){return this===a||t(a)&&k.exactEquals(this.point,a.point)}closestTo(){return g.clone(this.point)}} |
|
class P extends r{constructor(a,b,c){super();this.start=a;this.end=b;this.lineLike={start:a,end:b,type:c}}equals(a){return this===a||w(a)&&this.lineLike.type===a.lineLike.type&&k.exactEquals(this.start,a.start)&&k.exactEquals(this.end,a.end)}closestTo(a){const b=g.createWritable();e.projectPointToLineLike(a,this.lineLike,b);return b}}class T extends P{constructor(a,b){super(a,b,aa.LineType.LINE)}}class da extends P{constructor(a,b){super(a,b,aa.LineType.RAY)}}class K extends r{constructor(a){super(); |
|
this.constraints=a}equals(a){return this===a||a instanceof K&&X.equals(this.constraints,a.constraints,(b,c)=>b.equals(c))}closestTo(a){let b=Infinity,c;for(const d of this.constraints){const f=d.closestTo(a),h=k.squaredDistance(a,f);h<b&&(b=h,c=f)}return g.clone(c??a)}closestPoints(a){return this.constraints.flatMap(b=>b===this?[]:b.closestPoints(a))}}class fa extends r{constructor(a,b){super();this.center=a;this.radius=b}equals(a){return this===a||y(a)&&this.center[0]===a.center[0]&&this.center[1]=== |
|
a.center[1]&&this.radius===a.radius}closestTo(a){const b=g.createWritable();e.projectPointToVerticalCylinder(a,this.center,this.radius,b);return b}}class O extends r{constructor(a,b){super();this.center=a;this.radius=b}equals(a){return this===a||C(a)&&k.exactEquals(this.center,a.center)&&this.radius===a.radius}closestTo(a){const b=g.createWritable();e.projectPointToVerticalCylinder(a,this.center,this.radius,b);b[2]=this.center[2];return b}asCircle(){return new R(g.clone(this.center),this.radius,g.fromValues(0, |
|
0,1))}}class R extends r{constructor(a,b,c,d){super();this.center=a;this.radius=b;this.normal=c;this.slicePlane=d}equals(a){return this===a||G(a)&&k.exactEquals(this.center,a.center)&&k.exactEquals(this.normal,a.normal)&&this.radius===a.radius}closestTo(a){const {center:b,radius:c}=this;l.projectPoint(this.getPlane(Ca),a,U);var d=k.sub(U,U,b),f=k.squaredLength(d);if(e.isClose(f,0))return g.clone(a);const h=c/Math.sqrt(f);f=g.createWritable();k.scaleAndAdd(f,b,d,h);({slicePlane:d}=this);return d&& |
|
!e.isPointInsidePlane(d,f)?V(d,this)?.closestTo(a)??g.clone(a):f}getPlane(a=l.create()){return l.fromPositionAndNormal(this.center,this.normal,a)}}const U=q.create(),Ca=l.create();class ea extends r{constructor(a){super();this.z=a}equals(a){return this===a||B(a)&&this.z===a.z}closestTo(a){return g.fromValues(a[0],a[1],this.z)}getPlane(a=l.create()){k.set(ia,0,0,this.z);return l.fromPositionAndNormal(ia,q.UNIT_Z,a)}}const ia=q.create();class Q extends r{constructor(a,b,c){super();this.start=a;this.end= |
|
b;this.planeLike={start:g.asVec2(a),end:g.asVec2(b),type:c}}equals(a){return this===a||x(a)&&this.planeLike.type===a.planeLike.type&&k.exactEquals(this.start,a.start)&&k.exactEquals(this.end,a.end)}closestTo(a){const b=g.createWritable();e.projectPointToVerticalPlane(a,this.planeLike,b);return b}closestEndTo(a){const {start:b,end:c}=this.planeLike;return 0<Math.sign(F.dot(F.subtract(Da,c,b),F.subtract(Ea,g.asVec2(a),b)))?this.end:this.start}getPlane(a=l.create()){const b=k.copy(ja,this.end);b[2]+= |
|
1;return l.fromPoints(this.start,this.end,b,a)}getSlicePlane(a=l.create()){const {start:b,end:c,type:d}=this.planeLike;if(d!==e.VerticalPlaneType.PLANE){var f=k.set(ja,b[0],b[1],0),h=k.set(ka,c[0],c[1],0);h=k.subtract(ka,h,f);l.fromPositionAndNormal(f,h,a);return a}}}const Da=Y.create(),Ea=Y.create(),ja=q.create(),ka=q.create();class Fa extends Q{constructor(a,b){super(a,b,e.VerticalPlaneType.HALF_PLANE)}}class Ga extends Q{constructor(a,b){super(a,b,e.VerticalPlaneType.PLANE)}}class ha extends r{constructor(a, |
|
b){super();this.sphere=J.fromCenterAndRadius(a,b)}equals(a){return this===a||D(a)&&J.exactEquals(this.sphere,a.sphere)}closestTo(a){const b=g.createWritable();J.projectPoint(this.sphere,a,b);return b}get center(){return J.getCenter(this.sphere)}get radius(){return this.sphere[3]}}class L extends r{constructor(a,b,c){super();this.start=a;this.end=b;this.getZ=c;this.planeLike={start:g.asVec2(a),end:g.asVec2(b),type:e.VerticalPlaneType.PLANE}}equals(a){return this===a||a instanceof L&&k.exactEquals(this.start, |
|
a.start)&&k.exactEquals(this.end,a.end)&&this.getZ===a.getZ}closestTo(a){const b=g.createWritable();e.projectPointToVerticalPlane(a,this.planeLike,b);b[2]=this.getZ(b[0],b[1])??0;return b}addIfOnTheGround(a,b){for(const c of b)b=this.getZ(c[0],c[1])??0,e.isClose(c[2],b)&&(c[2]=b,a.push(c))}}class la extends r{constructor(a,b,c){super();this._x=a;this._y=b;this._z=c}equals(a){return this===a||a instanceof la&&this._x===a._x&&this._y===a._y&&this._z===a._z}closestTo([a,b,c]){return g.create(this._x?? |
|
a,this._y??b,this._z??c)}}class ma extends r{constructor(a,b,c,d,f){super();this._origin=a;this._spatialReference=b;this._distanceMeters=c;this._elevationMeters=d;this._directionDegrees=f}equals(a){return this===a||a instanceof ma&&F.exactEquals(this._origin,a._origin)&&this._spatialReference===a._spatialReference&&this._distanceMeters===a._distanceMeters&&this._elevationMeters===a._elevationMeters&&this._directionDegrees===a._directionDegrees}closestTo([a,b,c]){F.set(M,a,b);F.exactEquals(M,this._origin)|| |
|
this._applyDirectionAndDistance(M);return g.create(M[0],M[1],this._elevationMeters??c)}_applyDirectionAndDistance(a){if(null!=this._directionDegrees&&null!=this._distanceMeters)H.directGeodeticSolver(a,this._origin,this._directionDegrees,this._distanceMeters,this._spatialReference);else if(null!=this._directionDegrees){var b=this._origin,c=this._directionDegrees,d=this._spatialReference;let {azimuth:f,distance:h}=H.inverseGeodeticSolver(Ha,b,a,d);f??=0;let m=h*Math.cos((f-c)*ra.toRadians);m=Math.max(0, |
|
m);H.directGeodeticSolver(a,b,c,m,d)}else null!=this._distanceMeters&&({azimuth:b}=H.inverseGeodeticSolver(Ia,this._origin,a,this._spatialReference),H.directGeodeticSolver(a,this._origin,b??0,this._distanceMeters,this._spatialReference))}}const M=[0,0],Ia=new H.InverseGeodeticSolverResult,Ha=new H.InverseGeodeticSolverResult,ta=(()=>{const a=l.create();return(b,c)=>{const {start:d,end:f}=b;if(e.vectorsHaveCloseZ(d,f)&&e.isClose(d[2],c.z))return b;b=g.createWritable();if(l.intersectLine(c.getPlane(a), |
|
d,f,b))return new I(b)}})(),V=(()=>{const a=qa.create(),b=q.create(),c=q.create();return(d,f,h)=>{const {normal:m,center:z,radius:E}=f;sa.tangentFrame(m,b,c);const W=l.getNormal(d);var v=E*k.dot(W,b),p=E*k.dot(W,c);Z.set(a,z[0],z[1],z[2],1);const Ja=Z.dot(d,a),na=Math.hypot(v,p),oa=e.isClose(na,0);if(e.isClose(l.distance(d,z),0)){if(oa)return f;if(e.isClose(E,0))return!h||e.isPointInsidePlane(h,z)?new I(g.clone(z)):void 0;k.cross(b,W,m);k.normalize(b,b);v=[];p=q.clone(z);k.scaleAndAdd(p,p,b,E);h&& |
|
!e.isPointInsidePlane(h,p)||v.push(p);p=q.clone(z);k.scaleAndAdd(p,p,b,-E);h&&!e.isPointInsidePlane(h,p)||v.push(p);return u(v)}if(!(oa||(d=-Ja/na,1<Math.abs(d)||e.isClose(d,1))))return v=Math.atan(v/p),d=pa.asinClamped(d)-v,v=Math.PI-d,p=[],f=q.create(),k.scaleAndAdd(f,z,b,E*Math.cos(d)),k.scaleAndAdd(f,f,c,E*Math.sin(d)),p.push(f),d=q.create(),k.scaleAndAdd(d,z,b,E*Math.cos(v)),k.scaleAndAdd(d,d,c,E*Math.sin(v)),p.push(d),u(h?e.pointsInsidePlane(h,p):p)}})(),xa=(()=>{const a=l.create();return(b, |
|
c)=>V(b.getPlane(a),c,c.slicePlane)})(),Aa=(()=>{const a=l.create();return(b,{center:c,radius:d})=>{d=e.intersectVerticalPlaneAndVerticalCylinder(b.planeLike,c,d);c=c[2];b.getSlicePlane(a);b=[];for(const [f,h]of d)d=[f,h,c],e.isPointInsidePlane(a,d)&&b.push(d);return u(b)}})(),za=(()=>{const a=l.create(),b=l.create();return(c,d)=>V(c.getPlane(a),d,c.getSlicePlane(b))})(),Ba=(()=>{const a=l.create();return(b,{center:c,radius:d})=>{var f=b.getPlane(a);const h=l.signedDistance(f,c);var m=Math.abs(h); |
|
if(!(m>d)||e.isClose(m,d)){d=Math.sqrt(d**2-h**2);if(e.isClose(d,0))return b=g.createWritable(),l.projectPoint(f,c,b),new I(b);m=g.createWritable();f=q.clone(l.getNormal(f));k.scaleAndAdd(m,c,f,h);return new R(m,d,f,b.getSlicePlane())}}})();n.CircleConstraint=R;n.Constraint=r;n.CoordinateConstraint=la;n.DrapedLineConstraint=L;n.GeodesicConstraint=ma;n.HorizontalCircleConstraint=O;n.HorizontalPlaneConstraint=ea;n.LineConstraint=T;n.LineLikeConstraint=P;n.PointConstraint=I;n.RayConstraint=da;n.SetConstraint= |
|
K;n.SphereConstraint=ha;n.VerticalCylinderConstraint=fa;n.VerticalHalfPlaneConstraint=Fa;n.VerticalPlaneConstraint=Ga;n.VerticalPlaneLikeConstraint=Q;n.constraintOrSet=N;n.isPoint=t;Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}); |