angular-three-postprocessing 3.7.2 → 4.0.0-next.10

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.
Files changed (38) hide show
  1. package/fesm2022/angular-three-postprocessing-n8ao.mjs.map +1 -1
  2. package/fesm2022/angular-three-postprocessing.mjs +322 -173
  3. package/fesm2022/angular-three-postprocessing.mjs.map +1 -1
  4. package/lib/effect-composer.d.ts +8 -10
  5. package/lib/effect.d.ts +2 -2
  6. package/lib/effects/ascii.d.ts +3 -3
  7. package/lib/effects/bloom.d.ts +2 -1
  8. package/lib/effects/brightness-contrast.d.ts +2 -1
  9. package/lib/effects/chromatic-abberation.d.ts +2 -1
  10. package/lib/effects/color-average.d.ts +1 -0
  11. package/lib/effects/color-depth.d.ts +2 -1
  12. package/lib/effects/depth-of-field.d.ts +4 -5
  13. package/lib/effects/depth.d.ts +2 -1
  14. package/lib/effects/dot-screen.d.ts +2 -1
  15. package/lib/effects/fxaa.d.ts +2 -1
  16. package/lib/effects/glitch.d.ts +5 -1
  17. package/lib/effects/god-rays.d.ts +6 -3
  18. package/lib/effects/grid.d.ts +2 -1
  19. package/lib/effects/hue-saturation.d.ts +2 -1
  20. package/lib/effects/index.d.ts +1 -0
  21. package/lib/effects/lens-flare.d.ts +15 -15
  22. package/lib/effects/lut.d.ts +4 -4
  23. package/lib/effects/noise.d.ts +2 -1
  24. package/lib/effects/outline.d.ts +6 -7
  25. package/lib/effects/pixelation.d.ts +1 -1
  26. package/lib/effects/scanline.d.ts +2 -1
  27. package/lib/effects/selective-bloom.d.ts +42 -0
  28. package/lib/effects/sepia.d.ts +2 -1
  29. package/lib/effects/shock-wave.d.ts +2 -1
  30. package/lib/effects/smaa.d.ts +2 -1
  31. package/lib/effects/tilt-shift-2.d.ts +1 -1
  32. package/lib/effects/tilt-shift.d.ts +2 -1
  33. package/lib/effects/tone-mapping.d.ts +2 -1
  34. package/lib/effects/vignette.d.ts +2 -1
  35. package/lib/effects/water.d.ts +2 -1
  36. package/n8ao/lib/n8ao.d.ts +3 -3
  37. package/package.json +60 -60
  38. package/LICENSE +0 -21
@@ -1,10 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { inject, Component, CUSTOM_ELEMENTS_SCHEMA, ChangeDetectionStrategy, input, Directive, Injector, computed, viewChild, effect, untracked } from '@angular/core';
3
- import { injectStore, pick, extend, getLocalState, injectBeforeRender, NgtArgs, vector2, is, NgtSelection, omit, resolveRef } from 'angular-three';
3
+ import { injectStore, pick, extend, getInstanceState, injectBeforeRender, NgtArgs, vector2, omit, resolveRef, vector3, is, NgtSelection } from 'angular-three';
4
4
  import { createNoopInjectionToken } from 'ngxtension/create-injection-token';
5
5
  import { mergeInputs } from 'ngxtension/inject-inputs';
6
- import { EffectAttribute, EffectComposer, RenderPass, NormalPass, DepthDownsamplingPass, Effect, EffectPass, Pass, BloomEffect, BlendFunction, BrightnessContrastEffect, ChromaticAberrationEffect, ColorAverageEffect, ColorDepthEffect, DepthEffect, DepthOfFieldEffect, MaskFunction, DotScreenEffect, FXAAEffect, GlitchEffect, GlitchMode, GodRaysEffect, GridEffect, HueSaturationEffect, LUT3DEffect, NoiseEffect, OutlineEffect, PixelationEffect, ScanlineEffect, SepiaEffect, ShockWaveEffect, SMAAEffect, TiltShiftEffect, ToneMappingEffect, VignetteEffect } from 'postprocessing';
7
- import { HalfFloatType, Group, NoToneMapping, Uniform, Texture, Color, CanvasTexture, RepeatWrapping, NearestFilter, Vector3, Vector2, Mesh } from 'three';
6
+ import { EffectAttribute, EffectComposer, RenderPass, NormalPass, DepthDownsamplingPass, Effect, EffectPass, Pass, BloomEffect, BlendFunction, BrightnessContrastEffect, ChromaticAberrationEffect, ColorAverageEffect, ColorDepthEffect, DepthEffect, DepthOfFieldEffect, MaskFunction, DotScreenEffect, FXAAEffect, GlitchEffect, GlitchMode, GodRaysEffect, GridEffect, HueSaturationEffect, LUT3DEffect, NoiseEffect, OutlineEffect, PixelationEffect, ScanlineEffect, SelectiveBloomEffect, SepiaEffect, ShockWaveEffect, SMAAEffect, TiltShiftEffect, ToneMappingEffect, VignetteEffect } from 'postprocessing';
7
+ import * as THREE from 'three';
8
+ import { Group } from 'three';
8
9
  import { isWebGL2Available } from 'three-stdlib';
9
10
  import { easing } from 'maath';
10
11
 
@@ -41,8 +42,8 @@ class NgtpEffect {
41
42
  this.blendFunction = input(this.defaultEffectOptions?.blendFunction);
42
43
  this.opacity = input(this.defaultEffectOptions?.opacity);
43
44
  this.store = injectStore();
44
- this.camera = this.store.select('camera');
45
- this.invalidate = this.store.select('invalidate');
45
+ this.camera = this.store.camera;
46
+ this.invalidate = this.store.invalidate;
46
47
  }
47
48
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpEffect, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
48
49
  static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.4", type: NgtpEffect, isStandalone: true, inputs: { blendFunction: { classPropertyName: "blendFunction", publicName: "blendFunction", isSignal: true, isRequired: false, transformFunction: null }, opacity: { classPropertyName: "opacity", publicName: "opacity", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
@@ -51,25 +52,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
51
52
  type: Directive
52
53
  }] });
53
54
 
54
- const defaultOptions$4 = {
55
+ const defaultOptions$5 = {
55
56
  enabled: true,
56
57
  renderPriority: 1,
57
58
  autoClear: true,
58
59
  multisampling: 8,
59
- frameBufferType: HalfFloatType,
60
+ frameBufferType: THREE.HalfFloatType,
60
61
  };
61
62
  function isConvolution(effect) {
62
63
  return (effect.getAttributes() & EffectAttribute.CONVOLUTION) === EffectAttribute.CONVOLUTION;
63
64
  }
64
65
  class NgtpEffectComposer {
65
66
  constructor() {
66
- this.options = input(defaultOptions$4, { transform: mergeInputs(defaultOptions$4) });
67
+ this.options = input(defaultOptions$5, { transform: mergeInputs(defaultOptions$5) });
67
68
  this.injector = inject(Injector);
68
69
  this.store = injectStore();
69
- this.size = this.store.select('size');
70
- this.gl = this.store.select('gl');
71
- this.defaultScene = this.store.select('scene');
72
- this.defaultCamera = this.store.select('camera');
73
70
  this.depthBuffer = pick(this.options, 'depthBuffer');
74
71
  this.stencilBuffer = pick(this.options, 'stencilBuffer');
75
72
  this.multisampling = pick(this.options, 'multisampling');
@@ -78,8 +75,8 @@ class NgtpEffectComposer {
78
75
  this.resolutionScale = pick(this.options, 'resolutionScale');
79
76
  this.enabled = pick(this.options, 'enabled');
80
77
  this.renderPriority = pick(this.options, 'renderPriority');
81
- this.scene = computed(() => this.options().scene ?? this.defaultScene());
82
- this.camera = computed(() => this.options().camera ?? this.defaultCamera());
78
+ this.scene = computed(() => this.options().scene ?? this.store.scene());
79
+ this.camera = computed(() => this.options().camera ?? this.store.camera());
83
80
  this.groupRef = viewChild.required('group');
84
81
  this.priority = computed(() => {
85
82
  const enabled = this.enabled();
@@ -90,7 +87,7 @@ class NgtpEffectComposer {
90
87
  this.composerData = computed(() => {
91
88
  const webGL2Available = isWebGL2Available();
92
89
  const [gl, scene, camera, depthBuffer, stencilBuffer, multisampling, frameBufferType, enableNormalPass, resolutionScale,] = [
93
- this.gl(),
90
+ this.store.gl(),
94
91
  this.scene(),
95
92
  this.camera(),
96
93
  this.depthBuffer(),
@@ -124,18 +121,19 @@ class NgtpEffectComposer {
124
121
  }
125
122
  return { composer, normalPass, downSamplingPass };
126
123
  });
124
+ this.effectComposer = pick(this.composerData, 'composer');
127
125
  extend({ Group });
128
126
  // NOTE: Disable tone mapping because threejs disallows tonemapping on render targets
129
127
  effect((onCleanup) => {
130
- const gl = this.gl();
128
+ const gl = this.store.gl();
131
129
  const currentTonemapping = gl.toneMapping;
132
- gl.toneMapping = NoToneMapping;
130
+ gl.toneMapping = THREE.NoToneMapping;
133
131
  onCleanup(() => {
134
132
  gl.toneMapping = currentTonemapping;
135
133
  });
136
134
  });
137
135
  effect(() => {
138
- const [{ composer }, { width, height }] = [this.composerData(), this.size()];
136
+ const [{ composer }, width, height] = [this.composerData(), this.store.size.width(), this.store.size.height()];
139
137
  if (composer) {
140
138
  composer.setSize(width, height);
141
139
  }
@@ -148,10 +146,10 @@ class NgtpEffectComposer {
148
146
  ];
149
147
  const passes = [];
150
148
  if (composer) {
151
- const localState = getLocalState(group);
152
- if (!localState)
149
+ const instanceState = getInstanceState(group);
150
+ if (!instanceState)
153
151
  return;
154
- const children = localState.nonObjects();
152
+ const children = instanceState.nonObjects();
155
153
  for (let i = 0; i < children.length; i++) {
156
154
  const child = children[i];
157
155
  if (child instanceof Effect) {
@@ -195,7 +193,7 @@ class NgtpEffectComposer {
195
193
  const [{ composer }, { enabled, autoClear, stencilBuffer }, gl] = [
196
194
  this.composerData(),
197
195
  this.options(),
198
- this.gl(),
196
+ this.store.snapshot.gl,
199
197
  ];
200
198
  if (enabled) {
201
199
  const currentAutoClear = gl.autoClear;
@@ -273,11 +271,11 @@ void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor)
273
271
  class ASCIIEffect extends Effect {
274
272
  constructor({ font = 'arial', characters = ` .:,'-^=*+?!|0#X%WM@`, fontSize = 54, cellSize = 16, color = '#ffffff', invert = false, } = {}) {
275
273
  const uniforms = new Map([
276
- ['uCharacters', new Uniform(new Texture())],
277
- ['uCellSize', new Uniform(cellSize)],
278
- ['uCharactersCount', new Uniform(characters.length)],
279
- ['uColor', new Uniform(new Color(color))],
280
- ['uInvert', new Uniform(invert)],
274
+ ['uCharacters', new THREE.Uniform(new THREE.Texture())],
275
+ ['uCellSize', new THREE.Uniform(cellSize)],
276
+ ['uCharactersCount', new THREE.Uniform(characters.length)],
277
+ ['uColor', new THREE.Uniform(new THREE.Color(color))],
278
+ ['uInvert', new THREE.Uniform(invert)],
281
279
  ]);
282
280
  super('ASCIIEffect', fragment, { uniforms });
283
281
  const charactersTextureUniform = this.uniforms.get('uCharacters');
@@ -292,7 +290,7 @@ class ASCIIEffect extends Effect {
292
290
  const MAX_PER_ROW = 16;
293
291
  const CELL = SIZE / MAX_PER_ROW;
294
292
  canvas.width = canvas.height = SIZE;
295
- const texture = new CanvasTexture(canvas, undefined, RepeatWrapping, RepeatWrapping, NearestFilter, NearestFilter);
293
+ const texture = new THREE.CanvasTexture(canvas, undefined, THREE.RepeatWrapping, THREE.RepeatWrapping, THREE.NearestFilter, THREE.NearestFilter);
296
294
  const context = canvas.getContext('2d');
297
295
  if (!context) {
298
296
  throw new Error('Context not available');
@@ -312,7 +310,7 @@ class ASCIIEffect extends Effect {
312
310
  return texture;
313
311
  }
314
312
  }
315
- const defaultOptions$3 = {
313
+ const defaultOptions$4 = {
316
314
  font: 'arial',
317
315
  characters: ` .:,'-^=*+?!|0#X%WM@`,
318
316
  fontSize: 54,
@@ -322,7 +320,7 @@ const defaultOptions$3 = {
322
320
  };
323
321
  class NgtpASCII {
324
322
  constructor() {
325
- this.options = input(defaultOptions$3, { transform: mergeInputs(defaultOptions$3) });
323
+ this.options = input(defaultOptions$4, { transform: mergeInputs(defaultOptions$4) });
326
324
  this.effect = computed(() => new ASCIIEffect(this.options()));
327
325
  effect((onCleanup) => {
328
326
  const effect = this.effect();
@@ -347,11 +345,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
347
345
  }]
348
346
  }], ctorParameters: () => [] });
349
347
 
350
- extend({ BloomEffect });
351
348
  class NgtpBloom {
352
349
  constructor() {
353
- this.effect = inject(NgtpEffect, { host: true });
354
350
  this.options = input({});
351
+ this.effect = inject(NgtpEffect, { host: true });
352
+ extend({ BloomEffect });
355
353
  }
356
354
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpBloom, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
357
355
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.4", type: NgtpBloom, isStandalone: true, selector: "ngtp-bloom", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, providers: [provideDefaultEffectOptions({ blendFunction: BlendFunction.ADD })], hostDirectives: [{ directive: NgtpEffect, inputs: ["blendFunction", "blendFunction", "opacity", "opacity"] }], ngImport: i0, template: `
@@ -377,13 +375,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
377
375
  hostDirectives: [{ directive: NgtpEffect, inputs: ['blendFunction', 'opacity'] }],
378
376
  providers: [provideDefaultEffectOptions({ blendFunction: BlendFunction.ADD })],
379
377
  }]
380
- }] });
378
+ }], ctorParameters: () => [] });
381
379
 
382
- extend({ BrightnessContrastEffect });
383
380
  class NgtpBrightnessContrast {
384
381
  constructor() {
385
- this.effect = inject(NgtpEffect, { host: true });
386
382
  this.options = input({});
383
+ this.effect = inject(NgtpEffect, { host: true });
384
+ extend({ BrightnessContrastEffect });
387
385
  }
388
386
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpBrightnessContrast, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
389
387
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.4", type: NgtpBrightnessContrast, isStandalone: true, selector: "ngtp-brightness-contrast", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, hostDirectives: [{ directive: NgtpEffect, inputs: ["blendFunction", "blendFunction", "opacity", "opacity"] }], ngImport: i0, template: `
@@ -408,13 +406,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
408
406
  changeDetection: ChangeDetectionStrategy.OnPush,
409
407
  hostDirectives: [{ directive: NgtpEffect, inputs: ['blendFunction', 'opacity'] }],
410
408
  }]
411
- }] });
409
+ }], ctorParameters: () => [] });
412
410
 
413
- extend({ ChromaticAberrationEffect });
414
411
  class NgtpChromaticAberration {
415
412
  constructor() {
416
- this.effect = inject(NgtpEffect, { host: true });
417
413
  this.options = input({});
414
+ this.effect = inject(NgtpEffect, { host: true });
415
+ extend({ ChromaticAberrationEffect });
418
416
  }
419
417
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpChromaticAberration, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
420
418
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.4", type: NgtpChromaticAberration, isStandalone: true, selector: "ngtp-chromatic-aberration", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, hostDirectives: [{ directive: NgtpEffect, inputs: ["blendFunction", "blendFunction", "opacity", "opacity"] }], ngImport: i0, template: `
@@ -439,12 +437,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
439
437
  imports: [NgtArgs, NgtpEffectBlendMode],
440
438
  hostDirectives: [{ directive: NgtpEffect, inputs: ['blendFunction', 'opacity'] }],
441
439
  }]
442
- }] });
440
+ }], ctorParameters: () => [] });
443
441
 
444
- extend({ ColorAverageEffect });
445
442
  class NgtpColorAverage {
446
443
  constructor() {
447
444
  this.options = input({ blendFunction: BlendFunction.NORMAL }, { transform: mergeInputs({ blendFunction: BlendFunction.NORMAL }) });
445
+ extend({ ColorAverageEffect });
448
446
  }
449
447
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpColorAverage, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
450
448
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.4", type: NgtpColorAverage, isStandalone: true, selector: "ngtp-color-average", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
@@ -466,13 +464,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
466
464
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
467
465
  changeDetection: ChangeDetectionStrategy.OnPush,
468
466
  }]
469
- }] });
467
+ }], ctorParameters: () => [] });
470
468
 
471
- extend({ ColorDepthEffect });
472
469
  class NgtpColorDepth {
473
470
  constructor() {
474
- this.effect = inject(NgtpEffect, { host: true });
475
471
  this.options = input({});
472
+ this.effect = inject(NgtpEffect, { host: true });
473
+ extend({ ColorDepthEffect });
476
474
  }
477
475
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpColorDepth, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
478
476
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.4", type: NgtpColorDepth, isStandalone: true, selector: "ngtp-color-depth", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, hostDirectives: [{ directive: NgtpEffect, inputs: ["blendFunction", "blendFunction", "opacity", "opacity"] }], ngImport: i0, template: `
@@ -497,13 +495,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
497
495
  imports: [NgtArgs, NgtpEffectBlendMode],
498
496
  hostDirectives: [{ directive: NgtpEffect, inputs: ['blendFunction', 'opacity'] }],
499
497
  }]
500
- }] });
498
+ }], ctorParameters: () => [] });
501
499
 
502
- extend({ DepthEffect });
503
500
  class NgtpDepth {
504
501
  constructor() {
505
- this.effect = inject(NgtpEffect, { host: true });
506
502
  this.options = input({});
503
+ this.effect = inject(NgtpEffect, { host: true });
504
+ extend({ DepthEffect });
507
505
  }
508
506
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpDepth, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
509
507
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.4", type: NgtpDepth, isStandalone: true, selector: "ngtp-depth", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, hostDirectives: [{ directive: NgtpEffect, inputs: ["blendFunction", "blendFunction", "opacity", "opacity"] }], ngImport: i0, template: `
@@ -528,19 +526,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
528
526
  imports: [NgtArgs, NgtpEffectBlendMode],
529
527
  hostDirectives: [{ directive: NgtpEffect, inputs: ['blendFunction', 'opacity'] }],
530
528
  }]
531
- }] });
529
+ }], ctorParameters: () => [] });
532
530
 
533
531
  class NgtpDepthOfField {
534
532
  constructor() {
535
533
  this.options = input({});
536
- this.autoFocus = computed(() => this.options().target != null);
537
534
  this.effectComposer = inject(NgtpEffectComposer);
538
535
  this.effect = computed(() => {
539
- const [camera, options, autoFocus] = [this.effectComposer.camera(), this.options(), this.autoFocus()];
536
+ const [camera, options] = [this.effectComposer.camera(), this.options()];
537
+ const autoFocus = options.target != null;
540
538
  const effect = new DepthOfFieldEffect(camera, options);
541
- // Creating a target enables autofocus, R3F will set via props
539
+ // Creating a target enables autofocus, NGT will set via props
542
540
  if (autoFocus)
543
- effect.target = new Vector3();
541
+ effect.target = new THREE.Vector3();
544
542
  // Depth texture for depth picking with optional packing strategy
545
543
  if (options.depthTexture) {
546
544
  effect.setDepthTexture(options.depthTexture.texture, options.depthTexture.packing);
@@ -573,11 +571,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
573
571
  }]
574
572
  }], ctorParameters: () => [] });
575
573
 
576
- extend({ DotScreenEffect });
577
574
  class NgtpDotScreen {
578
575
  constructor() {
579
- this.effect = inject(NgtpEffect, { host: true });
580
576
  this.options = input({});
577
+ this.effect = inject(NgtpEffect, { host: true });
578
+ extend({ DotScreenEffect });
581
579
  }
582
580
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpDotScreen, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
583
581
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.4", type: NgtpDotScreen, isStandalone: true, selector: "ngtp-dot-screen", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, hostDirectives: [{ directive: NgtpEffect, inputs: ["blendFunction", "blendFunction", "opacity", "opacity"] }], ngImport: i0, template: `
@@ -602,13 +600,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
602
600
  imports: [NgtArgs, NgtpEffectBlendMode],
603
601
  hostDirectives: [{ directive: NgtpEffect, inputs: ['blendFunction', 'opacity'] }],
604
602
  }]
605
- }] });
603
+ }], ctorParameters: () => [] });
606
604
 
607
- extend({ FXAAEffect });
608
605
  class NgtpFXAA {
609
606
  constructor() {
610
- this.effect = inject(NgtpEffect, { host: true });
611
607
  this.options = input({});
608
+ this.effect = inject(NgtpEffect, { host: true });
609
+ extend({ FXAAEffect });
612
610
  }
613
611
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpFXAA, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
614
612
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.4", type: NgtpFXAA, isStandalone: true, selector: "ngtp-fxaa", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, hostDirectives: [{ directive: NgtpEffect, inputs: ["blendFunction", "blendFunction", "opacity", "opacity"] }], ngImport: i0, template: `
@@ -633,35 +631,41 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
633
631
  imports: [NgtArgs, NgtpEffectBlendMode],
634
632
  hostDirectives: [{ directive: NgtpEffect, inputs: ['blendFunction', 'opacity'] }],
635
633
  }]
636
- }] });
634
+ }], ctorParameters: () => [] });
637
635
 
638
636
  class NgtpGlitch {
639
637
  constructor() {
640
638
  this.options = input({ active: true }, { transform: mergeInputs({ active: true }) });
641
639
  this.active = pick(this.options, 'active');
642
640
  this.mode = pick(this.options, 'mode');
641
+ this.ratio = pick(this.options, 'ratio');
642
+ this.dtSize = pick(this.options, 'dtSize');
643
+ this.columns = pick(this.options, 'columns');
644
+ this.blendFunction = pick(this.options, 'blendFunction');
645
+ this.perturbationMap = pick(this.options, 'perturbationMap');
643
646
  this.delay = vector2(this.options, 'delay');
644
647
  this.duration = vector2(this.options, 'duration');
645
648
  this.chromaticAberrationOffset = vector2(this.options, 'chromaticAberrationOffset');
646
649
  this.strength = vector2(this.options, 'strength');
647
650
  this.store = injectStore();
648
- this.invalidate = this.store.select('invalidate');
649
- this.effect = computed(() => {
650
- const [{ ratio, dtSize, columns, blendFunction, perturbationMap }, delay, duration, chromaticAberrationOffset, strength,] = [this.options(), this.delay(), this.duration(), this.chromaticAberrationOffset(), this.strength()];
651
- return new GlitchEffect({
652
- ratio,
653
- dtSize,
654
- columns,
655
- blendFunction,
656
- perturbationMap,
657
- delay,
658
- duration,
659
- chromaticAberrationOffset,
660
- strength,
661
- });
662
- });
651
+ this.effect = computed(() => new GlitchEffect({
652
+ ratio: this.ratio(),
653
+ dtSize: this.dtSize(),
654
+ columns: this.columns(),
655
+ blendFunction: this.blendFunction(),
656
+ perturbationMap: this.perturbationMap(),
657
+ delay: this.delay(),
658
+ duration: this.duration(),
659
+ chromaticAberrationOffset: this.chromaticAberrationOffset(),
660
+ strength: this.strength(),
661
+ }));
663
662
  effect(() => {
664
- const [glitchEffect, invalidate, mode, active] = [this.effect(), this.invalidate(), this.mode(), this.active()];
663
+ const [glitchEffect, invalidate, mode, active] = [
664
+ this.effect(),
665
+ this.store.invalidate(),
666
+ this.mode(),
667
+ this.active(),
668
+ ];
665
669
  glitchEffect.mode = active ? mode || GlitchMode.SPORADIC : GlitchMode.DISABLED;
666
670
  invalidate();
667
671
  });
@@ -692,13 +696,24 @@ class NgtpGodRays {
692
696
  constructor() {
693
697
  this.options = input({});
694
698
  this.effectComposer = inject(NgtpEffectComposer);
699
+ this.effectOptions = omit(this.options, ['sun']);
700
+ this.sun = pick(this.options, 'sun');
701
+ this.sunElement = computed(() => {
702
+ const sun = this.sun();
703
+ if (typeof sun === 'function')
704
+ return resolveRef(sun());
705
+ return resolveRef(sun);
706
+ });
695
707
  this.effect = computed(() => {
696
- const [camera, { sun, ...options }] = [this.effectComposer.camera(), this.options()];
697
- return new GodRaysEffect(camera, is.ref(sun) ? sun.nativeElement : sun, options);
708
+ const [camera, sunElement, options] = [this.effectComposer.camera(), this.sunElement(), this.effectOptions()];
709
+ return new GodRaysEffect(camera, sunElement, options);
698
710
  });
699
711
  effect(() => {
700
- const [sun, godRaysEffect] = [this.options().sun, this.effect()];
701
- godRaysEffect.lightSource = is.ref(sun) ? sun.nativeElement : sun;
712
+ const sunElement = this.sunElement();
713
+ if (!sunElement)
714
+ return;
715
+ const godRaysEffect = this.effect();
716
+ godRaysEffect.lightSource = sunElement;
702
717
  });
703
718
  effect((onCleanup) => {
704
719
  const effect = this.effect();
@@ -726,11 +741,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
726
741
  class NgtpGrid {
727
742
  constructor() {
728
743
  this.options = input({});
744
+ this.effectOptions = omit(this.options, ['size']);
729
745
  this.size = pick(this.options, 'size');
730
- this.effect = computed(() => {
731
- const { size: _, ...options } = this.options();
732
- return new GridEffect(options);
733
- });
746
+ this.effect = computed(() => new GridEffect(this.effectOptions()));
734
747
  effect(() => {
735
748
  const [size, effect] = [this.size(), this.effect()];
736
749
  if (size) {
@@ -760,11 +773,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
760
773
  }]
761
774
  }], ctorParameters: () => [] });
762
775
 
763
- extend({ HueSaturationEffect });
764
776
  class NgtpHueSaturation {
765
777
  constructor() {
766
- this.effect = inject(NgtpEffect, { host: true });
767
778
  this.options = input({});
779
+ this.effect = inject(NgtpEffect, { host: true });
780
+ extend({ HueSaturationEffect });
768
781
  }
769
782
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpHueSaturation, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
770
783
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.4", type: NgtpHueSaturation, isStandalone: true, selector: "ngtp-hue-saturation", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, hostDirectives: [{ directive: NgtpEffect, inputs: ["blendFunction", "blendFunction", "opacity", "opacity"] }], ngImport: i0, template: `
@@ -789,7 +802,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
789
802
  imports: [NgtArgs, NgtpEffectBlendMode],
790
803
  hostDirectives: [{ directive: NgtpEffect, inputs: ['blendFunction', 'opacity'] }],
791
804
  }]
792
- }] });
805
+ }], ctorParameters: () => [] });
793
806
 
794
807
  // Created by Anderson Mancini 2023
795
808
  // React Three Fiber Ultimate LensFlare
@@ -841,29 +854,29 @@ const LensFlareShader = {
841
854
  `,
842
855
  };
843
856
  class LensFlareEffect extends Effect {
844
- 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 Color(20, 20, 20), lensDirtTexture = null, haloScale = 0.5, secondaryGhosts = true, aditionalStreaks = true, ghostScale = 0.0, opacity = 1.0, starBurst = false, } = {}) {
857
+ 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, } = {}) {
845
858
  super('LensFlareEffect', LensFlareShader.fragmentShader, {
846
859
  blendFunction,
847
860
  uniforms: new Map([
848
- ['enabled', new Uniform(enabled)],
849
- ['glareSize', new Uniform(glareSize)],
850
- ['lensPosition', new Uniform(lensPosition)],
851
- ['iTime', new Uniform(0)],
852
- ['iResolution', new Uniform(iResolution)],
853
- ['starPoints', new Uniform(starPoints)],
854
- ['flareSize', new Uniform(flareSize)],
855
- ['flareSpeed', new Uniform(flareSpeed)],
856
- ['flareShape', new Uniform(flareShape)],
857
- ['animated', new Uniform(animated)],
858
- ['anamorphic', new Uniform(anamorphic)],
859
- ['colorGain', new Uniform(colorGain)],
860
- ['lensDirtTexture', new Uniform(lensDirtTexture)],
861
- ['haloScale', new Uniform(haloScale)],
862
- ['secondaryGhosts', new Uniform(secondaryGhosts)],
863
- ['aditionalStreaks', new Uniform(aditionalStreaks)],
864
- ['ghostScale', new Uniform(ghostScale)],
865
- ['starBurst', new Uniform(starBurst)],
866
- ['opacity', new Uniform(opacity)],
861
+ ['enabled', new THREE.Uniform(enabled)],
862
+ ['glareSize', new THREE.Uniform(glareSize)],
863
+ ['lensPosition', new THREE.Uniform(lensPosition)],
864
+ ['iTime', new THREE.Uniform(0)],
865
+ ['iResolution', new THREE.Uniform(iResolution)],
866
+ ['starPoints', new THREE.Uniform(starPoints)],
867
+ ['flareSize', new THREE.Uniform(flareSize)],
868
+ ['flareSpeed', new THREE.Uniform(flareSpeed)],
869
+ ['flareShape', new THREE.Uniform(flareShape)],
870
+ ['animated', new THREE.Uniform(animated)],
871
+ ['anamorphic', new THREE.Uniform(anamorphic)],
872
+ ['colorGain', new THREE.Uniform(colorGain)],
873
+ ['lensDirtTexture', new THREE.Uniform(lensDirtTexture)],
874
+ ['haloScale', new THREE.Uniform(haloScale)],
875
+ ['secondaryGhosts', new THREE.Uniform(secondaryGhosts)],
876
+ ['aditionalStreaks', new THREE.Uniform(aditionalStreaks)],
877
+ ['ghostScale', new THREE.Uniform(ghostScale)],
878
+ ['starBurst', new THREE.Uniform(starBurst)],
879
+ ['opacity', new THREE.Uniform(opacity)],
867
880
  ]),
868
881
  });
869
882
  }
@@ -874,31 +887,31 @@ class LensFlareEffect extends Effect {
874
887
  }
875
888
  }
876
889
  }
877
- const defaultOptions$2 = {
878
- position: new Vector3(-25, 6, -60),
890
+ const defaultOptions$3 = {
891
+ position: new THREE.Vector3(-25, 6, -60),
879
892
  followMouse: false,
880
893
  smoothTime: 0.7,
881
894
  };
882
895
  class NgtpLensFlare {
883
896
  constructor() {
884
- this.options = input(defaultOptions$2, { transform: mergeInputs(defaultOptions$2) });
897
+ this.options = input(defaultOptions$3, { transform: mergeInputs(defaultOptions$3) });
885
898
  this.store = injectStore();
886
- this.viewport = this.store.select('viewport');
887
- this.raycaster = this.store.select('raycaster');
888
- this.pointer = this.store.select('pointer');
889
899
  this.effectComposer = inject(NgtpEffectComposer);
890
- this.projectedPosition = new Vector3();
891
- this.mouse2d = new Vector2();
892
- this.effect = computed(() => {
893
- const { position: _, followMouse: __, smoothTime: ___, ...options } = this.options();
894
- return new LensFlareEffect(options);
895
- });
900
+ this.effectOptions = omit(this.options, ['position', 'followMouse', 'smoothTime']);
901
+ this.position = vector3(this.options, 'position');
902
+ this.projectedPosition = new THREE.Vector3();
903
+ this.mouse2d = new THREE.Vector2();
904
+ this.effect = computed(() => new LensFlareEffect(this.effectOptions()));
896
905
  effect(() => {
897
- const [lensFlareEffect, viewport] = [this.effect(), this.viewport()];
906
+ const [lensFlareEffect, width, height] = [
907
+ this.effect(),
908
+ this.store.viewport.width(),
909
+ this.store.viewport.height(),
910
+ ];
898
911
  const iResolution = lensFlareEffect.uniforms.get('iResolution');
899
912
  if (iResolution) {
900
- iResolution.value.x = viewport.width;
901
- iResolution.value.y = viewport.height;
913
+ iResolution.value.x = width;
914
+ iResolution.value.y = height;
902
915
  }
903
916
  });
904
917
  effect((onCleanup) => {
@@ -909,12 +922,13 @@ class NgtpLensFlare {
909
922
  const [effect] = [this.effect()];
910
923
  if (!effect)
911
924
  return;
912
- const [{ followMouse, position, smoothTime }, pointer, camera, scene, raycaster] = [
925
+ const [{ followMouse, smoothTime }, position, pointer, camera, scene, raycaster] = [
913
926
  this.options(),
914
- this.pointer(),
927
+ this.position(),
928
+ this.store.snapshot.pointer,
915
929
  this.effectComposer.camera(),
916
930
  this.effectComposer.scene(),
917
- this.raycaster(),
931
+ this.store.snapshot.raycaster,
918
932
  ];
919
933
  const uLensPosition = effect.uniforms.get('lensPosition');
920
934
  const uOpacity = effect.uniforms.get('opacity');
@@ -940,12 +954,14 @@ class NgtpLensFlare {
940
954
  if (object.userData?.['lensflare'] === 'no-occlusion') {
941
955
  target = 0;
942
956
  }
943
- else if (object instanceof Mesh) {
944
- if (object.material.uniforms?._transmission?.value > 0.2) {
957
+ else if (is.three(object, 'isMesh')) {
958
+ if (object.material.uniforms?.['_transmission']?.value > 0.2) {
945
959
  //Check for MeshTransmissionMaterial
946
960
  target = 0.2;
947
961
  }
948
- else if (object.material._transmission && object.material._transmission > 0.2) {
962
+ else if ('_transmission' in object.material &&
963
+ typeof object.material._transmission === 'number' &&
964
+ object.material._transmission > 0.2) {
949
965
  //Check for MeshPhysicalMaterial with transmission setting
950
966
  target = 0.2;
951
967
  }
@@ -981,17 +997,18 @@ class NgtpLUT {
981
997
  constructor() {
982
998
  this.options = input({});
983
999
  this.lut = pick(this.options, 'lut');
1000
+ this.tetrahedralInterpolation = pick(this.options, 'tetrahedralInterpolation');
984
1001
  this.store = injectStore();
985
- this.invalidate = this.store.select('invalidate');
986
1002
  this.effect = computed(() => {
987
- const [lut, { lut: _, ...options }] = [this.lut(), this.options()];
1003
+ const { lut, ...options } = this.options();
988
1004
  return new LUT3DEffect(lut, options);
989
1005
  });
990
1006
  effect(() => {
991
- const [effect, { lut, tetrahedralInterpolation }, invalidate] = [
1007
+ const [effect, lut, tetrahedralInterpolation, invalidate] = [
992
1008
  this.effect(),
993
- this.options(),
994
- this.invalidate(),
1009
+ this.lut(),
1010
+ this.tetrahedralInterpolation(),
1011
+ this.store.invalidate(),
995
1012
  ];
996
1013
  if (tetrahedralInterpolation)
997
1014
  effect.tetrahedralInterpolation = tetrahedralInterpolation;
@@ -1022,11 +1039,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
1022
1039
  }]
1023
1040
  }], ctorParameters: () => [] });
1024
1041
 
1025
- extend({ NoiseEffect });
1026
1042
  class NgtpNoise {
1027
1043
  constructor() {
1028
- this.effect = inject(NgtpEffect, { host: true });
1029
1044
  this.options = input({});
1045
+ this.effect = inject(NgtpEffect, { host: true });
1046
+ extend({ NoiseEffect });
1030
1047
  }
1031
1048
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpNoise, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1032
1049
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.4", type: NgtpNoise, isStandalone: true, selector: "ngtp-noise", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, providers: [provideDefaultEffectOptions({ blendFunction: BlendFunction.COLOR_DODGE })], hostDirectives: [{ directive: NgtpEffect, inputs: ["blendFunction", "blendFunction", "opacity", "opacity"] }], ngImport: i0, template: `
@@ -1052,18 +1069,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
1052
1069
  hostDirectives: [{ directive: NgtpEffect, inputs: ['blendFunction', 'opacity'] }],
1053
1070
  providers: [provideDefaultEffectOptions({ blendFunction: BlendFunction.COLOR_DODGE })],
1054
1071
  }]
1055
- }] });
1072
+ }], ctorParameters: () => [] });
1056
1073
 
1057
- const defaultOptions$1 = {
1074
+ const defaultOptions$2 = {
1058
1075
  selectionLayer: 10,
1059
1076
  };
1060
1077
  class NgtpOutline {
1061
1078
  constructor() {
1062
- this.options = input(defaultOptions$1, { transform: mergeInputs(defaultOptions$1) });
1079
+ this.options = input(defaultOptions$2, { transform: mergeInputs(defaultOptions$2) });
1063
1080
  this.ngtSelection = inject(NgtSelection, { optional: true });
1064
1081
  this.effectComposer = inject(NgtpEffectComposer);
1065
1082
  this.store = injectStore();
1066
- this.invalidate = this.store.select('invalidate');
1067
1083
  this.selection = pick(this.options, 'selection');
1068
1084
  this.selectionLayer = pick(this.options, 'selectionLayer');
1069
1085
  this.blendFunction = pick(this.options, 'blendFunction');
@@ -1127,7 +1143,7 @@ class NgtpOutline {
1127
1143
  onCleanup(() => effect.dispose());
1128
1144
  });
1129
1145
  effect(() => {
1130
- const [effect, invalidate, selectionLayer] = [this.effect(), this.invalidate(), this.selectionLayer()];
1146
+ const [effect, invalidate, selectionLayer] = [this.effect(), this.store.invalidate(), this.selectionLayer()];
1131
1147
  effect.selectionLayer = selectionLayer;
1132
1148
  invalidate();
1133
1149
  });
@@ -1138,7 +1154,7 @@ class NgtpOutline {
1138
1154
  if (this.selection() === undefined) {
1139
1155
  throw new Error('[NGT PostProcessing]: ngtp-outline requires selection input or use NgtSelection');
1140
1156
  }
1141
- const cleanup = this.handleSelectionChangeEffect(this.selection, this.effect, this.invalidate);
1157
+ const cleanup = this.handleSelectionChangeEffect(this.selection, this.effect, this.store.invalidate);
1142
1158
  onCleanup(() => {
1143
1159
  cleanup?.();
1144
1160
  });
@@ -1148,7 +1164,7 @@ class NgtpOutline {
1148
1164
  const selectionEnabled = this.ngtSelection.enabled();
1149
1165
  if (!selectionEnabled)
1150
1166
  return;
1151
- const cleanup = this.handleSelectionChangeEffect(this.ngtSelection.selected, this.effect, this.invalidate);
1167
+ const cleanup = this.handleSelectionChangeEffect(this.ngtSelection.selected, this.effect, this.store.invalidate);
1152
1168
  onCleanup(() => {
1153
1169
  cleanup?.();
1154
1170
  });
@@ -1221,14 +1237,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
1221
1237
  }]
1222
1238
  }], ctorParameters: () => [] });
1223
1239
 
1224
- extend({ ScanlineEffect });
1225
- const defaultOptions = {
1240
+ const defaultOptions$1 = {
1226
1241
  density: 1.25,
1227
1242
  };
1228
1243
  class NgtpScanline {
1229
1244
  constructor() {
1245
+ this.options = input(defaultOptions$1, { transform: mergeInputs(defaultOptions$1) });
1230
1246
  this.effect = inject(NgtpEffect, { host: true });
1231
- this.options = input(defaultOptions, { transform: mergeInputs(defaultOptions) });
1247
+ extend({ ScanlineEffect });
1232
1248
  }
1233
1249
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpScanline, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1234
1250
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.4", type: NgtpScanline, isStandalone: true, selector: "ngtp-scanline", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, providers: [provideDefaultEffectOptions({ blendFunction: BlendFunction.OVERLAY })], hostDirectives: [{ directive: NgtpEffect, inputs: ["blendFunction", "blendFunction", "opacity", "opacity"] }], ngImport: i0, template: `
@@ -1254,13 +1270,146 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
1254
1270
  hostDirectives: [{ directive: NgtpEffect, inputs: ['blendFunction', 'opacity'] }],
1255
1271
  providers: [provideDefaultEffectOptions({ blendFunction: BlendFunction.OVERLAY })],
1256
1272
  }]
1257
- }] });
1273
+ }], ctorParameters: () => [] });
1274
+
1275
+ // const addLight = (light: Object3D, effect: SelectiveBloomEffect) => light.layers.enable(effect.selection.layer)
1276
+ // const removeLight = (light: Object3D, effect: SelectiveBloomEffect) => light.layers.disable(effect.selection.layer)
1277
+ const defaultOptions = {
1278
+ selectionLayer: 10,
1279
+ inverted: false,
1280
+ ignoreBackground: false,
1281
+ };
1282
+ class NgtpSelectiveBloom {
1283
+ constructor() {
1284
+ this.lights = input.required();
1285
+ this.selection = input([]);
1286
+ this.options = input(defaultOptions, { transform: mergeInputs(defaultOptions) });
1287
+ this.blendFunction = pick(this.options, 'blendFunction');
1288
+ this.luminanceThreshold = pick(this.options, 'luminanceThreshold');
1289
+ this.luminanceSmoothing = pick(this.options, 'luminanceSmoothing');
1290
+ this.mipmapBlur = pick(this.options, 'mipmapBlur');
1291
+ this.intensity = pick(this.options, 'intensity');
1292
+ this.radius = pick(this.options, 'radius');
1293
+ this.levels = pick(this.options, 'levels');
1294
+ this.kernelSize = pick(this.options, 'kernelSize');
1295
+ this.resolutionScale = pick(this.options, 'resolutionScale');
1296
+ this.width = pick(this.options, 'width');
1297
+ this.height = pick(this.options, 'height');
1298
+ this.resolutionX = pick(this.options, 'resolutionX');
1299
+ this.resolutionY = pick(this.options, 'resolutionY');
1300
+ this.inverted = pick(this.options, 'inverted');
1301
+ this.ignoreBackground = pick(this.options, 'ignoreBackground');
1302
+ this.selectionLayer = pick(this.options, 'selectionLayer');
1303
+ this.store = injectStore();
1304
+ this.effectComposer = inject(NgtpEffectComposer);
1305
+ this.ngtSelection = inject(NgtSelection, { optional: true });
1306
+ this.resolvedLights = computed(() => this.lights().map((light) => resolveRef(light)));
1307
+ this.resolvedSelected = computed(() => {
1308
+ const selection = this.selection();
1309
+ if (!selection)
1310
+ return [];
1311
+ const array = Array.isArray(selection) ? selection : [selection];
1312
+ return array.map((selected) => resolveRef(selected));
1313
+ });
1314
+ this.resolvedNgtSelected = computed(() => {
1315
+ if (!this.ngtSelection || !this.ngtSelection.enabled)
1316
+ return [];
1317
+ return this.ngtSelection.selected().map((selected) => resolveRef(selected));
1318
+ });
1319
+ this.effect = computed(() => {
1320
+ const effect = new SelectiveBloomEffect(this.effectComposer.scene(), this.effectComposer.camera(), {
1321
+ blendFunction: this.blendFunction() || BlendFunction.ADD,
1322
+ luminanceThreshold: this.luminanceThreshold(),
1323
+ luminanceSmoothing: this.luminanceSmoothing(),
1324
+ mipmapBlur: this.mipmapBlur(),
1325
+ intensity: this.intensity(),
1326
+ radius: this.radius(),
1327
+ levels: this.levels(),
1328
+ kernelSize: this.kernelSize(),
1329
+ resolutionScale: this.resolutionScale(),
1330
+ width: this.width(),
1331
+ height: this.height(),
1332
+ resolutionX: this.resolutionX(),
1333
+ resolutionY: this.resolutionY(),
1334
+ });
1335
+ effect.inverted = this.inverted();
1336
+ effect.ignoreBackground = this.ignoreBackground();
1337
+ return effect;
1338
+ });
1339
+ effect((onCleanup) => {
1340
+ // skip input selection altogether if NgtSelection is used
1341
+ if (this.ngtSelection)
1342
+ return;
1343
+ const selection = this.resolvedSelected();
1344
+ if (!selection.length)
1345
+ return;
1346
+ const [effect, invalidate] = [this.effect(), this.store.invalidate(), this.selectionLayer()];
1347
+ effect.selection.set(selection);
1348
+ invalidate();
1349
+ onCleanup(() => {
1350
+ effect.selection.clear();
1351
+ invalidate();
1352
+ });
1353
+ });
1354
+ effect(() => {
1355
+ const [selectionLayer, invalidate, effect] = [this.selectionLayer(), this.store.invalidate(), this.effect()];
1356
+ effect.selection.layer = selectionLayer;
1357
+ invalidate();
1358
+ });
1359
+ effect((onCleanup) => {
1360
+ const lights = this.resolvedLights();
1361
+ if (lights.length <= 0)
1362
+ return;
1363
+ const [effect, invalidate] = [this.effect(), this.store.invalidate(), this.selectionLayer()];
1364
+ lights.forEach((light) => light && this.addLight(effect, light));
1365
+ invalidate();
1366
+ onCleanup(() => {
1367
+ lights.forEach((light) => light && this.removeLight(effect, light));
1368
+ invalidate();
1369
+ });
1370
+ });
1371
+ effect((onCleanup) => {
1372
+ const selected = this.resolvedNgtSelected();
1373
+ if (!selected.length)
1374
+ return;
1375
+ const [effect, invalidate] = [this.effect(), this.store.invalidate(), this.selectionLayer()];
1376
+ effect.selection.set(selected);
1377
+ invalidate();
1378
+ onCleanup(() => {
1379
+ effect.selection.clear();
1380
+ invalidate();
1381
+ });
1382
+ });
1383
+ }
1384
+ addLight(effect, light) {
1385
+ light.layers.enable(effect.selection.layer);
1386
+ }
1387
+ removeLight(effect, light) {
1388
+ light.layers.disable(effect.selection.layer);
1389
+ }
1390
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpSelectiveBloom, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1391
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.4", type: NgtpSelectiveBloom, isStandalone: true, selector: "ngtp-selective-bloom", inputs: { lights: { classPropertyName: "lights", publicName: "lights", isSignal: true, isRequired: true, transformFunction: null }, selection: { classPropertyName: "selection", publicName: "selection", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
1392
+ <ngt-primitive *args="[effect()]" [dispose]="null" />
1393
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "ng-template[args]", inputs: ["args"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1394
+ }
1395
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpSelectiveBloom, decorators: [{
1396
+ type: Component,
1397
+ args: [{
1398
+ selector: 'ngtp-selective-bloom',
1399
+ template: `
1400
+ <ngt-primitive *args="[effect()]" [dispose]="null" />
1401
+ `,
1402
+ imports: [NgtArgs],
1403
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
1404
+ changeDetection: ChangeDetectionStrategy.OnPush,
1405
+ }]
1406
+ }], ctorParameters: () => [] });
1258
1407
 
1259
- extend({ SepiaEffect });
1260
1408
  class NgtpSepia {
1261
1409
  constructor() {
1262
- this.effect = inject(NgtpEffect, { host: true });
1263
1410
  this.options = input({});
1411
+ this.effect = inject(NgtpEffect, { host: true });
1412
+ extend({ SepiaEffect });
1264
1413
  }
1265
1414
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpSepia, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1266
1415
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.4", type: NgtpSepia, isStandalone: true, selector: "ngtp-sepia", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, hostDirectives: [{ directive: NgtpEffect, inputs: ["blendFunction", "blendFunction", "opacity", "opacity"] }], ngImport: i0, template: `
@@ -1285,13 +1434,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
1285
1434
  imports: [NgtArgs, NgtpEffectBlendMode],
1286
1435
  hostDirectives: [{ directive: NgtpEffect, inputs: ['blendFunction', 'opacity'] }],
1287
1436
  }]
1288
- }] });
1437
+ }], ctorParameters: () => [] });
1289
1438
 
1290
- extend({ ShockWaveEffect });
1291
1439
  class NgtpShockWave {
1292
1440
  constructor() {
1293
- this.effect = inject(NgtpEffect, { host: true });
1294
1441
  this.options = input({});
1442
+ this.effect = inject(NgtpEffect, { host: true });
1443
+ extend({ ShockWaveEffect });
1295
1444
  }
1296
1445
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpShockWave, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1297
1446
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.4", type: NgtpShockWave, isStandalone: true, selector: "ngtp-shock-wave", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, hostDirectives: [{ directive: NgtpEffect, inputs: ["blendFunction", "blendFunction", "opacity", "opacity"] }], ngImport: i0, template: `
@@ -1316,13 +1465,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
1316
1465
  imports: [NgtArgs, NgtpEffectBlendMode],
1317
1466
  hostDirectives: [{ directive: NgtpEffect, inputs: ['blendFunction', 'opacity'] }],
1318
1467
  }]
1319
- }] });
1468
+ }], ctorParameters: () => [] });
1320
1469
 
1321
- extend({ SMAAEffect });
1322
1470
  class NgtpSMAA {
1323
1471
  constructor() {
1324
- this.effect = inject(NgtpEffect, { host: true });
1325
1472
  this.options = input({});
1473
+ this.effect = inject(NgtpEffect, { host: true });
1474
+ extend({ SMAAEffect });
1326
1475
  }
1327
1476
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpSMAA, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1328
1477
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.4", type: NgtpSMAA, isStandalone: true, selector: "ngtp-smaa", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, hostDirectives: [{ directive: NgtpEffect, inputs: ["blendFunction", "blendFunction", "opacity", "opacity"] }], ngImport: i0, template: `
@@ -1347,13 +1496,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
1347
1496
  imports: [NgtArgs, NgtpEffectBlendMode],
1348
1497
  hostDirectives: [{ directive: NgtpEffect, inputs: ['blendFunction', 'opacity'] }],
1349
1498
  }]
1350
- }] });
1499
+ }], ctorParameters: () => [] });
1351
1500
 
1352
- extend({ TiltShiftEffect });
1353
1501
  class NgtpTiltShift {
1354
1502
  constructor() {
1355
- this.effect = inject(NgtpEffect, { host: true });
1356
1503
  this.options = input({});
1504
+ this.effect = inject(NgtpEffect, { host: true });
1505
+ extend({ TiltShiftEffect });
1357
1506
  }
1358
1507
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpTiltShift, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1359
1508
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.4", type: NgtpTiltShift, isStandalone: true, selector: "ngtp-tilt-shift", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, providers: [provideDefaultEffectOptions({ blendFunction: BlendFunction.ADD })], hostDirectives: [{ directive: NgtpEffect, inputs: ["blendFunction", "blendFunction", "opacity", "opacity"] }], ngImport: i0, template: `
@@ -1379,7 +1528,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
1379
1528
  hostDirectives: [{ directive: NgtpEffect, inputs: ['blendFunction', 'opacity'] }],
1380
1529
  providers: [provideDefaultEffectOptions({ blendFunction: BlendFunction.ADD })],
1381
1530
  }]
1382
- }] });
1531
+ }], ctorParameters: () => [] });
1383
1532
 
1384
1533
  const TiltShiftShader = {
1385
1534
  fragmentShader: /* language=glsl glsl */ `
@@ -1452,12 +1601,12 @@ class TiltShift2Effect extends Effect {
1452
1601
  blendFunction,
1453
1602
  attributes: EffectAttribute.CONVOLUTION,
1454
1603
  uniforms: new Map([
1455
- ['blur', new Uniform(blur)],
1456
- ['taper', new Uniform(taper)],
1457
- ['start', new Uniform(start)],
1458
- ['end', new Uniform(end)],
1459
- ['samples', new Uniform(samples)],
1460
- ['direction', new Uniform(direction)],
1604
+ ['blur', new THREE.Uniform(blur)],
1605
+ ['taper', new THREE.Uniform(taper)],
1606
+ ['start', new THREE.Uniform(start)],
1607
+ ['end', new THREE.Uniform(end)],
1608
+ ['samples', new THREE.Uniform(samples)],
1609
+ ['direction', new THREE.Uniform(direction)],
1461
1610
  ]),
1462
1611
  });
1463
1612
  }
@@ -1465,8 +1614,8 @@ class TiltShift2Effect extends Effect {
1465
1614
  extend({ TiltShift2Effect });
1466
1615
  class NgtpTiltShift2 {
1467
1616
  constructor() {
1468
- this.effect = inject(NgtpEffect, { host: true });
1469
1617
  this.options = input({});
1618
+ this.effect = inject(NgtpEffect, { host: true });
1470
1619
  }
1471
1620
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpTiltShift2, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1472
1621
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.4", type: NgtpTiltShift2, isStandalone: true, selector: "ngtp-tilt-shift2", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, providers: [provideDefaultEffectOptions({ blendFunction: BlendFunction.NORMAL })], hostDirectives: [{ directive: NgtpEffect, inputs: ["blendFunction", "blendFunction", "opacity", "opacity"] }], ngImport: i0, template: `
@@ -1494,11 +1643,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
1494
1643
  }]
1495
1644
  }] });
1496
1645
 
1497
- extend({ ToneMappingEffect });
1498
1646
  class NgtpToneMapping {
1499
1647
  constructor() {
1500
- this.effect = inject(NgtpEffect, { host: true });
1501
1648
  this.options = input({});
1649
+ this.effect = inject(NgtpEffect, { host: true });
1650
+ extend({ ToneMappingEffect });
1502
1651
  }
1503
1652
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpToneMapping, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1504
1653
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.4", type: NgtpToneMapping, isStandalone: true, selector: "ngtp-tone-mapping", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, hostDirectives: [{ directive: NgtpEffect, inputs: ["blendFunction", "blendFunction", "opacity", "opacity"] }], ngImport: i0, template: `
@@ -1523,13 +1672,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
1523
1672
  changeDetection: ChangeDetectionStrategy.OnPush,
1524
1673
  hostDirectives: [{ directive: NgtpEffect, inputs: ['blendFunction', 'opacity'] }],
1525
1674
  }]
1526
- }] });
1675
+ }], ctorParameters: () => [] });
1527
1676
 
1528
- extend({ VignetteEffect });
1529
1677
  class NgtpVignette {
1530
1678
  constructor() {
1531
- this.effect = inject(NgtpEffect, { host: true });
1532
1679
  this.options = input({});
1680
+ this.effect = inject(NgtpEffect, { host: true });
1681
+ extend({ VignetteEffect });
1533
1682
  }
1534
1683
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpVignette, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1535
1684
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.4", type: NgtpVignette, isStandalone: true, selector: "ngtp-vignette", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, hostDirectives: [{ directive: NgtpEffect, inputs: ["blendFunction", "blendFunction", "opacity", "opacity"] }], ngImport: i0, template: `
@@ -1554,7 +1703,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
1554
1703
  imports: [NgtArgs, NgtpEffectBlendMode],
1555
1704
  hostDirectives: [{ directive: NgtpEffect, inputs: ['blendFunction', 'opacity'] }],
1556
1705
  }]
1557
- }] });
1706
+ }], ctorParameters: () => [] });
1558
1707
 
1559
1708
  const WaterShader = {
1560
1709
  fragmentShader: /* language=glsl glsl */ `
@@ -1576,15 +1725,15 @@ class WaterEffect extends Effect {
1576
1725
  super('WaterEffect', WaterShader.fragmentShader, {
1577
1726
  blendFunction,
1578
1727
  attributes: EffectAttribute.CONVOLUTION,
1579
- uniforms: new Map([['factor', new Uniform(factor)]]),
1728
+ uniforms: new Map([['factor', new THREE.Uniform(factor)]]),
1580
1729
  });
1581
1730
  }
1582
1731
  }
1583
- extend({ WaterEffect });
1584
1732
  class NgtpWater {
1585
1733
  constructor() {
1586
- this.effect = inject(NgtpEffect, { host: true });
1587
1734
  this.options = input({});
1735
+ this.effect = inject(NgtpEffect, { host: true });
1736
+ extend({ WaterEffect });
1588
1737
  }
1589
1738
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: NgtpWater, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1590
1739
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.4", type: NgtpWater, isStandalone: true, selector: "ngtp-water", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, providers: [provideDefaultEffectOptions({ blendFunction: BlendFunction.NORMAL })], hostDirectives: [{ directive: NgtpEffect, inputs: ["blendFunction", "blendFunction", "opacity", "opacity"] }], ngImport: i0, template: `
@@ -1610,11 +1759,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
1610
1759
  hostDirectives: [{ directive: NgtpEffect, inputs: ['blendFunction', 'opacity'] }],
1611
1760
  providers: [provideDefaultEffectOptions({ blendFunction: BlendFunction.NORMAL })],
1612
1761
  }]
1613
- }] });
1762
+ }], ctorParameters: () => [] });
1614
1763
 
1615
1764
  /**
1616
1765
  * Generated bundle index. Do not edit.
1617
1766
  */
1618
1767
 
1619
- export { ASCIIEffect, LensFlareEffect, NgtpASCII, NgtpBloom, NgtpBrightnessContrast, NgtpChromaticAberration, NgtpColorAverage, NgtpColorDepth, NgtpDepth, NgtpDepthOfField, NgtpDotScreen, NgtpEffect, NgtpEffectBlendMode, NgtpEffectComposer, NgtpFXAA, NgtpGlitch, NgtpGodRays, NgtpGrid, NgtpHueSaturation, NgtpLUT, NgtpLensFlare, NgtpNoise, NgtpOutline, NgtpPixelation, NgtpSMAA, NgtpScanline, NgtpSepia, NgtpShockWave, NgtpTiltShift, NgtpTiltShift2, NgtpToneMapping, NgtpVignette, NgtpWater, TiltShift2Effect, WaterEffect, injectDefaultEffectOptions, provideDefaultEffectOptions };
1768
+ export { ASCIIEffect, LensFlareEffect, NgtpASCII, NgtpBloom, NgtpBrightnessContrast, NgtpChromaticAberration, NgtpColorAverage, NgtpColorDepth, NgtpDepth, NgtpDepthOfField, NgtpDotScreen, NgtpEffect, NgtpEffectBlendMode, NgtpEffectComposer, NgtpFXAA, NgtpGlitch, NgtpGodRays, NgtpGrid, NgtpHueSaturation, NgtpLUT, NgtpLensFlare, NgtpNoise, NgtpOutline, NgtpPixelation, NgtpSMAA, NgtpScanline, NgtpSelectiveBloom, NgtpSepia, NgtpShockWave, NgtpTiltShift, NgtpTiltShift2, NgtpToneMapping, NgtpVignette, NgtpWater, TiltShift2Effect, WaterEffect, injectDefaultEffectOptions, provideDefaultEffectOptions };
1620
1769
  //# sourceMappingURL=angular-three-postprocessing.mjs.map