@ndmspc/ndmvr-core 1.1.2-rc.3 → 1.1.2-rc.4
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 +2 -2
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1691,7 +1691,7 @@ var $ = class {
|
|
|
1691
1691
|
o.fXaxis.fNbins,
|
|
1692
1692
|
o.fYaxis.fNbins,
|
|
1693
1693
|
o.fZaxis.fNbins
|
|
1694
|
-
]), u, d, f, p, m = o.fArrays?.[this.selectedArray]?.outside ?? !1, h = this.selectedSet.indexOf(c), g = this.availableSets.indexOf(c), _ = o.fArrays[Object.keys(o.fArrays)[0]].values, v = this.config.scale.scaleBy === "value";
|
|
1694
|
+
]), u, d, f, p, m = o.fArrays?.[this.selectedArray]?.outside ?? !1, h = this.selectedSet.indexOf(c), g = this.availableSets.indexOf(c), _ = o.fArrays ? o.fArrays[Object.keys(o.fArrays)[0]].values : !1, v = this.config.scale.scaleBy === "value";
|
|
1695
1695
|
if (c) if (this.config.scale.sets === "fixed") ({min: u, max: d} = this.minMaxValue[a + this.pointer.parentPath.length][c].value), {min: p, max: f} = this.minMaxValue[a + this.pointer.parentPath.length][c].error;
|
|
1696
1696
|
else if (this.config.scale.sets === "relative") {
|
|
1697
1697
|
let e = o.fSumw2.filter((e) => e !== 0), t = v ? o.fArray.filter((e) => e !== 0) : e;
|
|
@@ -2084,7 +2084,7 @@ var $ = class {
|
|
|
2084
2084
|
distance: null
|
|
2085
2085
|
}), r;
|
|
2086
2086
|
}, o = (e, t, n = 0, i = [], s = null) => {
|
|
2087
|
-
let c = [], l = this.maxInstancesPerLayer[t + 1], u = this.maxInstancesPerLayer[t] * this.maxInstancesPerLayer[t + 1], d = e.fArrays[Object.keys(e.fArrays)[0]].values;
|
|
2087
|
+
let c = [], l = this.maxInstancesPerLayer[t + 1], u = this.maxInstancesPerLayer[t] * this.maxInstancesPerLayer[t + 1], d = e.fArrays ? e.fArrays[Object.keys(e.fArrays)[0]].values : !1;
|
|
2088
2088
|
return a(t, n, s).forEach((a) => {
|
|
2089
2089
|
let f = Math.abs(a.index) - n * this.maxInstancesPerLayer[t], p = f % e.fXaxis.fNbins, m = Math.floor(f % (e.fXaxis.fNbins * e.fYaxis.fNbins) / e.fXaxis.fNbins), h = Math.floor(f / (e.fXaxis.fNbins * e.fYaxis.fNbins)), g = [...i, {
|
|
2090
2090
|
x: p,
|
package/dist/index.umd.js
CHANGED
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
void main() {
|
|
55
55
|
gl_FragColor = vec4(vColor, 1.0);
|
|
56
56
|
}
|
|
57
|
-
`,transparent:!1})}getColorIndex(e,t){return this.config.color.set[t]?this.config.color.layer.length+1:this.config.color.layer[e]?e+1:0}getColorAt(e,t){return this.config.color.set[t]?this.config.color.set[t]:this.config.color.layer[e]?this.config.color.layer[e]:this.config.color.default}},je=class{id=void 0;functionSub=void 0;configSub=void 0;dispatchSub=void 0;rootObj=void 0;config=void 0;limits={scale:{x:20,y:10,z:20},position:{x:0,y:0,z:-5}};mouseEvents=[];keydownEvents=[];keyupEvents=[];keyBindings={};renderHistory=[];opts=void 0;constructor(e,n,r){this.rootObj=e.obj,this.id=n,this.opts=r,this.config=L().mergeHistogramConfig(this?.opts?.config),this.functionSub=x().getObservable().pipe((0,t.filter)(e=>e.target.entity===`nested-histogram`&&(e.target.id.includes(`*`)||e.target.id.includes(this.id)))).subscribe(e=>this.functionSubjectHandler(e)),this.configSub=L().getObservable().pipe((0,t.filter)(e=>e.target.id.includes(`*`)||e.target.id.includes(this.id))).subscribe(e=>this.configSubjectHandler(e)),this.dispatchSub=f().getObservable().pipe((0,t.filter)(e=>e.target.id===`*`||e.target.id===this.id)).subscribe(e=>this.dispatchSubjectHandler(e)),this.initDefaultFunctions()}remove(){this.functionSub.unsubscribe(),this.configSub.unsubscribe(),this.dispatchSub.unsubscribe(),window.removeEventListener(`keydown`,this.keyDownHandler),window.removeEventListener(`keydown`,this.keyUpHandler)}initDefaultFunctions(){this.keyDownHandler=this.keyDownHandler.bind(this),this.keyUpHandler=this.keyUpHandler.bind(this),this.raycastHandler=this.raycastHandler.bind(this),this.mouseClickDefault=this.mouseClickDefault.bind(this),this.mousemoveDefault=this.mousemoveDefault.bind(this),this.shiftMouseClickDefault=this.shiftMouseClickDefault.bind(this),this.mouseDBClickDefault=this.mouseDBClickDefault.bind(this),this.shiftMouseDBClickDefault=this.shiftMouseDBClickDefault.bind(this),window.addEventListener(`keydown`,this.keyDownHandler),window.addEventListener(`keydown`,this.keyUpHandler),this.addEvent(`mouseclick`,this.mouseClickDefault),this.addEvent(`mousemove`,this.mousemoveDefault),this.addEvent(`shiftmouseclick`,this.shiftMouseClickDefault),this.addEvent(`mousedbclick`,this.mouseDBClickDefault),this.addEvent(`shiftmousedbclick`,this.shiftMouseDBClickDefault)}configSubjectHandler(e){console.log(`default configSubjectHandler: `,e)}functionSubjectHandler(e){if(e.flag===`add`)if(e.function)this.addEvent(e.event,e.function);else switch(e.event){case`mousemove`:this.addEvent(e.event,this.mousemoveDefault);break;case`mouseclick`:this.addEvent(e.event,this.mouseClickDefault);break;case`shiftmouseclick`:this.addEvent(e.event,this.shiftMouseClickDefault);break;case`mousedbclick`:this.addEvent(e.event,this.mouseDBClickDefault);break;case`shiftmousedbclick`:this.addEvent(e.event,this.shiftMouseDBClickDefault);break}else if(e.flag===`remove`&&e.function)this.removeEvent(e.event,e.function);else if(e.flag===`remove`)switch(e?.state){case`keydown`:this.keydownEvents=[];break;case`keyup`:this.keyupEvents=[];break;default:this.mouseEvents=this.mouseEvents.filter(t=>t.event!==e.event)}else e.flag===`removeAll`&&(this.keydownEvents=[],this.keyupEvents=[],this.mouseEvents=[])}addEvent(e,t){e?.state===`keydown`?this.keydownEvents.push({key:e.key,function:t}):e?.state===`keyup`?this.keyupEvents.push({key:e.key,function:t}):this.mouseEvents.push({event:e,function:t})}removeEvent(e,t){let n=this.mouseEvents.find(e=>e===t);n&&this.mouseEvents.splice(n,1)}mouseClickDefault(e){console.log(`mouse click default`)}mousemoveDefault(e){console.log(`mouse move default`)}shiftMouseClickDefault(e){console.log(`shift mouse click`)}mouseDBClickDefault(e){console.log(`mouseDBClick default`)}shiftMouseDBClickDefault(e){console.log(`shift mouse db click default`)}dispatchSubjectHandler(e){console.log(`dispatch: `,e)}},Me=class extends je{stateSub=void 0;pointer=void 0;wireframe=void 0;BVHTree=[];minMaxValue=[];maxInstancesPerLayer=void 0;maxContentPerLayer=void 0;maxErrorPerLayer=void 0;totalInstances=void 0;color=new r.Color;matrixCache=void 0;selectedSet=[];selectedArray=`content`;availableSets=[];dirtyInstance=[];mesh=void 0;instGeom=void 0;material=void 0;instancePositions=void 0;instanceScales=void 0;instanceColors=void 0;colorArray=void 0;constructor(e,t,n){if(!e||!e.obj)throw console.error(`THnPainter constructor: histo or histo.obj is undefined`,e),Error(`THnPainter: histo or histo.obj is undefined`);super(e,t,n),console.log(`THnPainter constructor start: `),this.pointer=new $(this.rootObj),this.handleStateChange=this.handleStateChange.bind(this),this.stateSub=v(this.id).getObservable().subscribe(this.handleStateChange),this.init(!0),console.log(`THnPainter constructor end, mesh: `,this.mesh,`meshParent: `,this?.mesh?.parent??`undefined`)}async updateHistogram(e){if(!e||!e.obj)throw console.error(`THnPainter constructor: histo or histo.obj is undefined`,e),Error(`THnPainter: histo or histo.obj is undefined`);console.log(`THnPainter updateHistogram start => histo: `,e,`, mesh: `,this.mesh,`uuid: `,this.mesh.uuid,`mesh.parent: `,this?.mesh?.parent??`undefined`);let t,n=this.mesh.parent;if(console.log(`THnPainter updateHistogram parent is defined, removing mesh: `,this.mesh,`uuid: `,this.mesh.uuid,`mesh.parent: `,this?.mesh?.parent??`undefined`),this.pointer.isHistogramFilled&&(t=this.mesh.raycast,this.mesh.raycast=()=>{},this.wireframe.dispose(),this.instGeom.dispose()),this.matrixCache=[],this.BVHTree=[],this.availableSets=[],this.selectedSet=[],this.minMaxValue=[],v(this.id).next({sets:[],selectedSet:[],arrays:[`content`],selectedArray:`content`,minMaxValue:[]}),n&&(console.log(`THnPainter updateHistogram parent is undefined`,this.mesh,`uuid: `,this.mesh.uuid,`mesh.parent: `,this?.mesh?.parent??`undefined`),n.remove(this.mesh)),console.log(`THnPainter re-init in update: `,e,`mesh.uuid: `,this.mesh.uuid,`mesh.parent: `,this?.mesh?.parent??`undefined`),this.rootObj=e.obj,this.pointer=new $(this.rootObj),this.init(!0),await this.renderHistogram(0,this.totalInstances,0),this.mesh.raycast=t,console.log(`THnPainter re-init in update SUCCESSFULL, now adding mesh to parent: `,e,`mesh.uuid: `,this.mesh.uuid,`mesh.parent: `,this?.mesh?.parent??`undefined`),n)n.add(this.mesh),n.add(this.wireframe.wireframe),console.log(`THnPainter mesh successfully added to parent: `,this.mesh,`uuid: `,this.mesh.uuid,`mesh.parent: `,this?.mesh?.parent??`undefined`);else throw ReferenceError(`THnPainter: parent is undefined`)}remove(){super.remove(),this.matrixCache=[],this.instGeom.dispose(),this.mesh.parent&&(this.mesh.parent.remove(this.mesh),this.wireframe.dispose()),this.stateSub.unsubscribe()}init(e=!1){if(this.maxInstancesPerLayer=we(this.pointer.origin),e){this.maxContentPerLayer=be(this.pointer.origin),this.minContentPerLayer=Ce(this.pointer.origin),this.maxErrorPerLayer=xe(this.pointer.origin,this.maxContentPerLayer),this.minErrorPerLayer=Se(this.pointer.origin,this.minContentPerLayer),this.setAvailableSets(this.pointer.origin),this.setAvailableArrays(this.pointer.origin);let e=Array(this.maxContentPerLayer.length);for(let t=0;t<this.maxContentPerLayer.length;t++)e[t]={},Object.keys(this.maxContentPerLayer[t]).forEach(n=>{e[t][n]={value:{min:this.minContentPerLayer[t][n],max:this.maxContentPerLayer[t][n]},error:{min:this.minErrorPerLayer[t][n],max:this.maxErrorPerLayer[t][n]}}});console.log(`minMaxValues: `,e),v(this.id).next({...v(this.id).getValue(),minMaxValue:e})}this.totalInstances=this.maxInstancesPerLayer.reduce((e,t)=>e*t,1),this.setupInsBufGeom(),this.wireframe=new Ae(this.maxInstancesPerLayer,this.matrixCache,this.config.wireframe,this.id)}setupMatrixCache(){this.matrixCache=Array(this.maxInstancesPerLayer.length-1);let e=this.availableSets.length>0;e&&(this.matrixCache[this.matrixCache.length-1]=Array(this.availableSets.length));let t=this.maxInstancesPerLayer[0];for(let n=0;n<this.maxInstancesPerLayer.length-1-(e?1:0);n++)this.matrixCache[n]={pos:new Float32Array(t*3),scale:new Float32Array(t*3),rendered:new Float32Array(t).fill(-1)},t*=this.maxInstancesPerLayer[n+1];if(!e)return;let n=this.matrixCache[this.matrixCache.length-1];for(let e=0;e<n.length;e++)n[e]={pos:new Float32Array(t*3),scale:new Float32Array(t*3),rendered:new Float32Array(t).fill(-1)}}setupInsBufGeom(){this.setupMatrixCache();let e=this.maxInstancesPerLayer.reduce((e,t)=>e*t,1);this.selectedSet.length>1&&(e*=this.selectedSet.length);let t=new r.BoxGeometry(1,1,1);this.instGeom=new r.InstancedBufferGeometry,this.instGeom.instanceCount=0,this.instGeom.frustumCulled=!1,this.instGeom.index=t.index;for(let e in t.attributes)this.instGeom.setAttribute(e,t.attributes[e]);this.material=this.createMaterial(),this.colorArray=new Float32Array(192),this.material.uniforms.colorArray={value:this.colorArray},Te(this.config,this.material,this.colorArray),this.instancePositions=new Float32Array(3),this.instanceScales=new Float32Array(3),this.instanceColors=new Float32Array(1),this.instGeom.setAttribute(`instancePosition`,new r.InstancedBufferAttribute(this.instancePositions,3)),this.instGeom.setAttribute(`instanceScale`,new r.InstancedBufferAttribute(this.instanceScales,3)),this.instGeom.setAttribute(`instanceColorIndex`,new r.InstancedBufferAttribute(this.instanceColors,1)),this.mesh=new r.Mesh(this.instGeom,this.material),this.mesh.raycast=this.raycastHandler,this.mesh.frustumCulled=!1,this.material.uniforms.colorArray={value:this.colorArray},this.mesh.material.uniformsNeedUpdate=!0}pushVisibleInstances(){let e=this.mesh.parent;e&&(e.remove(this.mesh),this.instGeom.dispose());let t=0;for(let e=0;e<this.matrixCache.length;e++){let n=this.matrixCache[e];if(Array.isArray(n))for(let e=0;e<n.length;e++){let r=n[e];for(let e=0;e<r.rendered.length;e++)r.rendered[e]!==-1&&t++}else for(let e=0;e<n.rendered.length;e++)n.rendered[e]!==-1&&t++}let n=new Float32Array(t*3),i=new Float32Array(t*3),a=new Float32Array(t),o=0;for(let e=0;e<this.matrixCache.length;e++){let t=this.matrixCache[e];if(Array.isArray(t))for(let e=0;e<t.length;e++){let r=t[e];for(let e=0;e<r.rendered.length;e++)r.rendered[e]!==-1&&(n[o*3]=r.pos[e*3],n[o*3+1]=r.pos[e*3+1],n[o*3+2]=r.pos[e*3+2],i[o*3]=r.scale[e*3],i[o*3+1]=r.scale[e*3+1],i[o*3+2]=r.scale[e*3+2],a[o++]=r.rendered[e])}else for(let e=0;e<t.rendered.length;e++)t.rendered[e]!==-1&&(n[o*3]=t.pos[e*3],n[o*3+1]=t.pos[e*3+1],n[o*3+2]=t.pos[e*3+2],i[o*3]=t.scale[e*3],i[o*3+1]=t.scale[e*3+1],i[o*3+2]=t.scale[e*3+2],a[o++]=t.rendered[e])}let s=new r.BoxGeometry(1,1,1);this.instGeom=new r.InstancedBufferGeometry,this.instGeom.instanceCount=t,this.instGeom.frustumCulled=!1,this.instGeom.index=s.index;let c=s.attributes;for(let e in c)this.instGeom.setAttribute(e,c[e]);this.instancePositions=n,this.instanceScales=i,this.instanceColors=a,this.instGeom.setAttribute(`instancePosition`,new r.InstancedBufferAttribute(n,3)),this.instGeom.setAttribute(`instanceScale`,new r.InstancedBufferAttribute(i,3)),this.instGeom.setAttribute(`instanceColorIndex`,new r.InstancedBufferAttribute(a,1)),this.mesh=new r.Mesh(this.instGeom,this.material),this.mesh.raycast=this.raycastHandler,this.mesh.frustumCulled=!1,e&&e.add(this.mesh)}setMatrixCacheAt(e,t,n,r,i){let a=t===null?this.matrixCache[e]:this.matrixCache[e][t];a.pos[n*3]=r.x.pos,a.pos[n*3+1]=r.y.pos,a.pos[n*3+2]=r.z.pos,a.scale[n*3]=r.x.size,a.scale[n*3+1]=r.y.size,a.scale[n*3+2]=r.z.size,a.rendered[n]=i}async renderHistogram(e,t,n){if(!this.pointer||n>=this.maxInstancesPerLayer.length-1)return;this.logRender({procedure:`render`,value:{startIndex:e,endIndex:t,layer:n}});let i={x:{size:0,pos:0},y:{size:0,pos:0},z:{size:0,pos:0}},a=async(e,t,o,s,c,l)=>{if(o>n||!s)return;let u=new U([s.fXaxis.fNbins,s.fYaxis.fNbins,s.fZaxis.fNbins]),d,f,p,m,h=s.fArrays?.[this.selectedArray]?.outside??!1,g=this.selectedSet.indexOf(l),_=this.availableSets.indexOf(l),v=s.fArrays[Object.keys(s.fArrays)[0]].values,y=this.config.scale.scaleBy===`value`;if(l)if(this.config.scale.sets===`fixed`)({min:d,max:f}=this.minMaxValue[o+this.pointer.parentPath.length][l].value),{min:m,max:p}=this.minMaxValue[o+this.pointer.parentPath.length][l].error;else if(this.config.scale.sets===`relative`){let e=s.fSumw2.filter(e=>e!==0),t=y?s.fArray.filter(e=>e!==0):e;d=Math.min(...t),f=Math.max(...t),p=this.maxErrorPerLayer[o+this.pointer.parentPath.length][l],m=this.minErrorPerLayer[o+this.pointer.parentPath.length][l]}else d=y?this.minContentPerLayer[o+this.pointer.parentPath.length][l]:-.1,f=y?this.maxContentPerLayer[o+this.pointer.parentPath.length][l]:this.maxErrorPerLayer[o+this.pointer.parentPath.length][l],p=this.maxErrorPerLayer[o+this.pointer.parentPath.length][l],m=this.minErrorPerLayer[o+this.pointer.parentPath.length][l];else if(this.selectedArray!==`content`&&s.fArrays&&v)if(this.config.scale.parameter===`fixed`)({min:d,max:f}=this.minMaxValue[o+this.pointer.parentPath.length][this.selectedArray].value),{min:m,max:p}=this.minMaxValue[o+this.pointer.parentPath.length][this.selectedArray].error;else if(this.config.scale.parameter===`relative`){let e=s.fArrays[this.selectedArray].errors.filter(e=>e!==0),t=y?s.fArrays[this.selectedArray].values.filter(e=>e!==0):e;d=Math.min(...t),f=Math.max(...t),p=this.maxErrorPerLayer[o+this.pointer.parentPath.length][this.selectedArray],m=this.minErrorPerLayer[o+this.pointer.parentPath.length][this.selectedArray]}else d=y?this.minContentPerLayer[0][this.selectedArray]:-.1,f=y?this.maxContentPerLayer[0][this.selectedArray]:this.maxErrorPerLayer[0][this.selectedArray],p=this.maxErrorPerLayer[0][this.selectedArray],m=this.minErrorPerLayer[0][this.selectedArray];else{let e=this.pointer.isOnSet??`content`;if(this.config.scale.content===`fixed`)({min:d,max:f}=this.minMaxValue[o+this.pointer.parentPath.length][e].value),{min:m,max:p}=this.minMaxValue[o+this.pointer.parentPath.length][e].error;else if(this.config.scale.content===`relative`){let t=s.fSumw2.filter(e=>e!==0),n=y?s.fArray.filter(e=>e!==0):t;d=Math.min(...n),f=Math.max(...n),p=this.maxErrorPerLayer[o+this.pointer.parentPath.length][e],m=this.minErrorPerLayer[o+this.pointer.parentPath.length][e]}else d=y?this.minContentPerLayer[o+this.pointer.parentPath.length][e]:-.1,f=y?this.maxContentPerLayer[o+this.pointer.parentPath.length][e]:this.maxErrorPerLayer[o+this.pointer.parentPath.length][e],p=this.maxErrorPerLayer[o+this.pointer.parentPath.length][e],m=this.minErrorPerLayer[o+this.pointer.parentPath.length][e]}d===f&&(d=f-.2);let b=s._typename.substring(0,3)===`TH3`,x=s._typename.substring(0,3)===`TH2`,S=s._typename.substring(0,3)===`TH1`,C=this.maxInstancesPerLayer.slice(o+1).reduce((e,t)=>e*t,1);u.setFromNumber(e/C);let w=this.config.padding.layer[o]??this.config.padding.default,T=!this.config.padding.layer[o]&&S?{x:w.x,y:w.y,z:w.z}:{...w};l&&this.config.padding.sets&&S&&(T={x:this.config.padding.sets.x,y:0,z:0}),this.pointer.isOnSet&&(T={x:0,y:0,z:0});let{min:E,max:D}=this.config.scale?.layer?.[o]?this.config.scale?.layer[o]:this.config.scale.default;for(let y=e;y<t;y+=C){let e={x:u.getValueAt(0),y:u.getValueAt(1),z:u.getValueAt(2)},S=he(c.position.z,c.scale.z,G(K(s,e,T,c?.scale,c?.position,o,i))),w=this.getBinContent(s,e.x,e.y,e.z,v?this.selectedArray:`content`),O=this.getBinError(s,e.x,e.y,e.z,v?this.selectedArray:`content`),k=this.config.scale.scaleBy===`value`?w:O,A=this.config.scale.scaleBy===`value`?d:m,j=this.config.scale.scaleBy===`value`?f:p;A===j&&(A-=A*.1);let M=1;if(k>=A==!h){let e=(k-A)/(j-A);if(!h)M=Number.isInteger(k)&&k===0&&this.config.scale.scaleBy===`value`?M=0:(D-E)*e+E,M>1&&(M=1);else{let e=(w-void 0)/(void 0-void 0);M=Number.isInteger(w)&&w===0?M=0:(D-E)*e+E}}else M=0;this.config.color.scaleBy===`value`?this.color=Ee(this.config.color,k,A,j,_,o):this.color=Ee(this.config.color,O,m,p,_,o);let N=S.y.size*M;if(M===0)S.x.size=0,S.z.size=0,S.y.size=0;else if(b)S.x.size*=M,S.z.size*=M,S.y.size=N;else if(x)S.y.pos-=(S.y.size-N)/2,S.y.size=N;else if(S.y.pos-=(S.y.size-N)/2,S.y.size=N,l){let e=this.config.TH1ZScale.set;S.z.size=e||.01}else this.config.TH1ZScale?.layer?.[o]?S.z.size=c.scale.z*this.config.TH1ZScale.layer[o]:S.z.size=c.scale.z*this.config.TH1ZScale.default;if(l)S.z.size=.01,S.z.pos+=(g-(this.selectedSet.length-1)/2)*.1,this.setMatrixCacheAt(o,_,y/C,S,o===n&&M!==0?this.color:-1);else{let e=null;this.pointer.isOnSet&&(S.z.size=.01,S.z.pos+=(g-(this.selectedSet.length-1)/2)*.1,e=this.availableSets.indexOf(this.pointer.isOnSet)),this.setMatrixCacheAt(o,e,y/C,S,o===n&&M!==0?this.color:-1)}if(o===n){let e=y;l&&(e+=this.totalInstances*g)}else{let n=s.getBin(e.x+1,e.y+1,e.z+1),i,c={position:new r.Vector3(S.x.pos,S.y.pos,S.z.pos),scale:new r.Vector3(S.x.size,S.y.size,S.z.size)};s.children.content?(i=s.children.content[n],a(y,t,o+1,i,c)):this.selectedSet.forEach(e=>{i=s.children[e][n],a(y,t,o+1,i,c,e)})}if(!u.increment())break}};this.pointer.isOnSet?await Promise.all(this.selectedSet.map(n=>a(e,t,0,X(this.pointer.rootObj,this.pointer.parentPath.map(e=>e.bin[0]),n),this.limits,n))):await a(e,t,0,this.pointer.origin,this.limits),this.pointer.isOnSet||this.wireframe.pushVisibleInstances(this.matrixCache,this.maxInstancesPerLayer,this.availableSets.indexOf(this.selectedSet[0])),this.pushVisibleInstances();let o=this.availableSets.indexOf(this.pointer.isOnSet)===-1?null:this.availableSets.indexOf(this.pointer.isOnSet);return this.BVHTree=ke(this.matrixCache,this.pointer.origin,0,this.selectedSet,o,this.availableSets,this.mesh.matrixWorld,this.maxInstancesPerLayer),this.mesh}createMaterial(){return new r.ShaderMaterial({vertexShader:`
|
|
57
|
+
`,transparent:!1})}getColorIndex(e,t){return this.config.color.set[t]?this.config.color.layer.length+1:this.config.color.layer[e]?e+1:0}getColorAt(e,t){return this.config.color.set[t]?this.config.color.set[t]:this.config.color.layer[e]?this.config.color.layer[e]:this.config.color.default}},je=class{id=void 0;functionSub=void 0;configSub=void 0;dispatchSub=void 0;rootObj=void 0;config=void 0;limits={scale:{x:20,y:10,z:20},position:{x:0,y:0,z:-5}};mouseEvents=[];keydownEvents=[];keyupEvents=[];keyBindings={};renderHistory=[];opts=void 0;constructor(e,n,r){this.rootObj=e.obj,this.id=n,this.opts=r,this.config=L().mergeHistogramConfig(this?.opts?.config),this.functionSub=x().getObservable().pipe((0,t.filter)(e=>e.target.entity===`nested-histogram`&&(e.target.id.includes(`*`)||e.target.id.includes(this.id)))).subscribe(e=>this.functionSubjectHandler(e)),this.configSub=L().getObservable().pipe((0,t.filter)(e=>e.target.id.includes(`*`)||e.target.id.includes(this.id))).subscribe(e=>this.configSubjectHandler(e)),this.dispatchSub=f().getObservable().pipe((0,t.filter)(e=>e.target.id===`*`||e.target.id===this.id)).subscribe(e=>this.dispatchSubjectHandler(e)),this.initDefaultFunctions()}remove(){this.functionSub.unsubscribe(),this.configSub.unsubscribe(),this.dispatchSub.unsubscribe(),window.removeEventListener(`keydown`,this.keyDownHandler),window.removeEventListener(`keydown`,this.keyUpHandler)}initDefaultFunctions(){this.keyDownHandler=this.keyDownHandler.bind(this),this.keyUpHandler=this.keyUpHandler.bind(this),this.raycastHandler=this.raycastHandler.bind(this),this.mouseClickDefault=this.mouseClickDefault.bind(this),this.mousemoveDefault=this.mousemoveDefault.bind(this),this.shiftMouseClickDefault=this.shiftMouseClickDefault.bind(this),this.mouseDBClickDefault=this.mouseDBClickDefault.bind(this),this.shiftMouseDBClickDefault=this.shiftMouseDBClickDefault.bind(this),window.addEventListener(`keydown`,this.keyDownHandler),window.addEventListener(`keydown`,this.keyUpHandler),this.addEvent(`mouseclick`,this.mouseClickDefault),this.addEvent(`mousemove`,this.mousemoveDefault),this.addEvent(`shiftmouseclick`,this.shiftMouseClickDefault),this.addEvent(`mousedbclick`,this.mouseDBClickDefault),this.addEvent(`shiftmousedbclick`,this.shiftMouseDBClickDefault)}configSubjectHandler(e){console.log(`default configSubjectHandler: `,e)}functionSubjectHandler(e){if(e.flag===`add`)if(e.function)this.addEvent(e.event,e.function);else switch(e.event){case`mousemove`:this.addEvent(e.event,this.mousemoveDefault);break;case`mouseclick`:this.addEvent(e.event,this.mouseClickDefault);break;case`shiftmouseclick`:this.addEvent(e.event,this.shiftMouseClickDefault);break;case`mousedbclick`:this.addEvent(e.event,this.mouseDBClickDefault);break;case`shiftmousedbclick`:this.addEvent(e.event,this.shiftMouseDBClickDefault);break}else if(e.flag===`remove`&&e.function)this.removeEvent(e.event,e.function);else if(e.flag===`remove`)switch(e?.state){case`keydown`:this.keydownEvents=[];break;case`keyup`:this.keyupEvents=[];break;default:this.mouseEvents=this.mouseEvents.filter(t=>t.event!==e.event)}else e.flag===`removeAll`&&(this.keydownEvents=[],this.keyupEvents=[],this.mouseEvents=[])}addEvent(e,t){e?.state===`keydown`?this.keydownEvents.push({key:e.key,function:t}):e?.state===`keyup`?this.keyupEvents.push({key:e.key,function:t}):this.mouseEvents.push({event:e,function:t})}removeEvent(e,t){let n=this.mouseEvents.find(e=>e===t);n&&this.mouseEvents.splice(n,1)}mouseClickDefault(e){console.log(`mouse click default`)}mousemoveDefault(e){console.log(`mouse move default`)}shiftMouseClickDefault(e){console.log(`shift mouse click`)}mouseDBClickDefault(e){console.log(`mouseDBClick default`)}shiftMouseDBClickDefault(e){console.log(`shift mouse db click default`)}dispatchSubjectHandler(e){console.log(`dispatch: `,e)}},Me=class extends je{stateSub=void 0;pointer=void 0;wireframe=void 0;BVHTree=[];minMaxValue=[];maxInstancesPerLayer=void 0;maxContentPerLayer=void 0;maxErrorPerLayer=void 0;totalInstances=void 0;color=new r.Color;matrixCache=void 0;selectedSet=[];selectedArray=`content`;availableSets=[];dirtyInstance=[];mesh=void 0;instGeom=void 0;material=void 0;instancePositions=void 0;instanceScales=void 0;instanceColors=void 0;colorArray=void 0;constructor(e,t,n){if(!e||!e.obj)throw console.error(`THnPainter constructor: histo or histo.obj is undefined`,e),Error(`THnPainter: histo or histo.obj is undefined`);super(e,t,n),console.log(`THnPainter constructor start: `),this.pointer=new $(this.rootObj),this.handleStateChange=this.handleStateChange.bind(this),this.stateSub=v(this.id).getObservable().subscribe(this.handleStateChange),this.init(!0),console.log(`THnPainter constructor end, mesh: `,this.mesh,`meshParent: `,this?.mesh?.parent??`undefined`)}async updateHistogram(e){if(!e||!e.obj)throw console.error(`THnPainter constructor: histo or histo.obj is undefined`,e),Error(`THnPainter: histo or histo.obj is undefined`);console.log(`THnPainter updateHistogram start => histo: `,e,`, mesh: `,this.mesh,`uuid: `,this.mesh.uuid,`mesh.parent: `,this?.mesh?.parent??`undefined`);let t,n=this.mesh.parent;if(console.log(`THnPainter updateHistogram parent is defined, removing mesh: `,this.mesh,`uuid: `,this.mesh.uuid,`mesh.parent: `,this?.mesh?.parent??`undefined`),this.pointer.isHistogramFilled&&(t=this.mesh.raycast,this.mesh.raycast=()=>{},this.wireframe.dispose(),this.instGeom.dispose()),this.matrixCache=[],this.BVHTree=[],this.availableSets=[],this.selectedSet=[],this.minMaxValue=[],v(this.id).next({sets:[],selectedSet:[],arrays:[`content`],selectedArray:`content`,minMaxValue:[]}),n&&(console.log(`THnPainter updateHistogram parent is undefined`,this.mesh,`uuid: `,this.mesh.uuid,`mesh.parent: `,this?.mesh?.parent??`undefined`),n.remove(this.mesh)),console.log(`THnPainter re-init in update: `,e,`mesh.uuid: `,this.mesh.uuid,`mesh.parent: `,this?.mesh?.parent??`undefined`),this.rootObj=e.obj,this.pointer=new $(this.rootObj),this.init(!0),await this.renderHistogram(0,this.totalInstances,0),this.mesh.raycast=t,console.log(`THnPainter re-init in update SUCCESSFULL, now adding mesh to parent: `,e,`mesh.uuid: `,this.mesh.uuid,`mesh.parent: `,this?.mesh?.parent??`undefined`),n)n.add(this.mesh),n.add(this.wireframe.wireframe),console.log(`THnPainter mesh successfully added to parent: `,this.mesh,`uuid: `,this.mesh.uuid,`mesh.parent: `,this?.mesh?.parent??`undefined`);else throw ReferenceError(`THnPainter: parent is undefined`)}remove(){super.remove(),this.matrixCache=[],this.instGeom.dispose(),this.mesh.parent&&(this.mesh.parent.remove(this.mesh),this.wireframe.dispose()),this.stateSub.unsubscribe()}init(e=!1){if(this.maxInstancesPerLayer=we(this.pointer.origin),e){this.maxContentPerLayer=be(this.pointer.origin),this.minContentPerLayer=Ce(this.pointer.origin),this.maxErrorPerLayer=xe(this.pointer.origin,this.maxContentPerLayer),this.minErrorPerLayer=Se(this.pointer.origin,this.minContentPerLayer),this.setAvailableSets(this.pointer.origin),this.setAvailableArrays(this.pointer.origin);let e=Array(this.maxContentPerLayer.length);for(let t=0;t<this.maxContentPerLayer.length;t++)e[t]={},Object.keys(this.maxContentPerLayer[t]).forEach(n=>{e[t][n]={value:{min:this.minContentPerLayer[t][n],max:this.maxContentPerLayer[t][n]},error:{min:this.minErrorPerLayer[t][n],max:this.maxErrorPerLayer[t][n]}}});console.log(`minMaxValues: `,e),v(this.id).next({...v(this.id).getValue(),minMaxValue:e})}this.totalInstances=this.maxInstancesPerLayer.reduce((e,t)=>e*t,1),this.setupInsBufGeom(),this.wireframe=new Ae(this.maxInstancesPerLayer,this.matrixCache,this.config.wireframe,this.id)}setupMatrixCache(){this.matrixCache=Array(this.maxInstancesPerLayer.length-1);let e=this.availableSets.length>0;e&&(this.matrixCache[this.matrixCache.length-1]=Array(this.availableSets.length));let t=this.maxInstancesPerLayer[0];for(let n=0;n<this.maxInstancesPerLayer.length-1-(e?1:0);n++)this.matrixCache[n]={pos:new Float32Array(t*3),scale:new Float32Array(t*3),rendered:new Float32Array(t).fill(-1)},t*=this.maxInstancesPerLayer[n+1];if(!e)return;let n=this.matrixCache[this.matrixCache.length-1];for(let e=0;e<n.length;e++)n[e]={pos:new Float32Array(t*3),scale:new Float32Array(t*3),rendered:new Float32Array(t).fill(-1)}}setupInsBufGeom(){this.setupMatrixCache();let e=this.maxInstancesPerLayer.reduce((e,t)=>e*t,1);this.selectedSet.length>1&&(e*=this.selectedSet.length);let t=new r.BoxGeometry(1,1,1);this.instGeom=new r.InstancedBufferGeometry,this.instGeom.instanceCount=0,this.instGeom.frustumCulled=!1,this.instGeom.index=t.index;for(let e in t.attributes)this.instGeom.setAttribute(e,t.attributes[e]);this.material=this.createMaterial(),this.colorArray=new Float32Array(192),this.material.uniforms.colorArray={value:this.colorArray},Te(this.config,this.material,this.colorArray),this.instancePositions=new Float32Array(3),this.instanceScales=new Float32Array(3),this.instanceColors=new Float32Array(1),this.instGeom.setAttribute(`instancePosition`,new r.InstancedBufferAttribute(this.instancePositions,3)),this.instGeom.setAttribute(`instanceScale`,new r.InstancedBufferAttribute(this.instanceScales,3)),this.instGeom.setAttribute(`instanceColorIndex`,new r.InstancedBufferAttribute(this.instanceColors,1)),this.mesh=new r.Mesh(this.instGeom,this.material),this.mesh.raycast=this.raycastHandler,this.mesh.frustumCulled=!1,this.material.uniforms.colorArray={value:this.colorArray},this.mesh.material.uniformsNeedUpdate=!0}pushVisibleInstances(){let e=this.mesh.parent;e&&(e.remove(this.mesh),this.instGeom.dispose());let t=0;for(let e=0;e<this.matrixCache.length;e++){let n=this.matrixCache[e];if(Array.isArray(n))for(let e=0;e<n.length;e++){let r=n[e];for(let e=0;e<r.rendered.length;e++)r.rendered[e]!==-1&&t++}else for(let e=0;e<n.rendered.length;e++)n.rendered[e]!==-1&&t++}let n=new Float32Array(t*3),i=new Float32Array(t*3),a=new Float32Array(t),o=0;for(let e=0;e<this.matrixCache.length;e++){let t=this.matrixCache[e];if(Array.isArray(t))for(let e=0;e<t.length;e++){let r=t[e];for(let e=0;e<r.rendered.length;e++)r.rendered[e]!==-1&&(n[o*3]=r.pos[e*3],n[o*3+1]=r.pos[e*3+1],n[o*3+2]=r.pos[e*3+2],i[o*3]=r.scale[e*3],i[o*3+1]=r.scale[e*3+1],i[o*3+2]=r.scale[e*3+2],a[o++]=r.rendered[e])}else for(let e=0;e<t.rendered.length;e++)t.rendered[e]!==-1&&(n[o*3]=t.pos[e*3],n[o*3+1]=t.pos[e*3+1],n[o*3+2]=t.pos[e*3+2],i[o*3]=t.scale[e*3],i[o*3+1]=t.scale[e*3+1],i[o*3+2]=t.scale[e*3+2],a[o++]=t.rendered[e])}let s=new r.BoxGeometry(1,1,1);this.instGeom=new r.InstancedBufferGeometry,this.instGeom.instanceCount=t,this.instGeom.frustumCulled=!1,this.instGeom.index=s.index;let c=s.attributes;for(let e in c)this.instGeom.setAttribute(e,c[e]);this.instancePositions=n,this.instanceScales=i,this.instanceColors=a,this.instGeom.setAttribute(`instancePosition`,new r.InstancedBufferAttribute(n,3)),this.instGeom.setAttribute(`instanceScale`,new r.InstancedBufferAttribute(i,3)),this.instGeom.setAttribute(`instanceColorIndex`,new r.InstancedBufferAttribute(a,1)),this.mesh=new r.Mesh(this.instGeom,this.material),this.mesh.raycast=this.raycastHandler,this.mesh.frustumCulled=!1,e&&e.add(this.mesh)}setMatrixCacheAt(e,t,n,r,i){let a=t===null?this.matrixCache[e]:this.matrixCache[e][t];a.pos[n*3]=r.x.pos,a.pos[n*3+1]=r.y.pos,a.pos[n*3+2]=r.z.pos,a.scale[n*3]=r.x.size,a.scale[n*3+1]=r.y.size,a.scale[n*3+2]=r.z.size,a.rendered[n]=i}async renderHistogram(e,t,n){if(!this.pointer||n>=this.maxInstancesPerLayer.length-1)return;this.logRender({procedure:`render`,value:{startIndex:e,endIndex:t,layer:n}});let i={x:{size:0,pos:0},y:{size:0,pos:0},z:{size:0,pos:0}},a=async(e,t,o,s,c,l)=>{if(o>n||!s)return;let u=new U([s.fXaxis.fNbins,s.fYaxis.fNbins,s.fZaxis.fNbins]),d,f,p,m,h=s.fArrays?.[this.selectedArray]?.outside??!1,g=this.selectedSet.indexOf(l),_=this.availableSets.indexOf(l),v=s.fArrays?s.fArrays[Object.keys(s.fArrays)[0]].values:!1,y=this.config.scale.scaleBy===`value`;if(l)if(this.config.scale.sets===`fixed`)({min:d,max:f}=this.minMaxValue[o+this.pointer.parentPath.length][l].value),{min:m,max:p}=this.minMaxValue[o+this.pointer.parentPath.length][l].error;else if(this.config.scale.sets===`relative`){let e=s.fSumw2.filter(e=>e!==0),t=y?s.fArray.filter(e=>e!==0):e;d=Math.min(...t),f=Math.max(...t),p=this.maxErrorPerLayer[o+this.pointer.parentPath.length][l],m=this.minErrorPerLayer[o+this.pointer.parentPath.length][l]}else d=y?this.minContentPerLayer[o+this.pointer.parentPath.length][l]:-.1,f=y?this.maxContentPerLayer[o+this.pointer.parentPath.length][l]:this.maxErrorPerLayer[o+this.pointer.parentPath.length][l],p=this.maxErrorPerLayer[o+this.pointer.parentPath.length][l],m=this.minErrorPerLayer[o+this.pointer.parentPath.length][l];else if(this.selectedArray!==`content`&&s.fArrays&&v)if(this.config.scale.parameter===`fixed`)({min:d,max:f}=this.minMaxValue[o+this.pointer.parentPath.length][this.selectedArray].value),{min:m,max:p}=this.minMaxValue[o+this.pointer.parentPath.length][this.selectedArray].error;else if(this.config.scale.parameter===`relative`){let e=s.fArrays[this.selectedArray].errors.filter(e=>e!==0),t=y?s.fArrays[this.selectedArray].values.filter(e=>e!==0):e;d=Math.min(...t),f=Math.max(...t),p=this.maxErrorPerLayer[o+this.pointer.parentPath.length][this.selectedArray],m=this.minErrorPerLayer[o+this.pointer.parentPath.length][this.selectedArray]}else d=y?this.minContentPerLayer[0][this.selectedArray]:-.1,f=y?this.maxContentPerLayer[0][this.selectedArray]:this.maxErrorPerLayer[0][this.selectedArray],p=this.maxErrorPerLayer[0][this.selectedArray],m=this.minErrorPerLayer[0][this.selectedArray];else{let e=this.pointer.isOnSet??`content`;if(this.config.scale.content===`fixed`)({min:d,max:f}=this.minMaxValue[o+this.pointer.parentPath.length][e].value),{min:m,max:p}=this.minMaxValue[o+this.pointer.parentPath.length][e].error;else if(this.config.scale.content===`relative`){let t=s.fSumw2.filter(e=>e!==0),n=y?s.fArray.filter(e=>e!==0):t;d=Math.min(...n),f=Math.max(...n),p=this.maxErrorPerLayer[o+this.pointer.parentPath.length][e],m=this.minErrorPerLayer[o+this.pointer.parentPath.length][e]}else d=y?this.minContentPerLayer[o+this.pointer.parentPath.length][e]:-.1,f=y?this.maxContentPerLayer[o+this.pointer.parentPath.length][e]:this.maxErrorPerLayer[o+this.pointer.parentPath.length][e],p=this.maxErrorPerLayer[o+this.pointer.parentPath.length][e],m=this.minErrorPerLayer[o+this.pointer.parentPath.length][e]}d===f&&(d=f-.2);let b=s._typename.substring(0,3)===`TH3`,x=s._typename.substring(0,3)===`TH2`,S=s._typename.substring(0,3)===`TH1`,C=this.maxInstancesPerLayer.slice(o+1).reduce((e,t)=>e*t,1);u.setFromNumber(e/C);let w=this.config.padding.layer[o]??this.config.padding.default,T=!this.config.padding.layer[o]&&S?{x:w.x,y:w.y,z:w.z}:{...w};l&&this.config.padding.sets&&S&&(T={x:this.config.padding.sets.x,y:0,z:0}),this.pointer.isOnSet&&(T={x:0,y:0,z:0});let{min:E,max:D}=this.config.scale?.layer?.[o]?this.config.scale?.layer[o]:this.config.scale.default;for(let y=e;y<t;y+=C){let e={x:u.getValueAt(0),y:u.getValueAt(1),z:u.getValueAt(2)},S=he(c.position.z,c.scale.z,G(K(s,e,T,c?.scale,c?.position,o,i))),w=this.getBinContent(s,e.x,e.y,e.z,v?this.selectedArray:`content`),O=this.getBinError(s,e.x,e.y,e.z,v?this.selectedArray:`content`),k=this.config.scale.scaleBy===`value`?w:O,A=this.config.scale.scaleBy===`value`?d:m,j=this.config.scale.scaleBy===`value`?f:p;A===j&&(A-=A*.1);let M=1;if(k>=A==!h){let e=(k-A)/(j-A);if(!h)M=Number.isInteger(k)&&k===0&&this.config.scale.scaleBy===`value`?M=0:(D-E)*e+E,M>1&&(M=1);else{let e=(w-void 0)/(void 0-void 0);M=Number.isInteger(w)&&w===0?M=0:(D-E)*e+E}}else M=0;this.config.color.scaleBy===`value`?this.color=Ee(this.config.color,k,A,j,_,o):this.color=Ee(this.config.color,O,m,p,_,o);let N=S.y.size*M;if(M===0)S.x.size=0,S.z.size=0,S.y.size=0;else if(b)S.x.size*=M,S.z.size*=M,S.y.size=N;else if(x)S.y.pos-=(S.y.size-N)/2,S.y.size=N;else if(S.y.pos-=(S.y.size-N)/2,S.y.size=N,l){let e=this.config.TH1ZScale.set;S.z.size=e||.01}else this.config.TH1ZScale?.layer?.[o]?S.z.size=c.scale.z*this.config.TH1ZScale.layer[o]:S.z.size=c.scale.z*this.config.TH1ZScale.default;if(l)S.z.size=.01,S.z.pos+=(g-(this.selectedSet.length-1)/2)*.1,this.setMatrixCacheAt(o,_,y/C,S,o===n&&M!==0?this.color:-1);else{let e=null;this.pointer.isOnSet&&(S.z.size=.01,S.z.pos+=(g-(this.selectedSet.length-1)/2)*.1,e=this.availableSets.indexOf(this.pointer.isOnSet)),this.setMatrixCacheAt(o,e,y/C,S,o===n&&M!==0?this.color:-1)}if(o===n){let e=y;l&&(e+=this.totalInstances*g)}else{let n=s.getBin(e.x+1,e.y+1,e.z+1),i,c={position:new r.Vector3(S.x.pos,S.y.pos,S.z.pos),scale:new r.Vector3(S.x.size,S.y.size,S.z.size)};s.children.content?(i=s.children.content[n],a(y,t,o+1,i,c)):this.selectedSet.forEach(e=>{i=s.children[e][n],a(y,t,o+1,i,c,e)})}if(!u.increment())break}};this.pointer.isOnSet?await Promise.all(this.selectedSet.map(n=>a(e,t,0,X(this.pointer.rootObj,this.pointer.parentPath.map(e=>e.bin[0]),n),this.limits,n))):await a(e,t,0,this.pointer.origin,this.limits),this.pointer.isOnSet||this.wireframe.pushVisibleInstances(this.matrixCache,this.maxInstancesPerLayer,this.availableSets.indexOf(this.selectedSet[0])),this.pushVisibleInstances();let o=this.availableSets.indexOf(this.pointer.isOnSet)===-1?null:this.availableSets.indexOf(this.pointer.isOnSet);return this.BVHTree=ke(this.matrixCache,this.pointer.origin,0,this.selectedSet,o,this.availableSets,this.mesh.matrixWorld,this.maxInstancesPerLayer),this.mesh}createMaterial(){return new r.ShaderMaterial({vertexShader:`
|
|
58
58
|
attribute vec3 instancePosition;
|
|
59
59
|
attribute vec3 instanceScale;
|
|
60
60
|
attribute float instanceColorIndex;
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
void main() {
|
|
83
83
|
gl_FragColor = vec4(vColor, 1.0);
|
|
84
84
|
}
|
|
85
|
-
`,transparent:!1})}mouseClickDefault(e){this.showChildHistogram(e.index),e.selectedArray!==`content`&&e.jsrootObj?.fArrays[e.selectedArray]?.values&&(e.jsrootObj.fArray=e.jsrootObj.fArrays[e.selectedArray]?.values,e.jsrootObj.fSumw2=e.jsrootObj.fArrays[e.selectedArray]?.errors,e.jsrootObj.fMinimum=e.jsrootObj.fArrays[e.selectedArray]?.min,e.jsrootObj.fMaximum=e.jsrootObj.fArrays[e.selectedArray]?.max),F().next({id:this.id+`-cinema`,obj:e.jsrootObj})}getBinPosScaleByIndexMC(e,t){let n=t&&t!==`content`?this.matrixCache[e.length-1][this.availableSets.indexOf(t)]:this.matrixCache[e.length-1],r=e.at(-1)/this.maxInstancesPerLayer.slice(e.length).reduce((e,t)=>e*t,1)*3;return{position:n.pos.slice(r,r+3),scale:n.scale.slice(r,r+3)}}getBinPosScaleByIndex(e,t,n,r){let i=({scale:e,position:t})=>({scale:{x:e[0],y:e[1],z:e[2]},position:{x:t[0],y:t[1],z:t[2]}}),a=e.length-1,o=a===0?this.limits:i(this.getBinPosScaleByIndexMC(e.slice(0,-1),null)),s={x:{size:0,pos:0},y:{size:0,pos:0},z:{size:0,pos:0}},c=n._typename.substring(0,3)===`TH1`,l=this.config.padding.layer[a]??this.config.padding.default,u=!this.config.padding.layer[a]&&c?{x:l.x,y:l.y,z:l.z}:{...l};return t&&this.config.padding.sets&&c&&(u={x:this.config.padding.sets.x,y:0,z:0}),this.pointer.isOnSet&&(u={x:0,y:0,z:0}),he(o.position.z,o.scale.z,G(K(n,r,u,o?.scale,o?.position,a,s))),{position:[s.x.pos,s.y.pos,s.z.pos],scale:[s.x.size,s.y.size,s.z.size]}}mousemoveDefault(e){if(((e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.x!==i.x||r.y!==i.y||r.z!==i.z)return!1}return!0})(e.index,this.dirtyInstance)){this.dirtyInstance=null;return}let t=this.pointer.parentPath.map(e=>{let t=e.range[0];return{bin:e.bin[0],...t}});e.range=e.range.map((t,n)=>{let r=e.jsrootInstance[n];return{...t,bin:r}});let n={...e,level:t.length,range:t.concat(e.range)},{range:r,level:i,content:a,error:o,set:s,triggerSource:c,instanceId:l}=n,u={coords:r,level:i,content:a,error:o,set:s,triggerSource:c,instanceId:l,binPosSize:this.getBinPosScaleByIndexMC(n.instanceId,n.set),binWholePosSize:this.getBinPosScaleByIndex(n.instanceId,n.set,n.jsrootObj,n.index.at(-1))};z().next(u)}shiftMouseClickDefault(e){this.hideChildHistogram(e.index)}mouseDBClickDefault(e){e.set?this.setPointerToChild(e.index,e.set):this.setPointerToChild(e.index,this.selectedSet[0])}shiftMouseDBClickDefault(e){this.setPointerToParent()}intersectionHandler(e,t){this.mouseEvents.filter(e=>e.event===t).forEach(t=>t.function(e,this)),this.dirtyInstance=e.index}raycastHandler(e,t){try{let n=this.checkIntersectionBVH(e.ray)[0];if(n){let r=e._triggerSource;this.intersectionHandler(n,r),t.push(n)}}catch(e){console.log(e)}}handleStateChange(e){if(ge(e.sets,this.availableSets)&&(!ge(e.selectedSet,this.selectedSet)||this.selectedArray!==e.selectedArray)){this.selectedArray=e.selectedArray,this.selectedSet=e.selectedSet;let t=this.mesh.parent;this.instGeom.dispose(),t.remove(this.mesh),this.setupInsBufGeom(),t.add(this.mesh),this.renderHistogramHistory()}else this.minMaxValue.length!==0&&_e(e.minMaxValue,this.minMaxValue)?this.renderHistogramHistory():(this.availableSets=e.sets,this.selectedSet=e.selectedSet,this.minMaxValue=e.minMaxValue)}async renderHistogramHistory(){let e=this.renderHistory;this.renderHistory=[];for(let t of e)t.procedure===`render`?await this.renderHistogram(t.value.startIndex,t.value.endIndex,t.value.layer):t.procedure===`hide`&&this.hideChildHistogram(t.value)}async setPointerToChild(e,t){let n=this.mesh.parent;this.matrixCache=[],this.instGeom.dispose(),this.wireframe.dispose(),n.remove(this.mesh);let r=Y(e,t,this.pointer.origin,this.wireframe,this.selectedSet);if(this.pointer.setOriginToChild(J(e,this.pointer.origin,this.selectedSet),t,r),!this.pointer.isHistogramFilled){this.mesh=k(this.limits,this.setPointerToParent.bind(this)),n.add(this.mesh);return}this.init(!1),console.log(`path: `,this.pointer.path),console.log(`title: `,this.pointer.title),await this.renderHistogram(0,this.totalInstances,0),n.add(this.mesh),n.add(this.wireframe.wireframe),this.pointer.isOnSet&&this.wireframe.toggleVisibility(this.matrixCache,this.maxInstancesPerLayer,this.availableSets.indexOf(t))}async setPointerToParent(){let e=this.mesh.parent;e.remove(this.mesh),this.pointer.isHistogramFilled&&(this.matrixCache=[],this.instGeom.dispose(),this.wireframe.dispose()),this.pointer.setOriginToParent(1),console.log(`path: `,this.pointer.path),console.log(`title: `,this.pointer.title),this.init(!1),await this.renderHistogram(0,this.totalInstances,0),e.add(this.mesh),e.add(this.wireframe.wireframe)}showChildHistogram(e){let t=q(e,this.pointer.origin,this.maxInstancesPerLayer,this.selectedSet),n=this.maxInstancesPerLayer.slice(-this.maxInstancesPerLayer.length+e.length).reduce((e,t)=>e*t,1);this.renderHistogram(t.slice(-1)[0],t.slice(-1)[0]+n,e.length)}hideChildHistogram(e){if(e.length===1)return;let t=this.maxInstancesPerLayer.slice(e.length-1),n=this.maxInstancesPerLayer.slice(e.length-1,this.maxInstancesPerLayer.length-1),r=t.reduce((e,t)=>e*t,1),i=ve(e,this.pointer.origin,this.maxInstancesPerLayer,this.selectedSet),a=Math.floor(i/r)*r;this.clearMatrixCacheRange(a,r,n,e.length-1),this.logRender({procedure:`hide`,value:e}),this.renderHistogram(a,a+r,e.length-2),this.renderHistory.pop()}clearMatrixCacheRange(e,t,n,r){let i=e,a=t,o={x:{pos:0,size:0},y:{pos:0,size:0},z:{pos:0,size:0}};for(let e=r+n.length-1;e>=r;e--){if(Array.isArray(this.matrixCache[e]))for(let t=0;t<this.matrixCache[e].length;t++)for(let n=i;n<i+a;n++)this.setMatrixCacheAt(e,t,n,o,-1);else for(let t=i;t<i+a;t++)this.setMatrixCacheAt(e,null,t,o,-1);e>r&&(i/=n[e-r],a/=n[e-r])}}setAvailableSets(e){if(e.children?.content){let t=e.children.content.find(e=>e);this.setAvailableSets(t)}else if(e?.children){let t=v(this.id).getValue();t.sets=Object.keys(e.children),t.selectedSet.length===0?(this.selectedSet.push(t.sets[0]),t.selectedSet.push(t.sets[0])):this.selectedSet.every(e=>t.sets.find(t=>t===e))||(t.selectedSet=[t.sets[0]]),v(this.id).next(t)}else{let e=v(this.id).getValue();e.sets=[],e.selectedSet=[]}}setAvailableArrays(e){let t=v(this.id).getValue();t.arrays=[],e.fArrays&&(t.arrays=Object.keys(e.fArrays)),t.arrays.unshift(`content`);let n=e=>{let r=e.find(e=>e);r.fArrays&&(t.arrays=t.arrays.concat(Object.keys(r.fArrays))),r.children?.content&&n(r.children.content)};e.children?.content&&n(e.children.content),t.arrays=[...new Set(t.arrays)],v(this.id).next(t)}configSubjectHandler(e){this.config=L().mergeHistogramConfig(this?.opts?.config),this.keyBindings=T(e.config.bindings);let t=e.config.environment.histogramPads.find(e=>e.id===this.id);t&&!O(this.limits,t)&&this.renderHistory.length>0&&(this.limits={...t},this.renderHistogramHistory()),this.limits={...t}}keyDownHandler(e){let t=e.code.match(/^(?:Digit|Numpad)(\d+)$/);if(t){if(parseInt(t[1])>this.matrixCache.length)return;let e=new r.Object3D;e.scale.set(0,0,0),e.updateMatrix();let n=this.maxInstancesPerLayer.reduce((e,t)=>e*t,1);this.selectedSet.length>1&&(n*=this.selectedSet.length),this.setupMatrixCache(),this.wireframe.clearWireframe(),this.renderHistogram(0,this.totalInstances,parseInt(t[1])-1)}else e.key===this.keyBindings.hideOutlines?this.wireframe.toggleVisibility(this.matrixCache,this.maxInstancesPerLayer,this.availableSets.indexOf(this.selectedSet[0])):e.key===this.keyBindings.resetHistogram?this.resetHistogram():e.key===this.keyBindings.goToPreviousLayer&&this.setPointerToParent()}keyUpHandler(e){}resetHistogram(){this.updateHistogram({obj:this.rootObj})}logRender(e){e.procedure===`render`&&e.value.startIndex===0&&e.value.endIndex===this.totalInstances&&(this.renderHistory=[]),this.renderHistory.push(e)}getBinContent(e,t,n,r,i){if(i===`content`||!e.fArrays)return e.getBinContent(t+1,n+1,r+1);{let a=e.getBin(t+1,n+1,r+1);return e.fArrays?.[i].values[a]}}getBinError(e,t,n,r,i){let a=e.getBin(t+1,n+1,r+1);return i===`content`||!e.fArrays?e.fSumw2.length===0?e.getBinError(a):e.fSumw2[a]:e.fArrays?.[i].errors[a]}checkIntersectionBVH(e){let t=new r.Vector3,n=(e,t,n,i)=>{if(t<0||1/t==-1/0){let n=t*-1,a=i&&i!==`content`?this.matrixCache[e]?.[this.availableSets.indexOf(i)]:this.matrixCache[e];return a?new r.Box3().setFromCenterAndSize(new r.Vector3(a.pos[n*3],a.pos[n*3+1],a.pos[n*3+2]),new r.Vector3(a.scale[n*3],a.scale[n*3+1],a.scale[n*3+2])):void 0}else{let a=i&&i!==`content`?Array.isArray(this.BVHTree[e][this.availableSets.indexOf(i)])?this.BVHTree[e][this.availableSets.indexOf(i)][n]:this.BVHTree[e][this.availableSets.indexOf(i)]:this.BVHTree[e][n];return a?new r.Box3().setFromCenterAndSize(new r.Vector3(a.pos[t*3],a.pos[t*3+1],a.pos[t*3+2]),new r.Vector3(a.scale[t*3],a.scale[t*3+1],a.scale[t*3+2])):void 0}},i=(e,t)=>{let n=0,r=e,i=t;for(;r+1<this.matrixCache.length;){r++;let t=this.matrixCache[r];if(Array.isArray(t))this.selectedSet.forEach(a=>{let o=this.availableSets.indexOf(a);for(let a=i;a<i+this.maxInstancesPerLayer[r];a++)if(t[o].rendered[a]!==-1){n=r-e;break}});else{if(!t)return n;for(let a=i;a<i+this.maxInstancesPerLayer[r];a++)if(t.rendered[a]!==-1){n=r-e;break}}i*=this.maxInstancesPerLayer[r+1]}return n},a=(r,i,a,o)=>{let s=o&&o!==`content`?Array.isArray(this.BVHTree[a][this.availableSets.indexOf(o)])?this.BVHTree[a][this.availableSets.indexOf(o)][i]:this.BVHTree[a][this.availableSets.indexOf(o)]:this.BVHTree[a][i],c=n(a,s.left[r],i,o),l=n(a,s.right[r],i,o),u=[];return e.intersectBox(c,t)?u.push({index:s.left[r],target:t.clone(),distance:e.origin.distanceTo(t)}):u.push(null),e.intersectBox(l,t)?u.push({index:s.right[r],target:t.clone(),distance:e.origin.distanceTo(t)}):u.push(null),u},o=(e,t,n)=>{let r=[],i=o=>{if(o.index<0||1/o.index==-1/0){r.push(o);return}let[s,c]=a(o.index,t,e,n);s&&i(s),c&&i(c)},o=n&&n!==`content`?Array.isArray(this.BVHTree[e][this.availableSets.indexOf(n)])?this.BVHTree[e][this.availableSets.indexOf(n)][t]:this.BVHTree[e][this.availableSets.indexOf(n)]:this.BVHTree[e][t];return!o||o.length===0||i({index:o.left.length-1,target:null,distance:null}),r},s=(e,t,n=0,r=[],a=null)=>{let c=[],l=this.maxInstancesPerLayer[t+1],u=this.maxInstancesPerLayer[t]*this.maxInstancesPerLayer[t+1],d=e.fArrays[Object.keys(e.fArrays)[0]].values;return o(t,n,a).forEach(o=>{let f=Math.abs(o.index)-n*this.maxInstancesPerLayer[t],p=f%e.fXaxis.fNbins,m=Math.floor(f%(e.fXaxis.fNbins*e.fYaxis.fNbins)/e.fXaxis.fNbins),h=Math.floor(f/(e.fXaxis.fNbins*e.fYaxis.fNbins)),g=[...r,{x:p,y:m,z:h}];if(e.children){let r=Object.entries(e.children).flatMap(([r,a])=>{let c=e.getBin(p+1,m+1,h+1),d=a?.[c];if(!d||!(i(t,n*u+(p+m*e.fXaxis.fNbins+h*(e.fXaxis.fNbins*e.fYaxis.fNbins))*l,null)>0))return[];let f=s(d,t+1,Math.abs(o.index),g,r);return r!==`content`&&(f=f.map(e=>({...e,set:r}))),f});if(r.length>0)c.push(...r);else{let r=n*this.maxInstancesPerLayer[t]+(p+m*e.fXaxis.fNbins+h*(e.fXaxis.fNbins*e.fYaxis.fNbins));(a&&a!==`content`?this.matrixCache[t]?.[this.availableSets.indexOf(a)]:this.matrixCache[t]).rendered[r]!==-1&&c.push({index:g,target:o.target,distance:o.distance,set:a,selectedArray:this.selectedArray,instanceId:q(g,this.pointer.origin,this.maxInstancesPerLayer,this.selectedSet),jsrootInstance:J(g,this.pointer.origin,this.selectedSet),range:Y(g,a,this.pointer.origin,this.wireframe,this.selectedSet),origin:this,jsrootObj:e,content:this.getBinContent(e,p,m,h,d?this.selectedArray:`content`),error:this.getBinError(e,p,m,h,d?this.selectedArray:`content`)})}}else c.push({index:g,target:o.target,distance:o.distance,set:a,selectedArray:this.selectedArray,instanceId:q(g,this.pointer.origin,this.maxInstancesPerLayer,this.selectedSet),jsrootInstance:J(g,this.pointer.origin,this.selectedSet),range:Y(g,a,this.pointer.origin,this.wireframe,this.selectedSet),origin:this,object:this.mesh,jsrootObj:e,content:this.getBinContent(e,p,m,h,d?this.selectedArray:`content`),error:this.getBinError(e,p,m,h,d?this.selectedArray:`content`)})}),c.sort((e,t)=>e.distance-t.distance)};if(this.pointer.isOnSet===null)return s(this.pointer.origin,0,0,[],this.pointer.isOnSet);{let e=this.selectedSet.map(e=>s(X(this.pointer.rootObj,this.pointer.parentPath.map(e=>e.bin[0]),e),0,0,[],e)).filter(e=>e.length!==0),t=Math.min(...e.map(e=>e[0].distance));return e.find(e=>e[0].distance===t)??[]}}dispatchSubjectHandler(e){if(!e.event.jsrootInstance){let t=e.event.index.map(e=>({x:e.x-1,y:e.y-1,z:e.z-1})),n=this.pointer.getChildByPosition(J([...t]).slice(0,-1),e.event.set,this.selectedSet);e.event={index:t,set:e.event.set,jsrootInstance:J(t,this.pointer.origin,this.selectedSet),range:Y(t,e.event.set,this.pointer.origin,this.wireframe,this.selectedSet),origin:this,jsrootObj:n,content:this.getBinContent(n,t[0].x+1,t[0].y+1,t[0].z+1,n.fArrays[Object.keys(n.fArrays)[0]].values?this.selectedArray:`content`),error:n.getBinError(t[0].x+1,t[0].y+1,t[0].z+1)}}this.intersectionHandler(e.event,e.event.source)}},Ne=class{plane=void 0;cinemaSub=void 0;position;rotation;scale;id;configSub=void 0;constructor(e,i,a,o,s){let c=new r.PlaneGeometry(o.x,o.y),l=new r.MeshBasicMaterial({color:new r.Color().setHex(16777215),side:r.DoubleSide});this.plane||(this.plane=new r.Mesh(c,l),this.plane.position.set(i.x,i.y,i.z)),e&&this.updateTexture(e),this.id=s,this.position=i,this.rotation=a,this.scale=o,this.cinemaSub=F().getObservable().pipe((0,t.filter)(e=>e.id===this.id||e.id===`*`)).subscribe(e=>{let t=e.obj;(0,n.makeImage)({format:`png`,option:`pE`,object:t,width:1200,height:600}).then(e=>{this.updateTexture(e)})}),this.configSub=L().getObservable().pipe((0,t.filter)(e=>e.target.id.includes(`*`)||e.target.id.includes(this.id))).subscribe(e=>{let t=e.config.environment.canvasPads.filter(e=>e.id===this.id||e.id===`*`);t.length!==0&&(this.position=t[0].limits.position,this.rotation=t[0].limits.rotation,this.scale=t[0].limits.scale,this.updateMesh())})}updateMesh(){this.plane.scale.set(this.scale.x,this.scale.y,this.scale.z),this.plane.position.set(this.position.x,this.position.y,this.position.z);let e=Math.PI/180;this.plane.rotation.set(this.rotation.x*e,this.rotation.y*e,this.rotation.z*e)}updateTexture(e){if(!e){console.warn(`updateTexture called with null/undefined`);return}let t=new r.TextureLoader;if(typeof e==`string`&&(e.startsWith(`data:`)||e.startsWith(`http`)))t.load(e,e=>{this.plane.material.map=e,this.plane.material.needsUpdate=!0},void 0,e=>console.error(`Texture load failed`,e));else if(e instanceof HTMLImageElement){let t=new r.Texture(e);t.needsUpdate=!0,this.plane.material.map=t,this.plane.material.needsUpdate=!0}else console.error(`Unsupported image type passed to updateTexture:`,e)}remove(){this.plane.parent&&(this.plane.parent.remove(this.plane),this.cinemaSub.unsubscribe(),this.configSub.unsubscribe())}getPlane(){return this.plane}},Pe=class extends r.Loader{constructor(e){super(e)}load(e,t,n,i){let a=this,o=new r.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(e){let n=a.parse(JSON.parse(e));t&&t(n)},n,i)}parse(e){return new Fe(e)}},Fe=class{constructor(e){this.isFont=!0,this.type=`Font`,this.data=e}generateShapes(e,t=100,n=`ltr`){let r=[],i=Ie(e,t,this.data,n);for(let e=0,t=i.length;e<t;e++)r.push(...i[e].toShapes());return r}};function Ie(e,t,n,r){let i=Array.from(e),a=t/n.resolution,o=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*a,s=[],c=0,l=0;(r==`rtl`||r==`tb`)&&i.reverse();for(let e=0;e<i.length;e++){let t=i[e];if(t===`
|
|
85
|
+
`,transparent:!1})}mouseClickDefault(e){this.showChildHistogram(e.index),e.selectedArray!==`content`&&e.jsrootObj?.fArrays[e.selectedArray]?.values&&(e.jsrootObj.fArray=e.jsrootObj.fArrays[e.selectedArray]?.values,e.jsrootObj.fSumw2=e.jsrootObj.fArrays[e.selectedArray]?.errors,e.jsrootObj.fMinimum=e.jsrootObj.fArrays[e.selectedArray]?.min,e.jsrootObj.fMaximum=e.jsrootObj.fArrays[e.selectedArray]?.max),F().next({id:this.id+`-cinema`,obj:e.jsrootObj})}getBinPosScaleByIndexMC(e,t){let n=t&&t!==`content`?this.matrixCache[e.length-1][this.availableSets.indexOf(t)]:this.matrixCache[e.length-1],r=e.at(-1)/this.maxInstancesPerLayer.slice(e.length).reduce((e,t)=>e*t,1)*3;return{position:n.pos.slice(r,r+3),scale:n.scale.slice(r,r+3)}}getBinPosScaleByIndex(e,t,n,r){let i=({scale:e,position:t})=>({scale:{x:e[0],y:e[1],z:e[2]},position:{x:t[0],y:t[1],z:t[2]}}),a=e.length-1,o=a===0?this.limits:i(this.getBinPosScaleByIndexMC(e.slice(0,-1),null)),s={x:{size:0,pos:0},y:{size:0,pos:0},z:{size:0,pos:0}},c=n._typename.substring(0,3)===`TH1`,l=this.config.padding.layer[a]??this.config.padding.default,u=!this.config.padding.layer[a]&&c?{x:l.x,y:l.y,z:l.z}:{...l};return t&&this.config.padding.sets&&c&&(u={x:this.config.padding.sets.x,y:0,z:0}),this.pointer.isOnSet&&(u={x:0,y:0,z:0}),he(o.position.z,o.scale.z,G(K(n,r,u,o?.scale,o?.position,a,s))),{position:[s.x.pos,s.y.pos,s.z.pos],scale:[s.x.size,s.y.size,s.z.size]}}mousemoveDefault(e){if(((e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.x!==i.x||r.y!==i.y||r.z!==i.z)return!1}return!0})(e.index,this.dirtyInstance)){this.dirtyInstance=null;return}let t=this.pointer.parentPath.map(e=>{let t=e.range[0];return{bin:e.bin[0],...t}});e.range=e.range.map((t,n)=>{let r=e.jsrootInstance[n];return{...t,bin:r}});let n={...e,level:t.length,range:t.concat(e.range)},{range:r,level:i,content:a,error:o,set:s,triggerSource:c,instanceId:l}=n,u={coords:r,level:i,content:a,error:o,set:s,triggerSource:c,instanceId:l,binPosSize:this.getBinPosScaleByIndexMC(n.instanceId,n.set),binWholePosSize:this.getBinPosScaleByIndex(n.instanceId,n.set,n.jsrootObj,n.index.at(-1))};z().next(u)}shiftMouseClickDefault(e){this.hideChildHistogram(e.index)}mouseDBClickDefault(e){e.set?this.setPointerToChild(e.index,e.set):this.setPointerToChild(e.index,this.selectedSet[0])}shiftMouseDBClickDefault(e){this.setPointerToParent()}intersectionHandler(e,t){this.mouseEvents.filter(e=>e.event===t).forEach(t=>t.function(e,this)),this.dirtyInstance=e.index}raycastHandler(e,t){try{let n=this.checkIntersectionBVH(e.ray)[0];if(n){let r=e._triggerSource;this.intersectionHandler(n,r),t.push(n)}}catch(e){console.log(e)}}handleStateChange(e){if(ge(e.sets,this.availableSets)&&(!ge(e.selectedSet,this.selectedSet)||this.selectedArray!==e.selectedArray)){this.selectedArray=e.selectedArray,this.selectedSet=e.selectedSet;let t=this.mesh.parent;this.instGeom.dispose(),t.remove(this.mesh),this.setupInsBufGeom(),t.add(this.mesh),this.renderHistogramHistory()}else this.minMaxValue.length!==0&&_e(e.minMaxValue,this.minMaxValue)?this.renderHistogramHistory():(this.availableSets=e.sets,this.selectedSet=e.selectedSet,this.minMaxValue=e.minMaxValue)}async renderHistogramHistory(){let e=this.renderHistory;this.renderHistory=[];for(let t of e)t.procedure===`render`?await this.renderHistogram(t.value.startIndex,t.value.endIndex,t.value.layer):t.procedure===`hide`&&this.hideChildHistogram(t.value)}async setPointerToChild(e,t){let n=this.mesh.parent;this.matrixCache=[],this.instGeom.dispose(),this.wireframe.dispose(),n.remove(this.mesh);let r=Y(e,t,this.pointer.origin,this.wireframe,this.selectedSet);if(this.pointer.setOriginToChild(J(e,this.pointer.origin,this.selectedSet),t,r),!this.pointer.isHistogramFilled){this.mesh=k(this.limits,this.setPointerToParent.bind(this)),n.add(this.mesh);return}this.init(!1),console.log(`path: `,this.pointer.path),console.log(`title: `,this.pointer.title),await this.renderHistogram(0,this.totalInstances,0),n.add(this.mesh),n.add(this.wireframe.wireframe),this.pointer.isOnSet&&this.wireframe.toggleVisibility(this.matrixCache,this.maxInstancesPerLayer,this.availableSets.indexOf(t))}async setPointerToParent(){let e=this.mesh.parent;e.remove(this.mesh),this.pointer.isHistogramFilled&&(this.matrixCache=[],this.instGeom.dispose(),this.wireframe.dispose()),this.pointer.setOriginToParent(1),console.log(`path: `,this.pointer.path),console.log(`title: `,this.pointer.title),this.init(!1),await this.renderHistogram(0,this.totalInstances,0),e.add(this.mesh),e.add(this.wireframe.wireframe)}showChildHistogram(e){let t=q(e,this.pointer.origin,this.maxInstancesPerLayer,this.selectedSet),n=this.maxInstancesPerLayer.slice(-this.maxInstancesPerLayer.length+e.length).reduce((e,t)=>e*t,1);this.renderHistogram(t.slice(-1)[0],t.slice(-1)[0]+n,e.length)}hideChildHistogram(e){if(e.length===1)return;let t=this.maxInstancesPerLayer.slice(e.length-1),n=this.maxInstancesPerLayer.slice(e.length-1,this.maxInstancesPerLayer.length-1),r=t.reduce((e,t)=>e*t,1),i=ve(e,this.pointer.origin,this.maxInstancesPerLayer,this.selectedSet),a=Math.floor(i/r)*r;this.clearMatrixCacheRange(a,r,n,e.length-1),this.logRender({procedure:`hide`,value:e}),this.renderHistogram(a,a+r,e.length-2),this.renderHistory.pop()}clearMatrixCacheRange(e,t,n,r){let i=e,a=t,o={x:{pos:0,size:0},y:{pos:0,size:0},z:{pos:0,size:0}};for(let e=r+n.length-1;e>=r;e--){if(Array.isArray(this.matrixCache[e]))for(let t=0;t<this.matrixCache[e].length;t++)for(let n=i;n<i+a;n++)this.setMatrixCacheAt(e,t,n,o,-1);else for(let t=i;t<i+a;t++)this.setMatrixCacheAt(e,null,t,o,-1);e>r&&(i/=n[e-r],a/=n[e-r])}}setAvailableSets(e){if(e.children?.content){let t=e.children.content.find(e=>e);this.setAvailableSets(t)}else if(e?.children){let t=v(this.id).getValue();t.sets=Object.keys(e.children),t.selectedSet.length===0?(this.selectedSet.push(t.sets[0]),t.selectedSet.push(t.sets[0])):this.selectedSet.every(e=>t.sets.find(t=>t===e))||(t.selectedSet=[t.sets[0]]),v(this.id).next(t)}else{let e=v(this.id).getValue();e.sets=[],e.selectedSet=[]}}setAvailableArrays(e){let t=v(this.id).getValue();t.arrays=[],e.fArrays&&(t.arrays=Object.keys(e.fArrays)),t.arrays.unshift(`content`);let n=e=>{let r=e.find(e=>e);r.fArrays&&(t.arrays=t.arrays.concat(Object.keys(r.fArrays))),r.children?.content&&n(r.children.content)};e.children?.content&&n(e.children.content),t.arrays=[...new Set(t.arrays)],v(this.id).next(t)}configSubjectHandler(e){this.config=L().mergeHistogramConfig(this?.opts?.config),this.keyBindings=T(e.config.bindings);let t=e.config.environment.histogramPads.find(e=>e.id===this.id);t&&!O(this.limits,t)&&this.renderHistory.length>0&&(this.limits={...t},this.renderHistogramHistory()),this.limits={...t}}keyDownHandler(e){let t=e.code.match(/^(?:Digit|Numpad)(\d+)$/);if(t){if(parseInt(t[1])>this.matrixCache.length)return;let e=new r.Object3D;e.scale.set(0,0,0),e.updateMatrix();let n=this.maxInstancesPerLayer.reduce((e,t)=>e*t,1);this.selectedSet.length>1&&(n*=this.selectedSet.length),this.setupMatrixCache(),this.wireframe.clearWireframe(),this.renderHistogram(0,this.totalInstances,parseInt(t[1])-1)}else e.key===this.keyBindings.hideOutlines?this.wireframe.toggleVisibility(this.matrixCache,this.maxInstancesPerLayer,this.availableSets.indexOf(this.selectedSet[0])):e.key===this.keyBindings.resetHistogram?this.resetHistogram():e.key===this.keyBindings.goToPreviousLayer&&this.setPointerToParent()}keyUpHandler(e){}resetHistogram(){this.updateHistogram({obj:this.rootObj})}logRender(e){e.procedure===`render`&&e.value.startIndex===0&&e.value.endIndex===this.totalInstances&&(this.renderHistory=[]),this.renderHistory.push(e)}getBinContent(e,t,n,r,i){if(i===`content`||!e.fArrays)return e.getBinContent(t+1,n+1,r+1);{let a=e.getBin(t+1,n+1,r+1);return e.fArrays?.[i].values[a]}}getBinError(e,t,n,r,i){let a=e.getBin(t+1,n+1,r+1);return i===`content`||!e.fArrays?e.fSumw2.length===0?e.getBinError(a):e.fSumw2[a]:e.fArrays?.[i].errors[a]}checkIntersectionBVH(e){let t=new r.Vector3,n=(e,t,n,i)=>{if(t<0||1/t==-1/0){let n=t*-1,a=i&&i!==`content`?this.matrixCache[e]?.[this.availableSets.indexOf(i)]:this.matrixCache[e];return a?new r.Box3().setFromCenterAndSize(new r.Vector3(a.pos[n*3],a.pos[n*3+1],a.pos[n*3+2]),new r.Vector3(a.scale[n*3],a.scale[n*3+1],a.scale[n*3+2])):void 0}else{let a=i&&i!==`content`?Array.isArray(this.BVHTree[e][this.availableSets.indexOf(i)])?this.BVHTree[e][this.availableSets.indexOf(i)][n]:this.BVHTree[e][this.availableSets.indexOf(i)]:this.BVHTree[e][n];return a?new r.Box3().setFromCenterAndSize(new r.Vector3(a.pos[t*3],a.pos[t*3+1],a.pos[t*3+2]),new r.Vector3(a.scale[t*3],a.scale[t*3+1],a.scale[t*3+2])):void 0}},i=(e,t)=>{let n=0,r=e,i=t;for(;r+1<this.matrixCache.length;){r++;let t=this.matrixCache[r];if(Array.isArray(t))this.selectedSet.forEach(a=>{let o=this.availableSets.indexOf(a);for(let a=i;a<i+this.maxInstancesPerLayer[r];a++)if(t[o].rendered[a]!==-1){n=r-e;break}});else{if(!t)return n;for(let a=i;a<i+this.maxInstancesPerLayer[r];a++)if(t.rendered[a]!==-1){n=r-e;break}}i*=this.maxInstancesPerLayer[r+1]}return n},a=(r,i,a,o)=>{let s=o&&o!==`content`?Array.isArray(this.BVHTree[a][this.availableSets.indexOf(o)])?this.BVHTree[a][this.availableSets.indexOf(o)][i]:this.BVHTree[a][this.availableSets.indexOf(o)]:this.BVHTree[a][i],c=n(a,s.left[r],i,o),l=n(a,s.right[r],i,o),u=[];return e.intersectBox(c,t)?u.push({index:s.left[r],target:t.clone(),distance:e.origin.distanceTo(t)}):u.push(null),e.intersectBox(l,t)?u.push({index:s.right[r],target:t.clone(),distance:e.origin.distanceTo(t)}):u.push(null),u},o=(e,t,n)=>{let r=[],i=o=>{if(o.index<0||1/o.index==-1/0){r.push(o);return}let[s,c]=a(o.index,t,e,n);s&&i(s),c&&i(c)},o=n&&n!==`content`?Array.isArray(this.BVHTree[e][this.availableSets.indexOf(n)])?this.BVHTree[e][this.availableSets.indexOf(n)][t]:this.BVHTree[e][this.availableSets.indexOf(n)]:this.BVHTree[e][t];return!o||o.length===0||i({index:o.left.length-1,target:null,distance:null}),r},s=(e,t,n=0,r=[],a=null)=>{let c=[],l=this.maxInstancesPerLayer[t+1],u=this.maxInstancesPerLayer[t]*this.maxInstancesPerLayer[t+1],d=e.fArrays?e.fArrays[Object.keys(e.fArrays)[0]].values:!1;return o(t,n,a).forEach(o=>{let f=Math.abs(o.index)-n*this.maxInstancesPerLayer[t],p=f%e.fXaxis.fNbins,m=Math.floor(f%(e.fXaxis.fNbins*e.fYaxis.fNbins)/e.fXaxis.fNbins),h=Math.floor(f/(e.fXaxis.fNbins*e.fYaxis.fNbins)),g=[...r,{x:p,y:m,z:h}];if(e.children){let r=Object.entries(e.children).flatMap(([r,a])=>{let c=e.getBin(p+1,m+1,h+1),d=a?.[c];if(!d||!(i(t,n*u+(p+m*e.fXaxis.fNbins+h*(e.fXaxis.fNbins*e.fYaxis.fNbins))*l,null)>0))return[];let f=s(d,t+1,Math.abs(o.index),g,r);return r!==`content`&&(f=f.map(e=>({...e,set:r}))),f});if(r.length>0)c.push(...r);else{let r=n*this.maxInstancesPerLayer[t]+(p+m*e.fXaxis.fNbins+h*(e.fXaxis.fNbins*e.fYaxis.fNbins));(a&&a!==`content`?this.matrixCache[t]?.[this.availableSets.indexOf(a)]:this.matrixCache[t]).rendered[r]!==-1&&c.push({index:g,target:o.target,distance:o.distance,set:a,selectedArray:this.selectedArray,instanceId:q(g,this.pointer.origin,this.maxInstancesPerLayer,this.selectedSet),jsrootInstance:J(g,this.pointer.origin,this.selectedSet),range:Y(g,a,this.pointer.origin,this.wireframe,this.selectedSet),origin:this,jsrootObj:e,content:this.getBinContent(e,p,m,h,d?this.selectedArray:`content`),error:this.getBinError(e,p,m,h,d?this.selectedArray:`content`)})}}else c.push({index:g,target:o.target,distance:o.distance,set:a,selectedArray:this.selectedArray,instanceId:q(g,this.pointer.origin,this.maxInstancesPerLayer,this.selectedSet),jsrootInstance:J(g,this.pointer.origin,this.selectedSet),range:Y(g,a,this.pointer.origin,this.wireframe,this.selectedSet),origin:this,object:this.mesh,jsrootObj:e,content:this.getBinContent(e,p,m,h,d?this.selectedArray:`content`),error:this.getBinError(e,p,m,h,d?this.selectedArray:`content`)})}),c.sort((e,t)=>e.distance-t.distance)};if(this.pointer.isOnSet===null)return s(this.pointer.origin,0,0,[],this.pointer.isOnSet);{let e=this.selectedSet.map(e=>s(X(this.pointer.rootObj,this.pointer.parentPath.map(e=>e.bin[0]),e),0,0,[],e)).filter(e=>e.length!==0),t=Math.min(...e.map(e=>e[0].distance));return e.find(e=>e[0].distance===t)??[]}}dispatchSubjectHandler(e){if(!e.event.jsrootInstance){let t=e.event.index.map(e=>({x:e.x-1,y:e.y-1,z:e.z-1})),n=this.pointer.getChildByPosition(J([...t]).slice(0,-1),e.event.set,this.selectedSet);e.event={index:t,set:e.event.set,jsrootInstance:J(t,this.pointer.origin,this.selectedSet),range:Y(t,e.event.set,this.pointer.origin,this.wireframe,this.selectedSet),origin:this,jsrootObj:n,content:this.getBinContent(n,t[0].x+1,t[0].y+1,t[0].z+1,n.fArrays[Object.keys(n.fArrays)[0]].values?this.selectedArray:`content`),error:n.getBinError(t[0].x+1,t[0].y+1,t[0].z+1)}}this.intersectionHandler(e.event,e.event.source)}},Ne=class{plane=void 0;cinemaSub=void 0;position;rotation;scale;id;configSub=void 0;constructor(e,i,a,o,s){let c=new r.PlaneGeometry(o.x,o.y),l=new r.MeshBasicMaterial({color:new r.Color().setHex(16777215),side:r.DoubleSide});this.plane||(this.plane=new r.Mesh(c,l),this.plane.position.set(i.x,i.y,i.z)),e&&this.updateTexture(e),this.id=s,this.position=i,this.rotation=a,this.scale=o,this.cinemaSub=F().getObservable().pipe((0,t.filter)(e=>e.id===this.id||e.id===`*`)).subscribe(e=>{let t=e.obj;(0,n.makeImage)({format:`png`,option:`pE`,object:t,width:1200,height:600}).then(e=>{this.updateTexture(e)})}),this.configSub=L().getObservable().pipe((0,t.filter)(e=>e.target.id.includes(`*`)||e.target.id.includes(this.id))).subscribe(e=>{let t=e.config.environment.canvasPads.filter(e=>e.id===this.id||e.id===`*`);t.length!==0&&(this.position=t[0].limits.position,this.rotation=t[0].limits.rotation,this.scale=t[0].limits.scale,this.updateMesh())})}updateMesh(){this.plane.scale.set(this.scale.x,this.scale.y,this.scale.z),this.plane.position.set(this.position.x,this.position.y,this.position.z);let e=Math.PI/180;this.plane.rotation.set(this.rotation.x*e,this.rotation.y*e,this.rotation.z*e)}updateTexture(e){if(!e){console.warn(`updateTexture called with null/undefined`);return}let t=new r.TextureLoader;if(typeof e==`string`&&(e.startsWith(`data:`)||e.startsWith(`http`)))t.load(e,e=>{this.plane.material.map=e,this.plane.material.needsUpdate=!0},void 0,e=>console.error(`Texture load failed`,e));else if(e instanceof HTMLImageElement){let t=new r.Texture(e);t.needsUpdate=!0,this.plane.material.map=t,this.plane.material.needsUpdate=!0}else console.error(`Unsupported image type passed to updateTexture:`,e)}remove(){this.plane.parent&&(this.plane.parent.remove(this.plane),this.cinemaSub.unsubscribe(),this.configSub.unsubscribe())}getPlane(){return this.plane}},Pe=class extends r.Loader{constructor(e){super(e)}load(e,t,n,i){let a=this,o=new r.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(e){let n=a.parse(JSON.parse(e));t&&t(n)},n,i)}parse(e){return new Fe(e)}},Fe=class{constructor(e){this.isFont=!0,this.type=`Font`,this.data=e}generateShapes(e,t=100,n=`ltr`){let r=[],i=Ie(e,t,this.data,n);for(let e=0,t=i.length;e<t;e++)r.push(...i[e].toShapes());return r}};function Ie(e,t,n,r){let i=Array.from(e),a=t/n.resolution,o=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*a,s=[],c=0,l=0;(r==`rtl`||r==`tb`)&&i.reverse();for(let e=0;e<i.length;e++){let t=i[e];if(t===`
|
|
86
86
|
`)c=0,l-=o;else{let e=Le(t,a,c,l,n);r==`tb`?(c=0,l+=n.ascender*a):c+=e.offsetX,s.push(e.path)}}return s}function Le(e,t,n,i,a){let o=a.glyphs[e]||a.glyphs[`?`];if(!o){console.error(`THREE.Font: character "`+e+`" does not exists in font family `+a.familyName+`.`);return}let s=new r.ShapePath,c,l,u,d,f,p,m,h;if(o.o){let e=o._cachedOutline||=o.o.split(` `);for(let r=0,a=e.length;r<a;)switch(e[r++]){case`m`:c=e[r++]*t+n,l=e[r++]*t+i,s.moveTo(c,l);break;case`l`:c=e[r++]*t+n,l=e[r++]*t+i,s.lineTo(c,l);break;case`q`:u=e[r++]*t+n,d=e[r++]*t+i,f=e[r++]*t+n,p=e[r++]*t+i,s.quadraticCurveTo(f,p,u,d);break;case`b`:u=e[r++]*t+n,d=e[r++]*t+i,f=e[r++]*t+n,p=e[r++]*t+i,m=e[r++]*t+n,h=e[r++]*t+i,s.bezierCurveTo(f,p,m,h,u,d);break}}return{offsetX:o.ha*t,path:s}}var Re=class{constructor(e,n={}){this.camera=e,this.options={backgroundColor:11184810,textColor:1,titleColor:0,padding:.002,lineHeight:.002,textSize:10,width:.031,...n},this.loader=new Pe,this.queue=new t.Subject;let i=!1,a=null;this.queueSub=this.queue.pipe((0,t.concatMap)(e=>i?(a=e,t.EMPTY):(i=!0,(0,t.from)(this.updateVisualization(e)).pipe((0,t.finalize)(()=>{if(i=!1,a){let e=a;a=null,this.queue.next(e)}}))))).subscribe(),this.group=new r.Group}parseData(e){let t=[];if(e.title&&t.push({text:e.title,isTitle:!0}),e.coords&&Array.isArray(e.coords)&&e.coords.forEach(e=>{Object.entries(e).forEach(([e,n])=>{if(n&&typeof n==`object`&&!(`isColor`in n)){let r=`${e} = [${n.min.toFixed(2)}, ${n.max.toFixed(2)})`;t.push({text:r,isTitle:!1})}})}),e.index&&Array.isArray(e.index)&&e.index.forEach(n=>{let r=`bin = ${e.object.bins[e.instanceId]}`;Object.entries(n).forEach(([e,t])=>{r+=`, ${e}: ${t}`}),t.push({text:r,isTitle:!1})}),e.content!==void 0){let n=Number.isInteger(e.content)?`content = ${e.content}`:`content = ${e.content.toFixed(2)}`;t.push({text:n,isTitle:!1})}if(e.error!==void 0){let n=Number.isInteger(e.error)?`error = ${e.error}`:`error = ${e.error.toFixed(2)}`;t.push({text:n,isTitle:!1})}return t}createBackgroundPanel(e){let{width:t,backgroundColor:n}=this.options;return new r.Mesh(new r.PlaneGeometry(t,e),new r.MeshBasicMaterial({color:n,side:r.DoubleSide}))}async updateVisualization(e){for(e===null&&this.clear();this.group.children.length>0;){let e=this.group.children[0];e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose(),this.group.remove(e)}let t=this.parseData(e);if(t.length===0)return;let{padding:i,lineHeight:a,textSize:o,textColor:s,titleColor:c,width:l}=this.options,u=t.length*a+i*2,d=this.createBackgroundPanel(u);this.group.add(d);let f=u/2-i-a/2;for(let e=0;e<t.length;e++){let r=t[e],u=f-e*a;try{let e=(0,n.create)(`TLatex`);e.fTitle=r.text,e.fTextAlign=12,e.fTextFont=2,e.fTitleFont=2,e.fLabelFont=2,e.fTextColor=r.isTitle?c:s,e.fTextSize=r.isTitle?o+2:o;let t=await(0,n.build3d)(e,`p`,u*100,``,``);t.scale.set(16e-5,16e-5,16e-5),t.position.x=-(l/2)+i,t.position.y=u,t.position.z=.001,this.group.add(t)}catch(e){console.error(`Error creating text line:`,e)}}let p=new r.Vector3(e.point.x,e.point.y,e.point.z);this.camera.worldToLocal(p);let m=new r.Vector3().subVectors(p,this.camera.position).normalize(),h=new r.Vector3().copy(this.camera.position).addScaledVector(m,.1),g=new r.Box3().setFromObject(this.group),_=new r.Vector3;g.getSize(_);let v=_.clone().multiplyScalar(.5);h.add(new r.Vector3(v.x,v.y,0)),this.group.position.copy(h),this.camera.add(this.group)}getGroup(){return this.group}setPosition(e,t,n){this.group.position.set(e,t,n)}setRotation(e,t,n){this.group.rotation.set(e,t,n)}clear(){for(;this.group.children.length>0;){let e=this.group.children[0];e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose(),this.group.remove(e)}}dispose(){for(this.queueSub.unsubscribe();this.group.children.length>0;){let e=this.group.children[0];e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose(),this.group.remove(e)}}},ze=class{histogramGroup=void 0;binInfoComponent=void 0;id=void 0;configSub=void 0;rootObj=void 0;histoSub=void 0;dummyEl=void 0;defaultRaycastHandler=void 0;mouseEvents=[];color=new r.Color;colorTarget=new r.Color(65535);buildPromise=void 0;constructor(e,n,i){this.id=e,this.rootObj=n,this.camera=i,this.histogramGroup=new r.Group,this.dummyEl=document.getElementById(`dummyDiv`+e),this.dummyEl&&document.body.removeChild(this.dummyEl),this.binInfoComponent=new Re(this.camera,{backgroundColor:3556687,textColor:0,titleColor:0}),this.dummyEl=document.createElement(`div`),this.dummyEl.id=`dummyDiv`+e,document.body.appendChild(this.dummyEl),this.configSub=L().getObservable().pipe((0,t.filter)(e=>e.target.id.includes(`*`)||e.target.id.includes(this.id))).subscribe(e=>{this.config={...e.config};let t=this.config.environment.histogramPads.find(e=>e.id===this.id).position;this.histogramGroup.position.set(t.x,t.y,t.z)}),this.sub=x().getObservable().pipe((0,t.filter)(e=>e.target.id.includes(`*`)||e.target.id.includes(this.id))).subscribe(e=>{if(e.flag===`add`)if(e.function)this.addEvent(e.event,e.function);else switch(e.event){case`mousemove`:this.addEvent(e.event,this.mousemoveDefault);break;case`mouseclick`:this.addEvent(e.event,this.mouseClickDefault);break;case`shiftmouseclick`:this.addEvent(e.event,this.shiftMouseClickDefault);break;case`mousedbclick`:this.addEvent(e.event,this.mouseDBClickDefault);break;case`shiftmousedbclick`:this.addEvent(e.event,this.shiftMouseDBClickDefault);break}else if(e.flag===`remove`&&e.function)this.removeEvent(e.event,e.function);else if(e.flag===`remove`)switch(e?.state){case`keydown`:this.keydownEvents=[];break;case`keyup`:this.keyupEvents=[];break;default:this.mouseEvents=this.mouseEvents.filter(t=>t.event!==e.event),this.mousemoveDefault({object:this.getInstancedMesh(),instanceId:null})}else e.flag===`removeAll`&&(this.keydownEvents=[],this.keyupEvents=[],this.mouseEvents=[])}),this.raycastHandler=this.raycastHandler.bind(this),this.mouseClickDefault=this.mouseClickDefault.bind(this),this.mousemoveDefault=this.mousemoveDefault.bind(this),this.shiftMouseClickDefault=this.shiftMouseClickDefault.bind(this),this.mouseDBClickDefault=this.mouseDBClickDefault.bind(this),this.shiftMouseDBClickDefault=this.shiftMouseDBClickDefault.bind(this),this.addEvent(`mouseclick`,this.mouseClickDefault),this.addEvent(`mousemove`,this.mousemoveDefault),this.addEvent(`shiftmouseclick`,this.shiftMouseClickDefault),this.addEvent(`mousedbclick`,this.mouseDBClickDefault),this.addEvent(`shiftmousedbclick`,this.shiftMouseDBClickDefault),this.buildPromise=this.renderWithBuild3d()}updateHistogram(e){this.rootObj=e,this.histogramGroup.clear(),this.buildPromise=this.renderWithBuild3d()}renderWithBuild3d(){return(0,n.build3d)(this.rootObj).then(e=>{let t=this.config.environment.histogramPads.find(e=>e.id===this.id)?.scale,n=new r.Box3().setFromObject(e),i=new r.Vector3;n.getSize(i),e.scale.set(t.x/i.x,t.z/i.y,t.y/i.z),e.rotateX(-Math.PI/2),e.translateZ(-(t.y/2)),this.histogramGroup.add(e);let a=this.getInstancedMesh();a&&(this.defaultRaycastHandler=a.raycast.bind(a),a.raycast=this.raycastHandler.bind(this))}).catch(e=>{let t=this.config.environment.histogramPads.find(e=>e.id===this.id);throw console.log(`JSROOT was not able to build object: `,e,t),{message:e,scale:t?.scale,position:t?.position}})}raycastHandler(e,t){this.defaultRaycastHandler(e,t),setTimeout(()=>{let n=t.filter(e=>e.instanceId!==void 0).sort((e,t)=>e.distance-t.distance)[0];if(!n){this.mouseEvents.filter(e=>e.event===`mousemove`).forEach(e=>e.function({instanceId:void 0,object:this.getInstancedMesh()},this));return}let r=n.object.bins[n.instanceId],i=this.rootObj.fXaxis.fNbins+2,a=this.rootObj.fYaxis.fNbins+2,o={x:r%i,y:Math.floor(r%(i*a)/i),z:Math.floor(r/(i*a))},s=this.getRangeByPosition([o]),c=this.rootObj.fName,l={...n,index:[o],coords:[{...s,bin:r,name:c}],content:this.rootObj.getBinContent(o.x,o.y,o.z),error:this.rootObj.getBinError(o.x,o.y,o.z)};this.mouseEvents.filter(t=>t.event===e._triggerSource).forEach(e=>e.function(l,this)),this.dirtyInstance=n.instanceId},0)}addEvent(e,t){e?.state===`keydown`?this.keydownEvents.push({key:e.key,function:t}):e?.state===`keyup`?this.keyupEvents.push({key:e.key,function:t}):this.mouseEvents.push({event:e,function:t})}removeEvent(e,t){let n=this.mouseEvents.find(e=>e===t);n&&this.mouseEvents.splice(n,1)}mouseClickDefault(e){console.log(`mouseclick default`)}mousemoveDefault(e){if(e.instanceId===this.dirtyInstance)return;let t=e.object;if(this.dirtyInstance!==void 0){t.getColorAt(this.dirtyInstance,this.color);let e=.5;this.color.lerp(this.colorTarget,-e/(1-e)),t.setColorAt(this.dirtyInstance,this.color)}this.dirtyInstance=e.instanceId,t.getColorAt(this.dirtyInstance,this.color),this.color.lerp(this.colorTarget,.5),t.setColorAt(this.dirtyInstance,this.color),t.instanceColor.needsUpdate=!0,this.binInfoComponent.queue.next(e),z().next(e)}shiftMouseClickDefault(e){console.log(`shiftMouseClickDefault`)}mouseDBClickDefault(e){console.log(`mouseDBClickDefault`)}shiftMouseDBClickDefault(e){console.log(`shiftMouseDBClickDefault`)}getInstancedMesh(e=this.histogramGroup){if(!e)return null;if(e.isInstancedMesh===!0)return e;if(e.children&&e.children.length>0)for(let t of e.children){let e=this.getInstancedMesh(t);if(e)return e}return null}getRangeByPosition(e){let t=[`x`,`y`,`z`],n=Number.parseInt(this.rootObj._typename.substring(2,3),10),i={};if(e[0]){for(let r=0;r<n;r++){let n=t[r],a=this.rootObj[`f${n.toUpperCase()}axis`],o=e[0][n];i[n]={min:a.GetBinLowEdge(o),max:a.GetBinCenter(o)*2-a.GetBinLowEdge(o),name:a.fName,title:a.fTitle}}i={...i,color:new r.Color(0)}}return i}remove(){this.histogramGroup.parent.remove(this.histogramGroup),this.dummyEl=document.getElementById(`dummyDiv`+this.id),this.dummyEl&&document.body.removeChild(this.dummyEl),this.configSub.unsubscribe(),this.sub.unsubscribe()}getHistogramMesh(){return this.histogramGroup}};e.CanvasClass=Ne,e.HistogramJsrootClass=ze,e.HistogramPointerClass=$,e.MobileController=ue,e.NdmvrRaycaster=fe,e.THnPainter=Me,e.binInfoSubjectGet=z,e.brokerManagerGet=s,e.canvasSubjectGet=F,e.configSubjectGet=L,e.dispatchSubjectGet=f,e.fetchTFile=de,e.functionSubjectGet=x,e.getCameraComponent=ae,e.histogramSubjectGet=N,e.httpRequest=l,e.initNdmvrAframe=c,e.inputDeviceSubjectGet=h,e.stateSubjectGet=v});
|