11import * as THREE from 'three'
2- import { useEffect , useMemo , useState , useRef } from 'react'
2+ import { useEffect , useMemo } from 'react'
33import { pointFrag , pointVert } from '@/components/textures/shaders'
4- import { useAnalysisStore } from '@/GlobalStates/AnalysisStore' ;
54import { useGlobalStore } from '@/GlobalStates/GlobalStore' ;
65import { usePlotStore } from '@/GlobalStates/PlotStore' ;
76import { useShallow } from 'zustand/shallow' ;
8- import { parseUVCoords , getUnitAxis , GetTimeSeries , GetCurrentArray , deg2rad } from '@/utils/HelperFuncs' ;
9- import { evaluate_cmap } from 'js-colormaps-es' ;
7+ import { deg2rad } from '@/utils/HelperFuncs' ;
108import { useCoordBounds } from '@/hooks/useCoordBounds' ;
119import { UVCube } from './UVCube' ;
1210
@@ -40,14 +38,13 @@ const MappingCube = () =>{
4038
4139export const PointCloud = ( { textures} : { textures :PCProps } ) => {
4240 const { colormap } = textures ;
43- const { timeSeries, flipY, dataShape, textureData} = useGlobalStore ( useShallow ( state => ( {
44- timeSeries : state . timeSeries ,
41+ const { flipY, dataShape, textureData} = useGlobalStore ( useShallow ( state => ( {
4542 flipY : state . flipY ,
4643 dataShape : state . dataShape ,
4744 textureData : state . textureData
4845 } ) ) )
4946 const { scalePoints, scaleIntensity, pointSize, cScale, cOffset, valueRange, animProg,
50- selectTS , timeScale, xRange, yRange, zRange, fillValue,
47+ timeScale, xRange, yRange, zRange, fillValue,
5148 maskTexture, maskValue } = usePlotStore ( useShallow ( state => ( {
5249 scalePoints : state . scalePoints ,
5350 scaleIntensity : state . scaleIntensity ,
@@ -56,7 +53,6 @@ export const PointCloud = ({textures} : {textures:PCProps} )=>{
5653 cOffset :state . cOffset ,
5754 valueRange : state . valueRange ,
5855 animProg : state . animProg ,
59- selectTS : state . selectTS ,
6056 timeScale : state . timeScale ,
6157 xRange : state . xRange ,
6258 yRange : state . yRange ,
@@ -65,24 +61,6 @@ export const PointCloud = ({textures} : {textures:PCProps} )=>{
6561 maskTexture : state . maskTexture ,
6662 maskValue : state . maskValue ,
6763 } ) ) )
68-
69- const [ pointsObj , setPointsObj ] = useState < Record < string , number > > ( { } )
70- const [ pointIDs , setPointIDs ] = useState < number [ ] > ( new Array ( 10 ) . fill ( - 1 ) )
71- const [ stride , setStride ] = useState < number > ( 1 )
72- const [ dimWidth , setDimWidth ] = useState < number > ( 0 ) ;
73-
74- useEffect ( ( ) => { //This goes through the list of highlighted columns and removes those that aren't included in the timeseries object.
75- let pointIDs = Object . keys ( pointsObj )
76- const tsIDs = Object . keys ( timeSeries )
77- pointIDs = pointIDs . filter ( ( val ) => tsIDs . includes ( val ) )
78- const pointValues = pointIDs . map ( id => pointsObj [ id ] ) ;
79- const paddedArray = [
80- ...pointValues ,
81- ...Array ( Math . max ( 0 , 10 - pointValues . length ) ) . fill ( - 1 )
82- ] ;
83- setPointIDs ( paddedArray )
84-
85- } , [ timeSeries , pointsObj ] )
8664
8765 //Extract data and shape from Data3DTexture
8866 const { data, width, height, depth } = useMemo ( ( ) => {
@@ -94,7 +72,6 @@ export const PointCloud = ({textures} : {textures:PCProps} )=>{
9472 depth : depth ,
9573 } ;
9674 } , [ textureData , dataShape ] ) ;
97-
9875 // Create buffer geometry
9976 const geometry = useMemo ( ( ) => {
10077 const geom = new THREE . BufferGeometry ( ) ;
@@ -119,10 +96,6 @@ export const PointCloud = ({textures} : {textures:PCProps} )=>{
11996 valueRange : { value : new THREE . Vector2 ( valueRange [ 0 ] , valueRange [ 1 ] ) } ,
12097 scalePoints :{ value : scalePoints } ,
12198 scaleIntensity : { value : scaleIntensity } ,
122- startIDs : { value : pointIDs } ,
123- stride : { value : stride } ,
124- showTransect : { value : selectTS } ,
125- dimWidth : { value : dimWidth } ,
12699 timeScale : { value : timeScale } ,
127100 animateProg : { value : animProg } ,
128101 shape : { value : new THREE . Vector3 ( depth , height , width ) } ,
@@ -134,12 +107,10 @@ export const PointCloud = ({textures} : {textures:PCProps} )=>{
134107 fragmentShader :pointFrag ,
135108 depthWrite : true ,
136109 depthTest : true ,
137- transparent : false ,
138- blending :THREE . NormalBlending ,
139- side :THREE . DoubleSide ,
110+ blending :THREE . NoBlending ,
140111 } )
141112 ) , [ ] ) ;
142-
113+
143114 useEffect ( ( ) => {
144115 if ( shaderMaterial ) {
145116 const uniforms = shaderMaterial . uniforms ;
@@ -150,12 +121,8 @@ export const PointCloud = ({textures} : {textures:PCProps} )=>{
150121 uniforms . valueRange . value . set ( valueRange [ 0 ] , valueRange [ 1 ] ) ;
151122 uniforms . scalePoints . value = scalePoints ;
152123 uniforms . scaleIntensity . value = scaleIntensity ;
153- uniforms . startIDs . value = pointIDs ;
154- uniforms . stride . value = stride ;
155124 uniforms . latBounds . value = new THREE . Vector2 ( deg2rad ( latBounds [ 0 ] ) , deg2rad ( latBounds [ 1 ] ) )
156125 uniforms . lonBounds . value = new THREE . Vector2 ( deg2rad ( lonBounds [ 0 ] ) , deg2rad ( lonBounds [ 1 ] ) )
157- uniforms . showTransect . value = selectTS ;
158- uniforms . dimWidth . value = dimWidth ;
159126 uniforms . timeScale . value = timeScale ;
160127 uniforms . animateProg . value = animProg ;
161128 uniforms . flatBounds . value . set (
@@ -168,8 +135,7 @@ export const PointCloud = ({textures} : {textures:PCProps} )=>{
168135 uniforms . fillValue . value = fillValue ?? NaN
169136 uniforms . maskValue . value = maskValue
170137 }
171- } , [ pointSize , colormap , cOffset , cScale , valueRange , scalePoints , scaleIntensity , pointIDs , stride , selectTS , animProg , timeScale , xRange , yRange , fillValue , zRange , maskValue , lonBounds , latBounds ] ) ;
172-
138+ } , [ pointSize , colormap , cOffset , cScale , valueRange , scalePoints , scaleIntensity , animProg , timeScale , xRange , yRange , fillValue , zRange , maskValue , lonBounds , latBounds ] ) ;
173139 return (
174140 < >
175141 < mesh scale = { [ 1 , flipY ? - 1 :1 , 1 ] } >
0 commit comments