@needle-tools/engine 2.65.2-pre → 2.67.0-pre
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 +43 -0
- package/dist/needle-engine.js +34490 -26304
- package/dist/needle-engine.umd.cjs +748 -303
- package/lib/engine/api.d.ts +4 -0
- package/lib/engine/api.js +10 -0
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/codegen/register_types.js +23 -7
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine/debug/debug_overlay.js +11 -2
- package/lib/engine/debug/debug_overlay.js.map +1 -1
- package/lib/engine/engine_addressables.js +4 -4
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_assetdatabase.d.ts +17 -51
- package/lib/engine/engine_assetdatabase.js +252 -126
- package/lib/engine/engine_assetdatabase.js.map +1 -1
- package/lib/engine/engine_components.js +13 -1
- package/lib/engine/engine_components.js.map +1 -1
- package/lib/engine/engine_components_internal.d.ts +8 -0
- package/lib/engine/engine_components_internal.js +29 -0
- package/lib/engine/engine_components_internal.js.map +1 -0
- package/lib/engine/engine_constants.d.ts +1 -0
- package/lib/engine/engine_constants.js +1 -0
- package/lib/engine/engine_constants.js.map +1 -1
- package/lib/engine/engine_context_registry.d.ts +2 -0
- package/lib/engine/engine_context_registry.js +6 -0
- package/lib/engine/engine_context_registry.js.map +1 -1
- package/lib/engine/engine_editor-sync.d.ts +9 -0
- package/lib/engine/engine_editor-sync.js +8 -0
- package/lib/engine/engine_editor-sync.js.map +1 -0
- package/lib/engine/engine_element.d.ts +1 -0
- package/lib/engine/engine_element.js +4 -1
- package/lib/engine/engine_element.js.map +1 -1
- package/lib/engine/engine_element_loading.d.ts +3 -2
- package/lib/engine/engine_element_loading.js +19 -15
- package/lib/engine/engine_element_loading.js.map +1 -1
- package/lib/engine/engine_gameobject.js +21 -23
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_gizmos.js +3 -1
- package/lib/engine/engine_gizmos.js.map +1 -1
- package/lib/engine/engine_gltf_builtin_components.d.ts +2 -3
- package/lib/engine/engine_gltf_builtin_components.js +23 -6
- package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
- package/lib/engine/engine_networking.d.ts +3 -1
- package/lib/engine/engine_networking.js +10 -8
- package/lib/engine/engine_networking.js.map +1 -1
- package/lib/engine/engine_networking_auto.d.ts +1 -0
- package/lib/engine/engine_networking_auto.js +42 -9
- package/lib/engine/engine_networking_auto.js.map +1 -1
- package/lib/engine/engine_patcher.d.ts +8 -0
- package/lib/engine/engine_patcher.js +98 -0
- package/lib/engine/engine_patcher.js.map +1 -0
- package/lib/engine/engine_physics.d.ts +34 -2
- package/lib/engine/engine_physics.js +110 -11
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_scenetools.js +0 -1
- package/lib/engine/engine_scenetools.js.map +1 -1
- package/lib/engine/engine_serialization_core.js +4 -0
- package/lib/engine/engine_serialization_core.js.map +1 -1
- package/lib/engine/engine_setup.d.ts +1 -1
- package/lib/engine/engine_setup.js +12 -5
- package/lib/engine/engine_setup.js.map +1 -1
- package/lib/engine/engine_texture.d.ts +6 -1
- package/lib/engine/engine_texture.js +39 -1
- package/lib/engine/engine_texture.js.map +1 -1
- package/lib/engine/engine_types.d.ts +4 -0
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine/engine_utils.js +3 -2
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_progressive.d.ts +0 -1
- package/lib/engine/extensions/NEEDLE_progressive.js +24 -26
- package/lib/engine/extensions/NEEDLE_progressive.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_render_objects.js +9 -0
- package/lib/engine/extensions/NEEDLE_render_objects.js.map +1 -1
- package/lib/engine/extensions/extensions.d.ts +4 -1
- package/lib/engine/extensions/extensions.js +16 -0
- package/lib/engine/extensions/extensions.js.map +1 -1
- package/lib/engine/extensions/usage_tracker.d.ts +12 -0
- package/lib/engine/extensions/usage_tracker.js +59 -0
- package/lib/engine/extensions/usage_tracker.js.map +1 -0
- package/lib/engine-components/Animator.js +0 -1
- package/lib/engine-components/Animator.js.map +1 -1
- package/lib/engine-components/AnimatorController.js +4 -0
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/AudioSource.js +2 -1
- package/lib/engine-components/AudioSource.js.map +1 -1
- package/lib/engine-components/Camera.d.ts +6 -0
- package/lib/engine-components/Camera.js +70 -31
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/CharacterController.d.ts +1 -0
- package/lib/engine-components/CharacterController.js +14 -9
- package/lib/engine-components/CharacterController.js.map +1 -1
- package/lib/engine-components/Collider.js +14 -1
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/Component.d.ts +52 -0
- package/lib/engine-components/Component.js +55 -14
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/Networking.js +19 -0
- package/lib/engine-components/Networking.js.map +1 -1
- package/lib/engine-components/OrbitControls.d.ts +2 -0
- package/lib/engine-components/OrbitControls.js +9 -0
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/ParticleSystem.d.ts +5 -1
- package/lib/engine-components/ParticleSystem.js +52 -7
- package/lib/engine-components/ParticleSystem.js.map +1 -1
- package/lib/engine-components/ParticleSystemModules.d.ts +2 -0
- package/lib/engine-components/ParticleSystemModules.js +26 -0
- package/lib/engine-components/ParticleSystemModules.js.map +1 -1
- package/lib/engine-components/ParticleSystemSubEmitter.js +5 -2
- package/lib/engine-components/ParticleSystemSubEmitter.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.js +18 -6
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/Renderer.d.ts +1 -1
- package/lib/engine-components/Renderer.js +33 -11
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/ScreenCapture.js +3 -3
- package/lib/engine-components/ScreenCapture.js.map +1 -1
- package/lib/engine-components/Skybox.js +2 -0
- package/lib/engine-components/Skybox.js.map +1 -1
- package/lib/engine-components/SmoothFollow.js +1 -2
- package/lib/engine-components/SmoothFollow.js.map +1 -1
- package/lib/engine-components/SpectatorCamera.js +3 -3
- package/lib/engine-components/SpectatorCamera.js.map +1 -1
- package/lib/engine-components/SyncedCamera.js +1 -1
- package/lib/engine-components/SyncedCamera.js.map +1 -1
- package/lib/engine-components/SyncedTransform.js +2 -2
- package/lib/engine-components/SyncedTransform.js.map +1 -1
- package/lib/engine-components/TestRunner.js +1 -1
- package/lib/engine-components/TestRunner.js.map +1 -1
- package/lib/engine-components/WebARCameraBackground.d.ts +19 -0
- package/lib/engine-components/WebARCameraBackground.js +185 -0
- package/lib/engine-components/WebARCameraBackground.js.map +1 -0
- package/lib/engine-components/WebARSessionRoot.js +3 -2
- package/lib/engine-components/WebARSessionRoot.js.map +1 -1
- package/lib/engine-components/WebXR.d.ts +4 -0
- package/lib/engine-components/WebXR.js +11 -8
- package/lib/engine-components/WebXR.js.map +1 -1
- package/lib/engine-components/WebXRAvatar.js +1 -0
- package/lib/engine-components/WebXRAvatar.js.map +1 -1
- package/lib/engine-components/WebXRGrabRendering.js +2 -2
- package/lib/engine-components/WebXRGrabRendering.js.map +1 -1
- package/lib/engine-components/WebXRSync.js +2 -2
- package/lib/engine-components/WebXRSync.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +14 -6
- package/lib/engine-components/codegen/components.js +14 -6
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/js-extensions/Object3D.js +4 -1
- package/lib/engine-components/js-extensions/Object3D.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Antialiasing.d.ts +13 -0
- package/lib/engine-components/postprocessing/Effects/Antialiasing.js +46 -0
- package/lib/engine-components/postprocessing/Effects/Antialiasing.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/Bloom.d.ts +12 -0
- package/lib/engine-components/postprocessing/Effects/Bloom.js +76 -0
- package/lib/engine-components/postprocessing/Effects/Bloom.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/ChromaticAberration.d.ts +8 -0
- package/lib/engine-components/postprocessing/Effects/ChromaticAberration.js +39 -0
- package/lib/engine-components/postprocessing/Effects/ChromaticAberration.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.d.ts +12 -0
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js +96 -0
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/DepthOfField.d.ts +21 -0
- package/lib/engine-components/postprocessing/Effects/DepthOfField.js +87 -0
- package/lib/engine-components/postprocessing/Effects/DepthOfField.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/Pixelation.d.ts +7 -0
- package/lib/engine-components/postprocessing/Effects/Pixelation.js +30 -0
- package/lib/engine-components/postprocessing/Effects/Pixelation.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.d.ts +11 -0
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.js +70 -0
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/Tonemapping.d.ts +16 -0
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js +52 -0
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/Vignette.d.ts +11 -0
- package/lib/engine-components/postprocessing/Effects/Vignette.js +57 -0
- package/lib/engine-components/postprocessing/Effects/Vignette.js.map +1 -0
- package/lib/engine-components/postprocessing/PostProcessingEffect.d.ts +29 -0
- package/lib/engine-components/postprocessing/PostProcessingEffect.js +89 -0
- package/lib/engine-components/postprocessing/PostProcessingEffect.js.map +1 -0
- package/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +13 -0
- package/lib/engine-components/postprocessing/PostProcessingHandler.js +119 -0
- package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -0
- package/lib/engine-components/postprocessing/Volume.d.ts +23 -0
- package/lib/engine-components/postprocessing/Volume.js +176 -0
- package/lib/engine-components/postprocessing/Volume.js.map +1 -0
- package/lib/engine-components/postprocessing/VolumeParameter.d.ts +21 -0
- package/lib/engine-components/postprocessing/VolumeParameter.js +75 -0
- package/lib/engine-components/postprocessing/VolumeParameter.js.map +1 -0
- package/lib/engine-components/postprocessing/VolumeProfile.d.ts +7 -0
- package/lib/engine-components/postprocessing/VolumeProfile.js +42 -0
- package/lib/engine-components/postprocessing/VolumeProfile.js.map +1 -0
- package/lib/engine-components/timeline/TimelineTracks.js +14 -15
- package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
- package/lib/engine-components/ui/Text.js +28 -170
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/lib/engine-components-experimental/networking/PlayerSync.d.ts +18 -0
- package/lib/engine-components-experimental/networking/PlayerSync.js +62 -8
- package/lib/engine-components-experimental/networking/PlayerSync.js.map +1 -1
- package/lib/include/three/ARButton.d.ts +1 -1
- package/lib/include/three/ARButton.js +11 -19
- package/lib/include/three/ARButton.js.map +1 -1
- package/lib/include/three/VRButton.js +1 -4
- package/lib/include/three/VRButton.js.map +1 -1
- package/package.json +3 -2
- package/plugins/vite/drop-client.js +77 -0
- package/plugins/vite/drop.js +81 -0
- package/plugins/vite/editor-connection.js +121 -0
- package/plugins/vite/index.js +9 -4
- package/plugins/vite/meta.js +3 -0
- package/plugins/vite/poster-client.js +6 -4
- package/src/engine/api.ts +30 -1
- package/src/engine/codegen/register_types.js +25 -9
- package/src/engine/debug/debug_overlay.ts +11 -2
- package/src/engine/engine_addressables.ts +4 -4
- package/src/engine/engine_assetdatabase.ts +291 -184
- package/src/engine/engine_components.ts +20 -1
- package/src/engine/engine_components_internal.ts +30 -0
- package/src/engine/engine_constants.ts +4 -1
- package/src/engine/engine_context_registry.ts +7 -0
- package/src/engine/engine_editor-sync.ts +21 -0
- package/src/engine/engine_element.ts +8 -1
- package/src/engine/engine_element_loading.ts +19 -15
- package/src/engine/engine_gameobject.ts +579 -583
- package/src/engine/engine_gizmos.ts +3 -2
- package/src/engine/engine_gltf_builtin_components.ts +30 -15
- package/src/engine/engine_networking.ts +10 -8
- package/src/engine/engine_networking_auto.ts +48 -11
- package/src/engine/engine_patcher.ts +113 -0
- package/src/engine/engine_physics.ts +128 -12
- package/src/engine/engine_scenetools.ts +0 -1
- package/src/engine/engine_serialization_core.ts +6 -0
- package/src/engine/engine_setup.ts +15 -5
- package/src/engine/engine_texture.ts +54 -5
- package/src/engine/engine_types.ts +6 -1
- package/src/engine/engine_utils.ts +6 -5
- package/src/engine/extensions/NEEDLE_progressive.ts +32 -32
- package/src/engine/extensions/NEEDLE_render_objects.ts +10 -1
- package/src/engine/extensions/extensions.ts +22 -1
- package/src/engine/extensions/usage_tracker.ts +91 -0
- package/src/engine-components/Animator.ts +0 -1
- package/src/engine-components/AnimatorController.ts +2 -0
- package/src/engine-components/AudioSource.ts +1 -1
- package/src/engine-components/Camera.ts +77 -37
- package/src/engine-components/CharacterController.ts +12 -9
- package/src/engine-components/Collider.ts +16 -2
- package/src/engine-components/Component.ts +74 -30
- package/src/engine-components/Networking.ts +9 -1
- package/src/engine-components/OrbitControls.ts +11 -2
- package/src/engine-components/ParticleSystem.ts +54 -10
- package/src/engine-components/ParticleSystemModules.ts +28 -1
- package/src/engine-components/ParticleSystemSubEmitter.ts +5 -3
- package/src/engine-components/ReflectionProbe.ts +17 -7
- package/src/engine-components/Renderer.ts +36 -16
- package/src/engine-components/ScreenCapture.ts +3 -3
- package/src/engine-components/Skybox.ts +2 -0
- package/src/engine-components/SmoothFollow.ts +4 -4
- package/src/engine-components/SpectatorCamera.ts +3 -3
- package/src/engine-components/SyncedCamera.ts +1 -1
- package/src/engine-components/SyncedTransform.ts +2 -2
- package/src/engine-components/TestRunner.ts +1 -1
- package/src/engine-components/WebARCameraBackground.ts +215 -0
- package/src/engine-components/WebARSessionRoot.ts +3 -2
- package/src/engine-components/WebXR.ts +12 -8
- package/src/engine-components/WebXRAvatar.ts +1 -1
- package/src/engine-components/WebXRGrabRendering.ts +2 -2
- package/src/engine-components/WebXRSync.ts +2 -2
- package/src/engine-components/codegen/components.ts +14 -6
- package/src/engine-components/js-extensions/Object3D.ts +6 -1
- package/src/engine-components/postprocessing/Effects/Antialiasing.ts +52 -0
- package/src/engine-components/postprocessing/Effects/Bloom.ts +75 -0
- package/src/engine-components/postprocessing/Effects/ChromaticAberration.ts +36 -0
- package/src/engine-components/postprocessing/Effects/ColorAdjustments.ts +114 -0
- package/src/engine-components/postprocessing/Effects/DepthOfField.ts +90 -0
- package/src/engine-components/postprocessing/Effects/Pixelation.ts +28 -0
- package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.ts +71 -0
- package/src/engine-components/postprocessing/Effects/Tonemapping.ts +55 -0
- package/src/engine-components/postprocessing/Effects/Vignette.ts +55 -0
- package/src/engine-components/postprocessing/PostProcessingEffect.ts +112 -0
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +148 -0
- package/src/engine-components/postprocessing/Volume.ts +194 -0
- package/src/engine-components/postprocessing/VolumeParameter.ts +85 -0
- package/src/engine-components/postprocessing/VolumeProfile.ts +40 -0
- package/src/engine-components/timeline/TimelineTracks.ts +16 -17
- package/src/engine-components/ui/Text.ts +37 -174
- package/src/engine-components-experimental/networking/PlayerSync.ts +69 -8
- package/src/include/three/ARButton.js +13 -24
- package/src/include/three/VRButton.js +1 -7
- package/lib/engine-components/Volume.d.ts +0 -34
- package/lib/engine-components/Volume.js +0 -140
- package/lib/engine-components/Volume.js.map +0 -1
- package/src/engine-components/Volume.ts +0 -141
|
@@ -3,7 +3,7 @@ import { Object3D } from "three";
|
|
|
3
3
|
import { Constructor, ConstructorConcrete, IComponent } from "../../engine/engine_types"
|
|
4
4
|
import { IComponent as Component } from "../../engine/engine_types";
|
|
5
5
|
import { addNewComponent, getComponent, getComponentInChildren, getComponentInParent, getComponents, getComponentsInChildren, getComponentsInParent, getOrAddComponent, removeComponent } from "../../engine/engine_components";
|
|
6
|
-
import { isActiveSelf, setActive } from "../../engine/engine_gameobject";
|
|
6
|
+
import { isActiveSelf, setActive, destroy } from "../../engine/engine_gameobject";
|
|
7
7
|
|
|
8
8
|
// used to decorate cloned object3D objects with the same added components defined above
|
|
9
9
|
export function apply(object: Object3D) {
|
|
@@ -20,6 +20,10 @@ Object3D.prototype["setActive"] = function (active: boolean) {
|
|
|
20
20
|
this.visible = active;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
Object3D.prototype["destroy"] = function () {
|
|
24
|
+
destroy(this);
|
|
25
|
+
}
|
|
26
|
+
|
|
23
27
|
Object3D.prototype["addNewComponent"] = function <T extends Component>(type: ConstructorConcrete<T>) {
|
|
24
28
|
return addNewComponent(this, new type());
|
|
25
29
|
}
|
|
@@ -78,5 +82,6 @@ if (!Object.getOwnPropertyDescriptor(Object3D.prototype, "transform")) {
|
|
|
78
82
|
|
|
79
83
|
|
|
80
84
|
|
|
85
|
+
|
|
81
86
|
// do this after adding the component extensions
|
|
82
87
|
registerPrototypeExtensions(Object3D);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { EdgeDetectionMode, SMAAEffect, SMAAPreset } from "postprocessing";
|
|
2
|
+
import { serializable } from "../../../engine/engine_serialization";
|
|
3
|
+
import { EffectProviderResult, PostProcessingEffect } from "../PostProcessingEffect";
|
|
4
|
+
import { VolumeParameter } from "../VolumeParameter";
|
|
5
|
+
import { registerCustomEffectType } from "../VolumeProfile";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export enum QualityLevel {
|
|
10
|
+
LOW = 0,
|
|
11
|
+
MEDIUM = 1,
|
|
12
|
+
HIGH = 2,
|
|
13
|
+
ULTRA = 3
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export class Antialiasing extends PostProcessingEffect {
|
|
18
|
+
get typeName(): string {
|
|
19
|
+
return "Antialiasing";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// @serializable(VolumeParameter)
|
|
23
|
+
// edgeDetectionThreshold!: VolumeParameter;
|
|
24
|
+
|
|
25
|
+
@serializable(VolumeParameter)
|
|
26
|
+
preset!: VolumeParameter;
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
onCreateEffect(): EffectProviderResult {
|
|
30
|
+
const effect = new SMAAEffect({
|
|
31
|
+
preset: SMAAPreset.HIGH,
|
|
32
|
+
edgeDetectionMode: EdgeDetectionMode.DEPTH
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
this.preset.onValueChanged = (newValue) => {
|
|
36
|
+
effect.applyPreset(newValue);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// effect.edgeDetectionMaterial.edgeDetectionThreshold = .01;
|
|
40
|
+
|
|
41
|
+
// this.edgeDetectionThreshold.onValueChanged = (newValue) => {
|
|
42
|
+
// console.log(newValue);
|
|
43
|
+
// effect.edgeDetectionMaterial.edgeDetectionThreshold = newValue;
|
|
44
|
+
// }
|
|
45
|
+
|
|
46
|
+
return effect;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
registerCustomEffectType("Antialiasing", Antialiasing)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { BloomEffect, SelectiveBloomEffect } from "postprocessing";
|
|
2
|
+
import { serializable } from "../../../engine/engine_serialization";
|
|
3
|
+
import { PostProcessingEffect } from "../PostProcessingEffect";
|
|
4
|
+
import { VolumeParameter } from "../VolumeParameter";
|
|
5
|
+
import { registerCustomEffectType } from "../VolumeProfile";
|
|
6
|
+
|
|
7
|
+
export class Bloom extends PostProcessingEffect {
|
|
8
|
+
|
|
9
|
+
get typeName() {
|
|
10
|
+
return "Bloom";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@serializable(VolumeParameter)
|
|
14
|
+
threshold!: VolumeParameter;
|
|
15
|
+
@serializable(VolumeParameter)
|
|
16
|
+
intensity!: VolumeParameter;
|
|
17
|
+
@serializable(VolumeParameter)
|
|
18
|
+
scatter!: VolumeParameter;
|
|
19
|
+
|
|
20
|
+
selectiveBloom = true;
|
|
21
|
+
|
|
22
|
+
init() {
|
|
23
|
+
this.threshold.defaultValue = 1;
|
|
24
|
+
this.intensity.defaultValue = 0;
|
|
25
|
+
this.scatter.defaultValue = .2;
|
|
26
|
+
|
|
27
|
+
if (this.selectiveBloom) {
|
|
28
|
+
this.threshold.valueProcessor = (v: number) => v * .5;// / (Math.PI * 2);
|
|
29
|
+
this.intensity.valueProcessor = (v: number) => v * Math.PI * 2;
|
|
30
|
+
this.scatter.valueProcessor = (v: number) => .2 + Math.pow((1 - v), 2);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
this.threshold.valueProcessor = (v: number) => v / (Math.PI * 2);
|
|
34
|
+
this.intensity.valueProcessor = (v: number) => v;// * 2.2;
|
|
35
|
+
this.scatter.valueProcessor = (v: number) => (1 - v);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
onCreateEffect() {
|
|
40
|
+
let bloom: BloomEffect;
|
|
41
|
+
if (this.selectiveBloom) {
|
|
42
|
+
// https://github.com/pmndrs/postprocessing/blob/64d2829f014cfec97a46bf3c109f3abc55af0715/demo/src/demos/BloomDemo.js#L265
|
|
43
|
+
const selectiveBloom = bloom = new SelectiveBloomEffect(this.context.scene, this.context.mainCamera!, {
|
|
44
|
+
luminanceThreshold: this.threshold.value,
|
|
45
|
+
luminanceSmoothing: this.scatter.value,
|
|
46
|
+
intensity: this.intensity.value,
|
|
47
|
+
mipmapBlur: false,
|
|
48
|
+
});
|
|
49
|
+
selectiveBloom.inverted = true;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
bloom = new BloomEffect();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
const blur = bloom["mipmapBlurPass"];
|
|
57
|
+
if (typeof blur === "object") {
|
|
58
|
+
blur.radius = this.scatter.value;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
this.intensity.onValueChanged = newValue => {
|
|
62
|
+
bloom!.intensity = newValue;
|
|
63
|
+
};
|
|
64
|
+
this.threshold.onValueChanged = newValue => {
|
|
65
|
+
bloom!.luminanceMaterial.threshold = newValue;
|
|
66
|
+
};
|
|
67
|
+
this.scatter.onValueChanged = newValue => {
|
|
68
|
+
bloom!.luminanceMaterial.smoothing = newValue;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return bloom;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
registerCustomEffectType("Bloom", Bloom);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ChromaticAberrationEffect } from "postprocessing";
|
|
2
|
+
import { Vector2 } from "three";
|
|
3
|
+
import { serializable } from "../../../engine/engine_serialization";
|
|
4
|
+
import { EffectProviderResult, PostProcessingEffect } from "../PostProcessingEffect";
|
|
5
|
+
import { VolumeParameter } from "../VolumeParameter";
|
|
6
|
+
import { registerCustomEffectType, VolumeProfile } from "../VolumeProfile";
|
|
7
|
+
|
|
8
|
+
export class ChromaticAberration extends PostProcessingEffect {
|
|
9
|
+
|
|
10
|
+
get typeName() {
|
|
11
|
+
return "ChromaticAberration";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@serializable(VolumeParameter)
|
|
15
|
+
intensity!: VolumeParameter;
|
|
16
|
+
|
|
17
|
+
init() {
|
|
18
|
+
this.intensity.defaultValue = 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
onCreateEffect(): EffectProviderResult {
|
|
22
|
+
const chromatic = new ChromaticAberrationEffect();
|
|
23
|
+
chromatic.offset = new Vector2(0, 0)
|
|
24
|
+
chromatic.radialModulation = true;
|
|
25
|
+
chromatic.modulationOffset = .15;
|
|
26
|
+
this.intensity.valueProcessor = v => v * .02;
|
|
27
|
+
this.intensity.onValueChanged = v => {
|
|
28
|
+
chromatic.offset.x = -v;
|
|
29
|
+
chromatic.offset.y = v;
|
|
30
|
+
}
|
|
31
|
+
return chromatic;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
registerCustomEffectType("ChromaticAberration", ChromaticAberration);
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { BrightnessContrastEffect, HueSaturationEffect } from "postprocessing";
|
|
2
|
+
import { serializable } from "../../../engine/engine_serialization";
|
|
3
|
+
import { EffectProviderResult, PostProcessingEffect } from "../PostProcessingEffect";
|
|
4
|
+
import { VolumeParameter } from "../VolumeParameter";
|
|
5
|
+
import { registerCustomEffectType } from "../VolumeProfile";
|
|
6
|
+
import { NoToneMapping } from "three";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export class ColorAdjustments extends PostProcessingEffect {
|
|
10
|
+
|
|
11
|
+
get typeName() {
|
|
12
|
+
return "ColorAdjustments";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@serializable(VolumeParameter)
|
|
16
|
+
postExposure!: VolumeParameter;
|
|
17
|
+
|
|
18
|
+
@serializable(VolumeParameter)
|
|
19
|
+
contrast!: VolumeParameter;
|
|
20
|
+
|
|
21
|
+
@serializable(VolumeParameter)
|
|
22
|
+
hueShift!: VolumeParameter;
|
|
23
|
+
|
|
24
|
+
@serializable(VolumeParameter)
|
|
25
|
+
saturation!: VolumeParameter;
|
|
26
|
+
|
|
27
|
+
init() {
|
|
28
|
+
this.postExposure!.valueProcessor = v => {
|
|
29
|
+
// when using tone mapping, the exposure will just be set to the renderer
|
|
30
|
+
if (this.context.renderer.toneMapping !== NoToneMapping && v > 0) {
|
|
31
|
+
return Math.pow(2, v);
|
|
32
|
+
}
|
|
33
|
+
// Custom effects need modification
|
|
34
|
+
else {
|
|
35
|
+
return v / (2 * Math.PI);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
this.postExposure.defaultValue = 0;
|
|
39
|
+
|
|
40
|
+
this.contrast.valueProcessor = (v: number) => {
|
|
41
|
+
let divisor = 100;
|
|
42
|
+
if (v > 0) divisor *= Math.PI * 2;
|
|
43
|
+
const val = v / divisor;
|
|
44
|
+
return val;
|
|
45
|
+
};
|
|
46
|
+
this.contrast.defaultValue = 0;
|
|
47
|
+
|
|
48
|
+
this.hueShift.valueProcessor = (v: number) => Math.PI * v / 180;
|
|
49
|
+
this.hueShift.defaultValue = 0;
|
|
50
|
+
|
|
51
|
+
this.saturation.valueProcessor = (v: number) => {
|
|
52
|
+
return (v / 180);
|
|
53
|
+
}
|
|
54
|
+
this.saturation.defaultValue = 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
unapply() {
|
|
58
|
+
this.context.renderer.toneMappingExposure = 1;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
onCreateEffect(): EffectProviderResult {
|
|
63
|
+
|
|
64
|
+
const brightnesscontrast = new BrightnessContrastEffect();
|
|
65
|
+
// TODO: darkening etc doesnt really work well in all cases right now
|
|
66
|
+
this.postExposure!.onValueChanged = v => {
|
|
67
|
+
// We can use the builtin exposure when tonemapping is set
|
|
68
|
+
if (this.context.renderer.toneMapping !== NoToneMapping) {
|
|
69
|
+
if (v === 0) {
|
|
70
|
+
this.context.renderer.toneMappingExposure = 1;
|
|
71
|
+
brightnesscontrast.brightness = 0;
|
|
72
|
+
}
|
|
73
|
+
else if (v > 0) {
|
|
74
|
+
this.context.renderer.toneMappingExposure = v;
|
|
75
|
+
brightnesscontrast.brightness = 0;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
this.context.renderer.toneMappingExposure = v;
|
|
79
|
+
brightnesscontrast.brightness = 0;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Otherwise use the effect (they look sligthly different/behave different unfortunately)
|
|
83
|
+
else {
|
|
84
|
+
this.context.renderer.toneMappingExposure = 0;
|
|
85
|
+
brightnesscontrast.brightness = v;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
this.contrast!.onValueChanged = v => brightnesscontrast.contrast = v;
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
const hueSaturationEffect = new HueSaturationEffect();
|
|
92
|
+
this.hueShift!.onValueChanged = v => hueSaturationEffect.hue = v;
|
|
93
|
+
this.saturation!.onValueChanged = v => hueSaturationEffect.saturation = v;
|
|
94
|
+
|
|
95
|
+
return [brightnesscontrast, hueSaturationEffect];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// apply() {
|
|
99
|
+
// this.postExposure!.onValueChanged = () => {
|
|
100
|
+
// this.setExposure();
|
|
101
|
+
// };
|
|
102
|
+
|
|
103
|
+
// // unity range goes from -15..15
|
|
104
|
+
// // three.js range goes from 0..inf
|
|
105
|
+
// if (this.postExposure?.overrideState) {
|
|
106
|
+
// this.setExposure();
|
|
107
|
+
// }
|
|
108
|
+
// }
|
|
109
|
+
// private setExposure() {
|
|
110
|
+
// const exposure = Math.pow(2, this.postExposure?.value ?? 0);
|
|
111
|
+
// this.context.renderer.toneMappingExposure = exposure;
|
|
112
|
+
// }
|
|
113
|
+
}
|
|
114
|
+
registerCustomEffectType("ColorAdjustments", ColorAdjustments);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { DepthOfFieldEffect } from "postprocessing";
|
|
2
|
+
import { PerspectiveCamera, Vector3 } from "three";
|
|
3
|
+
import { getWorldPosition } from "../../../engine/engine_three_utils";
|
|
4
|
+
import { serializable } from "../../../engine/engine_serialization";
|
|
5
|
+
import { Mathf } from "../../../engine/engine_math";
|
|
6
|
+
import { PostProcessingEffect } from "../PostProcessingEffect";
|
|
7
|
+
import { VolumeParameter } from "../VolumeParameter";
|
|
8
|
+
import { registerCustomEffectType } from "../VolumeProfile";
|
|
9
|
+
|
|
10
|
+
export enum DepthOfFieldMode {
|
|
11
|
+
Off = 0,
|
|
12
|
+
Gaussian = 1,
|
|
13
|
+
Bokeh = 2,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class DepthOfField extends PostProcessingEffect {
|
|
17
|
+
|
|
18
|
+
get typeName() {
|
|
19
|
+
return "DepthOfField";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@serializable()
|
|
23
|
+
mode! : DepthOfFieldMode;
|
|
24
|
+
|
|
25
|
+
@serializable(VolumeParameter)
|
|
26
|
+
focusDistance!: VolumeParameter;
|
|
27
|
+
|
|
28
|
+
@serializable(VolumeParameter)
|
|
29
|
+
focalLength!: VolumeParameter;
|
|
30
|
+
|
|
31
|
+
@serializable(VolumeParameter)
|
|
32
|
+
aperture!: VolumeParameter;
|
|
33
|
+
|
|
34
|
+
@serializable(VolumeParameter)
|
|
35
|
+
gaussianMaxRadius!: VolumeParameter;
|
|
36
|
+
|
|
37
|
+
init() {
|
|
38
|
+
this.focalLength.valueProcessor = v => {
|
|
39
|
+
const t = v / 300;
|
|
40
|
+
const max = 2;// this.context.mainCameraComponent?.farClipPlane ?? 10;
|
|
41
|
+
return Mathf.lerp(max, .01, t);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const maxBokehScale = 20;
|
|
45
|
+
this.aperture.valueProcessor = v => {
|
|
46
|
+
const t = 1 - v / 32;
|
|
47
|
+
return Mathf.lerp(1, maxBokehScale, t);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
onCreateEffect() {
|
|
52
|
+
if(this.mode === DepthOfFieldMode.Off) return undefined;
|
|
53
|
+
// console.log(this.focusDistance.overrideState, this.focusDistance.value);
|
|
54
|
+
// const depth = new DepthEffect({
|
|
55
|
+
// inverted: true,
|
|
56
|
+
// // blendFunction: BlendFunction.SET,
|
|
57
|
+
// });
|
|
58
|
+
const dof = new DepthOfFieldEffect(this.context.mainCamera!, {
|
|
59
|
+
worldFocusRange: .2,
|
|
60
|
+
focalLength: 1,
|
|
61
|
+
bokehScale: 20,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
this.focusDistance.onValueChanged = v => dof.circleOfConfusionMaterial.worldFocusDistance = v;
|
|
65
|
+
this.focalLength.onValueChanged = v => dof.circleOfConfusionMaterial.worldFocusRange = v;
|
|
66
|
+
this.aperture.onValueChanged = v => dof.bokehScale = v;
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
return [dof];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
unapply() {
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
calculateFocusDistance(target) {
|
|
78
|
+
|
|
79
|
+
const camera = this.context.mainCamera! as PerspectiveCamera;
|
|
80
|
+
const distance = getWorldPosition(camera).distanceTo(target);
|
|
81
|
+
// console.log(distance, camera.near, camera.far);
|
|
82
|
+
return this.viewZToOrthographicDepth(-distance, camera.near, camera.far);
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
viewZToOrthographicDepth(viewZ, near, far) {
|
|
87
|
+
return (viewZ + near) / (near - far);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
registerCustomEffectType("DepthOfField", DepthOfField);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { registerCustomEffectType } from "../VolumeProfile";
|
|
2
|
+
import { EffectProviderResult, PostProcessingEffect } from "../PostProcessingEffect";
|
|
3
|
+
import { PixelationEffect as PixelationEffectPP } from "postprocessing";
|
|
4
|
+
import { VolumeParameter } from "../VolumeParameter";
|
|
5
|
+
import { serializable } from "../../../engine/engine_serialization";
|
|
6
|
+
|
|
7
|
+
export class PixelationEffect extends PostProcessingEffect {
|
|
8
|
+
get typeName(): string {
|
|
9
|
+
return "PixelationEffect";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@serializable(VolumeParameter)
|
|
13
|
+
granularity!: VolumeParameter;
|
|
14
|
+
|
|
15
|
+
onCreateEffect(): EffectProviderResult {
|
|
16
|
+
|
|
17
|
+
const effect = new PixelationEffectPP();
|
|
18
|
+
|
|
19
|
+
this.granularity.onValueChanged = v => {
|
|
20
|
+
console.log(v);
|
|
21
|
+
effect.granularity = v;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return effect;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
registerCustomEffectType("PixelationEffect", PixelationEffect);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { BlendFunction, DepthDownsamplingPass, Effect, NormalPass, SSAOEffect } from "postprocessing";
|
|
2
|
+
import { NeverDepth, PerspectiveCamera } from "three";
|
|
3
|
+
import { serializable } from "../../../engine/engine_serialization";
|
|
4
|
+
import { EffectProviderResult, PostProcessingEffect } from "../PostProcessingEffect";
|
|
5
|
+
import { VolumeParameter } from "../VolumeParameter";
|
|
6
|
+
import { registerCustomEffectType } from "../VolumeProfile";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export class ScreenSpaceAmbientOcclusion extends PostProcessingEffect {
|
|
10
|
+
|
|
11
|
+
get typeName() {
|
|
12
|
+
return "ScreenSpaceAmbientOcclusion";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@serializable(VolumeParameter)
|
|
16
|
+
intensity!: VolumeParameter;
|
|
17
|
+
|
|
18
|
+
@serializable(VolumeParameter)
|
|
19
|
+
falloff!: VolumeParameter;
|
|
20
|
+
|
|
21
|
+
@serializable(VolumeParameter)
|
|
22
|
+
samples!: VolumeParameter;
|
|
23
|
+
|
|
24
|
+
onBeforeRender() {
|
|
25
|
+
if (this._ssao && this.context.mainCamera instanceof PerspectiveCamera) {
|
|
26
|
+
const fadeDistance = this.context.mainCamera.far - this.context.mainCamera.near;
|
|
27
|
+
this._ssao.ssaoMaterial.worldDistanceFalloff = fadeDistance * .01;
|
|
28
|
+
this._ssao.ssaoMaterial.worldDistanceThreshold = this.context.mainCamera.far;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private _ssao?: SSAOEffect;
|
|
33
|
+
|
|
34
|
+
onCreateEffect(): EffectProviderResult {
|
|
35
|
+
|
|
36
|
+
const cam = this.context.mainCamera! as PerspectiveCamera;
|
|
37
|
+
const normalPass = new NormalPass(this.context.scene, cam);
|
|
38
|
+
const depthDownsamplingPass = new DepthDownsamplingPass({
|
|
39
|
+
normalBuffer: normalPass.texture,
|
|
40
|
+
resolutionScale: 0.5
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const ssao = this._ssao = new SSAOEffect(cam!, normalPass.texture, {
|
|
44
|
+
normalDepthBuffer: depthDownsamplingPass.texture,
|
|
45
|
+
worldDistanceThreshold: 1, // when it starts to fade out
|
|
46
|
+
worldDistanceFalloff: 1, // smoothness of cutoff
|
|
47
|
+
worldProximityThreshold: .1,
|
|
48
|
+
worldProximityFalloff: 2,
|
|
49
|
+
intensity: 1,
|
|
50
|
+
// blendFunction: BlendFunction.MULTIPLY,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
this.intensity.onValueChanged = newValue => {
|
|
54
|
+
ssao.intensity = newValue;
|
|
55
|
+
}
|
|
56
|
+
this.falloff.onValueChanged = newValue => {
|
|
57
|
+
ssao.ssaoMaterial.radius = newValue * .1;
|
|
58
|
+
}
|
|
59
|
+
this.samples.onValueChanged = newValue => {
|
|
60
|
+
ssao.samples = newValue;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const arr = new Array();
|
|
64
|
+
arr.push(normalPass);
|
|
65
|
+
arr.push(depthDownsamplingPass);
|
|
66
|
+
arr.push(ssao);
|
|
67
|
+
return arr;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
registerCustomEffectType("ScreenSpaceAmbientOcclusion", ScreenSpaceAmbientOcclusion);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ACESFilmicToneMapping, LinearToneMapping, NoToneMapping, ReinhardToneMapping } from "three";
|
|
2
|
+
import { serializable } from "../../../engine/engine_serialization";
|
|
3
|
+
import { EffectProviderResult, PostProcessingEffect } from "../PostProcessingEffect";
|
|
4
|
+
import { VolumeParameter } from "../VolumeParameter";
|
|
5
|
+
import { registerCustomEffectType } from "../VolumeProfile";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export enum TonemappingMode {
|
|
9
|
+
None = 0,
|
|
10
|
+
Neutral = 1, // Neutral tonemapper
|
|
11
|
+
ACES = 2, // ACES Filmic reference tonemapper (custom approximation)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class ToneMapping extends PostProcessingEffect {
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
get typeName() {
|
|
18
|
+
return "ToneMapping";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@serializable(VolumeParameter)
|
|
22
|
+
mode!: VolumeParameter;
|
|
23
|
+
|
|
24
|
+
get isToneMapping() { return true; }
|
|
25
|
+
|
|
26
|
+
init(): void {
|
|
27
|
+
this.mode.defaultValue = NoToneMapping;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
apply() {
|
|
31
|
+
this.mode!.onValueChanged = this._apply.bind(this);
|
|
32
|
+
this._apply(this.mode!.value)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
unapply() {
|
|
36
|
+
this.context.renderer.toneMapping = NoToneMapping;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private _apply(v) {
|
|
40
|
+
switch (v) {
|
|
41
|
+
case TonemappingMode.None:
|
|
42
|
+
this.context.renderer.toneMapping = LinearToneMapping;
|
|
43
|
+
break;
|
|
44
|
+
case TonemappingMode.Neutral:
|
|
45
|
+
this.context.renderer.toneMapping = ReinhardToneMapping;
|
|
46
|
+
break;
|
|
47
|
+
case TonemappingMode.ACES:
|
|
48
|
+
this.context.renderer.toneMapping = ACESFilmicToneMapping;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
registerCustomEffectType("Tonemapping", ToneMapping);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { serializable } from "../../../engine/engine_serialization";
|
|
2
|
+
import { VolumeParameter } from "../VolumeParameter";
|
|
3
|
+
import { EffectProviderResult, PostProcessingEffect } from "../PostProcessingEffect";
|
|
4
|
+
import { registerCustomEffectType } from "../VolumeProfile";
|
|
5
|
+
import { VignetteEffect } from "postprocessing";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export class Vignette extends PostProcessingEffect {
|
|
9
|
+
get typeName(): string {
|
|
10
|
+
return "Vignette";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@serializable(VolumeParameter)
|
|
14
|
+
color!: VolumeParameter;
|
|
15
|
+
|
|
16
|
+
@serializable(VolumeParameter)
|
|
17
|
+
intensity!: VolumeParameter;
|
|
18
|
+
|
|
19
|
+
@serializable(VolumeParameter)
|
|
20
|
+
center!: VolumeParameter;
|
|
21
|
+
|
|
22
|
+
init(){
|
|
23
|
+
this.color.defaultValue = { r: 0, g: 0, b: 0, a: 1 };
|
|
24
|
+
this.intensity.defaultValue = 0;
|
|
25
|
+
this.center.defaultValue = { x: 0.5, y: 0.5 };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
onCreateEffect(): EffectProviderResult {
|
|
29
|
+
// https://github.com/pmndrs/postprocessing/blob/f8ed90635ee6710744cc0f38811fc00ce873a450/src/effects/VignetteEffect.js
|
|
30
|
+
const vignette = new VignetteEffect();
|
|
31
|
+
|
|
32
|
+
this.intensity.onValueChanged = v => {
|
|
33
|
+
vignette.offset = v;
|
|
34
|
+
this.updateDarkness(vignette);
|
|
35
|
+
}
|
|
36
|
+
this.color.onValueChanged = _ => {
|
|
37
|
+
this.updateDarkness(vignette);
|
|
38
|
+
};
|
|
39
|
+
// this.center.onValueChanged = v => {
|
|
40
|
+
// console.log(v);
|
|
41
|
+
// vignette.offset = v.x;
|
|
42
|
+
// };
|
|
43
|
+
|
|
44
|
+
return vignette;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private updateDarkness(effect: VignetteEffect) {
|
|
48
|
+
// const col = this.color.value;
|
|
49
|
+
// const colval = 1 - (col.r + col.g + col.b + col.a) / 4;
|
|
50
|
+
const val = this.intensity.value;
|
|
51
|
+
effect.darkness = val;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
registerCustomEffectType("Vignette", Vignette);
|