Skip to content

Commit

Permalink
bump as far as r162; replace WebGLMultipleRenderTargets
Browse files Browse the repository at this point in the history
  • Loading branch information
frasercl committed Dec 6, 2024
1 parent 48dc7d1 commit a57a7b1
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 32 deletions.
52 changes: 43 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@types/lodash": "^4.14.175",
"@types/react": "^18.2.46",
"@types/react-dom": "^18.2.18",
"@types/three": "^0.144.0",
"@types/three": "^0.162.0",
"@typescript-eslint/eslint-plugin": "~8.15.0",
"@typescript-eslint/parser": "~8.15.0",
"@vitest/coverage-v8": "^2.1.5",
Expand Down Expand Up @@ -105,7 +105,7 @@
"mp4-muxer": "^2.2.2",
"parse-pdb": "^1.0.0",
"si-prefix": "^0.2.0",
"three": "^0.144.0",
"three": "^0.162.0",
"tweakpane": "^3.0.7"
}
}
2 changes: 1 addition & 1 deletion src/viewport/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class Viewport extends React.Component<
this.lastRenderTime = Date.now();
this.startTime = Date.now();
this.onPickObject = this.onPickObject.bind(this);
this.stats = Stats();
this.stats = new Stats();
this.stats.showPanel(1);

this.handlers = {
Expand Down
4 changes: 2 additions & 2 deletions src/visGeometry/rendering/GBufferPass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
Points,
Scene,
WebGLRenderer,
WebGLMultipleRenderTargets,
WebGLRenderTarget,
} from "three";

// strategy:
Expand Down Expand Up @@ -72,7 +72,7 @@ class GBufferPass {
renderer: WebGLRenderer,
scene: Scene,
camera: PerspectiveCamera | OrthographicCamera,
gbuffer: WebGLMultipleRenderTargets
gbuffer: WebGLRenderTarget
): void {
const c = renderer.getClearColor(new Color()).clone();
const a = renderer.getClearAlpha();
Expand Down
35 changes: 17 additions & 18 deletions src/visGeometry/rendering/SimulariumRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
PerspectiveCamera,
RGBAFormat,
Scene,
WebGLMultipleRenderTargets,
WebGLRenderer,
WebGLRenderTarget,
} from "three";
Expand Down Expand Up @@ -60,7 +59,7 @@ class SimulariumRenderer {
public compositePass: CompositePass;
public contourPass: ContourPass;
public drawBufferPass: DrawBufferPass;
public gbuffer: WebGLMultipleRenderTargets;
public gbuffer: WebGLRenderTarget;
private hitTestHelper: HitTestHelper;
public blurIntermediateBuffer: WebGLRenderTarget;
public ssaoBuffer: WebGLRenderTarget;
Expand Down Expand Up @@ -120,18 +119,18 @@ class SimulariumRenderer {
this.drawBufferPass = new DrawBufferPass();

// buffers:
this.gbuffer = new WebGLMultipleRenderTargets(2, 2, 3);
for (let i = 0, il = this.gbuffer.texture.length; i < il; i++) {
this.gbuffer.texture[i].minFilter = NearestFilter;
this.gbuffer.texture[i].magFilter = NearestFilter;
this.gbuffer.texture[i].format = RGBAFormat;
this.gbuffer.texture[i].type = FloatType;
this.gbuffer.texture[i].generateMipmaps = false;
}
this.gbuffer = new WebGLRenderTarget(2, 2, {
count: 3,
minFilter: NearestFilter,
magFilter: NearestFilter,
format: RGBAFormat,
type: FloatType,
generateMipmaps: false,
});
// Name our G-Buffer attachments for debugging
this.gbuffer.texture[AGENTBUFFER].name = "agentinfo";
this.gbuffer.texture[NORMALBUFFER].name = "normal";
this.gbuffer.texture[POSITIONBUFFER].name = "position";
this.gbuffer.textures[AGENTBUFFER].name = "agentinfo";
this.gbuffer.textures[NORMALBUFFER].name = "normal";
this.gbuffer.textures[POSITIONBUFFER].name = "position";

this.hitTestHelper = new HitTestHelper();

Expand Down Expand Up @@ -276,7 +275,7 @@ class SimulariumRenderer {
}

public hitTest(renderer: WebGLRenderer, x: number, y: number): number {
const tex = this.gbuffer.texture[AGENTBUFFER];
const tex = this.gbuffer.textures[AGENTBUFFER];
const pixel = this.hitTestHelper.hitTest(
renderer,
tex,
Expand Down Expand Up @@ -411,14 +410,14 @@ class SimulariumRenderer {
renderer,
camera,
this.ssaoBuffer,
this.gbuffer.texture[NORMALBUFFER],
this.gbuffer.texture[POSITIONBUFFER]
this.gbuffer.textures[NORMALBUFFER],
this.gbuffer.textures[POSITIONBUFFER]
);
this.blur1Pass.render(
renderer,
this.ssaoBufferBlurred,
this.ssaoBuffer,
this.gbuffer.texture[POSITIONBUFFER],
this.gbuffer.textures[POSITIONBUFFER],
this.blurIntermediateBuffer
);

Expand All @@ -433,7 +432,7 @@ class SimulariumRenderer {
compositeTarget,
this.ssaoBufferBlurred,
this.ssaoBufferBlurred2,
this.gbuffer.texture[AGENTBUFFER]
this.gbuffer.textures[AGENTBUFFER]
);

this.contourPass.render(
Expand Down

0 comments on commit a57a7b1

Please sign in to comment.