@needle-tools/engine 4.3.0-alpha.4 → 4.3.0-alpha.6
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 +10 -0
- package/dist/needle-engine.bundle.js +5050 -5003
- package/dist/needle-engine.bundle.light.js +4922 -4875
- package/dist/needle-engine.bundle.light.min.js +107 -107
- package/dist/needle-engine.bundle.light.umd.cjs +115 -115
- package/dist/needle-engine.bundle.min.js +107 -107
- package/dist/needle-engine.bundle.umd.cjs +115 -115
- package/dist/needle-engine.d.ts +9 -9
- package/lib/engine/engine_addressables.js +10 -2
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_math.d.ts +22 -2
- package/lib/engine/engine_math.js +23 -3
- package/lib/engine/engine_math.js.map +1 -1
- package/lib/engine/engine_three_utils.d.ts +8 -2
- package/lib/engine/engine_three_utils.js +17 -10
- package/lib/engine/engine_three_utils.js.map +1 -1
- package/lib/engine/engine_utils_screenshot.js +17 -2
- package/lib/engine/engine_utils_screenshot.js.map +1 -1
- package/lib/engine-components/AudioSource.js +10 -3
- package/lib/engine-components/AudioSource.js.map +1 -1
- package/lib/engine-components/RigidBody.d.ts +3 -1
- package/lib/engine-components/RigidBody.js +6 -5
- package/lib/engine-components/RigidBody.js.map +1 -1
- package/lib/engine-components/SpriteRenderer.d.ts +2 -0
- package/lib/engine-components/SpriteRenderer.js +16 -6
- package/lib/engine-components/SpriteRenderer.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.d.ts +2 -0
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.js +42 -5
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.js.map +1 -1
- package/lib/engine-components/postprocessing/PostProcessingEffect.d.ts +4 -0
- package/lib/engine-components/postprocessing/PostProcessingEffect.js +9 -1
- package/lib/engine-components/postprocessing/PostProcessingEffect.js.map +1 -1
- package/lib/engine-components/postprocessing/PostProcessingHandler.js +6 -6
- package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
- package/lib/engine-components/postprocessing/Volume.js +6 -6
- package/lib/engine-components/postprocessing/Volume.js.map +1 -1
- package/lib/engine-components/postprocessing/VolumeProfile.d.ts +2 -1
- package/lib/engine-components/postprocessing/VolumeProfile.js +8 -2
- package/lib/engine-components/postprocessing/VolumeProfile.js.map +1 -1
- package/package.json +2 -2
- package/src/engine/engine_addressables.ts +12 -2
- package/src/engine/engine_math.ts +25 -7
- package/src/engine/engine_three_utils.ts +22 -14
- package/src/engine/engine_utils_screenshot.ts +17 -3
- package/src/engine-components/AudioSource.ts +17 -8
- package/src/engine-components/RigidBody.ts +6 -4
- package/src/engine-components/SpriteRenderer.ts +22 -6
- package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.ts +56 -9
- package/src/engine-components/postprocessing/PostProcessingEffect.ts +7 -1
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +6 -6
- package/src/engine-components/postprocessing/Volume.ts +5 -7
- package/src/engine-components/postprocessing/VolumeProfile.ts +10 -2
|
@@ -75,6 +75,10 @@ export abstract class PostProcessingEffect extends Component implements IEffectP
|
|
|
75
75
|
|
|
76
76
|
abstract get typeName(): string;
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Whether the effect is active or not. Prefer using `enabled` instead.
|
|
80
|
+
* @deprecated
|
|
81
|
+
*/
|
|
78
82
|
@serializable()
|
|
79
83
|
active: boolean = true;
|
|
80
84
|
|
|
@@ -82,14 +86,16 @@ export abstract class PostProcessingEffect extends Component implements IEffectP
|
|
|
82
86
|
|
|
83
87
|
onEnable(): void {
|
|
84
88
|
super.onEnable();
|
|
85
|
-
this.
|
|
89
|
+
if (debug) console.warn("onEnable effect", this, this.__internalDidAwakeAndStart)
|
|
86
90
|
// Dont override the serialized value by enabling (we could also just disable this component / map enabled to active)
|
|
87
91
|
if (this.__internalDidAwakeAndStart)
|
|
88
92
|
this.active = true;
|
|
93
|
+
this.onEffectEnabled();
|
|
89
94
|
}
|
|
90
95
|
|
|
91
96
|
onDisable(): void {
|
|
92
97
|
super.onDisable();
|
|
98
|
+
if (debug) console.warn("onDisable effect", this)
|
|
93
99
|
this._manager?.removeEffect(this);
|
|
94
100
|
this.active = false;
|
|
95
101
|
}
|
|
@@ -219,12 +219,12 @@ export class PostProcessingHandler {
|
|
|
219
219
|
if (ef instanceof MODULES.POSTPROCESSING.MODULE.Effect)
|
|
220
220
|
effects.push(ef as Effect);
|
|
221
221
|
else if (ef instanceof MODULES.POSTPROCESSING.MODULE.Pass) {
|
|
222
|
-
const pass = new MODULES.POSTPROCESSING.MODULE.EffectPass(cam, ...effects);
|
|
223
|
-
pass.mainScene = scene;
|
|
224
|
-
pass.name = effects.map(e => e.constructor.name).join(", ");
|
|
225
|
-
pass.enabled = true;
|
|
222
|
+
// const pass = new MODULES.POSTPROCESSING.MODULE.EffectPass(cam, ...effects);
|
|
223
|
+
// pass.mainScene = scene;
|
|
224
|
+
// pass.name = effects.map(e => e.constructor.name).join(", ");
|
|
225
|
+
// pass.enabled = true;
|
|
226
226
|
// composer.addPass(pass);
|
|
227
|
-
effects.length = 0;
|
|
227
|
+
// effects.length = 0;
|
|
228
228
|
composer.addPass(ef as Pass);
|
|
229
229
|
}
|
|
230
230
|
else {
|
|
@@ -262,7 +262,7 @@ export class PostProcessingHandler {
|
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
if (debug)
|
|
265
|
-
console.log("PostProcessing Passes
|
|
265
|
+
console.log("[PostProcessing] Passes →", composer.passes);
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
private orderEffects() {
|
|
@@ -62,11 +62,11 @@ export class Volume extends Behaviour implements IEditorModificationReceiver, IP
|
|
|
62
62
|
* Add a post processing effect to the stack and schedules the effect stack to be re-created.
|
|
63
63
|
*/
|
|
64
64
|
addEffect<T extends PostProcessingEffect | Effect>(effect: T): T {
|
|
65
|
-
|
|
66
65
|
let entry = effect as PostProcessingEffect;
|
|
67
66
|
if (!(entry instanceof PostProcessingEffect)) {
|
|
68
67
|
entry = new EffectWrapper(entry);
|
|
69
68
|
}
|
|
69
|
+
if(entry.gameObject === undefined) this.gameObject.addComponent(entry);
|
|
70
70
|
if (this._effects.includes(entry)) return effect;
|
|
71
71
|
this._effects.push(entry);
|
|
72
72
|
this._isDirty = true;
|
|
@@ -125,7 +125,7 @@ export class Volume extends Behaviour implements IEditorModificationReceiver, IP
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
// ensure the profile is initialized
|
|
128
|
-
this.sharedProfile?.
|
|
128
|
+
this.sharedProfile?.__init(this);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
onEnable(): void {
|
|
@@ -190,7 +190,7 @@ export class Volume extends Behaviour implements IEditorModificationReceiver, IP
|
|
|
190
190
|
private _isDirty: boolean = false;
|
|
191
191
|
|
|
192
192
|
private apply() {
|
|
193
|
-
if (debug) console.log(
|
|
193
|
+
if (debug) console.log(`Apply PostProcessing "${this.name}"`);
|
|
194
194
|
|
|
195
195
|
if (isDevEnvironment()) {
|
|
196
196
|
if (this._lastApplyTime !== undefined && Date.now() - this._lastApplyTime < 100) {
|
|
@@ -209,18 +209,16 @@ export class Volume extends Behaviour implements IEditorModificationReceiver, IP
|
|
|
209
209
|
if (this.sharedProfile?.components) {
|
|
210
210
|
const comps = this.sharedProfile.components;
|
|
211
211
|
for (const effect of comps) {
|
|
212
|
-
if (effect.active && !this._activeEffects.includes(effect))
|
|
212
|
+
if (effect.active && effect.enabled && !this._activeEffects.includes(effect))
|
|
213
213
|
this._activeEffects.push(effect);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
// add effects registered via code
|
|
217
217
|
for (const effect of this._effects) {
|
|
218
|
-
if (effect.active && !this._activeEffects.includes(effect))
|
|
218
|
+
if (effect.active && effect.enabled && !this._activeEffects.includes(effect))
|
|
219
219
|
this._activeEffects.push(effect);
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
if (debug) console.log("Apply PostProcessing", this._activeEffects);
|
|
223
|
-
|
|
224
222
|
if (this._activeEffects.length > 0) {
|
|
225
223
|
if (!this._postprocessing)
|
|
226
224
|
this._postprocessing = new PostProcessingHandler(this.context);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { serializeable } from "../../engine/engine_serialization_decorator.js";
|
|
2
2
|
import { getParam } from "../../engine/engine_utils.js";
|
|
3
|
+
import { Component } from "../Component.js";
|
|
3
4
|
import { PostProcessingEffect } from "./PostProcessingEffect.js";
|
|
5
|
+
import type { Volume } from "./Volume.js";
|
|
4
6
|
|
|
5
7
|
const debug = getParam("debugpost");
|
|
6
8
|
|
|
@@ -38,8 +40,14 @@ export class VolumeProfile {
|
|
|
38
40
|
* call init on all components
|
|
39
41
|
* @hidden
|
|
40
42
|
**/
|
|
41
|
-
|
|
42
|
-
this.components?.forEach(c =>
|
|
43
|
+
__init(owner: Component) {
|
|
44
|
+
this.components?.forEach(c => {
|
|
45
|
+
// Make sure all components are added to the gameobject (this is not the case when e.g. effects are serialized from Unity)
|
|
46
|
+
if (c.gameObject === undefined) {
|
|
47
|
+
owner.gameObject.addComponent(c);
|
|
48
|
+
}
|
|
49
|
+
c.init()
|
|
50
|
+
});
|
|
43
51
|
}
|
|
44
52
|
|
|
45
53
|
addEffect(effect: PostProcessingEffect) {
|