babylonjs-editor-tools 0.0.8 → 0.0.9
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/build/index.node.js +1318 -0
- package/build/src/cinematic/events/apply-impulse.js +12 -0
- package/build/src/cinematic/events/set-enabled.js +5 -0
- package/build/src/cinematic/generate.js +134 -0
- package/build/src/cinematic/parse.js +99 -0
- package/build/src/cinematic/tools.js +66 -0
- package/build/src/cinematic/typings.js +2 -0
- package/build/src/decorators/apply.js +71 -0
- package/build/{decorators → src/decorators}/gui.js +1 -5
- package/build/src/decorators/inspector.js +131 -0
- package/build/src/decorators/particle-systems.js +15 -0
- package/build/{decorators → src/decorators}/scene.js +16 -7
- package/build/{decorators → src/decorators}/sound.js +1 -5
- package/build/src/index.js +17 -0
- package/build/src/loading/loader.js +55 -0
- package/build/src/loading/physics.js +28 -0
- package/build/src/loading/rendering.js +30 -0
- package/build/src/loading/script.js +35 -0
- package/build/src/loading/sound.js +14 -0
- package/build/{texture.js → src/loading/texture.js} +9 -11
- package/build/{rendering → src/rendering}/default-pipeline.js +40 -15
- package/build/src/rendering/motion-blur.js +42 -0
- package/build/{rendering → src/rendering}/ssao.js +11 -15
- package/build/{rendering → src/rendering}/ssr.js +11 -15
- package/build/src/rendering/tools.js +51 -0
- package/build/src/rendering/vls.js +57 -0
- package/build/src/script.js +2 -0
- package/build/{guards.js → src/tools/guards.js} +3 -9
- package/build/src/tools/light.js +25 -0
- package/build/src/tools/scalar.js +8 -0
- package/build/src/tools/sound.js +19 -0
- package/build/src/tools/texture.js +16 -0
- package/package.json +24 -6
- package/build/decorators/apply.js +0 -42
- package/build/decorators/apply.js.map +0 -1
- package/build/decorators/gui.js.map +0 -1
- package/build/decorators/scene.js.map +0 -1
- package/build/decorators/sound.js.map +0 -1
- package/build/guards.js.map +0 -1
- package/build/index.js +0 -26
- package/build/index.js.map +0 -1
- package/build/light.js +0 -30
- package/build/light.js.map +0 -1
- package/build/loader.js +0 -87
- package/build/loader.js.map +0 -1
- package/build/physics.js +0 -33
- package/build/physics.js.map +0 -1
- package/build/rendering/default-pipeline.js.map +0 -1
- package/build/rendering/motion-blur.js +0 -46
- package/build/rendering/motion-blur.js.map +0 -1
- package/build/rendering/ssao.js.map +0 -1
- package/build/rendering/ssr.js.map +0 -1
- package/build/script.js +0 -3
- package/build/script.js.map +0 -1
- package/build/texture.js.map +0 -1
- package/build/tools/scalar.js +0 -12
- package/build/tools/scalar.js.map +0 -1
- package/declaration/decorators/apply.d.ts +0 -23
- package/declaration/decorators/gui.d.ts +0 -12
- package/declaration/decorators/scene.d.ts +0 -17
- package/declaration/decorators/sound.d.ts +0 -8
- package/declaration/guards.d.ts +0 -18
- package/declaration/index.d.ts +0 -9
- package/declaration/light.d.ts +0 -3
- package/declaration/loader.d.ts +0 -31
- package/declaration/physics.d.ts +0 -6
- package/declaration/rendering/default-pipeline.d.ts +0 -11
- package/declaration/rendering/motion-blur.d.ts +0 -8
- package/declaration/rendering/ssao.d.ts +0 -8
- package/declaration/rendering/ssr.d.ts +0 -8
- package/declaration/script.d.ts +0 -13
- package/declaration/texture.d.ts +0 -1
- package/declaration/tools/scalar.d.ts +0 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { AppendSceneAsync } from "@babylonjs/core/Loading/sceneLoader";
|
|
2
|
+
import { SceneLoaderFlags } from "@babylonjs/core/Loading/sceneLoaderFlags";
|
|
3
|
+
import { isMesh } from "../tools/guards";
|
|
4
|
+
import { applyScriptForObject } from "./script";
|
|
5
|
+
import { configurePhysicsAggregate } from "./physics";
|
|
6
|
+
import { applyRenderingConfigurations } from "./rendering";
|
|
7
|
+
import { applyRenderingConfigurationForCamera } from "../rendering/tools";
|
|
8
|
+
import { configureShadowMapRefreshRate, configureShadowMapRenderListPredicate } from "../tools/light";
|
|
9
|
+
import "./sound";
|
|
10
|
+
import "./texture";
|
|
11
|
+
export async function loadScene(rootUrl, sceneFilename, scene, scriptsMap, options) {
|
|
12
|
+
scene.loadingQuality = options?.quality ?? "high";
|
|
13
|
+
await AppendSceneAsync(`${rootUrl}${sceneFilename}`, scene, {
|
|
14
|
+
pluginExtension: ".babylon",
|
|
15
|
+
onProgress: (event) => {
|
|
16
|
+
const progress = Math.min((event.loaded / event.total) * 0.5);
|
|
17
|
+
options?.onProgress?.(progress);
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
// Ensure all meshes perform their delay state check
|
|
21
|
+
if (SceneLoaderFlags.ForceFullSceneLoadingForIncremental) {
|
|
22
|
+
scene.meshes.forEach((m) => isMesh(m) && m._checkDelayState());
|
|
23
|
+
}
|
|
24
|
+
const waitingItemsCount = scene.getWaitingItemsCount();
|
|
25
|
+
// Wait until scene is ready.
|
|
26
|
+
while (!scene.isReady() || scene.getWaitingItemsCount() > 0) {
|
|
27
|
+
await new Promise((resolve) => setTimeout(resolve, 150));
|
|
28
|
+
const loadedItemsCount = waitingItemsCount - scene.getWaitingItemsCount();
|
|
29
|
+
options?.onProgress?.(0.5 + (loadedItemsCount / waitingItemsCount) * 0.5);
|
|
30
|
+
}
|
|
31
|
+
options?.onProgress?.(1);
|
|
32
|
+
configureShadowMapRenderListPredicate(scene);
|
|
33
|
+
configureShadowMapRefreshRate(scene);
|
|
34
|
+
if (scene.metadata?.rendering) {
|
|
35
|
+
applyRenderingConfigurations(scene, scene.metadata.rendering);
|
|
36
|
+
if (scene.activeCamera) {
|
|
37
|
+
applyRenderingConfigurationForCamera(scene.activeCamera);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
applyScriptForObject(scene, scene, scriptsMap, rootUrl);
|
|
41
|
+
scene.transformNodes.forEach((transformNode) => {
|
|
42
|
+
applyScriptForObject(scene, transformNode, scriptsMap, rootUrl);
|
|
43
|
+
});
|
|
44
|
+
scene.meshes.forEach((mesh) => {
|
|
45
|
+
configurePhysicsAggregate(mesh);
|
|
46
|
+
applyScriptForObject(scene, mesh, scriptsMap, rootUrl);
|
|
47
|
+
});
|
|
48
|
+
scene.lights.forEach((light) => {
|
|
49
|
+
applyScriptForObject(scene, light, scriptsMap, rootUrl);
|
|
50
|
+
});
|
|
51
|
+
scene.cameras.forEach((camera) => {
|
|
52
|
+
applyScriptForObject(scene, camera, scriptsMap, rootUrl);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Vector3, Quaternion } from "@babylonjs/core/Maths/math.vector";
|
|
2
|
+
import { PhysicsAggregate } from "@babylonjs/core/Physics/v2/physicsAggregate";
|
|
3
|
+
import { isMesh } from "../tools/guards";
|
|
4
|
+
/**
|
|
5
|
+
* Parses and loads the physics aggregate data for the given mesh.
|
|
6
|
+
* @param mesh defines the reference to the mesh object.
|
|
7
|
+
*/
|
|
8
|
+
export function configurePhysicsAggregate(mesh) {
|
|
9
|
+
const data = mesh.metadata?.physicsAggregate;
|
|
10
|
+
if (!data) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const aggregate = new PhysicsAggregate(mesh, data.shape.type, {
|
|
14
|
+
mass: data.massProperties.mass,
|
|
15
|
+
mesh: isMesh(mesh) ? mesh : undefined,
|
|
16
|
+
});
|
|
17
|
+
aggregate.body.setMassProperties({
|
|
18
|
+
mass: data.massProperties.mass,
|
|
19
|
+
inertia: data.massProperties.inertia ? Vector3.FromArray(data.massProperties.inertia) : undefined,
|
|
20
|
+
centerOfMass: data.massProperties.centerOfMass ? Vector3.FromArray(data.massProperties.centerOfMass) : undefined,
|
|
21
|
+
inertiaOrientation: data.massProperties.inertiaOrientation ? Quaternion.FromArray(data.massProperties.inertiaOrientation) : undefined,
|
|
22
|
+
});
|
|
23
|
+
aggregate.shape.density = data.shape.density;
|
|
24
|
+
aggregate.body.setMotionType(data.body.motionType);
|
|
25
|
+
aggregate.shape.material = data.material;
|
|
26
|
+
mesh.metadata.physicsAggregate = undefined;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=physics.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { vlsPostProcessCameraConfigurations } from "../rendering/vls";
|
|
2
|
+
import { ssrRenderingPipelineCameraConfigurations } from "../rendering/ssr";
|
|
3
|
+
import { ssaoRenderingPipelineCameraConfigurations } from "../rendering/ssao";
|
|
4
|
+
import { motionBlurPostProcessCameraConfigurations } from "../rendering/motion-blur";
|
|
5
|
+
import { defaultPipelineCameraConfigurations } from "../rendering/default-pipeline";
|
|
6
|
+
export function applyRenderingConfigurations(scene, rendering) {
|
|
7
|
+
const postProcessConfigurations = Array.isArray(rendering) ? rendering : [];
|
|
8
|
+
postProcessConfigurations.forEach((configuration) => {
|
|
9
|
+
const camera = scene.getCameraById(configuration.cameraId);
|
|
10
|
+
if (!camera) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (configuration.ssao2RenderingPipeline) {
|
|
14
|
+
ssaoRenderingPipelineCameraConfigurations.set(camera, configuration.ssao2RenderingPipeline);
|
|
15
|
+
}
|
|
16
|
+
if (configuration.vlsPostProcess) {
|
|
17
|
+
vlsPostProcessCameraConfigurations.set(camera, configuration.vlsPostProcess);
|
|
18
|
+
}
|
|
19
|
+
if (configuration.ssrRenderingPipeline) {
|
|
20
|
+
ssrRenderingPipelineCameraConfigurations.set(camera, configuration.ssrRenderingPipeline);
|
|
21
|
+
}
|
|
22
|
+
if (configuration.motionBlurPostProcess) {
|
|
23
|
+
motionBlurPostProcessCameraConfigurations.set(camera, configuration.motionBlurPostProcess);
|
|
24
|
+
}
|
|
25
|
+
if (configuration.defaultRenderingPipeline) {
|
|
26
|
+
defaultPipelineCameraConfigurations.set(camera, configuration.defaultRenderingPipeline);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=rendering.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { applyDecorators } from "../decorators/apply";
|
|
2
|
+
export function applyScriptForObject(scene, object, scriptsMap, rootUrl) {
|
|
3
|
+
if (!object.metadata) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
object.metadata.scripts?.forEach((script) => {
|
|
7
|
+
if (!script.enabled) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const exports = scriptsMap[script.key];
|
|
11
|
+
if (!exports) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (exports.default) {
|
|
15
|
+
const instance = new exports.default(object);
|
|
16
|
+
applyDecorators(scene, object, script, instance, rootUrl);
|
|
17
|
+
if (instance.onStart) {
|
|
18
|
+
scene.onBeforeRenderObservable.addOnce(() => instance.onStart());
|
|
19
|
+
}
|
|
20
|
+
if (instance.onUpdate) {
|
|
21
|
+
scene.onBeforeRenderObservable.add(() => instance.onUpdate());
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
if (exports.onStart) {
|
|
26
|
+
scene.onBeforeRenderObservable.addOnce(() => exports.onStart(object));
|
|
27
|
+
}
|
|
28
|
+
if (exports.onUpdate) {
|
|
29
|
+
scene.onBeforeRenderObservable.add(() => exports.onUpdate(object));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
object.metadata.scripts = undefined;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=script.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SceneComponentConstants } from "@babylonjs/core/sceneComponent";
|
|
2
|
+
import { GetParser, AddParser } from "@babylonjs/core/Loading/Plugins/babylonFileParser.function";
|
|
3
|
+
const audioParser = GetParser(SceneComponentConstants.NAME_AUDIO);
|
|
4
|
+
AddParser(SceneComponentConstants.NAME_AUDIO, (parsedData, scene, container, rootUrl) => {
|
|
5
|
+
audioParser?.(parsedData, scene, container, rootUrl);
|
|
6
|
+
parsedData.sounds?.forEach((sound) => {
|
|
7
|
+
const instance = container.sounds?.find((s) => s.name === sound.name);
|
|
8
|
+
if (instance) {
|
|
9
|
+
instance.id = sound.id;
|
|
10
|
+
instance.uniqueId = sound.uniqueId;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=sound.js.map
|
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const decorators_serialization_1 = require("@babylonjs/core/Misc/decorators.serialization");
|
|
4
|
-
const scalar_1 = require("./tools/scalar");
|
|
1
|
+
import { SerializationHelper } from "@babylonjs/core/Misc/decorators.serialization";
|
|
2
|
+
import { getPowerOfTwoUntil } from "../tools/scalar";
|
|
5
3
|
/**
|
|
6
4
|
* Defines the reference to the original texture parser function.
|
|
7
5
|
*/
|
|
8
|
-
const textureParser =
|
|
9
|
-
|
|
6
|
+
const textureParser = SerializationHelper._TextureParser;
|
|
7
|
+
SerializationHelper._TextureParser = (sourceProperty, scene, rootUrl) => {
|
|
10
8
|
if (scene.loadingQuality === "high" || !sourceProperty.metadata?.baseSize) {
|
|
11
9
|
return textureParser(sourceProperty, scene, rootUrl);
|
|
12
10
|
}
|
|
13
11
|
const width = sourceProperty.metadata.baseSize.width;
|
|
14
12
|
const height = sourceProperty.metadata.baseSize.height;
|
|
15
|
-
const isPowerOfTwo = width ===
|
|
13
|
+
const isPowerOfTwo = width === getPowerOfTwoUntil(width) || height === getPowerOfTwoUntil(height);
|
|
16
14
|
let suffix = "";
|
|
17
15
|
switch (scene.loadingQuality) {
|
|
18
16
|
case "medium":
|
|
19
17
|
let midWidth = (width * 0.66) >> 0;
|
|
20
18
|
let midHeight = (height * 0.66) >> 0;
|
|
21
19
|
if (isPowerOfTwo) {
|
|
22
|
-
midWidth =
|
|
23
|
-
midHeight =
|
|
20
|
+
midWidth = getPowerOfTwoUntil(midWidth);
|
|
21
|
+
midHeight = getPowerOfTwoUntil(midHeight);
|
|
24
22
|
}
|
|
25
23
|
suffix = `_${midWidth}_${midHeight}`;
|
|
26
24
|
break;
|
|
@@ -28,8 +26,8 @@ decorators_serialization_1.SerializationHelper._TextureParser = (sourceProperty,
|
|
|
28
26
|
let lowWidth = (width * 0.33) >> 0;
|
|
29
27
|
let lowHeight = (height * 0.33) >> 0;
|
|
30
28
|
if (isPowerOfTwo) {
|
|
31
|
-
lowWidth =
|
|
32
|
-
lowHeight =
|
|
29
|
+
lowWidth = getPowerOfTwoUntil(lowWidth);
|
|
30
|
+
lowHeight = getPowerOfTwoUntil(lowHeight);
|
|
33
31
|
}
|
|
34
32
|
suffix = `_${lowWidth}_${lowHeight}`;
|
|
35
33
|
break;
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const defaultRenderingPipeline_1 = require("@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline");
|
|
1
|
+
import { Color4 } from "@babylonjs/core/Maths/math.color";
|
|
2
|
+
import { Vector2 } from "@babylonjs/core/Maths/math.vector";
|
|
3
|
+
import { DefaultRenderingPipeline } from "@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
|
|
5
4
|
let defaultRenderingPipeline = null;
|
|
5
|
+
/**
|
|
6
|
+
* Defines the configuration of the default rendering pipeline per camera.
|
|
7
|
+
*/
|
|
8
|
+
export const defaultPipelineCameraConfigurations = new Map();
|
|
6
9
|
/**
|
|
7
10
|
* Returns the reference to the default rendering pipeline if exists.
|
|
8
11
|
*/
|
|
9
|
-
function getDefaultRenderingPipeline() {
|
|
12
|
+
export function getDefaultRenderingPipeline() {
|
|
10
13
|
return defaultRenderingPipeline;
|
|
11
14
|
}
|
|
12
|
-
|
|
13
|
-
function disposeDefaultRenderingPipeline() {
|
|
15
|
+
export function disposeDefaultRenderingPipeline() {
|
|
14
16
|
if (defaultRenderingPipeline) {
|
|
15
17
|
defaultRenderingPipeline.dispose();
|
|
16
18
|
defaultRenderingPipeline = null;
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
defaultRenderingPipeline = new defaultRenderingPipeline_1.DefaultRenderingPipeline("DefaultRenderingPipeline", true, scene, [camera]);
|
|
21
|
+
export function createDefaultRenderingPipeline(scene, camera) {
|
|
22
|
+
defaultRenderingPipeline = new DefaultRenderingPipeline("DefaultRenderingPipeline", true, scene, [camera]);
|
|
22
23
|
defaultRenderingPipeline.samples = 4;
|
|
23
24
|
defaultRenderingPipeline.depthOfField.lensSize = 512;
|
|
24
25
|
defaultRenderingPipeline.depthOfField.fStop = 0.25;
|
|
25
26
|
defaultRenderingPipeline.depthOfField.focusDistance = 55_000;
|
|
26
27
|
return defaultRenderingPipeline;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
function serializeDefaultRenderingPipeline() {
|
|
29
|
+
export function serializeDefaultRenderingPipeline() {
|
|
30
30
|
if (!defaultRenderingPipeline) {
|
|
31
31
|
return null;
|
|
32
32
|
}
|
|
@@ -58,10 +58,21 @@ function serializeDefaultRenderingPipeline() {
|
|
|
58
58
|
fStop: defaultRenderingPipeline.depthOfField.fStop,
|
|
59
59
|
focusDistance: defaultRenderingPipeline.depthOfField.focusDistance,
|
|
60
60
|
focalLength: defaultRenderingPipeline.depthOfField.focalLength,
|
|
61
|
+
// Since v5.0.0-alpha.9
|
|
62
|
+
vignetteEnabled: defaultRenderingPipeline.imageProcessing?.vignetteEnabled,
|
|
63
|
+
vignetteColor: defaultRenderingPipeline.imageProcessing?.vignetteColor.asArray(),
|
|
64
|
+
vignetteWeight: defaultRenderingPipeline.imageProcessing?.vignetteWeight,
|
|
65
|
+
chromaticAberrationEnabled: defaultRenderingPipeline.chromaticAberrationEnabled,
|
|
66
|
+
aberrationAmount: defaultRenderingPipeline.chromaticAberration.aberrationAmount,
|
|
67
|
+
radialIntensity: defaultRenderingPipeline.chromaticAberration.radialIntensity,
|
|
68
|
+
direction: defaultRenderingPipeline.chromaticAberration.direction.asArray(),
|
|
69
|
+
centerPosition: defaultRenderingPipeline.chromaticAberration.centerPosition.asArray(),
|
|
70
|
+
glowLayerEnabled: defaultRenderingPipeline.glowLayerEnabled,
|
|
71
|
+
glowLayerIntensity: defaultRenderingPipeline.glowLayer?.intensity,
|
|
72
|
+
glowLayerBlurKernelSize: defaultRenderingPipeline.glowLayer?.blurKernelSize,
|
|
61
73
|
};
|
|
62
74
|
}
|
|
63
|
-
|
|
64
|
-
function parseDefaultRenderingPipeline(scene, camera, data) {
|
|
75
|
+
export function parseDefaultRenderingPipeline(scene, camera, data) {
|
|
65
76
|
if (defaultRenderingPipeline) {
|
|
66
77
|
return defaultRenderingPipeline;
|
|
67
78
|
}
|
|
@@ -77,6 +88,10 @@ function parseDefaultRenderingPipeline(scene, camera, data) {
|
|
|
77
88
|
pipeline.imageProcessing.toneMappingType = data.toneMappingType;
|
|
78
89
|
pipeline.imageProcessing.ditheringEnabled = data.ditheringEnabled;
|
|
79
90
|
pipeline.imageProcessing.ditheringIntensity = data.ditheringIntensity;
|
|
91
|
+
// Since v5.0.0-alpha.9
|
|
92
|
+
pipeline.imageProcessing.vignetteEnabled = data.vignetteEnabled ?? false;
|
|
93
|
+
pipeline.imageProcessing.vignetteColor = Color4.FromArray(data.vignetteColor ?? [0, 0, 0]);
|
|
94
|
+
pipeline.imageProcessing.vignetteWeight = data.vignetteWeight ?? 0.3;
|
|
80
95
|
}
|
|
81
96
|
pipeline.bloomEnabled = data.bloomEnabled;
|
|
82
97
|
pipeline.bloomThreshold = data.bloomThreshold;
|
|
@@ -95,7 +110,17 @@ function parseDefaultRenderingPipeline(scene, camera, data) {
|
|
|
95
110
|
pipeline.depthOfField.fStop = data.fStop;
|
|
96
111
|
pipeline.depthOfField.focusDistance = data.focusDistance;
|
|
97
112
|
pipeline.depthOfField.focalLength = data.focalLength;
|
|
113
|
+
// Since v5.0.0-alpha.9
|
|
114
|
+
pipeline.chromaticAberrationEnabled = data.chromaticAberrationEnabled ?? false;
|
|
115
|
+
pipeline.chromaticAberration.aberrationAmount = data.aberrationAmount ?? 10;
|
|
116
|
+
pipeline.chromaticAberration.radialIntensity = data.radialIntensity ?? 1;
|
|
117
|
+
pipeline.chromaticAberration.direction = Vector2.FromArray(data.direction ?? [0, 0]);
|
|
118
|
+
pipeline.chromaticAberration.centerPosition = Vector2.FromArray(data.centerPosition ?? [0, 0]);
|
|
119
|
+
pipeline.glowLayerEnabled = data.glowLayerEnabled ?? false;
|
|
120
|
+
if (pipeline.glowLayer) {
|
|
121
|
+
pipeline.glowLayer.intensity = data.glowLayerIntensity ?? 1;
|
|
122
|
+
pipeline.glowLayer.blurKernelSize = data.glowLayerBlurKernelSize ?? 32;
|
|
123
|
+
}
|
|
98
124
|
return pipeline;
|
|
99
125
|
}
|
|
100
|
-
exports.parseDefaultRenderingPipeline = parseDefaultRenderingPipeline;
|
|
101
126
|
//# sourceMappingURL=default-pipeline.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { MotionBlurPostProcess } from "@babylonjs/core/PostProcesses/motionBlurPostProcess";
|
|
2
|
+
let motionBlurPostProcess = null;
|
|
3
|
+
/**
|
|
4
|
+
* Defines the configuration of the motion blur post-process per camera.
|
|
5
|
+
*/
|
|
6
|
+
export const motionBlurPostProcessCameraConfigurations = new Map();
|
|
7
|
+
export function getMotionBlurPostProcess() {
|
|
8
|
+
return motionBlurPostProcess;
|
|
9
|
+
}
|
|
10
|
+
export function disposeMotionBlurPostProcess() {
|
|
11
|
+
if (motionBlurPostProcess) {
|
|
12
|
+
motionBlurPostProcess.dispose();
|
|
13
|
+
motionBlurPostProcess = null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function createMotionBlurPostProcess(scene, camera) {
|
|
17
|
+
motionBlurPostProcess = new MotionBlurPostProcess("MotionBlurPostProcess", scene, 1.0, camera);
|
|
18
|
+
motionBlurPostProcess.motionStrength = 1.0;
|
|
19
|
+
motionBlurPostProcess.isObjectBased = true;
|
|
20
|
+
return motionBlurPostProcess;
|
|
21
|
+
}
|
|
22
|
+
export function serializeMotionBlurPostProcess() {
|
|
23
|
+
if (!motionBlurPostProcess) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
isObjectBased: motionBlurPostProcess.isObjectBased,
|
|
28
|
+
motionStrength: motionBlurPostProcess.motionStrength,
|
|
29
|
+
motionBlurSamples: motionBlurPostProcess.motionBlurSamples,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function parseMotionBlurPostProcess(scene, camera, data) {
|
|
33
|
+
if (motionBlurPostProcess) {
|
|
34
|
+
return motionBlurPostProcess;
|
|
35
|
+
}
|
|
36
|
+
const postProcess = createMotionBlurPostProcess(scene, camera);
|
|
37
|
+
postProcess.isObjectBased = data.isObjectBased;
|
|
38
|
+
postProcess.motionStrength = data.motionStrength;
|
|
39
|
+
postProcess.motionBlurSamples = data.motionBlurSamples;
|
|
40
|
+
return postProcess;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=motion-blur.js.map
|
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseSSAO2RenderingPipeline = exports.serializeSSAO2RenderingPipeline = exports.createSSAO2RenderingPipeline = exports.disposeSSAO2RenderingPipeline = exports.getSSAO2RenderingPipeline = void 0;
|
|
4
|
-
const ssao2RenderingPipeline_1 = require("@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline");
|
|
1
|
+
import { SSAO2RenderingPipeline } from "@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
|
|
5
2
|
let ssaoRenderingPipeline = null;
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Defines the configuration of the SSAO rendering pipeline per camera.
|
|
5
|
+
*/
|
|
6
|
+
export const ssaoRenderingPipelineCameraConfigurations = new Map();
|
|
7
|
+
export function getSSAO2RenderingPipeline() {
|
|
7
8
|
return ssaoRenderingPipeline;
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
function disposeSSAO2RenderingPipeline() {
|
|
10
|
+
export function disposeSSAO2RenderingPipeline() {
|
|
11
11
|
if (ssaoRenderingPipeline) {
|
|
12
12
|
ssaoRenderingPipeline.dispose();
|
|
13
13
|
ssaoRenderingPipeline = null;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
ssaoRenderingPipeline = new ssao2RenderingPipeline_1.SSAO2RenderingPipeline("SSAO2RenderingPipeline", scene, 1.0, [camera]);
|
|
16
|
+
export function createSSAO2RenderingPipeline(scene, camera) {
|
|
17
|
+
ssaoRenderingPipeline = new SSAO2RenderingPipeline("SSAO2RenderingPipeline", scene, 1.0, [camera]);
|
|
19
18
|
ssaoRenderingPipeline.samples = 4;
|
|
20
19
|
return ssaoRenderingPipeline;
|
|
21
20
|
}
|
|
22
|
-
|
|
23
|
-
function serializeSSAO2RenderingPipeline() {
|
|
21
|
+
export function serializeSSAO2RenderingPipeline() {
|
|
24
22
|
if (!ssaoRenderingPipeline) {
|
|
25
23
|
return null;
|
|
26
24
|
}
|
|
@@ -39,8 +37,7 @@ function serializeSSAO2RenderingPipeline() {
|
|
|
39
37
|
expensiveBlur: ssaoRenderingPipeline.expensiveBlur,
|
|
40
38
|
};
|
|
41
39
|
}
|
|
42
|
-
|
|
43
|
-
function parseSSAO2RenderingPipeline(scene, camera, data) {
|
|
40
|
+
export function parseSSAO2RenderingPipeline(scene, camera, data) {
|
|
44
41
|
if (ssaoRenderingPipeline) {
|
|
45
42
|
return ssaoRenderingPipeline;
|
|
46
43
|
}
|
|
@@ -59,5 +56,4 @@ function parseSSAO2RenderingPipeline(scene, camera, data) {
|
|
|
59
56
|
pipeline.expensiveBlur = data.expensiveBlur;
|
|
60
57
|
return pipeline;
|
|
61
58
|
}
|
|
62
|
-
exports.parseSSAO2RenderingPipeline = parseSSAO2RenderingPipeline;
|
|
63
59
|
//# sourceMappingURL=ssao.js.map
|
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseSSRRenderingPipeline = exports.serializeSSRRenderingPipeline = exports.createSSRRenderingPipeline = exports.disposeSSRRenderingPipeline = exports.getSSRRenderingPipeline = void 0;
|
|
4
|
-
const ssrRenderingPipeline_1 = require("@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline");
|
|
1
|
+
import { SSRRenderingPipeline } from "@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline";
|
|
5
2
|
let ssrRenderingPipeline = null;
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Defines the configuration of the ssr rendering pipeline per camera.
|
|
5
|
+
*/
|
|
6
|
+
export const ssrRenderingPipelineCameraConfigurations = new Map();
|
|
7
|
+
export function getSSRRenderingPipeline() {
|
|
7
8
|
return ssrRenderingPipeline;
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
function disposeSSRRenderingPipeline() {
|
|
10
|
+
export function disposeSSRRenderingPipeline() {
|
|
11
11
|
if (ssrRenderingPipeline) {
|
|
12
12
|
ssrRenderingPipeline.dispose();
|
|
13
13
|
ssrRenderingPipeline = null;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
ssrRenderingPipeline = new ssrRenderingPipeline_1.SSRRenderingPipeline("SSRRenderingPipeline", scene, [camera]);
|
|
16
|
+
export function createSSRRenderingPipeline(scene, camera) {
|
|
17
|
+
ssrRenderingPipeline = new SSRRenderingPipeline("SSRRenderingPipeline", scene, [camera]);
|
|
19
18
|
ssrRenderingPipeline.samples = 4;
|
|
20
19
|
return ssrRenderingPipeline;
|
|
21
20
|
}
|
|
22
|
-
|
|
23
|
-
function serializeSSRRenderingPipeline() {
|
|
21
|
+
export function serializeSSRRenderingPipeline() {
|
|
24
22
|
if (!ssrRenderingPipeline) {
|
|
25
23
|
return null;
|
|
26
24
|
}
|
|
@@ -48,8 +46,7 @@ function serializeSSRRenderingPipeline() {
|
|
|
48
46
|
backfaceDepthTextureDownsample: ssrRenderingPipeline.backfaceDepthTextureDownsample,
|
|
49
47
|
};
|
|
50
48
|
}
|
|
51
|
-
|
|
52
|
-
function parseSSRRenderingPipeline(scene, camera, data) {
|
|
49
|
+
export function parseSSRRenderingPipeline(scene, camera, data) {
|
|
53
50
|
if (ssrRenderingPipeline) {
|
|
54
51
|
return ssrRenderingPipeline;
|
|
55
52
|
}
|
|
@@ -77,5 +74,4 @@ function parseSSRRenderingPipeline(scene, camera, data) {
|
|
|
77
74
|
pipeline.backfaceDepthTextureDownsample = data.backfaceDepthTextureDownsample;
|
|
78
75
|
return pipeline;
|
|
79
76
|
}
|
|
80
|
-
exports.parseSSRRenderingPipeline = parseSSRRenderingPipeline;
|
|
81
77
|
//# sourceMappingURL=ssr.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { disposeVLSPostProcess, parseVLSPostProcess, serializeVLSPostProcess, vlsPostProcessCameraConfigurations } from "./vls";
|
|
2
|
+
import { disposeSSRRenderingPipeline, parseSSRRenderingPipeline, serializeSSRRenderingPipeline, ssrRenderingPipelineCameraConfigurations } from "./ssr";
|
|
3
|
+
import { disposeSSAO2RenderingPipeline, parseSSAO2RenderingPipeline, serializeSSAO2RenderingPipeline, ssaoRenderingPipelineCameraConfigurations } from "./ssao";
|
|
4
|
+
import { disposeMotionBlurPostProcess, motionBlurPostProcessCameraConfigurations, parseMotionBlurPostProcess, serializeMotionBlurPostProcess } from "./motion-blur";
|
|
5
|
+
import { defaultPipelineCameraConfigurations, disposeDefaultRenderingPipeline, parseDefaultRenderingPipeline, serializeDefaultRenderingPipeline } from "./default-pipeline";
|
|
6
|
+
/**
|
|
7
|
+
* Saves the rendering configurations for the given camera. This is useful to restore the rendering configurations
|
|
8
|
+
* when the camera is re-activated (typically using the preview panel toolbar).
|
|
9
|
+
* @param camera defines the reference to the camera to save its rendering configurations.
|
|
10
|
+
*/
|
|
11
|
+
export function saveRenderingConfigurationForCamera(camera) {
|
|
12
|
+
ssaoRenderingPipelineCameraConfigurations.set(camera, serializeSSAO2RenderingPipeline());
|
|
13
|
+
vlsPostProcessCameraConfigurations.set(camera, serializeVLSPostProcess());
|
|
14
|
+
ssrRenderingPipelineCameraConfigurations.set(camera, serializeSSRRenderingPipeline());
|
|
15
|
+
motionBlurPostProcessCameraConfigurations.set(camera, serializeMotionBlurPostProcess());
|
|
16
|
+
defaultPipelineCameraConfigurations.set(camera, serializeDefaultRenderingPipeline());
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Applies the post-processes configurations for the given camera. Rendering configurations (motion blur, ssao, etc.) are
|
|
20
|
+
* saved per-camera and can be applied on demand using this function.
|
|
21
|
+
* Previous post-processes configurations are disposed before applying the new ones.
|
|
22
|
+
* @param camera defines the reference to the camera to apply its rendering configurations.
|
|
23
|
+
*/
|
|
24
|
+
export function applyRenderingConfigurationForCamera(camera) {
|
|
25
|
+
disposeSSAO2RenderingPipeline();
|
|
26
|
+
disposeVLSPostProcess(camera.getScene());
|
|
27
|
+
disposeSSRRenderingPipeline();
|
|
28
|
+
disposeMotionBlurPostProcess();
|
|
29
|
+
disposeDefaultRenderingPipeline();
|
|
30
|
+
const ssao2RenderingPipeline = ssaoRenderingPipelineCameraConfigurations.get(camera);
|
|
31
|
+
if (ssao2RenderingPipeline) {
|
|
32
|
+
parseSSAO2RenderingPipeline(camera.getScene(), camera, ssao2RenderingPipeline);
|
|
33
|
+
}
|
|
34
|
+
const vlsPostProcess = vlsPostProcessCameraConfigurations.get(camera);
|
|
35
|
+
if (vlsPostProcess) {
|
|
36
|
+
parseVLSPostProcess(camera.getScene(), vlsPostProcess);
|
|
37
|
+
}
|
|
38
|
+
const ssrRenderingPipeline = ssrRenderingPipelineCameraConfigurations.get(camera);
|
|
39
|
+
if (ssrRenderingPipeline) {
|
|
40
|
+
parseSSRRenderingPipeline(camera.getScene(), camera, ssrRenderingPipeline);
|
|
41
|
+
}
|
|
42
|
+
const motionBlurPostProcess = motionBlurPostProcessCameraConfigurations.get(camera);
|
|
43
|
+
if (motionBlurPostProcess) {
|
|
44
|
+
parseMotionBlurPostProcess(camera.getScene(), camera, motionBlurPostProcess);
|
|
45
|
+
}
|
|
46
|
+
const defaultRenderingPipeline = defaultPipelineCameraConfigurations.get(camera);
|
|
47
|
+
if (defaultRenderingPipeline) {
|
|
48
|
+
parseDefaultRenderingPipeline(camera.getScene(), camera, defaultRenderingPipeline);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Vector3 } from "@babylonjs/core/Maths/math.vector";
|
|
2
|
+
import { Texture } from "@babylonjs/core/Materials/Textures/texture";
|
|
3
|
+
import { VolumetricLightScatteringPostProcess } from "@babylonjs/core/PostProcesses/volumetricLightScatteringPostProcess";
|
|
4
|
+
import { isMesh } from "../tools/guards";
|
|
5
|
+
let vlsPostProcess = null;
|
|
6
|
+
/**
|
|
7
|
+
* Defines the configuration of the motion blur post-process per camera.
|
|
8
|
+
*/
|
|
9
|
+
export const vlsPostProcessCameraConfigurations = new Map();
|
|
10
|
+
export function getVLSPostProcess() {
|
|
11
|
+
return vlsPostProcess;
|
|
12
|
+
}
|
|
13
|
+
export function disposeVLSPostProcess(scene) {
|
|
14
|
+
if (vlsPostProcess && scene.activeCamera) {
|
|
15
|
+
vlsPostProcess.dispose(scene.activeCamera);
|
|
16
|
+
vlsPostProcess = null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function createVLSPostProcess(scene, mesh) {
|
|
20
|
+
mesh ??= scene.meshes.find((mesh) => isMesh(mesh));
|
|
21
|
+
vlsPostProcess = new VolumetricLightScatteringPostProcess("VolumetricLightScatteringPostProcess", 1.0, scene.activeCamera, mesh, 100, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
|
|
22
|
+
return vlsPostProcess;
|
|
23
|
+
}
|
|
24
|
+
export function serializeVLSPostProcess() {
|
|
25
|
+
if (!vlsPostProcess) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
meshId: vlsPostProcess.mesh?.id,
|
|
30
|
+
exposure: vlsPostProcess.exposure,
|
|
31
|
+
decay: vlsPostProcess.decay,
|
|
32
|
+
weight: vlsPostProcess.weight,
|
|
33
|
+
density: vlsPostProcess.density,
|
|
34
|
+
invert: vlsPostProcess.invert,
|
|
35
|
+
useCustomMeshPosition: vlsPostProcess.useCustomMeshPosition,
|
|
36
|
+
customMeshPosition: vlsPostProcess.customMeshPosition.asArray(),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function parseVLSPostProcess(scene, data) {
|
|
40
|
+
let mesh = null;
|
|
41
|
+
if (data.meshId) {
|
|
42
|
+
const result = scene.getMeshById(data.meshId);
|
|
43
|
+
if (result && isMesh(result)) {
|
|
44
|
+
mesh = result;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const vlsPostProcess = createVLSPostProcess(scene, mesh);
|
|
48
|
+
vlsPostProcess.exposure = data.exposure;
|
|
49
|
+
vlsPostProcess.decay = data.decay;
|
|
50
|
+
vlsPostProcess.weight = data.weight;
|
|
51
|
+
vlsPostProcess.density = data.density;
|
|
52
|
+
vlsPostProcess.invert = data.invert;
|
|
53
|
+
vlsPostProcess.useCustomMeshPosition = data.useCustomMeshPosition;
|
|
54
|
+
vlsPostProcess.customMeshPosition.copyFrom(Vector3.FromArray(data.customMeshPosition));
|
|
55
|
+
return vlsPostProcess;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=vls.js.map
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isTexture = exports.isGroundMesh = exports.isMesh = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Returns wether or not the given object is a Mesh.
|
|
6
3
|
* @param object defines the reference to the object to test its class name.
|
|
7
4
|
*/
|
|
8
|
-
function isMesh(object) {
|
|
5
|
+
export function isMesh(object) {
|
|
9
6
|
switch (object.getClassName?.()) {
|
|
10
7
|
case "Mesh":
|
|
11
8
|
case "GroundMesh":
|
|
@@ -13,21 +10,18 @@ function isMesh(object) {
|
|
|
13
10
|
}
|
|
14
11
|
return false;
|
|
15
12
|
}
|
|
16
|
-
exports.isMesh = isMesh;
|
|
17
13
|
/**
|
|
18
14
|
* Returns wether or not the given object is a GroundMesh.
|
|
19
15
|
* @param object defines the reference to the object to test its class name.
|
|
20
16
|
*/
|
|
21
|
-
function isGroundMesh(object) {
|
|
17
|
+
export function isGroundMesh(object) {
|
|
22
18
|
return object.getClassName?.() === "GroundMesh";
|
|
23
19
|
}
|
|
24
|
-
exports.isGroundMesh = isGroundMesh;
|
|
25
20
|
/**
|
|
26
21
|
* Returns wether or not the given object is a Texture.
|
|
27
22
|
* @param object defines the reference to the object to test its class name.
|
|
28
23
|
*/
|
|
29
|
-
function isTexture(object) {
|
|
24
|
+
export function isTexture(object) {
|
|
30
25
|
return object?.getClassName?.() === "Texture";
|
|
31
26
|
}
|
|
32
|
-
exports.isTexture = isTexture;
|
|
33
27
|
//# sourceMappingURL=guards.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Vector3 } from "@babylonjs/core/Maths/math.vector";
|
|
2
|
+
import { RenderTargetTexture } from "@babylonjs/core/Materials/Textures/renderTargetTexture";
|
|
3
|
+
export function configureShadowMapRenderListPredicate(scene) {
|
|
4
|
+
scene.lights.forEach((light) => {
|
|
5
|
+
const shadowMap = light.getShadowGenerator()?.getShadowMap();
|
|
6
|
+
if (!shadowMap) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
shadowMap.renderListPredicate = (mesh) => {
|
|
10
|
+
const distance = Vector3.Distance(mesh.getAbsolutePosition(), light.getAbsolutePosition());
|
|
11
|
+
return distance <= light.range;
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export async function configureShadowMapRefreshRate(scene) {
|
|
16
|
+
scene.executeWhenReady(() => {
|
|
17
|
+
scene.lights.forEach((light) => {
|
|
18
|
+
const shadowMap = light.getShadowGenerator()?.getShadowMap();
|
|
19
|
+
if (shadowMap) {
|
|
20
|
+
shadowMap.refreshRate = light.metadata?.refreshRate ?? RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=light.js.map
|