Skip to content

Commit

Permalink
Use built RenderList and RenderLists (#989)
Browse files Browse the repository at this point in the history
* Add examples

* Add Nodes

* Update patch

* Delete examples

* Add RenderList and RenderLists
  • Loading branch information
Methuselah96 authored May 26, 2024
1 parent e176d6d commit e28b7a7
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
21 changes: 21 additions & 0 deletions examples-jsm/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,27 @@ index 9417df5a..43761555 100644
let viewZ;

const getViewZ = builder.context.getViewZ;
diff --git a/examples-jsm/examples/nodes/lighting/LightsNode.ts b/examples-jsm/examples/nodes/lighting/LightsNode.ts
index b3695ea8..603a4520 100644
--- a/examples-jsm/examples/nodes/lighting/LightsNode.ts
+++ b/examples-jsm/examples/nodes/lighting/LightsNode.ts
@@ -1,6 +1,7 @@
import Node from '../core/Node.js';
import AnalyticLightNode from './AnalyticLightNode.js';
import { nodeObject, nodeProxy, vec3 } from '../shadernode/ShaderNode.js';
+import { Light } from 'three';

const LightNodes = new WeakMap();

@@ -113,7 +114,7 @@ class LightsNode extends Node {
return null;
}

- fromLights(lights = []) {
+ fromLights(lights: Light[] = []) {
const lightNodes = [];

lights = sortLights(lights);
diff --git a/examples-jsm/examples/renderers/common/Animation.ts b/examples-jsm/examples/renderers/common/Animation.ts
index 0b00319a..c190633b 100644
--- a/examples-jsm/examples/renderers/common/Animation.ts
Expand Down
1 change: 1 addition & 0 deletions examples-jsm/create-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const files = [
'nodes/gpgpu/ComputeNode',
'nodes/lighting/EnvironmentNode',
'nodes/lighting/LightsNode',
'nodes/Nodes',
'renderers/common/nodes/NodeBuilderState',
'renderers/common/nodes/Nodes',
'renderers/common/Animation',
Expand Down
2 changes: 2 additions & 0 deletions examples-jsm/declarations.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const files = [
'renderers/common/DataMap',
'renderers/common/Info',
'renderers/common/RenderContexts',
'renderers/common/RenderList',
'renderers/common/RenderLists',
'renderers/common/Textures',
];

Expand Down
62 changes: 62 additions & 0 deletions types/three/examples/jsm/renderers/common/RenderList.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { BufferGeometry, Camera, GeometryGroup, Light, Material, Object3D } from "three";
import { LightsNode } from "../../nodes/Nodes.js";
export interface Bundle {
object: Object3D;
camera: Camera;
renderList: RenderList;
}
export interface RenderItem {
id: number | null;
object: Object3D | null;
geometry: BufferGeometry | null;
material: Material | null;
groupOrder: number | null;
renderOrder: number | null;
z: number | null;
group: GeometryGroup | null;
}
declare class RenderList {
renderItems: RenderItem[];
renderItemsIndex: number;
opaque: RenderItem[];
transparent: RenderItem[];
bundles: Bundle[];
lightsNode: LightsNode;
lightsArray: Light[];
occlusionQueryCount: number;
constructor();
begin(): this;
getNextRenderItem(
object: Object3D,
geometry: BufferGeometry,
material: Material,
groupOrder: number,
z: number,
group: GeometryGroup | null,
): RenderItem;
push(
object: Object3D,
geometry: BufferGeometry,
material: Material,
groupOrder: number,
z: number,
group: GeometryGroup | null,
): void;
unshift(
object: Object3D,
geometry: BufferGeometry,
material: Material,
groupOrder: number,
z: number,
group: GeometryGroup | null,
): void;
pushBundle(group: Bundle): void;
pushLight(light: Light): void;
getLightsNode(): LightsNode;
sort(
customOpaqueSort: ((a: RenderItem, b: RenderItem) => number) | null,
customTransparentSort: ((a: RenderItem, b: RenderItem) => number) | null,
): void;
finish(): void;
}
export default RenderList;
10 changes: 10 additions & 0 deletions types/three/examples/jsm/renderers/common/RenderLists.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Camera, Object3D } from "three";
import ChainMap from "./ChainMap.js";
import RenderList from "./RenderList.js";
declare class RenderLists {
lists: ChainMap<readonly [Object3D, Camera], RenderList>;
constructor();
get(scene: Object3D, camera: Camera): RenderList;
dispose(): void;
}
export default RenderLists;

0 comments on commit e28b7a7

Please sign in to comment.