Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoHamuy committed Feb 17, 2024
1 parent f7e4cd8 commit d86d3b5
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions stories/src/free-3d-buildings/batched-buildings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { suspend } from "suspend-react";
import { BatchedMesh, Color, ExtrudeGeometry, MathUtils, Shape, Vector3Tuple } from "three";
import { BatchedStandardMaterial } from "./batched-standard-material/batched-standard-material";
import { OverpassElement, getBuildingsData } from "./get-buildings-data";
import { useFunction } from "../../../src/core/use-function";

extend({ BatchedStandardMaterial })

Expand Down Expand Up @@ -76,7 +75,7 @@ export const BatchedBuildings = memo<BatchedBuildingsProps>(({ buildingsCenter,
const meshRef = useRef<BatchedMesh>(null);
const matRef = useRef<BatchedStandardMaterial>(null);

const step = useFunction((delta = 0) => {
useFrame((_, delta) => {
if (!matRef.current) return;
const material = matRef.current;
for (let i = 0; i < data.length; i++) {
Expand All @@ -98,15 +97,12 @@ export const BatchedBuildings = memo<BatchedBuildingsProps>(({ buildingsCenter,

})

useFrame((_, delta) => step(delta))

useLayoutEffect(() => {
if (!meshRef.current) return;
const mesh = meshRef.current;
for (let i = 0; i < data.length; i++) {
mesh.addGeometry(data[i].geometry);
}
step();
}, [data]); // eslint-disable-line react-hooks/exhaustive-deps

return <batchedMesh
Expand Down

0 comments on commit d86d3b5

Please sign in to comment.