angular-three-postprocessing 4.0.0-next.116 → 4.0.0-next.119
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/fesm2022/angular-three-postprocessing-n8ao.mjs +35 -0
- package/fesm2022/angular-three-postprocessing-n8ao.mjs.map +1 -1
- package/fesm2022/angular-three-postprocessing.mjs +930 -5
- package/fesm2022/angular-three-postprocessing.mjs.map +1 -1
- package/n8ao/README.md +143 -0
- package/package.json +1 -1
- package/types/angular-three-postprocessing-n8ao.d.ts +128 -0
- package/types/angular-three-postprocessing.d.ts +1156 -3
|
@@ -9,9 +9,37 @@ import { Group } from 'three';
|
|
|
9
9
|
import { isWebGL2Available } from 'three-stdlib';
|
|
10
10
|
import { easing } from 'maath';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Injection token for providing default effect options.
|
|
14
|
+
*
|
|
15
|
+
* Use `injectDefaultEffectOptions` to inject default options in effect components.
|
|
16
|
+
* Use `provideDefaultEffectOptions` to provide default options for effects.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* @Component({
|
|
21
|
+
* providers: [provideDefaultEffectOptions({ blendFunction: BlendFunction.ADD, opacity: 0.5 })]
|
|
22
|
+
* })
|
|
23
|
+
* export class MyEffect {}
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
12
26
|
const [injectDefaultEffectOptions, provideDefaultEffectOptions] = createNoopInjectionToken('Default Effect options');
|
|
27
|
+
/**
|
|
28
|
+
* Component that applies blend mode settings to a postprocessing effect.
|
|
29
|
+
*
|
|
30
|
+
* This component is used internally by effect components to apply `blendFunction`
|
|
31
|
+
* and `opacity` values to the effect's blend mode.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```html
|
|
35
|
+
* <ngt-bloom-effect *args="[options()]">
|
|
36
|
+
* <ngtp-effect-blend-mode />
|
|
37
|
+
* </ngt-bloom-effect>
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
13
40
|
class NgtpEffectBlendMode {
|
|
14
41
|
constructor() {
|
|
42
|
+
/** Reference to the parent NgtpEffect directive, if available */
|
|
15
43
|
this.effect = inject(NgtpEffect, { optional: true });
|
|
16
44
|
}
|
|
17
45
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: NgtpEffectBlendMode, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
@@ -36,13 +64,40 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
36
64
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
37
65
|
}]
|
|
38
66
|
}] });
|
|
67
|
+
/**
|
|
68
|
+
* Base directive for postprocessing effects that provides common functionality.
|
|
69
|
+
*
|
|
70
|
+
* This directive is used as a host directive by effect components to provide:
|
|
71
|
+
* - `blendFunction`: Controls how the effect blends with the scene
|
|
72
|
+
* - `opacity`: Controls the effect's opacity
|
|
73
|
+
* - Access to the camera and invalidate function from the store
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* @Component({
|
|
78
|
+
* hostDirectives: [{ directive: NgtpEffect, inputs: ['blendFunction', 'opacity'] }]
|
|
79
|
+
* })
|
|
80
|
+
* export class NgtpBloom {}
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
39
83
|
class NgtpEffect {
|
|
40
84
|
constructor() {
|
|
85
|
+
/** Default effect options injected from parent providers */
|
|
41
86
|
this.defaultEffectOptions = injectDefaultEffectOptions({ optional: true });
|
|
87
|
+
/**
|
|
88
|
+
* The blend function used to combine this effect with the scene.
|
|
89
|
+
* @see BlendFunction from postprocessing library
|
|
90
|
+
*/
|
|
42
91
|
this.blendFunction = input(this.defaultEffectOptions?.blendFunction, ...(ngDevMode ? [{ debugName: "blendFunction" }] : []));
|
|
92
|
+
/**
|
|
93
|
+
* The opacity of the effect.
|
|
94
|
+
* @default undefined (uses effect's default)
|
|
95
|
+
*/
|
|
43
96
|
this.opacity = input(this.defaultEffectOptions?.opacity, ...(ngDevMode ? [{ debugName: "opacity" }] : []));
|
|
44
97
|
this.store = injectStore();
|
|
98
|
+
/** The current camera from the store */
|
|
45
99
|
this.camera = this.store.camera;
|
|
100
|
+
/** Function to invalidate the render loop, triggering a re-render */
|
|
46
101
|
this.invalidate = this.store.invalidate;
|
|
47
102
|
}
|
|
48
103
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: NgtpEffect, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
@@ -59,11 +114,45 @@ const defaultOptions$5 = {
|
|
|
59
114
|
multisampling: 8,
|
|
60
115
|
frameBufferType: THREE.HalfFloatType,
|
|
61
116
|
};
|
|
117
|
+
/**
|
|
118
|
+
* Checks if an effect has the convolution attribute.
|
|
119
|
+
*
|
|
120
|
+
* @param effect - The effect to check
|
|
121
|
+
* @returns True if the effect has the convolution attribute
|
|
122
|
+
*/
|
|
62
123
|
function isConvolution(effect) {
|
|
63
124
|
return (effect.getAttributes() & EffectAttribute.CONVOLUTION) === EffectAttribute.CONVOLUTION;
|
|
64
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Angular component that manages postprocessing effects for a Three.js scene.
|
|
128
|
+
*
|
|
129
|
+
* The effect composer wraps the postprocessing library's EffectComposer and provides
|
|
130
|
+
* a declarative way to add effects to your scene. Effects are added as children of
|
|
131
|
+
* this component and are automatically composed into an effect pass.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```html
|
|
135
|
+
* <ngtp-effect-composer>
|
|
136
|
+
* <ngtp-bloom [options]="{ intensity: 1, luminanceThreshold: 0.9 }" />
|
|
137
|
+
* <ngtp-vignette [options]="{ darkness: 0.5 }" />
|
|
138
|
+
* </ngtp-effect-composer>
|
|
139
|
+
* ```
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```html
|
|
143
|
+
* <!-- With custom options -->
|
|
144
|
+
* <ngtp-effect-composer [options]="{ multisampling: 4, autoClear: false }">
|
|
145
|
+
* <ngtp-smaa />
|
|
146
|
+
* <ngtp-tone-mapping />
|
|
147
|
+
* </ngtp-effect-composer>
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
65
150
|
class NgtpEffectComposer {
|
|
66
151
|
constructor() {
|
|
152
|
+
/**
|
|
153
|
+
* Configuration options for the effect composer.
|
|
154
|
+
* @see NgtpEffectComposerOptions
|
|
155
|
+
*/
|
|
67
156
|
this.options = input(defaultOptions$5, { ...(ngDevMode ? { debugName: "options" } : {}), transform: mergeInputs(defaultOptions$5) });
|
|
68
157
|
this.store = injectStore();
|
|
69
158
|
this.depthBuffer = pick(this.options, 'depthBuffer');
|
|
@@ -74,15 +163,31 @@ class NgtpEffectComposer {
|
|
|
74
163
|
this.resolutionScale = pick(this.options, 'resolutionScale');
|
|
75
164
|
this.enabled = pick(this.options, 'enabled');
|
|
76
165
|
this.renderPriority = pick(this.options, 'renderPriority');
|
|
166
|
+
/**
|
|
167
|
+
* The scene used for rendering effects.
|
|
168
|
+
* Uses custom scene from options if provided, otherwise uses the store's scene.
|
|
169
|
+
*/
|
|
77
170
|
this.scene = computed(() => this.options().scene ?? this.store.scene(), ...(ngDevMode ? [{ debugName: "scene" }] : []));
|
|
171
|
+
/**
|
|
172
|
+
* The camera used for rendering effects.
|
|
173
|
+
* Uses custom camera from options if provided, otherwise uses the store's camera.
|
|
174
|
+
*/
|
|
78
175
|
this.camera = computed(() => this.options().camera ?? this.store.camera(), ...(ngDevMode ? [{ debugName: "camera" }] : []));
|
|
79
176
|
this.groupRef = viewChild.required('group');
|
|
177
|
+
/**
|
|
178
|
+
* Computed render priority based on whether the composer is enabled.
|
|
179
|
+
* Returns 0 when disabled, otherwise returns the configured renderPriority.
|
|
180
|
+
*/
|
|
80
181
|
this.priority = computed(() => {
|
|
81
182
|
const enabled = this.enabled();
|
|
82
183
|
if (!enabled)
|
|
83
184
|
return 0;
|
|
84
185
|
return this.renderPriority();
|
|
85
186
|
}, ...(ngDevMode ? [{ debugName: "priority" }] : []));
|
|
187
|
+
/**
|
|
188
|
+
* Creates and configures the effect composer with render pass, normal pass,
|
|
189
|
+
* and depth downsampling pass based on options.
|
|
190
|
+
*/
|
|
86
191
|
this.composerData = computed(() => {
|
|
87
192
|
const webGL2Available = isWebGL2Available();
|
|
88
193
|
const [gl, scene, camera, depthBuffer, stencilBuffer, multisampling, frameBufferType, enableNormalPass, resolutionScale,] = [
|
|
@@ -120,6 +225,10 @@ class NgtpEffectComposer {
|
|
|
120
225
|
}
|
|
121
226
|
return { composer, normalPass, downSamplingPass };
|
|
122
227
|
}, ...(ngDevMode ? [{ debugName: "composerData" }] : []));
|
|
228
|
+
/**
|
|
229
|
+
* The underlying postprocessing EffectComposer instance.
|
|
230
|
+
* Can be used to access the composer directly for advanced use cases.
|
|
231
|
+
*/
|
|
123
232
|
this.effectComposer = pick(this.composerData, 'composer');
|
|
124
233
|
extend({ Group });
|
|
125
234
|
// NOTE: Disable tone mapping because threejs disallows tonemapping on render targets
|
|
@@ -227,6 +336,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
227
336
|
}]
|
|
228
337
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], groupRef: [{ type: i0.ViewChild, args: ['group', { isSignal: true }] }] } });
|
|
229
338
|
|
|
339
|
+
/**
|
|
340
|
+
* Fragment shader for the ASCII effect.
|
|
341
|
+
* Converts the scene into ASCII character representation based on pixel brightness.
|
|
342
|
+
*/
|
|
230
343
|
const fragment = /* language=glsl glsl */ `
|
|
231
344
|
uniform sampler2D uCharacters;
|
|
232
345
|
uniform float uCharactersCount;
|
|
@@ -267,6 +380,21 @@ void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor)
|
|
|
267
380
|
outputColor = asciiCharacter;
|
|
268
381
|
}
|
|
269
382
|
`;
|
|
383
|
+
/**
|
|
384
|
+
* A postprocessing effect that renders the scene as ASCII art.
|
|
385
|
+
*
|
|
386
|
+
* This effect converts the rendered scene into a grid of ASCII characters,
|
|
387
|
+
* where the character used depends on the brightness of the underlying pixels.
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* ```typescript
|
|
391
|
+
* const effect = new ASCIIEffect({
|
|
392
|
+
* cellSize: 12,
|
|
393
|
+
* color: '#00ff00',
|
|
394
|
+
* characters: ' .:-=+*#%@'
|
|
395
|
+
* });
|
|
396
|
+
* ```
|
|
397
|
+
*/
|
|
270
398
|
class ASCIIEffect extends Effect {
|
|
271
399
|
constructor({ font = 'arial', characters = ` .:,'-^=*+?!|0#X%WM@`, fontSize = 54, cellSize = 16, color = '#ffffff', invert = false, } = {}) {
|
|
272
400
|
const uniforms = new Map([
|
|
@@ -282,7 +410,17 @@ class ASCIIEffect extends Effect {
|
|
|
282
410
|
charactersTextureUniform.value = this.createCharactersTexture(characters, font, fontSize);
|
|
283
411
|
}
|
|
284
412
|
}
|
|
285
|
-
/**
|
|
413
|
+
/**
|
|
414
|
+
* Creates a texture containing all the ASCII characters.
|
|
415
|
+
*
|
|
416
|
+
* Draws each character in the character set onto a canvas and creates
|
|
417
|
+
* a texture that can be sampled in the shader.
|
|
418
|
+
*
|
|
419
|
+
* @param characters - The character set to render
|
|
420
|
+
* @param font - The font family to use
|
|
421
|
+
* @param fontSize - The font size in pixels
|
|
422
|
+
* @returns A Three.js texture containing the rendered characters
|
|
423
|
+
*/
|
|
286
424
|
createCharactersTexture(characters, font, fontSize) {
|
|
287
425
|
const canvas = document.createElement('canvas');
|
|
288
426
|
const SIZE = 1024;
|
|
@@ -317,9 +455,27 @@ const defaultOptions$4 = {
|
|
|
317
455
|
color: '#ffffff',
|
|
318
456
|
invert: false,
|
|
319
457
|
};
|
|
458
|
+
/**
|
|
459
|
+
* Angular component that applies an ASCII art postprocessing effect to the scene.
|
|
460
|
+
*
|
|
461
|
+
* Renders the scene as ASCII characters, where character selection is based on
|
|
462
|
+
* the brightness of the underlying pixels.
|
|
463
|
+
*
|
|
464
|
+
* @example
|
|
465
|
+
* ```html
|
|
466
|
+
* <ngtp-effect-composer>
|
|
467
|
+
* <ngtp-ascii [options]="{ cellSize: 12, color: '#00ff00' }" />
|
|
468
|
+
* </ngtp-effect-composer>
|
|
469
|
+
* ```
|
|
470
|
+
*/
|
|
320
471
|
class NgtpASCII {
|
|
321
472
|
constructor() {
|
|
473
|
+
/**
|
|
474
|
+
* Configuration options for the ASCII effect.
|
|
475
|
+
* @see ASCIIEffectOptions
|
|
476
|
+
*/
|
|
322
477
|
this.options = input(defaultOptions$4, { ...(ngDevMode ? { debugName: "options" } : {}), transform: mergeInputs(defaultOptions$4) });
|
|
478
|
+
/** The underlying ASCIIEffect instance */
|
|
323
479
|
this.effect = computed(() => new ASCIIEffect(this.options()), ...(ngDevMode ? [{ debugName: "effect" }] : []));
|
|
324
480
|
effect((onCleanup) => {
|
|
325
481
|
const effect = this.effect();
|
|
@@ -344,9 +500,39 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
344
500
|
}]
|
|
345
501
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
346
502
|
|
|
503
|
+
/**
|
|
504
|
+
* Angular component that applies a bloom postprocessing effect to the scene.
|
|
505
|
+
*
|
|
506
|
+
* The bloom effect creates a glow around bright areas of the scene, simulating
|
|
507
|
+
* the way bright light bleeds in cameras and the human eye.
|
|
508
|
+
*
|
|
509
|
+
* @example
|
|
510
|
+
* ```html
|
|
511
|
+
* <ngtp-effect-composer>
|
|
512
|
+
* <ngtp-bloom [options]="{ intensity: 1, luminanceThreshold: 0.9 }" />
|
|
513
|
+
* </ngtp-effect-composer>
|
|
514
|
+
* ```
|
|
515
|
+
*
|
|
516
|
+
* @example
|
|
517
|
+
* ```html
|
|
518
|
+
* <!-- With custom blend function -->
|
|
519
|
+
* <ngtp-effect-composer>
|
|
520
|
+
* <ngtp-bloom
|
|
521
|
+
* [blendFunction]="BlendFunction.SCREEN"
|
|
522
|
+
* [options]="{ intensity: 0.5, luminanceSmoothing: 0.9 }"
|
|
523
|
+
* />
|
|
524
|
+
* </ngtp-effect-composer>
|
|
525
|
+
* ```
|
|
526
|
+
*/
|
|
347
527
|
class NgtpBloom {
|
|
348
528
|
constructor() {
|
|
529
|
+
/**
|
|
530
|
+
* Configuration options for the bloom effect.
|
|
531
|
+
* Accepts all BloomEffectOptions except blendFunction (use the blendFunction input instead).
|
|
532
|
+
* @see BloomEffectOptions from postprocessing library
|
|
533
|
+
*/
|
|
349
534
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
535
|
+
/** Reference to the host NgtpEffect directive */
|
|
350
536
|
this.effect = inject(NgtpEffect, { host: true });
|
|
351
537
|
extend({ BloomEffect });
|
|
352
538
|
}
|
|
@@ -376,9 +562,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
376
562
|
}]
|
|
377
563
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
378
564
|
|
|
565
|
+
/**
|
|
566
|
+
* Angular component that applies brightness and contrast adjustments to the scene.
|
|
567
|
+
*
|
|
568
|
+
* This effect allows you to modify the overall brightness and contrast of the
|
|
569
|
+
* rendered scene as a postprocessing step.
|
|
570
|
+
*
|
|
571
|
+
* @example
|
|
572
|
+
* ```html
|
|
573
|
+
* <ngtp-effect-composer>
|
|
574
|
+
* <ngtp-brightness-contrast [options]="{ brightness: 0.1, contrast: 0.2 }" />
|
|
575
|
+
* </ngtp-effect-composer>
|
|
576
|
+
* ```
|
|
577
|
+
*/
|
|
379
578
|
class NgtpBrightnessContrast {
|
|
380
579
|
constructor() {
|
|
580
|
+
/**
|
|
581
|
+
* Configuration options for the brightness/contrast effect.
|
|
582
|
+
* @see BrightnessEffectOptions
|
|
583
|
+
*/
|
|
381
584
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
585
|
+
/** Reference to the host NgtpEffect directive */
|
|
382
586
|
this.effect = inject(NgtpEffect, { host: true });
|
|
383
587
|
extend({ BrightnessContrastEffect });
|
|
384
588
|
}
|
|
@@ -407,9 +611,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
407
611
|
}]
|
|
408
612
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
409
613
|
|
|
614
|
+
/**
|
|
615
|
+
* Angular component that applies a chromatic aberration effect to the scene.
|
|
616
|
+
*
|
|
617
|
+
* Chromatic aberration simulates the color fringing that occurs in real camera lenses
|
|
618
|
+
* when different wavelengths of light are focused at different distances.
|
|
619
|
+
*
|
|
620
|
+
* @example
|
|
621
|
+
* ```html
|
|
622
|
+
* <ngtp-effect-composer>
|
|
623
|
+
* <ngtp-chromatic-aberration [options]="{ offset: [0.002, 0.002] }" />
|
|
624
|
+
* </ngtp-effect-composer>
|
|
625
|
+
* ```
|
|
626
|
+
*/
|
|
410
627
|
class NgtpChromaticAberration {
|
|
411
628
|
constructor() {
|
|
629
|
+
/**
|
|
630
|
+
* Configuration options for the chromatic aberration effect.
|
|
631
|
+
* @see ChromaticAberrationEffectOptions
|
|
632
|
+
*/
|
|
412
633
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
634
|
+
/** Reference to the host NgtpEffect directive */
|
|
413
635
|
this.effect = inject(NgtpEffect, { host: true });
|
|
414
636
|
extend({ ChromaticAberrationEffect });
|
|
415
637
|
}
|
|
@@ -438,8 +660,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
438
660
|
}]
|
|
439
661
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
440
662
|
|
|
663
|
+
/**
|
|
664
|
+
* Angular component that applies a color averaging effect to the scene.
|
|
665
|
+
*
|
|
666
|
+
* This effect converts the scene to grayscale by averaging the color channels,
|
|
667
|
+
* which can create a desaturated or monochrome look.
|
|
668
|
+
*
|
|
669
|
+
* @example
|
|
670
|
+
* ```html
|
|
671
|
+
* <ngtp-effect-composer>
|
|
672
|
+
* <ngtp-color-average />
|
|
673
|
+
* </ngtp-effect-composer>
|
|
674
|
+
* ```
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* ```html
|
|
678
|
+
* <!-- With custom blend function -->
|
|
679
|
+
* <ngtp-effect-composer>
|
|
680
|
+
* <ngtp-color-average [options]="{ blendFunction: BlendFunction.MULTIPLY }" />
|
|
681
|
+
* </ngtp-effect-composer>
|
|
682
|
+
* ```
|
|
683
|
+
*/
|
|
441
684
|
class NgtpColorAverage {
|
|
442
685
|
constructor() {
|
|
686
|
+
/**
|
|
687
|
+
* Configuration options for the color average effect.
|
|
688
|
+
* @default { blendFunction: BlendFunction.NORMAL }
|
|
689
|
+
*/
|
|
443
690
|
this.options = input({ blendFunction: BlendFunction.NORMAL }, { ...(ngDevMode ? { debugName: "options" } : {}), transform: mergeInputs({ blendFunction: BlendFunction.NORMAL }) });
|
|
444
691
|
extend({ ColorAverageEffect });
|
|
445
692
|
}
|
|
@@ -465,9 +712,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
465
712
|
}]
|
|
466
713
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
467
714
|
|
|
715
|
+
/**
|
|
716
|
+
* Angular component that applies a color depth reduction effect to the scene.
|
|
717
|
+
*
|
|
718
|
+
* This effect reduces the number of colors in the scene, creating a posterized
|
|
719
|
+
* or retro look similar to older display hardware with limited color palettes.
|
|
720
|
+
*
|
|
721
|
+
* @example
|
|
722
|
+
* ```html
|
|
723
|
+
* <ngtp-effect-composer>
|
|
724
|
+
* <ngtp-color-depth [options]="{ bits: 4 }" />
|
|
725
|
+
* </ngtp-effect-composer>
|
|
726
|
+
* ```
|
|
727
|
+
*/
|
|
468
728
|
class NgtpColorDepth {
|
|
469
729
|
constructor() {
|
|
730
|
+
/**
|
|
731
|
+
* Configuration options for the color depth effect.
|
|
732
|
+
* @see ColorDepthEffectOptions
|
|
733
|
+
*/
|
|
470
734
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
735
|
+
/** Reference to the host NgtpEffect directive */
|
|
471
736
|
this.effect = inject(NgtpEffect, { host: true });
|
|
472
737
|
extend({ ColorDepthEffect });
|
|
473
738
|
}
|
|
@@ -496,9 +761,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
496
761
|
}]
|
|
497
762
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
498
763
|
|
|
764
|
+
/**
|
|
765
|
+
* Angular component that visualizes the scene's depth buffer.
|
|
766
|
+
*
|
|
767
|
+
* This effect renders the depth information of the scene, which can be useful
|
|
768
|
+
* for debugging or creating stylized depth-based visualizations.
|
|
769
|
+
*
|
|
770
|
+
* @example
|
|
771
|
+
* ```html
|
|
772
|
+
* <ngtp-effect-composer>
|
|
773
|
+
* <ngtp-depth [options]="{ inverted: true }" />
|
|
774
|
+
* </ngtp-effect-composer>
|
|
775
|
+
* ```
|
|
776
|
+
*/
|
|
499
777
|
class NgtpDepth {
|
|
500
778
|
constructor() {
|
|
779
|
+
/**
|
|
780
|
+
* Configuration options for the depth effect.
|
|
781
|
+
* @see DepthEffectOptions
|
|
782
|
+
*/
|
|
501
783
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
784
|
+
/** Reference to the host NgtpEffect directive */
|
|
502
785
|
this.effect = inject(NgtpEffect, { host: true });
|
|
503
786
|
extend({ DepthEffect });
|
|
504
787
|
}
|
|
@@ -527,10 +810,40 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
527
810
|
}]
|
|
528
811
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
529
812
|
|
|
813
|
+
/**
|
|
814
|
+
* Angular component that applies a depth of field effect to the scene.
|
|
815
|
+
*
|
|
816
|
+
* This effect simulates the focus behavior of real camera lenses, blurring
|
|
817
|
+
* objects that are outside the focal range. Can be configured for autofocus
|
|
818
|
+
* by providing a target position.
|
|
819
|
+
*
|
|
820
|
+
* @example
|
|
821
|
+
* ```html
|
|
822
|
+
* <ngtp-effect-composer>
|
|
823
|
+
* <ngtp-depth-of-field [options]="{ focusDistance: 0, focalLength: 0.02, bokehScale: 2 }" />
|
|
824
|
+
* </ngtp-effect-composer>
|
|
825
|
+
* ```
|
|
826
|
+
*
|
|
827
|
+
* @example
|
|
828
|
+
* ```html
|
|
829
|
+
* <!-- With autofocus target -->
|
|
830
|
+
* <ngtp-effect-composer>
|
|
831
|
+
* <ngtp-depth-of-field [options]="{ target: [0, 0, 5], bokehScale: 3 }" />
|
|
832
|
+
* </ngtp-effect-composer>
|
|
833
|
+
* ```
|
|
834
|
+
*/
|
|
530
835
|
class NgtpDepthOfField {
|
|
531
836
|
constructor() {
|
|
837
|
+
/**
|
|
838
|
+
* Configuration options for the depth of field effect.
|
|
839
|
+
* @see DOFOptions
|
|
840
|
+
*/
|
|
532
841
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
533
842
|
this.effectComposer = inject(NgtpEffectComposer);
|
|
843
|
+
/**
|
|
844
|
+
* Creates the DepthOfFieldEffect instance with the configured options.
|
|
845
|
+
* Enables autofocus if a target is provided and applies depth texture settings.
|
|
846
|
+
*/
|
|
534
847
|
this.effect = computed(() => {
|
|
535
848
|
const [camera, options] = [this.effectComposer.camera(), this.options()];
|
|
536
849
|
const autoFocus = options.target != null;
|
|
@@ -570,9 +883,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
570
883
|
}]
|
|
571
884
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
572
885
|
|
|
886
|
+
/**
|
|
887
|
+
* Angular component that applies a dot screen effect to the scene.
|
|
888
|
+
*
|
|
889
|
+
* This effect overlays a pattern of dots on the scene, creating a halftone
|
|
890
|
+
* or comic book style appearance.
|
|
891
|
+
*
|
|
892
|
+
* @example
|
|
893
|
+
* ```html
|
|
894
|
+
* <ngtp-effect-composer>
|
|
895
|
+
* <ngtp-dot-screen [options]="{ scale: 1.5, angle: Math.PI * 0.25 }" />
|
|
896
|
+
* </ngtp-effect-composer>
|
|
897
|
+
* ```
|
|
898
|
+
*/
|
|
573
899
|
class NgtpDotScreen {
|
|
574
900
|
constructor() {
|
|
901
|
+
/**
|
|
902
|
+
* Configuration options for the dot screen effect.
|
|
903
|
+
* @see DotScreenEffectOptions
|
|
904
|
+
*/
|
|
575
905
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
906
|
+
/** Reference to the host NgtpEffect directive */
|
|
576
907
|
this.effect = inject(NgtpEffect, { host: true });
|
|
577
908
|
extend({ DotScreenEffect });
|
|
578
909
|
}
|
|
@@ -601,9 +932,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
601
932
|
}]
|
|
602
933
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
603
934
|
|
|
935
|
+
/**
|
|
936
|
+
* Angular component that applies Fast Approximate Anti-Aliasing (FXAA) to the scene.
|
|
937
|
+
*
|
|
938
|
+
* FXAA is a fast, single-pass anti-aliasing technique that smooths jagged edges
|
|
939
|
+
* in the rendered image. It's less demanding than multisampling but may blur
|
|
940
|
+
* some fine details.
|
|
941
|
+
*
|
|
942
|
+
* @example
|
|
943
|
+
* ```html
|
|
944
|
+
* <ngtp-effect-composer [options]="{ multisampling: 0 }">
|
|
945
|
+
* <ngtp-fxaa />
|
|
946
|
+
* </ngtp-effect-composer>
|
|
947
|
+
* ```
|
|
948
|
+
*/
|
|
604
949
|
class NgtpFXAA {
|
|
605
950
|
constructor() {
|
|
951
|
+
/**
|
|
952
|
+
* Configuration options for the FXAA effect.
|
|
953
|
+
* @see FXAAEffectOptions
|
|
954
|
+
*/
|
|
606
955
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
956
|
+
/** Reference to the host NgtpEffect directive */
|
|
607
957
|
this.effect = inject(NgtpEffect, { host: true });
|
|
608
958
|
extend({ FXAAEffect });
|
|
609
959
|
}
|
|
@@ -632,8 +982,35 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
632
982
|
}]
|
|
633
983
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
634
984
|
|
|
985
|
+
/**
|
|
986
|
+
* Angular component that applies a glitch effect to the scene.
|
|
987
|
+
*
|
|
988
|
+
* This effect simulates digital glitches with customizable timing, strength,
|
|
989
|
+
* and chromatic aberration. Can be toggled on/off and configured for different
|
|
990
|
+
* glitch modes.
|
|
991
|
+
*
|
|
992
|
+
* @example
|
|
993
|
+
* ```html
|
|
994
|
+
* <ngtp-effect-composer>
|
|
995
|
+
* <ngtp-glitch [options]="{ delay: [1.5, 3.5], duration: [0.6, 1.0] }" />
|
|
996
|
+
* </ngtp-effect-composer>
|
|
997
|
+
* ```
|
|
998
|
+
*
|
|
999
|
+
* @example
|
|
1000
|
+
* ```html
|
|
1001
|
+
* <!-- Constant glitch mode -->
|
|
1002
|
+
* <ngtp-effect-composer>
|
|
1003
|
+
* <ngtp-glitch [options]="{ mode: GlitchMode.CONSTANT_MILD, active: true }" />
|
|
1004
|
+
* </ngtp-effect-composer>
|
|
1005
|
+
* ```
|
|
1006
|
+
*/
|
|
635
1007
|
class NgtpGlitch {
|
|
636
1008
|
constructor() {
|
|
1009
|
+
/**
|
|
1010
|
+
* Configuration options for the glitch effect.
|
|
1011
|
+
* @default { active: true }
|
|
1012
|
+
* @see GlitchOptions
|
|
1013
|
+
*/
|
|
637
1014
|
this.options = input({ active: true }, { ...(ngDevMode ? { debugName: "options" } : {}), transform: mergeInputs({ active: true }) });
|
|
638
1015
|
this.active = pick(this.options, 'active');
|
|
639
1016
|
this.mode = pick(this.options, 'mode');
|
|
@@ -647,6 +1024,10 @@ class NgtpGlitch {
|
|
|
647
1024
|
this.chromaticAberrationOffset = vector2(this.options, 'chromaticAberrationOffset');
|
|
648
1025
|
this.strength = vector2(this.options, 'strength');
|
|
649
1026
|
this.store = injectStore();
|
|
1027
|
+
/**
|
|
1028
|
+
* The underlying GlitchEffect instance.
|
|
1029
|
+
* Created with the configured options and vector2 parameters.
|
|
1030
|
+
*/
|
|
650
1031
|
this.effect = computed(() => new GlitchEffect({
|
|
651
1032
|
ratio: this.ratio(),
|
|
652
1033
|
dtSize: this.dtSize(),
|
|
@@ -691,18 +1072,50 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
691
1072
|
}]
|
|
692
1073
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
693
1074
|
|
|
1075
|
+
/**
|
|
1076
|
+
* Angular component that applies a god rays (volumetric lighting) effect to the scene.
|
|
1077
|
+
*
|
|
1078
|
+
* This effect creates light shafts emanating from a light source, simulating
|
|
1079
|
+
* the way light scatters through atmospheric particles. Requires a sun/light
|
|
1080
|
+
* source mesh to generate the rays from.
|
|
1081
|
+
*
|
|
1082
|
+
* @example
|
|
1083
|
+
* ```html
|
|
1084
|
+
* <ngt-mesh #sun [position]="[0, 5, -10]">
|
|
1085
|
+
* <ngt-sphere-geometry />
|
|
1086
|
+
* <ngt-mesh-basic-material color="yellow" />
|
|
1087
|
+
* </ngt-mesh>
|
|
1088
|
+
*
|
|
1089
|
+
* <ngtp-effect-composer>
|
|
1090
|
+
* <ngtp-god-rays [options]="{ sun: sunRef, density: 0.96 }" />
|
|
1091
|
+
* </ngtp-effect-composer>
|
|
1092
|
+
* ```
|
|
1093
|
+
*/
|
|
694
1094
|
class NgtpGodRays {
|
|
695
1095
|
constructor() {
|
|
1096
|
+
/**
|
|
1097
|
+
* Configuration options for the god rays effect.
|
|
1098
|
+
* Must include a `sun` property with the light source reference.
|
|
1099
|
+
* @see GodRaysOptions
|
|
1100
|
+
*/
|
|
696
1101
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
697
1102
|
this.effectComposer = inject(NgtpEffectComposer);
|
|
698
1103
|
this.effectOptions = omit(this.options, ['sun']);
|
|
699
1104
|
this.sun = pick(this.options, 'sun');
|
|
1105
|
+
/**
|
|
1106
|
+
* Resolves the sun reference to the actual Three.js object.
|
|
1107
|
+
* Handles both direct references and function references.
|
|
1108
|
+
*/
|
|
700
1109
|
this.sunElement = computed(() => {
|
|
701
1110
|
const sun = this.sun();
|
|
702
1111
|
if (typeof sun === 'function')
|
|
703
1112
|
return resolveRef(sun());
|
|
704
1113
|
return resolveRef(sun);
|
|
705
1114
|
}, ...(ngDevMode ? [{ debugName: "sunElement" }] : []));
|
|
1115
|
+
/**
|
|
1116
|
+
* The underlying GodRaysEffect instance.
|
|
1117
|
+
* Created with the camera, sun element, and configured options.
|
|
1118
|
+
*/
|
|
706
1119
|
this.effect = computed(() => {
|
|
707
1120
|
const [camera, sunElement, options] = [this.effectComposer.camera(), this.sunElement(), this.effectOptions()];
|
|
708
1121
|
return new GodRaysEffect(camera, sunElement, options);
|
|
@@ -737,11 +1150,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
737
1150
|
}]
|
|
738
1151
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
739
1152
|
|
|
1153
|
+
/**
|
|
1154
|
+
* Angular component that applies a grid overlay effect to the scene.
|
|
1155
|
+
*
|
|
1156
|
+
* This effect overlays a grid pattern on the rendered scene, which can be
|
|
1157
|
+
* useful for technical visualization or stylized effects.
|
|
1158
|
+
*
|
|
1159
|
+
* @example
|
|
1160
|
+
* ```html
|
|
1161
|
+
* <ngtp-effect-composer>
|
|
1162
|
+
* <ngtp-grid [options]="{ scale: 1.5, lineWidth: 0.5 }" />
|
|
1163
|
+
* </ngtp-effect-composer>
|
|
1164
|
+
* ```
|
|
1165
|
+
*/
|
|
740
1166
|
class NgtpGrid {
|
|
741
1167
|
constructor() {
|
|
1168
|
+
/**
|
|
1169
|
+
* Configuration options for the grid effect.
|
|
1170
|
+
* @see GridOptions
|
|
1171
|
+
*/
|
|
742
1172
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
743
1173
|
this.effectOptions = omit(this.options, ['size']);
|
|
744
1174
|
this.size = pick(this.options, 'size');
|
|
1175
|
+
/** The underlying GridEffect instance */
|
|
745
1176
|
this.effect = computed(() => new GridEffect(this.effectOptions()), ...(ngDevMode ? [{ debugName: "effect" }] : []));
|
|
746
1177
|
effect(() => {
|
|
747
1178
|
const [size, effect] = [this.size(), this.effect()];
|
|
@@ -772,9 +1203,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
772
1203
|
}]
|
|
773
1204
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
774
1205
|
|
|
1206
|
+
/**
|
|
1207
|
+
* Angular component that applies hue and saturation adjustments to the scene.
|
|
1208
|
+
*
|
|
1209
|
+
* This effect allows you to shift the hue and adjust the saturation of the
|
|
1210
|
+
* rendered scene as a postprocessing step.
|
|
1211
|
+
*
|
|
1212
|
+
* @example
|
|
1213
|
+
* ```html
|
|
1214
|
+
* <ngtp-effect-composer>
|
|
1215
|
+
* <ngtp-hue-saturation [options]="{ hue: 0.5, saturation: 0.2 }" />
|
|
1216
|
+
* </ngtp-effect-composer>
|
|
1217
|
+
* ```
|
|
1218
|
+
*/
|
|
775
1219
|
class NgtpHueSaturation {
|
|
776
1220
|
constructor() {
|
|
1221
|
+
/**
|
|
1222
|
+
* Configuration options for the hue/saturation effect.
|
|
1223
|
+
* @see HueSaturationEffectOptions
|
|
1224
|
+
*/
|
|
777
1225
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
1226
|
+
/** Reference to the host NgtpEffect directive */
|
|
778
1227
|
this.effect = inject(NgtpEffect, { host: true });
|
|
779
1228
|
extend({ HueSaturationEffect });
|
|
780
1229
|
}
|
|
@@ -803,8 +1252,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
803
1252
|
}]
|
|
804
1253
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
805
1254
|
|
|
806
|
-
|
|
807
|
-
|
|
1255
|
+
/**
|
|
1256
|
+
* Lens Flare Effect
|
|
1257
|
+
* Created by Anderson Mancini 2023
|
|
1258
|
+
* React Three Fiber Ultimate LensFlare - Ported to Angular Three
|
|
1259
|
+
*/
|
|
1260
|
+
/**
|
|
1261
|
+
* Shader configuration for the lens flare effect.
|
|
1262
|
+
* Contains the GLSL fragment shader code.
|
|
1263
|
+
*/
|
|
808
1264
|
const LensFlareShader = {
|
|
809
1265
|
fragmentShader: /* language=glsl glsl */ `
|
|
810
1266
|
|
|
@@ -852,7 +1308,46 @@ const LensFlareShader = {
|
|
|
852
1308
|
void mainImage(vec4 v,vec2 r,out vec4 i){vec2 g=r-.5;g.y*=iResolution.y/iResolution.x;vec2 l=lensPosition*.5;l.y*=iResolution.y/iResolution.x;vec3 f=mLs(g,l)*20.*colorGain/256.;if(aditionalStreaks){vec3 o=vec3(.9,.2,.1),p=vec3(.3,.1,.9);for(float n=0.;n<10.;n++)f+=drC(g,pow(rnd(n*2e3)*2.8,.1)+1.41,0.,o+n,p+n,rnd(n*20.)*3.+.2-.5,lensPosition);}if(secondaryGhosts){vec3 n=vec3(0);n+=rHx(g,-lensPosition*.25,ghostScale*1.4,vec3(.25,.35,0));n+=rHx(g,lensPosition*.25,ghostScale*.5,vec3(1,.5,.5));n+=rHx(g,lensPosition*.1,ghostScale*1.6,vec3(1));n+=rHx(g,lensPosition*1.8,ghostScale*2.,vec3(0,.5,.75));n+=rHx(g,lensPosition*1.25,ghostScale*.8,vec3(1,1,.5));n+=rHx(g,-lensPosition*1.25,ghostScale*5.,vec3(.5,.5,.25));n+=fpow(1.-abs(distance(lensPosition*.8,g)-.7),.985)*colorGain/2100.;f+=n;}if(starBurst){vxtC=g+.5;vec4 n=geLD(g);float o=1.-clamp(0.5,0.,.5)*2.;n+=mix(n,pow(n*2.,vec4(2))*.5,o);float s=(g.x+g.y)*(1./6.);vec2 d=mat2(cos(s),-sin(s),sin(s),cos(s))*vxtC;n+=geLS(d)*2.;f+=clamp(n.xyz*strB().xyz,.01,1.);}i=enabled?vec4(mix(f,vec3(0),opacity)+v.xyz,v.w):vec4(v);}
|
|
853
1309
|
`,
|
|
854
1310
|
};
|
|
1311
|
+
/**
|
|
1312
|
+
* A postprocessing effect that simulates camera lens flares.
|
|
1313
|
+
*
|
|
1314
|
+
* Creates realistic lens flare effects including glare, ghosts, star bursts,
|
|
1315
|
+
* and anamorphic flares. Can be animated and positioned dynamically.
|
|
1316
|
+
*
|
|
1317
|
+
* @example
|
|
1318
|
+
* ```typescript
|
|
1319
|
+
* const effect = new LensFlareEffect({
|
|
1320
|
+
* glareSize: 0.3,
|
|
1321
|
+
* starPoints: 8,
|
|
1322
|
+
* animated: true
|
|
1323
|
+
* });
|
|
1324
|
+
* ```
|
|
1325
|
+
*/
|
|
855
1326
|
class LensFlareEffect extends Effect {
|
|
1327
|
+
/**
|
|
1328
|
+
* Creates a new LensFlareEffect instance.
|
|
1329
|
+
*
|
|
1330
|
+
* @param options - Configuration options for the lens flare
|
|
1331
|
+
* @param options.blendFunction - How to blend with the scene
|
|
1332
|
+
* @param options.enabled - Whether the effect is enabled
|
|
1333
|
+
* @param options.glareSize - Size of the glare
|
|
1334
|
+
* @param options.lensPosition - Position of the lens on screen
|
|
1335
|
+
* @param options.iResolution - Resolution of the effect
|
|
1336
|
+
* @param options.starPoints - Number of points in the star pattern
|
|
1337
|
+
* @param options.flareSize - Size of individual flares
|
|
1338
|
+
* @param options.flareSpeed - Animation speed of flares
|
|
1339
|
+
* @param options.flareShape - Shape parameter for flares
|
|
1340
|
+
* @param options.animated - Whether to animate the effect
|
|
1341
|
+
* @param options.anamorphic - Enable anamorphic lens simulation
|
|
1342
|
+
* @param options.colorGain - Color tint for the effect
|
|
1343
|
+
* @param options.lensDirtTexture - Texture for lens dirt overlay
|
|
1344
|
+
* @param options.haloScale - Scale of the halo effect
|
|
1345
|
+
* @param options.secondaryGhosts - Enable secondary ghost images
|
|
1346
|
+
* @param options.aditionalStreaks - Enable additional streak effects
|
|
1347
|
+
* @param options.ghostScale - Scale of ghost images
|
|
1348
|
+
* @param options.opacity - Opacity of the effect
|
|
1349
|
+
* @param options.starBurst - Enable star burst effect
|
|
1350
|
+
*/
|
|
856
1351
|
constructor({ blendFunction = BlendFunction.NORMAL, enabled = true, glareSize = 0.2, lensPosition = [0.01, 0.01], iResolution = [0, 0], starPoints = 6, flareSize = 0.01, flareSpeed = 0.01, flareShape = 0.01, animated = true, anamorphic = false, colorGain = new THREE.Color(20, 20, 20), lensDirtTexture = null, haloScale = 0.5, secondaryGhosts = true, aditionalStreaks = true, ghostScale = 0.0, opacity = 1.0, starBurst = false, } = {}) {
|
|
857
1352
|
super('LensFlareEffect', LensFlareShader.fragmentShader, {
|
|
858
1353
|
blendFunction,
|
|
@@ -879,6 +1374,13 @@ class LensFlareEffect extends Effect {
|
|
|
879
1374
|
]),
|
|
880
1375
|
});
|
|
881
1376
|
}
|
|
1377
|
+
/**
|
|
1378
|
+
* Updates the effect's time uniform for animation.
|
|
1379
|
+
*
|
|
1380
|
+
* @param _renderer - The WebGL renderer (unused)
|
|
1381
|
+
* @param _inputBuffer - The input render target (unused)
|
|
1382
|
+
* @param deltaTime - Time elapsed since last frame
|
|
1383
|
+
*/
|
|
882
1384
|
update(_renderer, _inputBuffer, deltaTime) {
|
|
883
1385
|
const iTime = this.uniforms.get('iTime');
|
|
884
1386
|
if (iTime) {
|
|
@@ -891,15 +1393,44 @@ const defaultOptions$3 = {
|
|
|
891
1393
|
followMouse: false,
|
|
892
1394
|
smoothTime: 0.7,
|
|
893
1395
|
};
|
|
1396
|
+
/**
|
|
1397
|
+
* Angular component that applies a lens flare effect to the scene.
|
|
1398
|
+
*
|
|
1399
|
+
* This effect simulates realistic camera lens flares with support for
|
|
1400
|
+
* dynamic positioning, mouse following, and occlusion detection.
|
|
1401
|
+
* The flare automatically fades when occluded by scene objects.
|
|
1402
|
+
*
|
|
1403
|
+
* @example
|
|
1404
|
+
* ```html
|
|
1405
|
+
* <ngtp-effect-composer>
|
|
1406
|
+
* <ngtp-lens-flare [options]="{ position: [10, 5, -20], glareSize: 0.3 }" />
|
|
1407
|
+
* </ngtp-effect-composer>
|
|
1408
|
+
* ```
|
|
1409
|
+
*
|
|
1410
|
+
* @example
|
|
1411
|
+
* ```html
|
|
1412
|
+
* <!-- Mouse-following flare -->
|
|
1413
|
+
* <ngtp-effect-composer>
|
|
1414
|
+
* <ngtp-lens-flare [options]="{ followMouse: true, smoothTime: 0.5 }" />
|
|
1415
|
+
* </ngtp-effect-composer>
|
|
1416
|
+
* ```
|
|
1417
|
+
*/
|
|
894
1418
|
class NgtpLensFlare {
|
|
895
1419
|
constructor() {
|
|
1420
|
+
/**
|
|
1421
|
+
* Configuration options for the lens flare effect.
|
|
1422
|
+
* @see LensFlareOptions
|
|
1423
|
+
*/
|
|
896
1424
|
this.options = input(defaultOptions$3, { ...(ngDevMode ? { debugName: "options" } : {}), transform: mergeInputs(defaultOptions$3) });
|
|
897
1425
|
this.store = injectStore();
|
|
898
1426
|
this.effectComposer = inject(NgtpEffectComposer);
|
|
899
1427
|
this.effectOptions = omit(this.options, ['position', 'followMouse', 'smoothTime']);
|
|
900
1428
|
this.position = vector3(this.options, 'position');
|
|
1429
|
+
/** Cached vector for projecting 3D position to screen space */
|
|
901
1430
|
this.projectedPosition = new THREE.Vector3();
|
|
1431
|
+
/** Cached vector for 2D mouse/raycaster coordinates */
|
|
902
1432
|
this.mouse2d = new THREE.Vector2();
|
|
1433
|
+
/** The underlying LensFlareEffect instance */
|
|
903
1434
|
this.effect = computed(() => new LensFlareEffect(this.effectOptions()), ...(ngDevMode ? [{ debugName: "effect" }] : []));
|
|
904
1435
|
effect(() => {
|
|
905
1436
|
const [lensFlareEffect, width, height] = [
|
|
@@ -992,12 +1523,36 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
992
1523
|
}]
|
|
993
1524
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
994
1525
|
|
|
1526
|
+
/**
|
|
1527
|
+
* Angular component that applies a LUT (Look-Up Table) color grading effect.
|
|
1528
|
+
*
|
|
1529
|
+
* LUTs are used for color grading in film and photography. This effect applies
|
|
1530
|
+
* a 3D LUT texture to transform the colors of the rendered scene.
|
|
1531
|
+
*
|
|
1532
|
+
* @example
|
|
1533
|
+
* ```typescript
|
|
1534
|
+
* // In component
|
|
1535
|
+
* lutTexture = injectLoader(() => LUTCubeLoader, () => 'path/to/lut.cube');
|
|
1536
|
+
* ```
|
|
1537
|
+
*
|
|
1538
|
+
* ```html
|
|
1539
|
+
* <ngtp-effect-composer>
|
|
1540
|
+
* <ngtp-lut [options]="{ lut: lutTexture() }" />
|
|
1541
|
+
* </ngtp-effect-composer>
|
|
1542
|
+
* ```
|
|
1543
|
+
*/
|
|
995
1544
|
class NgtpLUT {
|
|
996
1545
|
constructor() {
|
|
1546
|
+
/**
|
|
1547
|
+
* Configuration options for the LUT effect.
|
|
1548
|
+
* Must include a `lut` texture.
|
|
1549
|
+
* @see LUTOptions
|
|
1550
|
+
*/
|
|
997
1551
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
998
1552
|
this.lut = pick(this.options, 'lut');
|
|
999
1553
|
this.tetrahedralInterpolation = pick(this.options, 'tetrahedralInterpolation');
|
|
1000
1554
|
this.store = injectStore();
|
|
1555
|
+
/** The underlying LUT3DEffect instance */
|
|
1001
1556
|
this.effect = computed(() => {
|
|
1002
1557
|
const { lut, ...options } = this.options();
|
|
1003
1558
|
return new LUT3DEffect(lut, options);
|
|
@@ -1038,9 +1593,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
1038
1593
|
}]
|
|
1039
1594
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
1040
1595
|
|
|
1596
|
+
/**
|
|
1597
|
+
* Angular component that applies a noise/grain effect to the scene.
|
|
1598
|
+
*
|
|
1599
|
+
* This effect adds film grain or noise to the rendered image, which can
|
|
1600
|
+
* add a cinematic quality or help hide banding in gradients.
|
|
1601
|
+
*
|
|
1602
|
+
* @example
|
|
1603
|
+
* ```html
|
|
1604
|
+
* <ngtp-effect-composer>
|
|
1605
|
+
* <ngtp-noise [options]="{ premultiply: true }" />
|
|
1606
|
+
* </ngtp-effect-composer>
|
|
1607
|
+
* ```
|
|
1608
|
+
*/
|
|
1041
1609
|
class NgtpNoise {
|
|
1042
1610
|
constructor() {
|
|
1611
|
+
/**
|
|
1612
|
+
* Configuration options for the noise effect.
|
|
1613
|
+
* @see NoiseEffectOptions
|
|
1614
|
+
*/
|
|
1043
1615
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
1616
|
+
/** Reference to the host NgtpEffect directive */
|
|
1044
1617
|
this.effect = inject(NgtpEffect, { host: true });
|
|
1045
1618
|
extend({ NoiseEffect });
|
|
1046
1619
|
}
|
|
@@ -1073,8 +1646,39 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
1073
1646
|
const defaultOptions$2 = {
|
|
1074
1647
|
selectionLayer: 10,
|
|
1075
1648
|
};
|
|
1649
|
+
/**
|
|
1650
|
+
* Angular component that applies an outline effect to selected objects.
|
|
1651
|
+
*
|
|
1652
|
+
* This effect draws an outline around specified objects in the scene.
|
|
1653
|
+
* Can be used with NgtSelectionApi for declarative selection or with
|
|
1654
|
+
* manual selection via the options input.
|
|
1655
|
+
*
|
|
1656
|
+
* @example
|
|
1657
|
+
* ```html
|
|
1658
|
+
* <!-- With NgtSelectionApi (recommended) -->
|
|
1659
|
+
* <ngt-group [select]="hovered()" (pointerenter)="hovered.set(true)">
|
|
1660
|
+
* <ngt-mesh>...</ngt-mesh>
|
|
1661
|
+
* </ngt-group>
|
|
1662
|
+
*
|
|
1663
|
+
* <ngtp-effect-composer>
|
|
1664
|
+
* <ngtp-outline [options]="{ edgeStrength: 2.5, blur: true }" />
|
|
1665
|
+
* </ngtp-effect-composer>
|
|
1666
|
+
* ```
|
|
1667
|
+
*
|
|
1668
|
+
* @example
|
|
1669
|
+
* ```html
|
|
1670
|
+
* <!-- With manual selection -->
|
|
1671
|
+
* <ngtp-effect-composer>
|
|
1672
|
+
* <ngtp-outline [options]="{ selection: [meshRef.nativeElement], edgeStrength: 5 }" />
|
|
1673
|
+
* </ngtp-effect-composer>
|
|
1674
|
+
* ```
|
|
1675
|
+
*/
|
|
1076
1676
|
class NgtpOutline {
|
|
1077
1677
|
constructor() {
|
|
1678
|
+
/**
|
|
1679
|
+
* Configuration options for the outline effect.
|
|
1680
|
+
* @see NgtpOutlineOptions
|
|
1681
|
+
*/
|
|
1078
1682
|
this.options = input(defaultOptions$2, { ...(ngDevMode ? { debugName: "options" } : {}), transform: mergeInputs(defaultOptions$2) });
|
|
1079
1683
|
this.selectionApi = inject(NgtSelectionApi, { optional: true });
|
|
1080
1684
|
this.effectComposer = inject(NgtpEffectComposer);
|
|
@@ -1105,6 +1709,10 @@ class NgtpOutline {
|
|
|
1105
1709
|
'blur',
|
|
1106
1710
|
'xRay',
|
|
1107
1711
|
]);
|
|
1712
|
+
/**
|
|
1713
|
+
* The underlying OutlineEffect instance.
|
|
1714
|
+
* Created with the scene, camera, and configured options.
|
|
1715
|
+
*/
|
|
1108
1716
|
this.effect = computed(() => {
|
|
1109
1717
|
const [scene, camera, blendFunction, patternTexture, edgeStrength, pulseSpeed, visibleEdgeColor, hiddenEdgeColor, width, height, kernelSize, blur, xRay, restOptions,] = [
|
|
1110
1718
|
this.effectComposer.scene(),
|
|
@@ -1173,6 +1781,14 @@ class NgtpOutline {
|
|
|
1173
1781
|
});
|
|
1174
1782
|
});
|
|
1175
1783
|
}
|
|
1784
|
+
/**
|
|
1785
|
+
* Handles changes to the selection and updates the outline effect.
|
|
1786
|
+
*
|
|
1787
|
+
* @param selected - Function returning the currently selected objects
|
|
1788
|
+
* @param _effect - Function returning the OutlineEffect instance
|
|
1789
|
+
* @param _invalidate - Function returning the invalidate callback
|
|
1790
|
+
* @returns Cleanup function to clear the selection
|
|
1791
|
+
*/
|
|
1176
1792
|
handleSelectionChangeEffect(selected, _effect, _invalidate) {
|
|
1177
1793
|
const selection = selected();
|
|
1178
1794
|
if (!selection || selection.length === 0)
|
|
@@ -1212,10 +1828,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
1212
1828
|
}]
|
|
1213
1829
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
1214
1830
|
|
|
1831
|
+
/**
|
|
1832
|
+
* Angular component that applies a pixelation effect to the scene.
|
|
1833
|
+
*
|
|
1834
|
+
* This effect reduces the resolution of the rendered image to create
|
|
1835
|
+
* a retro, 8-bit style appearance.
|
|
1836
|
+
*
|
|
1837
|
+
* @example
|
|
1838
|
+
* ```html
|
|
1839
|
+
* <ngtp-effect-composer>
|
|
1840
|
+
* <ngtp-pixelation [options]="{ granularity: 10 }" />
|
|
1841
|
+
* </ngtp-effect-composer>
|
|
1842
|
+
* ```
|
|
1843
|
+
*/
|
|
1215
1844
|
class NgtpPixelation {
|
|
1216
1845
|
constructor() {
|
|
1846
|
+
/**
|
|
1847
|
+
* Configuration options for the pixelation effect.
|
|
1848
|
+
* @default { granularity: 5 }
|
|
1849
|
+
* @see PixelationOptions
|
|
1850
|
+
*/
|
|
1217
1851
|
this.options = input({ granularity: 5 }, { ...(ngDevMode ? { debugName: "options" } : {}), transform: mergeInputs({ granularity: 5 }) });
|
|
1218
1852
|
this.granularity = pick(this.options, 'granularity');
|
|
1853
|
+
/** The underlying PixelationEffect instance */
|
|
1219
1854
|
this.effect = computed(() => new PixelationEffect(this.granularity()), ...(ngDevMode ? [{ debugName: "effect" }] : []));
|
|
1220
1855
|
effect((onCleanup) => {
|
|
1221
1856
|
const effect = this.effect();
|
|
@@ -1243,9 +1878,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
1243
1878
|
const defaultOptions$1 = {
|
|
1244
1879
|
density: 1.25,
|
|
1245
1880
|
};
|
|
1881
|
+
/**
|
|
1882
|
+
* Angular component that applies a scanline effect to the scene.
|
|
1883
|
+
*
|
|
1884
|
+
* This effect overlays horizontal scanlines on the image, simulating
|
|
1885
|
+
* the appearance of old CRT monitors or television screens.
|
|
1886
|
+
*
|
|
1887
|
+
* @example
|
|
1888
|
+
* ```html
|
|
1889
|
+
* <ngtp-effect-composer>
|
|
1890
|
+
* <ngtp-scanline [options]="{ density: 2.0 }" />
|
|
1891
|
+
* </ngtp-effect-composer>
|
|
1892
|
+
* ```
|
|
1893
|
+
*/
|
|
1246
1894
|
class NgtpScanline {
|
|
1247
1895
|
constructor() {
|
|
1896
|
+
/**
|
|
1897
|
+
* Configuration options for the scanline effect.
|
|
1898
|
+
* @default { density: 1.25 }
|
|
1899
|
+
* @see ScanlineEffectOptions
|
|
1900
|
+
*/
|
|
1248
1901
|
this.options = input(defaultOptions$1, { ...(ngDevMode ? { debugName: "options" } : {}), transform: mergeInputs(defaultOptions$1) });
|
|
1902
|
+
/** Reference to the host NgtpEffect directive */
|
|
1249
1903
|
this.effect = inject(NgtpEffect, { host: true });
|
|
1250
1904
|
extend({ ScanlineEffect });
|
|
1251
1905
|
}
|
|
@@ -1275,17 +1929,50 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
1275
1929
|
}]
|
|
1276
1930
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
1277
1931
|
|
|
1278
|
-
// const addLight = (light: Object3D, effect: SelectiveBloomEffect) => light.layers.enable(effect.selection.layer)
|
|
1279
|
-
// const removeLight = (light: Object3D, effect: SelectiveBloomEffect) => light.layers.disable(effect.selection.layer)
|
|
1280
1932
|
const defaultOptions = {
|
|
1281
1933
|
selectionLayer: 10,
|
|
1282
1934
|
inverted: false,
|
|
1283
1935
|
ignoreBackground: false,
|
|
1284
1936
|
};
|
|
1937
|
+
/**
|
|
1938
|
+
* Angular component that applies bloom only to selected objects.
|
|
1939
|
+
*
|
|
1940
|
+
* Unlike the standard bloom effect, selective bloom allows you to specify
|
|
1941
|
+
* which objects should glow. Requires light sources to be provided for
|
|
1942
|
+
* proper rendering.
|
|
1943
|
+
*
|
|
1944
|
+
* Can be used with NgtSelectionApi for declarative selection or with
|
|
1945
|
+
* manual selection via the selection input.
|
|
1946
|
+
*
|
|
1947
|
+
* @example
|
|
1948
|
+
* ```html
|
|
1949
|
+
* <ngtp-effect-composer>
|
|
1950
|
+
* <ngtp-selective-bloom
|
|
1951
|
+
* [lights]="[ambientLightRef, pointLightRef]"
|
|
1952
|
+
* [selection]="[glowingMeshRef]"
|
|
1953
|
+
* [options]="{ intensity: 2, luminanceThreshold: 0 }"
|
|
1954
|
+
* />
|
|
1955
|
+
* </ngtp-effect-composer>
|
|
1956
|
+
* ```
|
|
1957
|
+
*/
|
|
1285
1958
|
class NgtpSelectiveBloom {
|
|
1286
1959
|
constructor() {
|
|
1960
|
+
/**
|
|
1961
|
+
* Light sources that should be included in the bloom calculation.
|
|
1962
|
+
* Required for proper selective bloom rendering.
|
|
1963
|
+
*/
|
|
1287
1964
|
this.lights = input.required(...(ngDevMode ? [{ debugName: "lights" }] : []));
|
|
1965
|
+
/**
|
|
1966
|
+
* Objects to apply bloom to.
|
|
1967
|
+
* Can be a single object, array of objects, or ElementRefs.
|
|
1968
|
+
* Not needed if using NgtSelectionApi.
|
|
1969
|
+
* @default []
|
|
1970
|
+
*/
|
|
1288
1971
|
this.selection = input([], ...(ngDevMode ? [{ debugName: "selection" }] : []));
|
|
1972
|
+
/**
|
|
1973
|
+
* Configuration options for the selective bloom effect.
|
|
1974
|
+
* @see SelectiveBloomOptions
|
|
1975
|
+
*/
|
|
1289
1976
|
this.options = input(defaultOptions, { ...(ngDevMode ? { debugName: "options" } : {}), transform: mergeInputs(defaultOptions) });
|
|
1290
1977
|
this.blendFunction = pick(this.options, 'blendFunction');
|
|
1291
1978
|
this.luminanceThreshold = pick(this.options, 'luminanceThreshold');
|
|
@@ -1319,6 +2006,10 @@ class NgtpSelectiveBloom {
|
|
|
1319
2006
|
return [];
|
|
1320
2007
|
return this.selectionApi.selected().map((selected) => resolveRef(selected));
|
|
1321
2008
|
}, ...(ngDevMode ? [{ debugName: "resolvedNgtSelected" }] : []));
|
|
2009
|
+
/**
|
|
2010
|
+
* The underlying SelectiveBloomEffect instance.
|
|
2011
|
+
* Created with the scene, camera, and configured options.
|
|
2012
|
+
*/
|
|
1322
2013
|
this.effect = computed(() => {
|
|
1323
2014
|
const effect = new SelectiveBloomEffect(this.effectComposer.scene(), this.effectComposer.camera(), {
|
|
1324
2015
|
blendFunction: this.blendFunction() || BlendFunction.ADD,
|
|
@@ -1388,9 +2079,21 @@ class NgtpSelectiveBloom {
|
|
|
1388
2079
|
});
|
|
1389
2080
|
});
|
|
1390
2081
|
}
|
|
2082
|
+
/**
|
|
2083
|
+
* Enables the selection layer on a light source.
|
|
2084
|
+
*
|
|
2085
|
+
* @param effect - The SelectiveBloomEffect instance
|
|
2086
|
+
* @param light - The light to enable on the selection layer
|
|
2087
|
+
*/
|
|
1391
2088
|
addLight(effect, light) {
|
|
1392
2089
|
light.layers.enable(effect.selection.layer);
|
|
1393
2090
|
}
|
|
2091
|
+
/**
|
|
2092
|
+
* Disables the selection layer on a light source.
|
|
2093
|
+
*
|
|
2094
|
+
* @param effect - The SelectiveBloomEffect instance
|
|
2095
|
+
* @param light - The light to disable from the selection layer
|
|
2096
|
+
*/
|
|
1394
2097
|
removeLight(effect, light) {
|
|
1395
2098
|
light.layers.disable(effect.selection.layer);
|
|
1396
2099
|
}
|
|
@@ -1412,9 +2115,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
1412
2115
|
}]
|
|
1413
2116
|
}], ctorParameters: () => [], propDecorators: { lights: [{ type: i0.Input, args: [{ isSignal: true, alias: "lights", required: true }] }], selection: [{ type: i0.Input, args: [{ isSignal: true, alias: "selection", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
1414
2117
|
|
|
2118
|
+
/**
|
|
2119
|
+
* Angular component that applies a sepia tone effect to the scene.
|
|
2120
|
+
*
|
|
2121
|
+
* This effect gives the rendered image a warm, brownish tint similar to
|
|
2122
|
+
* old photographs, creating a vintage or nostalgic appearance.
|
|
2123
|
+
*
|
|
2124
|
+
* @example
|
|
2125
|
+
* ```html
|
|
2126
|
+
* <ngtp-effect-composer>
|
|
2127
|
+
* <ngtp-sepia [options]="{ intensity: 0.5 }" />
|
|
2128
|
+
* </ngtp-effect-composer>
|
|
2129
|
+
* ```
|
|
2130
|
+
*/
|
|
1415
2131
|
class NgtpSepia {
|
|
1416
2132
|
constructor() {
|
|
2133
|
+
/**
|
|
2134
|
+
* Configuration options for the sepia effect.
|
|
2135
|
+
* @see SepiaEffectOptions
|
|
2136
|
+
*/
|
|
1417
2137
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
2138
|
+
/** Reference to the host NgtpEffect directive */
|
|
1418
2139
|
this.effect = inject(NgtpEffect, { host: true });
|
|
1419
2140
|
extend({ SepiaEffect });
|
|
1420
2141
|
}
|
|
@@ -1443,9 +2164,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
1443
2164
|
}]
|
|
1444
2165
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
1445
2166
|
|
|
2167
|
+
/**
|
|
2168
|
+
* Angular component that applies a shock wave distortion effect.
|
|
2169
|
+
*
|
|
2170
|
+
* This effect creates an expanding ring distortion that simulates a
|
|
2171
|
+
* shock wave or explosion ripple emanating from a point in the scene.
|
|
2172
|
+
*
|
|
2173
|
+
* @example
|
|
2174
|
+
* ```html
|
|
2175
|
+
* <ngtp-effect-composer>
|
|
2176
|
+
* <ngtp-shock-wave
|
|
2177
|
+
* [options]="{ speed: 2, maxRadius: 1, waveSize: 0.2, amplitude: 0.05 }"
|
|
2178
|
+
* />
|
|
2179
|
+
* </ngtp-effect-composer>
|
|
2180
|
+
* ```
|
|
2181
|
+
*/
|
|
1446
2182
|
class NgtpShockWave {
|
|
1447
2183
|
constructor() {
|
|
2184
|
+
/**
|
|
2185
|
+
* Configuration options for the shock wave effect.
|
|
2186
|
+
* @see ShockWaveEffectOptions
|
|
2187
|
+
*/
|
|
1448
2188
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
2189
|
+
/** Reference to the host NgtpEffect directive */
|
|
1449
2190
|
this.effect = inject(NgtpEffect, { host: true });
|
|
1450
2191
|
extend({ ShockWaveEffect });
|
|
1451
2192
|
}
|
|
@@ -1474,9 +2215,36 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
1474
2215
|
}]
|
|
1475
2216
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
1476
2217
|
|
|
2218
|
+
/**
|
|
2219
|
+
* Angular component that applies Subpixel Morphological Anti-Aliasing (SMAA).
|
|
2220
|
+
*
|
|
2221
|
+
* SMAA is a high-quality, efficient anti-aliasing technique that provides
|
|
2222
|
+
* better results than FXAA while being less demanding than multisampling.
|
|
2223
|
+
* It's particularly effective at smoothing edges while preserving sharpness.
|
|
2224
|
+
*
|
|
2225
|
+
* @example
|
|
2226
|
+
* ```html
|
|
2227
|
+
* <ngtp-effect-composer [options]="{ multisampling: 0 }">
|
|
2228
|
+
* <ngtp-smaa />
|
|
2229
|
+
* </ngtp-effect-composer>
|
|
2230
|
+
* ```
|
|
2231
|
+
*
|
|
2232
|
+
* @example
|
|
2233
|
+
* ```html
|
|
2234
|
+
* <!-- With preset -->
|
|
2235
|
+
* <ngtp-effect-composer>
|
|
2236
|
+
* <ngtp-smaa [options]="{ preset: SMAAPreset.ULTRA }" />
|
|
2237
|
+
* </ngtp-effect-composer>
|
|
2238
|
+
* ```
|
|
2239
|
+
*/
|
|
1477
2240
|
class NgtpSMAA {
|
|
1478
2241
|
constructor() {
|
|
2242
|
+
/**
|
|
2243
|
+
* Configuration options for the SMAA effect.
|
|
2244
|
+
* @see SMAAEffectOptions
|
|
2245
|
+
*/
|
|
1479
2246
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
2247
|
+
/** Reference to the host NgtpEffect directive */
|
|
1480
2248
|
this.effect = inject(NgtpEffect, { host: true });
|
|
1481
2249
|
extend({ SMAAEffect });
|
|
1482
2250
|
}
|
|
@@ -1505,9 +2273,32 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
1505
2273
|
}]
|
|
1506
2274
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
1507
2275
|
|
|
2276
|
+
/**
|
|
2277
|
+
* Angular component that applies a tilt-shift blur effect.
|
|
2278
|
+
*
|
|
2279
|
+
* This effect simulates the shallow depth of field look from tilt-shift
|
|
2280
|
+
* photography, creating a "miniature" or "diorama" appearance where only
|
|
2281
|
+
* a horizontal band of the image is in focus.
|
|
2282
|
+
*
|
|
2283
|
+
* Uses the postprocessing library's built-in TiltShiftEffect.
|
|
2284
|
+
*
|
|
2285
|
+
* @example
|
|
2286
|
+
* ```html
|
|
2287
|
+
* <ngtp-effect-composer>
|
|
2288
|
+
* <ngtp-tilt-shift [options]="{ blur: 0.5, offset: 0.5 }" />
|
|
2289
|
+
* </ngtp-effect-composer>
|
|
2290
|
+
* ```
|
|
2291
|
+
*
|
|
2292
|
+
* @see NgtpTiltShift2 for an alternative implementation with different parameters
|
|
2293
|
+
*/
|
|
1508
2294
|
class NgtpTiltShift {
|
|
1509
2295
|
constructor() {
|
|
2296
|
+
/**
|
|
2297
|
+
* Configuration options for the tilt-shift effect.
|
|
2298
|
+
* @see TiltShiftEffectOptions
|
|
2299
|
+
*/
|
|
1510
2300
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
2301
|
+
/** Reference to the host NgtpEffect directive */
|
|
1511
2302
|
this.effect = inject(NgtpEffect, { host: true });
|
|
1512
2303
|
extend({ TiltShiftEffect });
|
|
1513
2304
|
}
|
|
@@ -1537,6 +2328,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
1537
2328
|
}]
|
|
1538
2329
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
1539
2330
|
|
|
2331
|
+
/**
|
|
2332
|
+
* Custom tilt-shift shader based on Evan Wallace's implementation.
|
|
2333
|
+
* Provides line-based focus control with customizable blur parameters.
|
|
2334
|
+
*/
|
|
1540
2335
|
const TiltShiftShader = {
|
|
1541
2336
|
fragmentShader: /* language=glsl glsl */ `
|
|
1542
2337
|
|
|
@@ -1596,7 +2391,35 @@ const TiltShiftShader = {
|
|
|
1596
2391
|
}
|
|
1597
2392
|
`,
|
|
1598
2393
|
};
|
|
2394
|
+
/**
|
|
2395
|
+
* A custom tilt-shift effect with line-based focus control.
|
|
2396
|
+
*
|
|
2397
|
+
* This effect provides a different approach to tilt-shift compared to
|
|
2398
|
+
* the standard TiltShiftEffect, allowing you to define a focus line
|
|
2399
|
+
* between two screen-space points.
|
|
2400
|
+
*
|
|
2401
|
+
* @example
|
|
2402
|
+
* ```typescript
|
|
2403
|
+
* const effect = new TiltShift2Effect({
|
|
2404
|
+
* blur: 0.2,
|
|
2405
|
+
* start: [0.5, 0.3],
|
|
2406
|
+
* end: [0.5, 0.7]
|
|
2407
|
+
* });
|
|
2408
|
+
* ```
|
|
2409
|
+
*/
|
|
1599
2410
|
class TiltShift2Effect extends Effect {
|
|
2411
|
+
/**
|
|
2412
|
+
* Creates a new TiltShift2Effect instance.
|
|
2413
|
+
*
|
|
2414
|
+
* @param options - Configuration options
|
|
2415
|
+
* @param options.blendFunction - How to blend with the scene
|
|
2416
|
+
* @param options.blur - Blur intensity [0, 1], can exceed 1 for more blur
|
|
2417
|
+
* @param options.taper - Taper of the focus area [0, 1]
|
|
2418
|
+
* @param options.start - Start point of focus line in screen space [x, y]
|
|
2419
|
+
* @param options.end - End point of focus line in screen space [x, y]
|
|
2420
|
+
* @param options.samples - Number of blur samples
|
|
2421
|
+
* @param options.direction - Direction of the blur
|
|
2422
|
+
*/
|
|
1600
2423
|
constructor({ blendFunction = BlendFunction.NORMAL, blur = 0.15, // [0, 1], can go beyond 1 for extra
|
|
1601
2424
|
taper = 0.5, // [0, 1], can go beyond 1 for extra
|
|
1602
2425
|
start = [0.5, 0.0], // [0,1] percentage x,y of screenspace
|
|
@@ -1619,9 +2442,30 @@ class TiltShift2Effect extends Effect {
|
|
|
1619
2442
|
}
|
|
1620
2443
|
}
|
|
1621
2444
|
extend({ TiltShift2Effect });
|
|
2445
|
+
/**
|
|
2446
|
+
* Angular component that applies an alternative tilt-shift effect.
|
|
2447
|
+
*
|
|
2448
|
+
* This effect uses a line-based focus system where you define start and
|
|
2449
|
+
* end points in screen space. The area between these points stays in focus
|
|
2450
|
+
* while the rest of the image is blurred.
|
|
2451
|
+
*
|
|
2452
|
+
* @example
|
|
2453
|
+
* ```html
|
|
2454
|
+
* <ngtp-effect-composer>
|
|
2455
|
+
* <ngtp-tilt-shift2 [options]="{ blur: 0.2, start: [0.5, 0.3], end: [0.5, 0.7] }" />
|
|
2456
|
+
* </ngtp-effect-composer>
|
|
2457
|
+
* ```
|
|
2458
|
+
*
|
|
2459
|
+
* @see NgtpTiltShift for the standard tilt-shift implementation
|
|
2460
|
+
*/
|
|
1622
2461
|
class NgtpTiltShift2 {
|
|
1623
2462
|
constructor() {
|
|
2463
|
+
/**
|
|
2464
|
+
* Configuration options for the tilt-shift effect.
|
|
2465
|
+
* @see TiltShift2EffectOptions
|
|
2466
|
+
*/
|
|
1624
2467
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
2468
|
+
/** Reference to the host NgtpEffect directive */
|
|
1625
2469
|
this.effect = inject(NgtpEffect, { host: true });
|
|
1626
2470
|
}
|
|
1627
2471
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: NgtpTiltShift2, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
@@ -1650,9 +2494,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
1650
2494
|
}]
|
|
1651
2495
|
}], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
1652
2496
|
|
|
2497
|
+
/**
|
|
2498
|
+
* Angular component that applies tone mapping to the scene.
|
|
2499
|
+
*
|
|
2500
|
+
* Tone mapping converts HDR (High Dynamic Range) values to LDR (Low Dynamic
|
|
2501
|
+
* Range) for display. Various tone mapping modes are available including
|
|
2502
|
+
* Reinhard, ACES Filmic, and custom linear options.
|
|
2503
|
+
*
|
|
2504
|
+
* Note: The effect composer disables Three.js's built-in tone mapping,
|
|
2505
|
+
* so this effect should be used if tone mapping is desired.
|
|
2506
|
+
*
|
|
2507
|
+
* @example
|
|
2508
|
+
* ```html
|
|
2509
|
+
* <ngtp-effect-composer>
|
|
2510
|
+
* <ngtp-tone-mapping [options]="{ mode: ToneMappingMode.ACES_FILMIC }" />
|
|
2511
|
+
* </ngtp-effect-composer>
|
|
2512
|
+
* ```
|
|
2513
|
+
*/
|
|
1653
2514
|
class NgtpToneMapping {
|
|
1654
2515
|
constructor() {
|
|
2516
|
+
/**
|
|
2517
|
+
* Configuration options for the tone mapping effect.
|
|
2518
|
+
* @see ToneMappingEffectOptions
|
|
2519
|
+
*/
|
|
1655
2520
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
2521
|
+
/** Reference to the host NgtpEffect directive */
|
|
1656
2522
|
this.effect = inject(NgtpEffect, { host: true });
|
|
1657
2523
|
extend({ ToneMappingEffect });
|
|
1658
2524
|
}
|
|
@@ -1681,9 +2547,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
1681
2547
|
}]
|
|
1682
2548
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
1683
2549
|
|
|
2550
|
+
/**
|
|
2551
|
+
* Angular component that applies a vignette effect to the scene.
|
|
2552
|
+
*
|
|
2553
|
+
* This effect darkens the corners and edges of the image, drawing the
|
|
2554
|
+
* viewer's attention to the center. It's a common cinematic technique
|
|
2555
|
+
* for creating focus and atmosphere.
|
|
2556
|
+
*
|
|
2557
|
+
* @example
|
|
2558
|
+
* ```html
|
|
2559
|
+
* <ngtp-effect-composer>
|
|
2560
|
+
* <ngtp-vignette [options]="{ darkness: 0.5, offset: 0.3 }" />
|
|
2561
|
+
* </ngtp-effect-composer>
|
|
2562
|
+
* ```
|
|
2563
|
+
*/
|
|
1684
2564
|
class NgtpVignette {
|
|
1685
2565
|
constructor() {
|
|
2566
|
+
/**
|
|
2567
|
+
* Configuration options for the vignette effect.
|
|
2568
|
+
* @see VignetteEffectOptions
|
|
2569
|
+
*/
|
|
1686
2570
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
2571
|
+
/** Reference to the host NgtpEffect directive */
|
|
1687
2572
|
this.effect = inject(NgtpEffect, { host: true });
|
|
1688
2573
|
extend({ VignetteEffect });
|
|
1689
2574
|
}
|
|
@@ -1712,6 +2597,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
1712
2597
|
}]
|
|
1713
2598
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
1714
2599
|
|
|
2600
|
+
/**
|
|
2601
|
+
* Shader configuration for the water distortion effect.
|
|
2602
|
+
* Creates a rippling, underwater-like distortion.
|
|
2603
|
+
*/
|
|
1715
2604
|
const WaterShader = {
|
|
1716
2605
|
fragmentShader: /* language=glsl glsl */ `
|
|
1717
2606
|
uniform float factor;
|
|
@@ -1727,7 +2616,25 @@ const WaterShader = {
|
|
|
1727
2616
|
outputColor = rgba;
|
|
1728
2617
|
}`,
|
|
1729
2618
|
};
|
|
2619
|
+
/**
|
|
2620
|
+
* A postprocessing effect that simulates an underwater/water distortion.
|
|
2621
|
+
*
|
|
2622
|
+
* Creates animated rippling distortion that makes the scene appear as if
|
|
2623
|
+
* viewed through water or a heat haze.
|
|
2624
|
+
*
|
|
2625
|
+
* @example
|
|
2626
|
+
* ```typescript
|
|
2627
|
+
* const effect = new WaterEffect({ factor: 0.5 });
|
|
2628
|
+
* ```
|
|
2629
|
+
*/
|
|
1730
2630
|
class WaterEffect extends Effect {
|
|
2631
|
+
/**
|
|
2632
|
+
* Creates a new WaterEffect instance.
|
|
2633
|
+
*
|
|
2634
|
+
* @param options - Configuration options
|
|
2635
|
+
* @param options.blendFunction - How to blend with the scene
|
|
2636
|
+
* @param options.factor - Intensity of the water effect (0 = no effect)
|
|
2637
|
+
*/
|
|
1731
2638
|
constructor({ blendFunction = BlendFunction.NORMAL, factor = 0 } = {}) {
|
|
1732
2639
|
super('WaterEffect', WaterShader.fragmentShader, {
|
|
1733
2640
|
blendFunction,
|
|
@@ -1736,9 +2643,27 @@ class WaterEffect extends Effect {
|
|
|
1736
2643
|
});
|
|
1737
2644
|
}
|
|
1738
2645
|
}
|
|
2646
|
+
/**
|
|
2647
|
+
* Angular component that applies a water/ripple distortion effect.
|
|
2648
|
+
*
|
|
2649
|
+
* This effect creates an animated underwater-like distortion that can
|
|
2650
|
+
* simulate viewing through water, heat haze, or a dream-like state.
|
|
2651
|
+
*
|
|
2652
|
+
* @example
|
|
2653
|
+
* ```html
|
|
2654
|
+
* <ngtp-effect-composer>
|
|
2655
|
+
* <ngtp-water [options]="{ factor: 0.5 }" />
|
|
2656
|
+
* </ngtp-effect-composer>
|
|
2657
|
+
* ```
|
|
2658
|
+
*/
|
|
1739
2659
|
class NgtpWater {
|
|
1740
2660
|
constructor() {
|
|
2661
|
+
/**
|
|
2662
|
+
* Configuration options for the water effect.
|
|
2663
|
+
* @see WaterEffectOptions
|
|
2664
|
+
*/
|
|
1741
2665
|
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
2666
|
+
/** Reference to the host NgtpEffect directive */
|
|
1742
2667
|
this.effect = inject(NgtpEffect, { host: true });
|
|
1743
2668
|
extend({ WaterEffect });
|
|
1744
2669
|
}
|