@needle-tools/engine 4.6.1-next.1e3d612 → 4.6.1-next.2b1af6a

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 (68) hide show
  1. package/dist/{needle-engine.bundle-Dx31Hfkf.js → needle-engine.bundle-BBxAzv6J.js} +6556 -6485
  2. package/dist/{needle-engine.bundle-BYdv-DmQ.min.js → needle-engine.bundle-BwVJc8bG.min.js} +170 -158
  3. package/dist/{needle-engine.bundle-DsI9yYlp.umd.cjs → needle-engine.bundle-cvRBTPLl.umd.cjs} +173 -161
  4. package/dist/needle-engine.js +48 -48
  5. package/dist/needle-engine.min.js +1 -1
  6. package/dist/needle-engine.umd.cjs +1 -1
  7. package/lib/engine/engine_context.d.ts +2 -1
  8. package/lib/engine/engine_context.js +3 -2
  9. package/lib/engine/engine_context.js.map +1 -1
  10. package/lib/engine/engine_three_utils.d.ts +17 -14
  11. package/lib/engine/engine_three_utils.js +106 -53
  12. package/lib/engine/engine_three_utils.js.map +1 -1
  13. package/lib/engine/engine_tonemapping.d.ts +4 -0
  14. package/lib/engine/engine_tonemapping.js +21 -18
  15. package/lib/engine/engine_tonemapping.js.map +1 -1
  16. package/lib/engine/engine_utils.js.map +1 -1
  17. package/lib/engine/webcomponents/needle-engine.d.ts +4 -1
  18. package/lib/engine/webcomponents/needle-engine.extras.js +3 -3
  19. package/lib/engine/webcomponents/needle-engine.extras.js.map +1 -1
  20. package/lib/engine/webcomponents/needle-engine.js +11 -21
  21. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  22. package/lib/engine-components/CameraUtils.js.map +1 -1
  23. package/lib/engine-components/postprocessing/Effects/BloomEffect.d.ts +1 -1
  24. package/lib/engine-components/postprocessing/Effects/BloomEffect.js +2 -2
  25. package/lib/engine-components/postprocessing/Effects/ColorAdjustments.d.ts +8 -0
  26. package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js +27 -8
  27. package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js.map +1 -1
  28. package/lib/engine-components/postprocessing/Effects/Sharpening.d.ts +1 -1
  29. package/lib/engine-components/postprocessing/Effects/Sharpening.js +2 -2
  30. package/lib/engine-components/postprocessing/Effects/Sharpening.js.map +1 -1
  31. package/lib/engine-components/postprocessing/Effects/Tonemapping.d.ts +2 -9
  32. package/lib/engine-components/postprocessing/Effects/Tonemapping.js +22 -57
  33. package/lib/engine-components/postprocessing/Effects/Tonemapping.js.map +1 -1
  34. package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.d.ts +13 -0
  35. package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.js +52 -0
  36. package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.js.map +1 -0
  37. package/lib/engine-components/postprocessing/PostProcessingEffect.d.ts +7 -7
  38. package/lib/engine-components/postprocessing/PostProcessingEffect.js +7 -7
  39. package/lib/engine-components/postprocessing/PostProcessingEffect.js.map +1 -1
  40. package/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +6 -1
  41. package/lib/engine-components/postprocessing/PostProcessingHandler.js +107 -16
  42. package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
  43. package/lib/engine-components/postprocessing/Volume.js +19 -24
  44. package/lib/engine-components/postprocessing/Volume.js.map +1 -1
  45. package/lib/engine-components/postprocessing/index.d.ts +1 -1
  46. package/lib/engine-components/postprocessing/index.js +1 -1
  47. package/lib/engine-components/postprocessing/index.js.map +1 -1
  48. package/lib/engine-components/postprocessing/utils.d.ts +6 -6
  49. package/lib/engine-components/postprocessing/utils.js +26 -25
  50. package/lib/engine-components/postprocessing/utils.js.map +1 -1
  51. package/package.json +1 -1
  52. package/src/engine/engine_context.ts +5 -3
  53. package/src/engine/engine_three_utils.ts +134 -58
  54. package/src/engine/engine_tonemapping.ts +23 -24
  55. package/src/engine/engine_utils.ts +2 -2
  56. package/src/engine/webcomponents/needle-engine.extras.ts +3 -3
  57. package/src/engine/webcomponents/needle-engine.ts +14 -25
  58. package/src/engine-components/CameraUtils.ts +3 -3
  59. package/src/engine-components/postprocessing/Effects/BloomEffect.ts +2 -2
  60. package/src/engine-components/postprocessing/Effects/ColorAdjustments.ts +24 -13
  61. package/src/engine-components/postprocessing/Effects/Sharpening.ts +2 -2
  62. package/src/engine-components/postprocessing/Effects/Tonemapping.ts +24 -66
  63. package/src/engine-components/postprocessing/Effects/Tonemapping.utils.ts +60 -0
  64. package/src/engine-components/postprocessing/PostProcessingEffect.ts +7 -7
  65. package/src/engine-components/postprocessing/PostProcessingHandler.ts +122 -20
  66. package/src/engine-components/postprocessing/Volume.ts +19 -26
  67. package/src/engine-components/postprocessing/index.ts +1 -1
  68. package/src/engine-components/postprocessing/utils.ts +27 -26
@@ -64,21 +64,21 @@ export type PostprocessingEffectData = {
64
64
  }
65
65
 
66
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.
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
70
  * @example
71
71
  * ```typescript
72
- * import { PostProcessingEffectPriority } from "@needle-tools/engine"
73
- *
72
+ * import { PostProcessingEffectOrder } from "@needle-tools/engine"
73
+ *
74
74
  * export class MyCustomEffect extends PostProcessingEffect {
75
- * priority: PostProcessingEffectPriority.Bloom + 1; // render after bloom
75
+ * order: PostProcessingEffectPriority.Bloom + 1; // render after bloom
76
76
  *
77
77
  * // ... your effect code
78
78
  * }
79
79
  * ```
80
80
  */
81
- export const PostProcessingEffectPriority = {
81
+ export const PostProcessingEffectOrder = {
82
82
  /** Used to render effects at the start of the post-processing chain */
83
83
  AT_START: -10_000,
84
84
 
@@ -109,36 +109,37 @@ export function orderEffects(effects: Array<PostprocessingEffectData>) {
109
109
 
110
110
  if (!builtinOrder) {
111
111
  builtinOrder = new Map<Constructor<Effect | Pass>, number>();
112
- builtinOrder.set(MODULES.POSTPROCESSING.MODULE.NormalPass, PostProcessingEffectPriority.NormalPass);
113
- builtinOrder.set(MODULES.POSTPROCESSING.MODULE.DepthDownsamplingPass, PostProcessingEffectPriority.DepthDownsamplingPass);
114
- builtinOrder.set(MODULES.POSTPROCESSING.MODULE.SMAAEffect, PostProcessingEffectPriority.SMAA);
115
- builtinOrder.set(MODULES.POSTPROCESSING.MODULE.SSAOEffect, PostProcessingEffectPriority.SSAO);
116
- builtinOrder.set(MODULES.POSTPROCESSING_AO.MODULE.N8AOPostPass, PostProcessingEffectPriority.SSAO);
117
- builtinOrder.set(MODULES.POSTPROCESSING.MODULE.TiltShiftEffect, PostProcessingEffectPriority.TiltShift);
118
- builtinOrder.set(MODULES.POSTPROCESSING.MODULE.DepthOfFieldEffect, PostProcessingEffectPriority.DepthOfField);
119
- builtinOrder.set(MODULES.POSTPROCESSING.MODULE.ChromaticAberrationEffect, PostProcessingEffectPriority.ChromaticAberration);
120
- builtinOrder.set(MODULES.POSTPROCESSING.MODULE.BloomEffect, PostProcessingEffectPriority.Bloom);
121
- builtinOrder.set(MODULES.POSTPROCESSING.MODULE.SelectiveBloomEffect, PostProcessingEffectPriority.Bloom);
122
- builtinOrder.set(MODULES.POSTPROCESSING.MODULE.VignetteEffect, PostProcessingEffectPriority.Vignette);
123
- builtinOrder.set(MODULES.POSTPROCESSING.MODULE.PixelationEffect, PostProcessingEffectPriority.Pixelation);
124
- builtinOrder.set(MODULES.POSTPROCESSING.MODULE.ToneMappingEffect, PostProcessingEffectPriority.ToneMapping);
125
- builtinOrder.set(MODULES.POSTPROCESSING.MODULE.HueSaturationEffect, PostProcessingEffectPriority.HueSaturation);
126
- builtinOrder.set(MODULES.POSTPROCESSING.MODULE.BrightnessContrastEffect, PostProcessingEffectPriority.BrightnessContrast);
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);
127
128
  }
128
129
 
129
130
  // enforce correct order of effects (e.g. DOF before Bloom)
130
131
  effects.sort((a, b) => {
131
132
  // we use find index here because sometimes constructor names are prefixed with `_`
132
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)
133
- const aidx = typeof a.priority === "number" ? a.priority : builtinOrder!.get(a.effect.constructor as Constructor<Effect | Pass>) || -1;
134
- const bidx = typeof b.priority === "number" ? b.priority : builtinOrder!.get(b.effect.constructor as Constructor<Effect | Pass>) || -1;
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;
135
136
 
136
137
  // Unknown effects should be rendered first
137
- if (aidx < 0) {
138
+ if (aidx === Number.NEGATIVE_INFINITY) {
138
139
  if (debug) console.warn("Unknown effect found: ", a.constructor.name, a);
139
140
  return 1;
140
141
  }
141
- else if (bidx < 0) {
142
+ else if (bidx === Number.NEGATIVE_INFINITY) {
142
143
  if (debug) console.warn("Unknown effect found: ", b.constructor.name, b);
143
144
  return -1;
144
145
  }