@fps-games/engine 0.0.1-beta.2 → 0.0.1-beta.20
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/dist/asset-resource.d.ts +45 -0
- package/dist/asset-resource.d.ts.map +1 -0
- package/dist/asset-resource.js +147 -0
- package/dist/asset-resource.js.map +1 -0
- package/dist/babylon/camera.d.ts +25 -0
- package/dist/babylon/camera.d.ts.map +1 -0
- package/dist/babylon/camera.js +149 -0
- package/dist/babylon/camera.js.map +1 -0
- package/dist/babylon/frame-pump.d.ts +27 -0
- package/dist/babylon/frame-pump.d.ts.map +1 -0
- package/dist/babylon/frame-pump.js +90 -0
- package/dist/babylon/frame-pump.js.map +1 -0
- package/dist/babylon/game-world-plugin-lifecycle.d.ts +26 -0
- package/dist/babylon/game-world-plugin-lifecycle.d.ts.map +1 -0
- package/dist/babylon/game-world-plugin-lifecycle.js +257 -0
- package/dist/babylon/game-world-plugin-lifecycle.js.map +1 -0
- package/dist/babylon/lighting-controller.d.ts.map +1 -1
- package/dist/babylon/lighting-controller.js +162 -16
- package/dist/babylon/lighting-controller.js.map +1 -1
- package/dist/babylon/plugin-contract.d.ts +15 -0
- package/dist/babylon/plugin-contract.d.ts.map +1 -0
- package/dist/babylon/plugin-contract.js +10 -0
- package/dist/babylon/plugin-contract.js.map +1 -0
- package/dist/babylon/renderer/asset-container-instantiation.d.ts +39 -0
- package/dist/babylon/renderer/asset-container-instantiation.d.ts.map +1 -0
- package/dist/babylon/renderer/asset-container-instantiation.js +287 -0
- package/dist/babylon/renderer/asset-container-instantiation.js.map +1 -0
- package/dist/babylon/renderer/brdf-texture-settlement.d.ts +7 -0
- package/dist/babylon/renderer/brdf-texture-settlement.d.ts.map +1 -0
- package/dist/babylon/renderer/brdf-texture-settlement.js +29 -0
- package/dist/babylon/renderer/brdf-texture-settlement.js.map +1 -0
- package/dist/babylon/renderer/environment/environment-texture-controller.d.ts +7 -0
- package/dist/babylon/renderer/environment/environment-texture-controller.d.ts.map +1 -0
- package/dist/babylon/renderer/environment/environment-texture-controller.js +358 -0
- package/dist/babylon/renderer/environment/environment-texture-controller.js.map +1 -0
- package/dist/babylon/renderer/environment/index.d.ts +4 -0
- package/dist/babylon/renderer/environment/index.d.ts.map +1 -0
- package/dist/babylon/renderer/environment/index.js +4 -0
- package/dist/babylon/renderer/environment/index.js.map +1 -0
- package/dist/babylon/renderer/environment/profile.d.ts +3 -0
- package/dist/babylon/renderer/environment/profile.d.ts.map +1 -0
- package/dist/babylon/renderer/environment/profile.js +27 -0
- package/dist/babylon/renderer/environment/profile.js.map +1 -0
- package/dist/babylon/renderer/environment/types.d.ts +24 -0
- package/dist/babylon/renderer/environment/types.d.ts.map +1 -0
- package/dist/babylon/renderer/environment/types.js +6 -0
- package/dist/babylon/renderer/environment/types.js.map +1 -0
- package/dist/babylon/renderer/index.d.ts +26 -0
- package/dist/babylon/renderer/index.d.ts.map +1 -0
- package/dist/babylon/renderer/index.js +26 -0
- package/dist/babylon/renderer/index.js.map +1 -0
- package/dist/babylon/renderer/lighting/directional-light-angles.d.ts +17 -0
- package/dist/babylon/renderer/lighting/directional-light-angles.d.ts.map +1 -0
- package/dist/babylon/renderer/lighting/directional-light-angles.js +67 -0
- package/dist/babylon/renderer/lighting/directional-light-angles.js.map +1 -0
- package/dist/babylon/renderer/material-owner-candidates.d.ts +21 -0
- package/dist/babylon/renderer/material-owner-candidates.d.ts.map +1 -0
- package/dist/babylon/renderer/material-owner-candidates.js +217 -0
- package/dist/babylon/renderer/material-owner-candidates.js.map +1 -0
- package/dist/babylon/renderer/materials/index.d.ts +3 -0
- package/dist/babylon/renderer/materials/index.d.ts.map +1 -0
- package/dist/babylon/renderer/materials/index.js +3 -0
- package/dist/babylon/renderer/materials/index.js.map +1 -0
- package/dist/babylon/renderer/materials/material-runtime.d.ts +29 -0
- package/dist/babylon/renderer/materials/material-runtime.d.ts.map +1 -0
- package/dist/babylon/renderer/materials/material-runtime.js +660 -0
- package/dist/babylon/renderer/materials/material-runtime.js.map +1 -0
- package/dist/babylon/renderer/materials/material-slot-owner.d.ts +42 -0
- package/dist/babylon/renderer/materials/material-slot-owner.d.ts.map +1 -0
- package/dist/babylon/renderer/materials/material-slot-owner.js +318 -0
- package/dist/babylon/renderer/materials/material-slot-owner.js.map +1 -0
- package/dist/babylon/renderer/outlines/babylon-default/apply.d.ts +4 -0
- package/dist/babylon/renderer/outlines/babylon-default/apply.d.ts.map +1 -0
- package/dist/babylon/renderer/outlines/babylon-default/apply.js +45 -0
- package/dist/babylon/renderer/outlines/babylon-default/apply.js.map +1 -0
- package/dist/babylon/renderer/outlines/babylon-default/index.d.ts +3 -0
- package/dist/babylon/renderer/outlines/babylon-default/index.d.ts.map +1 -0
- package/dist/babylon/renderer/outlines/babylon-default/index.js +2 -0
- package/dist/babylon/renderer/outlines/babylon-default/index.js.map +1 -0
- package/dist/babylon/renderer/outlines/babylon-default/types.d.ts +7 -0
- package/dist/babylon/renderer/outlines/babylon-default/types.d.ts.map +1 -0
- package/dist/babylon/renderer/outlines/babylon-default/types.js +2 -0
- package/dist/babylon/renderer/outlines/babylon-default/types.js.map +1 -0
- package/dist/babylon/renderer/outlines/index.d.ts +4 -0
- package/dist/babylon/renderer/outlines/index.d.ts.map +1 -0
- package/dist/babylon/renderer/outlines/index.js +3 -0
- package/dist/babylon/renderer/outlines/index.js.map +1 -0
- package/dist/babylon/renderer/outlines/runtime-override.d.ts +36 -0
- package/dist/babylon/renderer/outlines/runtime-override.d.ts.map +1 -0
- package/dist/babylon/renderer/outlines/runtime-override.js +131 -0
- package/dist/babylon/renderer/outlines/runtime-override.js.map +1 -0
- package/dist/babylon/renderer/outlines/types.d.ts +7 -0
- package/dist/babylon/renderer/outlines/types.d.ts.map +1 -0
- package/dist/babylon/renderer/outlines/types.js +2 -0
- package/dist/babylon/renderer/outlines/types.js.map +1 -0
- package/dist/babylon/renderer/placement/index.d.ts +2 -0
- package/dist/babylon/renderer/placement/index.d.ts.map +1 -0
- package/dist/babylon/renderer/placement/index.js +2 -0
- package/dist/babylon/renderer/placement/index.js.map +1 -0
- package/dist/babylon/renderer/placement/runtime-drop-position.d.ts +24 -0
- package/dist/babylon/renderer/placement/runtime-drop-position.d.ts.map +1 -0
- package/dist/babylon/renderer/placement/runtime-drop-position.js +63 -0
- package/dist/babylon/renderer/placement/runtime-drop-position.js.map +1 -0
- package/dist/babylon/renderer/post-process/babylon-default-pipeline.d.ts +7 -0
- package/dist/babylon/renderer/post-process/babylon-default-pipeline.d.ts.map +1 -0
- package/dist/babylon/renderer/post-process/babylon-default-pipeline.js +301 -0
- package/dist/babylon/renderer/post-process/babylon-default-pipeline.js.map +1 -0
- package/dist/babylon/renderer/post-process/index.d.ts +5 -0
- package/dist/babylon/renderer/post-process/index.d.ts.map +1 -0
- package/dist/babylon/renderer/post-process/index.js +5 -0
- package/dist/babylon/renderer/post-process/index.js.map +1 -0
- package/dist/babylon/renderer/post-process/profile.d.ts +5 -0
- package/dist/babylon/renderer/post-process/profile.d.ts.map +1 -0
- package/dist/babylon/renderer/post-process/profile.js +155 -0
- package/dist/babylon/renderer/post-process/profile.js.map +1 -0
- package/dist/babylon/renderer/post-process/types.d.ts +81 -0
- package/dist/babylon/renderer/post-process/types.d.ts.map +1 -0
- package/dist/babylon/renderer/post-process/types.js +24 -0
- package/dist/babylon/renderer/post-process/types.js.map +1 -0
- package/dist/babylon/renderer/post-process/volume-stack.d.ts +4 -0
- package/dist/babylon/renderer/post-process/volume-stack.d.ts.map +1 -0
- package/dist/babylon/renderer/post-process/volume-stack.js +105 -0
- package/dist/babylon/renderer/post-process/volume-stack.js.map +1 -0
- package/dist/babylon/renderer/rendering/image-node.d.ts +35 -0
- package/dist/babylon/renderer/rendering/image-node.d.ts.map +1 -0
- package/dist/babylon/renderer/rendering/image-node.js +39 -0
- package/dist/babylon/renderer/rendering/image-node.js.map +1 -0
- package/dist/babylon/renderer/rendering/index.d.ts +3 -0
- package/dist/babylon/renderer/rendering/index.d.ts.map +1 -0
- package/dist/babylon/renderer/rendering/index.js +3 -0
- package/dist/babylon/renderer/rendering/index.js.map +1 -0
- package/dist/babylon/renderer/rendering/node-rendering.d.ts +19 -0
- package/dist/babylon/renderer/rendering/node-rendering.d.ts.map +1 -0
- package/dist/babylon/renderer/rendering/node-rendering.js +66 -0
- package/dist/babylon/renderer/rendering/node-rendering.js.map +1 -0
- package/dist/babylon/renderer/shadows/blob-shadow-shaders.d.ts +5 -0
- package/dist/babylon/renderer/shadows/blob-shadow-shaders.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/blob-shadow-shaders.js +46 -0
- package/dist/babylon/renderer/shadows/blob-shadow-shaders.js.map +1 -0
- package/dist/babylon/renderer/shadows/blob-shadow-system.d.ts +5 -0
- package/dist/babylon/renderer/shadows/blob-shadow-system.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/blob-shadow-system.js +402 -0
- package/dist/babylon/renderer/shadows/blob-shadow-system.js.map +1 -0
- package/dist/babylon/renderer/shadows/dynamic-shadow-system.d.ts +87 -0
- package/dist/babylon/renderer/shadows/dynamic-shadow-system.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/dynamic-shadow-system.js +659 -0
- package/dist/babylon/renderer/shadows/dynamic-shadow-system.js.map +1 -0
- package/dist/babylon/renderer/shadows/planar-shadow-shaders.d.ts +7 -0
- package/dist/babylon/renderer/shadows/planar-shadow-shaders.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/planar-shadow-shaders.js +316 -0
- package/dist/babylon/renderer/shadows/planar-shadow-shaders.js.map +1 -0
- package/dist/babylon/renderer/shadows/planar-shadow-system.d.ts +5 -0
- package/dist/babylon/renderer/shadows/planar-shadow-system.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/planar-shadow-system.js +1562 -0
- package/dist/babylon/renderer/shadows/planar-shadow-system.js.map +1 -0
- package/dist/babylon/renderer/shadows/shadow-generator-shaders.d.ts +14 -0
- package/dist/babylon/renderer/shadows/shadow-generator-shaders.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/shadow-generator-shaders.js +14 -0
- package/dist/babylon/renderer/shadows/shadow-generator-shaders.js.map +1 -0
- package/dist/babylon/renderer/shadows/shadow-map-experiment-depth-backend.d.ts +69 -0
- package/dist/babylon/renderer/shadows/shadow-map-experiment-depth-backend.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/shadow-map-experiment-depth-backend.js +847 -0
- package/dist/babylon/renderer/shadows/shadow-map-experiment-depth-backend.js.map +1 -0
- package/dist/babylon/renderer/shadows/shadow-map-experiment-system.d.ts +148 -0
- package/dist/babylon/renderer/shadows/shadow-map-experiment-system.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/shadow-map-experiment-system.js +4533 -0
- package/dist/babylon/renderer/shadows/shadow-map-experiment-system.js.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-artifact-system.d.ts +4 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-artifact-system.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-artifact-system.js +645 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-artifact-system.js.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-atlas.d.ts +61 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-atlas.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-atlas.js +382 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-atlas.js.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-bake.d.ts +47 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-bake.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-bake.js +285 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-bake.js.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-baker.d.ts +88 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-baker.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-baker.js +830 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-baker.js.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-options.d.ts +3 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-options.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-options.js +60 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-options.js.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-rendering.d.ts +27 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-rendering.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-rendering.js +220 -0
- package/dist/babylon/renderer/shadows/static-projected-shadow-rendering.js.map +1 -0
- package/dist/babylon/renderer/shadows/types.d.ts +421 -0
- package/dist/babylon/renderer/shadows/types.d.ts.map +1 -0
- package/dist/babylon/renderer/shadows/types.js +127 -0
- package/dist/babylon/renderer/shadows/types.js.map +1 -0
- package/dist/babylon/renderer/world-rendering-controller.d.ts +29 -0
- package/dist/babylon/renderer/world-rendering-controller.d.ts.map +1 -0
- package/dist/babylon/renderer/world-rendering-controller.js +183 -0
- package/dist/babylon/renderer/world-rendering-controller.js.map +1 -0
- package/dist/babylon/renderer-controller.d.ts +93 -0
- package/dist/babylon/renderer-controller.d.ts.map +1 -0
- package/dist/babylon/renderer-controller.js +706 -0
- package/dist/babylon/renderer-controller.js.map +1 -0
- package/dist/babylon/scene-renderer.d.ts +20 -0
- package/dist/babylon/scene-renderer.d.ts.map +1 -0
- package/dist/babylon/scene-renderer.js +58 -0
- package/dist/babylon/scene-renderer.js.map +1 -0
- package/dist/babylon.d.ts +7 -0
- package/dist/babylon.d.ts.map +1 -1
- package/dist/babylon.js +7 -0
- package/dist/babylon.js.map +1 -1
- package/dist/build-info.json +4 -4
- package/dist/camera.d.ts +25 -0
- package/dist/camera.d.ts.map +1 -0
- package/dist/camera.js +68 -0
- package/dist/camera.js.map +1 -0
- package/dist/compiled-scene-data.d.ts +23 -0
- package/dist/compiled-scene-data.d.ts.map +1 -0
- package/dist/compiled-scene-data.js +100 -0
- package/dist/compiled-scene-data.js.map +1 -0
- package/dist/config.d.ts +9 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +21 -0
- package/dist/config.js.map +1 -1
- package/dist/frame.d.ts +32 -0
- package/dist/frame.d.ts.map +1 -0
- package/dist/frame.js +54 -0
- package/dist/frame.js.map +1 -0
- package/dist/ground-decal.d.ts +22 -0
- package/dist/ground-decal.d.ts.map +1 -0
- package/dist/ground-decal.js +48 -0
- package/dist/ground-decal.js.map +1 -0
- package/dist/index.d.ts +16 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -1
- package/dist/lighting.d.ts +13 -5
- package/dist/lighting.d.ts.map +1 -1
- package/dist/lighting.js +11 -5
- package/dist/lighting.js.map +1 -1
- package/dist/material-owner.d.ts +141 -0
- package/dist/material-owner.d.ts.map +1 -0
- package/dist/material-owner.js +552 -0
- package/dist/material-owner.js.map +1 -0
- package/dist/material-profile.d.ts +62 -0
- package/dist/material-profile.d.ts.map +1 -0
- package/dist/material-profile.js +132 -0
- package/dist/material-profile.js.map +1 -0
- package/dist/rendering/index.d.ts +14 -0
- package/dist/rendering/index.d.ts.map +1 -0
- package/dist/rendering/index.js +12 -0
- package/dist/rendering/index.js.map +1 -0
- package/dist/rendering/rendering-profile-types.d.ts +322 -0
- package/dist/rendering/rendering-profile-types.d.ts.map +1 -0
- package/dist/rendering/rendering-profile-types.js +2 -0
- package/dist/rendering/rendering-profile-types.js.map +1 -0
- package/dist/rendering/rendering-profile-validation.d.ts +2 -0
- package/dist/rendering/rendering-profile-validation.d.ts.map +1 -0
- package/dist/rendering/rendering-profile-validation.js +364 -0
- package/dist/rendering/rendering-profile-validation.js.map +1 -0
- package/dist/rendering/rendering-profile-values.d.ts +19 -0
- package/dist/rendering/rendering-profile-values.d.ts.map +1 -0
- package/dist/rendering/rendering-profile-values.js +79 -0
- package/dist/rendering/rendering-profile-values.js.map +1 -0
- package/dist/rendering/rendering-profile.d.ts +15 -0
- package/dist/rendering/rendering-profile.d.ts.map +1 -0
- package/dist/rendering/rendering-profile.js +442 -0
- package/dist/rendering/rendering-profile.js.map +1 -0
- package/dist/rendering/shadow-map-experiment-depth.d.ts +63 -0
- package/dist/rendering/shadow-map-experiment-depth.d.ts.map +1 -0
- package/dist/rendering/shadow-map-experiment-depth.js +186 -0
- package/dist/rendering/shadow-map-experiment-depth.js.map +1 -0
- package/dist/rendering/shadow-map-experiment-lifecycle.d.ts +94 -0
- package/dist/rendering/shadow-map-experiment-lifecycle.d.ts.map +1 -0
- package/dist/rendering/shadow-map-experiment-lifecycle.js +407 -0
- package/dist/rendering/shadow-map-experiment-lifecycle.js.map +1 -0
- package/dist/rendering/shadow-map-experiment.d.ts +189 -0
- package/dist/rendering/shadow-map-experiment.d.ts.map +1 -0
- package/dist/rendering/shadow-map-experiment.js +549 -0
- package/dist/rendering/shadow-map-experiment.js.map +1 -0
- package/dist/rendering/shadow-quality.d.ts +5 -0
- package/dist/rendering/shadow-quality.d.ts.map +1 -0
- package/dist/rendering/shadow-quality.js +83 -0
- package/dist/rendering/shadow-quality.js.map +1 -0
- package/dist/rendering/shadow-runtime.d.ts +59 -0
- package/dist/rendering/shadow-runtime.d.ts.map +1 -0
- package/dist/rendering/shadow-runtime.js +378 -0
- package/dist/rendering/shadow-runtime.js.map +1 -0
- package/dist/rendering/shadow-settings.d.ts +15 -0
- package/dist/rendering/shadow-settings.d.ts.map +1 -0
- package/dist/rendering/shadow-settings.js +129 -0
- package/dist/rendering/shadow-settings.js.map +1 -0
- package/dist/rendering/shadow-types.d.ts +99 -0
- package/dist/rendering/shadow-types.d.ts.map +1 -0
- package/dist/rendering/shadow-types.js +5 -0
- package/dist/rendering/shadow-types.js.map +1 -0
- package/dist/rendering/shadow-validation.d.ts +3 -0
- package/dist/rendering/shadow-validation.d.ts.map +1 -0
- package/dist/rendering/shadow-validation.js +166 -0
- package/dist/rendering/shadow-validation.js.map +1 -0
- package/dist/rendering/value.d.ts +2 -0
- package/dist/rendering/value.d.ts.map +1 -0
- package/dist/rendering/value.js +6 -0
- package/dist/rendering/value.js.map +1 -0
- package/dist/runtime-data-token.d.ts +4 -0
- package/dist/runtime-data-token.d.ts.map +1 -0
- package/dist/runtime-data-token.js +4 -0
- package/dist/runtime-data-token.js.map +1 -0
- package/dist/runtime-data-types.d.ts +83 -0
- package/dist/runtime-data-types.d.ts.map +1 -0
- package/dist/runtime-data-types.js +2 -0
- package/dist/runtime-data-types.js.map +1 -0
- package/dist/runtime-data.d.ts +18 -0
- package/dist/runtime-data.d.ts.map +1 -0
- package/dist/runtime-data.js +301 -0
- package/dist/runtime-data.js.map +1 -0
- package/dist/runtime-scene-resolvers.d.ts +33 -0
- package/dist/runtime-scene-resolvers.d.ts.map +1 -0
- package/dist/runtime-scene-resolvers.js +36 -0
- package/dist/runtime-scene-resolvers.js.map +1 -0
- package/dist/scene-artifact-types.d.ts +385 -0
- package/dist/scene-artifact-types.d.ts.map +1 -0
- package/dist/scene-artifact-types.js +2 -0
- package/dist/scene-artifact-types.js.map +1 -0
- package/dist/scene-artifact-validation.d.ts +20 -0
- package/dist/scene-artifact-validation.d.ts.map +1 -0
- package/dist/scene-artifact-validation.js +1402 -0
- package/dist/scene-artifact-validation.js.map +1 -0
- package/dist/static-shadow-artifact.d.ts +131 -0
- package/dist/static-shadow-artifact.d.ts.map +1 -0
- package/dist/static-shadow-artifact.js +327 -0
- package/dist/static-shadow-artifact.js.map +1 -0
- package/package.json +51 -1
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
import { Color3 } from '@babylonjs/core/Maths/math.color.js';
|
|
2
|
+
import { Texture } from '@babylonjs/core/Materials/Textures/texture.js';
|
|
3
|
+
import { MaterialPluginBase } from '@babylonjs/core/Materials/materialPluginBase.js';
|
|
4
|
+
const ARTIST_BASE_TEXTURE_ADJUSTMENT_PLUGIN_KEY = '__fpsArtistBaseTextureAdjustmentPlugin';
|
|
5
|
+
const DEFAULT_BABYLON_MATERIAL_RUNTIME = { Color3, Texture, MaterialPluginBase };
|
|
6
|
+
function getBabylonRuntime(runtime) {
|
|
7
|
+
return runtime ?? DEFAULT_BABYLON_MATERIAL_RUNTIME;
|
|
8
|
+
}
|
|
9
|
+
function readRuntimeSubMaterials(material) {
|
|
10
|
+
if (!material || typeof material !== 'object' || !Array.isArray(material.subMaterials))
|
|
11
|
+
return null;
|
|
12
|
+
return material.subMaterials.filter((subMaterial) => (subMaterial && typeof subMaterial === 'object' && subMaterial !== material));
|
|
13
|
+
}
|
|
14
|
+
function isFiniteNumber(value) {
|
|
15
|
+
return typeof value === 'number' && Number.isFinite(value);
|
|
16
|
+
}
|
|
17
|
+
export function resolveMaterialRuntimeKind(material) {
|
|
18
|
+
if (!material || typeof material !== 'object')
|
|
19
|
+
return 'unknown';
|
|
20
|
+
const subMaterials = readRuntimeSubMaterials(material);
|
|
21
|
+
if (subMaterials?.length) {
|
|
22
|
+
const firstKnownKind = subMaterials
|
|
23
|
+
.map(resolveMaterialRuntimeKind)
|
|
24
|
+
.find(kind => kind !== 'unknown');
|
|
25
|
+
return firstKnownKind ?? 'unknown';
|
|
26
|
+
}
|
|
27
|
+
const className = typeof material.getClassName === 'function' ? material.getClassName() : '';
|
|
28
|
+
const normalizedClassName = typeof className === 'string' ? className.toLowerCase() : '';
|
|
29
|
+
if (normalizedClassName.includes('standardmaterial'))
|
|
30
|
+
return 'standard';
|
|
31
|
+
if (normalizedClassName.includes('pbr'))
|
|
32
|
+
return 'pbr';
|
|
33
|
+
if ('diffuseColor' in material || 'specularColor' in material || 'specularPower' in material)
|
|
34
|
+
return 'standard';
|
|
35
|
+
if ('albedoColor' in material
|
|
36
|
+
|| '_albedoColor' in material
|
|
37
|
+
|| 'reflectivityColor' in material
|
|
38
|
+
|| '_reflectivityColor' in material
|
|
39
|
+
|| 'microSurface' in material
|
|
40
|
+
|| '_microSurface' in material)
|
|
41
|
+
return 'pbr';
|
|
42
|
+
return 'unknown';
|
|
43
|
+
}
|
|
44
|
+
function resolveRuntimeMaterialProperty(material, path) {
|
|
45
|
+
switch (path) {
|
|
46
|
+
case 'material.albedoColor':
|
|
47
|
+
return 'albedoColor' in material ? 'albedoColor' : 'diffuseColor' in material ? 'diffuseColor' : null;
|
|
48
|
+
case 'material.emissiveColor':
|
|
49
|
+
return 'emissiveColor' in material ? 'emissiveColor' : null;
|
|
50
|
+
case 'material.metallic':
|
|
51
|
+
return 'metallic' in material ? 'metallic' : null;
|
|
52
|
+
case 'material.roughness':
|
|
53
|
+
return 'roughness' in material ? 'roughness' : null;
|
|
54
|
+
case 'material.alpha':
|
|
55
|
+
return 'alpha' in material ? 'alpha' : null;
|
|
56
|
+
case 'material.alphaCutOff':
|
|
57
|
+
return 'alphaCutOff' in material ? 'alphaCutOff' : null;
|
|
58
|
+
case 'material.transparencyMode':
|
|
59
|
+
return 'transparencyMode' in material ? 'transparencyMode' : null;
|
|
60
|
+
case 'material.backFaceCulling':
|
|
61
|
+
return 'backFaceCulling' in material ? 'backFaceCulling' : null;
|
|
62
|
+
case 'material.albedoTexture.url':
|
|
63
|
+
return 'albedoTexture' in material ? 'albedoTexture' : 'diffuseTexture' in material ? 'diffuseTexture' : null;
|
|
64
|
+
case 'material.normalTexture.url':
|
|
65
|
+
return 'normalTexture' in material ? 'normalTexture' : 'bumpTexture' in material ? 'bumpTexture' : null;
|
|
66
|
+
case 'material.normalTexture.level':
|
|
67
|
+
return 'normalTexture' in material ? 'normalTexture' : 'bumpTexture' in material ? 'bumpTexture' : null;
|
|
68
|
+
case 'material.metallicTexture.url':
|
|
69
|
+
return 'metallicTexture' in material ? 'metallicTexture' : null;
|
|
70
|
+
case 'material.occlusionTexture.url':
|
|
71
|
+
return 'ambientTexture' in material ? 'ambientTexture' : null;
|
|
72
|
+
case 'material.emissiveTexture.url':
|
|
73
|
+
return 'emissiveTexture' in material ? 'emissiveTexture' : null;
|
|
74
|
+
case 'material.opacityTexture.url':
|
|
75
|
+
return 'opacityTexture' in material ? 'opacityTexture' : null;
|
|
76
|
+
case 'material.pbr.albedoColor':
|
|
77
|
+
return '_albedoColor' in material ? '_albedoColor' : 'albedoColor' in material ? 'albedoColor' : null;
|
|
78
|
+
case 'material.pbr.baseWeight':
|
|
79
|
+
return '_baseWeight' in material ? '_baseWeight' : 'baseWeight' in material ? 'baseWeight' : null;
|
|
80
|
+
case 'material.pbr.reflectivityColor':
|
|
81
|
+
return '_reflectivityColor' in material ? '_reflectivityColor' : 'reflectivityColor' in material ? 'reflectivityColor' : null;
|
|
82
|
+
case 'material.pbr.microSurface':
|
|
83
|
+
return '_microSurface' in material ? '_microSurface' : 'microSurface' in material ? 'microSurface' : null;
|
|
84
|
+
case 'material.pbr.emissiveColor':
|
|
85
|
+
return '_emissiveColor' in material ? '_emissiveColor' : 'emissiveColor' in material ? 'emissiveColor' : null;
|
|
86
|
+
case 'material.pbr.emissiveIntensity':
|
|
87
|
+
return '_emissiveIntensity' in material ? '_emissiveIntensity' : 'emissiveIntensity' in material ? 'emissiveIntensity' : null;
|
|
88
|
+
case 'material.pbr.ambientColor':
|
|
89
|
+
return '_ambientColor' in material ? '_ambientColor' : 'ambientColor' in material ? 'ambientColor' : null;
|
|
90
|
+
case 'material.pbr.lightFalloff':
|
|
91
|
+
return '_lightFalloff' in material ? '_lightFalloff' : 'lightFalloff' in material ? 'lightFalloff' : null;
|
|
92
|
+
case 'material.standard.diffuseColor':
|
|
93
|
+
return 'diffuseColor' in material ? 'diffuseColor' : '_diffuseColor' in material ? '_diffuseColor' : null;
|
|
94
|
+
case 'material.standard.specularColor':
|
|
95
|
+
return 'specularColor' in material ? 'specularColor' : '_specularColor' in material ? '_specularColor' : null;
|
|
96
|
+
case 'material.standard.specularPower':
|
|
97
|
+
return 'specularPower' in material ? 'specularPower' : '_specularPower' in material ? '_specularPower' : null;
|
|
98
|
+
case 'material.standard.emissiveColor':
|
|
99
|
+
return 'emissiveColor' in material ? 'emissiveColor' : '_emissiveColor' in material ? '_emissiveColor' : null;
|
|
100
|
+
case 'material.standard.ambientColor':
|
|
101
|
+
return 'ambientColor' in material ? 'ambientColor' : '_ambientColor' in material ? '_ambientColor' : null;
|
|
102
|
+
case 'material.standard.useSpecularOverAlpha':
|
|
103
|
+
return 'useSpecularOverAlpha' in material ? 'useSpecularOverAlpha' : '_useSpecularOverAlpha' in material ? '_useSpecularOverAlpha' : null;
|
|
104
|
+
default:
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export function applyMaterialValueToRuntimeMaterial(material, scene, path, value, options = {}) {
|
|
109
|
+
const writableMaterial = material;
|
|
110
|
+
if (!writableMaterial || typeof writableMaterial !== 'object')
|
|
111
|
+
return false;
|
|
112
|
+
const subMaterials = readRuntimeSubMaterials(writableMaterial);
|
|
113
|
+
if (subMaterials?.length) {
|
|
114
|
+
let changed = false;
|
|
115
|
+
for (const subMaterial of new Set(subMaterials)) {
|
|
116
|
+
changed = applyMaterialValueToRuntimeMaterial(subMaterial, scene, path, value, options) || changed;
|
|
117
|
+
}
|
|
118
|
+
return changed;
|
|
119
|
+
}
|
|
120
|
+
const property = resolveRuntimeMaterialProperty(writableMaterial, path);
|
|
121
|
+
if (!property)
|
|
122
|
+
return false;
|
|
123
|
+
if (path === 'material.albedoColor'
|
|
124
|
+
|| path === 'material.emissiveColor'
|
|
125
|
+
|| path === 'material.pbr.albedoColor'
|
|
126
|
+
|| path === 'material.pbr.reflectivityColor'
|
|
127
|
+
|| path === 'material.pbr.emissiveColor'
|
|
128
|
+
|| path === 'material.pbr.ambientColor'
|
|
129
|
+
|| path === 'material.standard.diffuseColor'
|
|
130
|
+
|| path === 'material.standard.specularColor'
|
|
131
|
+
|| path === 'material.standard.emissiveColor'
|
|
132
|
+
|| path === 'material.standard.ambientColor') {
|
|
133
|
+
if (!value || typeof value !== 'object')
|
|
134
|
+
return false;
|
|
135
|
+
const color = value;
|
|
136
|
+
const target = writableMaterial[property];
|
|
137
|
+
if (target?.copyFromFloats) {
|
|
138
|
+
target.copyFromFloats(color.r, color.g, color.b);
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
const Color3 = getBabylonRuntime(options.babylon)?.Color3;
|
|
142
|
+
writableMaterial[property] = Color3 ? new Color3(color.r, color.g, color.b) : { r: color.r, g: color.g, b: color.b };
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
if (path === 'material.normalTexture.level') {
|
|
146
|
+
const texture = writableMaterial[property];
|
|
147
|
+
if (!texture || typeof texture !== 'object' || !('level' in texture))
|
|
148
|
+
return false;
|
|
149
|
+
texture.level = typeof value === 'number' && Number.isFinite(value) ? value : texture.level;
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
if (path === 'material.albedoTexture.url'
|
|
153
|
+
|| path === 'material.normalTexture.url'
|
|
154
|
+
|| path === 'material.metallicTexture.url'
|
|
155
|
+
|| path === 'material.occlusionTexture.url'
|
|
156
|
+
|| path === 'material.emissiveTexture.url'
|
|
157
|
+
|| path === 'material.opacityTexture.url') {
|
|
158
|
+
if (value == null) {
|
|
159
|
+
writableMaterial[property] = null;
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
if (typeof value !== 'string' || !scene)
|
|
163
|
+
return false;
|
|
164
|
+
const Texture = getBabylonRuntime(options.babylon)?.Texture;
|
|
165
|
+
if (!Texture)
|
|
166
|
+
return false;
|
|
167
|
+
writableMaterial[property] = new Texture(value, scene, false, false);
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
writableMaterial[property] = value;
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
export function applyArtistMaterialProfileToRuntimeMaterial(material, scene, profile, options = {}) {
|
|
174
|
+
const writableMaterial = material;
|
|
175
|
+
if (!writableMaterial || typeof writableMaterial !== 'object' || !profile)
|
|
176
|
+
return false;
|
|
177
|
+
const subMaterials = readRuntimeSubMaterials(writableMaterial);
|
|
178
|
+
if (subMaterials?.length) {
|
|
179
|
+
let changed = false;
|
|
180
|
+
for (const subMaterial of new Set(subMaterials)) {
|
|
181
|
+
changed = applyArtistMaterialProfileToRuntimeMaterial(subMaterial, scene, profile, options) || changed;
|
|
182
|
+
}
|
|
183
|
+
return changed;
|
|
184
|
+
}
|
|
185
|
+
let changed = false;
|
|
186
|
+
changed = applyArtistLightingModelProfile(writableMaterial, profile) || changed;
|
|
187
|
+
changed = applyArtistBaseColorProfile(writableMaterial, scene, profile, options) || changed;
|
|
188
|
+
changed = applyArtistNormalProfile(writableMaterial, scene, profile, options) || changed;
|
|
189
|
+
const materialRuntimeKind = resolveMaterialRuntimeKind(writableMaterial);
|
|
190
|
+
if (materialRuntimeKind === 'pbr' && isFiniteNumber(profile.metallic)) {
|
|
191
|
+
changed = applyMaterialValueToRuntimeMaterial(writableMaterial, scene, 'material.metallic', clamp01(profile.metallic), options) || changed;
|
|
192
|
+
}
|
|
193
|
+
if (materialRuntimeKind === 'pbr' && isFiniteNumber(profile.roughness)) {
|
|
194
|
+
changed = applyMaterialValueToRuntimeMaterial(writableMaterial, scene, 'material.roughness', clamp01(profile.roughness), options) || changed;
|
|
195
|
+
}
|
|
196
|
+
if (materialRuntimeKind === 'pbr') {
|
|
197
|
+
changed = applyArtistPbrTextureProfiles(writableMaterial, scene, profile, options) || changed;
|
|
198
|
+
}
|
|
199
|
+
changed = applyArtistEmissionProfile(writableMaterial, scene, profile, options) || changed;
|
|
200
|
+
changed = applyArtistAlphaProfile(writableMaterial, scene, profile, options) || changed;
|
|
201
|
+
if (changed)
|
|
202
|
+
markRuntimeMaterialDirty(writableMaterial);
|
|
203
|
+
return changed;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Applies only the lightweight runtime value represented by one artist profile
|
|
207
|
+
* path. Texture ownership and shader-structure changes deliberately return
|
|
208
|
+
* false so callers can fall back to the full profile transaction.
|
|
209
|
+
*/
|
|
210
|
+
export function applyArtistMaterialProfileValueToRuntimeMaterial(material, scene, path, profile, options = {}) {
|
|
211
|
+
const writableMaterial = material;
|
|
212
|
+
if (!writableMaterial || typeof writableMaterial !== 'object' || !profile)
|
|
213
|
+
return false;
|
|
214
|
+
const subMaterials = readRuntimeSubMaterials(writableMaterial);
|
|
215
|
+
if (subMaterials?.length) {
|
|
216
|
+
let changed = false;
|
|
217
|
+
for (const subMaterial of new Set(subMaterials)) {
|
|
218
|
+
changed = applyArtistMaterialProfileValueToRuntimeMaterial(subMaterial, scene, path, profile, options) || changed;
|
|
219
|
+
}
|
|
220
|
+
return changed;
|
|
221
|
+
}
|
|
222
|
+
if (path === 'material.baseColor.color') {
|
|
223
|
+
const color = readProfileColor(profile.baseColor?.color);
|
|
224
|
+
return color
|
|
225
|
+
? applyMaterialValueToRuntimeMaterial(writableMaterial, scene, 'material.albedoColor', color, options)
|
|
226
|
+
: false;
|
|
227
|
+
}
|
|
228
|
+
if (path === 'material.baseColor.brightness'
|
|
229
|
+
|| path === 'material.baseColor.saturation'
|
|
230
|
+
|| path === 'material.baseColor.contrast'
|
|
231
|
+
|| path === 'material.baseColor.hue') {
|
|
232
|
+
return profile.baseColor
|
|
233
|
+
? applyArtistBaseTextureAdjustmentPipeline(writableMaterial, profile.baseColor, hasRuntimeBaseTexture(writableMaterial), options)
|
|
234
|
+
: false;
|
|
235
|
+
}
|
|
236
|
+
if (path === 'material.normal.strength') {
|
|
237
|
+
return isFiniteNumber(profile.normal?.strength)
|
|
238
|
+
? applyMaterialValueToRuntimeMaterial(writableMaterial, scene, 'material.normalTexture.level', Math.max(0, profile.normal.strength), options)
|
|
239
|
+
: false;
|
|
240
|
+
}
|
|
241
|
+
if (path === 'material.metallic') {
|
|
242
|
+
return resolveMaterialRuntimeKind(writableMaterial) === 'pbr' && isFiniteNumber(profile.metallic)
|
|
243
|
+
? applyMaterialValueToRuntimeMaterial(writableMaterial, scene, 'material.metallic', clamp01(profile.metallic), options)
|
|
244
|
+
: false;
|
|
245
|
+
}
|
|
246
|
+
if (path === 'material.roughness') {
|
|
247
|
+
return resolveMaterialRuntimeKind(writableMaterial) === 'pbr' && isFiniteNumber(profile.roughness)
|
|
248
|
+
? applyMaterialValueToRuntimeMaterial(writableMaterial, scene, 'material.roughness', clamp01(profile.roughness), options)
|
|
249
|
+
: false;
|
|
250
|
+
}
|
|
251
|
+
if (path === 'material.occlusion.strength') {
|
|
252
|
+
if (!isFiniteNumber(profile.occlusion?.strength) || !('ambientTextureStrength' in writableMaterial)) {
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
writableMaterial.ambientTextureStrength = Math.max(0, profile.occlusion.strength);
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
if (path === 'material.emission.color' || path === 'material.emission.intensity') {
|
|
259
|
+
return applyArtistEmissionValues(writableMaterial, scene, profile, options);
|
|
260
|
+
}
|
|
261
|
+
if (path === 'material.alpha.opacity') {
|
|
262
|
+
return isFiniteNumber(profile.alpha?.opacity)
|
|
263
|
+
? applyMaterialValueToRuntimeMaterial(writableMaterial, scene, 'material.alpha', clamp01(profile.alpha.opacity), options)
|
|
264
|
+
: false;
|
|
265
|
+
}
|
|
266
|
+
if (path === 'material.alpha.cutoff') {
|
|
267
|
+
return isFiniteNumber(profile.alpha?.cutoff)
|
|
268
|
+
? applyMaterialValueToRuntimeMaterial(writableMaterial, scene, 'material.alphaCutOff', clamp01(profile.alpha.cutoff), options)
|
|
269
|
+
: false;
|
|
270
|
+
}
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
function applyArtistLightingModelProfile(material, profile) {
|
|
274
|
+
if (profile.lightingModel !== 'lit' && profile.lightingModel !== 'unlit')
|
|
275
|
+
return false;
|
|
276
|
+
const unlit = profile.lightingModel === 'unlit';
|
|
277
|
+
let changed = false;
|
|
278
|
+
if ('unlit' in material && material.unlit !== unlit) {
|
|
279
|
+
material.unlit = unlit;
|
|
280
|
+
changed = true;
|
|
281
|
+
}
|
|
282
|
+
if ('disableLighting' in material && material.disableLighting !== unlit) {
|
|
283
|
+
material.disableLighting = unlit;
|
|
284
|
+
changed = true;
|
|
285
|
+
}
|
|
286
|
+
return changed;
|
|
287
|
+
}
|
|
288
|
+
function applyArtistBaseColorProfile(material, scene, profile, options) {
|
|
289
|
+
const baseColor = profile.baseColor;
|
|
290
|
+
if (!baseColor)
|
|
291
|
+
return false;
|
|
292
|
+
const hasTextureField = hasProfileTextureField(baseColor, 'texture');
|
|
293
|
+
const hasBaseColorInput = baseColor.color !== undefined
|
|
294
|
+
|| hasTextureField
|
|
295
|
+
|| baseColor.brightness !== undefined
|
|
296
|
+
|| baseColor.saturation !== undefined
|
|
297
|
+
|| baseColor.contrast !== undefined
|
|
298
|
+
|| baseColor.hue !== undefined;
|
|
299
|
+
if (!hasBaseColorInput)
|
|
300
|
+
return false;
|
|
301
|
+
let changed = false;
|
|
302
|
+
const textureUrl = readTextureUrl(baseColor.texture, options);
|
|
303
|
+
if (textureUrl || hasTextureField) {
|
|
304
|
+
changed = applyMaterialValueToRuntimeMaterial(material, scene, 'material.albedoTexture.url', textureUrl ?? null, options) || changed;
|
|
305
|
+
}
|
|
306
|
+
const hasBaseTexture = textureUrl
|
|
307
|
+
? true
|
|
308
|
+
: hasTextureField
|
|
309
|
+
? false
|
|
310
|
+
: hasRuntimeBaseTexture(material);
|
|
311
|
+
changed = applyArtistBaseTextureAdjustmentPipeline(material, baseColor, hasBaseTexture, options) || changed;
|
|
312
|
+
const sourceColor = readProfileColor(baseColor.color);
|
|
313
|
+
if (!sourceColor)
|
|
314
|
+
return changed;
|
|
315
|
+
return applyMaterialValueToRuntimeMaterial(material, scene, 'material.albedoColor', sourceColor, options) || changed;
|
|
316
|
+
}
|
|
317
|
+
function applyArtistBaseTextureAdjustmentPipeline(material, baseColor, hasBaseTexture, options) {
|
|
318
|
+
const adjustment = resolveArtistBaseTextureAdjustment(baseColor, hasBaseTexture);
|
|
319
|
+
const existingPlugin = readArtistBaseTextureAdjustmentPlugin(material);
|
|
320
|
+
if (!adjustment.enabled) {
|
|
321
|
+
existingPlugin?.updateAdjustment?.(adjustment);
|
|
322
|
+
existingPlugin?.setEnabled?.(false);
|
|
323
|
+
return !!existingPlugin;
|
|
324
|
+
}
|
|
325
|
+
const plugin = existingPlugin ?? createArtistBaseTextureAdjustmentPlugin(material, options);
|
|
326
|
+
if (!plugin)
|
|
327
|
+
return false;
|
|
328
|
+
plugin.updateAdjustment?.(adjustment);
|
|
329
|
+
plugin.setEnabled?.(true);
|
|
330
|
+
return true;
|
|
331
|
+
}
|
|
332
|
+
function resolveArtistBaseTextureAdjustment(baseColor, hasBaseTexture) {
|
|
333
|
+
const brightness = isFiniteNumber(baseColor.brightness) ? Math.max(0, baseColor.brightness) : 1;
|
|
334
|
+
const contrast = isFiniteNumber(baseColor.contrast) ? baseColor.contrast : 1;
|
|
335
|
+
const saturation = isFiniteNumber(baseColor.saturation) ? Math.max(0, baseColor.saturation) : 1;
|
|
336
|
+
const hue = isFiniteNumber(baseColor.hue) ? baseColor.hue : 0;
|
|
337
|
+
const enabled = hasBaseTexture && (Math.abs(brightness - 1) > 1e-6
|
|
338
|
+
|| Math.abs(contrast - 1) > 1e-6
|
|
339
|
+
|| Math.abs(saturation - 1) > 1e-6
|
|
340
|
+
|| Math.abs(hue) > 1e-6);
|
|
341
|
+
return { enabled, brightness, saturation, contrast, hue };
|
|
342
|
+
}
|
|
343
|
+
function readArtistBaseTextureAdjustmentPlugin(material) {
|
|
344
|
+
const plugin = material?.[ARTIST_BASE_TEXTURE_ADJUSTMENT_PLUGIN_KEY];
|
|
345
|
+
return plugin && typeof plugin === 'object' ? plugin : null;
|
|
346
|
+
}
|
|
347
|
+
function hasRuntimeBaseTexture(material) {
|
|
348
|
+
const property = resolveRuntimeMaterialProperty(material, 'material.albedoTexture.url');
|
|
349
|
+
return !!(property && material?.[property]);
|
|
350
|
+
}
|
|
351
|
+
function hasProfileTextureField(owner, key) {
|
|
352
|
+
return !!owner && typeof owner === 'object' && Object.prototype.hasOwnProperty.call(owner, key);
|
|
353
|
+
}
|
|
354
|
+
function createArtistBaseTextureAdjustmentPlugin(material, options) {
|
|
355
|
+
const MaterialPluginBase = getBabylonRuntime(options.babylon)?.MaterialPluginBase;
|
|
356
|
+
if (typeof MaterialPluginBase !== 'function' || !material || typeof material !== 'object')
|
|
357
|
+
return null;
|
|
358
|
+
const baseTextureProperty = resolveRuntimeMaterialProperty(material, 'material.albedoTexture.url');
|
|
359
|
+
class ArtistBaseTextureAdjustmentPluginRuntime extends MaterialPluginBase {
|
|
360
|
+
adjustment = {
|
|
361
|
+
enabled: false,
|
|
362
|
+
brightness: 1,
|
|
363
|
+
saturation: 1,
|
|
364
|
+
contrast: 1,
|
|
365
|
+
hue: 0,
|
|
366
|
+
};
|
|
367
|
+
constructor(targetMaterial) {
|
|
368
|
+
super(targetMaterial, 'FpsArtistBaseTextureAdjustment', 210, undefined, true, true);
|
|
369
|
+
this.doNotSerialize = true;
|
|
370
|
+
}
|
|
371
|
+
getClassName() {
|
|
372
|
+
return 'FpsArtistBaseTextureAdjustment';
|
|
373
|
+
}
|
|
374
|
+
updateAdjustment(adjustment) {
|
|
375
|
+
this.adjustment = adjustment;
|
|
376
|
+
}
|
|
377
|
+
setEnabled(enabled) {
|
|
378
|
+
this.adjustment = { ...this.adjustment, enabled };
|
|
379
|
+
}
|
|
380
|
+
getUniforms() {
|
|
381
|
+
return {
|
|
382
|
+
externalUniforms: [
|
|
383
|
+
'fpsArtistBaseTextureAdjust',
|
|
384
|
+
'fpsArtistBaseTextureAdjustEnabled',
|
|
385
|
+
],
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
bindForSubMesh(uniformBuffer) {
|
|
389
|
+
const effect = uniformBuffer?.currentEffect;
|
|
390
|
+
effect?.setFloat4?.('fpsArtistBaseTextureAdjust', this.adjustment.brightness, this.adjustment.saturation, this.adjustment.contrast, this.adjustment.hue);
|
|
391
|
+
effect?.setFloat?.('fpsArtistBaseTextureAdjustEnabled', this.adjustment.enabled ? 1 : 0);
|
|
392
|
+
}
|
|
393
|
+
getCustomCode(shaderType) {
|
|
394
|
+
if (shaderType !== 'fragment')
|
|
395
|
+
return null;
|
|
396
|
+
const customCode = {
|
|
397
|
+
CUSTOM_FRAGMENT_DEFINITIONS: ARTIST_BASE_TEXTURE_ADJUSTMENT_GLSL,
|
|
398
|
+
};
|
|
399
|
+
if (baseTextureProperty === 'albedoTexture') {
|
|
400
|
+
customCode.CUSTOM_FRAGMENT_BEFORE_LIGHTS = `
|
|
401
|
+
if (fpsArtistBaseTextureAdjustEnabled > 0.5) {
|
|
402
|
+
surfaceAlbedo = fpsArtistAdjustBaseTextureColor(surfaceAlbedo, fpsArtistBaseTextureAdjust);
|
|
403
|
+
}`;
|
|
404
|
+
}
|
|
405
|
+
else if (baseTextureProperty === 'diffuseTexture') {
|
|
406
|
+
customCode.CUSTOM_FRAGMENT_UPDATE_DIFFUSE = `
|
|
407
|
+
if (fpsArtistBaseTextureAdjustEnabled > 0.5) {
|
|
408
|
+
baseColor.rgb = fpsArtistAdjustBaseTextureColor(baseColor.rgb, fpsArtistBaseTextureAdjust);
|
|
409
|
+
}`;
|
|
410
|
+
}
|
|
411
|
+
return customCode;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
const plugin = new ArtistBaseTextureAdjustmentPluginRuntime(material);
|
|
415
|
+
material[ARTIST_BASE_TEXTURE_ADJUSTMENT_PLUGIN_KEY] = plugin;
|
|
416
|
+
return plugin;
|
|
417
|
+
}
|
|
418
|
+
const ARTIST_BASE_TEXTURE_ADJUSTMENT_GLSL = `
|
|
419
|
+
uniform vec4 fpsArtistBaseTextureAdjust;
|
|
420
|
+
uniform float fpsArtistBaseTextureAdjustEnabled;
|
|
421
|
+
|
|
422
|
+
vec3 fpsArtistRgbToHsl(vec3 color) {
|
|
423
|
+
float maxChannel = max(max(color.r, color.g), color.b);
|
|
424
|
+
float minChannel = min(min(color.r, color.g), color.b);
|
|
425
|
+
float lightness = (maxChannel + minChannel) * 0.5;
|
|
426
|
+
if (maxChannel == minChannel) {
|
|
427
|
+
return vec3(0.0, 0.0, lightness);
|
|
428
|
+
}
|
|
429
|
+
float delta = maxChannel - minChannel;
|
|
430
|
+
float saturation = lightness > 0.5 ? delta / (2.0 - maxChannel - minChannel) : delta / (maxChannel + minChannel);
|
|
431
|
+
float hue = 0.0;
|
|
432
|
+
if (maxChannel == color.r) {
|
|
433
|
+
hue = (color.g - color.b) / delta + (color.g < color.b ? 6.0 : 0.0);
|
|
434
|
+
} else if (maxChannel == color.g) {
|
|
435
|
+
hue = (color.b - color.r) / delta + 2.0;
|
|
436
|
+
} else {
|
|
437
|
+
hue = (color.r - color.g) / delta + 4.0;
|
|
438
|
+
}
|
|
439
|
+
return vec3(hue / 6.0, saturation, lightness);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
float fpsArtistHueToRgb(float p, float q, float t) {
|
|
443
|
+
if (t < 0.0) t += 1.0;
|
|
444
|
+
if (t > 1.0) t -= 1.0;
|
|
445
|
+
if (t < 1.0 / 6.0) return p + (q - p) * 6.0 * t;
|
|
446
|
+
if (t < 1.0 / 2.0) return q;
|
|
447
|
+
if (t < 2.0 / 3.0) return p + (q - p) * (2.0 / 3.0 - t) * 6.0;
|
|
448
|
+
return p;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
vec3 fpsArtistHslToRgb(vec3 hsl) {
|
|
452
|
+
if (hsl.y == 0.0) return vec3(hsl.z);
|
|
453
|
+
float q = hsl.z < 0.5 ? hsl.z * (1.0 + hsl.y) : hsl.z + hsl.y - hsl.z * hsl.y;
|
|
454
|
+
float p = 2.0 * hsl.z - q;
|
|
455
|
+
return vec3(
|
|
456
|
+
fpsArtistHueToRgb(p, q, hsl.x + 1.0 / 3.0),
|
|
457
|
+
fpsArtistHueToRgb(p, q, hsl.x),
|
|
458
|
+
fpsArtistHueToRgb(p, q, hsl.x - 1.0 / 3.0)
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
vec3 fpsArtistAdjustBaseTextureColor(vec3 color, vec4 adjustment) {
|
|
463
|
+
vec3 adjusted = clamp(color * max(adjustment.x, 0.0), 0.0, 1.0);
|
|
464
|
+
adjusted = clamp((adjusted - vec3(0.5)) * adjustment.z + vec3(0.5), 0.0, 1.0);
|
|
465
|
+
vec3 hsl = fpsArtistRgbToHsl(adjusted);
|
|
466
|
+
hsl.x = fract(hsl.x + adjustment.w / 360.0);
|
|
467
|
+
hsl.y = clamp(hsl.y * max(adjustment.y, 0.0), 0.0, 1.0);
|
|
468
|
+
return fpsArtistHslToRgb(hsl);
|
|
469
|
+
}
|
|
470
|
+
`;
|
|
471
|
+
function applyArtistNormalProfile(material, scene, profile, options) {
|
|
472
|
+
const normal = profile.normal;
|
|
473
|
+
if (!normal)
|
|
474
|
+
return false;
|
|
475
|
+
let changed = false;
|
|
476
|
+
const hasTextureField = hasProfileTextureField(normal, 'texture');
|
|
477
|
+
const textureUrl = readTextureUrl(normal.texture, options);
|
|
478
|
+
if (textureUrl || hasTextureField) {
|
|
479
|
+
changed = applyMaterialValueToRuntimeMaterial(material, scene, 'material.normalTexture.url', textureUrl ?? null, options) || changed;
|
|
480
|
+
}
|
|
481
|
+
if (isFiniteNumber(normal.strength)) {
|
|
482
|
+
changed = applyMaterialValueToRuntimeMaterial(material, scene, 'material.normalTexture.level', Math.max(0, normal.strength), options) || changed;
|
|
483
|
+
}
|
|
484
|
+
return changed;
|
|
485
|
+
}
|
|
486
|
+
function applyArtistPbrTextureProfiles(material, scene, profile, options) {
|
|
487
|
+
let changed = false;
|
|
488
|
+
const metallicRoughness = profile.metallicRoughness;
|
|
489
|
+
const hasMetallicRoughnessTextureField = hasProfileTextureField(metallicRoughness, 'texture');
|
|
490
|
+
const metallicRoughnessUrl = readTextureUrl(profile.metallicRoughness?.texture, options);
|
|
491
|
+
if (metallicRoughnessUrl || hasMetallicRoughnessTextureField) {
|
|
492
|
+
changed = applyMaterialValueToRuntimeMaterial(material, scene, 'material.metallicTexture.url', metallicRoughnessUrl ?? null, options) || changed;
|
|
493
|
+
if (metallicRoughnessUrl) {
|
|
494
|
+
changed = applyBabylonPbrMetallicRoughnessTextureConventions(material) || changed;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
const occlusion = profile.occlusion;
|
|
498
|
+
const hasOcclusionTextureField = hasProfileTextureField(occlusion, 'texture');
|
|
499
|
+
const occlusionUrl = readTextureUrl(profile.occlusion?.texture, options);
|
|
500
|
+
const hasOcclusionInput = !!occlusion && typeof occlusion === 'object' && (hasOcclusionTextureField
|
|
501
|
+
|| occlusionUrl != null
|
|
502
|
+
|| occlusion.strength !== undefined);
|
|
503
|
+
if (hasOcclusionInput) {
|
|
504
|
+
changed = applyMaterialValueToRuntimeMaterial(material, scene, 'material.occlusionTexture.url', occlusionUrl ?? null, options) || changed;
|
|
505
|
+
changed = disableBabylonPbrMetallicRoughnessAmbientOcclusion(material) || changed;
|
|
506
|
+
}
|
|
507
|
+
const occlusionStrength = profile.occlusion?.strength;
|
|
508
|
+
if (isFiniteNumber(occlusionStrength) && 'ambientTextureStrength' in material) {
|
|
509
|
+
material.ambientTextureStrength = Math.max(0, occlusionStrength);
|
|
510
|
+
changed = true;
|
|
511
|
+
}
|
|
512
|
+
return changed;
|
|
513
|
+
}
|
|
514
|
+
function applyArtistEmissionProfile(material, scene, profile, options) {
|
|
515
|
+
const emission = profile.emission;
|
|
516
|
+
if (!emission)
|
|
517
|
+
return false;
|
|
518
|
+
let changed = applyArtistEmissionValues(material, scene, profile, options);
|
|
519
|
+
const materialRuntimeKind = resolveMaterialRuntimeKind(material);
|
|
520
|
+
const canWritePbrEmissiveIntensity = materialRuntimeKind === 'pbr'
|
|
521
|
+
&& resolveRuntimeMaterialProperty(material, 'material.pbr.emissiveIntensity') != null;
|
|
522
|
+
const intensity = isFiniteNumber(emission.intensity) ? Math.max(0, emission.intensity) : null;
|
|
523
|
+
const hasTextureField = hasProfileTextureField(emission, 'texture');
|
|
524
|
+
const hasMaskTextureField = hasProfileTextureField(emission, 'maskTexture');
|
|
525
|
+
const textureUrl = readTextureUrl(emission.texture, options) ?? readTextureUrl(emission.maskTexture, options);
|
|
526
|
+
if (textureUrl || hasTextureField || hasMaskTextureField) {
|
|
527
|
+
changed = applyMaterialValueToRuntimeMaterial(material, scene, 'material.emissiveTexture.url', textureUrl ?? null, options) || changed;
|
|
528
|
+
if (textureUrl
|
|
529
|
+
&& !canWritePbrEmissiveIntensity
|
|
530
|
+
&& material.emissiveTexture
|
|
531
|
+
&& 'level' in material.emissiveTexture) {
|
|
532
|
+
material.emissiveTexture.level = intensity ?? 0;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
return changed;
|
|
536
|
+
}
|
|
537
|
+
function applyArtistEmissionValues(material, scene, profile, options) {
|
|
538
|
+
const emission = profile.emission;
|
|
539
|
+
if (!emission || (emission.color === undefined && emission.intensity === undefined))
|
|
540
|
+
return false;
|
|
541
|
+
const materialRuntimeKind = resolveMaterialRuntimeKind(material);
|
|
542
|
+
const canWritePbrEmissiveIntensity = materialRuntimeKind === 'pbr'
|
|
543
|
+
&& resolveRuntimeMaterialProperty(material, 'material.pbr.emissiveIntensity') != null;
|
|
544
|
+
const intensity = isFiniteNumber(emission.intensity) ? Math.max(0, emission.intensity) : null;
|
|
545
|
+
const color = readProfileColor(emission.color);
|
|
546
|
+
let changed = false;
|
|
547
|
+
if (canWritePbrEmissiveIntensity) {
|
|
548
|
+
if (color) {
|
|
549
|
+
changed = applyMaterialValueToRuntimeMaterial(material, scene, 'material.pbr.emissiveColor', color, options) || changed;
|
|
550
|
+
}
|
|
551
|
+
if (intensity != null) {
|
|
552
|
+
changed = applyMaterialValueToRuntimeMaterial(material, scene, 'material.pbr.emissiveIntensity', intensity, options) || changed;
|
|
553
|
+
}
|
|
554
|
+
return changed;
|
|
555
|
+
}
|
|
556
|
+
const fallbackIntensity = intensity ?? 0;
|
|
557
|
+
const fallbackColor = color
|
|
558
|
+
?? readMaterialColor(material, 'emissiveColor')
|
|
559
|
+
?? { r: 1, g: 1, b: 1 };
|
|
560
|
+
return applyMaterialValueToRuntimeMaterial(material, scene, 'material.emissiveColor', {
|
|
561
|
+
r: fallbackColor.r * fallbackIntensity,
|
|
562
|
+
g: fallbackColor.g * fallbackIntensity,
|
|
563
|
+
b: fallbackColor.b * fallbackIntensity,
|
|
564
|
+
}, options);
|
|
565
|
+
}
|
|
566
|
+
function applyArtistAlphaProfile(material, scene, profile, options) {
|
|
567
|
+
const alpha = profile.alpha;
|
|
568
|
+
if (!alpha)
|
|
569
|
+
return false;
|
|
570
|
+
let changed = false;
|
|
571
|
+
const transparencyMode = resolveBabylonTransparencyMode(alpha.mode);
|
|
572
|
+
if (transparencyMode != null) {
|
|
573
|
+
changed = applyMaterialValueToRuntimeMaterial(material, scene, 'material.transparencyMode', transparencyMode, options) || changed;
|
|
574
|
+
}
|
|
575
|
+
if (isFiniteNumber(alpha.opacity)) {
|
|
576
|
+
changed = applyMaterialValueToRuntimeMaterial(material, scene, 'material.alpha', clamp01(alpha.opacity), options) || changed;
|
|
577
|
+
}
|
|
578
|
+
if (isFiniteNumber(alpha.cutoff)) {
|
|
579
|
+
changed = applyMaterialValueToRuntimeMaterial(material, scene, 'material.alphaCutOff', clamp01(alpha.cutoff), options) || changed;
|
|
580
|
+
}
|
|
581
|
+
const hasTextureField = hasProfileTextureField(alpha, 'texture');
|
|
582
|
+
const textureUrl = readTextureUrl(alpha.texture, options);
|
|
583
|
+
if (textureUrl || hasTextureField) {
|
|
584
|
+
changed = applyMaterialValueToRuntimeMaterial(material, scene, 'material.opacityTexture.url', textureUrl ?? null, options) || changed;
|
|
585
|
+
}
|
|
586
|
+
return changed;
|
|
587
|
+
}
|
|
588
|
+
function readTextureUrl(texture, options) {
|
|
589
|
+
if (!texture || typeof texture !== 'object')
|
|
590
|
+
return null;
|
|
591
|
+
const resolved = options.resolveTextureUrl?.(texture);
|
|
592
|
+
if (typeof resolved === 'string' && resolved.trim())
|
|
593
|
+
return resolved.trim();
|
|
594
|
+
return typeof texture.url === 'string' && texture.url.trim() ? texture.url.trim() : null;
|
|
595
|
+
}
|
|
596
|
+
function resolveBabylonTransparencyMode(mode) {
|
|
597
|
+
if (mode === 'opaque')
|
|
598
|
+
return 0;
|
|
599
|
+
if (mode === 'mask')
|
|
600
|
+
return 1;
|
|
601
|
+
if (mode === 'blend')
|
|
602
|
+
return 2;
|
|
603
|
+
return null;
|
|
604
|
+
}
|
|
605
|
+
function applyBabylonPbrMetallicRoughnessTextureConventions(material) {
|
|
606
|
+
let changed = false;
|
|
607
|
+
if ('useMetallnessFromMetallicTextureBlue' in material && material.useMetallnessFromMetallicTextureBlue !== true) {
|
|
608
|
+
material.useMetallnessFromMetallicTextureBlue = true;
|
|
609
|
+
changed = true;
|
|
610
|
+
}
|
|
611
|
+
if ('useRoughnessFromMetallicTextureGreen' in material && material.useRoughnessFromMetallicTextureGreen !== true) {
|
|
612
|
+
material.useRoughnessFromMetallicTextureGreen = true;
|
|
613
|
+
changed = true;
|
|
614
|
+
}
|
|
615
|
+
if ('useRoughnessFromMetallicTextureAlpha' in material && material.useRoughnessFromMetallicTextureAlpha !== false) {
|
|
616
|
+
material.useRoughnessFromMetallicTextureAlpha = false;
|
|
617
|
+
changed = true;
|
|
618
|
+
}
|
|
619
|
+
return disableBabylonPbrMetallicRoughnessAmbientOcclusion(material) || changed;
|
|
620
|
+
}
|
|
621
|
+
function disableBabylonPbrMetallicRoughnessAmbientOcclusion(material) {
|
|
622
|
+
if (!material || typeof material !== 'object')
|
|
623
|
+
return false;
|
|
624
|
+
if (!('useAmbientOcclusionFromMetallicTextureRed' in material))
|
|
625
|
+
return false;
|
|
626
|
+
if (material.useAmbientOcclusionFromMetallicTextureRed === false)
|
|
627
|
+
return false;
|
|
628
|
+
material.useAmbientOcclusionFromMetallicTextureRed = false;
|
|
629
|
+
return true;
|
|
630
|
+
}
|
|
631
|
+
function markRuntimeMaterialDirty(material) {
|
|
632
|
+
if (!material || typeof material !== 'object')
|
|
633
|
+
return;
|
|
634
|
+
if (material.getScene?.()?.blockMaterialDirtyMechanism === true)
|
|
635
|
+
return;
|
|
636
|
+
material.markDirty?.();
|
|
637
|
+
}
|
|
638
|
+
function readProfileColor(color) {
|
|
639
|
+
if (!color || !isFiniteNumber(color.r) || !isFiniteNumber(color.g) || !isFiniteNumber(color.b))
|
|
640
|
+
return null;
|
|
641
|
+
return { r: color.r, g: color.g, b: color.b };
|
|
642
|
+
}
|
|
643
|
+
function readMaterialColor(material, property) {
|
|
644
|
+
const value = material?.[property];
|
|
645
|
+
if (!value || typeof value !== 'object')
|
|
646
|
+
return null;
|
|
647
|
+
const r = isFiniteNumber(value.r) ? value.r : isFiniteNumber(value._r) ? value._r : null;
|
|
648
|
+
const g = isFiniteNumber(value.g) ? value.g : isFiniteNumber(value._g) ? value._g : null;
|
|
649
|
+
const b = isFiniteNumber(value.b) ? value.b : isFiniteNumber(value._b) ? value._b : null;
|
|
650
|
+
if (r == null || g == null || b == null)
|
|
651
|
+
return null;
|
|
652
|
+
return { r, g, b };
|
|
653
|
+
}
|
|
654
|
+
function clamp01(value) {
|
|
655
|
+
return Math.min(1, Math.max(0, value));
|
|
656
|
+
}
|
|
657
|
+
export function applyMaterialValueToRuntimeNode(ownerNode, scene, path, value, options = {}) {
|
|
658
|
+
return applyMaterialValueToRuntimeMaterial(ownerNode?.material, scene, path, value, options);
|
|
659
|
+
}
|
|
660
|
+
//# sourceMappingURL=material-runtime.js.map
|