@ndmspc/ndmvr-core 1.1.0-rc.7 → 1.1.0-rc.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/dist/index.es.js +2 -2
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1417,9 +1417,9 @@ class ue {
|
|
|
1417
1417
|
* */
|
|
1418
1418
|
getChildByPosition(e, t, A = this.origin) {
|
|
1419
1419
|
var i;
|
|
1420
|
-
if (!e || e.length === 0) return A;
|
|
1420
|
+
if (!e || e.length === 0) return { ...A };
|
|
1421
1421
|
const s = e.splice(0, 1)[0];
|
|
1422
|
-
return A != null && A.children ? (i = A.children) != null && i.content ? this.getChildByPosition(e, t, A.children.content[s]) : Object.keys(A.children).includes(t) ? this.getChildByPosition(e, t, A.children[t][s]) : (console.error("Bad set or index specified."), null) : A;
|
|
1422
|
+
return A != null && A.children ? (i = A.children) != null && i.content ? this.getChildByPosition(e, t, A.children.content[s]) : Object.keys(A.children).includes(t) ? this.getChildByPosition(e, t, A.children[t][s]) : (console.error("Bad set or index specified."), null) : { ...A };
|
|
1423
1423
|
}
|
|
1424
1424
|
/**
|
|
1425
1425
|
* sets origin of pointer to one of parent nodes.
|
package/dist/index.umd.js
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
<div class="regionUI baseColor" style="bottom: 10px; right: 10px;">
|
|
34
34
|
</div>
|
|
35
35
|
</div>
|
|
36
|
-
`}}Bt=new WeakMap,wt=new WeakMap,ft=new WeakMap,et=new WeakMap;const Pe=async o=>{let e;o.startsWith("root://")?e=o.replace(/^root:\/\//,"https://").replace(/\/\//g,"/"):e=o,console.log(`Fetching from URL: ${e}`);const t=await fetch(e);if(!t.ok)throw new Error(`Response status: ${t.status}`);return t.json()};class He{constructor(e,t){m(this,"raycaster");m(this,"mouse");m(this,"cameraElement");m(this,"sceneElement");m(this,"singleClickTimer");m(this,"dbClickTimeout");m(this,"configSub");m(this,"rendererElement");m(this,"raycastOn");this.singleClickTimer=null,this.dbClickTimeout=190,this.raycastOn=!0,this.rendererElement=t,this.raycaster=new g.Raycaster,this.mouse=new g.Vector2,this.sceneElement=e,this.checkInterval=1,this.lastCheck=void 0,e.traverse(A=>{A.isCamera&&(this.cameraElement=A)}),this.mousemoveEventHandle=this.mousemoveEventHandle.bind(this),this.clickEventHandle=this.clickEventHandle.bind(this),this.setupRaycasting(),this.configSub=nt().getObservable().subscribe(A=>{this.dbClickTimeout=A.config.environment.dbClickTimeout??190})}setupRaycasting(){window.addEventListener("mousemove",this.mousemoveEventHandle),window.addEventListener("click",this.clickEventHandle)}destroyRaycasting(){window.removeEventListener("mousemove",this.mousemoveEventHandle),window.removeEventListener("click",this.clickEventHandle)}toggleRaycasting(){this.raycastOn=!this.raycastOn,this.raycastOn?this.setupRaycasting():this.destroyRaycasting()}mousemoveEventHandle(e){const t=performance.now();t-this.lastCheck<this.checkInterval||(this.lastCheck=t,this.updateRaycaster(e))}clickEventHandle(e){const t=this.rendererElement.getBoundingClientRect();this.mouse.x=(e.clientX-t.left)/t.width*2-1,this.mouse.y=-((e.clientY-t.top)/t.height)*2+1,this.raycaster.setFromCamera(this.mouse,this.cameraElement);const A=Date.now(),i=(this.lastClick?A-this.lastClick:1/0)<this.dbClickTimeout;this.singleClickTimer&&(clearTimeout(this.singleClickTimer),this.singleClickTimer=null),i?(this.raycaster._triggerSource=e.shiftKey?"shiftmousedbclick":"mousedbclick",this.handleRaycast()):this.singleClickTimer=setTimeout(()=>{this.raycaster._triggerSource=e.shiftKey?"shiftmouseclick":"mouseclick",this.handleRaycast(),this.singleClickTimer=null},this.dbClickTimeout),this.lastClick=A}handleRaycast(){this.raycaster.intersectObjects(this.sceneElement.children,!0).length>0}updateRaycaster(e){const t=this.rendererElement.getBoundingClientRect();this.mouse.x=(e.clientX-t.left)/t.width*2-1,this.mouse.y=-((e.clientY-t.top)/t.height)*2+1,this.raycaster.setFromCamera(this.mouse,this.cameraElement),this.raycaster._triggerSource="mousemove",this.raycaster.intersectObjects(this.sceneElement.children,!0)}}class $t{constructor(e){this.limits=new Int32Array(e),this.values=new Int32Array(e.length)}increment(){for(let e=0;e<this.values.length;e++){if(this.values[e]++,this.values[e]<this.limits[e])return!0;this.values[e]=0}return!1}getIndex(){let e=0,t=1;for(let A=0;A<this.values.length;A++)e+=this.values[A]*t,t*=this.limits[A];return e}setFromNumber(e){for(let t=0;t<this.limits.length;t++)this.values[t]=Math.floor(e%this.limits[t]),e=Math.floor(e/this.limits[t])}getValueAt(e){return this.values[e]}getValues(){return[...this.values]}reset(){this.values.fill(0)}}function Fe(o,e){return e<=0?o.fXmin:e>o.fNbins?o.fXmax:o.GetBinLowEdge(e+1)}function Xt(o,e,t,A,s,i,n){const c=e+1,a=o.GetBinLowEdge(c),r=Fe(o,c),l=Math.abs(r-a);if(n.size=l,n.pos=a+l*.5-o.fXmin,t){const u=(o.fXmax-o.fXmin)*o.fNbins/(t*o.fNbins);n.pos/=u,n.size/=u,n.size*=1-A,n.pos-=t*.5,n.pos+=s}}function We(o,e,t,A,s,i,n){Xt(o.fXaxis,e.x,t==null?void 0:t.x,A==null?void 0:A.x,s==null?void 0:s.x,i,n.x),Xt(o.fYaxis,e.y,t==null?void 0:t.z,A==null?void 0:A.y,s==null?void 0:s.z,i,n.y),Xt(o.fZaxis,e.z,t==null?void 0:t.y,A==null?void 0:A.z,s==null?void 0:s.y,i,n.z)}function Xe(o){const e=o.y.size,t=o.y.pos;return o.y.size=o.z.size,o.y.pos=o.z.pos,o.z.size=e,o.z.pos=t,o}function Ve(o,e,t,A,s,i,n){return We(o,e,A,t,s,i,n),n}function Je(o,e,t){return t.z.pos=2*o-t.z.pos,t}function _t(o,e){if(o.length!==e.length)return!1;const t={};for(const A of o)t[A]=(t[A]||0)+1;for(const A of e){if(!t[A])return!1;t[A]--}return!0}function Le(o,e){if(!Array.isArray(o)||!Array.isArray(e)||o.length!==e.length)return!1;for(let t=0;t<o.length;t++){const A=Object.keys(o[t]),s=Object.keys(e[t]);if(A.length!==s.length)return!1;for(const i of A){if(!e[t].hasOwnProperty(i))return!1;const n=o[t][i],c=e[t][i];if(typeof n!=typeof c)return!1;if(typeof n=="object"){if(!n||!c){if(n!==c)return!1;continue}const a=Object.keys(n),r=Object.keys(c);if(a.length!==r.length)return!1;for(const l of a)if(!c.hasOwnProperty(l)||n[l]!==c[l])return!1}else if(n!==c)return!1}}return!0}function Vt(o,e,t,A){let s=Array(o.length).fill(0);const i=(n,c,a)=>{const r=c.fXaxis.fNbins,l=c.fYaxis.fNbins;c.fZaxis.fNbins;const u=t.slice(-t.length+n+1).reduce((f,d)=>f*d,1);if(s[a]+=(o[n].x+o[n].y*r+o[n].z*r*l)*u,n+1<o.length){let f;c.children.content?f=c.children.content[c.getBin(o[n].x+1,o[n].y+1,o[n].z+1)]:f=c.children[A[0]][c.getBin(o[n].x+1,o[n].y+1,o[n].z+1)],a>n&&i(n+1,f,a)}};for(let n=0;n<o.length;n++)i(0,e,n);return s}function dt(o,e,t){var s,i;let A=Array(o.length).fill(0);for(let n=0;n<o.length;n++)if(A[n]=e.getBin(o[n].x+1,o[n].y+1,o[n].z+1),e.children)(s=e.children)!=null&&s.content?e=e.children.content[A[n]]:e=(i=e.children[t[0]])==null?void 0:i[A[n]];else return A;return A}function mt(o,e,t,A,s,i=0){var r,l,h,u;const n=["x","y","z"],c=Number.parseInt(t._typename.substring(2,3),10);let a={};if(o[0]){for(let f=0;f<c;f++){const d=n[f],C=t[`f${d.toUpperCase()}axis`],p=o[0][d];a[d]={min:C.GetBinLowEdge(p+1),max:C.GetBinCenter(p+1)*2-C.GetBinLowEdge(p+1),name:C.fName,title:C.fTitle,label:(l=(r=C.fLabels)==null?void 0:r.arr[p])==null?void 0:l.fString}}a={...a,color:A.getColorAt(i,e),name:t.fName}}if(o[1]){let f;return(h=t.children)!=null&&h.content?f=t.children.content[t.getBin(o[0].x+1,o[0].y+1,o[0].z+1)]:(u=t.children)!=null&&u[s[0]]&&(f=t.children[s[0]][t.getBin(o[0].x+1,o[0].y+1,o[0].z+1)]),[a,...mt(o.slice(1),e,f,A,s,i+1)]}else return[a]}function ke(o,e,t,A){let s=0;const i=t.slice(1),n=[];for(let a=0;a<i.length;a++){const r=i.slice(a).reduce((l,h)=>l*h,1);n.push(r)}const c=(a,r)=>{const{fNbins:l}=r.fXaxis,{fNbins:h}=r.fYaxis,{fNbins:u}=r.fZaxis,f=o[a].x+o[a].y*l+o[a].z*l*h;if(s+=f*n[a],a+1<o.length){const d=Ze(r,o[a],A);c(a+1,d)}};return c(0,e),s}function Ze(o,e,t){const A=o.getBin(e.x+1,e.y+1,e.z+1);return o.children.content?o.children.content[A]:o.children[t[0]][A]}function Jt(o,e,t){const A=e.splice(0,1)[0];return e.length>0?Jt(o.children.content[A],e,t):o.children.content?o.children.content[A]:o.children[t][A]}function qe(o){if(!o)return;const e=s=>{let i=-1/0;for(let n=0;n<s.length;n++){const c=s[n];c>i&&(i=c)}return i},t=[];t[0]={content:e(o.fArray)},o.fArrays&&Object.keys(o==null?void 0:o.fArrays).forEach(s=>{t[0]={...t[0],[s]:e(o.fArrays[s].values)}});const A=(s,i=1)=>{t[i]||(t[i]={}),Object.entries(s).forEach(([n,c])=>{c.forEach(a=>{if(!a)return;const r=e(a.fArray);(!(n in t[i])||r>t[i][n])&&(t[i][n]=r),a.fArrays&&Object.keys(a.fArrays).forEach(l=>{const h=a.fArrays[l].max;(!(l in t[i])||h>t[i][l])&&(t[i][l]=h),t[i][l]=Math.max(t[i][l],e(a.fArrays[l].values))}),a.children&&A(a.children,i+1)})})};return o.children&&A(o.children),t}function Re(o,e){if(!o)return;const t=i=>{let n=0;for(let c=0;c<i.length;c++){const a=i[c];a>n&&(n=a)}return n},A=[];A[0]={content:t(o.fSumw2)},o.fArrays&&Object.keys(o==null?void 0:o.fArrays).forEach(i=>{o.fArrays[i].errors&&(A[0]={...A[0],[i]:t(o.fArrays[i].errors)})});const s=(i,n=1)=>{A[n]||(A[n]={}),Object.entries(i).forEach(([c,a])=>{a.forEach(r=>{if(!r)return;const l=t(r.fSumw2),h=isNaN(l)?0:l;(!(c in A[n])||h>A[n][c])&&(A[n][c]=h),r.fArrays&&Object.keys(r.fArrays).forEach(u=>{r.fArrays[u].errors&&((!(u in A[n])||h>A[n][u])&&(A[n][u]=h),A[n][u]=Math.max(A[n][u],t(r.fArrays[u].errors)))}),r.children&&s(r.children,n+1)})})};o.children&&s(o.children);for(let i=0;i<A.length;i++)Object.keys(A[i]).forEach(n=>{A[i][n]===0&&(A[i][n]=Math.sqrt(e[i][n]))});return A}function Ke(o,e){if(!o)return;const t=i=>{let n=1/0;for(let c=0;c<i.length;c++){const a=i[c];a<n&&(n=a)}return n},A=[];A[0]={content:t(o.fSumw2)},o.fArrays&&Object.keys(o==null?void 0:o.fArrays).forEach(i=>{o.fArrays[i].errors&&(A[0]={...A[0],[i]:t(o.fArrays[i].errors)})});const s=(i,n=1)=>{A[n]||(A[n]={}),Object.entries(i).forEach(([c,a])=>{a.forEach(r=>{if(!r)return;const l=t(r.fSumw2),h=isNaN(l)?0:l;(!(c in A[n])||h<A[n][c])&&(A[n][c]=h),r.fArrays&&Object.keys(r.fArrays).forEach(u=>{r.fArrays[u].errors&&((!(u in A[n])||h<A[n][u])&&(A[n][u]=h),A[n][u]=Math.min(A[n][u],t(r.fArrays[u].errors.filter(f=>f>0))))}),r.children&&s(r.children,n+1)})})};o.children&&s(o.children);for(let i=0;i<A.length;i++)Object.keys(A[i]).forEach(n=>{(A[i][n]===0||A[i][n]===1/0)&&(A[i][n]=Math.sqrt(e[i][n]))});return A}function $e(o){if(!o)return;const e=s=>{let i=1/0;for(let n=0;n<s.length;n++){const c=s[n];c<i&&(i=c)}return i},t=[];t[0]={content:e(o.fArray.filter(s=>s!==0))},o.fArrays&&Object.keys(o==null?void 0:o.fArrays).forEach(s=>{t[0]={...t[0],[s]:e(o.fArrays[s].values.filter(i=>i!==0))}});const A=(s,i=1)=>{t[i]||(t[i]={}),Object.entries(s).forEach(([n,c])=>{c.forEach(a=>{if(!a)return;const r=e(a.fArray.filter(l=>l!==0));(!(n in t[i])||r<t[i][n])&&(t[i][n]=r),a.fArrays&&Object.keys(a.fArrays).forEach(l=>{(!(l in t[i])||r>t[i][l])&&(t[i][l]=r),t[i][l]=Math.min(t[i][l],e(a.fArrays[l].values.filter(h=>h!==0)))}),a.children&&A(a.children,i+1)})})};return o.children&&A(o.children),t}function _e(o){if(!o)return;const e=o.fXaxis.fNbins*o.fYaxis.fNbins*o.fZaxis.fNbins;let t=[];t.push(e);const A=(s,i=1)=>{let n=0;return i>=t.length&&t.push(1),Object.entries(s).forEach((c,a)=>{c[1].forEach(r=>{r&&(n=r.fXaxis.fNbins*r.fYaxis.fNbins*r.fZaxis.fNbins,n>t[i]&&(t[i]=n),r.children&&A(r.children,i+1))})}),t};return o.children&&A(o.children),t.push(1),t}function tA(o,e,t){new g.Color(o.color.default.min).toArray(t,0),new g.Color(o.color.default.max).toArray(t,3);let A=1;o.color.layer.forEach(s=>{const i=A*6;new g.Color(s.min).toArray(t,i),new g.Color(s.max).toArray(t,i+3),A++}),o.color.set.forEach(s=>{const i=A*6;new g.Color(s.min).toArray(t,i),new g.Color(s.max).toArray(t,i+3),A++}),e.uniforms.colorPairs={value:t},e.uniformsNeedUpdate=!0}function te(o,e,t,A,s,i){const c=((r,l,h)=>{let u=(r-l)/(h-l);return u>1&&(u=1),isNaN(u)||u===1/0?0:u})(e,t,A);let a=0;return o.set[s]?a=1+o.layer.length+s:o.layer[i]&&(a=1+i),a+c}function ee(o,e,t,A,s,i,n){if(!(1/o===-1/0||o<0))return n[0]=e[o],n[1]=e[o+1],n[2]=e[o+2],n[3]=t[o],n[4]=t[o+1],n[5]=t[o+2],n;const a=Math.abs(o),r=i!==null?A[s][i]:A[s];return n[0]=r.pos[a],n[1]=r.pos[a+1],n[2]=r.pos[a+2],n[3]=r.scale[a],n[4]=r.scale[a+1],n[5]=r.scale[a+2],n}const eA=o=>{if(!o)return!1;for(const e in o)if(e!=="content"&&Object.prototype.hasOwnProperty.call(o,e)&&o[e]&&typeof o[e]=="object"&&Object.keys(o[e]).length>0)return!0;return!1};function Mt(o,e,t,A,s,i,n){const c=e.fXaxis.fNbins,a=e.fYaxis.fNbins,r=e.fZaxis.fNbins;let l=0,h=0;const u=new Float32Array((c*a*r-1)*3),f=new Float32Array((c*a*r-1)*3),d=new Float32Array(c*a*r-1),C=new Float32Array(c*a*r-1),p=new Float32Array(c*a*r-1),w=new Float32Array(6),y=new Float32Array(6),b=x=>{const T=I*3;u[T]=x[0],u[T+1]=x[1],u[T+2]=x[2],f[T]=x[3],f[T+1]=x[4],f[T+2]=x[5],d[I]=x[6],C[I]=x[7],p[I]=x[8]},v=(x,T,z,O)=>{ee(x,u,f,o,z,O,w),ee(T,u,f,o,z,O,y);const N=w[0]-w[3]*.5<y[0]-y[3]*.5?w[0]-w[3]*.5:y[0]-y[3]*.5,D=w[1]-w[4]*.5<y[1]-y[4]*.5?w[1]-w[4]*.5:y[1]-y[4]*.5,J=w[2]-w[5]*.5<y[2]-y[5]*.5?w[2]-w[5]*.5:y[2]-y[5]*.5,H=w[0]+w[3]*.5>y[0]+y[3]*.5?w[0]+w[3]*.5:y[0]+y[3]*.5,k=w[1]+w[4]*.5>y[1]+y[4]*.5?w[1]+w[4]*.5:y[1]+y[4]*.5,X=w[2]+w[5]*.5>y[2]+y[5]*.5?w[2]+w[5]*.5:y[2]+y[5]*.5,F=new Float32Array(9);return F[0]=(N+H)*.5,F[1]=(D+k)*.5,F[2]=(J+X)*.5,F[3]=H-N,F[4]=k-D,F[5]=X-J,F};let I=0;for(let x=0;x<a;x++){for(let z=0;z<r;z++){const O=l+n;let N=new Array(c);for(let D=0;D<c;D++)N[D]=-D-O;for(;N.length>1;){let D=0;const J=Math.floor(N.length/2);for(let H=0;H<J;H++){const k=N[D],X=N[D+1],F=v(k*3,X*3,t,A);N.splice(D,2,I),Lt(F,i),F[6]=1/k===-1/0||k<0?k:p[k],F[7]=1/X===-1/0||X<0?X:p[X],F[8]=h,b(F),I+=1,h+=1,D+=1}}l+=c}const T=new Array(r);for(let z=0;z<r;z++)T[z]=I-1-(r-1-z)*(c-1);for(;T.length>1;){let z=0;const O=Math.floor(T.length/2);for(let N=0;N<O;N++){const D=T[z],J=T[z+1],H=v(D*3,J*3,t,A);T.splice(z,2,I),Lt(H,i),H[6]=p[D],H[7]=p[J],H[8]=h,b(H),I+=1,h+=1,z+=1}}}const M=new Array(a);for(let x=0;x<a;x++)M[x]=I-1-(a-1-x)*(c*r-1);for(;M.length>1;){let x=0;const T=Math.floor(M.length/2);for(let z=0;z<T;z++){const O=M[x],N=M[x+1],D=v(O*3,N*3,t,A);M.splice(x,2,I),Lt(D,i),D[6]=p[O],D[7]=p[N],D[8]=h,b(D),I+=1,h+=1,x+=1}}return{pos:u,scale:f,left:d,right:C}}function AA(o,e,t,A,s,i,n,c){const a=new Array(o.length).fill().map(l=>[]);a[a.length-1]=Array.from({length:i.length},()=>[]),s===null?a[0]=[Mt(o,e,t,null,i,n,0)]:(a[0]=new Array(i.length),A.forEach(l=>a[0][i.indexOf(l)]=Mt(o,e,t,i.indexOf(l),i,n,0)));const r=(l,h,u)=>{var w;if(!l.children)return;const f=new $t([l.fXaxis.fNbins,l.fYaxis.fNbins,l.fZaxis.fNbins]),d=l.fXaxis.fNbins*l.fYaxis.fNbins*l.fZaxis.fNbins,C=c.slice(1,h-1).reduce((y,b)=>y*b,c[1]),p=c[h];for(let y=0;y<d;y++){const b={x:f.getValueAt(0),y:f.getValueAt(1),z:f.getValueAt(2)};if((w=l==null?void 0:l.children)!=null&&w.content){const v=l.children.content[l.getBin(b.x+1,b.y+1,b.z+1)];if(!v){if(f.increment()===!1)break;continue}a[h][y+u]=Mt(o,v,h,null,i,n,(y+u)*p),r(v,h+1,(f.getIndex()+u)*C)}else eA(l.children)&&A.forEach(v=>{const I=i.indexOf(v),M=(y+u)*p;let x=!1;for(let z=M;z<M+c[h];z++)if(o[h][I].rendered[z]!==-1){x=!0;break}if(!x){a[h][I].push(null);return}const T=l.children[v][l.getBin(b.x+1,b.z+1,b.y+1)];T&&(a[h][I][y+u]=Mt(o,T,h,I,i,n,(y+u)*p),r(T,h+1,(f.getIndex()+u)*C))});if(f.increment()===!1)break}};return r(e,1,0),a}function Lt(o,e){const t=e.elements,A=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),s=Math.sqrt(t[4]*t[4]+t[5]*t[5]+t[6]*t[6]),i=Math.sqrt(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]);o[0]=o[0]*A+t[12],o[1]=o[1]*s+t[13],o[2]=o[2]*i+t[14],o[3]=o[3]*A,o[4]=o[4]*s,o[5]=o[5]*i}class kt{constructor(e){m(this,"rootObj");m(this,"origin");m(this,"parentPath",[]);m(this,"path");m(this,"title");m(this,"range",[]);m(this,"isOnSet",null);m(this,"isHistogramFilled",!0);this.rootObj=e,this.origin=this.rootObj,this.title=this.origin.fTitle,this.path=this.origin.fName}setOriginToChild(e,t,A){var i,n;if(!e)return;const s=e.splice(0,1);if((i=this.origin)!=null&&i.children){if((n=this.origin.children)!=null&&n.content)this.parentPath.push({origin:this.origin,range:A.splice(0,1),bin:s}),this.origin=this.origin.children.content[s],this.isOnSet=null;else if(Object.keys(this.origin.children).includes(t)){if(this.parentPath.push({origin:this.origin,range:A.splice(0,1),bin:s}),!this.origin.children[t][s]){this.isHistogramFilled=!1,this.path=this.path+"/empty",this.origin=null;return}this.origin=this.origin.children[t][s],this.isOnSet=t}else{console.error("Bad set or index specified.");return}this.title=this.origin.fTitle,this.path=this.path+"/"+this.origin.fName,e.length>0&&this.setOriginToChild(e,t,A)}}getChildByPosition(e,t,A=this.origin){var i;if(!e||e.length===0)return A;const s=e.splice(0,1)[0];return A!=null&&A.children?(i=A.children)!=null&&i.content?this.getChildByPosition(e,t,A.children.content[s]):Object.keys(A.children).includes(t)?this.getChildByPosition(e,t,A.children[t][s]):(console.error("Bad set or index specified."),null):A}setOriginToParent(e=1){if(e<=0||this.parentPath.length===0)return;const t=this.path.lastIndexOf("/");this.path=this.path.slice(0,t);const A=this.parentPath.pop();A&&(this.origin=A.origin),this.title=this.origin.fTitle,this.setOriginToParent(e-1),this.isOnSet=null,this.isHistogramFilled=!0}}class sA{constructor(e,t,A,s){m(this,"wireframe");m(this,"instGeom");m(this,"material");m(this,"totalInstances");m(this,"maxInstancesPerLayer");m(this,"instancePositions");m(this,"instanceScales");m(this,"instanceColors");m(this,"colorArray");m(this,"configSub");m(this,"stateSub");m(this,"config");m(this,"numOfavailableSets");m(this,"visibility",!0);m(this,"id");this.config=A,this.maxInstancesPerLayer=e,this.id=s;const i=new g.BoxGeometry(1,1,1),n=new g.EdgesGeometry(i);this.instGeom=new g.InstancedBufferGeometry,this.instGeom.instanceCount=0,this.instGeom.frustumCulled=!1,this.instGeom.index=n.index;for(const c in n.attributes)this.instGeom.setAttribute(c,n.attributes[c]);this.material=this.createMaterial(),this.colorArray=new Float32Array(32*3),this.fillColorArray(),this.instancePositions=new Float32Array(3),this.instanceScales=new Float32Array(3),this.instanceColors=new Float32Array(1),this.instGeom.setAttribute("instancePosition",new g.InstancedBufferAttribute(this.instancePositions,3)),this.instGeom.setAttribute("instanceScale",new g.InstancedBufferAttribute(this.instanceScales,3)),this.instGeom.setAttribute("instanceColorIndex",new g.InstancedBufferAttribute(this.instanceColors,1)),this.wireframe=new g.LineSegments(this.instGeom,this.material),this.wireframe.frustumCulled=!1,this.stateSub=q(this.id).getObservable().subscribe(c=>{this.numOfavailableSets=c.sets.length})}pushVisibleInstances(e,t,A){let s=this.wireframe.parent;s&&(s.remove(this.wireframe),this.instGeom.dispose());const i=this.config.display.start??0,n=this.config.display.end??e.length-1,c=[];let a=e.length-1;{const v=(Array.isArray(e[a])?e[a][A]:e[a]).rendered,I=new Uint8Array(v.length);for(let M=0;M<v.length;M++)I[M]=v[M]!==-1?1:0;c[a]=I}for(let b=a-1;b>=0;b--){const I=(Array.isArray(e[b])?e[b][A]:e[b]).rendered,M=c[b+1],x=t[b+1]||0,T=new Uint8Array(I.length);for(let z=0;z<I.length;z++){if(I[z]!==-1){T[z]=1;continue}const O=z*x,N=O+x;for(let D=O;D<N;D++)if(M[D]){T[z]=1;break}}c[b]=T}const r=(b,v)=>b<i||b>n?!1:c[b][v]===1,l=(b,v)=>{let I=0,M=b,x=v;for(;M+1<e.length;){M++,x*=t[M];const T=e[M],z=Array.isArray(T)?T[A===-1?0:A]:T;for(let O=x;O<x+t[M];O++)if(z.rendered[O]!==-1){I=M-b;break}}return I};let h=0;for(let b=0;b<e.length;b++){const v=e[b];if(!Array.isArray(v))for(let I=0;I<v.rendered.length;I++)r(b,I)&&h++}const u=new Float32Array(h*3),f=new Float32Array(h*3),d=new Float32Array(h);let C=0;for(let b=0;b<e.length;b++){const v=e[b],I=this.getColorIndex(b,A);if(!Array.isArray(v)){for(let M=0;M<v.rendered.length;M++)if(r(b,M)){const x=l(b,M)*.05;u[C*3]=v.pos[M*3],u[C*3+1]=v.pos[M*3+1],u[C*3+2]=v.pos[M*3+2],f[C*3]=v.scale[M*3]+x,f[C*3+1]=v.scale[M*3+1]+x,f[C*3+2]=v.scale[M*3+2]+x,d[C++]=I}}}const p=new g.BoxGeometry(1,1,1),w=new g.EdgesGeometry(p);this.instGeom=new g.InstancedBufferGeometry,this.instGeom.instanceCount=h,this.instGeom.frustumCulled=!1,this.instGeom.index=w.index;const y=w.attributes;for(const b in y)this.instGeom.setAttribute(b,y[b]);this.instancePositions=u,this.instanceScales=f,this.instanceColors=d,this.instGeom.setAttribute("instancePosition",new g.InstancedBufferAttribute(u,3)),this.instGeom.setAttribute("instanceScale",new g.InstancedBufferAttribute(f,3)),this.instGeom.setAttribute("instanceColorIndex",new g.InstancedBufferAttribute(d,1)),this.wireframe=new g.LineSegments(this.instGeom,this.material),this.wireframe.frustumCulled=!1,s&&s.add(this.wireframe)}toggleVisibility(e,t,A){this.visibility=!this.visibility,this.visibility?this.pushVisibleInstances(e,t,A):this.clearWireframe()}dispose(){this.instancePositions=[],this.instanceScales=[],this.wireframe.parent.remove(this.wireframe),this.instGeom.dispose()}clearWireframe(){this.instancePositions=new Float32Array(3),this.instanceScales=new Float32Array(3),this.instanceColors=new Float32Array(1),this.instGeom.dispose(),this.instGeom.instanceCount=0}fillColorArray(){new g.Color(this.config.color.default).toArray(this.colorArray,0);let e=1;this.config.color.layer.map(t=>new g.Color(t)).forEach(t=>{const A=e*3;t.toArray(this.colorArray,A),e++}),this.config.color.set.map(t=>new g.Color(t)).forEach(t=>{const A=e*3;t.toArray(this.colorArray,A),e++}),this.material.uniforms.colorArray={value:this.colorArray},this.material.uniformsNeedUpdate=!0}createMaterial(){return new g.ShaderMaterial({vertexShader:`
|
|
36
|
+
`}}Bt=new WeakMap,wt=new WeakMap,ft=new WeakMap,et=new WeakMap;const Pe=async o=>{let e;o.startsWith("root://")?e=o.replace(/^root:\/\//,"https://").replace(/\/\//g,"/"):e=o,console.log(`Fetching from URL: ${e}`);const t=await fetch(e);if(!t.ok)throw new Error(`Response status: ${t.status}`);return t.json()};class He{constructor(e,t){m(this,"raycaster");m(this,"mouse");m(this,"cameraElement");m(this,"sceneElement");m(this,"singleClickTimer");m(this,"dbClickTimeout");m(this,"configSub");m(this,"rendererElement");m(this,"raycastOn");this.singleClickTimer=null,this.dbClickTimeout=190,this.raycastOn=!0,this.rendererElement=t,this.raycaster=new g.Raycaster,this.mouse=new g.Vector2,this.sceneElement=e,this.checkInterval=1,this.lastCheck=void 0,e.traverse(A=>{A.isCamera&&(this.cameraElement=A)}),this.mousemoveEventHandle=this.mousemoveEventHandle.bind(this),this.clickEventHandle=this.clickEventHandle.bind(this),this.setupRaycasting(),this.configSub=nt().getObservable().subscribe(A=>{this.dbClickTimeout=A.config.environment.dbClickTimeout??190})}setupRaycasting(){window.addEventListener("mousemove",this.mousemoveEventHandle),window.addEventListener("click",this.clickEventHandle)}destroyRaycasting(){window.removeEventListener("mousemove",this.mousemoveEventHandle),window.removeEventListener("click",this.clickEventHandle)}toggleRaycasting(){this.raycastOn=!this.raycastOn,this.raycastOn?this.setupRaycasting():this.destroyRaycasting()}mousemoveEventHandle(e){const t=performance.now();t-this.lastCheck<this.checkInterval||(this.lastCheck=t,this.updateRaycaster(e))}clickEventHandle(e){const t=this.rendererElement.getBoundingClientRect();this.mouse.x=(e.clientX-t.left)/t.width*2-1,this.mouse.y=-((e.clientY-t.top)/t.height)*2+1,this.raycaster.setFromCamera(this.mouse,this.cameraElement);const A=Date.now(),i=(this.lastClick?A-this.lastClick:1/0)<this.dbClickTimeout;this.singleClickTimer&&(clearTimeout(this.singleClickTimer),this.singleClickTimer=null),i?(this.raycaster._triggerSource=e.shiftKey?"shiftmousedbclick":"mousedbclick",this.handleRaycast()):this.singleClickTimer=setTimeout(()=>{this.raycaster._triggerSource=e.shiftKey?"shiftmouseclick":"mouseclick",this.handleRaycast(),this.singleClickTimer=null},this.dbClickTimeout),this.lastClick=A}handleRaycast(){this.raycaster.intersectObjects(this.sceneElement.children,!0).length>0}updateRaycaster(e){const t=this.rendererElement.getBoundingClientRect();this.mouse.x=(e.clientX-t.left)/t.width*2-1,this.mouse.y=-((e.clientY-t.top)/t.height)*2+1,this.raycaster.setFromCamera(this.mouse,this.cameraElement),this.raycaster._triggerSource="mousemove",this.raycaster.intersectObjects(this.sceneElement.children,!0)}}class $t{constructor(e){this.limits=new Int32Array(e),this.values=new Int32Array(e.length)}increment(){for(let e=0;e<this.values.length;e++){if(this.values[e]++,this.values[e]<this.limits[e])return!0;this.values[e]=0}return!1}getIndex(){let e=0,t=1;for(let A=0;A<this.values.length;A++)e+=this.values[A]*t,t*=this.limits[A];return e}setFromNumber(e){for(let t=0;t<this.limits.length;t++)this.values[t]=Math.floor(e%this.limits[t]),e=Math.floor(e/this.limits[t])}getValueAt(e){return this.values[e]}getValues(){return[...this.values]}reset(){this.values.fill(0)}}function Fe(o,e){return e<=0?o.fXmin:e>o.fNbins?o.fXmax:o.GetBinLowEdge(e+1)}function Xt(o,e,t,A,s,i,n){const c=e+1,a=o.GetBinLowEdge(c),r=Fe(o,c),l=Math.abs(r-a);if(n.size=l,n.pos=a+l*.5-o.fXmin,t){const u=(o.fXmax-o.fXmin)*o.fNbins/(t*o.fNbins);n.pos/=u,n.size/=u,n.size*=1-A,n.pos-=t*.5,n.pos+=s}}function We(o,e,t,A,s,i,n){Xt(o.fXaxis,e.x,t==null?void 0:t.x,A==null?void 0:A.x,s==null?void 0:s.x,i,n.x),Xt(o.fYaxis,e.y,t==null?void 0:t.z,A==null?void 0:A.y,s==null?void 0:s.z,i,n.y),Xt(o.fZaxis,e.z,t==null?void 0:t.y,A==null?void 0:A.z,s==null?void 0:s.y,i,n.z)}function Xe(o){const e=o.y.size,t=o.y.pos;return o.y.size=o.z.size,o.y.pos=o.z.pos,o.z.size=e,o.z.pos=t,o}function Ve(o,e,t,A,s,i,n){return We(o,e,A,t,s,i,n),n}function Je(o,e,t){return t.z.pos=2*o-t.z.pos,t}function _t(o,e){if(o.length!==e.length)return!1;const t={};for(const A of o)t[A]=(t[A]||0)+1;for(const A of e){if(!t[A])return!1;t[A]--}return!0}function Le(o,e){if(!Array.isArray(o)||!Array.isArray(e)||o.length!==e.length)return!1;for(let t=0;t<o.length;t++){const A=Object.keys(o[t]),s=Object.keys(e[t]);if(A.length!==s.length)return!1;for(const i of A){if(!e[t].hasOwnProperty(i))return!1;const n=o[t][i],c=e[t][i];if(typeof n!=typeof c)return!1;if(typeof n=="object"){if(!n||!c){if(n!==c)return!1;continue}const a=Object.keys(n),r=Object.keys(c);if(a.length!==r.length)return!1;for(const l of a)if(!c.hasOwnProperty(l)||n[l]!==c[l])return!1}else if(n!==c)return!1}}return!0}function Vt(o,e,t,A){let s=Array(o.length).fill(0);const i=(n,c,a)=>{const r=c.fXaxis.fNbins,l=c.fYaxis.fNbins;c.fZaxis.fNbins;const u=t.slice(-t.length+n+1).reduce((f,d)=>f*d,1);if(s[a]+=(o[n].x+o[n].y*r+o[n].z*r*l)*u,n+1<o.length){let f;c.children.content?f=c.children.content[c.getBin(o[n].x+1,o[n].y+1,o[n].z+1)]:f=c.children[A[0]][c.getBin(o[n].x+1,o[n].y+1,o[n].z+1)],a>n&&i(n+1,f,a)}};for(let n=0;n<o.length;n++)i(0,e,n);return s}function dt(o,e,t){var s,i;let A=Array(o.length).fill(0);for(let n=0;n<o.length;n++)if(A[n]=e.getBin(o[n].x+1,o[n].y+1,o[n].z+1),e.children)(s=e.children)!=null&&s.content?e=e.children.content[A[n]]:e=(i=e.children[t[0]])==null?void 0:i[A[n]];else return A;return A}function mt(o,e,t,A,s,i=0){var r,l,h,u;const n=["x","y","z"],c=Number.parseInt(t._typename.substring(2,3),10);let a={};if(o[0]){for(let f=0;f<c;f++){const d=n[f],C=t[`f${d.toUpperCase()}axis`],p=o[0][d];a[d]={min:C.GetBinLowEdge(p+1),max:C.GetBinCenter(p+1)*2-C.GetBinLowEdge(p+1),name:C.fName,title:C.fTitle,label:(l=(r=C.fLabels)==null?void 0:r.arr[p])==null?void 0:l.fString}}a={...a,color:A.getColorAt(i,e),name:t.fName}}if(o[1]){let f;return(h=t.children)!=null&&h.content?f=t.children.content[t.getBin(o[0].x+1,o[0].y+1,o[0].z+1)]:(u=t.children)!=null&&u[s[0]]&&(f=t.children[s[0]][t.getBin(o[0].x+1,o[0].y+1,o[0].z+1)]),[a,...mt(o.slice(1),e,f,A,s,i+1)]}else return[a]}function ke(o,e,t,A){let s=0;const i=t.slice(1),n=[];for(let a=0;a<i.length;a++){const r=i.slice(a).reduce((l,h)=>l*h,1);n.push(r)}const c=(a,r)=>{const{fNbins:l}=r.fXaxis,{fNbins:h}=r.fYaxis,{fNbins:u}=r.fZaxis,f=o[a].x+o[a].y*l+o[a].z*l*h;if(s+=f*n[a],a+1<o.length){const d=Ze(r,o[a],A);c(a+1,d)}};return c(0,e),s}function Ze(o,e,t){const A=o.getBin(e.x+1,e.y+1,e.z+1);return o.children.content?o.children.content[A]:o.children[t[0]][A]}function Jt(o,e,t){const A=e.splice(0,1)[0];return e.length>0?Jt(o.children.content[A],e,t):o.children.content?o.children.content[A]:o.children[t][A]}function qe(o){if(!o)return;const e=s=>{let i=-1/0;for(let n=0;n<s.length;n++){const c=s[n];c>i&&(i=c)}return i},t=[];t[0]={content:e(o.fArray)},o.fArrays&&Object.keys(o==null?void 0:o.fArrays).forEach(s=>{t[0]={...t[0],[s]:e(o.fArrays[s].values)}});const A=(s,i=1)=>{t[i]||(t[i]={}),Object.entries(s).forEach(([n,c])=>{c.forEach(a=>{if(!a)return;const r=e(a.fArray);(!(n in t[i])||r>t[i][n])&&(t[i][n]=r),a.fArrays&&Object.keys(a.fArrays).forEach(l=>{const h=a.fArrays[l].max;(!(l in t[i])||h>t[i][l])&&(t[i][l]=h),t[i][l]=Math.max(t[i][l],e(a.fArrays[l].values))}),a.children&&A(a.children,i+1)})})};return o.children&&A(o.children),t}function Re(o,e){if(!o)return;const t=i=>{let n=0;for(let c=0;c<i.length;c++){const a=i[c];a>n&&(n=a)}return n},A=[];A[0]={content:t(o.fSumw2)},o.fArrays&&Object.keys(o==null?void 0:o.fArrays).forEach(i=>{o.fArrays[i].errors&&(A[0]={...A[0],[i]:t(o.fArrays[i].errors)})});const s=(i,n=1)=>{A[n]||(A[n]={}),Object.entries(i).forEach(([c,a])=>{a.forEach(r=>{if(!r)return;const l=t(r.fSumw2),h=isNaN(l)?0:l;(!(c in A[n])||h>A[n][c])&&(A[n][c]=h),r.fArrays&&Object.keys(r.fArrays).forEach(u=>{r.fArrays[u].errors&&((!(u in A[n])||h>A[n][u])&&(A[n][u]=h),A[n][u]=Math.max(A[n][u],t(r.fArrays[u].errors)))}),r.children&&s(r.children,n+1)})})};o.children&&s(o.children);for(let i=0;i<A.length;i++)Object.keys(A[i]).forEach(n=>{A[i][n]===0&&(A[i][n]=Math.sqrt(e[i][n]))});return A}function Ke(o,e){if(!o)return;const t=i=>{let n=1/0;for(let c=0;c<i.length;c++){const a=i[c];a<n&&(n=a)}return n},A=[];A[0]={content:t(o.fSumw2)},o.fArrays&&Object.keys(o==null?void 0:o.fArrays).forEach(i=>{o.fArrays[i].errors&&(A[0]={...A[0],[i]:t(o.fArrays[i].errors)})});const s=(i,n=1)=>{A[n]||(A[n]={}),Object.entries(i).forEach(([c,a])=>{a.forEach(r=>{if(!r)return;const l=t(r.fSumw2),h=isNaN(l)?0:l;(!(c in A[n])||h<A[n][c])&&(A[n][c]=h),r.fArrays&&Object.keys(r.fArrays).forEach(u=>{r.fArrays[u].errors&&((!(u in A[n])||h<A[n][u])&&(A[n][u]=h),A[n][u]=Math.min(A[n][u],t(r.fArrays[u].errors.filter(f=>f>0))))}),r.children&&s(r.children,n+1)})})};o.children&&s(o.children);for(let i=0;i<A.length;i++)Object.keys(A[i]).forEach(n=>{(A[i][n]===0||A[i][n]===1/0)&&(A[i][n]=Math.sqrt(e[i][n]))});return A}function $e(o){if(!o)return;const e=s=>{let i=1/0;for(let n=0;n<s.length;n++){const c=s[n];c<i&&(i=c)}return i},t=[];t[0]={content:e(o.fArray.filter(s=>s!==0))},o.fArrays&&Object.keys(o==null?void 0:o.fArrays).forEach(s=>{t[0]={...t[0],[s]:e(o.fArrays[s].values.filter(i=>i!==0))}});const A=(s,i=1)=>{t[i]||(t[i]={}),Object.entries(s).forEach(([n,c])=>{c.forEach(a=>{if(!a)return;const r=e(a.fArray.filter(l=>l!==0));(!(n in t[i])||r<t[i][n])&&(t[i][n]=r),a.fArrays&&Object.keys(a.fArrays).forEach(l=>{(!(l in t[i])||r>t[i][l])&&(t[i][l]=r),t[i][l]=Math.min(t[i][l],e(a.fArrays[l].values.filter(h=>h!==0)))}),a.children&&A(a.children,i+1)})})};return o.children&&A(o.children),t}function _e(o){if(!o)return;const e=o.fXaxis.fNbins*o.fYaxis.fNbins*o.fZaxis.fNbins;let t=[];t.push(e);const A=(s,i=1)=>{let n=0;return i>=t.length&&t.push(1),Object.entries(s).forEach((c,a)=>{c[1].forEach(r=>{r&&(n=r.fXaxis.fNbins*r.fYaxis.fNbins*r.fZaxis.fNbins,n>t[i]&&(t[i]=n),r.children&&A(r.children,i+1))})}),t};return o.children&&A(o.children),t.push(1),t}function tA(o,e,t){new g.Color(o.color.default.min).toArray(t,0),new g.Color(o.color.default.max).toArray(t,3);let A=1;o.color.layer.forEach(s=>{const i=A*6;new g.Color(s.min).toArray(t,i),new g.Color(s.max).toArray(t,i+3),A++}),o.color.set.forEach(s=>{const i=A*6;new g.Color(s.min).toArray(t,i),new g.Color(s.max).toArray(t,i+3),A++}),e.uniforms.colorPairs={value:t},e.uniformsNeedUpdate=!0}function te(o,e,t,A,s,i){const c=((r,l,h)=>{let u=(r-l)/(h-l);return u>1&&(u=1),isNaN(u)||u===1/0?0:u})(e,t,A);let a=0;return o.set[s]?a=1+o.layer.length+s:o.layer[i]&&(a=1+i),a+c}function ee(o,e,t,A,s,i,n){if(!(1/o===-1/0||o<0))return n[0]=e[o],n[1]=e[o+1],n[2]=e[o+2],n[3]=t[o],n[4]=t[o+1],n[5]=t[o+2],n;const a=Math.abs(o),r=i!==null?A[s][i]:A[s];return n[0]=r.pos[a],n[1]=r.pos[a+1],n[2]=r.pos[a+2],n[3]=r.scale[a],n[4]=r.scale[a+1],n[5]=r.scale[a+2],n}const eA=o=>{if(!o)return!1;for(const e in o)if(e!=="content"&&Object.prototype.hasOwnProperty.call(o,e)&&o[e]&&typeof o[e]=="object"&&Object.keys(o[e]).length>0)return!0;return!1};function Mt(o,e,t,A,s,i,n){const c=e.fXaxis.fNbins,a=e.fYaxis.fNbins,r=e.fZaxis.fNbins;let l=0,h=0;const u=new Float32Array((c*a*r-1)*3),f=new Float32Array((c*a*r-1)*3),d=new Float32Array(c*a*r-1),C=new Float32Array(c*a*r-1),p=new Float32Array(c*a*r-1),w=new Float32Array(6),y=new Float32Array(6),b=x=>{const T=I*3;u[T]=x[0],u[T+1]=x[1],u[T+2]=x[2],f[T]=x[3],f[T+1]=x[4],f[T+2]=x[5],d[I]=x[6],C[I]=x[7],p[I]=x[8]},v=(x,T,z,O)=>{ee(x,u,f,o,z,O,w),ee(T,u,f,o,z,O,y);const N=w[0]-w[3]*.5<y[0]-y[3]*.5?w[0]-w[3]*.5:y[0]-y[3]*.5,D=w[1]-w[4]*.5<y[1]-y[4]*.5?w[1]-w[4]*.5:y[1]-y[4]*.5,J=w[2]-w[5]*.5<y[2]-y[5]*.5?w[2]-w[5]*.5:y[2]-y[5]*.5,H=w[0]+w[3]*.5>y[0]+y[3]*.5?w[0]+w[3]*.5:y[0]+y[3]*.5,k=w[1]+w[4]*.5>y[1]+y[4]*.5?w[1]+w[4]*.5:y[1]+y[4]*.5,X=w[2]+w[5]*.5>y[2]+y[5]*.5?w[2]+w[5]*.5:y[2]+y[5]*.5,F=new Float32Array(9);return F[0]=(N+H)*.5,F[1]=(D+k)*.5,F[2]=(J+X)*.5,F[3]=H-N,F[4]=k-D,F[5]=X-J,F};let I=0;for(let x=0;x<a;x++){for(let z=0;z<r;z++){const O=l+n;let N=new Array(c);for(let D=0;D<c;D++)N[D]=-D-O;for(;N.length>1;){let D=0;const J=Math.floor(N.length/2);for(let H=0;H<J;H++){const k=N[D],X=N[D+1],F=v(k*3,X*3,t,A);N.splice(D,2,I),Lt(F,i),F[6]=1/k===-1/0||k<0?k:p[k],F[7]=1/X===-1/0||X<0?X:p[X],F[8]=h,b(F),I+=1,h+=1,D+=1}}l+=c}const T=new Array(r);for(let z=0;z<r;z++)T[z]=I-1-(r-1-z)*(c-1);for(;T.length>1;){let z=0;const O=Math.floor(T.length/2);for(let N=0;N<O;N++){const D=T[z],J=T[z+1],H=v(D*3,J*3,t,A);T.splice(z,2,I),Lt(H,i),H[6]=p[D],H[7]=p[J],H[8]=h,b(H),I+=1,h+=1,z+=1}}}const M=new Array(a);for(let x=0;x<a;x++)M[x]=I-1-(a-1-x)*(c*r-1);for(;M.length>1;){let x=0;const T=Math.floor(M.length/2);for(let z=0;z<T;z++){const O=M[x],N=M[x+1],D=v(O*3,N*3,t,A);M.splice(x,2,I),Lt(D,i),D[6]=p[O],D[7]=p[N],D[8]=h,b(D),I+=1,h+=1,x+=1}}return{pos:u,scale:f,left:d,right:C}}function AA(o,e,t,A,s,i,n,c){const a=new Array(o.length).fill().map(l=>[]);a[a.length-1]=Array.from({length:i.length},()=>[]),s===null?a[0]=[Mt(o,e,t,null,i,n,0)]:(a[0]=new Array(i.length),A.forEach(l=>a[0][i.indexOf(l)]=Mt(o,e,t,i.indexOf(l),i,n,0)));const r=(l,h,u)=>{var w;if(!l.children)return;const f=new $t([l.fXaxis.fNbins,l.fYaxis.fNbins,l.fZaxis.fNbins]),d=l.fXaxis.fNbins*l.fYaxis.fNbins*l.fZaxis.fNbins,C=c.slice(1,h-1).reduce((y,b)=>y*b,c[1]),p=c[h];for(let y=0;y<d;y++){const b={x:f.getValueAt(0),y:f.getValueAt(1),z:f.getValueAt(2)};if((w=l==null?void 0:l.children)!=null&&w.content){const v=l.children.content[l.getBin(b.x+1,b.y+1,b.z+1)];if(!v){if(f.increment()===!1)break;continue}a[h][y+u]=Mt(o,v,h,null,i,n,(y+u)*p),r(v,h+1,(f.getIndex()+u)*C)}else eA(l.children)&&A.forEach(v=>{const I=i.indexOf(v),M=(y+u)*p;let x=!1;for(let z=M;z<M+c[h];z++)if(o[h][I].rendered[z]!==-1){x=!0;break}if(!x){a[h][I].push(null);return}const T=l.children[v][l.getBin(b.x+1,b.z+1,b.y+1)];T&&(a[h][I][y+u]=Mt(o,T,h,I,i,n,(y+u)*p),r(T,h+1,(f.getIndex()+u)*C))});if(f.increment()===!1)break}};return r(e,1,0),a}function Lt(o,e){const t=e.elements,A=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),s=Math.sqrt(t[4]*t[4]+t[5]*t[5]+t[6]*t[6]),i=Math.sqrt(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]);o[0]=o[0]*A+t[12],o[1]=o[1]*s+t[13],o[2]=o[2]*i+t[14],o[3]=o[3]*A,o[4]=o[4]*s,o[5]=o[5]*i}class kt{constructor(e){m(this,"rootObj");m(this,"origin");m(this,"parentPath",[]);m(this,"path");m(this,"title");m(this,"range",[]);m(this,"isOnSet",null);m(this,"isHistogramFilled",!0);this.rootObj=e,this.origin=this.rootObj,this.title=this.origin.fTitle,this.path=this.origin.fName}setOriginToChild(e,t,A){var i,n;if(!e)return;const s=e.splice(0,1);if((i=this.origin)!=null&&i.children){if((n=this.origin.children)!=null&&n.content)this.parentPath.push({origin:this.origin,range:A.splice(0,1),bin:s}),this.origin=this.origin.children.content[s],this.isOnSet=null;else if(Object.keys(this.origin.children).includes(t)){if(this.parentPath.push({origin:this.origin,range:A.splice(0,1),bin:s}),!this.origin.children[t][s]){this.isHistogramFilled=!1,this.path=this.path+"/empty",this.origin=null;return}this.origin=this.origin.children[t][s],this.isOnSet=t}else{console.error("Bad set or index specified.");return}this.title=this.origin.fTitle,this.path=this.path+"/"+this.origin.fName,e.length>0&&this.setOriginToChild(e,t,A)}}getChildByPosition(e,t,A=this.origin){var i;if(!e||e.length===0)return{...A};const s=e.splice(0,1)[0];return A!=null&&A.children?(i=A.children)!=null&&i.content?this.getChildByPosition(e,t,A.children.content[s]):Object.keys(A.children).includes(t)?this.getChildByPosition(e,t,A.children[t][s]):(console.error("Bad set or index specified."),null):{...A}}setOriginToParent(e=1){if(e<=0||this.parentPath.length===0)return;const t=this.path.lastIndexOf("/");this.path=this.path.slice(0,t);const A=this.parentPath.pop();A&&(this.origin=A.origin),this.title=this.origin.fTitle,this.setOriginToParent(e-1),this.isOnSet=null,this.isHistogramFilled=!0}}class sA{constructor(e,t,A,s){m(this,"wireframe");m(this,"instGeom");m(this,"material");m(this,"totalInstances");m(this,"maxInstancesPerLayer");m(this,"instancePositions");m(this,"instanceScales");m(this,"instanceColors");m(this,"colorArray");m(this,"configSub");m(this,"stateSub");m(this,"config");m(this,"numOfavailableSets");m(this,"visibility",!0);m(this,"id");this.config=A,this.maxInstancesPerLayer=e,this.id=s;const i=new g.BoxGeometry(1,1,1),n=new g.EdgesGeometry(i);this.instGeom=new g.InstancedBufferGeometry,this.instGeom.instanceCount=0,this.instGeom.frustumCulled=!1,this.instGeom.index=n.index;for(const c in n.attributes)this.instGeom.setAttribute(c,n.attributes[c]);this.material=this.createMaterial(),this.colorArray=new Float32Array(32*3),this.fillColorArray(),this.instancePositions=new Float32Array(3),this.instanceScales=new Float32Array(3),this.instanceColors=new Float32Array(1),this.instGeom.setAttribute("instancePosition",new g.InstancedBufferAttribute(this.instancePositions,3)),this.instGeom.setAttribute("instanceScale",new g.InstancedBufferAttribute(this.instanceScales,3)),this.instGeom.setAttribute("instanceColorIndex",new g.InstancedBufferAttribute(this.instanceColors,1)),this.wireframe=new g.LineSegments(this.instGeom,this.material),this.wireframe.frustumCulled=!1,this.stateSub=q(this.id).getObservable().subscribe(c=>{this.numOfavailableSets=c.sets.length})}pushVisibleInstances(e,t,A){let s=this.wireframe.parent;s&&(s.remove(this.wireframe),this.instGeom.dispose());const i=this.config.display.start??0,n=this.config.display.end??e.length-1,c=[];let a=e.length-1;{const v=(Array.isArray(e[a])?e[a][A]:e[a]).rendered,I=new Uint8Array(v.length);for(let M=0;M<v.length;M++)I[M]=v[M]!==-1?1:0;c[a]=I}for(let b=a-1;b>=0;b--){const I=(Array.isArray(e[b])?e[b][A]:e[b]).rendered,M=c[b+1],x=t[b+1]||0,T=new Uint8Array(I.length);for(let z=0;z<I.length;z++){if(I[z]!==-1){T[z]=1;continue}const O=z*x,N=O+x;for(let D=O;D<N;D++)if(M[D]){T[z]=1;break}}c[b]=T}const r=(b,v)=>b<i||b>n?!1:c[b][v]===1,l=(b,v)=>{let I=0,M=b,x=v;for(;M+1<e.length;){M++,x*=t[M];const T=e[M],z=Array.isArray(T)?T[A===-1?0:A]:T;for(let O=x;O<x+t[M];O++)if(z.rendered[O]!==-1){I=M-b;break}}return I};let h=0;for(let b=0;b<e.length;b++){const v=e[b];if(!Array.isArray(v))for(let I=0;I<v.rendered.length;I++)r(b,I)&&h++}const u=new Float32Array(h*3),f=new Float32Array(h*3),d=new Float32Array(h);let C=0;for(let b=0;b<e.length;b++){const v=e[b],I=this.getColorIndex(b,A);if(!Array.isArray(v)){for(let M=0;M<v.rendered.length;M++)if(r(b,M)){const x=l(b,M)*.05;u[C*3]=v.pos[M*3],u[C*3+1]=v.pos[M*3+1],u[C*3+2]=v.pos[M*3+2],f[C*3]=v.scale[M*3]+x,f[C*3+1]=v.scale[M*3+1]+x,f[C*3+2]=v.scale[M*3+2]+x,d[C++]=I}}}const p=new g.BoxGeometry(1,1,1),w=new g.EdgesGeometry(p);this.instGeom=new g.InstancedBufferGeometry,this.instGeom.instanceCount=h,this.instGeom.frustumCulled=!1,this.instGeom.index=w.index;const y=w.attributes;for(const b in y)this.instGeom.setAttribute(b,y[b]);this.instancePositions=u,this.instanceScales=f,this.instanceColors=d,this.instGeom.setAttribute("instancePosition",new g.InstancedBufferAttribute(u,3)),this.instGeom.setAttribute("instanceScale",new g.InstancedBufferAttribute(f,3)),this.instGeom.setAttribute("instanceColorIndex",new g.InstancedBufferAttribute(d,1)),this.wireframe=new g.LineSegments(this.instGeom,this.material),this.wireframe.frustumCulled=!1,s&&s.add(this.wireframe)}toggleVisibility(e,t,A){this.visibility=!this.visibility,this.visibility?this.pushVisibleInstances(e,t,A):this.clearWireframe()}dispose(){this.instancePositions=[],this.instanceScales=[],this.wireframe.parent.remove(this.wireframe),this.instGeom.dispose()}clearWireframe(){this.instancePositions=new Float32Array(3),this.instanceScales=new Float32Array(3),this.instanceColors=new Float32Array(1),this.instGeom.dispose(),this.instGeom.instanceCount=0}fillColorArray(){new g.Color(this.config.color.default).toArray(this.colorArray,0);let e=1;this.config.color.layer.map(t=>new g.Color(t)).forEach(t=>{const A=e*3;t.toArray(this.colorArray,A),e++}),this.config.color.set.map(t=>new g.Color(t)).forEach(t=>{const A=e*3;t.toArray(this.colorArray,A),e++}),this.material.uniforms.colorArray={value:this.colorArray},this.material.uniformsNeedUpdate=!0}createMaterial(){return new g.ShaderMaterial({vertexShader:`
|
|
37
37
|
attribute vec3 instancePosition;
|
|
38
38
|
attribute vec3 instanceScale;
|
|
39
39
|
attribute float instanceColorIndex;
|