threed-garden
Version:
ThreeD Garden: WebGL 3D Environment Interface for Next.JS React TypeScript Three.JS React-Three Physics, 2D Paper.JS; APIs: Apollo GraphQL, WordPress; CSS: Tailwind, Radix-UI; Libraries: FarmBot 3D; AI: OpenAI, DeepSeek
34 lines (30 loc) • 737 B
text/typescript
import { useCallback, useMemo } from "react";
import { MathUtils, Vector2 } from "three";
import { FBM } from "../lib/three-noise.module";
import { useSettings } from "../state/useSettings";
export function useFbmNoise() {
const generation = useSettings((s) => s.generation);
const fbm = useMemo(
() =>
new FBM({
seed: generation.Seed,
lacunarity: generation.Detail * 4,
persistance: generation.Fuzzyness * 2
}),
[generation]
);
return useCallback(
(vector: Vector2) =>
Math.pow(
MathUtils.mapLinear(
fbm.get2(vector),
-1, //
1,
0,
1
),
2
),
[fbm]
);
}