-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Formalized the progressive pipeline concept which removed a lot of du…
…plicated code
- Loading branch information
1 parent
58c86f3
commit 19250e8
Showing
12 changed files
with
73 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
packages/viewer/src/modules/pipeline/G/Pipelines/GProgressivePipeline.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { OrthographicCamera, PerspectiveCamera } from 'three' | ||
import { GPass, ProgressiveGPass } from '../GPass.js' | ||
import { GPipeline } from './GPipeline.js' | ||
|
||
export abstract class GProgressivePipeline extends GPipeline { | ||
protected accumulationFrameIndex: number = 0 | ||
protected accumulationFrameCount: number = 16 | ||
protected dynamicStage: Array<GPass> = [] | ||
protected progressiveStage: Array<GPass> = [] | ||
|
||
public update(camera: PerspectiveCamera | OrthographicCamera): void { | ||
this.passList.forEach((pass: GPass) => { | ||
pass.enabled && pass.update?.(camera) | ||
if (pass instanceof ProgressiveGPass) { | ||
pass.frameIndex = this.accumulationFrameIndex | ||
} | ||
}) | ||
this.accumulationFrameIndex++ | ||
|
||
if (this.accumulationFrameIndex === this.accumulationFrameCount) | ||
this.onAccumulationComplete() | ||
} | ||
|
||
public resize(width: number, height: number) { | ||
super.resize(width, height) | ||
this.dynamicStage.forEach((pass: GPass) => pass.setSize?.(width, height)) | ||
this.progressiveStage.forEach((pass: GPass) => pass.setSize?.(width, height)) | ||
} | ||
|
||
public onStationaryBegin() { | ||
this.accumulationFrameIndex = 0 | ||
this.passList = this.progressiveStage | ||
} | ||
|
||
public onStationaryEnd() { | ||
this.passList = this.dynamicStage | ||
} | ||
|
||
public onAccumulationComplete() { | ||
console.warn('Accumulation Complete') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.