Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
fix(postprocessing): update effectPassParams$
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc committed Apr 20, 2022
1 parent 8c68283 commit ac2cdff
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions libs/postprocessing/src/lib/effect-composer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
NormalPass,
RenderPass,
} from 'postprocessing';
import { map, tap } from 'rxjs';
import { defer, EMPTY, map, of, tap } from 'rxjs';
import * as THREE from 'three';

export interface NgtEffectComposerState
Expand Down Expand Up @@ -138,8 +138,13 @@ export class NgtEffectComposer extends NgtInstance<
this.select((s) => s.camera),
this.select((s) => s.normalPass),
this.select((s) => s.depthDownSamplingPass),
this.select((s) => s.instance.value),
this.select((s) => s.instance.value.__ngt__.objects)
this.instance.ref$,
defer(() => {
if (this.instance.value) {
return this.instance.value.__ngt__.objects.ref$;
}
return of(null);
})
);

constructor(
Expand Down Expand Up @@ -265,14 +270,14 @@ export class NgtEffectComposer extends NgtInstance<
private readonly setBeforeRender = this.effect<{}>(
tapEffect(() => {
const { renderPriority, enabled } = this.get();
const gl = this.store.get((s) => s.gl);
const unregister = this.store.registerBeforeRender({
callback: ({ delta }) => {
const gl = this.store.get((s) => s.gl);
const { instance, autoClear } = this.get();
const { instance: composer, autoClear } = this.get();

if (enabled && instance.value) {
if (enabled && composer.value) {
gl.autoClear = autoClear;
instance.value.render(delta);
composer.value.render(delta);
}
},
priority: enabled ? renderPriority : 0,
Expand All @@ -295,12 +300,14 @@ export class NgtEffectComposer extends NgtInstance<
} = this.get();
if (
composer.value &&
composer.value.__ngt__.objects.length &&
composer.value.__ngt__.objects.value.length &&
camera
) {
effectPass = new EffectPass(
camera,
...(composer.value.__ngt__.objects as unknown as Effect[])
...composer.value.__ngt__.objects.value.map(
(ref) => ref.value
)
);
effectPass.renderToScreen = true;
composer.value.addPass(effectPass);
Expand Down

0 comments on commit ac2cdff

Please sign in to comment.