-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add FullScreenQuad directly to maintain bundle less support + Ou… (
#77) * fix: copy Pass/FullScreenQuad directly to maintain bundle less support + Outlines use empty {} as default input
- Loading branch information
Showing
5 changed files
with
61 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { OrthographicCamera, PlaneGeometry, Mesh, Material, Renderer, WebGLRenderer, WebGLRenderTarget } from 'three' | ||
|
||
class Pass { | ||
// if set to true, the pass is processed by the composer | ||
public enabled = true | ||
|
||
// if set to true, the pass indicates to swap read and write buffer after rendering | ||
public needsSwap = true | ||
|
||
// if set to true, the pass clears its buffer before rendering | ||
public clear = false | ||
|
||
// if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer. | ||
public renderToScreen = false | ||
|
||
public setSize(width: number, height: number): void {} | ||
|
||
public render( | ||
renderer: WebGLRenderer, | ||
writeBuffer: WebGLRenderTarget, | ||
readBuffer: WebGLRenderTarget, | ||
deltaTime: number, | ||
maskActive?: unknown | ||
): void { | ||
console.error('THREE.Pass: .render() must be implemented in derived pass.') | ||
} | ||
|
||
public dispose() {} | ||
} | ||
|
||
// Helper for passes that need to fill the viewport with a single quad. | ||
class FullScreenQuad<TMaterial extends Material = Material> { | ||
public camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1) | ||
public geometry = new PlaneGeometry(2, 2) | ||
private mesh: Mesh<PlaneGeometry, TMaterial> | ||
|
||
constructor(material: TMaterial) { | ||
this.mesh = new Mesh(this.geometry, material) | ||
} | ||
|
||
public get material(): TMaterial { | ||
return this.mesh.material | ||
} | ||
|
||
public set material(value: TMaterial) { | ||
this.mesh.material = value | ||
} | ||
|
||
public dispose(): void { | ||
this.mesh.geometry.dispose() | ||
} | ||
|
||
public render(renderer: Renderer): void { | ||
renderer.render(this.mesh, this.camera) | ||
} | ||
} | ||
|
||
export { Pass, FullScreenQuad } |
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