Skip to content

Commit 1d95f91

Browse files
committed
docs: update injectFBO usage
1 parent 6aa5917 commit 1d95f91

File tree

9 files changed

+24
-48
lines changed

9 files changed

+24
-48
lines changed

apps/examples/src/app/misc/particle-maxime/scene.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class FBOParticles {
9696
0,
9797
1, // top-left
9898
]);
99-
protected renderTarget = injectFBO(() => ({
99+
private renderTarget = injectFBO(() => ({
100100
width: this.size,
101101
height: this.size,
102102
settings: {
@@ -127,15 +127,15 @@ export class FBOParticles {
127127

128128
constructor() {
129129
injectBeforeRender(({ gl, clock }) => {
130-
gl.setRenderTarget(this.renderTarget());
130+
gl.setRenderTarget(this.renderTarget);
131131
gl.clear();
132132
gl.render(this.virtualScene, this.virtualCamera);
133133
gl.setRenderTarget(null);
134134

135135
const simulationMaterial = this.simulationMaterialRef()?.nativeElement;
136136
if (!simulationMaterial) return;
137137

138-
this.uniforms['uPositions'].value = this.renderTarget().texture;
138+
this.uniforms['uPositions'].value = this.renderTarget.texture;
139139
simulationMaterial.uniforms['uFrequency'].value = this.frequency();
140140
simulationMaterial.uniforms['uTime'].value = clock.elapsedTime * this.timeScale();
141141
});

apps/examples/src/app/soba/bruno-simons-20k/bruno-simons-20k.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ChangeDetectionStrategy, Component } from '@angular/core';
2+
import { NgtTweakCheckbox, NgtTweakPane } from 'angular-three-tweakpane';
23
import { NgtCanvas } from 'angular-three/dom';
3-
import { ToggleButton } from '../../toggle-button';
44
import { debug, SceneGraph, withN8ao } from './scene';
55

66
@Component({
@@ -14,14 +14,14 @@ import { debug, SceneGraph, withN8ao } from './scene';
1414
<app-bruno-scene-graph *canvasContent />
1515
</ngt-canvas>
1616
17-
<div class="absolute top-10 right-2 flex gap-2 items-center">
18-
<button [(toggleButton)]="debug">Toggle debug</button>
19-
<button [(toggleButton)]="withN8ao">Toggle N8ao</button>
20-
</div>
17+
<ngt-tweak-pane title="Bruno Simons 20k">
18+
<ngt-tweak-checkbox [(value)]="debug" label="debug" />
19+
<ngt-tweak-checkbox [(value)]="withN8ao" label="withN8ao" />
20+
</ngt-tweak-pane>
2121
`,
2222
changeDetection: ChangeDetectionStrategy.OnPush,
2323
host: { class: 'bruno-simons-2k-soba' },
24-
imports: [NgtCanvas, ToggleButton, SceneGraph],
24+
imports: [NgtCanvas, SceneGraph, NgtTweakPane, NgtTweakCheckbox],
2525
})
2626
export default class BrunoSimons20k {
2727
protected debug = debug;

apps/examples/src/app/soba/inverted-stencil-buffer/angular.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeDetectionStrategy, Component, computed, CUSTOM_ELEMENTS_SCHEMA, effect, input } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, computed, CUSTOM_ELEMENTS_SCHEMA, input } from '@angular/core';
22
import { injectGLTF } from 'angular-three-soba/loaders';
33
import { mask } from 'angular-three-soba/staging';
44
import { Mesh, MeshPhongMaterial, MeshStandardMaterial } from 'three';
@@ -37,10 +37,4 @@ export class Angular {
3737
const stencilParameters = this.stencilParameters();
3838
return new MeshPhongMaterial({ color: '#E72BAA', ...stencilParameters });
3939
});
40-
41-
constructor() {
42-
effect(() => {
43-
console.log(this.gltf());
44-
});
45-
}
4640
}
Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ChangeDetectionStrategy, Component } from '@angular/core';
2+
import { NgtTweakCheckbox, NgtTweakList, NgtTweakPane } from 'angular-three-tweakpane';
23
import { NgtCanvas } from 'angular-three/dom';
34
import { SceneGraph, invert, logo } from './scene';
45

@@ -7,35 +8,17 @@ import { SceneGraph, invert, logo } from './scene';
78
<ngt-canvas shadows [gl]="{ stencil: true }">
89
<app-inverted-stencil-buffer-scene-graph *canvasContent />
910
</ngt-canvas>
10-
<div
11-
class="absolute top-2 right-2 p-4 flex flex-col gap-4 items-center rounded border border-black border-dotted font-mono"
12-
>
13-
<label class="flex gap-2 items-center">
14-
<input type="checkbox" [value]="invert()" (change)="onInvertChange($event)" />
15-
invert
16-
</label>
17-
<select [value]="logo()" (change)="onLogoChange($event)">
18-
<option value="angular">Angular</option>
19-
<option value="nx">Nx</option>
20-
<option value="nx-cloud">Nx Cloud</option>
21-
</select>
22-
</div>
11+
12+
<ngt-tweak-pane title="Inverted Stencil Buffer">
13+
<ngt-tweak-checkbox [(value)]="invert" label="invert" />
14+
<ngt-tweak-list [(value)]="logo" [options]="['angular', 'nx', 'nx-cloud']" label="logo" />
15+
</ngt-tweak-pane>
2316
`,
2417
host: { class: 'inverted-stencil-buffer-soba' },
2518
changeDetection: ChangeDetectionStrategy.OnPush,
26-
imports: [NgtCanvas, SceneGraph],
19+
imports: [NgtCanvas, SceneGraph, NgtTweakPane, NgtTweakCheckbox, NgtTweakList],
2720
})
2821
export default class InvertedStencilBuffer {
2922
protected invert = invert;
3023
protected logo = logo;
31-
32-
onInvertChange(event: Event) {
33-
const target = event.target as HTMLInputElement;
34-
this.invert.set(target.checked);
35-
}
36-
37-
onLogoChange(event: Event) {
38-
const target = event.target as HTMLSelectElement;
39-
this.logo.set(target.value as 'angular' | 'nx' | 'nx-cloud');
40-
}
4124
}

apps/examples/src/app/soba/inverted-stencil-buffer/scene.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,13 @@ export class Box {
110110
</ngts-float>
111111
<ng-container [ngTemplateOutlet]="boxes" />
112112
</ngts-bounds>
113+
<ngts-orbit-controls [options]="{ makeDefault: true }" />
113114
} @else {
114115
<ng-container [ngTemplateOutlet]="logos" />
115116
<ng-container [ngTemplateOutlet]="boxes" />
116117
}
117118
118119
<ngts-environment [options]="{ preset: 'city' }" />
119-
@if (!asRenderTexture()) {
120-
<ngts-orbit-controls [options]="{ makeDefault: true }" />
121-
}
122120
123121
<ng-template #logos>
124122
@switch (logo()) {

apps/examples/src/app/soba/shoe-configuration/scene.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ export class Shoe {
110110
});
111111

112112
constructor() {
113-
effect(() => {
113+
effect((onCleanup) => {
114114
this.document.body.style.cursor = `url('data:image/svg+xml;base64,${this.cursor()}'), auto`;
115+
onCleanup(() => (this.document.body.style.cursor = 'auto'));
115116
});
116117
}
117118
}

libs/soba/src/cameras/cube-camera.stories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { storyDecorators, storyFunction } from '../setup-canvas';
1818
<ngts-cube-camera [options]="options()">
1919
<ngt-mesh *cameraContent="let texture" #mesh>
2020
<ngt-sphere-geometry *args="[5, 64, 64]" />
21-
<ngt-mesh-standard-material [roughness]="0" [metalness]="1" [envMap]="texture()" />
21+
<ngt-mesh-standard-material [roughness]="0" [metalness]="1" [envMap]="texture" />
2222
</ngt-mesh>
2323
</ngts-cube-camera>
2424
`,

libs/soba/src/materials/mesh-refraction-materials.stories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ injectLoader.preload(
4949
[rotation]="rotation()"
5050
[position]="position()"
5151
>
52-
<ngts-mesh-refraction-material [options]="options()" [envMap]="cameraTexture()" />
52+
<ngts-mesh-refraction-material [options]="options()" [envMap]="cameraTexture" />
5353
</ngt-mesh>
5454
</ngts-caustics>
5555
}

libs/soba/src/staging/spot-light.stories.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ class DefaultSpotLightStory {
117117
depthBuffer = injectDepthBuffer();
118118

119119
spotLightOneOptions = computed(() => ({
120-
depthBuffer: this.depthBuffer(),
120+
depthBuffer: this.depthBuffer,
121121
position: [3, 2, 0],
122122
color: '#ff005b',
123123
...this.options(),
124124
}));
125125
spotLightTwoOptions = computed(() => ({
126-
depthBuffer: this.depthBuffer(),
126+
depthBuffer: this.depthBuffer,
127127
position: [-3, 2, 0],
128128
color: '#0EEC82',
129129
...this.options(),

0 commit comments

Comments
 (0)