@@ -17,7 +17,6 @@ interface DataCubeProps {
1717 volTexture : THREE . Data3DTexture | THREE . DataTexture | null ,
1818 shape : THREE . Vector3 ,
1919 colormap : THREE . DataTexture
20-
2120}
2221
2322interface PCProps {
@@ -27,8 +26,6 @@ interface PCProps {
2726
2827export const DataCube = ( { volTexture, shape, colormap } : DataCubeProps ) => {
2928 const meshRef = useRef < THREE . Mesh > ( null ) ;
30- // const materialRef = useRef<THREE.ShaderMaterial | null>(null);
31- // const { invalidate } = useThree();
3229 const { threshold, steps, flip, xMax, xMin, yMax, yMin, zMax, zMin } = useControls ( {
3330 threshold : {
3431 value : 0 , // Default value
@@ -94,25 +91,25 @@ export const DataCube = ({ volTexture, shape, colormap }: DataCubeProps ) => {
9491
9592 // We need to check if moving this outside of useMemo means it's creating a ton of materials. This was how it was done in THREE Journey when I was doing that, so I know it's not stricly speaking wrong
9693 const shaderMaterial = new THREE . ShaderMaterial ( {
97- glslVersion : THREE . GLSL3 ,
98- uniforms : {
99- map : { value : volTexture } ,
100- cmap :{ value : colormap } ,
101- cameraPos : { value : new THREE . Vector3 ( ) } ,
102- threshold : { value : threshold } ,
103- scale : { value : shape } ,
104- flatBounds :{ value : new THREE . Vector4 ( xMin , xMax , yMin , yMax ) } ,
105- vertBounds :{ value : new THREE . Vector2 ( zMin , zMax ) } ,
106- steps : { value : steps } ,
107- flip : { value : flip }
108- } ,
109- vertexShader,
110- fragmentShader,
111- transparent : true ,
112- blending : THREE . NormalBlending ,
113- depthWrite : false ,
114- side : THREE . BackSide ,
115- } ) ;
94+ glslVersion : THREE . GLSL3 ,
95+ uniforms : {
96+ map : { value : volTexture } ,
97+ cmap :{ value : colormap } ,
98+ cameraPos : { value : new THREE . Vector3 ( ) } ,
99+ threshold : { value : threshold } ,
100+ scale : { value : shape } ,
101+ flatBounds :{ value : new THREE . Vector4 ( xMin , xMax , yMin , yMax ) } ,
102+ vertBounds :{ value : new THREE . Vector2 ( zMin , zMax ) } ,
103+ steps : { value : steps } ,
104+ flip : { value : flip }
105+ } ,
106+ vertexShader,
107+ fragmentShader,
108+ transparent : true ,
109+ blending : THREE . NormalBlending ,
110+ depthWrite : false ,
111+ side : THREE . BackSide ,
112+ } ) ;
116113
117114 // Use geometry once, avoid recreating -- Using a sphere to avoid the weird angles you get with cube
118115 const geometry = useMemo ( ( ) => new THREE . IcosahedronGeometry ( 4 , 8 ) , [ ] ) ;
@@ -142,8 +139,6 @@ export const UVCube = ({shape,setTimeSeriesLocs} : {shape:THREE.Vector3, setTime
142139 normal
143140 } )
144141 }
145-
146-
147142 return (
148143 < mesh scale = { shape } onClick = { TimeSeriesLocs } >
149144 < boxGeometry args = { [ 1 , 1 , 1 ] } />
@@ -168,7 +163,7 @@ export const PointCloud = ({textures} : {textures:PCProps} )=>{
168163 }
169164 }
170165 )
171- // Extract data and shape from Data3DTexture
166+ //Extract data and shape from Data3DTexture
172167 const { data, width, height, depth } = useMemo ( ( ) => {
173168 if ( ! ( texture instanceof THREE . Data3DTexture ) ) {
174169 console . warn ( 'Provided texture is not a Data3DTexture' ) ;
@@ -188,15 +183,15 @@ export const PointCloud = ({textures} : {textures:PCProps} )=>{
188183 const aspectRatio = width / height
189184 let depthRatio = depth / height ;
190185 depthRatio = depthRatio > 10 ? 10 : depthRatio ;
191- // Generate grid points based on texture shape
186+ //Generate grid points based on texture shape
192187 for ( let z = 0 ; z < depth ; z ++ ) {
193188 for ( let y = 0 ; y < height ; y ++ ) {
194189 for ( let x = 0 ; x < width ; x ++ ) {
195190 const index = x + y * width + z * width * height ;
196191 const value = ( data as number [ ] ) [ index ] || 0 ;
197192 // Skip zero or invalid values if needed
198193 if ( value > 0 ) {
199- // Normalize coordinates to [-0.5, 0.5] range
194+ // Normalize coordinates acceptable range
200195 const px = ( ( x / ( width - 1 ) ) - 0.5 ) * aspectRatio ;
201196 const py = ( y / ( height - 1 ) ) - 0.5 ;
202197 const pz = ( ( z / ( depth - 1 ) ) - 0.5 ) * depthRatio ;
@@ -221,17 +216,17 @@ export const PointCloud = ({textures} : {textures:PCProps} )=>{
221216
222217
223218 const shaderMaterial = new THREE . ShaderMaterial ( {
224- glslVersion : THREE . GLSL3 ,
225- uniforms : {
226- pointSize : { value : pointScale } ,
227- cmap : { value : colormap } ,
228- scalePoints :{ value : scalePoints }
229- } ,
230- vertexShader :pointVert ,
231- fragmentShader :pointFrag ,
232- blending : THREE . NoBlending ,
233- depthWrite : true ,
234- } ) ;
219+ glslVersion : THREE . GLSL3 ,
220+ uniforms : {
221+ pointSize : { value : pointScale } ,
222+ cmap : { value : colormap } ,
223+ scalePoints :{ value : scalePoints }
224+ } ,
225+ vertexShader :pointVert ,
226+ fragmentShader :pointFrag ,
227+ blending : THREE . NoBlending ,
228+ depthWrite : true ,
229+ } ) ;
235230
236231 return (
237232 < points geometry = { geometry } material = { shaderMaterial } />
0 commit comments