Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/GlobalStates/GlobalStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ type StoreState = {
idx4D: number | null;
titleDescription: { title: string | null; description: string | null };
textureArrayDepths: number[];
textureData: Uint8Array;
clampExtremes: boolean;

// setters
Expand Down Expand Up @@ -92,7 +91,6 @@ type StoreState = {
setIdx4D: (idx4D: number | null) => void;
setTitleDescription: (titleDescription: { title: string | null; description: string | null }) => void;
setTextureArrayDepths: (textureArrayResolution: number[] ) => void;
setTextureData: (textureData: Uint8Array ) => void;
setDPR: (DPR: number) => void;
setScalingFactor: (scalingFactor: number | null) => void;
setClampExtremes: (clampExtremes: boolean) => void;
Expand Down Expand Up @@ -133,7 +131,6 @@ const createStore = () => create<StoreState>((set, get) => ({
idx4D: null,
titleDescription: { title: null, description: null },
textureArrayDepths: [1,1,1],
textureData: new Uint8Array(1),
DPR: 1,
scalingFactor: null,
clampExtremes: false,
Expand Down Expand Up @@ -193,7 +190,6 @@ const createStore = () => create<StoreState>((set, get) => ({
setIdx4D: (idx4D) => set({ idx4D }),
setTitleDescription: (titleDescription) => set({ titleDescription }),
setTextureArrayDepths: (textureArrayDepths) => set({ textureArrayDepths }),
setTextureData: (textureData) => set({ textureData }),
setDPR: (DPR) => set({ DPR }),
setScalingFactor: (scalingFactor) => set({ scalingFactor }),
setClampExtremes: (clampExtremes) => set({ clampExtremes }),
Expand Down
6 changes: 1 addition & 5 deletions src/components/plots/PointCloud.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { pointFrag, pointVert } from '@/components/textures/shaders'
import { useGlobalStore } from '@/GlobalStates/GlobalStore';
import { usePlotStore } from '@/GlobalStates/PlotStore';
import { useShallow } from 'zustand/shallow';
import { deg2rad } from '@/utils/HelperFuncs';
import { useCoordBounds } from '@/hooks/useCoordBounds';
import { UVCube } from './UVCube';
import { ColumnMeshes } from './TransectMeshes';

Expand Down Expand Up @@ -97,7 +95,7 @@ export const PointCloud = ({textures} : {textures:PCProps} )=>{
}
}
const indexAttr = new THREE.Int32BufferAttribute(indexData, 1);
const maxPointsPerDraw = 2e31 - 1; // 32bit limit
const maxPointsPerDraw = 25e6;
const list = [];
for (let offset = 0; offset < subNumPoints; offset += maxPointsPerDraw) {
const count = Math.min(maxPointsPerDraw, subNumPoints - offset);
Expand All @@ -109,8 +107,6 @@ export const PointCloud = ({textures} : {textures:PCProps} )=>{
return list;
}, [depth, width, height]);

const {lonBounds, latBounds} = useCoordBounds()

const shaderMaterial = useMemo(()=> (new THREE.ShaderMaterial({
glslVersion: THREE.GLSL3,
uniforms: {
Expand Down
14 changes: 6 additions & 8 deletions src/components/textures/TextureMakers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ interface Array {
shape: number[];
}

function StoreData(array: Array, valueScales?: {maxVal: number, minVal: number}): {minVal: number, maxVal: number}{
const { setTextureData} = useGlobalStore.getState()
function createData(array: Array, valueScales?: {maxVal: number, minVal: number}): {textureData: Uint8Array, scales:{minVal: number, maxVal: number}}{
const data = array.data;
const [minVal,maxVal] = valueScales ? [valueScales.minVal, valueScales.maxVal] : ArrayMinMax(data )
const [minVal,maxVal] = valueScales ? [valueScales.minVal, valueScales.maxVal] : ArrayMinMax(data)
const textureData = new Uint8Array(data.length)
const range = (maxVal - minVal)
for (let i = 0; i < data.length; i++){
Expand All @@ -22,13 +21,12 @@ function StoreData(array: Array, valueScales?: {maxVal: number, minVal: number})
textureData[i] = normed * 254;
}
};
setTextureData(textureData)
return {minVal, maxVal}
return {textureData, scales:{minVal, maxVal}}
}

export function CreateTexture(shape: number[], data?: Uint8Array) : THREE.DataTexture[] | THREE.Data3DTexture[] | undefined {
const {textureArrayDepths} = useGlobalStore.getState()
const textureData = data ? data : useGlobalStore.getState().textureData
const textureData = data

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since the fallback to useGlobalStore.getState().textureData has been removed, the data parameter is now effectively required for CreateTexture to function. If data is omitted, the function immediately returns undefined.

To improve type safety and catch potential bugs at compile time, we should make data a required parameter in the function signature (line 27) and update the return type to exclude undefined.

export function CreateTexture(shape: number[], data: Uint8Array) : THREE.DataTexture[] | THREE.Data3DTexture[]

if (!textureData){
return
}
Expand Down Expand Up @@ -76,8 +74,8 @@ export function CreateTexture(shape: number[], data?: Uint8Array) : THREE.DataTe
}

export function ArrayToTexture(array: Array, valueScales?: {maxVal: number, minVal: number}): [ THREE.Data3DTexture[] | THREE.DataTexture[], {minVal: number, maxVal: number}]{
const scales = StoreData(array, valueScales);
const textures = CreateTexture(array.shape)
const {textureData, scales} = createData(array, valueScales)
const textures = CreateTexture(array.shape, textureData)
return [textures as THREE.Data3DTexture[] | THREE.DataTexture[], scales];
}

Expand Down
Loading