@needle-tools/engine 4.6.0 → 4.6.1-next.5971d67
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-OFyr3b1P.min.js +1563 -0
- package/dist/{needle-engine.bundle-CoJqbtmp.umd.cjs → needle-engine.bundle-PlhhqNqg.umd.cjs} +152 -148
- package/dist/{needle-engine.bundle-DsrPZ9gj.js → needle-engine.bundle-xzFdwTHR.js} +8052 -7969
- package/dist/needle-engine.js +343 -342
- 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_assetdatabase.js +3 -1
- package/lib/engine/engine_assetdatabase.js.map +1 -1
- package/lib/engine/engine_context.d.ts +2 -2
- package/lib/engine/engine_context.js +15 -11
- package/lib/engine/engine_context.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-components/ReflectionProbe.d.ts +2 -1
- package/lib/engine-components/ReflectionProbe.js +4 -1
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/Renderer.js +9 -5
- package/lib/engine-components/Renderer.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 +1 -1
- package/lib/engine-components/postprocessing/Effects/BloomEffect.js +3 -0
- package/lib/engine-components/postprocessing/Effects/BloomEffect.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js +10 -6
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js.map +1 -1
- package/lib/engine-components/postprocessing/PostProcessingEffect.d.ts +18 -0
- package/lib/engine-components/postprocessing/PostProcessingEffect.js +20 -1
- package/lib/engine-components/postprocessing/PostProcessingEffect.js.map +1 -1
- package/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +11 -3
- package/lib/engine-components/postprocessing/PostProcessingHandler.js +118 -117
- 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 +50 -27
- 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 +38 -0
- package/lib/engine-components/postprocessing/utils.js +98 -0
- package/lib/engine-components/postprocessing/utils.js.map +1 -1
- package/package.json +2 -2
- package/plugins/vite/dependency-watcher.js +8 -2
- package/src/engine/engine_assetdatabase.ts +3 -1
- package/src/engine/engine_context.ts +17 -12
- package/src/engine/engine_utils_screenshot.ts +13 -3
- package/src/engine-components/ReflectionProbe.ts +5 -1
- package/src/engine-components/Renderer.ts +10 -7
- package/src/engine-components/postprocessing/Effects/Antialiasing.ts +3 -1
- package/src/engine-components/postprocessing/Effects/BloomEffect.ts +4 -2
- package/src/engine-components/postprocessing/Effects/Tonemapping.ts +9 -7
- package/src/engine-components/postprocessing/PostProcessingEffect.ts +21 -1
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +137 -123
- package/src/engine-components/postprocessing/Volume.ts +56 -33
- package/src/engine-components/postprocessing/index.ts +1 -0
- package/src/engine-components/postprocessing/utils.ts +118 -2
- package/dist/generateMeshBVH.worker-Cdfpaq5W.js +0 -25
- package/dist/needle-engine.bundle-BDO_N7gN.min.js +0 -1559
|
@@ -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,116 @@ 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 priority 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 `priority: PostProcessingEffectPriority.Bloom + 1;` to ensure it gets rendered after the bloom effect.
|
|
69
|
+
* OR `priority: PostProcessingEffectPriority.Bloom - 1;` to ensure it gets rendered before the bloom effect.
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* import { PostProcessingEffectPriority } from "@needle-tools/engine"
|
|
73
|
+
*
|
|
74
|
+
* export class MyCustomEffect extends PostProcessingEffect {
|
|
75
|
+
* priority: PostProcessingEffectPriority.Bloom + 1; // render after bloom
|
|
76
|
+
*
|
|
77
|
+
* // ... your effect code
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export const PostProcessingEffectPriority = {
|
|
82
|
+
NormalPass: 0,
|
|
83
|
+
DepthDownsamplingPass: 10,
|
|
84
|
+
SMAA: 20,
|
|
85
|
+
SSAO: 30,
|
|
86
|
+
TiltShift: 40,
|
|
87
|
+
DepthOfField: 50,
|
|
88
|
+
ChromaticAberration: 60,
|
|
89
|
+
Bloom: 70,
|
|
90
|
+
Vignette: 80,
|
|
91
|
+
Pixelation: 90,
|
|
92
|
+
ToneMapping: 100,
|
|
93
|
+
HueSaturation: 110,
|
|
94
|
+
BrightnessContrast: 120,
|
|
95
|
+
// Sharpening: 130,
|
|
96
|
+
}
|
|
97
|
+
// let effectsOrder: Array<Constructor<Effect | Pass>> | null = null;
|
|
98
|
+
|
|
99
|
+
let builtinOrder: Map<Constructor<Effect | Pass>, number> | null = null;
|
|
100
|
+
|
|
101
|
+
export function orderEffects(effects: Array<PostprocessingEffectData>) {
|
|
102
|
+
if (debug === "verbose") console.debug("Before ordering effects", [...effects]);
|
|
103
|
+
|
|
104
|
+
if (!builtinOrder) {
|
|
105
|
+
builtinOrder = new Map<Constructor<Effect | Pass>, number>();
|
|
106
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.NormalPass, PostProcessingEffectPriority.NormalPass);
|
|
107
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.DepthDownsamplingPass, PostProcessingEffectPriority.DepthDownsamplingPass);
|
|
108
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.SMAAEffect, PostProcessingEffectPriority.SMAA);
|
|
109
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.SSAOEffect, PostProcessingEffectPriority.SSAO);
|
|
110
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.TiltShiftEffect, PostProcessingEffectPriority.TiltShift);
|
|
111
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.DepthOfFieldEffect, PostProcessingEffectPriority.DepthOfField);
|
|
112
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.ChromaticAberrationEffect, PostProcessingEffectPriority.ChromaticAberration);
|
|
113
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.BloomEffect, PostProcessingEffectPriority.Bloom);
|
|
114
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.VignetteEffect, PostProcessingEffectPriority.Vignette);
|
|
115
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.PixelationEffect, PostProcessingEffectPriority.Pixelation);
|
|
116
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.ToneMappingEffect, PostProcessingEffectPriority.ToneMapping);
|
|
117
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.HueSaturationEffect, PostProcessingEffectPriority.HueSaturation);
|
|
118
|
+
builtinOrder.set(MODULES.POSTPROCESSING.MODULE.BrightnessContrastEffect, PostProcessingEffectPriority.BrightnessContrast);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// enforce correct order of effects (e.g. DOF before Bloom)
|
|
122
|
+
effects.sort((a, b) => {
|
|
123
|
+
// we use find index here because sometimes constructor names are prefixed with `_`
|
|
124
|
+
// 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)
|
|
125
|
+
const aidx = typeof a.priority === "number" ? a.priority : builtinOrder!.get(a.effect.constructor as Constructor<Effect | Pass>) || -1;
|
|
126
|
+
const bidx = typeof b.priority === "number" ? b.priority : builtinOrder!.get(b.effect.constructor as Constructor<Effect | Pass>) || -1;
|
|
127
|
+
|
|
128
|
+
// Unknown effects should be rendered first
|
|
129
|
+
if (aidx < 0) {
|
|
130
|
+
if (debug) console.warn("Unknown effect found: ", a.constructor.name);
|
|
131
|
+
return -1;
|
|
132
|
+
}
|
|
133
|
+
else if (bidx < 0) {
|
|
134
|
+
if (debug) console.warn("Unknown effect found: ", b.constructor.name);
|
|
135
|
+
return 1;
|
|
136
|
+
}
|
|
137
|
+
// if (aidx < 0) return 1;
|
|
138
|
+
// if (bidx < 0) return -1;
|
|
139
|
+
return aidx - bidx;
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// effects.sort((a, b) => {
|
|
143
|
+
// if (a.beforeEffect) {
|
|
144
|
+
// const beforeA = effectsOrder!.findIndex(e => a.beforeEffect!.constructor.name.endsWith(e.name));
|
|
145
|
+
// if (beforeA >= 0) {
|
|
146
|
+
// return -1; // before effect should be rendered first
|
|
147
|
+
// }
|
|
148
|
+
// else {
|
|
149
|
+
// return 1; // no before effect, so we can keep the order
|
|
150
|
+
// }
|
|
151
|
+
// }
|
|
152
|
+
// else if (b.beforeEffect) {
|
|
153
|
+
// const beforeB = effectsOrder!.findIndex(e => b.beforeEffect!.constructor.name.endsWith(e.name));
|
|
154
|
+
// if (beforeB >= 0) {
|
|
155
|
+
// return 1; // before effect should be rendered first
|
|
156
|
+
// }
|
|
157
|
+
// else if (a.beforeEffect) {
|
|
158
|
+
// return -1; // no before effect, so we can keep the order
|
|
159
|
+
// }
|
|
160
|
+
|
|
161
|
+
// }
|
|
162
|
+
// return 0; // no before effect, so we can keep the order
|
|
163
|
+
// });
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
if (debug === "verbose") console.debug("After ordering effects", [...effects]);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
|