@@ -170,12 +170,16 @@ const AnalysisWG = ({ setTexture, }: { setTexture: React.Dispatch<React.SetState
170170 setValueScales ( { minVal, maxVal } ) ;
171171 let _scales ;
172172 const thisShape = dataShape . length > 2 ? dataShape . filter ( ( _ , idx ) => idx !== axis ) : dataShape ;
173- const textureData = new Uint8Array (
174- newArray . map ( ( i ) => {
175- const normed = ( i - minVal ) / ( maxVal - minVal ) ;
176- return isNaN ( normed ) ? 255 : normed * 254 ;
177- } )
178- ) ;
173+ const textureData = new Uint8Array ( newArray . length )
174+ const range = ( maxVal - minVal )
175+ for ( let i = 0 ; i < newArray . length ; i ++ ) {
176+ const normed = ( newArray [ i ] - minVal ) / range ;
177+ if ( isNaN ( normed ) ) {
178+ textureData [ i ] = 255 ;
179+ } else {
180+ textureData [ i ] = normed * 254 ;
181+ }
182+ } ;
179183 const newTexture = CreateTexture ( is3DResult ? dataShape : thisShape , textureData )
180184 // --- Final state updates ---
181185 setAnalysisArray ( newArray ) ;
@@ -200,12 +204,16 @@ const AnalysisWG = ({ setTexture, }: { setTexture: React.Dispatch<React.SetState
200204 const dataArray = GetCurrentArray ( analysisStore ) ;
201205 const newArray = await CustomShader ( dataArray , shapeInfo , kernelParams , axis , customShader ?? "" ) as Float16Array
202206 const { minVal, maxVal} = valueScales
203- const textureData = new Uint8Array (
204- newArray . map ( ( i ) => {
205- const normed = ( i - minVal ) / ( maxVal - minVal ) ;
206- return isNaN ( normed ) ? 255 : normed * 254 ;
207- } )
208- ) ;
207+ const textureData = new Uint8Array ( newArray . length )
208+ const range = ( maxVal - minVal )
209+ for ( let i = 0 ; i < newArray . length ; i ++ ) {
210+ const normed = ( newArray [ i ] - minVal ) / range ;
211+ if ( isNaN ( normed ) ) {
212+ textureData [ i ] = 255 ;
213+ } else {
214+ textureData [ i ] = normed * 254 ;
215+ }
216+ } ;
209217 const newTexture = CreateTexture ( outputShape , textureData )
210218 setAnalysisArray ( newArray ) ;
211219 if ( newTexture ) {
0 commit comments