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