angular-three-postprocessing 2.0.0-beta.285 → 2.0.0-beta.287
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/esm2022/lib/effect-composer.mjs +2 -2
- package/esm2022/lib/effects/depth-of-field.mjs +2 -2
- package/esm2022/lib/effects/grid.mjs +2 -4
- package/esm2022/lib/effects/index.mjs +2 -1
- package/esm2022/lib/effects/lens-flare.mjs +3 -3
- package/esm2022/lib/effects/outline.mjs +143 -0
- package/fesm2022/angular-three-postprocessing.mjs +151 -17
- package/fesm2022/angular-three-postprocessing.mjs.map +1 -1
- package/lib/effect-composer.d.ts +1 -2
- package/lib/effects/depth-of-field.d.ts +2 -2
- package/lib/effects/grid.d.ts +0 -2
- package/lib/effects/index.d.ts +1 -0
- package/lib/effects/lens-flare.d.ts +2 -2
- package/lib/effects/outline.d.ts +74 -0
- package/package.json +5 -5
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, Component, CUSTOM_ELEMENTS_SCHEMA, ChangeDetectionStrategy, input, Directive, Injector, computed, viewChild, afterNextRender } from '@angular/core';
|
|
3
|
-
import { injectStore,
|
|
2
|
+
import { inject, Component, CUSTOM_ELEMENTS_SCHEMA, ChangeDetectionStrategy, input, Directive, Injector, computed, viewChild, afterNextRender, untracked } from '@angular/core';
|
|
3
|
+
import { injectStore, pick, extend, injectBeforeRender, getLocalState, NgtArgs, vector2, is, NgtSelection, omit, resolveRef } from 'angular-three';
|
|
4
4
|
import { createNoopInjectionToken } from 'ngxtension/create-injection-token';
|
|
5
5
|
import { injectAutoEffect } from 'ngxtension/auto-effect';
|
|
6
6
|
import { mergeInputs } from 'ngxtension/inject-inputs';
|
|
7
|
-
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, PixelationEffect, ScanlineEffect, SepiaEffect, ShockWaveEffect, SMAAEffect, TiltShiftEffect, VignetteEffect } from 'postprocessing';
|
|
8
|
-
import {
|
|
7
|
+
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, VignetteEffect } from 'postprocessing';
|
|
8
|
+
import { HalfFloatType, Group, NoToneMapping, Uniform, Texture, Color, CanvasTexture, RepeatWrapping, NearestFilter, Vector3, Vector2, Mesh } from 'three';
|
|
9
9
|
import { isWebGL2Available } from 'three-stdlib';
|
|
10
10
|
import { easing } from 'maath';
|
|
11
11
|
|
|
@@ -55,8 +55,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.3", ngImpor
|
|
|
55
55
|
}] });
|
|
56
56
|
const NgtpEffectHostDirective = { directive: NgtpEffect, inputs: ['blendFunction', 'opacity'] };
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
const defaultOptions$3 = {
|
|
58
|
+
const defaultOptions$4 = {
|
|
60
59
|
enabled: true,
|
|
61
60
|
renderPriority: 1,
|
|
62
61
|
autoClear: true,
|
|
@@ -68,7 +67,7 @@ function isConvolution(effect) {
|
|
|
68
67
|
}
|
|
69
68
|
class NgtpEffectComposer {
|
|
70
69
|
constructor() {
|
|
71
|
-
this.options = input(defaultOptions$
|
|
70
|
+
this.options = input(defaultOptions$4, { transform: mergeInputs(defaultOptions$4) });
|
|
72
71
|
this.injector = inject(Injector);
|
|
73
72
|
this.autoEffect = injectAutoEffect();
|
|
74
73
|
this.store = injectStore();
|
|
@@ -122,6 +121,7 @@ class NgtpEffectComposer {
|
|
|
122
121
|
}
|
|
123
122
|
return { composer, normalPass, downSamplingPass };
|
|
124
123
|
});
|
|
124
|
+
extend({ Group });
|
|
125
125
|
afterNextRender(() => {
|
|
126
126
|
this.disableToneMapping();
|
|
127
127
|
this.setComposerSize();
|
|
@@ -317,7 +317,7 @@ class ASCIIEffect extends Effect {
|
|
|
317
317
|
return texture;
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
|
-
const defaultOptions$
|
|
320
|
+
const defaultOptions$3 = {
|
|
321
321
|
font: 'arial',
|
|
322
322
|
characters: ` .:,'-^=*+?!|0#X%WM@`,
|
|
323
323
|
fontSize: 54,
|
|
@@ -327,7 +327,7 @@ const defaultOptions$2 = {
|
|
|
327
327
|
};
|
|
328
328
|
class NgtpASCII {
|
|
329
329
|
constructor() {
|
|
330
|
-
this.options = input(defaultOptions$
|
|
330
|
+
this.options = input(defaultOptions$3, { transform: mergeInputs(defaultOptions$3) });
|
|
331
331
|
this.effect = computed(() => new ASCIIEffect(this.options()));
|
|
332
332
|
}
|
|
333
333
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.3", ngImport: i0, type: NgtpASCII, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
@@ -555,7 +555,7 @@ class NgtpDepthOfField {
|
|
|
555
555
|
effect.setDepthTexture(options.depthTexture.texture, options.depthTexture.packing);
|
|
556
556
|
}
|
|
557
557
|
// Temporary fix that restores DOF 6.21.3 behavior, everything since then lets shapes leak through the blur
|
|
558
|
-
const maskPass = effect
|
|
558
|
+
const maskPass = effect['maskPass'];
|
|
559
559
|
maskPass.maskFunction = MaskFunction.MULTIPLY_RGB_SET_ALPHA;
|
|
560
560
|
return effect;
|
|
561
561
|
});
|
|
@@ -746,8 +746,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.3", ngImpor
|
|
|
746
746
|
class NgtpGrid {
|
|
747
747
|
constructor() {
|
|
748
748
|
this.autoEffect = injectAutoEffect();
|
|
749
|
-
this.store = injectStore();
|
|
750
|
-
this.invalidate = this.store.select('invalidate');
|
|
751
749
|
this.options = input({});
|
|
752
750
|
this.size = pick(this.options, 'size');
|
|
753
751
|
this.effect = computed(() => {
|
|
@@ -897,7 +895,7 @@ class LensFlareEffect extends Effect {
|
|
|
897
895
|
}
|
|
898
896
|
}
|
|
899
897
|
}
|
|
900
|
-
const defaultOptions$
|
|
898
|
+
const defaultOptions$2 = {
|
|
901
899
|
position: new Vector3(-25, 6, -60),
|
|
902
900
|
followMouse: false,
|
|
903
901
|
smoothTime: 0.7,
|
|
@@ -910,7 +908,7 @@ class NgtpLensFlare {
|
|
|
910
908
|
this.raycaster = this.store.select('raycaster');
|
|
911
909
|
this.pointer = this.store.select('pointer');
|
|
912
910
|
this.effectComposer = inject(NgtpEffectComposer);
|
|
913
|
-
this.options = input(defaultOptions$
|
|
911
|
+
this.options = input(defaultOptions$2, { transform: mergeInputs(defaultOptions$2) });
|
|
914
912
|
this.projectedPosition = new Vector3();
|
|
915
913
|
this.mouse2d = new Vector2();
|
|
916
914
|
this.effect = computed(() => {
|
|
@@ -983,7 +981,7 @@ class NgtpLensFlare {
|
|
|
983
981
|
}
|
|
984
982
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.3", ngImport: i0, type: NgtpLensFlare, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
985
983
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.1.3", type: NgtpLensFlare, isStandalone: true, selector: "ngtp-lens-flare", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
986
|
-
<ngt-primitive *args="[effect()]" [
|
|
984
|
+
<ngt-primitive *args="[effect()]" [parameters]="{ dispose: null }" />
|
|
987
985
|
`, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "ng-template[args]", inputs: ["args"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
988
986
|
}
|
|
989
987
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.3", ngImport: i0, type: NgtpLensFlare, decorators: [{
|
|
@@ -992,7 +990,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.3", ngImpor
|
|
|
992
990
|
selector: 'ngtp-lens-flare',
|
|
993
991
|
standalone: true,
|
|
994
992
|
template: `
|
|
995
|
-
<ngt-primitive *args="[effect()]" [
|
|
993
|
+
<ngt-primitive *args="[effect()]" [parameters]="{ dispose: null }" />
|
|
996
994
|
`,
|
|
997
995
|
imports: [NgtArgs],
|
|
998
996
|
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
@@ -1078,6 +1076,142 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.3", ngImpor
|
|
|
1078
1076
|
}]
|
|
1079
1077
|
}] });
|
|
1080
1078
|
|
|
1079
|
+
const defaultOptions$1 = {
|
|
1080
|
+
selectionLayer: 10,
|
|
1081
|
+
};
|
|
1082
|
+
class NgtpOutline {
|
|
1083
|
+
constructor() {
|
|
1084
|
+
this.options = input(defaultOptions$1, { transform: mergeInputs(defaultOptions$1) });
|
|
1085
|
+
this.ngtSelection = inject(NgtSelection, { optional: true });
|
|
1086
|
+
this.effectComposer = inject(NgtpEffectComposer);
|
|
1087
|
+
this.store = injectStore();
|
|
1088
|
+
this.invalidate = this.store.select('invalidate');
|
|
1089
|
+
this.selection = pick(this.options, 'selection');
|
|
1090
|
+
this.selectionLayer = pick(this.options, 'selectionLayer');
|
|
1091
|
+
this.blendFunction = pick(this.options, 'blendFunction');
|
|
1092
|
+
this.patternTexture = pick(this.options, 'patternTexture');
|
|
1093
|
+
this.edgeStrength = pick(this.options, 'edgeStrength');
|
|
1094
|
+
this.pulseSpeed = pick(this.options, 'pulseSpeed');
|
|
1095
|
+
this.visibleEdgeColor = pick(this.options, 'visibleEdgeColor');
|
|
1096
|
+
this.hiddenEdgeColor = pick(this.options, 'hiddenEdgeColor');
|
|
1097
|
+
this.width = pick(this.options, 'width');
|
|
1098
|
+
this.height = pick(this.options, 'height');
|
|
1099
|
+
this.kernelSize = pick(this.options, 'kernelSize');
|
|
1100
|
+
this.blur = pick(this.options, 'blur');
|
|
1101
|
+
this.xRay = pick(this.options, 'xRay');
|
|
1102
|
+
this.restOptions = omit(this.options, [
|
|
1103
|
+
'blendFunction',
|
|
1104
|
+
'patternTexture',
|
|
1105
|
+
'edgeStrength',
|
|
1106
|
+
'pulseSpeed',
|
|
1107
|
+
'visibleEdgeColor',
|
|
1108
|
+
'hiddenEdgeColor',
|
|
1109
|
+
'width',
|
|
1110
|
+
'height',
|
|
1111
|
+
'kernelSize',
|
|
1112
|
+
'blur',
|
|
1113
|
+
'xRay',
|
|
1114
|
+
]);
|
|
1115
|
+
this.effect = computed(() => {
|
|
1116
|
+
const [scene, camera, blendFunction, patternTexture, edgeStrength, pulseSpeed, visibleEdgeColor, hiddenEdgeColor, width, height, kernelSize, blur, xRay, restOptions,] = [
|
|
1117
|
+
this.effectComposer.scene(),
|
|
1118
|
+
this.effectComposer.camera(),
|
|
1119
|
+
this.blendFunction(),
|
|
1120
|
+
this.patternTexture(),
|
|
1121
|
+
this.edgeStrength(),
|
|
1122
|
+
this.pulseSpeed(),
|
|
1123
|
+
this.visibleEdgeColor(),
|
|
1124
|
+
this.hiddenEdgeColor(),
|
|
1125
|
+
this.width(),
|
|
1126
|
+
this.height(),
|
|
1127
|
+
this.kernelSize(),
|
|
1128
|
+
this.blur(),
|
|
1129
|
+
this.xRay(),
|
|
1130
|
+
untracked(this.restOptions),
|
|
1131
|
+
];
|
|
1132
|
+
return new OutlineEffect(scene, camera, {
|
|
1133
|
+
blendFunction,
|
|
1134
|
+
patternTexture,
|
|
1135
|
+
edgeStrength,
|
|
1136
|
+
pulseSpeed,
|
|
1137
|
+
visibleEdgeColor,
|
|
1138
|
+
hiddenEdgeColor,
|
|
1139
|
+
width,
|
|
1140
|
+
height,
|
|
1141
|
+
kernelSize,
|
|
1142
|
+
blur,
|
|
1143
|
+
xRay,
|
|
1144
|
+
...restOptions,
|
|
1145
|
+
});
|
|
1146
|
+
});
|
|
1147
|
+
const autoEffect = injectAutoEffect();
|
|
1148
|
+
afterNextRender(() => {
|
|
1149
|
+
autoEffect(() => {
|
|
1150
|
+
const effect = this.effect();
|
|
1151
|
+
return () => effect.dispose();
|
|
1152
|
+
});
|
|
1153
|
+
autoEffect(() => {
|
|
1154
|
+
const [effect, invalidate, selectionLayer] = [this.effect(), this.invalidate(), this.selectionLayer()];
|
|
1155
|
+
effect.selectionLayer = selectionLayer;
|
|
1156
|
+
invalidate();
|
|
1157
|
+
});
|
|
1158
|
+
autoEffect(() => {
|
|
1159
|
+
// NOTE: we run this effect if declarative NgtSelection is not enabled
|
|
1160
|
+
if (!this.ngtSelection) {
|
|
1161
|
+
// NOTE: if NgtSelection is not used and selection is not provided, we throw
|
|
1162
|
+
if (this.selection() === undefined) {
|
|
1163
|
+
throw new Error('[NGT PostProcessing]: ngtp-outline requires selection input or use NgtSelection');
|
|
1164
|
+
}
|
|
1165
|
+
return this.handleSelectionChangeEffect(this.selection, this.effect, this.invalidate);
|
|
1166
|
+
}
|
|
1167
|
+
// NOTE: we run this effect if declarative NgtSelection is enabled
|
|
1168
|
+
const selectionEnabled = this.ngtSelection.enabled();
|
|
1169
|
+
if (!selectionEnabled)
|
|
1170
|
+
return;
|
|
1171
|
+
return this.handleSelectionChangeEffect(this.ngtSelection.collection, this.effect, this.invalidate);
|
|
1172
|
+
});
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
handleSelectionChangeEffect(collection, _effect, _invalidate) {
|
|
1176
|
+
const selection = collection();
|
|
1177
|
+
if (!selection || selection.length === 0)
|
|
1178
|
+
return;
|
|
1179
|
+
const [effect, invalidate] = [_effect(), _invalidate()];
|
|
1180
|
+
const objects = [];
|
|
1181
|
+
for (const el of selection) {
|
|
1182
|
+
const obj = resolveRef(el);
|
|
1183
|
+
if (!obj)
|
|
1184
|
+
continue;
|
|
1185
|
+
objects.push(obj);
|
|
1186
|
+
}
|
|
1187
|
+
if (objects.length === 0)
|
|
1188
|
+
return;
|
|
1189
|
+
effect.selection.set(objects);
|
|
1190
|
+
invalidate();
|
|
1191
|
+
return () => {
|
|
1192
|
+
effect.selection.clear();
|
|
1193
|
+
invalidate();
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.3", ngImport: i0, type: NgtpOutline, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1197
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.1.3", type: NgtpOutline, isStandalone: true, selector: "ngtp-outline", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
1198
|
+
<ngt-primitive *args="[effect()]" />
|
|
1199
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "ng-template[args]", inputs: ["args"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
1200
|
+
}
|
|
1201
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.3", ngImport: i0, type: NgtpOutline, decorators: [{
|
|
1202
|
+
type: Component,
|
|
1203
|
+
args: [{
|
|
1204
|
+
selector: 'ngtp-outline',
|
|
1205
|
+
standalone: true,
|
|
1206
|
+
template: `
|
|
1207
|
+
<ngt-primitive *args="[effect()]" />
|
|
1208
|
+
`,
|
|
1209
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
1210
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1211
|
+
imports: [NgtArgs],
|
|
1212
|
+
}]
|
|
1213
|
+
}], ctorParameters: () => [] });
|
|
1214
|
+
|
|
1081
1215
|
class NgtpPixelation {
|
|
1082
1216
|
constructor() {
|
|
1083
1217
|
this.options = input({ granularity: 5 }, { transform: mergeInputs({ granularity: 5 }) });
|
|
@@ -1475,5 +1609,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.3", ngImpor
|
|
|
1475
1609
|
* Generated bundle index. Do not edit.
|
|
1476
1610
|
*/
|
|
1477
1611
|
|
|
1478
|
-
export { ASCIIEffect, LensFlareEffect, NgtpASCII, NgtpBloom, NgtpBrightnessContrast, NgtpChromaticAberration, NgtpColorAverage, NgtpColorDepth, NgtpDepth, NgtpDepthOfField, NgtpDotScreen, NgtpEffect, NgtpEffectBlendMode, NgtpEffectComposer, NgtpEffectHostDirective, NgtpFXAA, NgtpGlitch, NgtpGodRays, NgtpGrid, NgtpHueSaturation, NgtpLUT, NgtpLensFlare, NgtpNoise, NgtpPixelation, NgtpSMAA, NgtpScanline, NgtpSepia, NgtpShockWave, NgtpTiltShift, NgtpTiltShift2, NgtpVignette, NgtpWater, TiltShift2Effect, WaterEffect, injectDefaultEffectOptions, provideDefaultEffectOptions };
|
|
1612
|
+
export { ASCIIEffect, LensFlareEffect, NgtpASCII, NgtpBloom, NgtpBrightnessContrast, NgtpChromaticAberration, NgtpColorAverage, NgtpColorDepth, NgtpDepth, NgtpDepthOfField, NgtpDotScreen, NgtpEffect, NgtpEffectBlendMode, NgtpEffectComposer, NgtpEffectHostDirective, NgtpFXAA, NgtpGlitch, NgtpGodRays, NgtpGrid, NgtpHueSaturation, NgtpLUT, NgtpLensFlare, NgtpNoise, NgtpOutline, NgtpPixelation, NgtpSMAA, NgtpScanline, NgtpSepia, NgtpShockWave, NgtpTiltShift, NgtpTiltShift2, NgtpVignette, NgtpWater, TiltShift2Effect, WaterEffect, injectDefaultEffectOptions, provideDefaultEffectOptions };
|
|
1479
1613
|
//# sourceMappingURL=angular-three-postprocessing.mjs.map
|