@@ -4,7 +4,6 @@ import { useEffect, useMemo, useState, useRef } from 'react'
44import { pointFrag , pointVert } from '@/components/textures/shaders'
55import { useAnalysisStore , useGlobalStore , usePlotStore } from '@/utils/GlobalStates' ;
66import { useShallow } from 'zustand/shallow' ;
7- import { ZarrDataset } from '../zarr/ZarrLoaderLRU' ;
87import { parseUVCoords , getUnitAxis , GetTimeSeries , GetCurrentArray } from '@/utils/HelperFuncs' ;
98import { evaluate_cmap } from 'js-colormaps-es' ;
109
@@ -25,7 +24,7 @@ interface pointSetters{
2524 setDimWidth : React . Dispatch < React . SetStateAction < number > > ;
2625}
2726
28- const MappingCube = ( { dimensions, ZarrDS , setters} : { dimensions : dimensionsProps , ZarrDS : ZarrDataset , setters :pointSetters } ) => {
27+ const MappingCube = ( { dimensions, setters} : { dimensions : dimensionsProps , setters :pointSetters } ) => {
2928 const { width, height, depth} = dimensions ;
3029 const { setPoints, setStride, setDimWidth} = setters ;
3130 const selectTS = usePlotStore ( state => state . selectTS )
@@ -80,60 +79,56 @@ const MappingCube = ({dimensions, ZarrDS, setters} : {dimensions: dimensionsProp
8079 setPoints ( { } )
8180 }
8281 lastNormal . current = dimAxis ;
83-
84- if ( ZarrDS ) {
85- const tempTS = GetTimeSeries ( { data : analysisMode ? analysisArray : GetCurrentArray ( ) , shape : dataShape , stride : strides } , { uv, normal} )
86- const plotDim = ( normal . toArray ( ) ) . map ( ( val , idx ) => {
87- if ( Math . abs ( val ) > 0 ) {
88- return idx ;
89- }
90- return null ; } ) . filter ( idx => idx !== null ) ;
91- setPlotDim ( 2 - plotDim [ 0 ] ) //I think this 2 is only if there are 3-dims. Need to rework the logic
92- const coordUV = parseUVCoords ( { normal :normal , uv :uv } )
93- let dimCoords = coordUV . map ( ( val , idx ) => val ? dimSlices [ idx ] [ Math . round ( val * dimSlices [ idx ] . length - .5 ) ] : null )
94- const thisDimNames = dimNames . filter ( ( _ , idx ) => dimCoords [ idx ] !== null )
95- const thisDimUnits = dimUnits . filter ( ( _ , idx ) => dimCoords [ idx ] !== null )
96- dimCoords = dimCoords . filter ( val => val !== null )
97- const tsID = `${ dimCoords [ 0 ] } _${ dimCoords [ 1 ] } `
98- const tsObj = {
99- color :evaluate_cmap ( getColorIdx ( ) / 10 , "Paired" ) ,
100- data :tempTS
82+ const tempTS = GetTimeSeries ( { data : analysisMode ? analysisArray : GetCurrentArray ( ) , shape : dataShape , stride : strides } , { uv, normal} )
83+ const plotDim = ( normal . toArray ( ) ) . map ( ( val , idx ) => {
84+ if ( Math . abs ( val ) > 0 ) {
85+ return idx ;
10186 }
102- incrementColorIdx ( ) ;
103- updateTimeSeries ( { [ tsID ] : tsObj } )
104- const dimObj = {
105- first :{
106- name :thisDimNames [ 0 ] ,
107- loc :dimCoords [ 0 ] ?? 0 ,
108- units :thisDimUnits [ 0 ]
109- } ,
110- second :{
111- name :thisDimNames [ 1 ] ,
112- loc :dimCoords [ 1 ] ?? 0 ,
113- units :thisDimUnits [ 1 ]
114- } ,
115- plot :{
116- units :dimUnits [ 2 - plotDim [ 0 ] ]
117- }
87+ return null ; } ) . filter ( idx => idx !== null ) ;
88+ setPlotDim ( 2 - plotDim [ 0 ] ) //I think this 2 is only if there are 3-dims. Need to rework the logic
89+ const coordUV = parseUVCoords ( { normal :normal , uv :uv } )
90+ let dimCoords = coordUV . map ( ( val , idx ) => val ? dimSlices [ idx ] [ Math . round ( val * dimSlices [ idx ] . length - .5 ) ] : null )
91+ const thisDimNames = dimNames . filter ( ( _ , idx ) => dimCoords [ idx ] !== null )
92+ const thisDimUnits = dimUnits . filter ( ( _ , idx ) => dimCoords [ idx ] !== null )
93+ dimCoords = dimCoords . filter ( val => val !== null )
94+ const tsID = `${ dimCoords [ 0 ] } _${ dimCoords [ 1 ] } `
95+ const tsObj = {
96+ color :evaluate_cmap ( getColorIdx ( ) / 10 , "Paired" ) ,
97+ data :tempTS
98+ }
99+ incrementColorIdx ( ) ;
100+ updateTimeSeries ( { [ tsID ] : tsObj } )
101+ const dimObj = {
102+ first :{
103+ name :thisDimNames [ 0 ] ,
104+ loc :dimCoords [ 0 ] ?? 0 ,
105+ units :thisDimUnits [ 0 ]
106+ } ,
107+ second :{
108+ name :thisDimNames [ 1 ] ,
109+ loc :dimCoords [ 1 ] ?? 0 ,
110+ units :thisDimUnits [ 1 ]
111+ } ,
112+ plot :{
113+ units :dimUnits [ 2 - plotDim [ 0 ] ]
118114 }
119- updateDimCoords ( { [ tsID ] : dimObj } )
120- const dims = [ depth , height , width ] . filter ( ( _ , idx ) => coordUV [ idx ] != null )
121- const dimWidth = [ depth , height , width ] . filter ( ( _ , idx ) => coordUV [ idx ] == null )
122- const newUV = coordUV . filter ( ( v ) => v != null )
123- const thisStride = strides . filter ( ( _ , idx ) => coordUV [ idx ] != null )
124- const uIdx = Math . round ( ( newUV [ 0 ] ) * dims [ 0 ] - .5 )
125- const vIdx = Math . round ( newUV [ 1 ] * dims [ 1 ] - .5 )
126- const newIdx = uIdx * thisStride [ 0 ] + vIdx * thisStride [ 1 ]
127- const dimStride = strides . filter ( ( _ , idx ) => coordUV [ idx ] == null )
128- setDimWidth ( dimWidth [ 0 ] )
129- setPoints ( prevItems => {
130- const newEntry = { [ tsID ] : newIdx }
131- const updated = { ...newEntry , ...prevItems } ;
132- return updated ; // keep only first 10 items
133- } )
134- setStride ( dimStride [ 0 ] )
135115 }
136-
116+ updateDimCoords ( { [ tsID ] : dimObj } )
117+ const dims = [ depth , height , width ] . filter ( ( _ , idx ) => coordUV [ idx ] != null )
118+ const dimWidth = [ depth , height , width ] . filter ( ( _ , idx ) => coordUV [ idx ] == null )
119+ const newUV = coordUV . filter ( ( v ) => v != null )
120+ const thisStride = strides . filter ( ( _ , idx ) => coordUV [ idx ] != null )
121+ const uIdx = Math . round ( ( newUV [ 0 ] ) * dims [ 0 ] - .5 )
122+ const vIdx = Math . round ( newUV [ 1 ] * dims [ 1 ] - .5 )
123+ const newIdx = uIdx * thisStride [ 0 ] + vIdx * thisStride [ 1 ]
124+ const dimStride = strides . filter ( ( _ , idx ) => coordUV [ idx ] == null )
125+ setDimWidth ( dimWidth [ 0 ] )
126+ setPoints ( prevItems => {
127+ const newEntry = { [ tsID ] : newIdx }
128+ const updated = { ...newEntry , ...prevItems } ;
129+ return updated ; // keep only first 10 items
130+ } )
131+ setStride ( dimStride [ 0 ] )
137132 }
138133 return (
139134 < mesh scale = { [ 2 * globalScale , 2 * shapeRatio * globalScale , 2 * depthRatio * globalScale ] } position = { [ - offset , - offset , offset ] } onClick = { HandleTimeSeries } >
@@ -143,7 +138,7 @@ const MappingCube = ({dimensions, ZarrDS, setters} : {dimensions: dimensionsProp
143138 )
144139}
145140
146- export const PointCloud = ( { textures, ZarrDS } : { textures :PCProps , ZarrDS : ZarrDataset } ) => {
141+ export const PointCloud = ( { textures} : { textures :PCProps } ) => {
147142 const { colormap } = textures ;
148143 const { timeSeries, flipY, dataShape, textureData} = useGlobalStore ( useShallow ( state => ( {
149144 timeSeries : state . timeSeries ,
@@ -265,7 +260,7 @@ export const PointCloud = ({textures, ZarrDS} : {textures:PCProps, ZarrDS: ZarrD
265260 < mesh scale = { [ 1 , flipY ? - 1 :1 , 1 ] } >
266261 < points geometry = { geometry } material = { shaderMaterial } frustumCulled = { false } />
267262 </ mesh >
268- < MappingCube dimensions = { { width, height, depth} } ZarrDS = { ZarrDS } setters = { { setPoints :setPointsObj , setStride, setDimWidth} } />
263+ < MappingCube dimensions = { { width, height, depth} } setters = { { setPoints :setPointsObj , setStride, setDimWidth} } />
269264 </ >
270265 ) ;
271266 }
0 commit comments