Skip to content

Commit 0b160ae

Browse files
authored
Merge pull request #575 from EarthyScience/jp/tweaks-n-stuff
moved axis bars, tweaked mask value
2 parents abc373c + 6611fda commit 0b160ae

4 files changed

Lines changed: 27 additions & 40 deletions

File tree

src/components/plots/DataCube.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const DataCube = ({ volTexture }: DataCubeProps ) => {
6666
useClipScale: {value: vTransferRange},
6767
nanAlpha: {value: 1-nanTransparency},
6868
nanColor: {value: new THREE.Color(nanColor)},
69-
fillValue: {value: fillValue}
69+
fillValue: {value: NaN}
7070
},
7171
vertexShader: useOrtho ? orthoVertex : vertexShader,
7272
fragmentShader: useFragOpt ? fragOpt : fragmentShader,
@@ -96,7 +96,7 @@ export const DataCube = ({ volTexture }: DataCubeProps ) => {
9696
uniforms.nanColor.value.set(nanColor);
9797
uniforms.opacityMag.value = vTransferScale;
9898
uniforms.useClipScale.value = vTransferRange;
99-
uniforms.fillValue.value = fillValue;
99+
uniforms.fillValue.value = fillValue?? NaN;
100100
uniforms.maskValue.value = maskValue
101101
invalidate() // Needed because Won't trigger re-render if camera is stationary.
102102
}

src/components/plots/PointCloud.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ export const PointCloud = ({textures} : {textures:PCProps} )=>{
230230
shape: {value: new THREE.Vector3(depth, height, width)},
231231
flatBounds:{value: new THREE.Vector4(xRange[0], xRange[1], zRange[0], zRange[1])},
232232
vertBounds:{value: new THREE.Vector2(yRange[0], yRange[1])},
233-
fillValue: {value: fillValue}
233+
fillValue: {value: NaN}
234234
},
235235
vertexShader:pointVert,
236236
fragmentShader:pointFrag,
@@ -267,7 +267,7 @@ export const PointCloud = ({textures} : {textures:PCProps} )=>{
267267
uniforms.vertBounds.value.set(
268268
yRange[0], yRange[1]
269269
);
270-
uniforms.fillValue.value = fillValue
270+
uniforms.fillValue.value = fillValue?? NaN
271271
uniforms.maskValue.value = maskValue
272272
}
273273
}, [pointSize, colormap, cOffset, cScale, valueRange, scalePoints, scaleIntensity, pointIDs, stride, selectTS, animProg, timeScale, xRange, yRange, fillValue, zRange, maskValue, lonBounds, latBounds]);

src/components/plots/Sphere.tsx

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ export const Sphere = ({textures} : {textures: THREE.Data3DTexture[] | THREE.Dat
8282
const [boundsObj, setBoundsObj] = useState<Record<string, THREE.Vector4>>({})
8383
const [bounds, setBounds] = useState<THREE.Vector4[]>(new Array(10).fill(new THREE.Vector4(-1 , -1, -1, -1)))
8484
const [height, width] = useMemo(()=>isFlat ? dataShape : [dataShape[1], dataShape[2]], [dataShape])
85-
8685
useEffect(()=>{ //This goes through the list of highlighted squares and removes those that aren't included in the timeseries object.
8786
let boundIDs = Object.keys(boundsObj)
8887
const tsIDs = Object.keys(timeSeries)
@@ -131,7 +130,7 @@ export const Sphere = ({textures} : {textures: THREE.Data3DTexture[] | THREE.Dat
131130
nanAlpha: {value: 1 - nanTransparency},
132131
displaceZero: {value: -valueScales.minVal/(valueScales.maxVal-valueScales.minVal)},
133132
displacement: {value: sphereDisplacement},
134-
fillValue: {value: fillValue},
133+
fillValue: {value: NaN},
135134
},
136135
vertexShader: isFlat ? sphereVertexFlat : sphereVertex,
137136
fragmentShader: isFlat ? flatSphereFrag : sphereFrag,
@@ -149,42 +148,31 @@ export const Sphere = ({textures} : {textures: THREE.Data3DTexture[] | THREE.Dat
149148
return mat;
150149
},[shaderMaterial])
151150

151+
const updateMaterial = (material: THREE.ShaderMaterial) =>{
152+
const uniforms = material.uniforms;
153+
uniforms.map.value = textures
154+
uniforms.selectTS.value = selectTS
155+
uniforms.selectBounds.value = bounds
156+
uniforms.cmap.value = colormap
157+
uniforms.maskValue.value = maskValue
158+
uniforms.cOffset.value = cOffset
159+
uniforms.cScale.value = cScale
160+
uniforms.animateProg.value = animProg
161+
uniforms.latBounds.value = new THREE.Vector2(deg2rad(latBounds[0]), deg2rad(latBounds[1]))
162+
uniforms.lonBounds.value = new THREE.Vector2(deg2rad(lonBounds[0]), deg2rad(lonBounds[1]))
163+
uniforms.nanColor.value = new THREE.Color(nanColor)
164+
uniforms.nanAlpha.value = 1 - nanTransparency
165+
uniforms.displaceZero.value = -valueScales.minVal/(valueScales.maxVal-valueScales.minVal)
166+
uniforms.displacement.value = sphereDisplacement
167+
uniforms.fillValue.value = fillValue?? NaN
168+
}
169+
152170
useEffect(()=>{
153171
if (shaderMaterial){
154-
const uniforms = shaderMaterial.uniforms;
155-
uniforms.map.value = textures
156-
uniforms.selectTS.value = selectTS
157-
uniforms.selectBounds.value = bounds
158-
uniforms.cmap.value = colormap
159-
uniforms.maskValue.value = maskValue
160-
uniforms.cOffset.value = cOffset
161-
uniforms.cScale.value = cScale
162-
uniforms.animateProg.value = animProg
163-
uniforms.latBounds.value = new THREE.Vector2(deg2rad(latBounds[0]), deg2rad(latBounds[1]))
164-
uniforms.lonBounds.value = new THREE.Vector2(deg2rad(lonBounds[0]), deg2rad(lonBounds[1]))
165-
uniforms.nanColor.value = new THREE.Color(nanColor)
166-
uniforms.nanAlpha.value = 1 - nanTransparency
167-
uniforms.displaceZero.value = -valueScales.minVal/(valueScales.maxVal-valueScales.minVal)
168-
uniforms.displacement.value = sphereDisplacement
169-
uniforms.fillValue.value = fillValue
172+
updateMaterial(shaderMaterial)
170173
}
171174
if (backMaterial){
172-
const uniforms = backMaterial.uniforms;
173-
uniforms.map. value = textures
174-
uniforms.selectTS.value = selectTS
175-
uniforms.selectBounds.value = bounds
176-
uniforms.cmap.value = colormap
177-
uniforms.maskValue.value = maskValue
178-
uniforms.cOffset.value = cOffset
179-
uniforms.cScale.value = cScale
180-
uniforms.animateProg.value = animProg
181-
uniforms.latBounds.value = new THREE.Vector2(deg2rad(latBounds[0]), deg2rad(latBounds[1]))
182-
uniforms.lonBounds.value = new THREE.Vector2(deg2rad(lonBounds[0]), deg2rad(lonBounds[1]))
183-
uniforms.nanColor.value = new THREE.Color(nanColor)
184-
uniforms.nanAlpha.value = 1 - nanTransparency
185-
uniforms.displaceZero.value = -valueScales.minVal/(valueScales.maxVal-valueScales.minVal)
186-
uniforms.displacement.value = sphereDisplacement
187-
uniforms.fillValue.value = fillValue
175+
updateMaterial(backMaterial)
188176
}
189177
},[textures, animProg, colormap, cOffset, cScale, animate, bounds, selectTS, lonBounds, latBounds, nanColor, nanTransparency, sphereDisplacement, fillValue, maskValue, valueScales])
190178

src/components/ui/NavBar/Navbar.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,11 @@ const Navbar = React.memo(function Navbar() {
6767
{isOpen ? "Close navigation" : "Open navigation"}
6868
</TooltipContent>
6969
</Tooltip>
70-
7170
<div className={cn("navbar-content", isOpen ? "open" : "closed")}>
7271
{/* <LogoDrawer /> */}
7372
<div className="navbar-left">
7473
{plotOn && (
7574
<>
76-
<AxisBars />
7775
<Tooltip delayDuration={500}>
7876
<TooltipTrigger asChild>
7977
<Button
@@ -122,6 +120,7 @@ const Navbar = React.memo(function Navbar() {
122120
)}
123121
</div>
124122
</div>
123+
{plotOn && <AxisBars />}
125124
</nav>
126125
);
127126
});

0 commit comments

Comments
 (0)