@arcgis/core 4.29.6 → 4.29.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{4984e2b79d862114d6a6.js → 1a8d56e01ddfec2257c3.js} +1 -1
- package/assets/esri/core/workers/chunks/{3afb525a131b6841276b.js → 1e4d779a884f13762601.js} +1 -1
- package/assets/esri/core/workers/chunks/{2447a4d5886aeb0ff72a.js → 205597cd91cb7ff3d2b4.js} +1 -1
- package/assets/esri/core/workers/chunks/{6c50daccd84ba5545bfe.js → 22ebdec0867e44d8d58c.js} +1 -1
- package/assets/esri/core/workers/chunks/{da4616b02dd0c3dd3d5d.js → 321547d796a2ecd72ab4.js} +1 -1
- package/assets/esri/core/workers/chunks/{6c3ae96ec90e9ed7dd50.js → 32be478638e9e643ea32.js} +1 -1
- package/assets/esri/core/workers/chunks/{a61f337802ae963d7f65.js → 59f03847a9eb96e5f65c.js} +1 -1
- package/assets/esri/core/workers/chunks/{7a98d2e026f63a581b1e.js → 5b08309b184f5d8345a0.js} +1 -1
- package/assets/esri/core/workers/chunks/631bda7b99a27f4453c1.js +1 -0
- package/assets/esri/core/workers/chunks/{c527692694688a5b3b07.js → 658a8ee9a4f24bc03f7f.js} +1 -1
- package/assets/esri/core/workers/chunks/99ac2a6a5be0604ee4c2.js +1 -0
- package/assets/esri/core/workers/chunks/{48db6e0bbb1a9c043193.js → b7a78246d25dc07f173d.js} +1 -1
- package/assets/esri/core/workers/chunks/{60ab18c6a04d4b2f1d4c.js → bb05528d2ca12c57a031.js} +1 -1
- package/assets/esri/core/workers/chunks/{5227f9eea6988aadad7f.js → cf0dc0ccbeaf9458de6e.js} +1 -1
- package/assets/esri/core/workers/chunks/{f59b5ea05caca8a1a398.js → d40408be9bbcb0021d18.js} +1 -1
- package/assets/esri/core/workers/chunks/df6fbabbc74a408575fc.js +1 -0
- package/chunks/Laserlines.glsl.js +1 -1
- package/chunks/sphere.js +1 -1
- package/chunks/vec32.js +1 -1
- package/chunks/vec42.js +1 -1
- package/core/libs/gl-matrix-2/math/quat.js +1 -1
- package/core/libs/gl-matrix-2/math/vec3.js +1 -1
- package/core/libs/gl-matrix-2/math/vec4.js +1 -1
- package/geometry/support/sphere.js +1 -1
- package/interfaces.d.ts +8 -2
- package/kernel.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/layers/mixins/FeatureLayerBase.js +1 -1
- package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
- package/layers/support/SubtypeSublayer.js +1 -1
- package/layers/voxel/VoxelVolume.js +1 -1
- package/networks/UtilityNetwork.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/mesh/MeshData.js +1 -1
- package/views/2d/engine/webgl/mesh/MultiTileMeshData.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
- package/views/2d/layers/features/FeatureContainer.js +1 -1
- package/views/2d/layers/features/Processor.js +1 -1
- package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
- package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/OverrideChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderIndirect.js +1 -1
- package/views/2d/layers/features/support/GraphicsReader.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
- package/views/3d/camera/constraintUtils/distance.js +1 -1
- package/views/3d/camera/constraintUtils/tilt.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/graphics/Deconflictor.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
- package/views/3d/layers/support/makeScheduleFunction.js +5 -0
- package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
- package/views/3d/state/controllers/global/PinchAndPanController.js +1 -1
- package/views/3d/state/controllers/global/ZoomController.js +1 -1
- package/views/3d/state/controllers/global/ZoomStepController.js +1 -1
- package/views/3d/state/controllers/momentum/ZoomSphericalMomentumController.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/support/geometryUtils/sphere.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/terrain/SphericalPatch.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/webgl-engine/lib/Camera.js +1 -1
- package/views/3d/webgl-engine/lib/Object3D.js +1 -1
- package/views/3d/webgl-engine/lib/Octree.js +1 -1
- package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
- package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/lib/intersectorUtilsConversions.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/InstanceOctree.js +1 -1
- package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
- package/views/interactive/sketch/constraints.js +1 -1
- package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
- package/views/support/geometry3dUtils.js +1 -1
- package/assets/esri/core/workers/chunks/a068f0c8c1c632e8b2cb.js +0 -1
- package/assets/esri/core/workers/chunks/a28b7d868346e13468bb.js +0 -1
- package/assets/esri/core/workers/chunks/ccd53b81c2688dd11584.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../../chunks/tslib.es6.js";import i from"../../../../core/Accessor.js";import e from"../../../../core/Logger.js";import{lerp as r}from"../../../../core/mathUtils.js";import{createScreenPointArray as s,createRenderScreenPointArray3 as o}from"../../../../core/screenUtils.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{copy as a,multiply as p,frustum as u,equals as _,invert as l,transpose as c,lookAt as v}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as w}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{copy as d,exactEquals as y}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as g}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{f as m,s as f,q as x,c as M,j as T,z as D,k as j,x as R,w as P,h as F,l as O,b as V,n as C,E as b}from"../../../../chunks/vec32.js";import{create as S}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{d as I,e as E,a as L,c as H,f as G,t as B}from"../../../../chunks/vec42.js";import{fromValues as A,create as k}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as U,copy as z,fromMatrix as W}from"../../../../geometry/support/frustum.js";import{create as q}from"../../../../geometry/support/ray.js";import{projectPointSignedLength as X}from"../../../../geometry/support/vector.js";import{ViewingMode as Y}from"../../../ViewingMode.js";import{fovd2fovx as N,fovx2fovd as J,fovd2fovy as K,fovy2fovd as Q}from"./fov.js";var Z;let $=Z=class extends i{constructor(t){super(t),this._ray=q(),this._viewport=A(0,0,1,1),this._padding=A(0,0,0,0),this._fov=55/180*Math.PI,this._nearFar=g(1,1e3),this._viewDirty=!0,this._viewMatrix=w(),this._viewProjectionDirty=!0,this._viewProjectionMatrix=w(),this._viewInverseTransposeMatrixDirty=!0,this._viewInverseTransposeMatrix=w(),this._frustumDirty=!0,this._frustum=U(),this._fullViewport=k(),this._pixelRatio=1,this.row=0,this.column=0,this._rows=1,this._columns=1,this._center=S(),this._up=S(),this.relativeElevation=0}get pixelRatio(){return this._pixelRatio}set pixelRatio(t){this._pixelRatio=t>0?t:1}get rows(){return this._rows}set rows(t){this._rows=Math.max(1,t)}get columns(){return this._columns}set columns(t){this._columns=Math.max(1,t)}get eye(){return this._ray.origin}set eye(t){this._compareAndSetView(t,this._ray.origin)}get center(){return this._center}set center(t){this._compareAndSetView(t,this._center,"_center")}get ray(){return m(this._ray.direction,this.center,this.eye),this._ray}get up(){return this._up}set up(t){this._compareAndSetView(t,this._up,"_up")}get viewMatrix(){return this._ensureViewClean(),this._viewMatrix}set viewMatrix(t){a(this._viewMatrix,t),this.notifyChange("_viewMatrix"),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0,this._viewProjectionDirty=!0,this._frustumDirty=!0}get viewForward(){return this._ensureViewClean(),f(S(),-this._viewMatrix[2],-this._viewMatrix[6],-this._viewMatrix[10])}get viewUp(){return this._ensureViewClean(),f(S(),this._viewMatrix[1],this._viewMatrix[5],this._viewMatrix[9])}get viewRight(){return this._ensureViewClean(),f(S(),this._viewMatrix[0],this._viewMatrix[4],this._viewMatrix[8])}get nearFar(){return this._nearFar}get near(){return this._nearFar[0]}set near(t){this._nearFar[0]!==t&&(this._nearFar[0]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_nearFar"))}get far(){return this._nearFar[1]}set far(t){this._nearFar[1]!==t&&(this._nearFar[1]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_nearFar"))}get viewport(){return this._viewport}set viewport(t){this.x=t[0],this.y=t[1],this.width=t[2],this.height=t[3]}get screenViewport(){if(1===this.pixelRatio)return this._viewport;const t=I(k(),this._viewport,1/this.pixelRatio),i=this._get("screenViewport");return i&&E(t,i)?i:t}get screenPadding(){if(1===this.pixelRatio)return this._padding;const t=I(k(),this._padding,1/this.pixelRatio),i=this._get("screenPadding");return i&&E(t,i)?i:t}get x(){return this._viewport[0]}set x(t){t+=this._padding[ot.LEFT],this._viewport[0]!==t&&(this._viewport[0]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get y(){return this._viewport[1]}set y(t){t+=this._padding[ot.BOTTOM],this._viewport[1]!==t&&(this._viewport[1]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get width(){return this._viewport[2]}set width(t){this._viewport[2]!==t&&(this._viewport[2]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get height(){return this._viewport[3]}set height(t){this._viewport[3]!==t&&(this._viewport[3]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get fullWidth(){return this._viewport[2]+this._padding[ot.RIGHT]+this._padding[ot.LEFT]}set fullWidth(t){this.width=t-(this._padding[ot.RIGHT]+this._padding[ot.LEFT])}get fullHeight(){return this._viewport[3]+this._padding[ot.TOP]+this._padding[ot.BOTTOM]}set fullHeight(t){this.height=t-(this._padding[ot.TOP]+this._padding[ot.BOTTOM])}get fullViewport(){return this._fullViewport[0]=this._viewport[0]-this._padding[ot.LEFT],this._fullViewport[1]=this._viewport[1]-this._padding[ot.BOTTOM],this._fullViewport[2]=this.fullWidth,this._fullViewport[3]=this.fullHeight,this._fullViewport}get _aspect(){return this.width/this.height}get padding(){return this._padding}set padding(t){L(this._padding,t)||(this._viewport[0]+=t[ot.LEFT]-this._padding[ot.LEFT],this._viewport[1]+=t[ot.BOTTOM]-this._padding[ot.BOTTOM],this._viewport[2]-=t[ot.RIGHT]+t[ot.LEFT]-(this._padding[ot.RIGHT]+this._padding[ot.LEFT]),this._viewport[3]-=t[ot.TOP]+t[ot.BOTTOM]-(this._padding[ot.TOP]+this._padding[ot.BOTTOM]),H(this._padding,t),this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_padding"),this.notifyChange("_viewport"))}get viewProjectionMatrix(){return this._viewProjectionDirty&&(p(this._viewProjectionMatrix,this.projectionMatrix,this.viewMatrix),this._viewProjectionDirty=!1),this._viewProjectionMatrix}get projectionMatrix(){const t=this.width,i=this.height,e=this.near*Math.tan(this.fovY/2)*2,r=e*this._aspect,s=e/this.rows,o=r/this.columns,n=-r/2+this.column*o,h=n+o,a=-e/2+this.row*s,p=a+s,l=u(w(),n*(1+2*this._padding[ot.LEFT]/t),h*(1+2*this._padding[ot.RIGHT]/t),a*(1+2*this._padding[ot.BOTTOM]/i),p*(1+2*this._padding[ot.TOP]/i),this.near,this.far),c=this._get("projectionMatrix");return c&&_(c,l)?c:l}get inverseProjectionMatrix(){return l(w(),this.projectionMatrix)||this._get("inverseProjectionMatrix")||w()}get fov(){return this._fov}set fov(t){this._fov=t,this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovX(){return N(this._fov,this.width,this.height)}set fovX(t){this._fov=J(t,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovY(){return K(this._fov,this.width,this.height)}set fovY(t){this._fov=Q(t,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get distance(){return x(this.center,this.eye)}get frustum(){return this._recomputeFrustum(),this._frustum}get viewInverseTransposeMatrix(){return(this._viewInverseTransposeMatrixDirty||this._viewDirty)&&(l(this._viewInverseTransposeMatrix,this.viewMatrix),c(this._viewInverseTransposeMatrix,this._viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),this._viewInverseTransposeMatrix}depthNDCToWorld(t){const i=2*t-1;return 2*this.near*this.far/(this.far+this.near-i*(this.far-this.near))}get perRenderPixelRatio(){return Math.tan(this.fovX/2)/(this.width/2)}get perScreenPixelRatio(){return this.perRenderPixelRatio*this.pixelRatio}get aboveGround(){return null!=this.relativeElevation&&this.relativeElevation>=0}copyFrom(t){M(this._ray.origin,t.eye),this.center=t.center,this.up=t.up,H(this._viewport,t.viewport),this.notifyChange("_viewport"),H(this._padding,t.padding),this.notifyChange("_padding"),d(this._nearFar,t.nearFar),this.notifyChange("_nearFar"),this._fov=t.fov,this.row=t.row,this.column=t.column,this.rows=t.rows,this.columns=t.columns,this.relativeElevation=t.relativeElevation;const i=t;return this._viewDirty=i._viewDirty,this._viewDirty||(a(this._viewMatrix,t.viewMatrix),this.notifyChange("_viewMatrix")),this._viewProjectionDirty=!0,this._frustumDirty=i._frustumDirty,this._frustumDirty||(z(this._frustum,t.frustum),this._frustumDirty=!1),i._viewInverseTransposeMatrixDirty?this._viewInverseTransposeMatrixDirty=!0:(a(this._viewInverseTransposeMatrix,t.viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),H(this._fullViewport,t.fullViewport),this.pixelRatio=t.pixelRatio,this}copyViewFrom(t){this.eye=t.eye,this.center=t.center,this.up=t.up}clone(){return(new Z).copyFrom(this)}equals(t){return T(this.eye,t.eye)&&T(this.center,t.center)&&T(this.up,t.up)&&L(this._viewport,t.viewport)&&L(this._padding,t.padding)&&y(this.nearFar,t.nearFar)&&this._fov===t.fov&&this.pixelRatio===t.pixelRatio&&this.relativeElevation===t.relativeElevation&&this.row===t.row&&this.column===t.column&&this.rows===t.rows&&this.columns===t.columns}almostEquals(t){const i=Math.max(1,1/this.pixelRatio,1/t.pixelRatio);if(Math.abs(t.fov-this._fov)>=.001||G(t.screenPadding,this.screenPadding)>=i||G(this.screenViewport,t.screenViewport)>=i||this.row!==t.row||this.column!==t.column||this.rows!==t.rows||this.columns!==t.columns)return!1;D(et,t.eye,t.center),D(rt,this.eye,this.center);const e=j(et,rt),r=R(et),s=R(rt),o=5e-4;return e*e>=(1-1e-10)*r*s&&P(t.eye,this.eye)<Math.max(r,s)*o*o}computeRenderPixelSizeAt(t){return this.computeRenderPixelSizeAtDist(this._viewDirectionDistance(t))}computeRenderPixelSizeAtDist(t){return t*this.perRenderPixelRatio}computeScreenPixelSizeAt(t){return this.computeScreenPixelSizeAtDist(this._viewDirectionDistance(t))}_viewDirectionDistance(t){return Math.abs(X(this.viewForward,m(et,t,this.eye)))}computeScreenPixelSizeAtDist(t){return t*this.perScreenPixelRatio}computeDistanceFromRadius(t,i){return t/Math.tan(Math.min(this.fovX,this.fovY)/(2*(i||1)))}getScreenCenter(t=s()){return t[0]=(this.padding[ot.LEFT]+this.width/2)/this.pixelRatio,t[1]=(this.padding[ot.TOP]+this.height/2)/this.pixelRatio,t}getRenderCenter(t,i=.5,e=.5){return t[0]=this.padding[ot.LEFT]+this.width*i,t[1]=this.padding[ot.BOTTOM]+this.height*e,t[2]=.5,t}setGLViewport(t){const i=this.viewport,e=this.padding;t.setViewport(i[0]-e[3],i[1]-e[2],i[2]+e[1]+e[3],i[3]+e[0]+e[2])}applyProjection(t,i){t!==tt&&M(tt,t),tt[3]=1,B(tt,tt,this.projectionMatrix);const e=Math.abs(tt[3]);F(tt,tt,1/e);const s=this.fullViewport;i[0]=r(0,s[0]+s[2],.5+.5*tt[0]),i[1]=r(0,s[1]+s[3],.5+.5*tt[1]),i[2]=.5*(tt[2]+1),i[3]=e}unapplyProjection(t,i){const e=this.fullViewport;tt[0]=(t[0]/(e[0]+e[2])*2-1)*t[3],tt[1]=(t[1]/(e[1]+e[3])*2-1)*t[3],tt[2]=(2*t[2]-1)*t[3],tt[3]=t[3],null!=this.inverseProjectionMatrix&&(B(tt,tt,this.inverseProjectionMatrix),i[0]=tt[0],i[1]=tt[1],i[2]=tt[2])}projectToScreen(t,i){return this.projectToRenderScreen(t,st),this.renderToScreen(st,i),i}projectToRenderScreen(t,i){if(tt[0]=t[0],tt[1]=t[1],tt[2]=t[2],tt[3]=1,B(tt,tt,this.viewProjectionMatrix),0===tt[3])return null;const e=tt;F(e,e,1/Math.abs(tt[3]));const s=this.fullViewport,o=r(0,s[0]+s[2],.5+.5*e[0]),n=r(0,s[1]+s[3],.5+.5*e[1]);return"x"in i?(i.x=o,i.y=n):(i[0]=o,i[1]=n,i.length>2&&(i[2]=.5*(e[2]+1))),i}unprojectFromScreen(t,i){return this.unprojectFromRenderScreen(this.screenToRender(t,st),i)}unprojectFromRenderScreen(t,i){if(p(it,this.projectionMatrix,this.viewMatrix),!l(it,it))return null;const e=this.fullViewport;return tt[0]=2*(t[0]-e[0])/e[2]-1,tt[1]=2*(t[1]-e[1])/e[3]-1,tt[2]=2*t[2]-1,tt[3]=1,B(tt,tt,it),0===tt[3]?null:(i[0]=tt[0]/tt[3],i[1]=tt[1]/tt[3],i[2]=tt[2]/tt[3],i)}constrainWindowSize(t,i,e,r){const s=t*this.pixelRatio,o=i*this.pixelRatio,n=Math.max(s-e/2,0),h=Math.max(this.fullHeight-o-r/2,0),a=-Math.min(s-e/2,0),p=-Math.min(this.fullHeight-o-r/2,0),u=e-a- -Math.min(this.fullWidth-s-e/2,0),_=r-p- -Math.min(o-r/2,0);return[Math.round(n),Math.round(h),Math.round(u),Math.round(_)]}computeUp(t){t===Y.Global?this._computeUpGlobal():this._computeUpLocal()}screenToRender(t,i){const e=t[0]*this.pixelRatio,r=this.fullHeight-t[1]*this.pixelRatio;return i[0]=e,i[1]=r,i}renderToScreen(t,i){const e=t[0]/this.pixelRatio,r=(this.fullHeight-t[1])/this.pixelRatio;i[0]=e,i[1]=r}_computeUpGlobal(){m(et,this.center,this.eye);const t=O(this.center);t<1?(f(this._up,0,0,1),this._markViewDirty(),this.notifyChange("_up")):Math.abs(j(et,this.center))>.9999*O(et)*t||(V(this._up,et,this.center),V(this._up,this._up,et),C(this._up,this._up),this.notifyChange("_up"),this._markViewDirty())}_computeUpLocal(){b(et,this.eye,this.center),Math.abs(et[2])<=.9999&&(F(et,et,et[2]),f(this._up,-et[0],-et[1],1-et[2]),C(this._up,this._up),this.notifyChange("_up"),this._markViewDirty())}_compareAndSetView(t,i,r=""){"number"==typeof t[0]&&isFinite(t[0])&&"number"==typeof t[1]&&isFinite(t[1])&&"number"==typeof t[2]&&isFinite(t[2])?T(t,i)||(M(i,t),this._markViewDirty(),r.length&&this.notifyChange(r)):e.getLogger("esri.views.3d.webgl-engine.lib.Camera").warn("Camera vector contains invalid number, ignoring value")}_markViewDirty(){this._viewDirty=!0,this._frustumDirty=!0,this._viewProjectionDirty=!0}_recomputeFrustum(){this._frustumDirty&&(W(this.viewMatrix,this.projectionMatrix,this._frustum),this._frustumDirty=!1)}_ensureViewClean(){this._viewDirty&&(v(this._viewMatrix,this.eye,this.center,this.up),this.notifyChange("_viewMatrix"),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0)}};t([n()],$.prototype,"_viewport",void 0),t([n()],$.prototype,"_padding",void 0),t([n()],$.prototype,"_fov",void 0),t([n()],$.prototype,"_nearFar",void 0),t([n()],$.prototype,"_viewDirty",void 0),t([n()],$.prototype,"_viewMatrix",void 0),t([n()],$.prototype,"_pixelRatio",void 0),t([n()],$.prototype,"pixelRatio",null),t([n()],$.prototype,"row",void 0),t([n()],$.prototype,"column",void 0),t([n()],$.prototype,"_rows",void 0),t([n()],$.prototype,"rows",null),t([n()],$.prototype,"_columns",void 0),t([n()],$.prototype,"columns",null),t([n()],$.prototype,"eye",null),t([n()],$.prototype,"center",null),t([n()],$.prototype,"_center",void 0),t([n()],$.prototype,"up",null),t([n()],$.prototype,"_up",void 0),t([n({readOnly:!0})],$.prototype,"viewForward",null),t([n({readOnly:!0})],$.prototype,"viewUp",null),t([n({readOnly:!0})],$.prototype,"viewRight",null),t([n({readOnly:!0})],$.prototype,"nearFar",null),t([n()],$.prototype,"near",null),t([n()],$.prototype,"far",null),t([n()],$.prototype,"viewport",null),t([n({readOnly:!0})],$.prototype,"screenViewport",null),t([n({readOnly:!0})],$.prototype,"screenPadding",null),t([n()],$.prototype,"x",null),t([n()],$.prototype,"y",null),t([n()],$.prototype,"width",null),t([n()],$.prototype,"height",null),t([n()],$.prototype,"fullWidth",null),t([n()],$.prototype,"fullHeight",null),t([n({readOnly:!0})],$.prototype,"_aspect",null),t([n()],$.prototype,"padding",null),t([n({readOnly:!0})],$.prototype,"projectionMatrix",null),t([n({readOnly:!0})],$.prototype,"inverseProjectionMatrix",null),t([n()],$.prototype,"fov",null),t([n()],$.prototype,"fovX",null),t([n()],$.prototype,"fovY",null),$=Z=t([h("esri.views.3d.webgl-engine.lib.Camera")],$);const tt=k(),it=w(),et=S(),rt=S(),st=o();var ot;!function(t){t[t.TOP=0]="TOP",t[t.RIGHT=1]="RIGHT",t[t.BOTTOM=2]="BOTTOM",t[t.LEFT=3]="LEFT"}(ot||(ot={}));export{$ as Camera,ot as PaddingSide};
|
|
5
|
+
import{_ as t}from"../../../../chunks/tslib.es6.js";import i from"../../../../core/Accessor.js";import e from"../../../../core/Logger.js";import{lerp as r}from"../../../../core/mathUtils.js";import{createScreenPointArray as s,createRenderScreenPointArray3 as o}from"../../../../core/screenUtils.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{copy as a,multiply as p,frustum as u,equals as _,invert as l,transpose as c,lookAt as v}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as w}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{copy as d,exactEquals as y}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as g}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{f as m,s as f,q as x,c as M,j as T,z as D,k as j,x as R,w as P,h as F,l as O,b as V,n as C,E as b}from"../../../../chunks/vec32.js";import{create as S}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{b as I,e as E,a as L,c as H,d as G,t as B}from"../../../../chunks/vec42.js";import{fromValues as A,create as k}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as U,copy as z,fromMatrix as W}from"../../../../geometry/support/frustum.js";import{create as q}from"../../../../geometry/support/ray.js";import{projectPointSignedLength as X}from"../../../../geometry/support/vector.js";import{ViewingMode as Y}from"../../../ViewingMode.js";import{fovd2fovx as N,fovx2fovd as J,fovd2fovy as K,fovy2fovd as Q}from"./fov.js";var Z;let $=Z=class extends i{constructor(t){super(t),this._ray=q(),this._viewport=A(0,0,1,1),this._padding=A(0,0,0,0),this._fov=55/180*Math.PI,this._nearFar=g(1,1e3),this._viewDirty=!0,this._viewMatrix=w(),this._viewProjectionDirty=!0,this._viewProjectionMatrix=w(),this._viewInverseTransposeMatrixDirty=!0,this._viewInverseTransposeMatrix=w(),this._frustumDirty=!0,this._frustum=U(),this._fullViewport=k(),this._pixelRatio=1,this.row=0,this.column=0,this._rows=1,this._columns=1,this._center=S(),this._up=S(),this.relativeElevation=0}get pixelRatio(){return this._pixelRatio}set pixelRatio(t){this._pixelRatio=t>0?t:1}get rows(){return this._rows}set rows(t){this._rows=Math.max(1,t)}get columns(){return this._columns}set columns(t){this._columns=Math.max(1,t)}get eye(){return this._ray.origin}set eye(t){this._compareAndSetView(t,this._ray.origin)}get center(){return this._center}set center(t){this._compareAndSetView(t,this._center,"_center")}get ray(){return m(this._ray.direction,this.center,this.eye),this._ray}get up(){return this._up}set up(t){this._compareAndSetView(t,this._up,"_up")}get viewMatrix(){return this._ensureViewClean(),this._viewMatrix}set viewMatrix(t){a(this._viewMatrix,t),this.notifyChange("_viewMatrix"),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0,this._viewProjectionDirty=!0,this._frustumDirty=!0}get viewForward(){return this._ensureViewClean(),f(S(),-this._viewMatrix[2],-this._viewMatrix[6],-this._viewMatrix[10])}get viewUp(){return this._ensureViewClean(),f(S(),this._viewMatrix[1],this._viewMatrix[5],this._viewMatrix[9])}get viewRight(){return this._ensureViewClean(),f(S(),this._viewMatrix[0],this._viewMatrix[4],this._viewMatrix[8])}get nearFar(){return this._nearFar}get near(){return this._nearFar[0]}set near(t){this._nearFar[0]!==t&&(this._nearFar[0]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_nearFar"))}get far(){return this._nearFar[1]}set far(t){this._nearFar[1]!==t&&(this._nearFar[1]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_nearFar"))}get viewport(){return this._viewport}set viewport(t){this.x=t[0],this.y=t[1],this.width=t[2],this.height=t[3]}get screenViewport(){if(1===this.pixelRatio)return this._viewport;const t=I(k(),this._viewport,1/this.pixelRatio),i=this._get("screenViewport");return i&&E(t,i)?i:t}get screenPadding(){if(1===this.pixelRatio)return this._padding;const t=I(k(),this._padding,1/this.pixelRatio),i=this._get("screenPadding");return i&&E(t,i)?i:t}get x(){return this._viewport[0]}set x(t){t+=this._padding[ot.LEFT],this._viewport[0]!==t&&(this._viewport[0]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get y(){return this._viewport[1]}set y(t){t+=this._padding[ot.BOTTOM],this._viewport[1]!==t&&(this._viewport[1]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get width(){return this._viewport[2]}set width(t){this._viewport[2]!==t&&(this._viewport[2]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get height(){return this._viewport[3]}set height(t){this._viewport[3]!==t&&(this._viewport[3]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get fullWidth(){return this._viewport[2]+this._padding[ot.RIGHT]+this._padding[ot.LEFT]}set fullWidth(t){this.width=t-(this._padding[ot.RIGHT]+this._padding[ot.LEFT])}get fullHeight(){return this._viewport[3]+this._padding[ot.TOP]+this._padding[ot.BOTTOM]}set fullHeight(t){this.height=t-(this._padding[ot.TOP]+this._padding[ot.BOTTOM])}get fullViewport(){return this._fullViewport[0]=this._viewport[0]-this._padding[ot.LEFT],this._fullViewport[1]=this._viewport[1]-this._padding[ot.BOTTOM],this._fullViewport[2]=this.fullWidth,this._fullViewport[3]=this.fullHeight,this._fullViewport}get _aspect(){return this.width/this.height}get padding(){return this._padding}set padding(t){L(this._padding,t)||(this._viewport[0]+=t[ot.LEFT]-this._padding[ot.LEFT],this._viewport[1]+=t[ot.BOTTOM]-this._padding[ot.BOTTOM],this._viewport[2]-=t[ot.RIGHT]+t[ot.LEFT]-(this._padding[ot.RIGHT]+this._padding[ot.LEFT]),this._viewport[3]-=t[ot.TOP]+t[ot.BOTTOM]-(this._padding[ot.TOP]+this._padding[ot.BOTTOM]),H(this._padding,t),this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_padding"),this.notifyChange("_viewport"))}get viewProjectionMatrix(){return this._viewProjectionDirty&&(p(this._viewProjectionMatrix,this.projectionMatrix,this.viewMatrix),this._viewProjectionDirty=!1),this._viewProjectionMatrix}get projectionMatrix(){const t=this.width,i=this.height,e=this.near*Math.tan(this.fovY/2)*2,r=e*this._aspect,s=e/this.rows,o=r/this.columns,n=-r/2+this.column*o,h=n+o,a=-e/2+this.row*s,p=a+s,l=u(w(),n*(1+2*this._padding[ot.LEFT]/t),h*(1+2*this._padding[ot.RIGHT]/t),a*(1+2*this._padding[ot.BOTTOM]/i),p*(1+2*this._padding[ot.TOP]/i),this.near,this.far),c=this._get("projectionMatrix");return c&&_(c,l)?c:l}get inverseProjectionMatrix(){return l(w(),this.projectionMatrix)||this._get("inverseProjectionMatrix")||w()}get fov(){return this._fov}set fov(t){this._fov=t,this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovX(){return N(this._fov,this.width,this.height)}set fovX(t){this._fov=J(t,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovY(){return K(this._fov,this.width,this.height)}set fovY(t){this._fov=Q(t,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get distance(){return x(this.center,this.eye)}get frustum(){return this._recomputeFrustum(),this._frustum}get viewInverseTransposeMatrix(){return(this._viewInverseTransposeMatrixDirty||this._viewDirty)&&(l(this._viewInverseTransposeMatrix,this.viewMatrix),c(this._viewInverseTransposeMatrix,this._viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),this._viewInverseTransposeMatrix}depthNDCToWorld(t){const i=2*t-1;return 2*this.near*this.far/(this.far+this.near-i*(this.far-this.near))}get perRenderPixelRatio(){return Math.tan(this.fovX/2)/(this.width/2)}get perScreenPixelRatio(){return this.perRenderPixelRatio*this.pixelRatio}get aboveGround(){return null!=this.relativeElevation&&this.relativeElevation>=0}copyFrom(t){M(this._ray.origin,t.eye),this.center=t.center,this.up=t.up,H(this._viewport,t.viewport),this.notifyChange("_viewport"),H(this._padding,t.padding),this.notifyChange("_padding"),d(this._nearFar,t.nearFar),this.notifyChange("_nearFar"),this._fov=t.fov,this.row=t.row,this.column=t.column,this.rows=t.rows,this.columns=t.columns,this.relativeElevation=t.relativeElevation;const i=t;return this._viewDirty=i._viewDirty,this._viewDirty||(a(this._viewMatrix,t.viewMatrix),this.notifyChange("_viewMatrix")),this._viewProjectionDirty=!0,this._frustumDirty=i._frustumDirty,this._frustumDirty||(z(this._frustum,t.frustum),this._frustumDirty=!1),i._viewInverseTransposeMatrixDirty?this._viewInverseTransposeMatrixDirty=!0:(a(this._viewInverseTransposeMatrix,t.viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),H(this._fullViewport,t.fullViewport),this.pixelRatio=t.pixelRatio,this}copyViewFrom(t){this.eye=t.eye,this.center=t.center,this.up=t.up}clone(){return(new Z).copyFrom(this)}equals(t){return T(this.eye,t.eye)&&T(this.center,t.center)&&T(this.up,t.up)&&L(this._viewport,t.viewport)&&L(this._padding,t.padding)&&y(this.nearFar,t.nearFar)&&this._fov===t.fov&&this.pixelRatio===t.pixelRatio&&this.relativeElevation===t.relativeElevation&&this.row===t.row&&this.column===t.column&&this.rows===t.rows&&this.columns===t.columns}almostEquals(t){const i=Math.max(1,1/this.pixelRatio,1/t.pixelRatio);if(Math.abs(t.fov-this._fov)>=.001||G(t.screenPadding,this.screenPadding)>=i||G(this.screenViewport,t.screenViewport)>=i||this.row!==t.row||this.column!==t.column||this.rows!==t.rows||this.columns!==t.columns)return!1;D(et,t.eye,t.center),D(rt,this.eye,this.center);const e=j(et,rt),r=R(et),s=R(rt),o=5e-4;return e*e>=(1-1e-10)*r*s&&P(t.eye,this.eye)<Math.max(r,s)*o*o}computeRenderPixelSizeAt(t){return this.computeRenderPixelSizeAtDist(this._viewDirectionDistance(t))}computeRenderPixelSizeAtDist(t){return t*this.perRenderPixelRatio}computeScreenPixelSizeAt(t){return this.computeScreenPixelSizeAtDist(this._viewDirectionDistance(t))}_viewDirectionDistance(t){return Math.abs(X(this.viewForward,m(et,t,this.eye)))}computeScreenPixelSizeAtDist(t){return t*this.perScreenPixelRatio}computeDistanceFromRadius(t,i){return t/Math.tan(Math.min(this.fovX,this.fovY)/(2*(i||1)))}getScreenCenter(t=s()){return t[0]=(this.padding[ot.LEFT]+this.width/2)/this.pixelRatio,t[1]=(this.padding[ot.TOP]+this.height/2)/this.pixelRatio,t}getRenderCenter(t,i=.5,e=.5){return t[0]=this.padding[ot.LEFT]+this.width*i,t[1]=this.padding[ot.BOTTOM]+this.height*e,t[2]=.5,t}setGLViewport(t){const i=this.viewport,e=this.padding;t.setViewport(i[0]-e[3],i[1]-e[2],i[2]+e[1]+e[3],i[3]+e[0]+e[2])}applyProjection(t,i){t!==tt&&M(tt,t),tt[3]=1,B(tt,tt,this.projectionMatrix);const e=Math.abs(tt[3]);F(tt,tt,1/e);const s=this.fullViewport;i[0]=r(0,s[0]+s[2],.5+.5*tt[0]),i[1]=r(0,s[1]+s[3],.5+.5*tt[1]),i[2]=.5*(tt[2]+1),i[3]=e}unapplyProjection(t,i){const e=this.fullViewport;tt[0]=(t[0]/(e[0]+e[2])*2-1)*t[3],tt[1]=(t[1]/(e[1]+e[3])*2-1)*t[3],tt[2]=(2*t[2]-1)*t[3],tt[3]=t[3],null!=this.inverseProjectionMatrix&&(B(tt,tt,this.inverseProjectionMatrix),i[0]=tt[0],i[1]=tt[1],i[2]=tt[2])}projectToScreen(t,i){return this.projectToRenderScreen(t,st),this.renderToScreen(st,i),i}projectToRenderScreen(t,i){if(tt[0]=t[0],tt[1]=t[1],tt[2]=t[2],tt[3]=1,B(tt,tt,this.viewProjectionMatrix),0===tt[3])return null;const e=tt;F(e,e,1/Math.abs(tt[3]));const s=this.fullViewport,o=r(0,s[0]+s[2],.5+.5*e[0]),n=r(0,s[1]+s[3],.5+.5*e[1]);return"x"in i?(i.x=o,i.y=n):(i[0]=o,i[1]=n,i.length>2&&(i[2]=.5*(e[2]+1))),i}unprojectFromScreen(t,i){return this.unprojectFromRenderScreen(this.screenToRender(t,st),i)}unprojectFromRenderScreen(t,i){if(p(it,this.projectionMatrix,this.viewMatrix),!l(it,it))return null;const e=this.fullViewport;return tt[0]=2*(t[0]-e[0])/e[2]-1,tt[1]=2*(t[1]-e[1])/e[3]-1,tt[2]=2*t[2]-1,tt[3]=1,B(tt,tt,it),0===tt[3]?null:(i[0]=tt[0]/tt[3],i[1]=tt[1]/tt[3],i[2]=tt[2]/tt[3],i)}constrainWindowSize(t,i,e,r){const s=t*this.pixelRatio,o=i*this.pixelRatio,n=Math.max(s-e/2,0),h=Math.max(this.fullHeight-o-r/2,0),a=-Math.min(s-e/2,0),p=-Math.min(this.fullHeight-o-r/2,0),u=e-a- -Math.min(this.fullWidth-s-e/2,0),_=r-p- -Math.min(o-r/2,0);return[Math.round(n),Math.round(h),Math.round(u),Math.round(_)]}computeUp(t){t===Y.Global?this._computeUpGlobal():this._computeUpLocal()}screenToRender(t,i){const e=t[0]*this.pixelRatio,r=this.fullHeight-t[1]*this.pixelRatio;return i[0]=e,i[1]=r,i}renderToScreen(t,i){const e=t[0]/this.pixelRatio,r=(this.fullHeight-t[1])/this.pixelRatio;i[0]=e,i[1]=r}_computeUpGlobal(){m(et,this.center,this.eye);const t=O(this.center);t<1?(f(this._up,0,0,1),this._markViewDirty(),this.notifyChange("_up")):Math.abs(j(et,this.center))>.9999*O(et)*t||(V(this._up,et,this.center),V(this._up,this._up,et),C(this._up,this._up),this.notifyChange("_up"),this._markViewDirty())}_computeUpLocal(){b(et,this.eye,this.center),Math.abs(et[2])<=.9999&&(F(et,et,et[2]),f(this._up,-et[0],-et[1],1-et[2]),C(this._up,this._up),this.notifyChange("_up"),this._markViewDirty())}_compareAndSetView(t,i,r=""){"number"==typeof t[0]&&isFinite(t[0])&&"number"==typeof t[1]&&isFinite(t[1])&&"number"==typeof t[2]&&isFinite(t[2])?T(t,i)||(M(i,t),this._markViewDirty(),r.length&&this.notifyChange(r)):e.getLogger("esri.views.3d.webgl-engine.lib.Camera").warn("Camera vector contains invalid number, ignoring value")}_markViewDirty(){this._viewDirty=!0,this._frustumDirty=!0,this._viewProjectionDirty=!0}_recomputeFrustum(){this._frustumDirty&&(W(this.viewMatrix,this.projectionMatrix,this._frustum),this._frustumDirty=!1)}_ensureViewClean(){this._viewDirty&&(v(this._viewMatrix,this.eye,this.center,this.up),this.notifyChange("_viewMatrix"),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0)}};t([n()],$.prototype,"_viewport",void 0),t([n()],$.prototype,"_padding",void 0),t([n()],$.prototype,"_fov",void 0),t([n()],$.prototype,"_nearFar",void 0),t([n()],$.prototype,"_viewDirty",void 0),t([n()],$.prototype,"_viewMatrix",void 0),t([n()],$.prototype,"_pixelRatio",void 0),t([n()],$.prototype,"pixelRatio",null),t([n()],$.prototype,"row",void 0),t([n()],$.prototype,"column",void 0),t([n()],$.prototype,"_rows",void 0),t([n()],$.prototype,"rows",null),t([n()],$.prototype,"_columns",void 0),t([n()],$.prototype,"columns",null),t([n()],$.prototype,"eye",null),t([n()],$.prototype,"center",null),t([n()],$.prototype,"_center",void 0),t([n()],$.prototype,"up",null),t([n()],$.prototype,"_up",void 0),t([n({readOnly:!0})],$.prototype,"viewForward",null),t([n({readOnly:!0})],$.prototype,"viewUp",null),t([n({readOnly:!0})],$.prototype,"viewRight",null),t([n({readOnly:!0})],$.prototype,"nearFar",null),t([n()],$.prototype,"near",null),t([n()],$.prototype,"far",null),t([n()],$.prototype,"viewport",null),t([n({readOnly:!0})],$.prototype,"screenViewport",null),t([n({readOnly:!0})],$.prototype,"screenPadding",null),t([n()],$.prototype,"x",null),t([n()],$.prototype,"y",null),t([n()],$.prototype,"width",null),t([n()],$.prototype,"height",null),t([n()],$.prototype,"fullWidth",null),t([n()],$.prototype,"fullHeight",null),t([n({readOnly:!0})],$.prototype,"_aspect",null),t([n()],$.prototype,"padding",null),t([n({readOnly:!0})],$.prototype,"projectionMatrix",null),t([n({readOnly:!0})],$.prototype,"inverseProjectionMatrix",null),t([n()],$.prototype,"fov",null),t([n()],$.prototype,"fovX",null),t([n()],$.prototype,"fovY",null),$=Z=t([h("esri.views.3d.webgl-engine.lib.Camera")],$);const tt=k(),it=w(),et=S(),rt=S(),st=o();var ot;!function(t){t[t.TOP=0]="TOP",t[t.RIGHT=1]="RIGHT",t[t.BOTTOM=2]="BOTTOM",t[t.LEFT=3]="LEFT"}(ot||(ot={}));export{$ as Camera,ot as PaddingSide};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{copy as t,multiply as e,hasIdentityRotation as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as s,create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{m as o,e as a,q as n,s as m,g as h,j as c,c as l}from"../../../../chunks/vec32.js";import{fromValues as d,create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{g,
|
|
5
|
+
import{copy as t,multiply as e,hasIdentityRotation as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as s,create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{m as o,e as a,q as n,s as m,g as h,j as c,c as l}from"../../../../chunks/vec32.js";import{fromValues as d,create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{g,c as f}from"../../../../chunks/sphere.js";import{maxScale as b}from"../../support/mathUtils.js";import{Object3DState as _}from"./basicInterfaces.js";import{ContentObject as p}from"./ContentObject.js";import{ContentObjectType as v}from"./ContentObjectType.js";import{Object3DStateID as j}from"./Object3DStateID.js";import{assert as y}from"./Util.js";import{affectsGeometry as S}from"./VertexAttribute.js";import{addObject3DStateID as x,removeObject3DStateID as V}from"../materials/renderers/utils.js";class O extends p{get geometries(){return this._geometries}get transformation(){return this._transformation??s}set transformation(e){this._transformation=t(this._transformation??r(),e),this._invalidateBoundingVolume(),this._emit("transformationChanged",this)}get shaderTransformation(){return this._shaderTransformation}set shaderTransformation(e){this._shaderTransformation=e?t(this._shaderTransformation??r(),e):null,this._invalidateBoundingVolume(),this._emit("shaderTransformationChanged",this)}get effectiveTransformation(){return this.shaderTransformation??this.transformation}constructor(t={}){super(),this.type=v.Object,this._shaderTransformation=null,this._parentLayer=null,this._visible=!0,this.castShadow=t.castShadow??!0,this.usesVerticalDistanceToGround=t.usesVerticalDistanceToGround??!1,this.graphicUid=t.graphicUid,this.layerUid=t.layerUid,t.isElevationSource&&(this.lastValidElevationBB=new A),this._geometries=t.geometries?Array.from(t.geometries):new Array}dispose(){this._geometries.length=0}get parentLayer(){return this._parentLayer}set parentLayer(t){y(null==this._parentLayer||null==t,"Object3D can only be added to a single Layer"),this._parentLayer=t}addGeometry(t){t.visible=this._visible,this._geometries.push(t),this._emit("geometryAdded",{object:this,geometry:t}),this._invalidateBoundingVolume()}removeGeometry(t){const e=this._geometries.splice(t,1)[0];e&&(this._emit("geometryRemoved",{object:this,geometry:e}),this._invalidateBoundingVolume())}removeAllGeometries(){for(;this._geometries.length>0;)this.removeGeometry(0)}geometryVertexAttributeUpdated(t,e,i=!1){this._emit("attributesChanged",{object:this,geometry:t,attribute:e,sync:i}),S(e)&&this._invalidateBoundingVolume()}get visible(){return this._visible}set visible(t){if(this._visible!==t){this._visible=t;for(const t of this._geometries)t.visible=this._visible;this._emit("visibilityChanged",this)}}maskOccludee(){const t=new j(_.MaskOccludee);for(const e of this._geometries)e.occludees=x(e.occludees,t);return this._emit("occlusionChanged",this),t}removeOcclude(t){for(const e of this._geometries)e.occludees=V(e.occludees,t);this._emit("occlusionChanged",this)}highlight(){const t=new j(_.Highlight);for(const e of this._geometries)e.highlights=x(e.highlights,t);return this._emit("highlightChanged",this),t}removeHighlight(t){for(const e of this._geometries)e.highlights=V(e.highlights,t);this._emit("highlightChanged",this)}getCombinedStaticTransformation(t,i){return e(i,this.transformation,t.transformation)}getCombinedShaderTransformation(t,i=r()){return e(i,this.effectiveTransformation,t.transformation)}get boundingVolumeWorldSpace(){return this._bvWorldSpace||(this._bvWorldSpace=this._bvWorldSpace||new M,this._validateBoundingVolume(this._bvWorldSpace,W.WorldSpace)),this._bvWorldSpace}get boundingVolumeObjectSpace(){return this._bvObjectSpace||(this._bvObjectSpace=this._bvObjectSpace||new M,this._validateBoundingVolume(this._bvObjectSpace,W.ObjectSpace)),this._bvObjectSpace}_validateBoundingVolume(t,e){const i=e===W.ObjectSpace;for(const s of this._geometries){const e=s.boundingInfo;e&&L(e,t,i?s.transformation:this.getCombinedShaderTransformation(s))}o(g(t.bounds),t.min,t.max,.5);for(const s of this._geometries){const e=s.boundingInfo;if(null==e)continue;const r=i?s.transformation:this.getCombinedShaderTransformation(s),o=b(r);a(U,e.center,r);const m=n(U,g(t.bounds)),h=e.radius*o;t.bounds[3]=Math.max(t.bounds[3],m+h)}}_invalidateBoundingVolume(){const t=this._bvWorldSpace?.bounds;this._bvObjectSpace=this._bvWorldSpace=void 0,this._parentLayer&&t&&this._parentLayer.notifyObjectBBChanged(this,t)}_emit(t,e){this._parentLayer&&this._parentLayer.events.emit(t,e)}get test(){const t=this;return{hasGeometry:e=>t._geometries.includes(e),getGeometryIndex:e=>t._geometries.indexOf(e)}}}class A{constructor(){this.min=d(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this.max=d(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE)}isEmpty(){return this.max[0]<this.min[0]&&this.max[1]<this.min[1]&&this.max[2]<this.min[2]}}class M extends A{constructor(){super(...arguments),this.bounds=f()}}function L(t,e,s){const r=t.bbMin,o=t.bbMax;if(i(s)){const t=m(T,s[12],s[13],s[14]);h(C,r,t),h(B,o,t);for(let i=0;i<3;++i)e.min[i]=Math.min(e.min[i],C[i]),e.max[i]=Math.max(e.max[i],B[i])}else if(a(C,r,s),c(r,o))for(let i=0;i<3;++i)e.min[i]=Math.min(e.min[i],C[i]),e.max[i]=Math.max(e.max[i],C[i]);else{a(B,o,s);for(let t=0;t<3;++t)e.min[t]=Math.min(e.min[t],C[t],B[t]),e.max[t]=Math.max(e.max[t],C[t],B[t]);for(let t=0;t<3;++t){l(C,r),l(B,o),C[t]=o[t],B[t]=r[t],a(C,C,s),a(B,B,s);for(let t=0;t<3;++t)e.min[t]=Math.min(e.min[t],C[t],B[t]),e.max[t]=Math.max(e.max[t],C[t],B[t])}}}const T=u(),C=u(),B=u(),U=u();var W;!function(t){t[t.WorldSpace=0]="WorldSpace",t[t.ObjectSpace=1]="ObjectSpace"}(W||(W={}));export{O as Object3D};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/ObjectPool.js";import t from"../../../../core/PooledArray.js";import{h as o,g as n,a as i,c as s,m as r}from"../../../../chunks/vec32.js";import{create as h,fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as d}from"../../../../geometry/support/frustum.js";import{wrap as l}from"../../../../geometry/support/ray.js";import{c as u,g as c,a as f,i as m,d as _}from"../../../../chunks/sphere.js";import{rayBoxTest as p}from"./Util.js";class b{get bounds(){return this._root.bounds}get halfSize(){return this._root.halfSize}get root(){return this._root.node}get maximumObjectsPerNode(){return this._maximumObjectsPerNode}get maximumDepth(){return this._maximumDepth}get objectCount(){return this._objectCount}constructor(e,t){this.objectToBoundingSphere=e,this._maximumObjectsPerNode=10,this._maximumDepth=20,this._degenerateObjects=new Set,this._root=new g,this._objectCount=0,t&&(void 0!==t.maximumObjectsPerNode&&(this._maximumObjectsPerNode=t.maximumObjectsPerNode),void 0!==t.maximumDepth&&(this._maximumDepth=t.maximumDepth))}destroy(){this._degenerateObjects.clear(),g.clearPool(),B[0]=null,P.prune(),H.prune()}add(e,t=e.length){this._objectCount+=t,this._grow(e,t);const o=g.acquire();for(let n=0;n<t;n++){const t=e[n];this._isDegenerate(t)?this._degenerateObjects.add(t):(o.init(this._root),this._add(t,o))}g.release(o)}remove(e,t=null){this._objectCount-=e.length;const o=g.acquire();for(const n of e){const e=t??u(this.objectToBoundingSphere(n),w);E(e[3])?(o.init(this._root),this._remove(n,e,o)):this._degenerateObjects.delete(n)}g.release(o),this._shrink()}update(e,t){if(!E(t[3])&&this._isDegenerate(e))return;const o=R(e);this.remove(o,t),this.add(o)}forEachAlongRay(e,t,o){const n=l(e,t);this._forEachNode(this._root,(e=>{if(!this._intersectsNode(n,e))return!1;const t=e.node;return t.terminals.forAll((e=>{this._intersectsObject(n,e)&&o(e)})),null!==t.residents&&t.residents.forAll((e=>{this._intersectsObject(n,e)&&o(e)})),!0}))}forEachAlongRayWithVerticalOffset(e,t,o,n){const i=l(e,t);this._forEachNode(this._root,(e=>{if(!this._intersectsNodeWithOffset(i,e,n))return!1;const t=e.node;return t.terminals.forAll((e=>{this._intersectsObjectWithOffset(i,e,n)&&o(e)})),null!==t.residents&&t.residents.forAll((e=>{this._intersectsObjectWithOffset(i,e,n)&&o(e)})),!0}))}forEach(e){this._forEachNode(this._root,(t=>{const o=t.node;return o.terminals.forAll(e),null!==o.residents&&o.residents.forAll(e),!0})),this._degenerateObjects.forEach(e)}forEachDegenerateObject(e){this._degenerateObjects.forEach(e)}findClosest(e,t,i,s=(()=>!0),r=1/0){let h=1/0,a=1/0,l=null;const u=T(e,t),f=o=>{if(--r,!s(o))return;const n=this.objectToBoundingSphere(o);if(!d(i,n))return;const u=z(e,t,c(n)),f=u-n[3],m=u+n[3];f<h&&(h=f,a=m,l=o)};return this._forEachNodeDepthOrdered(this._root,(s=>{if(r<=0||!d(i,s.bounds))return!1;o(v,u,s.halfSize),n(v,v,c(s.bounds));if(z(e,t,v)>a)return!1;const h=s.node;return h.terminals.forAll((e=>f(e))),null!==h.residents&&h.residents.forAll((e=>f(e))),!0}),e,t),l}forEachInDepthRange(e,t,i,s,r,h,a){let l=-1/0,u=1/0;const f={setRange:e=>{i===b.DepthOrder.FRONT_TO_BACK?(l=Math.max(l,e.near),u=Math.min(u,e.far)):(l=Math.max(l,-e.far),u=Math.min(u,-e.near))}};f.setRange(s);const m=z(t,i,e),_=T(t,i),p=T(t,-i),g=e=>{if(!a(e))return;const o=this.objectToBoundingSphere(e),n=c(o),s=z(t,i,n)-m,_=s-o[3],p=s+o[3];_>u||p<l||!d(h,o)||r(e,f)};this._forEachNodeDepthOrdered(this._root,(e=>{if(!d(h,e.bounds))return!1;o(v,_,e.halfSize),n(v,v,c(e.bounds));if(z(t,i,v)-m>u)return!1;o(v,p,e.halfSize),n(v,v,c(e.bounds));if(z(t,i,v)-m<l)return!1;const s=e.node;return s.terminals.forAll((e=>g(e))),null!==s.residents&&s.residents.forAll((e=>g(e))),!0}),t,i)}forEachNode(e){this._forEachNode(this._root,(t=>e(t.node,t.bounds,t.halfSize,t.depth)))}forEachNeighbor(e,t){const o=f(t),n=c(t),s=t=>{const s=this.objectToBoundingSphere(t),r=f(s),h=o+r;return!(i(c(s),n)-h*h<=0)||e(t)};let r=!0;const h=e=>{r&&(r=s(e))};this._forEachNode(this._root,(e=>{const t=f(e.bounds),s=o+t;if(i(c(e.bounds),n)-s*s>0)return!1;const a=e.node;return a.terminals.forAll(h),r&&null!==a.residents&&a.residents.forAll(h),r})),r&&this.forEachDegenerateObject(h)}_intersectsNode(e,t){return j(c(t.bounds),2*-t.halfSize,C),j(c(t.bounds),2*t.halfSize,y),p(e.origin,e.direction,C,y)}_intersectsNodeWithOffset(e,t,o){return j(c(t.bounds),2*-t.halfSize,C),j(c(t.bounds),2*t.halfSize,y),o.applyToMinMax(C,y),p(e.origin,e.direction,C,y)}_intersectsObject(e,t){const o=this.objectToBoundingSphere(t);return!(o[3]>0)||m(o,e)}_intersectsObjectWithOffset(e,t,o){const n=this.objectToBoundingSphere(t);return!(n[3]>0)||m(o.applyToBoundingSphere(n),e)}_forEachNode(e,t){let o=g.acquire().init(e);const n=[o];for(;0!==n.length;){if(o=n.pop(),t(o)&&!o.isLeaf())for(let e=0;e<o.node.children.length;e++){o.node.children[e]&&n.push(g.acquire().init(o).advance(e))}g.release(o)}}_forEachNodeDepthOrdered(e,t,o,n=b.DepthOrder.FRONT_TO_BACK){let i=g.acquire().init(e);const s=[i];for(N(o,n,K);0!==s.length;){if(i=s.pop(),t(i)&&!i.isLeaf())for(let e=7;e>=0;--e){const t=K[e];i.node.children[t]&&s.push(g.acquire().init(i).advance(t))}g.release(i)}}_remove(e,t,o){P.clear();const n=o.advanceTo(t,((e,t)=>{P.push(e.node),P.push(t)}))?o.node.terminals:o.node.residents;if(n.removeUnordered(e),0===n.length)for(let i=P.length-2;i>=0;i-=2){const e=P.data[i],t=P.data[i+1];if(!this._purge(e,t))break}}_nodeIsEmpty(e){if(0!==e.terminals.length)return!1;if(null!==e.residents)return 0===e.residents.length;for(let t=0;t<e.children.length;t++)if(e.children[t])return!1;return!0}_purge(e,o){return o>=0&&(e.children[o]=null),!!this._nodeIsEmpty(e)&&(null===e.residents&&(e.residents=new t({shrink:!0})),!0)}_add(e,t){t.advanceTo(this.objectToBoundingSphere(e))?t.node.terminals.push(e):(t.node.residents.push(e),t.node.residents.length>this._maximumObjectsPerNode&&t.depth<this._maximumDepth&&this._split(t))}_split(e){const t=e.node.residents;e.node.residents=null;for(let o=0;o<t.length;o++){const n=g.acquire().init(e);this._add(t.at(o),n),g.release(n)}}_grow(e,t){if(0!==t&&(x(e,t,(e=>this.objectToBoundingSphere(e)),q),E(q[3])&&!this._fitsInsideTree(q)))if(this._nodeIsEmpty(this._root.node))u(q,this._root.bounds),this._root.halfSize=1.25*this._root.bounds[3],this._root.updateBoundsRadiusFromHalfSize();else{const e=this._rootBoundsForRootAsSubNode(q);this._placingRootViolatesMaxDepth(e)?this._rebuildTree(q,e):this._growRootAsSubNode(e),g.release(e)}}_rebuildTree(e,t){s(c(k),c(t.bounds)),k[3]=t.halfSize,x([e,k],2,(e=>e),I);const o=g.acquire().init(this._root);this._root.initFrom(null,I,I[3]),this._root.increaseHalfSize(1.25),this._forEachNode(o,(e=>(this.add(e.node.terminals.data,e.node.terminals.length),null!==e.node.residents&&this.add(e.node.residents.data,e.node.residents.length),!0))),g.release(o)}_placingRootViolatesMaxDepth(e){const t=Math.log(e.halfSize/this._root.halfSize)*Math.LOG2E;let o=0;return this._forEachNode(this._root,(e=>(o=Math.max(o,e.depth),o+t<=this._maximumDepth))),o+t>this._maximumDepth}_rootBoundsForRootAsSubNode(e){const t=e[3],o=e;let n=-1/0;const i=this._root.bounds,s=this._root.halfSize;for(let h=0;h<3;h++){const e=i[h]-s-(o[h]-t),r=o[h]+t-(i[h]+s),a=Math.max(0,Math.ceil(e/(2*s))),d=Math.max(0,Math.ceil(r/(2*s)))+1,l=2**Math.ceil(Math.log(a+d)*Math.LOG2E);n=Math.max(n,l),L[h].min=a,L[h].max=d}for(let h=0;h<3;h++){let e=L[h].min,t=L[h].max;const o=(n-(e+t))/2;e+=Math.ceil(o),t+=Math.floor(o);const r=i[h]-s-e*s*2;F[h]=r+(t+e)*s}const r=n*s;return F[3]=r*A,g.acquire().initFrom(null,F,r,0)}_growRootAsSubNode(e){const t=this._root.node;s(c(q),c(this._root.bounds)),q[3]=this._root.halfSize,this._root.init(e),e.advanceTo(q,null,!0),e.node.children=t.children,e.node.residents=t.residents,e.node.terminals=t.terminals}_shrink(){for(;;){const e=this._findShrinkIndex();if(-1===e)break;this._root.advance(e),this._root.depth=0}}_findShrinkIndex(){if(0!==this._root.node.terminals.length||this._root.isLeaf())return-1;let e=null;const t=this._root.node.children;let o=0,n=0;for(;n<t.length&&null==e;)o=n++,e=t[o];for(;n<t.length;)if(t[n++])return-1;return o}_isDegenerate(e){return!E(this.objectToBoundingSphere(e)[3])}_fitsInsideTree(e){const t=this._root.bounds,o=this._root.halfSize;return e[3]<=o&&e[0]>=t[0]-o&&e[0]<=t[0]+o&&e[1]>=t[1]-o&&e[1]<=t[1]+o&&e[2]>=t[2]-o&&e[2]<=t[2]+o}toJSON(){const{maximumDepth:e,maximumObjectsPerNode:t,_objectCount:o}=this,n=this._nodeToJSON(this._root.node);return{maximumDepth:e,maximumObjectsPerNode:t,objectCount:o,root:{bounds:this._root.bounds,halfSize:this._root.halfSize,depth:this._root.depth,node:n}}}_nodeToJSON(e){const t=e.children.map((e=>e?this._nodeToJSON(e):null)),o=e.residents?.map((e=>this.objectToBoundingSphere(e))),n=e.terminals?.map((e=>this.objectToBoundingSphere(e)));return{children:t,residents:o,terminals:n}}static fromJSON(e){const t=new b((e=>e),{maximumDepth:e.maximumDepth,maximumObjectsPerNode:e.maximumObjectsPerNode});return t._objectCount=e.objectCount,t._root.initFrom(e.root.node,e.root.bounds,e.root.halfSize,e.root.depth),t}}class g{constructor(){this.bounds=_(),this.halfSize=0,this.initFrom(null,null,0,0)}init(e){return this.initFrom(e.node,e.bounds,e.halfSize,e.depth)}initFrom(e,t,o,n=this.depth){return this.node=null!=e?e:g.createEmptyNode(),t&&u(t,this.bounds),this.halfSize=o,this.depth=n,this}increaseHalfSize(e){this.halfSize*=e,this.updateBoundsRadiusFromHalfSize()}updateBoundsRadiusFromHalfSize(){this.bounds[3]=this.halfSize*A}advance(e){let t=this.node.children[e];t||(t=g.createEmptyNode(),this.node.children[e]=t),this.node=t,this.halfSize/=2,this.depth++;const o=M[e];return this.bounds[0]+=o[0]*this.halfSize,this.bounds[1]+=o[1]*this.halfSize,this.bounds[2]+=o[2]*this.halfSize,this.updateBoundsRadiusFromHalfSize(),this}advanceTo(e,t,o=!1){for(;;){if(this.isTerminalFor(e))return t&&t(this,-1),!0;if(this.isLeaf()){if(!o)return t&&t(this,-1),!1;this.node.residents=null}const n=this._childIndex(e);t&&t(this,n),this.advance(n)}}isLeaf(){return null!=this.node.residents}isTerminalFor(e){return e[3]>this.halfSize/2}_childIndex(e){const t=this.bounds;return(t[0]<e[0]?1:0)+(t[1]<e[1]?2:0)+(t[2]<e[2]?4:0)}static createEmptyNode(){return{children:[null,null,null,null,null,null,null,null],terminals:new t({shrink:!0}),residents:new t({shrink:!0})}}static acquire(){return g._pool.acquire()}static release(e){g._pool.release(e)}static clearPool(){g._pool.prune()}}function S(e,t){e[0]=Math.min(e[0],t[0]-t[3]),e[1]=Math.min(e[1],t[1]-t[3]),e[2]=Math.min(e[2],t[2]-t[3])}function O(e,t){e[0]=Math.max(e[0],t[0]+t[3]),e[1]=Math.max(e[1],t[1]+t[3]),e[2]=Math.max(e[2],t[2]+t[3])}function j(e,t,o){o[0]=e[0]+t,o[1]=e[1]+t,o[2]=e[2]+t}function x(e,t,o,n){if(1===t){const t=o(e[0]);u(t,n)}else{C[0]=1/0,C[1]=1/0,C[2]=1/0,y[0]=-1/0,y[1]=-1/0,y[2]=-1/0;for(let n=0;n<t;n++){const t=o(e[n]);E(t[3])&&(S(C,t),O(y,t))}r(c(n),C,y,.5),n[3]=Math.max(y[0]-C[0],y[1]-C[1],y[2]-C[2])/2}}function N(e,t,o){if(!H.length)for(let n=0;n<8;++n)H.push({index:0,distance:0});for(let n=0;n<8;++n){const o=M[n];H.data[n].index=n,H.data[n].distance=z(e,t,o)}H.sort(((e,t)=>e.distance-t.distance));for(let n=0;n<8;++n)o[n]=H.data[n].index}function T(e,t){let o,n=1/0;for(let i=0;i<8;++i){const s=z(e,t,D[i]);s<n&&(n=s,o=D[i])}return o}function z(e,t,o){return t*(e[0]*o[0]+e[1]*o[1]+e[2]*o[2])}function E(e){return!isNaN(e)&&e!==-1/0&&e!==1/0&&e>0}g._pool=new e(g),function(e){var t;(t=e.DepthOrder||(e.DepthOrder={}))[t.FRONT_TO_BACK=1]="FRONT_TO_BACK",t[t.BACK_TO_FRONT=-1]="BACK_TO_FRONT"}(b||(b={}));const M=[a(-1,-1,-1),a(1,-1,-1),a(-1,1,-1),a(1,1,-1),a(-1,-1,1),a(1,-1,1),a(-1,1,1),a(1,1,1)],D=[a(-1,-1,-1),a(-1,-1,1),a(-1,1,-1),a(-1,1,1),a(1,-1,-1),a(1,-1,1),a(1,1,-1),a(1,1,1)],A=Math.sqrt(3),B=[null];function R(e){return B[0]=e,B}const F=_(),v=h(),C=h(),y=h(),P=new t,w=_(),q=_(),k=_(),I=_(),L=[{min:0,max:0},{min:0,max:0},{min:0,max:0}],H=new t,K=[0,0,0,0,0,0,0,0],W=b;export{W as default};
|
|
5
|
+
import e from"../../../../core/ObjectPool.js";import t from"../../../../core/PooledArray.js";import{h as o,g as n,a as i,c as s,m as r}from"../../../../chunks/vec32.js";import{create as h,fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as d}from"../../../../geometry/support/frustum.js";import{wrap as l}from"../../../../geometry/support/ray.js";import{a as u,g as c,b as f,j as m,c as _}from"../../../../chunks/sphere.js";import{rayBoxTest as p}from"./Util.js";class b{get bounds(){return this._root.bounds}get halfSize(){return this._root.halfSize}get root(){return this._root.node}get maximumObjectsPerNode(){return this._maximumObjectsPerNode}get maximumDepth(){return this._maximumDepth}get objectCount(){return this._objectCount}constructor(e,t){this.objectToBoundingSphere=e,this._maximumObjectsPerNode=10,this._maximumDepth=20,this._degenerateObjects=new Set,this._root=new g,this._objectCount=0,t&&(void 0!==t.maximumObjectsPerNode&&(this._maximumObjectsPerNode=t.maximumObjectsPerNode),void 0!==t.maximumDepth&&(this._maximumDepth=t.maximumDepth))}destroy(){this._degenerateObjects.clear(),g.clearPool(),B[0]=null,P.prune(),H.prune()}add(e,t=e.length){this._objectCount+=t,this._grow(e,t);const o=g.acquire();for(let n=0;n<t;n++){const t=e[n];this._isDegenerate(t)?this._degenerateObjects.add(t):(o.init(this._root),this._add(t,o))}g.release(o)}remove(e,t=null){this._objectCount-=e.length;const o=g.acquire();for(const n of e){const e=t??u(this.objectToBoundingSphere(n),w);E(e[3])?(o.init(this._root),this._remove(n,e,o)):this._degenerateObjects.delete(n)}g.release(o),this._shrink()}update(e,t){if(!E(t[3])&&this._isDegenerate(e))return;const o=R(e);this.remove(o,t),this.add(o)}forEachAlongRay(e,t,o){const n=l(e,t);this._forEachNode(this._root,(e=>{if(!this._intersectsNode(n,e))return!1;const t=e.node;return t.terminals.forAll((e=>{this._intersectsObject(n,e)&&o(e)})),null!==t.residents&&t.residents.forAll((e=>{this._intersectsObject(n,e)&&o(e)})),!0}))}forEachAlongRayWithVerticalOffset(e,t,o,n){const i=l(e,t);this._forEachNode(this._root,(e=>{if(!this._intersectsNodeWithOffset(i,e,n))return!1;const t=e.node;return t.terminals.forAll((e=>{this._intersectsObjectWithOffset(i,e,n)&&o(e)})),null!==t.residents&&t.residents.forAll((e=>{this._intersectsObjectWithOffset(i,e,n)&&o(e)})),!0}))}forEach(e){this._forEachNode(this._root,(t=>{const o=t.node;return o.terminals.forAll(e),null!==o.residents&&o.residents.forAll(e),!0})),this._degenerateObjects.forEach(e)}forEachDegenerateObject(e){this._degenerateObjects.forEach(e)}findClosest(e,t,i,s=(()=>!0),r=1/0){let h=1/0,a=1/0,l=null;const u=T(e,t),f=o=>{if(--r,!s(o))return;const n=this.objectToBoundingSphere(o);if(!d(i,n))return;const u=z(e,t,c(n)),f=u-n[3],m=u+n[3];f<h&&(h=f,a=m,l=o)};return this._forEachNodeDepthOrdered(this._root,(s=>{if(r<=0||!d(i,s.bounds))return!1;o(v,u,s.halfSize),n(v,v,c(s.bounds));if(z(e,t,v)>a)return!1;const h=s.node;return h.terminals.forAll((e=>f(e))),null!==h.residents&&h.residents.forAll((e=>f(e))),!0}),e,t),l}forEachInDepthRange(e,t,i,s,r,h,a){let l=-1/0,u=1/0;const f={setRange:e=>{i===b.DepthOrder.FRONT_TO_BACK?(l=Math.max(l,e.near),u=Math.min(u,e.far)):(l=Math.max(l,-e.far),u=Math.min(u,-e.near))}};f.setRange(s);const m=z(t,i,e),_=T(t,i),p=T(t,-i),g=e=>{if(!a(e))return;const o=this.objectToBoundingSphere(e),n=c(o),s=z(t,i,n)-m,_=s-o[3],p=s+o[3];_>u||p<l||!d(h,o)||r(e,f)};this._forEachNodeDepthOrdered(this._root,(e=>{if(!d(h,e.bounds))return!1;o(v,_,e.halfSize),n(v,v,c(e.bounds));if(z(t,i,v)-m>u)return!1;o(v,p,e.halfSize),n(v,v,c(e.bounds));if(z(t,i,v)-m<l)return!1;const s=e.node;return s.terminals.forAll((e=>g(e))),null!==s.residents&&s.residents.forAll((e=>g(e))),!0}),t,i)}forEachNode(e){this._forEachNode(this._root,(t=>e(t.node,t.bounds,t.halfSize,t.depth)))}forEachNeighbor(e,t){const o=f(t),n=c(t),s=t=>{const s=this.objectToBoundingSphere(t),r=f(s),h=o+r;return!(i(c(s),n)-h*h<=0)||e(t)};let r=!0;const h=e=>{r&&(r=s(e))};this._forEachNode(this._root,(e=>{const t=f(e.bounds),s=o+t;if(i(c(e.bounds),n)-s*s>0)return!1;const a=e.node;return a.terminals.forAll(h),r&&null!==a.residents&&a.residents.forAll(h),r})),r&&this.forEachDegenerateObject(h)}_intersectsNode(e,t){return j(c(t.bounds),2*-t.halfSize,C),j(c(t.bounds),2*t.halfSize,y),p(e.origin,e.direction,C,y)}_intersectsNodeWithOffset(e,t,o){return j(c(t.bounds),2*-t.halfSize,C),j(c(t.bounds),2*t.halfSize,y),o.applyToMinMax(C,y),p(e.origin,e.direction,C,y)}_intersectsObject(e,t){const o=this.objectToBoundingSphere(t);return!(o[3]>0)||m(o,e)}_intersectsObjectWithOffset(e,t,o){const n=this.objectToBoundingSphere(t);return!(n[3]>0)||m(o.applyToBoundingSphere(n),e)}_forEachNode(e,t){let o=g.acquire().init(e);const n=[o];for(;0!==n.length;){if(o=n.pop(),t(o)&&!o.isLeaf())for(let e=0;e<o.node.children.length;e++){o.node.children[e]&&n.push(g.acquire().init(o).advance(e))}g.release(o)}}_forEachNodeDepthOrdered(e,t,o,n=b.DepthOrder.FRONT_TO_BACK){let i=g.acquire().init(e);const s=[i];for(N(o,n,K);0!==s.length;){if(i=s.pop(),t(i)&&!i.isLeaf())for(let e=7;e>=0;--e){const t=K[e];i.node.children[t]&&s.push(g.acquire().init(i).advance(t))}g.release(i)}}_remove(e,t,o){P.clear();const n=o.advanceTo(t,((e,t)=>{P.push(e.node),P.push(t)}))?o.node.terminals:o.node.residents;if(n.removeUnordered(e),0===n.length)for(let i=P.length-2;i>=0;i-=2){const e=P.data[i],t=P.data[i+1];if(!this._purge(e,t))break}}_nodeIsEmpty(e){if(0!==e.terminals.length)return!1;if(null!==e.residents)return 0===e.residents.length;for(let t=0;t<e.children.length;t++)if(e.children[t])return!1;return!0}_purge(e,o){return o>=0&&(e.children[o]=null),!!this._nodeIsEmpty(e)&&(null===e.residents&&(e.residents=new t({shrink:!0})),!0)}_add(e,t){t.advanceTo(this.objectToBoundingSphere(e))?t.node.terminals.push(e):(t.node.residents.push(e),t.node.residents.length>this._maximumObjectsPerNode&&t.depth<this._maximumDepth&&this._split(t))}_split(e){const t=e.node.residents;e.node.residents=null;for(let o=0;o<t.length;o++){const n=g.acquire().init(e);this._add(t.at(o),n),g.release(n)}}_grow(e,t){if(0!==t&&(x(e,t,(e=>this.objectToBoundingSphere(e)),q),E(q[3])&&!this._fitsInsideTree(q)))if(this._nodeIsEmpty(this._root.node))u(q,this._root.bounds),this._root.halfSize=1.25*this._root.bounds[3],this._root.updateBoundsRadiusFromHalfSize();else{const e=this._rootBoundsForRootAsSubNode(q);this._placingRootViolatesMaxDepth(e)?this._rebuildTree(q,e):this._growRootAsSubNode(e),g.release(e)}}_rebuildTree(e,t){s(c(k),c(t.bounds)),k[3]=t.halfSize,x([e,k],2,(e=>e),I);const o=g.acquire().init(this._root);this._root.initFrom(null,I,I[3]),this._root.increaseHalfSize(1.25),this._forEachNode(o,(e=>(this.add(e.node.terminals.data,e.node.terminals.length),null!==e.node.residents&&this.add(e.node.residents.data,e.node.residents.length),!0))),g.release(o)}_placingRootViolatesMaxDepth(e){const t=Math.log(e.halfSize/this._root.halfSize)*Math.LOG2E;let o=0;return this._forEachNode(this._root,(e=>(o=Math.max(o,e.depth),o+t<=this._maximumDepth))),o+t>this._maximumDepth}_rootBoundsForRootAsSubNode(e){const t=e[3],o=e;let n=-1/0;const i=this._root.bounds,s=this._root.halfSize;for(let h=0;h<3;h++){const e=i[h]-s-(o[h]-t),r=o[h]+t-(i[h]+s),a=Math.max(0,Math.ceil(e/(2*s))),d=Math.max(0,Math.ceil(r/(2*s)))+1,l=2**Math.ceil(Math.log(a+d)*Math.LOG2E);n=Math.max(n,l),L[h].min=a,L[h].max=d}for(let h=0;h<3;h++){let e=L[h].min,t=L[h].max;const o=(n-(e+t))/2;e+=Math.ceil(o),t+=Math.floor(o);const r=i[h]-s-e*s*2;F[h]=r+(t+e)*s}const r=n*s;return F[3]=r*A,g.acquire().initFrom(null,F,r,0)}_growRootAsSubNode(e){const t=this._root.node;s(c(q),c(this._root.bounds)),q[3]=this._root.halfSize,this._root.init(e),e.advanceTo(q,null,!0),e.node.children=t.children,e.node.residents=t.residents,e.node.terminals=t.terminals}_shrink(){for(;;){const e=this._findShrinkIndex();if(-1===e)break;this._root.advance(e),this._root.depth=0}}_findShrinkIndex(){if(0!==this._root.node.terminals.length||this._root.isLeaf())return-1;let e=null;const t=this._root.node.children;let o=0,n=0;for(;n<t.length&&null==e;)o=n++,e=t[o];for(;n<t.length;)if(t[n++])return-1;return o}_isDegenerate(e){return!E(this.objectToBoundingSphere(e)[3])}_fitsInsideTree(e){const t=this._root.bounds,o=this._root.halfSize;return e[3]<=o&&e[0]>=t[0]-o&&e[0]<=t[0]+o&&e[1]>=t[1]-o&&e[1]<=t[1]+o&&e[2]>=t[2]-o&&e[2]<=t[2]+o}toJSON(){const{maximumDepth:e,maximumObjectsPerNode:t,_objectCount:o}=this,n=this._nodeToJSON(this._root.node);return{maximumDepth:e,maximumObjectsPerNode:t,objectCount:o,root:{bounds:this._root.bounds,halfSize:this._root.halfSize,depth:this._root.depth,node:n}}}_nodeToJSON(e){const t=e.children.map((e=>e?this._nodeToJSON(e):null)),o=e.residents?.map((e=>this.objectToBoundingSphere(e))),n=e.terminals?.map((e=>this.objectToBoundingSphere(e)));return{children:t,residents:o,terminals:n}}static fromJSON(e){const t=new b((e=>e),{maximumDepth:e.maximumDepth,maximumObjectsPerNode:e.maximumObjectsPerNode});return t._objectCount=e.objectCount,t._root.initFrom(e.root.node,e.root.bounds,e.root.halfSize,e.root.depth),t}}class g{constructor(){this.bounds=_(),this.halfSize=0,this.initFrom(null,null,0,0)}init(e){return this.initFrom(e.node,e.bounds,e.halfSize,e.depth)}initFrom(e,t,o,n=this.depth){return this.node=null!=e?e:g.createEmptyNode(),t&&u(t,this.bounds),this.halfSize=o,this.depth=n,this}increaseHalfSize(e){this.halfSize*=e,this.updateBoundsRadiusFromHalfSize()}updateBoundsRadiusFromHalfSize(){this.bounds[3]=this.halfSize*A}advance(e){let t=this.node.children[e];t||(t=g.createEmptyNode(),this.node.children[e]=t),this.node=t,this.halfSize/=2,this.depth++;const o=M[e];return this.bounds[0]+=o[0]*this.halfSize,this.bounds[1]+=o[1]*this.halfSize,this.bounds[2]+=o[2]*this.halfSize,this.updateBoundsRadiusFromHalfSize(),this}advanceTo(e,t,o=!1){for(;;){if(this.isTerminalFor(e))return t&&t(this,-1),!0;if(this.isLeaf()){if(!o)return t&&t(this,-1),!1;this.node.residents=null}const n=this._childIndex(e);t&&t(this,n),this.advance(n)}}isLeaf(){return null!=this.node.residents}isTerminalFor(e){return e[3]>this.halfSize/2}_childIndex(e){const t=this.bounds;return(t[0]<e[0]?1:0)+(t[1]<e[1]?2:0)+(t[2]<e[2]?4:0)}static createEmptyNode(){return{children:[null,null,null,null,null,null,null,null],terminals:new t({shrink:!0}),residents:new t({shrink:!0})}}static acquire(){return g._pool.acquire()}static release(e){g._pool.release(e)}static clearPool(){g._pool.prune()}}function S(e,t){e[0]=Math.min(e[0],t[0]-t[3]),e[1]=Math.min(e[1],t[1]-t[3]),e[2]=Math.min(e[2],t[2]-t[3])}function O(e,t){e[0]=Math.max(e[0],t[0]+t[3]),e[1]=Math.max(e[1],t[1]+t[3]),e[2]=Math.max(e[2],t[2]+t[3])}function j(e,t,o){o[0]=e[0]+t,o[1]=e[1]+t,o[2]=e[2]+t}function x(e,t,o,n){if(1===t){const t=o(e[0]);u(t,n)}else{C[0]=1/0,C[1]=1/0,C[2]=1/0,y[0]=-1/0,y[1]=-1/0,y[2]=-1/0;for(let n=0;n<t;n++){const t=o(e[n]);E(t[3])&&(S(C,t),O(y,t))}r(c(n),C,y,.5),n[3]=Math.max(y[0]-C[0],y[1]-C[1],y[2]-C[2])/2}}function N(e,t,o){if(!H.length)for(let n=0;n<8;++n)H.push({index:0,distance:0});for(let n=0;n<8;++n){const o=M[n];H.data[n].index=n,H.data[n].distance=z(e,t,o)}H.sort(((e,t)=>e.distance-t.distance));for(let n=0;n<8;++n)o[n]=H.data[n].index}function T(e,t){let o,n=1/0;for(let i=0;i<8;++i){const s=z(e,t,D[i]);s<n&&(n=s,o=D[i])}return o}function z(e,t,o){return t*(e[0]*o[0]+e[1]*o[1]+e[2]*o[2])}function E(e){return!isNaN(e)&&e!==-1/0&&e!==1/0&&e>0}g._pool=new e(g),function(e){var t;(t=e.DepthOrder||(e.DepthOrder={}))[t.FRONT_TO_BACK=1]="FRONT_TO_BACK",t[t.BACK_TO_FRONT=-1]="BACK_TO_FRONT"}(b||(b={}));const M=[a(-1,-1,-1),a(1,-1,-1),a(-1,1,-1),a(1,1,-1),a(-1,-1,1),a(1,-1,1),a(-1,1,1),a(1,1,1)],D=[a(-1,-1,-1),a(-1,-1,1),a(-1,1,-1),a(-1,1,1),a(1,-1,-1),a(1,-1,1),a(1,1,-1),a(1,1,1)],A=Math.sqrt(3),B=[null];function R(e){return B[0]=e,B}const F=_(),v=h(),C=h(),y=h(),P=new t,w=_(),q=_(),k=_(),I=_(),L=[{min:0,max:0},{min:0,max:0},{min:0,max:0}],H=new t,K=[0,0,0,0,0,0,0,0],W=b;export{W as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{generateUID as t}from"../../../../core/uid.js";import{copy as r,multiply as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{e as s}from"../../../../chunks/vec32.js";import{N as o,
|
|
5
|
+
import{generateUID as t}from"../../../../core/uid.js";import{copy as r,multiply as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{e as s}from"../../../../chunks/vec32.js";import{N as o,c as n,g as a}from"../../../../chunks/sphere.js";import{maxScale as h}from"../../support/mathUtils.js";class m{constructor(r,e={}){this.geometry=r,this.screenToWorldRatio=1,this._transformation=i(),this._shaderTransformation=null,this._boundingSphere=null,this.id=t(),this.layerUid=e.layerUid,this.graphicUid=e.graphicUid,this.castShadow=e.castShadow??!1,null!=e.objectShaderTransformation&&this.objectShaderTransformationChanged(e.objectShaderTransformation)}get transformation(){return this._transformation}set transformation(t){r(this._transformation,t),this._boundingSphere=null}get boundingInfo(){return this.geometry.boundingInfo}objectShaderTransformationChanged(t){null==t?this._shaderTransformation=null:(this._shaderTransformation??=i(),e(this._shaderTransformation,t,this.geometry.transformation)),this._boundingSphere=null}get boundingSphere(){return this.boundingInfo?(null==this._boundingSphere&&(this._boundingSphere??=n(),s(a(this._boundingSphere),this.boundingInfo.center,this.shaderTransformation),this._boundingSphere[3]=this.boundingInfo.radius*h(this.shaderTransformation)),this._boundingSphere):o}get material(){return this.geometry.material}get type(){return this.geometry.type}get shaderTransformation(){return this._shaderTransformation??this.transformation}get attributes(){return this.geometry.attributes}get highlights(){return this.geometry.highlights}get occludees(){return this.geometry.occludees}get visible(){return this.geometry.visible}set visible(t){this.geometry.visible=t}}class g extends m{}export{m as RenderGeometry,g as ValidatedRenderGeometry};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{unpackFloatRGBA as e}from"../../../../core/floatRGBA.js";import t from"../../../../core/PooledArray.js";import{multiply as r,copy as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{e as s}from"../../../../chunks/vec32.js";import{l as a}from"../../../../chunks/vec42.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{intersectsSphere as h,create as f,copy as c}from"../../../../geometry/support/frustum.js";import{g as l,
|
|
5
|
+
import{unpackFloatRGBA as e}from"../../../../core/floatRGBA.js";import t from"../../../../core/PooledArray.js";import{multiply as r,copy as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{e as s}from"../../../../chunks/vec32.js";import{l as a}from"../../../../chunks/vec42.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{intersectsSphere as h,create as f,copy as c}from"../../../../geometry/support/frustum.js";import{g as l,c as _}from"../../../../chunks/sphere.js";import{maxScale as u}from"../../support/mathUtils.js";import{empty as d,union as m,set as g,DepthRange as p}from"./depthRange.js";import b from"./Octree.js";import{assert as w}from"./Util.js";const v=1e4,R=100,j=500,C=500,A=.1;function B(t,r,i){return e(r,t)*(i[1]-i[0])+i[0]}function M(e,t,r){let i=0;if(!t.some((e=>!!e.materialReference&&(i+=e.numGeometries,i>=v))))return k.compute(e,t);const n=d();return r.forAll((t=>m(n,O(e,t)))),n}function O(e,t){if(!t.visible)return;const r=d(),i=t.getSpatialQueryAccelerator();return i?T(r,e,i):x(r,e,t.objects),r}function T(e,t,r){const i=t.eye,n=t.viewForward,s=t.frustum,a=e=>e.visible,o=r.objectCount;if(o<j)g(S,t.near,Math.min(e.near,t.far)),r.forEachInDepthRange(i,n,b.DepthOrder.FRONT_TO_BACK,S,((r,i)=>{D(e,t,r),S.far=e.near,i.setRange(S)}),s,a),g(S,Math.max(e.far,t.near),t.far),r.forEachInDepthRange(i,n,b.DepthOrder.BACK_TO_FRONT,S,((r,i)=>{D(e,t,r),S.near=e.far,i.setRange(S)}),s,a);else{const i=Math.max(Math.min(o,C),Math.ceil(o*A)),h=r.findClosest(n,b.DepthOrder.FRONT_TO_BACK,s,a,i),f=r.findClosest(n,b.DepthOrder.BACK_TO_FRONT,s,a,i);h&&f&&(I(e,t,h.boundingVolumeWorldSpace.bounds),I(e,t,f.boundingVolumeWorldSpace.bounds))}}function x(e,t,r){V.clear(),r.forAll((e=>{e.visible&&0!==e.geometries.length&&V.add(e)})),V.empty||(V.sort(t),g(S,t.near,Math.min(e.near,t.far)),V.forEachInDepthRange(S,b.DepthOrder.FRONT_TO_BACK,((r,i)=>{i<e.near&&D(e,t,r)})),g(S,Math.max(e.far,t.near),t.far),V.forEachInDepthRange(S,b.DepthOrder.BACK_TO_FRONT,((t,r,i)=>{e.far=Math.max(e.far,i)})))}function D(e,t,i){if(!i.visible)return;if(!h(t.frustum,i.boundingVolumeWorldSpace.bounds))return;const n=i.transformation,s=K;i.geometries.forEach((i=>{r(s,n,i.transformation);const a=u(s);F(e,t,i.boundingInfo,s,a)}))}function F(e,t,r,i,n){if(null==r)return;s(l(W),r.center,i);const{eye:a,viewForward:o}=t,f=o[0]*(W[0]-a[0])+o[1]*(W[1]-a[1])+o[2]*(W[2]-a[2]);if(W[3]=r.radius*n,!(f-W[3]>e.near&&f+W[3]<e.far)&&h(t.frustum,W))if(r.radius>R&&r.getChildren())for(const s of r.getChildren())F(e,t,s,i,n);else G.unionDepthRangeWithAABB(e,t.viewProjectionMatrix,i,r.bbMin,r.bbMax)}function I(e,t,r){const i=t.eye,n=t.viewForward,s=(r[0]-i[0])*n[0]+(r[1]-i[1])*n[1]+(r[2]-i[2])*n[2];e.near=Math.min(e.near,s-r[3]),e.far=Math.max(e.far,s+r[3])}class y{constructor(){this._items=new t({allocator:e=>e||{object:null,distance:0,near:0,far:0},deallocator:e=>(e.object=null,e.distance=0,e.near=0,e.far=0,e)})}get length(){return this._items.length}get empty(){return 0===this._items.length}clear(){this._items.clear()}add(e){this._items.pushNew().object=e}sort(e){const t=e.eye,r=e.viewForward;this._items.forAll((e=>{const i=e.object.boundingVolumeWorldSpace.bounds,n=(i[0]-t[0])*r[0]+(i[1]-t[1])*r[1]+(i[2]-t[2])*r[2];e.distance=n,e.near=n-i[3],e.far=n+i[3]})),this._items.sort(((e,t)=>e.distance-t.distance))}forEachInDepthRange(e,t,r){if(t===b.DepthOrder.FRONT_TO_BACK)for(let i=0;i<this._items.length;++i){const t=this._items.data[i];t.far<e.near||t.near>e.far||r(t.object,t.near,t.far)}else for(let i=this._items.length-1;i>=0;--i){const t=this._items.data[i];t.far<e.near||t.near>e.far||r(t.object,t.near,t.far)}}}class P{constructor(){this._view=n(),this._viewProj=n(),this._frustum=f(),this._geometries=new Array,this._near=[],this._far=[],this._nearCandidates=[],this._farCandidates=[],this._looseRange={near:0,far:0}}compute(e,t){this._reset(),i(this._view,e.viewMatrix),r(this._viewProj,e.projectionMatrix,this._view),c(this._frustum,e.frustum);const n=this._view,s=n[2],a=n[6],o=n[10],h=n[14];t.forAll((e=>{e.materialReference&&e.forEachGeometry&&e.forEachGeometry((e=>{if(!e.visible||!e.castShadow)return;const t=e.boundingSphere,r=s*t[0]+a*t[1]+o*t[2]+h,i=r-t[3],n=r+t[3];this._geometries.push(e),this._near.push(-n),this._far.push(-i)}))}));const f=new p;if(0===this._geometries.length)return f;for(let r=0;r<this._geometries.length;++r)this._near[r]>f.far&&(f.far=this._near[r]),this._near[r]>2&&this._far[r]<f.near&&(f.near=this._far[r]);const l=this._looseRange;l.near=Math.max(.5*f.near,2),l.far=2*f.far;let _=0,u=0;for(let r=0;r<this._geometries.length;++r)this._near[r]<f.near&&(this._near[r]>=l.near?f.near=this._near[r]:this._nearCandidates[_++]=r),this._far[r]>f.far&&(this._far[r]<=l.far?f.far=this._far[r]:this._farCandidates[u++]=r);if(0===this._nearCandidates.length&&0===this._farCandidates.length)return f;this._nearCandidates.sort(((e,t)=>this._near[e]<this._near[t]?-1:this._near[e]>this._near[t]?1:0)),this._farCandidates.sort(((e,t)=>this._far[e]<this._far[t]?1:this._far[e]>this._far[t]?-1:0));for(let r=0;r<this._nearCandidates.length;++r){const e=this._nearCandidates[r];if(this._near[e]<f.near){const t=this._geometries[e],r=t.boundingInfo;this._includeNearBoundingInfoRec(r,t.shaderTransformation,f)}}for(let r=0;r<this._farCandidates.length;++r){const e=this._farCandidates[r];if(this._far[e]>f.far){const t=this._geometries[e],r=t.boundingInfo;this._includeFarBoundingInfoRec(r,t.shaderTransformation,f)}}return this._reset(),f}_reset(){this._geometries.length=0,this._near.length=0,this._far.length=0,this._nearCandidates.length=0,this._farCandidates.length=0}_includeNearBoundingInfoRec(e,t,r){if(null==e)return;const i=e.center;s(l(W),i,t);const n=u(t),a=W[0],o=W[1],h=W[2],f=e.radius*n,c=this._frustum;if(c[0][0]*a+c[0][1]*o+c[0][2]*h+c[0][3]>f||c[1][0]*a+c[1][1]*o+c[1][2]*h+c[1][3]>f||c[2][0]*a+c[2][1]*o+c[2][2]*h+c[2][3]>f||c[3][0]*a+c[3][1]*o+c[3][2]*h+c[3][3]>f)return;const _=this._view[2]*a+this._view[6]*o+this._view[10]*h+this._view[14],d=_+f;if(!(-(_-f)<2||-d>=r.near))if(-d>this._looseRange.near)r.near=-d;else{if(f>R){const i=e.getChildren();if(void 0!==i){for(const e of i)this._includeNearBoundingInfoRec(e,t,r);return}}G.unionDepthRangeWithAABB(r,this._viewProj,t,e.bbMin,e.bbMax)}}_includeFarBoundingInfoRec(e,t,r){if(null==e)return;let i=e.radius;const n=e.center;s(l(W),n,t);const a=u(t),o=W[0],h=W[1],f=W[2];i*=a;const c=this._frustum;if(c[0][0]*o+c[0][1]*h+c[0][2]*f+c[0][3]>i||c[1][0]*o+c[1][1]*h+c[1][2]*f+c[1][3]>i||c[2][0]*o+c[2][1]*h+c[2][2]*f+c[2][3]>i||c[3][0]*o+c[3][1]*h+c[3][2]*f+c[3][3]>i)return;const _=this._view[2]*o+this._view[6]*h+this._view[10]*f+this._view[14]-i;if(!(-_<=r.far))if(-_<this._looseRange.far)r.far=-_;else{if(i>R){const i=e.getChildren();if(void 0!==i){for(const e of i)this._includeFarBoundingInfoRec(e,t,r);return}}G.unionDepthRangeWithAABB(r,this._viewProj,t,e.bbMin,e.bbMax)}}}class N{constructor(){this._modelViewProj=n(),this._clipPosition=[o(),o(),o(),o(),o(),o(),o(),o()]}unionDepthRangeWithAABB(e,t,i,n,s){const a=this._modelViewProj;r(a,t,i);let o=!1;for(let r=0;r<8;++r){const e=this._clipPosition[r],t=0===r||3===r||4===r||7===r?n[0]:s[0],i=0===r||1===r||4===r||5===r?n[1]:s[1],o=r<4?n[2]:s[2];e[0]=a[0]*t+a[4]*i+a[8]*o+a[12],e[1]=a[1]*t+a[5]*i+a[9]*o+a[13],e[2]=a[2]*t+a[6]*i+a[10]*o+a[14],e[3]=a[3]*t+a[7]*i+a[11]*o+a[15]}for(let r=0;r<12;++r){const t=this._clipPosition[E[r][0]],i=this._clipPosition[E[r][1]],n=this._clipPosition[E[r][2]],s=this._clipTriangle(t,i,n);let a=!0;for(let e=0;e<s.length;++e){if(s[e][3]>=2){a=!1;break}}if(!a){o=!0;for(let t=0;t<s.length;++t){const r=s[t][3];Number.isFinite(r)&&(e.near=Math.min(r,e.near),e.far=Math.max(r,e.far))}}}return o}_inside(e,t){return 0===t?e[0]>=-e[3]:1===t?e[1]>=-e[3]:2===t?e[0]<=e[3]:3===t?e[1]<=e[3]:void w(!1)}_intersect(e,t,r){let i=0;return 0===r?i=(-e[3]-e[0])/(t[0]-e[0]+t[3]-e[3]):1===r?i=(-e[3]-e[1])/(t[1]-e[1]+t[3]-e[3]):2===r?i=(e[3]-e[0])/(t[0]-e[0]-t[3]+e[3]):3===r&&(i=(e[3]-e[1])/(t[1]-e[1]-t[3]+e[3])),a(o(),e,t,i)}_clipTriangle(e,t,r){let i=[e,t,r];for(let n=0;n<4;++n){const e=i;i=[];for(let t=0;t<e.length;++t){const r=e[t],s=e[(t+1)%e.length];this._inside(s,n)?(this._inside(r,n)||i.push(this._intersect(r,s,n)),i.push(s)):this._inside(r,n)&&i.push(this._intersect(r,s,n))}}return i}}const E=[[0,1,3],[2,3,1],[1,5,2],[6,2,5],[5,4,6],[7,6,4],[4,0,7],[3,7,0],[3,2,7],[6,7,2],[4,5,0],[1,0,5]],W=_(),K=n(),S=d(),V=new y,k=new P,G=new N;export{P as DepthRangeFromRenderGeometries,O as depthRangeFromLayer,M as depthRangeFromScene,B as textureToDepth};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{equals as r,binaryIndexOf as s}from"../../../../../core/arrayUtils.js";import n from"../../../../../core/Logger.js";import{clamp as o}from"../../../../../core/mathUtils.js";import{disposeMaybe as i,destroyMaybe as a}from"../../../../../core/maybe.js";import{property as c}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as d,transpose as u,invert as h}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as g}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as p,c as f,z as _,k as b}from"../../../../../chunks/vec32.js";import{create as y,clone as j}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as O}from"../../../../../core/support/UpdatingHandles.js";import{g as w,a as E}from"../../../../../chunks/sphere.js";import{c as R}from"../../../../../chunks/vec33.js";import{ViewingMode as v}from"../../../../ViewingMode.js";import{encodeElevationOffset as x}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as M}from"../../core/util/TwoVectorPosition.js";import{Attribute as T}from"../Attribute.js";import{GridLocalOriginFactory as C}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as D}from"../localOriginHelper.js";import{LocalOriginManager as P}from"../LocalOriginManager.js";import{Object3D as S}from"../Object3D.js";import{VertexArrayObject as A}from"../VertexArrayObject.js";import{VertexAttribute as B}from"../VertexAttribute.js";import{VertexLayout as L,EdgeInputBufferLayout as U,EdgeShaderAttributeLocations as I,glVertexLayout as k}from"./bufferLayouts.js";import{RegularEdgeBufferWriter as H,SilhouetteEdgeBufferWriter as V}from"./edgeBufferWriters.js";import{EdgeType as N}from"./edgePreprocessing.js";import{EdgeRenderer as G,lineWidthFractionFactor as W,extensionLengthOffset as q}from"./EdgeRenderer.js";import{EdgePassParameters as z}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as K}from"./EdgeWorkerHandle.js";import{Transparency as F}from"./interfaces.js";import{generateStrokesTexture as Q}from"./strokes.js";import{determineRendererType as J,determineEdgeTransparency as X,determineObjectTransparency as Y,fillComponenBufferIndices as Z}from"./util.js";import{BufferManager as $}from"../TextureBackedBuffer/BufferManager.js";import{EdgeSilhouette as ee}from"../../shaders/sources/edgeRenderer/EdgeUtil.glsl.js";import{BufferObject as te}from"../../../../webgl/BufferObject.js";import{Usage as re}from"../../../../webgl/enums.js";let se=class extends t{constructor(e){super(e),this._updatingHandles=new O,this._perObjectData=new Map,this._perObjectDataEvictionCache=new Set,this._renderers=new Map,this._gpuMemoryUsage=0,this._workerAbort=new AbortController,this._tmpModelPosition=y(),this._localOrigins=new P(new C(e.renderSR))}initialize(){this._worker=new K(this.schedule),this._componentColorManager=new $(this.rctx,3);const e=L.createBuffer(4);for(let t=0;t<4;t++)e.sideness.set(t,0,0===t||3===t?0:1),e.sideness.set(t,1,0===t||1===t?0:1);this._verticesBufferObject=te.createVertex(this.rctx,re.STATIC_DRAW,e.buffer)}destroy(){this.destroyed||(this._perObjectData.forEach((e=>this._discardObjectEntry(e))),this._perObjectData.clear(),this._strokesTexture=i(this._strokesTexture),this._componentColorManager=a(this._componentColorManager),this._workerAbort.abort(),this._worker.destroy(),this._verticesBufferObject=i(this._verticesBufferObject),this._renderers.clear(),this._updatingHandles.destroy(),this._set("schedule",be))}get updating(){return this._updatingHandles.updating}get usedMemory(){return this._gpuMemoryUsage}shouldRender(){return this._renderers.size>0}async addComponentObject(e,t,r,s,n,o){if(this.hasObject(e))return this.getObjectMemoryUsage(e);let i;const a=new ie(new Promise((e=>i=e)),e.obb.center,e.obb.radius);this._perObjectData.set(e,a);const c=await this._updatingHandles.addPromise(this._addComponentGeometry(e.transform,a,t,r,s,n,o));return this.setNeedsRender(),i(),c}async addOrUpdateObject3D(e,t,r,s){if(this.destroyed)return void n.getLogger(this).warn("Attempt to add an object to a destroyed instance");const o=this._perObjectData.get(e);let i;o?.renderables.length>0&&this._perObjectDataEvictionCache.add(o);const a=e.boundingVolumeWorldSpace.bounds,c=new ie(new Promise((e=>i=e)),w(a),E(a));this._perObjectData.set(e,c);const l=new Array;if(r.mergeGeometries&&e.geometries.length>1&&oe(e))l.push(this._addObjectMergedGeometries(e,c,t,r,s));else for(let n=0;n<e.geometries.length;n++){const o=e.geometries[n];o.material.supportsEdges&&l.push(this._addGeometry(e,c,o,t[0],r,s))}await this._updatingHandles.addPromise(Promise.all(l)),this._perObjectDataEvictionCache.delete(c),this._discardObjectEntry(o),this.setNeedsRender(),i()}fastUpdateObject3DEdgesTransform(e){if(this.destroyed)return!1;const t=this._perObjectData.get(e);if(!t)return!1;const{geometries:r}=e,{renderables:s}=t;if(0===r.length||0===s.length)return!0;if(s.length>1)return!1;const[n]=s,o=n.transform;if(!(o instanceof le))return!1;const[i]=r;if(i.localOrigin!==o.origin.origin)return!1;const a=g(),c=this._computeModelTransformWithLocalOrigin(e,i,a);return n.transform=new le(a,c),this.setNeedsRender(),!0}_discardObjectEntry(e){e&&(e.renderables.length&&(e.renderables.forEach((e=>this._removeRenderable(e))),this.setNeedsRender()),e.loaded=null)}hasObject(e){return this._perObjectData.has(e)}async updateAllComponentOpacities(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));if(null==r)return;const s=t instanceof Array?e=>t[e]:()=>t;r.renderables.forEach((e=>{const t=e.components.meta.length;for(let r=0;r<t;r++){const t=s(r),n=e.components.meta[r],o=n.index;n.material.opacity=t,e.components.buffer.textureBuffer.setDataElement(o,1,3,255*t)}this._updateTransparency(e)})),this.setNeedsRender()}async getObjectMemoryUsage(e){const t=await this._getObjectEntry(e);return null!=t?t.renderables.reduce(((e,t)=>e+t.statistics.gpuMemoryUsage),0):0}async updateAllComponentMaterials(e,t,r,s){const n=e instanceof S,o=!!r.hasSlicePlane,i=J(t),a=G.getKey(i,o,n),c=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=c&&(c.renderables.forEach((e=>{if(a!==e.rendererKey){const t=this._renderers.get(e.rendererKey),r=this._acquireRenderer(i,o,n);t.removeRenderable(e),--t.refCount,e.rendererKey=a,r.addRenderable(e)}for(let r=0;r<t.length;r++)e.components.meta[r].material=t[r];s&&this._updateComponentBuffer(e.components),this._updateTransparency(e)})),this.setNeedsRender())}async updateAllVerticalOffsets(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&(r.renderables.forEach((e=>{const r=e.components.meta;for(let s=0;s<r.length;s++)e.components.meta[s].verticalOffset=t?.[s]??0;this._updateComponentBuffer(e.components)})),this.setNeedsRender())}async updateObjectVisibility(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&(r.renderables.forEach((e=>e.visible=t)),this.setNeedsRender())}removeObject(e){const t=this._perObjectData.get(e);t&&(this._perObjectData.delete(e),this._discardObjectEntry(t))}async _getObjectEntry(e){const t=this._perObjectData.get(e);if(!t)throw new Error("no object");return await t.loaded,null==t.loaded?null:t}render(e,t){if(null==this._componentColorManager)return;this._localOrigins.updateViewMatrices(e.camera.viewMatrix);const r=e.camera.viewInverseTransposeMatrix,s=y(),n=new M;let o=0,i=0;if(this._renderers.forEach((r=>{if(0===r.refCount)return this._renderers.delete(r.key),void r.dispose();let s=!0,n=!0;r.forEachRenderable((t=>{t.visible&&(o+=t.statistics.averageEdgeLength,i++,s&&t.regular&&(r.updateTechnique(e,!1),s=!1),n&&t.silhouette&&(r.updateTechnique(e,!0),n=!1))}),t)})),this._componentColorManager.garbageCollect(),this._componentColorManager.updateTextures(),0===i)return;const a=new z(40*o/i,t);p(s,r[3],r[7],r[11]),n.set(s),f(a.transformWorldFromViewTH,n.high),f(a.transformWorldFromViewTL,n.low),d(a.transformViewFromCameraRelativeRS,e.camera.viewMatrix),u(_e,a.transformViewFromCameraRelativeRS),h(a.transformNormalViewFromGlobal,_e),a.transformProjFromView=e.camera.projectionMatrix,this._updateObjectCameraDistances(e),this._renderers.forEach((t=>{this._renderRegularEdges(t,e,a),this._renderSilhouetteEdges(t,e,a)}))}_updateTransparency(e){const t=X(e.components.meta),r=Y(e.components.meta);t===e.edgeTransparency&&r===e.objectTransparency||(e.edgeTransparency=t,e.objectTransparency=r,this._renderers.get(e.rendererKey).setRenderablesDirty())}_computeModelTransformWithLocalOrigin(e,t,r){e.getCombinedShaderTransformation(t,r);const s=null!=t.localOrigin?this._localOrigins.register(t.localOrigin):this._localOrigins.acquire(p(this._tmpModelPosition,r[12],r[13],r[14]));return t.localOrigin=s.origin,D(s.origin.vec3,r),s}_updateComponentBuffer(e){const{meta:t,buffer:r}=e,s=new Uint8Array(4);for(let n=0;n<t.length;n++){const e=t[n].material,i=t[n].index,a=o(Math.round(e.size*W),0,255),c=o(e.extensionLength,-q,255-q)+q,l="solid"===e.type?N.SOLID:N.SKETCH,d=255*e.opacity,u=e.color,h=255*u[0],m=255*u[1],g=255*u[2],p=255*u[3];r.textureBuffer.setData(i,0,h,m,g,p),r.textureBuffer.setData(i,1,a,c,l,d),x(t[n].verticalOffset,s),r.textureBuffer.setData(i,2,s[0],s[1],s[2],s[3])}}_createComponentBuffers(e){if(null==this._componentColorManager)return null;const t=new Array,r=this._componentColorManager.getBuffer(e.length);for(let n=0;n<e.length;n++){const s=e[n],o=r.acquireIndex();t.push({index:o,verticalOffset:0,material:s})}const s=new ae(r,t);return this._updateComponentBuffer(s),s}_extractEdges(e,t,r,s,n,o=n.length){return this._worker.process({data:t,indices:n,indicesLength:o,writerSettings:e,skipDeduplicate:r},this._workerAbort.signal,s)}_createRenderable(e,t,r,s,n){const o=t=>null!=this._verticesBufferObject?new ce(new A(this.rctx,I,{vertices:k,instances:t===ee.REGULAR?H.glLayout:V.glLayout},{vertices:this._verticesBufferObject,instances:te.createVertex(this.rctx,re.STATIC_DRAW,t===ee.REGULAR?e.regular.instancesData.buffer:e.silhouette.instancesData.buffer)}),t===ee.REGULAR?e.regular.lodInfo:e.silhouette.lodInfo):null,i=e.regular.lodInfo.lengths.length>0?o(ee.REGULAR):null,a=e.silhouette.lodInfo.lengths.length>0?o(ee.SILHOUETTE):null,c=(i?.vao.usedMemory??0)+(a?.vao.usedMemory??0);return new de(i,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,X(t.meta),Y(t.meta),t,s)}async _addGeometry(e,t,r,s,n,o){if(r.edgeIndicesLength<=0)return;const i=r.attributes.get(B.POSITION),a=g(),c=this._computeModelTransformWithLocalOrigin(e,r,a),l=new fe(i,a,c);return this._addPositionData(t,l,r.edgeIndicesLength,s,n,o)}async _addPositionData(e,t,r,s,n,o=!1){if(null==e.loaded)return;const i=this._createComponentBuffers([s]);if(null==i)return;const a=this._acquireRenderer(s.type,!!n.hasSlicePlane,!0),{modelTransform:c,origin:l}=t,d=t.position.indices,u=t.position,h=u.data.length/u.size,m=U.createBuffer(h);for(let f=0;f<h;f++)m.position.set(f,0,u.data[f*u.size]),m.position.set(f,1,u.data[f*u.size+1]),m.position.set(f,2,u.data[f*u.size+2]);Z(i.meta,[0,m.componentIndex.count],m.componentIndex);const g=await this._updatingHandles.addPromise(this._extractEdges(a.writerSettings,m,!1,o,d,r));if(null==e.loaded)return;const p=this._createRenderable(g,i,new le(c,l),a.key,!1);e.renderables.push(p),a.addRenderable(p),this._gpuMemoryUsage+=p.statistics.gpuMemoryUsage}async _addComponentGeometry(e,t,r,s,n,o,i){if(null==t.loaded)return 0;const a=this._createComponentBuffers(o);if(null==a)return 0;const c=J(o),l=this._acquireRenderer(c,i.hasSlicePlane||!1,!1),d=U.createBuffer(r.length/3);R(d.position.typedBuffer,r,d.position.typedBufferStride,3),Z(a.meta,n,d.componentIndex,s);const u=!0,h=l.writerSettings,m=await this._updatingHandles.addPromise(this._extractEdges(h,d,u,!1,s));if(null==t.loaded)return 0;const g=this._createRenderable(m,a,e,l.key,!0);return t.renderables.push(g),l.addRenderable(g),g.statistics.gpuMemoryUsage}async _addObjectMergedGeometries(e,t,r,s,n){const o=new Map;let i=0,a=null,c=0;const l=e.geometries.filter((e=>{if(e.edgeIndicesLength<=0||!e.material.supportsEdges)return!1;!a&&e.localOrigin&&(a=e);const t=e.attributes.get(B.POSITION);return c+=t.data.length/t.size,i+=e.edgeIndicesLength,!0}));if(0===l.length)return;const d=c>=65536?Uint32Array:Uint16Array,u=i?new d(i):null,h=[];let m=0;l.forEach((e=>{const t=e.attributes.get(B.POSITION),r=t.indices;let s=o.get(t.data);if(null==s){s=h.length/3;for(let e=0;e<t.data.length;e+=t.size)h.push(t.data[e]),h.push(t.data[e+1]),h.push(t.data[e+2]);o.set(t.data,s)}for(let n=0;n<e.edgeIndicesLength;n++)u[m++]=s+r[n]}));const p=a||e.geometries[0],f=g(),_=this._computeModelTransformWithLocalOrigin(e,p,f);for(let g=0;g<e.geometries.length;g++)e.geometries[g].localOrigin=_.origin;const b=new fe(new T(h,u,3),f,_);await this._updatingHandles.addPromise(this._addPositionData(t,b,u.length,r[0],s,n))}_acquireRenderer(e,t,r){const s=G.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=Q(this.rctx)),n||(n=new G(this.rctx,this.techniqueRepository,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:this.viewingMode===v.Global}),this._renderers.set(s,n)),++n.refCount,n}_removeRenderable(e){ne(e.regular),ne(e.silhouette);const t=this._renderers.get(e.rendererKey);if(t){t.removeRenderable(e),--t.refCount,"origin"in e.transform&&this._localOrigins.release(e.transform.origin),this._gpuMemoryUsage-=e.statistics.externalMemoryUsage?0:e.statistics.gpuMemoryUsage;for(const t of e.components.meta)e.components.buffer.releaseIndex(t.index)}}_updateObjectCameraDistances(e){const t=e.camera.eye,r=e.camera.viewForward,s=y(),n=e=>{_(s,e.center,t);const n=b(s,r),o=e.radius,i=n<-o?1/0:n<o?0:n-o;e.renderables.forEach((e=>e.distanceToCamera=i))};this._perObjectData.forEach(n),this._perObjectDataEvictionCache.forEach(n)}_renderRegularEdges(e,t,r){const s=e.bindRegularEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!he(n)||!n.visible)return;const i=pe(n.regular.lod.lengths,n.distanceToCamera,o);e.renderRegularEdges(s,n,r,t,i)}),n)}_renderSilhouetteEdges(e,t,r){const s=e.bindSilhouetteEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!ge(n)||!n.visible)return;const i=pe(n.silhouette.lod.lengths,n.distanceToCamera,o);e.renderSilhouetteEdges(s,n,r,t,i)}),n)}get test(){return{hasRenderedPrimitives:e=>{let t=!1;const r=e.perScreenPixelRatio,s=(e,s)=>e.forEachRenderable((e=>{e.visible&&!t&&(he(e)&&(t=pe(e.regular.lod.lengths,e.distanceToCamera,r)>0),!t&&ge(e)&&(t=pe(e.silhouette.lod.lengths,e.distanceToCamera,r)>0))}),s);return this._renderers.forEach((e=>{t||(s(e,F.OPAQUE),s(e,F.TRANSPARENT))})),t},getObjectData:e=>this._perObjectData.get(e)}}};function ne(e){null!=e&&(e.vao.vertexBuffers.instances.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function oe(e){let t=null,s=null;for(let n=0;n<e.geometries.length;n++){const o=e.geometries[n];if(o.material.supportsEdges){if(t){if(!r(t,o.transformation))return!1}else t=o.transformation;if(s||null==o.localOrigin){if(null!=s?.localOrigin&&null!=o.localOrigin&&s.localOrigin.id!==o.localOrigin.id)return!1}else s=o}}return!0}e([c({constructOnly:!0})],se.prototype,"rctx",void 0),e([c({constructOnly:!0})],se.prototype,"renderSR",void 0),e([c({constructOnly:!0})],se.prototype,"viewingMode",void 0),e([c({constructOnly:!0})],se.prototype,"techniqueRepository",void 0),e([c({constructOnly:!0})],se.prototype,"setNeedsRender",void 0),e([c({constructOnly:!0})],se.prototype,"schedule",void 0),e([c({readOnly:!0})],se.prototype,"_updatingHandles",void 0),e([c({readOnly:!0})],se.prototype,"updating",null),se=e([l("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],se);class ie{constructor(e,t,r){this.radius=r,this.renderables=new Array,this.loaded=e,this.loaded.then((()=>{null!=this.loaded&&(this.loaded=!0)})),this.center=j(t)}}class ae{constructor(e,t){this.buffer=e,this.meta=t}}class ce{constructor(e,t){this.vao=e,this.lod=t}}class le{constructor(e,t){this.modelMatrix=e,this.origin=t}}class de{constructor(e,t,r,s,n,o,i,a){this.regular=e,this.silhouette=t,this.statistics=r,this.transform=s,this.edgeTransparency=n,this.objectTransparency=o,this.components=i,this.rendererKey=a,this.distanceToCamera=0,this.visible=!0}}class ue extends de{}function he(e){return null!=e.regular}class me extends de{}function ge(e){return null!=e.silhouette}function pe(e,t,r){const n=t*r,o=s(e,n,!0);return-1===o?n<e[0]?e.length:0:e.length-o}class fe{constructor(e,t,r){this.position=e,this.modelTransform=t,this.origin=r}}const _e=m(),be=()=>Promise.reject();export{se as EdgeView,le as LegacyTransform,ue as RegularRenderable,de as Renderable,me as SilhouetteRenderable};
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{equals as r,binaryIndexOf as s}from"../../../../../core/arrayUtils.js";import n from"../../../../../core/Logger.js";import{clamp as o}from"../../../../../core/mathUtils.js";import{disposeMaybe as i,destroyMaybe as a}from"../../../../../core/maybe.js";import{property as c}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as d,transpose as u,invert as h}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as g}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as p,c as f,z as _,k as b}from"../../../../../chunks/vec32.js";import{create as y,clone as j}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as O}from"../../../../../core/support/UpdatingHandles.js";import{g as w,b as E}from"../../../../../chunks/sphere.js";import{c as R}from"../../../../../chunks/vec33.js";import{ViewingMode as v}from"../../../../ViewingMode.js";import{encodeElevationOffset as x}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as M}from"../../core/util/TwoVectorPosition.js";import{Attribute as T}from"../Attribute.js";import{GridLocalOriginFactory as C}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as D}from"../localOriginHelper.js";import{LocalOriginManager as P}from"../LocalOriginManager.js";import{Object3D as S}from"../Object3D.js";import{VertexArrayObject as A}from"../VertexArrayObject.js";import{VertexAttribute as B}from"../VertexAttribute.js";import{VertexLayout as L,EdgeInputBufferLayout as U,EdgeShaderAttributeLocations as I,glVertexLayout as k}from"./bufferLayouts.js";import{RegularEdgeBufferWriter as H,SilhouetteEdgeBufferWriter as V}from"./edgeBufferWriters.js";import{EdgeType as N}from"./edgePreprocessing.js";import{EdgeRenderer as G,lineWidthFractionFactor as W,extensionLengthOffset as q}from"./EdgeRenderer.js";import{EdgePassParameters as z}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as K}from"./EdgeWorkerHandle.js";import{Transparency as F}from"./interfaces.js";import{generateStrokesTexture as Q}from"./strokes.js";import{determineRendererType as J,determineEdgeTransparency as X,determineObjectTransparency as Y,fillComponenBufferIndices as Z}from"./util.js";import{BufferManager as $}from"../TextureBackedBuffer/BufferManager.js";import{EdgeSilhouette as ee}from"../../shaders/sources/edgeRenderer/EdgeUtil.glsl.js";import{BufferObject as te}from"../../../../webgl/BufferObject.js";import{Usage as re}from"../../../../webgl/enums.js";let se=class extends t{constructor(e){super(e),this._updatingHandles=new O,this._perObjectData=new Map,this._perObjectDataEvictionCache=new Set,this._renderers=new Map,this._gpuMemoryUsage=0,this._workerAbort=new AbortController,this._tmpModelPosition=y(),this._localOrigins=new P(new C(e.renderSR))}initialize(){this._worker=new K(this.schedule),this._componentColorManager=new $(this.rctx,3);const e=L.createBuffer(4);for(let t=0;t<4;t++)e.sideness.set(t,0,0===t||3===t?0:1),e.sideness.set(t,1,0===t||1===t?0:1);this._verticesBufferObject=te.createVertex(this.rctx,re.STATIC_DRAW,e.buffer)}destroy(){this.destroyed||(this._perObjectData.forEach((e=>this._discardObjectEntry(e))),this._perObjectData.clear(),this._strokesTexture=i(this._strokesTexture),this._componentColorManager=a(this._componentColorManager),this._workerAbort.abort(),this._worker.destroy(),this._verticesBufferObject=i(this._verticesBufferObject),this._renderers.clear(),this._updatingHandles.destroy(),this._set("schedule",be))}get updating(){return this._updatingHandles.updating}get usedMemory(){return this._gpuMemoryUsage}shouldRender(){return this._renderers.size>0}async addComponentObject(e,t,r,s,n,o){if(this.hasObject(e))return this.getObjectMemoryUsage(e);let i;const a=new ie(new Promise((e=>i=e)),e.obb.center,e.obb.radius);this._perObjectData.set(e,a);const c=await this._updatingHandles.addPromise(this._addComponentGeometry(e.transform,a,t,r,s,n,o));return this.setNeedsRender(),i(),c}async addOrUpdateObject3D(e,t,r,s){if(this.destroyed)return void n.getLogger(this).warn("Attempt to add an object to a destroyed instance");const o=this._perObjectData.get(e);let i;o?.renderables.length>0&&this._perObjectDataEvictionCache.add(o);const a=e.boundingVolumeWorldSpace.bounds,c=new ie(new Promise((e=>i=e)),w(a),E(a));this._perObjectData.set(e,c);const l=new Array;if(r.mergeGeometries&&e.geometries.length>1&&oe(e))l.push(this._addObjectMergedGeometries(e,c,t,r,s));else for(let n=0;n<e.geometries.length;n++){const o=e.geometries[n];o.material.supportsEdges&&l.push(this._addGeometry(e,c,o,t[0],r,s))}await this._updatingHandles.addPromise(Promise.all(l)),this._perObjectDataEvictionCache.delete(c),this._discardObjectEntry(o),this.setNeedsRender(),i()}fastUpdateObject3DEdgesTransform(e){if(this.destroyed)return!1;const t=this._perObjectData.get(e);if(!t)return!1;const{geometries:r}=e,{renderables:s}=t;if(0===r.length||0===s.length)return!0;if(s.length>1)return!1;const[n]=s,o=n.transform;if(!(o instanceof le))return!1;const[i]=r;if(i.localOrigin!==o.origin.origin)return!1;const a=g(),c=this._computeModelTransformWithLocalOrigin(e,i,a);return n.transform=new le(a,c),this.setNeedsRender(),!0}_discardObjectEntry(e){e&&(e.renderables.length&&(e.renderables.forEach((e=>this._removeRenderable(e))),this.setNeedsRender()),e.loaded=null)}hasObject(e){return this._perObjectData.has(e)}async updateAllComponentOpacities(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));if(null==r)return;const s=t instanceof Array?e=>t[e]:()=>t;r.renderables.forEach((e=>{const t=e.components.meta.length;for(let r=0;r<t;r++){const t=s(r),n=e.components.meta[r],o=n.index;n.material.opacity=t,e.components.buffer.textureBuffer.setDataElement(o,1,3,255*t)}this._updateTransparency(e)})),this.setNeedsRender()}async getObjectMemoryUsage(e){const t=await this._getObjectEntry(e);return null!=t?t.renderables.reduce(((e,t)=>e+t.statistics.gpuMemoryUsage),0):0}async updateAllComponentMaterials(e,t,r,s){const n=e instanceof S,o=!!r.hasSlicePlane,i=J(t),a=G.getKey(i,o,n),c=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=c&&(c.renderables.forEach((e=>{if(a!==e.rendererKey){const t=this._renderers.get(e.rendererKey),r=this._acquireRenderer(i,o,n);t.removeRenderable(e),--t.refCount,e.rendererKey=a,r.addRenderable(e)}for(let r=0;r<t.length;r++)e.components.meta[r].material=t[r];s&&this._updateComponentBuffer(e.components),this._updateTransparency(e)})),this.setNeedsRender())}async updateAllVerticalOffsets(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&(r.renderables.forEach((e=>{const r=e.components.meta;for(let s=0;s<r.length;s++)e.components.meta[s].verticalOffset=t?.[s]??0;this._updateComponentBuffer(e.components)})),this.setNeedsRender())}async updateObjectVisibility(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&(r.renderables.forEach((e=>e.visible=t)),this.setNeedsRender())}removeObject(e){const t=this._perObjectData.get(e);t&&(this._perObjectData.delete(e),this._discardObjectEntry(t))}async _getObjectEntry(e){const t=this._perObjectData.get(e);if(!t)throw new Error("no object");return await t.loaded,null==t.loaded?null:t}render(e,t){if(null==this._componentColorManager)return;this._localOrigins.updateViewMatrices(e.camera.viewMatrix);const r=e.camera.viewInverseTransposeMatrix,s=y(),n=new M;let o=0,i=0;if(this._renderers.forEach((r=>{if(0===r.refCount)return this._renderers.delete(r.key),void r.dispose();let s=!0,n=!0;r.forEachRenderable((t=>{t.visible&&(o+=t.statistics.averageEdgeLength,i++,s&&t.regular&&(r.updateTechnique(e,!1),s=!1),n&&t.silhouette&&(r.updateTechnique(e,!0),n=!1))}),t)})),this._componentColorManager.garbageCollect(),this._componentColorManager.updateTextures(),0===i)return;const a=new z(40*o/i,t);p(s,r[3],r[7],r[11]),n.set(s),f(a.transformWorldFromViewTH,n.high),f(a.transformWorldFromViewTL,n.low),d(a.transformViewFromCameraRelativeRS,e.camera.viewMatrix),u(_e,a.transformViewFromCameraRelativeRS),h(a.transformNormalViewFromGlobal,_e),a.transformProjFromView=e.camera.projectionMatrix,this._updateObjectCameraDistances(e),this._renderers.forEach((t=>{this._renderRegularEdges(t,e,a),this._renderSilhouetteEdges(t,e,a)}))}_updateTransparency(e){const t=X(e.components.meta),r=Y(e.components.meta);t===e.edgeTransparency&&r===e.objectTransparency||(e.edgeTransparency=t,e.objectTransparency=r,this._renderers.get(e.rendererKey).setRenderablesDirty())}_computeModelTransformWithLocalOrigin(e,t,r){e.getCombinedShaderTransformation(t,r);const s=null!=t.localOrigin?this._localOrigins.register(t.localOrigin):this._localOrigins.acquire(p(this._tmpModelPosition,r[12],r[13],r[14]));return t.localOrigin=s.origin,D(s.origin.vec3,r),s}_updateComponentBuffer(e){const{meta:t,buffer:r}=e,s=new Uint8Array(4);for(let n=0;n<t.length;n++){const e=t[n].material,i=t[n].index,a=o(Math.round(e.size*W),0,255),c=o(e.extensionLength,-q,255-q)+q,l="solid"===e.type?N.SOLID:N.SKETCH,d=255*e.opacity,u=e.color,h=255*u[0],m=255*u[1],g=255*u[2],p=255*u[3];r.textureBuffer.setData(i,0,h,m,g,p),r.textureBuffer.setData(i,1,a,c,l,d),x(t[n].verticalOffset,s),r.textureBuffer.setData(i,2,s[0],s[1],s[2],s[3])}}_createComponentBuffers(e){if(null==this._componentColorManager)return null;const t=new Array,r=this._componentColorManager.getBuffer(e.length);for(let n=0;n<e.length;n++){const s=e[n],o=r.acquireIndex();t.push({index:o,verticalOffset:0,material:s})}const s=new ae(r,t);return this._updateComponentBuffer(s),s}_extractEdges(e,t,r,s,n,o=n.length){return this._worker.process({data:t,indices:n,indicesLength:o,writerSettings:e,skipDeduplicate:r},this._workerAbort.signal,s)}_createRenderable(e,t,r,s,n){const o=t=>null!=this._verticesBufferObject?new ce(new A(this.rctx,I,{vertices:k,instances:t===ee.REGULAR?H.glLayout:V.glLayout},{vertices:this._verticesBufferObject,instances:te.createVertex(this.rctx,re.STATIC_DRAW,t===ee.REGULAR?e.regular.instancesData.buffer:e.silhouette.instancesData.buffer)}),t===ee.REGULAR?e.regular.lodInfo:e.silhouette.lodInfo):null,i=e.regular.lodInfo.lengths.length>0?o(ee.REGULAR):null,a=e.silhouette.lodInfo.lengths.length>0?o(ee.SILHOUETTE):null,c=(i?.vao.usedMemory??0)+(a?.vao.usedMemory??0);return new de(i,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,X(t.meta),Y(t.meta),t,s)}async _addGeometry(e,t,r,s,n,o){if(r.edgeIndicesLength<=0)return;const i=r.attributes.get(B.POSITION),a=g(),c=this._computeModelTransformWithLocalOrigin(e,r,a),l=new fe(i,a,c);return this._addPositionData(t,l,r.edgeIndicesLength,s,n,o)}async _addPositionData(e,t,r,s,n,o=!1){if(null==e.loaded)return;const i=this._createComponentBuffers([s]);if(null==i)return;const a=this._acquireRenderer(s.type,!!n.hasSlicePlane,!0),{modelTransform:c,origin:l}=t,d=t.position.indices,u=t.position,h=u.data.length/u.size,m=U.createBuffer(h);for(let f=0;f<h;f++)m.position.set(f,0,u.data[f*u.size]),m.position.set(f,1,u.data[f*u.size+1]),m.position.set(f,2,u.data[f*u.size+2]);Z(i.meta,[0,m.componentIndex.count],m.componentIndex);const g=await this._updatingHandles.addPromise(this._extractEdges(a.writerSettings,m,!1,o,d,r));if(null==e.loaded)return;const p=this._createRenderable(g,i,new le(c,l),a.key,!1);e.renderables.push(p),a.addRenderable(p),this._gpuMemoryUsage+=p.statistics.gpuMemoryUsage}async _addComponentGeometry(e,t,r,s,n,o,i){if(null==t.loaded)return 0;const a=this._createComponentBuffers(o);if(null==a)return 0;const c=J(o),l=this._acquireRenderer(c,i.hasSlicePlane||!1,!1),d=U.createBuffer(r.length/3);R(d.position.typedBuffer,r,d.position.typedBufferStride,3),Z(a.meta,n,d.componentIndex,s);const u=!0,h=l.writerSettings,m=await this._updatingHandles.addPromise(this._extractEdges(h,d,u,!1,s));if(null==t.loaded)return 0;const g=this._createRenderable(m,a,e,l.key,!0);return t.renderables.push(g),l.addRenderable(g),g.statistics.gpuMemoryUsage}async _addObjectMergedGeometries(e,t,r,s,n){const o=new Map;let i=0,a=null,c=0;const l=e.geometries.filter((e=>{if(e.edgeIndicesLength<=0||!e.material.supportsEdges)return!1;!a&&e.localOrigin&&(a=e);const t=e.attributes.get(B.POSITION);return c+=t.data.length/t.size,i+=e.edgeIndicesLength,!0}));if(0===l.length)return;const d=c>=65536?Uint32Array:Uint16Array,u=i?new d(i):null,h=[];let m=0;l.forEach((e=>{const t=e.attributes.get(B.POSITION),r=t.indices;let s=o.get(t.data);if(null==s){s=h.length/3;for(let e=0;e<t.data.length;e+=t.size)h.push(t.data[e]),h.push(t.data[e+1]),h.push(t.data[e+2]);o.set(t.data,s)}for(let n=0;n<e.edgeIndicesLength;n++)u[m++]=s+r[n]}));const p=a||e.geometries[0],f=g(),_=this._computeModelTransformWithLocalOrigin(e,p,f);for(let g=0;g<e.geometries.length;g++)e.geometries[g].localOrigin=_.origin;const b=new fe(new T(h,u,3),f,_);await this._updatingHandles.addPromise(this._addPositionData(t,b,u.length,r[0],s,n))}_acquireRenderer(e,t,r){const s=G.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=Q(this.rctx)),n||(n=new G(this.rctx,this.techniqueRepository,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:this.viewingMode===v.Global}),this._renderers.set(s,n)),++n.refCount,n}_removeRenderable(e){ne(e.regular),ne(e.silhouette);const t=this._renderers.get(e.rendererKey);if(t){t.removeRenderable(e),--t.refCount,"origin"in e.transform&&this._localOrigins.release(e.transform.origin),this._gpuMemoryUsage-=e.statistics.externalMemoryUsage?0:e.statistics.gpuMemoryUsage;for(const t of e.components.meta)e.components.buffer.releaseIndex(t.index)}}_updateObjectCameraDistances(e){const t=e.camera.eye,r=e.camera.viewForward,s=y(),n=e=>{_(s,e.center,t);const n=b(s,r),o=e.radius,i=n<-o?1/0:n<o?0:n-o;e.renderables.forEach((e=>e.distanceToCamera=i))};this._perObjectData.forEach(n),this._perObjectDataEvictionCache.forEach(n)}_renderRegularEdges(e,t,r){const s=e.bindRegularEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!he(n)||!n.visible)return;const i=pe(n.regular.lod.lengths,n.distanceToCamera,o);e.renderRegularEdges(s,n,r,t,i)}),n)}_renderSilhouetteEdges(e,t,r){const s=e.bindSilhouetteEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!ge(n)||!n.visible)return;const i=pe(n.silhouette.lod.lengths,n.distanceToCamera,o);e.renderSilhouetteEdges(s,n,r,t,i)}),n)}get test(){return{hasRenderedPrimitives:e=>{let t=!1;const r=e.perScreenPixelRatio,s=(e,s)=>e.forEachRenderable((e=>{e.visible&&!t&&(he(e)&&(t=pe(e.regular.lod.lengths,e.distanceToCamera,r)>0),!t&&ge(e)&&(t=pe(e.silhouette.lod.lengths,e.distanceToCamera,r)>0))}),s);return this._renderers.forEach((e=>{t||(s(e,F.OPAQUE),s(e,F.TRANSPARENT))})),t},getObjectData:e=>this._perObjectData.get(e)}}};function ne(e){null!=e&&(e.vao.vertexBuffers.instances.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function oe(e){let t=null,s=null;for(let n=0;n<e.geometries.length;n++){const o=e.geometries[n];if(o.material.supportsEdges){if(t){if(!r(t,o.transformation))return!1}else t=o.transformation;if(s||null==o.localOrigin){if(null!=s?.localOrigin&&null!=o.localOrigin&&s.localOrigin.id!==o.localOrigin.id)return!1}else s=o}}return!0}e([c({constructOnly:!0})],se.prototype,"rctx",void 0),e([c({constructOnly:!0})],se.prototype,"renderSR",void 0),e([c({constructOnly:!0})],se.prototype,"viewingMode",void 0),e([c({constructOnly:!0})],se.prototype,"techniqueRepository",void 0),e([c({constructOnly:!0})],se.prototype,"setNeedsRender",void 0),e([c({constructOnly:!0})],se.prototype,"schedule",void 0),e([c({readOnly:!0})],se.prototype,"_updatingHandles",void 0),e([c({readOnly:!0})],se.prototype,"updating",null),se=e([l("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],se);class ie{constructor(e,t,r){this.radius=r,this.renderables=new Array,this.loaded=e,this.loaded.then((()=>{null!=this.loaded&&(this.loaded=!0)})),this.center=j(t)}}class ae{constructor(e,t){this.buffer=e,this.meta=t}}class ce{constructor(e,t){this.vao=e,this.lod=t}}class le{constructor(e,t){this.modelMatrix=e,this.origin=t}}class de{constructor(e,t,r,s,n,o,i,a){this.regular=e,this.silhouette=t,this.statistics=r,this.transform=s,this.edgeTransparency=n,this.objectTransparency=o,this.components=i,this.rendererKey=a,this.distanceToCamera=0,this.visible=!0}}class ue extends de{}function he(e){return null!=e.regular}class me extends de{}function ge(e){return null!=e.silhouette}function pe(e,t,r){const n=t*r,o=s(e,n,!0);return-1===o?n<e[0]?e.length:0:e.length-o}class fe{constructor(e,t,r){this.position=e,this.modelTransform=t,this.origin=r}}const _e=m(),be=()=>Promise.reject();export{se as EdgeView,le as LegacyTransform,ue as RegularRenderable,de as Renderable,me as SilhouetteRenderable};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{getScaling as r}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{diameter as t}from"../../../../geometry/support/aaBoundingBox.js";import{
|
|
5
|
+
import{getScaling as r}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{diameter as t}from"../../../../geometry/support/aaBoundingBox.js";import{b as n}from"../../../../chunks/sphere.js";import{isPclIntersectorResult as i,isI3sIntersectorResult as l,isVoxelIntersectorResult as a,isTiles3DIntersectorResult as o}from"../../layers/i3s/Intersector.js";import{isTerrainIntersectorResult as u,isOverlayIntersectorResult as c}from"../../terrain/Intersector.js";import{isObjectIntersectorResult as s,isHudIntersectorResult as g}from"./intersectorUtils.js";import{isLodIntersectorResult as p}from"./lodRendering/Intersector.js";function f(r,e){return s(r)||g(r)?U(r.target?.object,e):u(r)?e.map?.ground:i(r)||l(r)||c(r)||a(r)?U(r.target,e):null}function m(r,e){const t=h(r,e);return null!=t&&"graphic"===t.type?t.graphic:null}function h(r,e){if(null==r)return null;if(s(r)||g(r))return d(r.target?.object,e);if(i(r)){const e=r.target.createGraphic();return{type:"graphic",graphic:e,layer:e.layer}}if(a(r)){const e=r.target.createVoxelGraphic();return{type:"graphic",graphic:e,layer:e.layer}}if(o(r)){const e=r.target.createTiles3DGraphic();return{type:"graphic",graphic:e,layer:e.layer}}return c(r)||p(r)?d(r.target,e):l(r)?y(r.target,e):null}function d(r,e){if(null==r?.graphicUid)return null;const t=U(r,e);if(null==t)return null;if(t===e.graphics)return null==e.graphicsView||"number"!=typeof r.graphicUid?null:e.graphicsView.getHit(r.graphicUid);const n=e.allLayerViews.find((r=>r.layer===t));return!n||n.suspended||null==r.graphicUid?null:"getHit"in n?n.getHit(r.graphicUid):null}function y(r,e){const t=U(r,e);if(null==t)return null;const n=e.allLayerViews.find((r=>r.layer===t));return n&&!n.suspended&&"getGraphicFromIntersectorTarget"in n?b(n.getGraphicFromIntersectorTarget(r)):null}function j(r,e){const t=U(r,e);if(null==t)return null;const n=e.allLayerViews.find((r=>r.layer===t));return n&&!n.suspended&&"getAABBFromIntersectorTarget"in n?n.getAABBFromIntersectorTarget(r):null}function b(r){return null!=r?{type:"graphic",graphic:r,layer:r.layer}:null}function U(r,e){return null==r?.layerUid?null:null!=e.graphicsView&&r.layerUid===e.graphicsView.processor.layer.id?e.graphics:e.map.allLayers.find((e=>e.uid===r.layerUid))}function V(e,i){if(s(e)||g(e))return n(e.target.object.boundingVolumeWorldSpace.bounds);if(p(e)){r(B,e.transformation);const t=Math.max(B[0],B[1],B[2]);return e.target.baseBoundingSphere.radius*t}if(l(e)){const r=j(e.target,i);return r?.5*t(r):null}return null}function w(r){return!s(r)&&!g(r)&&(p(r)?r.target.numLodLevels>1:!!l(r))}const B=e();export{V as getIntersectedFeatureBSRadius,w as hasLod,m as toGraphic,h as toHit,f as toOwner};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{create as t}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{e}from"../../../../../chunks/vec32.js";import{w as s,
|
|
5
|
+
import{create as t}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{e}from"../../../../../chunks/vec32.js";import{w as s,c as i,g as r}from"../../../../../chunks/sphere.js";import{maxScale as a}from"../../../support/mathUtils.js";import h from"../Octree.js";class n extends h{constructor(e,r){super((t=>s(this._instanceData.view.boundingSphere.getVec(t,this._tmpSphere))),{maximumDepth:25}),this._instanceData=e,this._boundingSphere=r,this._tmpSphere=i(),this._tmpMat4=t()}addInstance(t){const s=this._instanceData.view.boundingSphere,i=this._instanceData.getCombinedModelTransform(t,this._tmpMat4);e(r(this._tmpSphere),this._boundingSphere.center,i),this._tmpSphere[3]=this._boundingSphere.radius*a(i),s.setVec(t,this._tmpSphere),this.add([t])}removeInstance(t){this.remove([t])}}export{n as InstanceOctree};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{normalFromMat4Legacy as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as r,transpose as e,copy as i,multiply as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as n,g as h,l as f,r as l,e as m}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{
|
|
5
|
+
import{normalFromMat4Legacy as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as r,transpose as e,copy as i,multiply as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as n,g as h,l as f,r as l,e as m}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c,g as _}from"../../../../chunks/sphere.js";import{ViewingMode as u}from"../../../ViewingMode.js";import{Obb as g,computeOffsetObb as M}from"../../support/orientedBoundingBox.js";class v{constructor(){this._transform=a(),this._transformInverse=new b({value:this._transform},r,a),this._transformInverseTranspose=new b(this._transformInverse,e,a),this._transformTranspose=new b({value:this._transform},e,a),this._transformInverseRotation=new b({value:this._transform},t,s)}_invalidateLazyTransforms(){this._transformInverse.invalidate(),this._transformInverseTranspose.invalidate(),this._transformTranspose.invalidate(),this._transformInverseRotation.invalidate()}get transform(){return this._transform}get inverse(){return this._transformInverse.value}get inverseTranspose(){return this._transformInverseTranspose.value}get inverseRotation(){return this._transformInverseRotation.value}get transpose(){return this._transformTranspose.value}setTransformMatrix(t){i(this._transform,t)}multiplyTransform(t){o(this._transform,this._transform,t)}set(t){i(this._transform,t),this._invalidateLazyTransforms()}setAndInvalidateLazyTransforms(t,s){this.setTransformMatrix(t),this.multiplyTransform(s),this._invalidateLazyTransforms()}}class b{constructor(t,s,r){this._original=t,this._update=s,this._dirty=!0,this._transform=r()}invalidate(){this._dirty=!0}get value(){return this._dirty&&(this._update(this._transform,this._original.value),this._dirty=!1),this._transform}}class T{constructor(t=0){this.offset=t,this.tmpVertex=p()}applyToVertex(t,s,r){const e=n(q,t,s,r),i=h(z,e,this.localOrigin),o=this.offset/f(i);return l(this.tmpVertex,e,i,o),this.tmpVertex}applyToAabb(t){const s=A,r=R,e=B;for(let n=0;n<3;++n)s[n]=t[0+n]+this.localOrigin[n],r[n]=t[3+n]+this.localOrigin[n],e[n]=s[n];const i=this.applyToVertex(s[0],s[1],s[2]);for(let n=0;n<3;++n)t[n]=i[n],t[n+3]=i[n];const o=s=>{const r=this.applyToVertex(s[0],s[1],s[2]);for(let e=0;e<3;++e)t[e]=Math.min(t[e],r[e]),t[e+3]=Math.max(t[e+3],r[e])};for(let n=1;n<8;++n){for(let t=0;t<3;++t)e[t]=0==(n&1<<t)?s[t]:r[t];o(e)}let a=0;for(let n=0;n<3;++n){s[n]*r[n]<0&&(a|=1<<n)}if(0!==a&&7!==a)for(let n=0;n<8;++n)if(0==(a&n)){for(let t=0;t<3;++t)e[t]=0!=(a&1<<t)?0:0!=(n&1<<t)?s[t]:r[t];o(e)}for(let n=0;n<3;++n)t[n]-=this.localOrigin[n],t[n+3]-=this.localOrigin[n];return t}}class x{constructor(t=0){this.componentLocalOriginLength=0,this._totalOffset=0,this._offset=0,this._tmpVertex=p(),this._tmpMbs=c(),this._tmpObb=new g,this._resetOffset(t)}_resetOffset(t){this._offset=t,this._totalOffset=t}set offset(t){this._resetOffset(t)}get offset(){return this._offset}set componentOffset(t){this._totalOffset=this._offset+t}set localOrigin(t){this.componentLocalOriginLength=f(t)}applyToVertex(t,s,r){const e=n(q,t,s,r),i=n(z,t,s,r+this.componentLocalOriginLength),o=this._totalOffset/f(i);return l(this._tmpVertex,e,i,o),this._tmpVertex}applyToAabb(t){const s=this.componentLocalOriginLength,r=t[0],e=t[1],i=t[2]+s,o=t[3],a=t[4],n=t[5]+s,h=Math.abs(r),f=Math.abs(e),l=Math.abs(i),m=Math.abs(o),p=Math.abs(a),c=Math.abs(n),_=.5*(1+Math.sign(r*o))*Math.min(h,m),u=.5*(1+Math.sign(e*a))*Math.min(f,p),g=.5*(1+Math.sign(i*n))*Math.min(l,c),M=Math.max(h,m),v=Math.max(f,p),b=Math.max(l,c),T=Math.sqrt(_*_+u*u+g*g),x=Math.sign(h+r),O=Math.sign(f+e),y=Math.sign(l+i),d=Math.sign(m+o),V=Math.sign(p+a),L=Math.sign(c+n),j=this._totalOffset;if(T<j)return t[0]-=(1-x)*j,t[1]-=(1-O)*j,t[2]-=(1-y)*j,t[3]+=d*j,t[4]+=V*j,t[5]+=L*j,t;const I=j/Math.sqrt(M*M+v*v+b*b),w=j/T,q=w-I,z=-q;return t[0]+=r*(x*z+w),t[1]+=e*(O*z+w),t[2]+=i*(y*z+w),t[3]+=o*(d*q+I),t[4]+=a*(V*q+I),t[5]+=n*(L*q+I),t}applyToMbs(t){const s=f(_(t)),r=this._totalOffset/s;return l(_(this._tmpMbs),_(t),_(t),r),this._tmpMbs[3]=t[3]+t[3]*this._totalOffset/s,this._tmpMbs}applyToObb(t){return M(t,this._totalOffset,this._totalOffset,u.Global,this._tmpObb),this._tmpObb}}class O{constructor(t=0){this.offset=t,this.sphere=c(),this.tmpVertex=p()}applyToVertex(t,s,r){const e=this.objectTransform.transform,i=n(q,t,s,r),o=m(i,i,e),a=this.offset/f(o);l(o,o,o,a);const h=this.objectTransform.inverse;return m(this.tmpVertex,o,h),this.tmpVertex}applyToMinMax(t,s){const r=this.offset/f(t);l(t,t,t,r);const e=this.offset/f(s);l(s,s,s,e)}applyToAabb(t){const s=this.offset/Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]+=t[0]*s,t[1]+=t[1]*s,t[2]+=t[2]*s;const r=this.offset/Math.sqrt(t[3]*t[3]+t[4]*t[4]+t[5]*t[5]);return t[3]+=t[3]*r,t[4]+=t[4]*r,t[5]+=t[5]*r,t}applyToBoundingSphere(t){const s=f(_(t)),r=this.offset/s;return l(_(this.sphere),_(t),_(t),r),this.sphere[3]=t[3]+t[3]*this.offset/s,this.sphere}}const y=new O;function d(t){return null!=t?(y.offset=t,y):null}const V=new x;function L(t){return null!=t?(V.offset=t,V):null}const j=new T;function I(t){return null!=t?(j.offset=t,j):null}const w="terrain",q=p(),z=p(),A=p(),R=p(),B=p();export{x as I3SVerticalOffsetGlobalViewingMode,v as IntersectorTransform,O as Object3DVerticalOffsetGlobalViewingMode,T as TerrainVerticalOffsetGlobalViewingMode,L as getVerticalOffsetI3S,d as getVerticalOffsetObject3D,I as getVerticalOffsetTerrain,w as terrainId};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as t,equals as e}from"../../../core/arrayUtils.js";import{asinClamped as s}from"../../../core/mathUtils.js";import{dot as r,subtract as n,exactEquals as i,set as o,squaredDistance as c}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{create as u}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{r as a,j as h,a as f,z as l,p as d,s as p,c as m,f as g,G as L,k,b as _,n as M}from"../../../chunks/vec32.js";import{clone as P,create as x,fromValues as v,UNIT_Z as y}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as T,h as w}from"../../../chunks/vec42.js";import{create as j}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{toRadians as q}from"../../../geometry/support/geodesicConstants.js";import{directGeodeticSolver as z,inverseGeodeticSolver as A,InverseGeodeticSolverResult as b}from"../../../geometry/support/geodesicUtils.js";import{create as D,intersectLine as E,signedDistance as N,projectPoint as R,fromPositionAndNormal as U,fromPoints as Z,distance as I,getNormal as G}from"../../../geometry/support/plane.js";import{b as S,l as C,p as O,g as F,m as H}from"../../../chunks/sphere.js";import{tangentFrame as V}from"../../3d/support/mathUtils.js";import{fromVec3 as Y,clone as B,fromValues as J,asVec2 as K,create as Q}from"./normalizedPoint.js";import{vectorsHaveCloseZ as W,isClose as X,intersectVerticalPlaneAndVerticalCylinder as $,isPointInsidePlane as tt,projectPointToLineLike as et,projectPointToVerticalCylinder as st,projectPointToVerticalPlane as rt,VerticalPlaneType as nt,intersectLineLikes as it,intersectVerticalPlaneAndLineLike as ot,intersectLineLikeAndVerticalCylinder as ct,intersectLineLikeAndCircle as ut,intersectVerticalPlanes as at,intersectVerticalCylinders as ht,pointsInsidePlane as ft,intersectVerticalPlaneAndPoint as lt}from"../../support/geometry3dUtils.js";import{LineType as dt}from"../../support/geometry2dUtils.js";class pt{intersect(t){return Ot(this,t)}closestPoints(t){return[this.closestTo(t)]}}class mt extends pt{constructor(t){super(),this.point=t}equals(t){return this===t||ge(t)&&h(this.point,t.point)}closestTo(){return B(this.point)}}class gt extends pt{constructor(t,e,s){super(),this.start=t,this.end=e,this.lineLike={start:t,end:e,type:s}}equals(t){return this===t||Le(t)&&this.lineLike.type===t.lineLike.type&&h(this.start,t.start)&&h(this.end,t.end)}closestTo(t){const e=et(t,this.lineLike);return Y(e)}}class Lt extends gt{constructor(t,e){super(t,e,dt.LINE)}}class kt extends gt{constructor(t,e){super(t,e,dt.RAY)}}class _t extends pt{constructor(t){super(),this.constraints=t}equals(t){return this===t||me(t)&&e(this.constraints,t.constraints,((t,e)=>t.equals(e)))}closestTo(t){let e,s=1/0;for(const r of this.constraints){const n=r.closestTo(t),i=f(t,n);i<s&&(s=i,e=n)}return e?B(e):t}closestPoints(t){return this.constraints.flatMap((e=>e===this?[]:e.closestPoints(t)))}}class Mt extends pt{constructor(t,e){super(),this.center=t,this.radius=e}equals(t){return this===t||Me(t)&&this.center[0]===t.center[0]&&this.center[1]===t.center[1]&&this.radius===t.radius}closestTo(t){const e=st(t,this.center,this.radius);return Y(e)}}class Pt extends pt{constructor(t,e){super(),this.center=t,this.radius=e}equals(t){return this===t||Pe(t)&&h(this.center,t.center)&&this.radius===t.radius}closestTo(t){const e=st(t,this.center,this.radius);return e[2]=this.center[2],Y(e)}asCircle(){return new xt(B(this.center),this.radius,J(0,0,1))}}class xt extends pt{constructor(t,e,s,r=void 0){super(),this.center=t,this.radius=e,this.normal=s,this.slicePlane=r}equals(t){return this===t||xe(t)&&h(this.center,t.center)&&h(this.normal,t.normal)&&this.radius===t.radius}closestTo(t){const{center:e,radius:s}=this;R(this.getPlane(yt),t,vt);const r=l(vt,vt,e),n=d(r);if(X(n,0))return B(t);const i=s/Math.sqrt(n),o=a(x(),e,r,i),{slicePlane:c}=this;if(c&&!tt(c,o)){const e=Yt(c,this);return e?.closestTo(t)??B(t)}return Y(o)}getPlane(t=D()){return U(this.center,this.normal,t)}}const vt=x(),yt=D();class Tt extends pt{constructor(t){super(),this.z=t}equals(t){return this===t||ke(t)&&this.z===t.z}closestTo(t){return Y(v(t[0],t[1],this.z))}getPlane(t=D()){return p(wt,0,0,this.z),U(wt,y,t)}}const wt=x();class jt extends pt{constructor(t,e,s){super(),this.start=t,this.end=e,this.planeLike={start:K(t),end:K(e),type:s}}equals(t){return this===t||_e(t)&&this.planeLike.type===t.planeLike.type&&h(this.start,t.start)&&h(this.end,t.end)}closestTo(t){return Y(rt(t,this.planeLike))}closestEndTo(t){const{start:e,end:s}=this.planeLike;return Math.sign(r(n(qt,s,e),n(zt,K(t),e)))>0?this.end:this.start}getPlane(t=D()){const e=m(At,this.end);return e[2]+=1,Z(this.start,this.end,e,t)}getSlicePlane(t=D()){const{start:e,end:s,type:r}=this.planeLike;if(r===nt.PLANE)return;const n=p(At,e[0],e[1],0),i=p(bt,s[0],s[1],0),o=g(bt,i,n);return U(n,o,t),t}}const qt=u(),zt=u(),At=x(),bt=x();class Dt extends jt{constructor(t,e){super(t,e,nt.HALF_PLANE)}}class Et extends jt{constructor(t,e){super(t,e,nt.PLANE)}}class Nt extends pt{constructor(t,e){super(),this.sphere=S(t,e)}equals(t){return this===t||ve(t)&&C(this.sphere,t.sphere)}closestTo(t){const e=O(this.sphere,t,x());return Y(e)}get center(){return F(this.sphere)}get radius(){return this.sphere[3]}}class Rt extends pt{constructor(t,e,s){super(),this.start=t,this.end=e,this.getZ=s,this.planeLike={start:K(t),end:K(e),type:nt.PLANE}}equals(t){return this===t||ye(t)&&h(this.start,t.start)&&h(this.end,t.end)&&this.getZ===t.getZ}closestTo(t){return Ct(this,t)}addIfOnTheGround(t,e){for(const s of e){const e=this.getZ(s[0],s[1])??0;X(s[2],e)&&(s[2]=e,t.push(s))}}}class Ut extends pt{constructor(t,e,s,r,n){super(),this._origin=t,this._spatialReference=e,this._distanceMeters=s,this._elevationMeters=r,this._directionDegrees=n}equals(t){return this===t||Te(t)&&i(this._origin,t._origin)&&this._distanceMeters===t._distanceMeters&&this._elevationMeters===t._elevationMeters&&this._directionDegrees===t._directionDegrees}closestTo([t,e,s]){if(o(Zt,t,e),null!=this._directionDegrees&&null!=this._distanceMeters)z(Zt,this._origin,this._directionDegrees,this._distanceMeters,this._spatialReference);else if(null!=this._directionDegrees)Gt(Zt,this._origin,this._directionDegrees,Zt,this._spatialReference);else if(null!=this._distanceMeters){const{azimuth:t}=A(It,this._origin,Zt,this._spatialReference);z(Zt,this._origin,t??0,this._distanceMeters,this._spatialReference)}return Q(Zt[0],Zt[1],this._elevationMeters??s)}}const Zt=[0,0],It=new b;function Gt(t,e,s,r,n){let{azimuth:i,distance:o}=A(St,e,r,n);i??=0;let c=o*Math.cos((i-s)*q);c=Math.max(0,c),z(t,e,s,c,n)}const St=new b;function Ct(t,e){const s=rt(e,t.planeLike);return s[2]=t.getZ(s[0],s[1])??we,Y(s)}function Ot(t,e){if(me(t)){const s=[];for(const r of t.constraints){const t=r.intersect(e);t&&s.push(t)}return pe(s)}if(me(e))return Ot(e,t);if(ye(t))return he(t,e);if(ye(e))return he(e,t);if(ge(t)){const{point:s}=t;if(ge(e))return h(s,e.point)?t:void 0;const r=e.closestTo(s);return L(r,s)?t:void 0}if(Le(t)){if(ge(e))return Ot(e,t);if(Le(e))return le(it(t.lineLike,e.lineLike));if(ke(e))return Ft(t,e);if(_e(e))return le(ot(e.planeLike,t.lineLike));if(Me(e))return le(ct(t.lineLike,e.center,e.radius));if(xe(e))return le(ut(t.lineLike,e));if(Pe(e))return Ht(t,e);if(ve(e))return Vt(t,e)}else if(ke(t)){if(ge(e)||Le(e))return Ot(e,t);if(ke(e))return Bt(t,e);if(_e(e))return Jt(t,e);if(Me(e))return Kt(t,e);if(xe(e))return Wt(t,e);if(Pe(e))return Qt(t,e);if(ve(e))return Xt(t,e)}else if(_e(t)){if(ge(e)||Le(e)||ke(e))return Ot(e,t);if(_e(e))return fe(at(t.planeLike,e.planeLike));if(Me(e))return fe($(t.planeLike,e.center,e.radius));if(xe(e))return te(t,e);if(Pe(e))return $t(t,e);if(ve(e))return ee(t,e)}else if(Me(t)){if(ge(e)||Le(e)||ke(e)||_e(e))return Ot(e,t);if(Me(e))return fe(ht(K(t.center),t.radius,K(e.center),e.radius));if(xe(e))return se();if(Pe(e))return re(t,e);if(ve(e))return ne()}else if(xe(t)){if(ge(e)||Le(e)||ke(e)||_e(e)||Me(e))return Ot(e,t);if(xe(e))return ie();if(Pe(e))return ie(e.asCircle());if(ve(e))return oe()}else if(Pe(t)){if(ge(e)||Le(e)||ke(e)||_e(e)||Me(e)||xe(e))return Ot(e,t);if(Pe(e))return ce(e,t);if(ve(e))return ue()}else if(ve(t)){if(ge(e)||Le(e)||ke(e)||_e(e)||Me(e)||Pe(e))return Ot(e,t);if(ve(e))return ae()}}const Ft=(()=>{const t=D();return(e,s)=>{const{start:r,end:n}=e;if(W(r,n)&&X(r[2],s.z))return e;const i=x();return E(s.getPlane(t),r,n,i)?new mt(Y(i)):void 0}})();function Ht({lineLike:t},{center:e,radius:s}){const r=e[2];return le(ct(t,e,s).filter((t=>X(t[2],r))))}function Vt({lineLike:t},{sphere:e}){return le(H(e,t.start,t.end))}const Yt=(()=>{const t=j(),e=x(),r=x();return(n,i,o)=>{const{normal:c,center:u,radius:h}=i;V(c,e,r);const f=G(n),l=h*k(f,e),d=h*k(f,r);T(t,u[0],u[1],u[2],1);const p=w(n,t),m=Math.hypot(l,d),g=X(m,0);if(X(I(n,u),0)){if(g)return i;if(X(h,0))return!o||tt(o,u)?new mt(B(u)):void 0;_(e,f,c),M(e,e);const t=new Array,s=P(u);a(s,s,e,h),o&&!tt(o,s)||t.push(s);const r=P(u);return a(r,r,e,-h),o&&!tt(o,r)||t.push(r),le(t)}if(g)return;const L=-p/m;if(Math.abs(L)>1||X(L,1))return;const v=Math.atan(l/d),y=s(L)-v,j=Math.PI-y,q=new Array,z=x();a(z,u,e,h*Math.cos(y)),a(z,z,r,h*Math.sin(y)),q.push(z);const A=x();return a(A,u,e,h*Math.cos(j)),a(A,A,r,h*Math.sin(j)),q.push(A),le(o?ft(o,q):q)}})();function Bt(t,e){return X(t.z,e.z)?t:void 0}function Jt({z:t},{planeLike:e}){const[s,r]=e.start,[n,i]=e.end,o=J(s,r,t),c=J(n,i,t);return e.type===nt.PLANE?new Lt(o,c):new kt(o,c)}function Kt(t,e){const[s,r]=e.center;return new Pt(J(s,r,t.z),e.radius)}function Qt(t,e){return X(e.center[2],t.z)?e:void 0}const Wt=(()=>{const t=D();return(e,s)=>Yt(e.getPlane(t),s,s.slicePlane)})();function Xt(t,{center:e,radius:s}){const r=Math.abs(e[2]-t.z);if(r>s&&!X(r,s))return;const n=J(e[0],e[1],t.z),i=Math.sqrt(s**2-r**2);return X(i,0)?void 0:new Pt(n,i)}const $t=(()=>{const t=D();return(e,{center:s,radius:r})=>{const n=$(e.planeLike,s,r),i=s[2];e.getSlicePlane(t);const o=new Array;for(const[c,u]of n){const e=[c,u,i];tt(t,e)&&o.push(e)}return le(o)}})(),te=(()=>{const t=D(),e=D();return(s,r)=>Yt(s.getPlane(t),r,s.getSlicePlane(e))})(),ee=(()=>{const t=D();return(e,{center:s,radius:r})=>{const n=e.getPlane(t),i=N(n,s),o=Math.abs(i);if(o>r&&!X(o,r))return;const c=P(G(n)),u=a(x(),s,c,i),h=Math.sqrt(r**2-i**2);return X(h,0)?new mt(Y(R(n,s,x()))):new xt(Y(u),h,c,e.getSlicePlane())}})();function se(t,e){}function re(t,e){const s=c(K(t.center),K(e.center));if(X(s,0)&&X(t.radius,e.radius))return e;return de(ht(K(t.center),t.radius,K(e.center),e.radius),e.center[2])}function ne(t,e){}function ie(t,e){}function oe(t,e){}function ce(t,e){if(!W(t.center,e.center))return;const s=c(K(t.center),K(e.center));if(X(s,0)&&X(t.radius,e.radius))return t;return de(ht(K(t.center),t.radius,K(e.center),e.radius),t.center[2])}function ue(t,e){}function ae(t,e){}function he(t,e){const{planeLike:s,getZ:r}=t,n=new Array;if(ge(e))t.addIfOnTheGround(n,lt(s,e.point));else if(Le(e))t.addIfOnTheGround(n,ot(s,e.lineLike));else if(Me(e))for(const[i,o]of $(s,e.center,e.radius)){const t=r(i,o);null!=t&&n.push(v(i,o,t))}else if(_e(e)||ye(e))for(const[i,o]of at(s,e.planeLike)){const t=r(i,o)??we;n.push(v(i,o,t))}return le(n)}function fe(t){return pe(t.map((([t,e])=>{const s=J(t,e,0),r=J(t,e,1);return new Lt(s,r)})))}function le(t){return pe(t.map((t=>t?new mt(Y(t)):void 0)))}function de(t,e){return le(t.map((([t,s])=>[t,s,e])))}function pe(e){if(0!==e.length)return 1===e.length?e[0]??void 0:new _t(e.filter(t))}function me(t){return t instanceof _t}function ge(t){return t instanceof mt}function Le(t){return t instanceof gt}function ke(t){return t instanceof Tt}function _e(t){return t instanceof jt}function Me(t){return t instanceof Mt}function Pe(t){return t instanceof Pt}function xe(t){return t instanceof xt}function ve(t){return t instanceof Nt}function ye(t){return t instanceof Rt}function Te(t){return t instanceof Ut}const we=0;export{xt as CircleConstraint,pt as Constraint,Rt as DrapedLineConstraint,Ut as GeodesicConstraint,Pt as HorizontalCircleConstraint,Tt as HorizontalPlaneConstraint,Lt as LineConstraint,gt as LineLikeConstraint,mt as PointConstraint,kt as RayConstraint,_t as SetConstraint,Nt as SphereConstraint,Mt as VerticalCylinderConstraint,Dt as VerticalHalfPlaneConstraint,Et as VerticalPlaneConstraint,jt as VerticalPlaneLikeConstraint,pe as constraintOrSet,ge as isPoint};
|
|
5
|
+
import{isSome as t,equals as e}from"../../../core/arrayUtils.js";import{asinClamped as s}from"../../../core/mathUtils.js";import{dot as r,subtract as n,exactEquals as i,set as o,squaredDistance as c}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{create as u}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{r as a,j as f,a as h,z as l,p as d,s as p,c as m,f as g,G as L,k,b as _,n as M}from"../../../chunks/vec32.js";import{clone as P,create as x,fromValues as v,UNIT_Z as y}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as T,g as w}from"../../../chunks/vec42.js";import{create as j}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{toRadians as q}from"../../../geometry/support/geodesicConstants.js";import{directGeodeticSolver as z,inverseGeodeticSolver as A,InverseGeodeticSolverResult as b}from"../../../geometry/support/geodesicUtils.js";import{create as D,intersectLine as E,signedDistance as N,projectPoint as R,fromPositionAndNormal as U,fromPoints as Z,distance as I,getNormal as G}from"../../../geometry/support/plane.js";import{k as S,l as C,p as O,g as F,m as H}from"../../../chunks/sphere.js";import{tangentFrame as V}from"../../3d/support/mathUtils.js";import{fromVec3 as Y,clone as B,fromValues as J,asVec2 as K,create as Q}from"./normalizedPoint.js";import{vectorsHaveCloseZ as W,isClose as X,intersectVerticalPlaneAndVerticalCylinder as $,isPointInsidePlane as tt,projectPointToLineLike as et,projectPointToVerticalCylinder as st,projectPointToVerticalPlane as rt,VerticalPlaneType as nt,intersectLineLikes as it,intersectVerticalPlaneAndLineLike as ot,intersectLineLikeAndVerticalCylinder as ct,intersectLineLikeAndCircle as ut,intersectVerticalPlanes as at,intersectVerticalCylinders as ft,pointsInsidePlane as ht,intersectVerticalPlaneAndPoint as lt}from"../../support/geometry3dUtils.js";import{LineType as dt}from"../../support/geometry2dUtils.js";class pt{intersect(t){return Ot(this,t)}closestPoints(t){return[this.closestTo(t)]}}class mt extends pt{constructor(t){super(),this.point=t}equals(t){return this===t||ge(t)&&f(this.point,t.point)}closestTo(){return B(this.point)}}class gt extends pt{constructor(t,e,s){super(),this.start=t,this.end=e,this.lineLike={start:t,end:e,type:s}}equals(t){return this===t||Le(t)&&this.lineLike.type===t.lineLike.type&&f(this.start,t.start)&&f(this.end,t.end)}closestTo(t){const e=et(t,this.lineLike);return Y(e)}}class Lt extends gt{constructor(t,e){super(t,e,dt.LINE)}}class kt extends gt{constructor(t,e){super(t,e,dt.RAY)}}class _t extends pt{constructor(t){super(),this.constraints=t}equals(t){return this===t||me(t)&&e(this.constraints,t.constraints,((t,e)=>t.equals(e)))}closestTo(t){let e,s=1/0;for(const r of this.constraints){const n=r.closestTo(t),i=h(t,n);i<s&&(s=i,e=n)}return e?B(e):t}closestPoints(t){return this.constraints.flatMap((e=>e===this?[]:e.closestPoints(t)))}}class Mt extends pt{constructor(t,e){super(),this.center=t,this.radius=e}equals(t){return this===t||Me(t)&&this.center[0]===t.center[0]&&this.center[1]===t.center[1]&&this.radius===t.radius}closestTo(t){const e=st(t,this.center,this.radius);return Y(e)}}class Pt extends pt{constructor(t,e){super(),this.center=t,this.radius=e}equals(t){return this===t||Pe(t)&&f(this.center,t.center)&&this.radius===t.radius}closestTo(t){const e=st(t,this.center,this.radius);return e[2]=this.center[2],Y(e)}asCircle(){return new xt(B(this.center),this.radius,J(0,0,1))}}class xt extends pt{constructor(t,e,s,r=void 0){super(),this.center=t,this.radius=e,this.normal=s,this.slicePlane=r}equals(t){return this===t||xe(t)&&f(this.center,t.center)&&f(this.normal,t.normal)&&this.radius===t.radius}closestTo(t){const{center:e,radius:s}=this;R(this.getPlane(yt),t,vt);const r=l(vt,vt,e),n=d(r);if(X(n,0))return B(t);const i=s/Math.sqrt(n),o=a(x(),e,r,i),{slicePlane:c}=this;if(c&&!tt(c,o)){const e=Yt(c,this);return e?.closestTo(t)??B(t)}return Y(o)}getPlane(t=D()){return U(this.center,this.normal,t)}}const vt=x(),yt=D();class Tt extends pt{constructor(t){super(),this.z=t}equals(t){return this===t||ke(t)&&this.z===t.z}closestTo(t){return Y(v(t[0],t[1],this.z))}getPlane(t=D()){return p(wt,0,0,this.z),U(wt,y,t)}}const wt=x();class jt extends pt{constructor(t,e,s){super(),this.start=t,this.end=e,this.planeLike={start:K(t),end:K(e),type:s}}equals(t){return this===t||_e(t)&&this.planeLike.type===t.planeLike.type&&f(this.start,t.start)&&f(this.end,t.end)}closestTo(t){return Y(rt(t,this.planeLike))}closestEndTo(t){const{start:e,end:s}=this.planeLike;return Math.sign(r(n(qt,s,e),n(zt,K(t),e)))>0?this.end:this.start}getPlane(t=D()){const e=m(At,this.end);return e[2]+=1,Z(this.start,this.end,e,t)}getSlicePlane(t=D()){const{start:e,end:s,type:r}=this.planeLike;if(r===nt.PLANE)return;const n=p(At,e[0],e[1],0),i=p(bt,s[0],s[1],0),o=g(bt,i,n);return U(n,o,t),t}}const qt=u(),zt=u(),At=x(),bt=x();class Dt extends jt{constructor(t,e){super(t,e,nt.HALF_PLANE)}}class Et extends jt{constructor(t,e){super(t,e,nt.PLANE)}}class Nt extends pt{constructor(t,e){super(),this.sphere=S(t,e)}equals(t){return this===t||ve(t)&&C(this.sphere,t.sphere)}closestTo(t){const e=O(this.sphere,t,x());return Y(e)}get center(){return F(this.sphere)}get radius(){return this.sphere[3]}}class Rt extends pt{constructor(t,e,s){super(),this.start=t,this.end=e,this.getZ=s,this.planeLike={start:K(t),end:K(e),type:nt.PLANE}}equals(t){return this===t||ye(t)&&f(this.start,t.start)&&f(this.end,t.end)&&this.getZ===t.getZ}closestTo(t){return Ct(this,t)}addIfOnTheGround(t,e){for(const s of e){const e=this.getZ(s[0],s[1])??0;X(s[2],e)&&(s[2]=e,t.push(s))}}}class Ut extends pt{constructor(t,e,s,r,n){super(),this._origin=t,this._spatialReference=e,this._distanceMeters=s,this._elevationMeters=r,this._directionDegrees=n}equals(t){return this===t||Te(t)&&i(this._origin,t._origin)&&this._distanceMeters===t._distanceMeters&&this._elevationMeters===t._elevationMeters&&this._directionDegrees===t._directionDegrees}closestTo([t,e,s]){if(o(Zt,t,e),null!=this._directionDegrees&&null!=this._distanceMeters)z(Zt,this._origin,this._directionDegrees,this._distanceMeters,this._spatialReference);else if(null!=this._directionDegrees)Gt(Zt,this._origin,this._directionDegrees,Zt,this._spatialReference);else if(null!=this._distanceMeters){const{azimuth:t}=A(It,this._origin,Zt,this._spatialReference);z(Zt,this._origin,t??0,this._distanceMeters,this._spatialReference)}return Q(Zt[0],Zt[1],this._elevationMeters??s)}}const Zt=[0,0],It=new b;function Gt(t,e,s,r,n){let{azimuth:i,distance:o}=A(St,e,r,n);i??=0;let c=o*Math.cos((i-s)*q);c=Math.max(0,c),z(t,e,s,c,n)}const St=new b;function Ct(t,e){const s=rt(e,t.planeLike);return s[2]=t.getZ(s[0],s[1])??we,Y(s)}function Ot(t,e){if(me(t)){const s=[];for(const r of t.constraints){const t=r.intersect(e);t&&s.push(t)}return pe(s)}if(me(e))return Ot(e,t);if(ye(t))return fe(t,e);if(ye(e))return fe(e,t);if(ge(t)){const{point:s}=t;if(ge(e))return f(s,e.point)?t:void 0;const r=e.closestTo(s);return L(r,s)?t:void 0}if(Le(t)){if(ge(e))return Ot(e,t);if(Le(e))return le(it(t.lineLike,e.lineLike));if(ke(e))return Ft(t,e);if(_e(e))return le(ot(e.planeLike,t.lineLike));if(Me(e))return le(ct(t.lineLike,e.center,e.radius));if(xe(e))return le(ut(t.lineLike,e));if(Pe(e))return Ht(t,e);if(ve(e))return Vt(t,e)}else if(ke(t)){if(ge(e)||Le(e))return Ot(e,t);if(ke(e))return Bt(t,e);if(_e(e))return Jt(t,e);if(Me(e))return Kt(t,e);if(xe(e))return Wt(t,e);if(Pe(e))return Qt(t,e);if(ve(e))return Xt(t,e)}else if(_e(t)){if(ge(e)||Le(e)||ke(e))return Ot(e,t);if(_e(e))return he(at(t.planeLike,e.planeLike));if(Me(e))return he($(t.planeLike,e.center,e.radius));if(xe(e))return te(t,e);if(Pe(e))return $t(t,e);if(ve(e))return ee(t,e)}else if(Me(t)){if(ge(e)||Le(e)||ke(e)||_e(e))return Ot(e,t);if(Me(e))return he(ft(K(t.center),t.radius,K(e.center),e.radius));if(xe(e))return se();if(Pe(e))return re(t,e);if(ve(e))return ne()}else if(xe(t)){if(ge(e)||Le(e)||ke(e)||_e(e)||Me(e))return Ot(e,t);if(xe(e))return ie();if(Pe(e))return ie(e.asCircle());if(ve(e))return oe()}else if(Pe(t)){if(ge(e)||Le(e)||ke(e)||_e(e)||Me(e)||xe(e))return Ot(e,t);if(Pe(e))return ce(e,t);if(ve(e))return ue()}else if(ve(t)){if(ge(e)||Le(e)||ke(e)||_e(e)||Me(e)||Pe(e))return Ot(e,t);if(ve(e))return ae()}}const Ft=(()=>{const t=D();return(e,s)=>{const{start:r,end:n}=e;if(W(r,n)&&X(r[2],s.z))return e;const i=x();return E(s.getPlane(t),r,n,i)?new mt(Y(i)):void 0}})();function Ht({lineLike:t},{center:e,radius:s}){const r=e[2];return le(ct(t,e,s).filter((t=>X(t[2],r))))}function Vt({lineLike:t},{sphere:e}){return le(H(e,t.start,t.end))}const Yt=(()=>{const t=j(),e=x(),r=x();return(n,i,o)=>{const{normal:c,center:u,radius:f}=i;V(c,e,r);const h=G(n),l=f*k(h,e),d=f*k(h,r);T(t,u[0],u[1],u[2],1);const p=w(n,t),m=Math.hypot(l,d),g=X(m,0);if(X(I(n,u),0)){if(g)return i;if(X(f,0))return!o||tt(o,u)?new mt(B(u)):void 0;_(e,h,c),M(e,e);const t=new Array,s=P(u);a(s,s,e,f),o&&!tt(o,s)||t.push(s);const r=P(u);return a(r,r,e,-f),o&&!tt(o,r)||t.push(r),le(t)}if(g)return;const L=-p/m;if(Math.abs(L)>1||X(L,1))return;const v=Math.atan(l/d),y=s(L)-v,j=Math.PI-y,q=new Array,z=x();a(z,u,e,f*Math.cos(y)),a(z,z,r,f*Math.sin(y)),q.push(z);const A=x();return a(A,u,e,f*Math.cos(j)),a(A,A,r,f*Math.sin(j)),q.push(A),le(o?ht(o,q):q)}})();function Bt(t,e){return X(t.z,e.z)?t:void 0}function Jt({z:t},{planeLike:e}){const[s,r]=e.start,[n,i]=e.end,o=J(s,r,t),c=J(n,i,t);return e.type===nt.PLANE?new Lt(o,c):new kt(o,c)}function Kt(t,e){const[s,r]=e.center;return new Pt(J(s,r,t.z),e.radius)}function Qt(t,e){return X(e.center[2],t.z)?e:void 0}const Wt=(()=>{const t=D();return(e,s)=>Yt(e.getPlane(t),s,s.slicePlane)})();function Xt(t,{center:e,radius:s}){const r=Math.abs(e[2]-t.z);if(r>s&&!X(r,s))return;const n=J(e[0],e[1],t.z),i=Math.sqrt(s**2-r**2);return X(i,0)?void 0:new Pt(n,i)}const $t=(()=>{const t=D();return(e,{center:s,radius:r})=>{const n=$(e.planeLike,s,r),i=s[2];e.getSlicePlane(t);const o=new Array;for(const[c,u]of n){const e=[c,u,i];tt(t,e)&&o.push(e)}return le(o)}})(),te=(()=>{const t=D(),e=D();return(s,r)=>Yt(s.getPlane(t),r,s.getSlicePlane(e))})(),ee=(()=>{const t=D();return(e,{center:s,radius:r})=>{const n=e.getPlane(t),i=N(n,s),o=Math.abs(i);if(o>r&&!X(o,r))return;const c=P(G(n)),u=a(x(),s,c,i),f=Math.sqrt(r**2-i**2);return X(f,0)?new mt(Y(R(n,s,x()))):new xt(Y(u),f,c,e.getSlicePlane())}})();function se(t,e){}function re(t,e){const s=c(K(t.center),K(e.center));if(X(s,0)&&X(t.radius,e.radius))return e;return de(ft(K(t.center),t.radius,K(e.center),e.radius),e.center[2])}function ne(t,e){}function ie(t,e){}function oe(t,e){}function ce(t,e){if(!W(t.center,e.center))return;const s=c(K(t.center),K(e.center));if(X(s,0)&&X(t.radius,e.radius))return t;return de(ft(K(t.center),t.radius,K(e.center),e.radius),t.center[2])}function ue(t,e){}function ae(t,e){}function fe(t,e){const{planeLike:s,getZ:r}=t,n=new Array;if(ge(e))t.addIfOnTheGround(n,lt(s,e.point));else if(Le(e))t.addIfOnTheGround(n,ot(s,e.lineLike));else if(Me(e))for(const[i,o]of $(s,e.center,e.radius)){const t=r(i,o);null!=t&&n.push(v(i,o,t))}else if(_e(e)||ye(e))for(const[i,o]of at(s,e.planeLike)){const t=r(i,o)??we;n.push(v(i,o,t))}return le(n)}function he(t){return pe(t.map((([t,e])=>{const s=J(t,e,0),r=J(t,e,1);return new Lt(s,r)})))}function le(t){return pe(t.map((t=>t?new mt(Y(t)):void 0)))}function de(t,e){return le(t.map((([t,s])=>[t,s,e])))}function pe(e){if(0!==e.length)return 1===e.length?e[0]??void 0:new _t(e.filter(t))}function me(t){return t instanceof _t}function ge(t){return t instanceof mt}function Le(t){return t instanceof gt}function ke(t){return t instanceof Tt}function _e(t){return t instanceof jt}function Me(t){return t instanceof Mt}function Pe(t){return t instanceof Pt}function xe(t){return t instanceof xt}function ve(t){return t instanceof Nt}function ye(t){return t instanceof Rt}function Te(t){return t instanceof Ut}const we=0;export{xt as CircleConstraint,pt as Constraint,Rt as DrapedLineConstraint,Ut as GeodesicConstraint,Pt as HorizontalCircleConstraint,Tt as HorizontalPlaneConstraint,Lt as LineConstraint,gt as LineLikeConstraint,mt as PointConstraint,kt as RayConstraint,_t as SetConstraint,Nt as SphereConstraint,Mt as VerticalCylinderConstraint,Dt as VerticalHalfPlaneConstraint,Et as VerticalPlaneConstraint,jt as VerticalPlaneLikeConstraint,pe as constraintOrSet,ge as isPoint};
|
package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{r as s,q as r,g as o}from"../../../../../chunks/vec32.js";import{
|
|
5
|
+
import{r as s,q as r,g as o}from"../../../../../chunks/vec32.js";import{c,g as n}from"../../../../../chunks/sphere.js";const t=1e3;function e(t,e,a){const m=c(),p=n(m);return s(p,p,t,.5),s(p,p,e,.5),m[3]=r(p,t),o(p,p,a),m}export{e as boundsFromEdge,t as maxCandidateCount};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{floatEqualAbsolute as t}from"../../core/mathUtils.js";import{subtract as n,squaredLength as r,dot as s,scaleAndAdd as e,sub as o,length as c,distance as i,squaredDistance as u,lerp as a,set as f}from"../../core/libs/gl-matrix-2/math/vec2.js";import{create as p,fromValues as m,ZEROS as L}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as h,z as A,k as d,r as l,q as E,b as N,
|
|
5
|
+
import{floatEqualAbsolute as t}from"../../core/mathUtils.js";import{subtract as n,squaredLength as r,dot as s,scaleAndAdd as e,sub as o,length as c,distance as i,squaredDistance as u,lerp as a,set as f}from"../../core/libs/gl-matrix-2/math/vec2.js";import{create as p,fromValues as m,ZEROS as L}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as h,z as A,k as d,r as l,q as E,b as N,H as y,c as P,f as b,x as j}from"../../chunks/vec32.js";import{create as M,clone as I}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getEpsilon as x}from"../../core/libs/gl-matrix-2/math/common.js";import{create as R,fromPositionAndNormal as Y,distance as g,intersectLine as q,isPointInside as v}from"../../geometry/support/plane.js";import{tangentFrame as H}from"../3d/support/mathUtils.js";import{LineType as F,intersectLineLikeAndCircle as _}from"./geometry2dUtils.js";function k({start:t,end:o,type:c},i,u){const a=[],f=n(et,o,t),m=n(ot,t,i),L=r(f),h=2*s(f,m),A=h*h-4*L*(r(m)-u*u);if(0===A){const n=-h/(2*L);(c===rt.PLANE||n>=0)&&a.push(e(p(),t,f,n))}else if(A>0){const n=Math.sqrt(A),r=(-h+n)/(2*L);(c===rt.PLANE||r>=0)&&a.push(e(p(),t,f,r));const s=(-h-n)/(2*L);(c===rt.PLANE||s>=0)&&a.push(e(p(),t,f,s))}return a}function U(t,r){const e=t.start,c=t.end,i=n(et,c,e),u=h(it,-i[1],i[0],0),a=r.start,f=r.end,p=A(ut,f,a),m=d(p,u),L=h(at,e[0],e[1],0),E=A(ft,L,a),N=d(E,u),y=x();if(Math.abs(m)<y)return Math.abs(N),[];const P=l(pt,a,p,N/m);if(r.type===F.RAY){const t=A(mt,P,a);if(d(t,p)<-y)return[]}if(t.type===rt.HALF_PLANE){const t=o(ot,P,e);if(s(t,i)<-y)return[]}return[I(P)]}function w(t,n){return T(X(ht,n[2],t),n)}function z(t,n){const r=0;return S(X(ht,r,t),X(At,r,n)).map((([t,n])=>m(t,n)))}function C(t,n){return J(t,X(ht,t[2],n))}function B(t,n){return K(X(ht,t[2],n),t)}function D(t,r,s){const o=n(et,t,r),i=c(o),u=0===i?1:s/i,a=M();return e(a,r,o,u),a[2]=t[2],a}function G(t,n,r){return i(t,n)-r}function J(t,{start:n,end:r,type:s},e=M()){const o=A(ct,t,n),c=A(it,r,n),i=d(o,c)/d(c,c);return l(e,n,c,s===F.RAY?Math.max(i,0):i)}function K({start:t,end:n,type:r},s){const e=A(ct,s,t),o=A(it,n,t);if(r===F.RAY&&d(o,e)<-x())return E(t,s);const c=N(ut,o,e);return y(c)/y(o)}const O=(()=>{const t=M(),n=M(),r=M();return({start:s,end:e},{center:o,radius:c,normal:i,slicePlane:u})=>{const a=Y(o,i,Lt);if($(g(a,s),0)&&$(g(a,e),0)){H(i,t,n);const a=(s,e)=>(b(r,e,o),f(s,d(r,t),d(r,n)),s),p=_({start:a(et,s),end:a(ot,e),type:F.LINE},L,c),m=[];for(const[r,s]of p){const e=P(M(),o);l(e,e,t,r),l(e,e,n,s),u&&!nt(u,e)||m.push(e)}return m}const p=M();return q(a,s,e,p)?!$(E(p,o),c)||u&&!nt(u,p)?[]:[p]:[]}})();function Q({start:t,end:e,type:o},c,i){const u=[],a=b(ct,e,t),f=n(ot,t,c),p=r(a),m=2*s(a,f),L=m*m-4*p*(r(f)-i*i);if(0===L){const n=-m/(2*p);(o===F.LINE||n>=0)&&u.push(l(M(),t,a,n))}else if(L>0){const n=Math.sqrt(L),r=(-m+n)/(2*p);(o===F.LINE||r>=0)&&u.push(l(M(),t,a,r));const s=(-m-n)/(2*p);(o===F.LINE||s>=0)&&u.push(l(M(),t,a,s))}return u}function S(t,n){const r=t.start,s=t.end,e=n.start,o=n.end,c=A(ct,s,r),i=A(it,o,e),u=A(ut,e,r),a=N(at,c,i);if(!$(d(u,a),0))return[];const f=j(a);if($(f,0))return[];const p=N(ft,u,i),m=d(p,a)/f,L=l(pt,r,c,m);if(t.type===F.RAY){const t=A(mt,L,r);if(d(c,t)<-x())return[]}if(n.type===F.RAY){const t=A(mt,L,e);if(d(i,t)<-x())return[]}return[I(L)]}function T({start:t,end:n,type:r},s){const e=A(ct,s,t),o=A(it,n,t),c=N(ut,o,e),i=j(c)/j(o),u=x();if(i<u)switch(r){case F.LINE:return[I(s)];case F.RAY:return d(o,e)<-u?[]:[I(s)]}return[]}function V(t,n,r){return $(u(r,t),n*n)?[I(r)]:[]}function W(t,n,r,s){const[e,o]=t,[c,i]=r,u=c-e,f=i-o,p=u*u+f*f,L=Math.sqrt(p);if(L>n+s)return[];if(L<Math.abs(n-s))return[];if($(L,0)&&$(n,s))return[];const h=(n*n-s*s+p)/(2*L),A=Math.sqrt(n*n-h*h),d=A*f/L,l=A*u/L,[E,N]=a(et,t,r,h/L);return $(d,l)?[m(E,N)]:[m(E+d,N-l),m(E-d,N+l)]}function X(t,n,{start:r,end:s,type:e}){return h(t.start,r[0],r[1],n),h(t.end,s[0],s[1],n),t.type=st[e],t}function Z(t,n){return $(t[2],n[2])}function $(n,r){return t(Math.abs(n-r),0,x())}function tt(t,n){return n.filter((n=>nt(t,n)))}function nt(t,n){return v(t,n)}var rt;!function(t){t[t.PLANE=0]="PLANE",t[t.HALF_PLANE=1]="HALF_PLANE"}(rt||(rt={}));const st={[rt.PLANE]:F.LINE,[rt.HALF_PLANE]:F.RAY},et=p(),ot=p(),ct=M(),it=M(),ut=M(),at=M(),ft=M(),pt=M(),mt=M(),Lt=R(),ht={start:M(),end:M(),type:F.LINE},At={start:M(),end:M(),type:F.LINE};export{F as LineType,rt as VerticalPlaneType,T as intersectLineAndPoint,O as intersectLineLikeAndCircle,Q as intersectLineLikeAndVerticalCylinder,S as intersectLineLikes,V as intersectVerticalCylinderAndPoint,W as intersectVerticalCylinders,U as intersectVerticalPlaneAndLineLike,w as intersectVerticalPlaneAndPoint,k as intersectVerticalPlaneAndVerticalCylinder,z as intersectVerticalPlanes,$ as isClose,nt as isPointInsidePlane,K as pointToLineLikeDistance,G as pointToVerticalCylinderDistance,B as pointToVerticalPlaneDistance,tt as pointsInsidePlane,J as projectPointToLineLike,D as projectPointToVerticalCylinder,C as projectPointToVerticalPlane,Z as vectorsHaveCloseZ};
|