heat map bug fix
This commit is contained in:
@@ -5,14 +5,10 @@ import { useProductContext } from "../../modules/simulation/products/productCont
|
||||
import { useSceneContext } from "../../modules/scene/sceneContext";
|
||||
import * as CONSTANTS from "../../types/world/worldConstants";
|
||||
import { determineExecutionMachineSequences } from "../../modules/simulation/simulator/functions/determineExecutionMachineSequences";
|
||||
import {
|
||||
useAnimationPlaySpeed,
|
||||
usePauseButtonStore,
|
||||
usePlayButtonStore,
|
||||
useResetButtonStore,
|
||||
} from "../../store/usePlayButtonStore";
|
||||
import { useAnimationPlaySpeed, usePauseButtonStore, usePlayButtonStore, useResetButtonStore } from "../../store/usePlayButtonStore";
|
||||
|
||||
const DECAY_RATE = 0.01;
|
||||
const GROWTH_TIME_MULTIPLIER = 20;
|
||||
const RADIUS = 0.005;
|
||||
const OPACITY = 0.8;
|
||||
const UPDATE_INTERVAL = 0.1;
|
||||
@@ -55,6 +51,7 @@ const HeatMap = () => {
|
||||
u_radius: { value: RADIUS },
|
||||
u_opacity: { value: OPACITY },
|
||||
u_debugMode: { value: debugModeMap[debugMode] },
|
||||
u_growthRate: { value: GROWTH_TIME_MULTIPLIER }, // NEW
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
@@ -168,7 +165,8 @@ const HeatMap = () => {
|
||||
uniformsRef.current.u_radius.value = RADIUS;
|
||||
uniformsRef.current.u_opacity.value = OPACITY;
|
||||
uniformsRef.current.u_debugMode.value = debugModeMap[debugMode];
|
||||
}, [RADIUS, OPACITY, debugMode]);
|
||||
uniformsRef.current.u_growthRate.value = GROWTH_TIME_MULTIPLIER;
|
||||
}, [RADIUS, OPACITY, debugMode, GROWTH_TIME_MULTIPLIER]);
|
||||
|
||||
useEffect(() => {
|
||||
uniformsRef.current.u_points.value = pointTexture;
|
||||
@@ -199,6 +197,7 @@ const HeatMap = () => {
|
||||
uniform float u_radius;
|
||||
uniform float u_opacity;
|
||||
uniform int u_debugMode;
|
||||
uniform float u_growthRate;
|
||||
varying vec2 vUv;
|
||||
|
||||
float gauss(float dist, float radius) {
|
||||
@@ -214,7 +213,7 @@ const HeatMap = () => {
|
||||
float intensity = 0.0;
|
||||
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
if (i >= u_count) break; // dynamically stop looping
|
||||
if (i >= u_count) break;
|
||||
float fi = float(i) + 0.5;
|
||||
float u = fi / float(u_count);
|
||||
|
||||
@@ -231,9 +230,13 @@ const HeatMap = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
vec3 color = vec3(0.0);
|
||||
float normalized = clamp(intensity / 4.0, 0.0, 1.0);
|
||||
// Apply growth rate BEFORE normalization
|
||||
float adjustedIntensity = intensity * u_growthRate;
|
||||
|
||||
// Normalize intensity between 0-1
|
||||
float normalized = clamp(intensity / max(u_growthRate, 0.0001), 0.0, 1.0);
|
||||
|
||||
vec3 color = vec3(0.0);
|
||||
if (normalized < 0.33) {
|
||||
color = mix(vec3(0.0, 0.0, 1.0), vec3(0.0, 1.0, 0.0), normalized / 0.33);
|
||||
} else if (normalized < 0.66) {
|
||||
@@ -244,10 +247,11 @@ const HeatMap = () => {
|
||||
|
||||
gl_FragColor = vec4(color, normalized * u_opacity);
|
||||
}
|
||||
|
||||
`}
|
||||
/>
|
||||
</mesh>
|
||||
);
|
||||
};
|
||||
|
||||
export default HeatMap;
|
||||
export default HeatMap;
|
||||
Reference in New Issue
Block a user