mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-12-04 23:32:54 +01:00
smart shadow updates
This commit is contained in:
11 files changed
+110
-15
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { invalidate } from "@react-three/fiber";
|
||||
import { useEffect, useMemo, type ComponentProps } from "react";
|
||||
import { BatchedMesh, Color, type Matrix4, type Mesh } from "three";
|
||||
import { sceneChangeEvent } from "../../core/three/sceneChange";
|
||||
|
||||
export interface BatchItem {
|
||||
mesh: Mesh;
|
||||
@@ -32,6 +33,10 @@ export function Batch({ items, ...props }: BatchProps) {
|
||||
const batch = new BatchedMesh(items.length, vertices, indices);
|
||||
const color = new Color();
|
||||
|
||||
// otherwise the draw list is re-culled, re-sorted and re-uploaded every draw
|
||||
batch.perObjectFrustumCulled = false;
|
||||
batch.sortObjects = false;
|
||||
|
||||
for (const { mesh, matrix, thickness } of items) {
|
||||
const instanceId = batch.addInstance(batch.addGeometry(mesh.geometry));
|
||||
|
||||
@@ -49,9 +54,11 @@ export function Batch({ items, ...props }: BatchProps) {
|
||||
if (!batch) return;
|
||||
|
||||
invalidate();
|
||||
sceneChangeEvent.dispatch();
|
||||
|
||||
return () => {
|
||||
batch.dispose();
|
||||
sceneChangeEvent.dispatch();
|
||||
};
|
||||
}, [batch]);
|
||||
|
||||
|
||||
Reference in new issue
Block a user