Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use built RenderList and RenderLists #989

Merged
merged 5 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading