@needle-tools/engine 4.6.1 → 4.6.2
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/CHANGELOG.md +6 -0
- package/dist/generateMeshBVH.worker-BaNp_Xtp.js +25 -0
- package/dist/{gltf-progressive-Bm9eEfgu.min.js → gltf-progressive-Bl4okF1b.min.js} +1 -1
- package/dist/{gltf-progressive-GjIqwSG3.js → gltf-progressive-DSpdn0QT.js} +2 -2
- package/dist/{gltf-progressive-Dn6o99rH.umd.cjs → gltf-progressive-P8b8a0qY.umd.cjs} +1 -1
- package/dist/needle-engine.bundle-D0XWaCQs.min.js +1575 -0
- package/dist/{needle-engine.bundle-BVg46UWZ.js → needle-engine.bundle-DGcStTA7.js} +9715 -9555
- package/dist/needle-engine.bundle-DmYMLdWP.umd.cjs +1575 -0
- package/dist/needle-engine.js +352 -351
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{postprocessing-CRQa6Qxn.umd.cjs → postprocessing-CjW23fio.umd.cjs} +18 -18
- package/dist/{postprocessing-D6W1EyZ-.js → postprocessing-DYLNOL3W.js} +4 -3
- package/dist/{postprocessing-DF8AlRgW.min.js → postprocessing-xYQWCHFu.min.js} +26 -26
- package/dist/{three-DMrv-4ar.umd.cjs → three-B_hneGZr.umd.cjs} +4 -4
- package/dist/{three-Bz6X1mrw.js → three-DrqIzZTH.js} +4198 -4198
- package/dist/{three-Boa-jOq-.min.js → three-DuDKwKB8.min.js} +33 -33
- package/dist/{three-examples-GggCDHv0.js → three-examples-B50TT3Iu.js} +5 -5
- package/dist/{three-examples-DuVhxqft.min.js → three-examples-DaDLBuy6.min.js} +14 -14
- package/dist/{three-examples-C7ryg8vN.umd.cjs → three-examples-X3OadjXB.umd.cjs} +3 -3
- package/dist/{three-mesh-ui-CY6Izc7C.min.js → three-mesh-ui-B3p3gyUz.min.js} +1 -1
- package/dist/{three-mesh-ui-CwlN0FUC.umd.cjs → three-mesh-ui-CQiIQIlA.umd.cjs} +1 -1
- package/dist/{three-mesh-ui-CLNOfsWn.js → three-mesh-ui-CxuWt7m-.js} +1 -1
- package/dist/{vendor-zxXa3Dmr.min.js → vendor-BlSxe9JJ.min.js} +3 -3
- package/dist/{vendor-BSD1RQIh.js → vendor-BmYIgaS1.js} +3 -3
- package/dist/{vendor-DHr4aqIZ.umd.cjs → vendor-Cavtu3CP.umd.cjs} +3 -3
- package/lib/engine/engine_context.d.ts +4 -1
- package/lib/engine/engine_context.js +9 -2
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_three_utils.d.ts +17 -14
- package/lib/engine/engine_three_utils.js +106 -53
- package/lib/engine/engine_three_utils.js.map +1 -1
- package/lib/engine/engine_tonemapping.d.ts +4 -0
- package/lib/engine/engine_tonemapping.js +21 -18
- package/lib/engine/engine_tonemapping.js.map +1 -1
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/engine_utils_screenshot.d.ts +1 -1
- package/lib/engine/engine_utils_screenshot.js +11 -2
- package/lib/engine/engine_utils_screenshot.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.d.ts +4 -1
- package/lib/engine/webcomponents/needle-engine.extras.js +3 -3
- package/lib/engine/webcomponents/needle-engine.extras.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.js +11 -21
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/lib/engine-components/CameraUtils.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Antialiasing.js +3 -1
- package/lib/engine-components/postprocessing/Effects/Antialiasing.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/BloomEffect.d.ts +2 -2
- package/lib/engine-components/postprocessing/Effects/BloomEffect.js +5 -2
- package/lib/engine-components/postprocessing/Effects/BloomEffect.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.d.ts +8 -0
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js +27 -8
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.js +1 -0
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Sharpening.d.ts +1 -0
- package/lib/engine-components/postprocessing/Effects/Sharpening.js +4 -0
- package/lib/engine-components/postprocessing/Effects/Sharpening.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.d.ts +2 -9
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js +23 -71
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.d.ts +13 -0
- package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.js +52 -0
- package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.js.map +1 -0
- package/lib/engine-components/postprocessing/PostProcessingEffect.d.ts +18 -0
- package/lib/engine-components/postprocessing/PostProcessingEffect.js +22 -3
- package/lib/engine-components/postprocessing/PostProcessingEffect.js.map +1 -1
- package/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +20 -4
- package/lib/engine-components/postprocessing/PostProcessingHandler.js +209 -112
- package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
- package/lib/engine-components/postprocessing/Volume.d.ts +2 -1
- package/lib/engine-components/postprocessing/Volume.js +51 -33
- package/lib/engine-components/postprocessing/Volume.js.map +1 -1
- package/lib/engine-components/postprocessing/index.d.ts +1 -0
- package/lib/engine-components/postprocessing/index.js +1 -0
- package/lib/engine-components/postprocessing/index.js.map +1 -1
- package/lib/engine-components/postprocessing/utils.d.ts +43 -0
- package/lib/engine-components/postprocessing/utils.js +82 -0
- package/lib/engine-components/postprocessing/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/engine_context.ts +13 -4
- package/src/engine/engine_three_utils.ts +134 -58
- package/src/engine/engine_tonemapping.ts +23 -24
- package/src/engine/engine_utils.ts +2 -2
- package/src/engine/engine_utils_screenshot.ts +13 -3
- package/src/engine/webcomponents/needle-engine.extras.ts +3 -3
- package/src/engine/webcomponents/needle-engine.ts +14 -25
- package/src/engine-components/CameraUtils.ts +3 -3
- package/src/engine-components/postprocessing/Effects/Antialiasing.ts +3 -1
- package/src/engine-components/postprocessing/Effects/BloomEffect.ts +6 -4
- package/src/engine-components/postprocessing/Effects/ColorAdjustments.ts +24 -13
- package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.ts +1 -0
- package/src/engine-components/postprocessing/Effects/Sharpening.ts +5 -0
- package/src/engine-components/postprocessing/Effects/Tonemapping.ts +26 -80
- package/src/engine-components/postprocessing/Effects/Tonemapping.utils.ts +60 -0
- package/src/engine-components/postprocessing/PostProcessingEffect.ts +23 -3
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +239 -119
- package/src/engine-components/postprocessing/Volume.ts +54 -38
- package/src/engine-components/postprocessing/index.ts +2 -1
- package/src/engine-components/postprocessing/utils.ts +102 -2
- package/dist/generateMeshBVH.worker-Cdfpaq5W.js +0 -25
- package/dist/needle-engine.bundle-AOXFIsYk.umd.cjs +0 -1563
- package/dist/needle-engine.bundle-Dt52m2jf.min.js +0 -1563
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./PostProcessingEffect.js";
|
|
2
2
|
export * from "./PostProcessingHandler.js"
|
|
3
|
+
export { PostProcessingEffectOrder } from "./utils.js";
|
|
3
4
|
export { PostProcessingManager } from "./Volume.js"
|
|
4
5
|
export * from "./VolumeParameter.js"
|
|
5
|
-
export * from "./VolumeProfile.js";
|
|
6
|
+
export * from "./VolumeProfile.js";
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { Effect, Pass } from "postprocessing";
|
|
1
2
|
import { Object3D } from "three";
|
|
2
3
|
|
|
3
4
|
import { isDevEnvironment } from "../../engine/debug/index.js";
|
|
4
5
|
import { addComponent } from "../../engine/engine_components.js";
|
|
5
6
|
import { foreachComponentEnumerator } from "../../engine/engine_gameobject.js";
|
|
6
|
-
import {
|
|
7
|
+
import { MODULES } from "../../engine/engine_modules.js";
|
|
8
|
+
import { Constructor, ConstructorConcrete, IComponent } from "../../engine/engine_types.js";
|
|
7
9
|
import { getParam } from "../../engine/engine_utils.js";
|
|
8
10
|
import { type PostProcessingEffect } from "./PostProcessingEffect.js";
|
|
9
11
|
|
|
@@ -11,6 +13,8 @@ export const debug = getParam("debugpost");
|
|
|
11
13
|
|
|
12
14
|
export type IPostProcessingManager = IComponent & {
|
|
13
15
|
get isPostProcessingManager(): boolean;
|
|
16
|
+
get dirty(): boolean;
|
|
17
|
+
set dirty(value: boolean);
|
|
14
18
|
addEffect(effect: PostProcessingEffect): void;
|
|
15
19
|
removeEffect(effect: PostProcessingEffect): void;
|
|
16
20
|
}
|
|
@@ -50,4 +54,100 @@ export function getPostProcessingManager(effect: PostProcessingEffect): IPostPro
|
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
return manager;
|
|
53
|
-
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
export type PostprocessingEffectData = {
|
|
62
|
+
effect: Effect | Pass;
|
|
63
|
+
priority?: number,
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Default order for post-processing effects. This can be used to sort effects by their rendering order when creating custom effects.
|
|
68
|
+
* E.g. in your custom effect, you can set `order: PostProcessingEffectOrder.Bloom + 1;` to ensure it gets rendered after the bloom effect.
|
|
69
|
+
* OR `order: PostProcessingEffectOrder.Bloom - 1;` to ensure it gets rendered before the bloom effect.
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* import { PostProcessingEffectOrder } from "@needle-tools/engine"
|
|
73
|
+
*
|
|
74
|
+
* export class MyCustomEffect extends PostProcessingEffect {
|
|
75
|
+
* order: PostProcessingEffectPriority.Bloom + 1; // render after bloom
|
|
76
|
+
*
|
|
77
|
+
* // ... your effect code
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export const PostProcessingEffectOrder = {
|
|
82
|
+
/** Used to render effects at the start of the post-processing chain */
|
|
83
|
+
AT_START: -10_000,
|
|
84
|
+
|
|
85
|
+
NormalPass: 0,
|
|
86
|
+
DepthDownsamplingPass: 10,
|
|
87
|
+
SSAO: 20,
|
|
88
|
+
SMAA: 30,
|
|
89
|
+
TiltShift: 40,
|
|
90
|
+
DepthOfField: 50,
|
|
91
|
+
ChromaticAberration: 60,
|
|
92
|
+
Bloom: 70,
|
|
93
|
+
Vignette: 80,
|
|
94
|
+
Pixelation: 90,
|
|
95
|
+
ToneMapping: 100,
|
|
96
|
+
HueSaturation: 110,
|
|
97
|
+
BrightnessContrast: 120,
|
|
98
|
+
Sharpening: 130,
|
|
99
|
+
|
|
100
|
+
/** Used to render effects at the end of the post-processing chain, e.g. for final adjustments or overlays. */
|
|
101
|
+
AT_END: 10_000,
|
|
102
|
+
}
|
|
103
|
+
// let effectsOrder: Array<Constructor<Effect | Pass>> | null = null;
|
|
104
|
+
|
|
105
|
+
let builtinOrder: Map<Constructor<Effect | Pass>, number> | null = null;
|
|
106
|
+
|
|
107
|
+
export function orderEffects(effects: Array<PostprocessingEffectData>) {
|
|
108
|
+
if (debug === "verbose") console.debug("Before ordering effects", [...effects]);
|
|
109
|
+
|
|
110
|
+
if (!builtinOrder) {
|
|
111
|
+
builtinOrder = new Map<Constructor<Effect | Pass>, number>();
|
|
112
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.NormalPass, PostProcessingEffectOrder.NormalPass);
|
|
113
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.DepthDownsamplingPass, PostProcessingEffectOrder.DepthDownsamplingPass);
|
|
114
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.SMAAEffect, PostProcessingEffectOrder.SMAA);
|
|
115
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.SSAOEffect, PostProcessingEffectOrder.SSAO);
|
|
116
|
+
builtinOrder.set(MODULES.POSTPROCESSING_AO.MODULE.N8AOPostPass, PostProcessingEffectOrder.SSAO);
|
|
117
|
+
builtinOrder.set(MODULES.POSTPROCESSING_AO.MODULE.N8AOPass, PostProcessingEffectOrder.SSAO);
|
|
118
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.TiltShiftEffect, PostProcessingEffectOrder.TiltShift);
|
|
119
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.DepthOfFieldEffect, PostProcessingEffectOrder.DepthOfField);
|
|
120
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.ChromaticAberrationEffect, PostProcessingEffectOrder.ChromaticAberration);
|
|
121
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.BloomEffect, PostProcessingEffectOrder.Bloom);
|
|
122
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.SelectiveBloomEffect, PostProcessingEffectOrder.Bloom);
|
|
123
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.VignetteEffect, PostProcessingEffectOrder.Vignette);
|
|
124
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.PixelationEffect, PostProcessingEffectOrder.Pixelation);
|
|
125
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.ToneMappingEffect, PostProcessingEffectOrder.ToneMapping);
|
|
126
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.HueSaturationEffect, PostProcessingEffectOrder.HueSaturation);
|
|
127
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.BrightnessContrastEffect, PostProcessingEffectOrder.BrightnessContrast);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// enforce correct order of effects (e.g. DOF before Bloom)
|
|
131
|
+
effects.sort((a, b) => {
|
|
132
|
+
// we use find index here because sometimes constructor names are prefixed with `_`
|
|
133
|
+
// TODO: find a more robust solution that isnt name based (not sure if that exists tho... maybe we must give effect TYPES some priority/index)
|
|
134
|
+
const aidx = typeof a.priority === "number" ? a.priority : builtinOrder!.get(a.effect.constructor as Constructor<Effect | Pass>) ?? Number.NEGATIVE_INFINITY;
|
|
135
|
+
const bidx = typeof b.priority === "number" ? b.priority : builtinOrder!.get(b.effect.constructor as Constructor<Effect | Pass>) ?? Number.NEGATIVE_INFINITY;
|
|
136
|
+
|
|
137
|
+
// Unknown effects should be rendered first
|
|
138
|
+
if (aidx === Number.NEGATIVE_INFINITY) {
|
|
139
|
+
if (debug) console.warn("Unknown effect found: ", a.constructor.name, a);
|
|
140
|
+
return 1;
|
|
141
|
+
}
|
|
142
|
+
else if (bidx === Number.NEGATIVE_INFINITY) {
|
|
143
|
+
if (debug) console.warn("Unknown effect found: ", b.constructor.name, b);
|
|
144
|
+
return -1;
|
|
145
|
+
}
|
|
146
|
+
return aidx - bidx;
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
if (debug === "verbose") console.debug("After ordering effects", [...effects]);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
|