@babylonjs/serializers 9.13.0 → 9.14.0
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/3MF/core/model/pure.d.ts +8 -0
- package/3MF/core/model/pure.js +9 -0
- package/3MF/core/model/pure.js.map +1 -0
- package/3MF/core/pure.d.ts +3 -0
- package/3MF/core/pure.js +5 -0
- package/3MF/core/pure.js.map +1 -0
- package/3MF/core/xml/pure.d.ts +7 -0
- package/3MF/core/xml/pure.js +8 -0
- package/3MF/core/xml/pure.js.map +1 -0
- package/3MF/pure.d.ts +4 -0
- package/3MF/pure.js +6 -0
- package/3MF/pure.js.map +1 -0
- package/BVH/pure.d.ts +2 -0
- package/BVH/pure.js +3 -0
- package/BVH/pure.js.map +1 -0
- package/OBJ/pure.d.ts +2 -0
- package/OBJ/pure.js +3 -0
- package/OBJ/pure.js.map +1 -0
- package/USDZ/pure.d.ts +2 -0
- package/USDZ/pure.js +4 -0
- package/USDZ/pure.js.map +1 -0
- package/glTF/2.0/Extensions/EXT_lights_area.d.ts +3 -37
- package/glTF/2.0/Extensions/EXT_lights_area.js +5 -130
- package/glTF/2.0/Extensions/EXT_lights_area.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_lights_area.pure.d.ts +44 -0
- package/glTF/2.0/Extensions/EXT_lights_area.pure.js +145 -0
- package/glTF/2.0/Extensions/EXT_lights_area.pure.js.map +1 -0
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +4 -38
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +6 -138
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.pure.d.ts +44 -0
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.pure.js +151 -0
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.pure.js.map +1 -0
- package/glTF/2.0/Extensions/EXT_texture_avif.d.ts +3 -15
- package/glTF/2.0/Extensions/EXT_texture_avif.js +5 -38
- package/glTF/2.0/Extensions/EXT_texture_avif.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_texture_avif.pure.d.ts +27 -0
- package/glTF/2.0/Extensions/EXT_texture_avif.pure.js +58 -0
- package/glTF/2.0/Extensions/EXT_texture_avif.pure.js.map +1 -0
- package/glTF/2.0/Extensions/EXT_texture_webp.d.ts +3 -14
- package/glTF/2.0/Extensions/EXT_texture_webp.js +5 -37
- package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_texture_webp.pure.d.ts +26 -0
- package/glTF/2.0/Extensions/EXT_texture_webp.pure.js +57 -0
- package/glTF/2.0/Extensions/EXT_texture_webp.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.d.ts +3 -30
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +5 -128
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.pure.d.ts +37 -0
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.pure.js +143 -0
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +3 -37
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +5 -142
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.pure.d.ts +44 -0
- package/glTF/2.0/Extensions/KHR_lights_punctual.pure.js +157 -0
- package/glTF/2.0/Extensions/KHR_lights_punctual.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_anisotropy.d.ts +3 -30
- package/glTF/2.0/Extensions/KHR_materials_anisotropy.js +5 -177
- package/glTF/2.0/Extensions/KHR_materials_anisotropy.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_anisotropy.pure.d.ts +37 -0
- package/glTF/2.0/Extensions/KHR_materials_anisotropy.pure.js +192 -0
- package/glTF/2.0/Extensions/KHR_materials_anisotropy.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +3 -30
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +5 -251
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.pure.d.ts +37 -0
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.pure.js +266 -0
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_coat.d.ts +3 -30
- package/glTF/2.0/Extensions/KHR_materials_coat.js +5 -380
- package/glTF/2.0/Extensions/KHR_materials_coat.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_coat.pure.d.ts +37 -0
- package/glTF/2.0/Extensions/KHR_materials_coat.pure.js +395 -0
- package/glTF/2.0/Extensions/KHR_materials_coat.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.d.ts +3 -22
- package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.js +5 -75
- package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.pure.d.ts +29 -0
- package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.pure.js +90 -0
- package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.d.ts +3 -38
- package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js +5 -115
- package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.pure.d.ts +45 -0
- package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.pure.js +130 -0
- package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_dispersion.d.ts +3 -29
- package/glTF/2.0/Extensions/KHR_materials_dispersion.js +5 -60
- package/glTF/2.0/Extensions/KHR_materials_dispersion.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_dispersion.pure.d.ts +36 -0
- package/glTF/2.0/Extensions/KHR_materials_dispersion.pure.js +75 -0
- package/glTF/2.0/Extensions/KHR_materials_dispersion.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +3 -25
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +5 -54
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.pure.d.ts +32 -0
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.pure.js +69 -0
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_fuzz.d.ts +3 -30
- package/glTF/2.0/Extensions/KHR_materials_fuzz.js +5 -191
- package/glTF/2.0/Extensions/KHR_materials_fuzz.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_fuzz.pure.d.ts +37 -0
- package/glTF/2.0/Extensions/KHR_materials_fuzz.pure.js +206 -0
- package/glTF/2.0/Extensions/KHR_materials_fuzz.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +3 -27
- package/glTF/2.0/Extensions/KHR_materials_ior.js +5 -67
- package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.pure.d.ts +34 -0
- package/glTF/2.0/Extensions/KHR_materials_ior.pure.js +81 -0
- package/glTF/2.0/Extensions/KHR_materials_ior.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_iridescence.d.ts +3 -22
- package/glTF/2.0/Extensions/KHR_materials_iridescence.js +5 -100
- package/glTF/2.0/Extensions/KHR_materials_iridescence.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_iridescence.pure.d.ts +29 -0
- package/glTF/2.0/Extensions/KHR_materials_iridescence.pure.js +115 -0
- package/glTF/2.0/Extensions/KHR_materials_iridescence.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_openpbr.d.ts +3 -25
- package/glTF/2.0/Extensions/KHR_materials_openpbr.js +5 -41
- package/glTF/2.0/Extensions/KHR_materials_openpbr.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_openpbr.pure.d.ts +32 -0
- package/glTF/2.0/Extensions/KHR_materials_openpbr.pure.js +56 -0
- package/glTF/2.0/Extensions/KHR_materials_openpbr.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +3 -22
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +5 -63
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.pure.d.ts +29 -0
- package/glTF/2.0/Extensions/KHR_materials_sheen.pure.js +78 -0
- package/glTF/2.0/Extensions/KHR_materials_sheen.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +3 -39
- package/glTF/2.0/Extensions/KHR_materials_specular.js +5 -123
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.pure.d.ts +46 -0
- package/glTF/2.0/Extensions/KHR_materials_specular.pure.js +138 -0
- package/glTF/2.0/Extensions/KHR_materials_specular.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +3 -38
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +5 -145
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.pure.d.ts +45 -0
- package/glTF/2.0/Extensions/KHR_materials_transmission.pure.js +160 -0
- package/glTF/2.0/Extensions/KHR_materials_transmission.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +3 -18
- package/glTF/2.0/Extensions/KHR_materials_unlit.js +5 -43
- package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_unlit.pure.d.ts +25 -0
- package/glTF/2.0/Extensions/KHR_materials_unlit.pure.js +58 -0
- package/glTF/2.0/Extensions/KHR_materials_unlit.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +3 -38
- package/glTF/2.0/Extensions/KHR_materials_volume.js +5 -169
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.pure.d.ts +45 -0
- package/glTF/2.0/Extensions/KHR_materials_volume.pure.js +184 -0
- package/glTF/2.0/Extensions/KHR_materials_volume.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_volume_scatter.d.ts +3 -38
- package/glTF/2.0/Extensions/KHR_materials_volume_scatter.js +5 -130
- package/glTF/2.0/Extensions/KHR_materials_volume_scatter.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume_scatter.pure.d.ts +45 -0
- package/glTF/2.0/Extensions/KHR_materials_volume_scatter.pure.js +145 -0
- package/glTF/2.0/Extensions/KHR_materials_volume_scatter.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +3 -14
- package/glTF/2.0/Extensions/KHR_texture_basisu.js +5 -37
- package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_basisu.pure.d.ts +26 -0
- package/glTF/2.0/Extensions/KHR_texture_basisu.pure.js +57 -0
- package/glTF/2.0/Extensions/KHR_texture_basisu.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +3 -19
- package/glTF/2.0/Extensions/KHR_texture_transform.js +5 -90
- package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.pure.d.ts +26 -0
- package/glTF/2.0/Extensions/KHR_texture_transform.pure.js +105 -0
- package/glTF/2.0/Extensions/KHR_texture_transform.pure.js.map +1 -0
- package/glTF/2.0/Extensions/pure.d.ts +26 -0
- package/glTF/2.0/Extensions/pure.js +27 -0
- package/glTF/2.0/Extensions/pure.js.map +1 -0
- package/glTF/2.0/pure.d.ts +5 -0
- package/glTF/2.0/pure.js +7 -0
- package/glTF/2.0/pure.js.map +1 -0
- package/glTF/pure.d.ts +3 -0
- package/glTF/pure.js +5 -0
- package/glTF/pure.js.map +1 -0
- package/package.json +30 -4
- package/pure.d.ts +7 -0
- package/pure.js +9 -0
- package/pure.js.map +1 -0
- package/stl/pure.d.ts +2 -0
- package/stl/pure.js +3 -0
- package/stl/pure.js.map +1 -0
|
@@ -1,133 +1,8 @@
|
|
|
1
|
-
import { GLTFExporter } from "../glTFExporter.js";
|
|
2
|
-
import { OpenPBRMaterial } from "@babylonjs/core/Materials/PBR/openpbrMaterial.js";
|
|
3
|
-
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
|
4
|
-
import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
|
5
|
-
const NAME = "KHR_materials_volume_scatter";
|
|
6
|
-
function SingleScatterToMultiScatterAlbedo(singleScatter) {
|
|
7
|
-
const s = new Vector3(Math.sqrt(1.0 - singleScatter.x), Math.sqrt(1.0 - singleScatter.y), Math.sqrt(1.0 - singleScatter.z));
|
|
8
|
-
const ones = new Vector3(1.0, 1.0, 1.0);
|
|
9
|
-
const t = ones.subtract(s);
|
|
10
|
-
const p = ones.subtract(new Vector3(0.139, 0.139, 0.139).multiplyInPlace(s));
|
|
11
|
-
const k = ones.add(new Vector3(1.17, 1.17, 1.17).multiplyInPlace(s));
|
|
12
|
-
return t.multiplyInPlace(p).divideInPlace(k);
|
|
13
|
-
}
|
|
14
1
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
2
|
+
* Re-exports the pure implementation and applies the runtime registration side effect.
|
|
3
|
+
* Import "./KHR_materials_volume_scatter.pure" for tree-shakeable, side-effect-free usage.
|
|
17
4
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/** Name of this extension */
|
|
22
|
-
this.name = NAME;
|
|
23
|
-
/** Defines whether this extension is enabled */
|
|
24
|
-
this.enabled = true;
|
|
25
|
-
/** Defines whether this extension is required */
|
|
26
|
-
this.required = false;
|
|
27
|
-
this._wasUsed = false;
|
|
28
|
-
this._exporter = exporter;
|
|
29
|
-
}
|
|
30
|
-
dispose() { }
|
|
31
|
-
/** @internal */
|
|
32
|
-
get wasUsed() {
|
|
33
|
-
return this._wasUsed;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* After exporting a material, deal with additional textures
|
|
37
|
-
* @param context GLTF context of the material
|
|
38
|
-
* @param node exported GLTF node
|
|
39
|
-
* @param babylonMaterial corresponding babylon material
|
|
40
|
-
* @returns array of additional textures to export
|
|
41
|
-
*/
|
|
42
|
-
async postExportMaterialAdditionalTexturesAsync(context, node, babylonMaterial) {
|
|
43
|
-
const additionalTextures = [];
|
|
44
|
-
if (babylonMaterial instanceof OpenPBRMaterial) {
|
|
45
|
-
if (babylonMaterial.transmissionWeight > 0) {
|
|
46
|
-
if (babylonMaterial.transmissionScatterTexture) {
|
|
47
|
-
additionalTextures.push(babylonMaterial.transmissionScatterTexture);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (babylonMaterial.subsurfaceWeight > 0) {
|
|
51
|
-
if (babylonMaterial.subsurfaceColorTexture) {
|
|
52
|
-
additionalTextures.push(babylonMaterial.subsurfaceColorTexture);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return additionalTextures;
|
|
57
|
-
}
|
|
58
|
-
_isExtensionEnabled(mat) {
|
|
59
|
-
// This extension must not be used on a material that also uses KHR_materials_unlit
|
|
60
|
-
if (mat.unlit) {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
const transmissionVolume = mat.transmissionWeight > 0 && !mat.geometryThinWalled && mat.transmissionDepth > 0;
|
|
64
|
-
const transmissionScatter = transmissionVolume && !mat.transmissionScatter.equals(Color3.Black());
|
|
65
|
-
const subsurfaceVolume = mat.subsurfaceWeight > 0 && !mat.geometryThinWalled;
|
|
66
|
-
if (transmissionScatter || subsurfaceVolume) {
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* After exporting a material
|
|
73
|
-
* @param context GLTF context of the material
|
|
74
|
-
* @param node exported GLTF node
|
|
75
|
-
* @param babylonMaterial corresponding babylon material
|
|
76
|
-
* @returns promise that resolves with the updated node
|
|
77
|
-
*/
|
|
78
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
79
|
-
postExportMaterialAsync(context, node, babylonMaterial) {
|
|
80
|
-
return new Promise((resolve) => {
|
|
81
|
-
if (babylonMaterial instanceof OpenPBRMaterial && this._isExtensionEnabled(babylonMaterial)) {
|
|
82
|
-
this._wasUsed = true;
|
|
83
|
-
// If both transmission and subsurface volumes exist, combine them.
|
|
84
|
-
let transmissionMultiscatterColor = Vector3.Zero();
|
|
85
|
-
let transmissionScatterAnisotropy = 0;
|
|
86
|
-
if (babylonMaterial.transmissionWeight > 0) {
|
|
87
|
-
// In OpenPBR 1.2, the transmission_scatter_color represents the single scatter albedo.
|
|
88
|
-
const ssAlbedo = new Vector3(babylonMaterial.transmissionScatter.r, babylonMaterial.transmissionScatter.g, babylonMaterial.transmissionScatter.b);
|
|
89
|
-
transmissionMultiscatterColor = SingleScatterToMultiScatterAlbedo(ssAlbedo);
|
|
90
|
-
transmissionScatterAnisotropy = babylonMaterial.transmissionScatterAnisotropy;
|
|
91
|
-
}
|
|
92
|
-
const subsurfaceMultiscatterColor = Vector3.Zero();
|
|
93
|
-
let subsurfaceScatterAnisotropy = 0;
|
|
94
|
-
if (babylonMaterial.subsurfaceWeight > 0) {
|
|
95
|
-
subsurfaceMultiscatterColor.set(babylonMaterial.subsurfaceColor.r, babylonMaterial.subsurfaceColor.g, babylonMaterial.subsurfaceColor.b);
|
|
96
|
-
subsurfaceScatterAnisotropy = babylonMaterial.subsurfaceScatterAnisotropy;
|
|
97
|
-
}
|
|
98
|
-
const subsurfaceFractionOfDielectric = (1.0 - babylonMaterial.transmissionWeight) * babylonMaterial.subsurfaceWeight;
|
|
99
|
-
const subsurfaceAndTransmissionFractionOfDielectric = subsurfaceFractionOfDielectric + babylonMaterial.transmissionWeight;
|
|
100
|
-
const reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric = 1.0 / Math.max(subsurfaceAndTransmissionFractionOfDielectric, 1e-6);
|
|
101
|
-
const transWeight = babylonMaterial.transmissionWeight * reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric;
|
|
102
|
-
const subsurfWeight = subsurfaceFractionOfDielectric * reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric;
|
|
103
|
-
const multiscatterColor = transmissionMultiscatterColor
|
|
104
|
-
.multiplyByFloats(transWeight, transWeight, transWeight)
|
|
105
|
-
.addInPlace(subsurfaceMultiscatterColor.multiplyByFloats(subsurfWeight, subsurfWeight, subsurfWeight));
|
|
106
|
-
const volumeInfo = {
|
|
107
|
-
multiscatterColorFactor: multiscatterColor.asArray(),
|
|
108
|
-
scatterAnisotropy: transmissionScatterAnisotropy * transWeight + subsurfaceScatterAnisotropy * subsurfWeight,
|
|
109
|
-
};
|
|
110
|
-
if (babylonMaterial.subsurfaceWeight > 0 && babylonMaterial.subsurfaceColorTexture) {
|
|
111
|
-
this._exporter._materialNeedsUVsSet.add(babylonMaterial);
|
|
112
|
-
const subsurfaceScatterTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.subsurfaceColorTexture);
|
|
113
|
-
if (subsurfaceScatterTexture) {
|
|
114
|
-
volumeInfo.multiscatterColorTexture = subsurfaceScatterTexture;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
else if (babylonMaterial.transmissionWeight > 0 && babylonMaterial.transmissionScatterTexture) {
|
|
118
|
-
this._exporter._materialNeedsUVsSet.add(babylonMaterial);
|
|
119
|
-
// TODO - the transmission_scatter texture represents the single scatter albedo, not the multiscatter color. Convert it before exporting.
|
|
120
|
-
const transmissionTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.transmissionScatterTexture);
|
|
121
|
-
if (transmissionTexture) {
|
|
122
|
-
volumeInfo.multiscatterColorTexture = transmissionTexture;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
node.extensions = node.extensions || {};
|
|
126
|
-
node.extensions[NAME] = volumeInfo;
|
|
127
|
-
}
|
|
128
|
-
resolve(node);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_volume_scatter(exporter), 101);
|
|
5
|
+
export * from "./KHR_materials_volume_scatter.pure.js";
|
|
6
|
+
import { RegisterKHR_materials_volume_scatter } from "./KHR_materials_volume_scatter.pure.js";
|
|
7
|
+
RegisterKHR_materials_volume_scatter();
|
|
133
8
|
//# sourceMappingURL=KHR_materials_volume_scatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KHR_materials_volume_scatter.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_volume_scatter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,MAAM,IAAI,GAAG,8BAA8B,CAAC;AAE5C,SAAS,iCAAiC,CAAC,aAAsB;IAC7D,MAAM,CAAC,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,IAA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oBAC9D,CAAC;gBACL,CAAC;gBAED,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;gBACxC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;YACvC,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,YAAY,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,4BAA4B,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC","sourcesContent":["import { type IMaterial, type IKHRMaterialsVolumeScatter } from \"babylonjs-gltf2interface\";\r\nimport { type IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { GLTFExporter } from \"../glTFExporter\";\r\nimport { type Material } from \"core/Materials/material\";\r\nimport { OpenPBRMaterial } from \"core/Materials/PBR/openpbrMaterial\";\r\nimport { type BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\n\r\nconst NAME = \"KHR_materials_volume_scatter\";\r\n\r\nfunction SingleScatterToMultiScatterAlbedo(singleScatter: Vector3): Vector3 {\r\n const s = new Vector3(Math.sqrt(1.0 - singleScatter.x), Math.sqrt(1.0 - singleScatter.y), Math.sqrt(1.0 - singleScatter.z));\r\n const ones = new Vector3(1.0, 1.0, 1.0);\r\n const t = ones.subtract(s);\r\n const p = ones.subtract(new Vector3(0.139, 0.139, 0.139).multiplyInPlace(s));\r\n const k = ones.add(new Vector3(1.17, 1.17, 1.17).multiplyInPlace(s));\r\n\r\n return t.multiplyInPlace(p).divideInPlace(k);\r\n}\r\n\r\n/**\r\n * TODO: In-progress specification\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/7ea427ed55d44427e83c0a6d1c87068b1a4151c5/extensions/2.0/Khronos/KHR_materials_volume_scatter/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_volume_scatter implements IGLTFExporterExtensionV2 {\r\n /** Name of this extension */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n private _exporter: GLTFExporter;\r\n\r\n private _wasUsed = false;\r\n\r\n constructor(exporter: GLTFExporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n public dispose() {}\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n /**\r\n * After exporting a material, deal with additional textures\r\n * @param context GLTF context of the material\r\n * @param node exported GLTF node\r\n * @param babylonMaterial corresponding babylon material\r\n * @returns array of additional textures to export\r\n */\r\n public async postExportMaterialAdditionalTexturesAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]> {\r\n const additionalTextures: BaseTexture[] = [];\r\n\r\n if (babylonMaterial instanceof OpenPBRMaterial) {\r\n if (babylonMaterial.transmissionWeight > 0) {\r\n if (babylonMaterial.transmissionScatterTexture) {\r\n additionalTextures.push(babylonMaterial.transmissionScatterTexture);\r\n }\r\n }\r\n if (babylonMaterial.subsurfaceWeight > 0) {\r\n if (babylonMaterial.subsurfaceColorTexture) {\r\n additionalTextures.push(babylonMaterial.subsurfaceColorTexture);\r\n }\r\n }\r\n }\r\n\r\n return additionalTextures;\r\n }\r\n\r\n private _isExtensionEnabled(mat: OpenPBRMaterial): boolean {\r\n // This extension must not be used on a material that also uses KHR_materials_unlit\r\n if (mat.unlit) {\r\n return false;\r\n }\r\n const transmissionVolume = mat.transmissionWeight > 0 && !mat.geometryThinWalled && mat.transmissionDepth > 0;\r\n const transmissionScatter = transmissionVolume && !mat.transmissionScatter.equals(Color3.Black());\r\n const subsurfaceVolume = mat.subsurfaceWeight > 0 && !mat.geometryThinWalled;\r\n if (transmissionScatter || subsurfaceVolume) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * After exporting a material\r\n * @param context GLTF context of the material\r\n * @param node exported GLTF node\r\n * @param babylonMaterial corresponding babylon material\r\n * @returns promise that resolves with the updated node\r\n */\r\n // eslint-disable-next-line no-restricted-syntax\r\n public postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial> {\r\n return new Promise((resolve) => {\r\n if (babylonMaterial instanceof OpenPBRMaterial && this._isExtensionEnabled(babylonMaterial)) {\r\n this._wasUsed = true;\r\n\r\n // If both transmission and subsurface volumes exist, combine them.\r\n let transmissionMultiscatterColor = Vector3.Zero();\r\n let transmissionScatterAnisotropy = 0;\r\n if (babylonMaterial.transmissionWeight > 0) {\r\n // In OpenPBR 1.2, the transmission_scatter_color represents the single scatter albedo.\r\n const ssAlbedo = new Vector3(babylonMaterial.transmissionScatter.r, babylonMaterial.transmissionScatter.g, babylonMaterial.transmissionScatter.b);\r\n transmissionMultiscatterColor = SingleScatterToMultiScatterAlbedo(ssAlbedo);\r\n transmissionScatterAnisotropy = babylonMaterial.transmissionScatterAnisotropy;\r\n }\r\n\r\n const subsurfaceMultiscatterColor = Vector3.Zero();\r\n let subsurfaceScatterAnisotropy = 0;\r\n if (babylonMaterial.subsurfaceWeight > 0) {\r\n subsurfaceMultiscatterColor.set(babylonMaterial.subsurfaceColor.r, babylonMaterial.subsurfaceColor.g, babylonMaterial.subsurfaceColor.b);\r\n subsurfaceScatterAnisotropy = babylonMaterial.subsurfaceScatterAnisotropy;\r\n }\r\n\r\n const subsurfaceFractionOfDielectric = (1.0 - babylonMaterial.transmissionWeight) * babylonMaterial.subsurfaceWeight;\r\n const subsurfaceAndTransmissionFractionOfDielectric = subsurfaceFractionOfDielectric + babylonMaterial.transmissionWeight;\r\n const reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric = 1.0 / Math.max(subsurfaceAndTransmissionFractionOfDielectric, 1e-6);\r\n const transWeight = babylonMaterial.transmissionWeight * reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric;\r\n const subsurfWeight = subsurfaceFractionOfDielectric * reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric;\r\n\r\n const multiscatterColor = transmissionMultiscatterColor\r\n .multiplyByFloats(transWeight, transWeight, transWeight)\r\n .addInPlace(subsurfaceMultiscatterColor.multiplyByFloats(subsurfWeight, subsurfWeight, subsurfWeight));\r\n\r\n const volumeInfo: IKHRMaterialsVolumeScatter = {\r\n multiscatterColorFactor: multiscatterColor.asArray(),\r\n scatterAnisotropy: transmissionScatterAnisotropy * transWeight + subsurfaceScatterAnisotropy * subsurfWeight,\r\n };\r\n\r\n if (babylonMaterial.subsurfaceWeight > 0 && babylonMaterial.subsurfaceColorTexture) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n const subsurfaceScatterTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.subsurfaceColorTexture);\r\n if (subsurfaceScatterTexture) {\r\n volumeInfo.multiscatterColorTexture = subsurfaceScatterTexture;\r\n }\r\n } else if (babylonMaterial.transmissionWeight > 0 && babylonMaterial.transmissionScatterTexture) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n // TODO - the transmission_scatter texture represents the single scatter albedo, not the multiscatter color. Convert it before exporting.\r\n const transmissionTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.transmissionScatterTexture);\r\n if (transmissionTexture) {\r\n volumeInfo.multiscatterColorTexture = transmissionTexture;\r\n }\r\n }\r\n\r\n node.extensions = node.extensions || {};\r\n node.extensions[NAME] = volumeInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\nGLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_volume_scatter(exporter), 101);\r\n"]}
|
|
1
|
+
{"version":3,"file":"KHR_materials_volume_scatter.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_volume_scatter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,qCAAqC,CAAC;AAEpD,OAAO,EAAE,oCAAoC,EAAE,MAAM,qCAAqC,CAAC;AAC3F,oCAAoC,EAAE,CAAC","sourcesContent":["/**\r\n * Re-exports the pure implementation and applies the runtime registration side effect.\r\n * Import \"./KHR_materials_volume_scatter.pure\" for tree-shakeable, side-effect-free usage.\r\n */\r\nexport * from \"./KHR_materials_volume_scatter.pure\";\r\n\r\nimport { RegisterKHR_materials_volume_scatter } from \"./KHR_materials_volume_scatter.pure\";\r\nRegisterKHR_materials_volume_scatter();\r\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type IMaterial } from "babylonjs-gltf2interface";
|
|
2
|
+
import { type IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
|
3
|
+
import { GLTFExporter } from "../glTFExporter.js";
|
|
4
|
+
import { type Material } from "@babylonjs/core/Materials/material.js";
|
|
5
|
+
import { type BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
|
|
6
|
+
/**
|
|
7
|
+
* TODO: In-progress specification
|
|
8
|
+
* [Specification](https://github.com/KhronosGroup/glTF/blob/7ea427ed55d44427e83c0a6d1c87068b1a4151c5/extensions/2.0/Khronos/KHR_materials_volume_scatter/README.md)
|
|
9
|
+
*/
|
|
10
|
+
export declare class KHR_materials_volume_scatter implements IGLTFExporterExtensionV2 {
|
|
11
|
+
/** Name of this extension */
|
|
12
|
+
readonly name = "KHR_materials_volume_scatter";
|
|
13
|
+
/** Defines whether this extension is enabled */
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
/** Defines whether this extension is required */
|
|
16
|
+
required: boolean;
|
|
17
|
+
private _exporter;
|
|
18
|
+
private _wasUsed;
|
|
19
|
+
constructor(exporter: GLTFExporter);
|
|
20
|
+
dispose(): void;
|
|
21
|
+
/** @internal */
|
|
22
|
+
get wasUsed(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* After exporting a material, deal with additional textures
|
|
25
|
+
* @param context GLTF context of the material
|
|
26
|
+
* @param node exported GLTF node
|
|
27
|
+
* @param babylonMaterial corresponding babylon material
|
|
28
|
+
* @returns array of additional textures to export
|
|
29
|
+
*/
|
|
30
|
+
postExportMaterialAdditionalTexturesAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]>;
|
|
31
|
+
private _isExtensionEnabled;
|
|
32
|
+
/**
|
|
33
|
+
* After exporting a material
|
|
34
|
+
* @param context GLTF context of the material
|
|
35
|
+
* @param node exported GLTF node
|
|
36
|
+
* @param babylonMaterial corresponding babylon material
|
|
37
|
+
* @returns promise that resolves with the updated node
|
|
38
|
+
*/
|
|
39
|
+
postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Registers the KHR_materials_volume_scatter glTF serializer extension with the {@link GLTFExporter}.
|
|
43
|
+
* Safe to call multiple times; only the first call has an effect.
|
|
44
|
+
*/
|
|
45
|
+
export declare function RegisterKHR_materials_volume_scatter(): void;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { GLTFExporter } from "../glTFExporter.js";
|
|
2
|
+
import { OpenPBRMaterial } from "@babylonjs/core/Materials/PBR/openpbrMaterial.pure.js";
|
|
3
|
+
import { Color3 } from "@babylonjs/core/Maths/math.color.pure.js";
|
|
4
|
+
import { Vector3 } from "@babylonjs/core/Maths/math.vector.pure.js";
|
|
5
|
+
const NAME = "KHR_materials_volume_scatter";
|
|
6
|
+
function SingleScatterToMultiScatterAlbedo(singleScatter) {
|
|
7
|
+
const s = new Vector3(Math.sqrt(1.0 - singleScatter.x), Math.sqrt(1.0 - singleScatter.y), Math.sqrt(1.0 - singleScatter.z));
|
|
8
|
+
const ones = new Vector3(1.0, 1.0, 1.0);
|
|
9
|
+
const t = ones.subtract(s);
|
|
10
|
+
const p = ones.subtract(new Vector3(0.139, 0.139, 0.139).multiplyInPlace(s));
|
|
11
|
+
const k = ones.add(new Vector3(1.17, 1.17, 1.17).multiplyInPlace(s));
|
|
12
|
+
return t.multiplyInPlace(p).divideInPlace(k);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* TODO: In-progress specification
|
|
16
|
+
* [Specification](https://github.com/KhronosGroup/glTF/blob/7ea427ed55d44427e83c0a6d1c87068b1a4151c5/extensions/2.0/Khronos/KHR_materials_volume_scatter/README.md)
|
|
17
|
+
*/
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
19
|
+
export class KHR_materials_volume_scatter {
|
|
20
|
+
constructor(exporter) {
|
|
21
|
+
/** Name of this extension */
|
|
22
|
+
this.name = NAME;
|
|
23
|
+
/** Defines whether this extension is enabled */
|
|
24
|
+
this.enabled = true;
|
|
25
|
+
/** Defines whether this extension is required */
|
|
26
|
+
this.required = false;
|
|
27
|
+
this._wasUsed = false;
|
|
28
|
+
this._exporter = exporter;
|
|
29
|
+
}
|
|
30
|
+
dispose() { }
|
|
31
|
+
/** @internal */
|
|
32
|
+
get wasUsed() {
|
|
33
|
+
return this._wasUsed;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* After exporting a material, deal with additional textures
|
|
37
|
+
* @param context GLTF context of the material
|
|
38
|
+
* @param node exported GLTF node
|
|
39
|
+
* @param babylonMaterial corresponding babylon material
|
|
40
|
+
* @returns array of additional textures to export
|
|
41
|
+
*/
|
|
42
|
+
async postExportMaterialAdditionalTexturesAsync(context, node, babylonMaterial) {
|
|
43
|
+
const additionalTextures = [];
|
|
44
|
+
if (babylonMaterial instanceof OpenPBRMaterial) {
|
|
45
|
+
if (babylonMaterial.transmissionWeight > 0) {
|
|
46
|
+
if (babylonMaterial.transmissionScatterTexture) {
|
|
47
|
+
additionalTextures.push(babylonMaterial.transmissionScatterTexture);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (babylonMaterial.subsurfaceWeight > 0) {
|
|
51
|
+
if (babylonMaterial.subsurfaceColorTexture) {
|
|
52
|
+
additionalTextures.push(babylonMaterial.subsurfaceColorTexture);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return additionalTextures;
|
|
57
|
+
}
|
|
58
|
+
_isExtensionEnabled(mat) {
|
|
59
|
+
// This extension must not be used on a material that also uses KHR_materials_unlit
|
|
60
|
+
if (mat.unlit) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
const transmissionVolume = mat.transmissionWeight > 0 && !mat.geometryThinWalled && mat.transmissionDepth > 0;
|
|
64
|
+
const transmissionScatter = transmissionVolume && !mat.transmissionScatter.equals(Color3.Black());
|
|
65
|
+
const subsurfaceVolume = mat.subsurfaceWeight > 0 && !mat.geometryThinWalled;
|
|
66
|
+
if (transmissionScatter || subsurfaceVolume) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* After exporting a material
|
|
73
|
+
* @param context GLTF context of the material
|
|
74
|
+
* @param node exported GLTF node
|
|
75
|
+
* @param babylonMaterial corresponding babylon material
|
|
76
|
+
* @returns promise that resolves with the updated node
|
|
77
|
+
*/
|
|
78
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
79
|
+
postExportMaterialAsync(context, node, babylonMaterial) {
|
|
80
|
+
return new Promise((resolve) => {
|
|
81
|
+
if (babylonMaterial instanceof OpenPBRMaterial && this._isExtensionEnabled(babylonMaterial)) {
|
|
82
|
+
this._wasUsed = true;
|
|
83
|
+
// If both transmission and subsurface volumes exist, combine them.
|
|
84
|
+
let transmissionMultiscatterColor = Vector3.Zero();
|
|
85
|
+
let transmissionScatterAnisotropy = 0;
|
|
86
|
+
if (babylonMaterial.transmissionWeight > 0) {
|
|
87
|
+
// In OpenPBR 1.2, the transmission_scatter_color represents the single scatter albedo.
|
|
88
|
+
const ssAlbedo = new Vector3(babylonMaterial.transmissionScatter.r, babylonMaterial.transmissionScatter.g, babylonMaterial.transmissionScatter.b);
|
|
89
|
+
transmissionMultiscatterColor = SingleScatterToMultiScatterAlbedo(ssAlbedo);
|
|
90
|
+
transmissionScatterAnisotropy = babylonMaterial.transmissionScatterAnisotropy;
|
|
91
|
+
}
|
|
92
|
+
const subsurfaceMultiscatterColor = Vector3.Zero();
|
|
93
|
+
let subsurfaceScatterAnisotropy = 0;
|
|
94
|
+
if (babylonMaterial.subsurfaceWeight > 0) {
|
|
95
|
+
subsurfaceMultiscatterColor.set(babylonMaterial.subsurfaceColor.r, babylonMaterial.subsurfaceColor.g, babylonMaterial.subsurfaceColor.b);
|
|
96
|
+
subsurfaceScatterAnisotropy = babylonMaterial.subsurfaceScatterAnisotropy;
|
|
97
|
+
}
|
|
98
|
+
const subsurfaceFractionOfDielectric = (1.0 - babylonMaterial.transmissionWeight) * babylonMaterial.subsurfaceWeight;
|
|
99
|
+
const subsurfaceAndTransmissionFractionOfDielectric = subsurfaceFractionOfDielectric + babylonMaterial.transmissionWeight;
|
|
100
|
+
const reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric = 1.0 / Math.max(subsurfaceAndTransmissionFractionOfDielectric, 1e-6);
|
|
101
|
+
const transWeight = babylonMaterial.transmissionWeight * reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric;
|
|
102
|
+
const subsurfWeight = subsurfaceFractionOfDielectric * reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric;
|
|
103
|
+
const multiscatterColor = transmissionMultiscatterColor
|
|
104
|
+
.multiplyByFloats(transWeight, transWeight, transWeight)
|
|
105
|
+
.addInPlace(subsurfaceMultiscatterColor.multiplyByFloats(subsurfWeight, subsurfWeight, subsurfWeight));
|
|
106
|
+
const volumeInfo = {
|
|
107
|
+
multiscatterColorFactor: multiscatterColor.asArray(),
|
|
108
|
+
scatterAnisotropy: transmissionScatterAnisotropy * transWeight + subsurfaceScatterAnisotropy * subsurfWeight,
|
|
109
|
+
};
|
|
110
|
+
if (babylonMaterial.subsurfaceWeight > 0 && babylonMaterial.subsurfaceColorTexture) {
|
|
111
|
+
this._exporter._materialNeedsUVsSet.add(babylonMaterial);
|
|
112
|
+
const subsurfaceScatterTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.subsurfaceColorTexture);
|
|
113
|
+
if (subsurfaceScatterTexture) {
|
|
114
|
+
volumeInfo.multiscatterColorTexture = subsurfaceScatterTexture;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else if (babylonMaterial.transmissionWeight > 0 && babylonMaterial.transmissionScatterTexture) {
|
|
118
|
+
this._exporter._materialNeedsUVsSet.add(babylonMaterial);
|
|
119
|
+
// TODO - the transmission_scatter texture represents the single scatter albedo, not the multiscatter color. Convert it before exporting.
|
|
120
|
+
const transmissionTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.transmissionScatterTexture);
|
|
121
|
+
if (transmissionTexture) {
|
|
122
|
+
volumeInfo.multiscatterColorTexture = transmissionTexture;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
node.extensions = node.extensions || {};
|
|
126
|
+
node.extensions[NAME] = volumeInfo;
|
|
127
|
+
}
|
|
128
|
+
resolve(node);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
let _Registered = false;
|
|
133
|
+
/**
|
|
134
|
+
* Registers the KHR_materials_volume_scatter glTF serializer extension with the {@link GLTFExporter}.
|
|
135
|
+
* Safe to call multiple times; only the first call has an effect.
|
|
136
|
+
*/
|
|
137
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
138
|
+
export function RegisterKHR_materials_volume_scatter() {
|
|
139
|
+
if (_Registered) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
_Registered = true;
|
|
143
|
+
GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_volume_scatter(exporter), 101);
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=KHR_materials_volume_scatter.pure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KHR_materials_volume_scatter.pure.js","sourceRoot":"","sources":["../../../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AAwB,CAAC;oBACnE,CAAC;gBACL,CAAC;qBAAM,IAAI,eAAe,CAAC,kBAAkB,GAAG,CAAC,IAAI,eAAe,CAAC,0BAA0B,EAAE,CAAC;oBAC9F,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;oBACzD,yIAAyI;oBACzI,MAAM,mBAAmB,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,cAAc,CAAC,eAAe,CAAC,0BAA0B,CAAC,CAAC;oBACxH,IAAI,mBAAmB,EAAE,CAAC;wBACtB,UAAU,CAAC,wBAAwB,GAAG,mBAAmB,CAAC;oBAC9D,CAAC;gBACL,CAAC;gBAED,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;gBACxC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;YACvC,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,gEAAgE;AAChE,MAAM,UAAU,oCAAoC;IAChD,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,YAAY,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,4BAA4B,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC;AACxG,CAAC","sourcesContent":["import { type IMaterial, type IKHRMaterialsVolumeScatter } from \"babylonjs-gltf2interface\";\r\nimport { type IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { GLTFExporter } from \"../glTFExporter\";\r\nimport { type Material } from \"core/Materials/material\";\r\nimport { OpenPBRMaterial } from \"core/Materials/PBR/openpbrMaterial.pure\";\r\nimport { type BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { Color3 } from \"core/Maths/math.color.pure\";\r\nimport { Vector3 } from \"core/Maths/math.vector.pure\";\r\n\r\nconst NAME = \"KHR_materials_volume_scatter\";\r\n\r\nfunction SingleScatterToMultiScatterAlbedo(singleScatter: Vector3): Vector3 {\r\n const s = new Vector3(Math.sqrt(1.0 - singleScatter.x), Math.sqrt(1.0 - singleScatter.y), Math.sqrt(1.0 - singleScatter.z));\r\n const ones = new Vector3(1.0, 1.0, 1.0);\r\n const t = ones.subtract(s);\r\n const p = ones.subtract(new Vector3(0.139, 0.139, 0.139).multiplyInPlace(s));\r\n const k = ones.add(new Vector3(1.17, 1.17, 1.17).multiplyInPlace(s));\r\n\r\n return t.multiplyInPlace(p).divideInPlace(k);\r\n}\r\n\r\n/**\r\n * TODO: In-progress specification\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/7ea427ed55d44427e83c0a6d1c87068b1a4151c5/extensions/2.0/Khronos/KHR_materials_volume_scatter/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_volume_scatter implements IGLTFExporterExtensionV2 {\r\n /** Name of this extension */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n private _exporter: GLTFExporter;\r\n\r\n private _wasUsed = false;\r\n\r\n constructor(exporter: GLTFExporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n public dispose() {}\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n /**\r\n * After exporting a material, deal with additional textures\r\n * @param context GLTF context of the material\r\n * @param node exported GLTF node\r\n * @param babylonMaterial corresponding babylon material\r\n * @returns array of additional textures to export\r\n */\r\n public async postExportMaterialAdditionalTexturesAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]> {\r\n const additionalTextures: BaseTexture[] = [];\r\n\r\n if (babylonMaterial instanceof OpenPBRMaterial) {\r\n if (babylonMaterial.transmissionWeight > 0) {\r\n if (babylonMaterial.transmissionScatterTexture) {\r\n additionalTextures.push(babylonMaterial.transmissionScatterTexture);\r\n }\r\n }\r\n if (babylonMaterial.subsurfaceWeight > 0) {\r\n if (babylonMaterial.subsurfaceColorTexture) {\r\n additionalTextures.push(babylonMaterial.subsurfaceColorTexture);\r\n }\r\n }\r\n }\r\n\r\n return additionalTextures;\r\n }\r\n\r\n private _isExtensionEnabled(mat: OpenPBRMaterial): boolean {\r\n // This extension must not be used on a material that also uses KHR_materials_unlit\r\n if (mat.unlit) {\r\n return false;\r\n }\r\n const transmissionVolume = mat.transmissionWeight > 0 && !mat.geometryThinWalled && mat.transmissionDepth > 0;\r\n const transmissionScatter = transmissionVolume && !mat.transmissionScatter.equals(Color3.Black());\r\n const subsurfaceVolume = mat.subsurfaceWeight > 0 && !mat.geometryThinWalled;\r\n if (transmissionScatter || subsurfaceVolume) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * After exporting a material\r\n * @param context GLTF context of the material\r\n * @param node exported GLTF node\r\n * @param babylonMaterial corresponding babylon material\r\n * @returns promise that resolves with the updated node\r\n */\r\n // eslint-disable-next-line no-restricted-syntax\r\n public postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial> {\r\n return new Promise((resolve) => {\r\n if (babylonMaterial instanceof OpenPBRMaterial && this._isExtensionEnabled(babylonMaterial)) {\r\n this._wasUsed = true;\r\n\r\n // If both transmission and subsurface volumes exist, combine them.\r\n let transmissionMultiscatterColor = Vector3.Zero();\r\n let transmissionScatterAnisotropy = 0;\r\n if (babylonMaterial.transmissionWeight > 0) {\r\n // In OpenPBR 1.2, the transmission_scatter_color represents the single scatter albedo.\r\n const ssAlbedo = new Vector3(babylonMaterial.transmissionScatter.r, babylonMaterial.transmissionScatter.g, babylonMaterial.transmissionScatter.b);\r\n transmissionMultiscatterColor = SingleScatterToMultiScatterAlbedo(ssAlbedo);\r\n transmissionScatterAnisotropy = babylonMaterial.transmissionScatterAnisotropy;\r\n }\r\n\r\n const subsurfaceMultiscatterColor = Vector3.Zero();\r\n let subsurfaceScatterAnisotropy = 0;\r\n if (babylonMaterial.subsurfaceWeight > 0) {\r\n subsurfaceMultiscatterColor.set(babylonMaterial.subsurfaceColor.r, babylonMaterial.subsurfaceColor.g, babylonMaterial.subsurfaceColor.b);\r\n subsurfaceScatterAnisotropy = babylonMaterial.subsurfaceScatterAnisotropy;\r\n }\r\n\r\n const subsurfaceFractionOfDielectric = (1.0 - babylonMaterial.transmissionWeight) * babylonMaterial.subsurfaceWeight;\r\n const subsurfaceAndTransmissionFractionOfDielectric = subsurfaceFractionOfDielectric + babylonMaterial.transmissionWeight;\r\n const reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric = 1.0 / Math.max(subsurfaceAndTransmissionFractionOfDielectric, 1e-6);\r\n const transWeight = babylonMaterial.transmissionWeight * reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric;\r\n const subsurfWeight = subsurfaceFractionOfDielectric * reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric;\r\n\r\n const multiscatterColor = transmissionMultiscatterColor\r\n .multiplyByFloats(transWeight, transWeight, transWeight)\r\n .addInPlace(subsurfaceMultiscatterColor.multiplyByFloats(subsurfWeight, subsurfWeight, subsurfWeight));\r\n\r\n const volumeInfo: IKHRMaterialsVolumeScatter = {\r\n multiscatterColorFactor: multiscatterColor.asArray(),\r\n scatterAnisotropy: transmissionScatterAnisotropy * transWeight + subsurfaceScatterAnisotropy * subsurfWeight,\r\n };\r\n\r\n if (babylonMaterial.subsurfaceWeight > 0 && babylonMaterial.subsurfaceColorTexture) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n const subsurfaceScatterTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.subsurfaceColorTexture);\r\n if (subsurfaceScatterTexture) {\r\n volumeInfo.multiscatterColorTexture = subsurfaceScatterTexture;\r\n }\r\n } else if (babylonMaterial.transmissionWeight > 0 && babylonMaterial.transmissionScatterTexture) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n // TODO - the transmission_scatter texture represents the single scatter albedo, not the multiscatter color. Convert it before exporting.\r\n const transmissionTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.transmissionScatterTexture);\r\n if (transmissionTexture) {\r\n volumeInfo.multiscatterColorTexture = transmissionTexture;\r\n }\r\n }\r\n\r\n node.extensions = node.extensions || {};\r\n node.extensions[NAME] = volumeInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Registers the KHR_materials_volume_scatter glTF serializer extension with the {@link GLTFExporter}.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function RegisterKHR_materials_volume_scatter(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_volume_scatter(exporter), 101);\r\n}\r\n"]}
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import { type IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
|
2
|
-
import { GLTFExporter } from "../glTFExporter.js";
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
2
|
+
* Re-exports the pure implementation and applies the runtime registration side effect.
|
|
3
|
+
* Import "./KHR_texture_basisu.pure" for tree-shakeable, side-effect-free usage.
|
|
5
4
|
*/
|
|
6
|
-
export
|
|
7
|
-
readonly name = "KHR_texture_basisu";
|
|
8
|
-
enabled: boolean;
|
|
9
|
-
required: boolean;
|
|
10
|
-
private _wasUsed;
|
|
11
|
-
get wasUsed(): boolean;
|
|
12
|
-
private _exporter;
|
|
13
|
-
constructor(exporter: GLTFExporter);
|
|
14
|
-
dispose(): void;
|
|
15
|
-
postExportTexture(_: string, textureInfo: BABYLON.GLTF2.ITextureInfo): void;
|
|
16
|
-
}
|
|
5
|
+
export * from "./KHR_texture_basisu.pure.js";
|
|
@@ -1,40 +1,8 @@
|
|
|
1
|
-
import { GLTFExporter } from "../glTFExporter.js";
|
|
2
|
-
import { GetMimeType } from "@babylonjs/core/Misc/fileTools.js";
|
|
3
|
-
const NAME = "KHR_texture_basisu";
|
|
4
1
|
/**
|
|
5
|
-
*
|
|
2
|
+
* Re-exports the pure implementation and applies the runtime registration side effect.
|
|
3
|
+
* Import "./KHR_texture_basisu.pure" for tree-shakeable, side-effect-free usage.
|
|
6
4
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return this._wasUsed;
|
|
11
|
-
}
|
|
12
|
-
constructor(exporter) {
|
|
13
|
-
this.name = NAME;
|
|
14
|
-
this.enabled = true;
|
|
15
|
-
this.required = true;
|
|
16
|
-
this._wasUsed = false;
|
|
17
|
-
this._exporter = exporter;
|
|
18
|
-
}
|
|
19
|
-
dispose() { }
|
|
20
|
-
postExportTexture(_, textureInfo) {
|
|
21
|
-
const texture = this._exporter._textures[textureInfo.index];
|
|
22
|
-
const imageIndex = texture.source;
|
|
23
|
-
if (imageIndex === undefined) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const image = this._exporter._images[imageIndex];
|
|
27
|
-
const sourceMimeType = image.mimeType || GetMimeType(image.uri);
|
|
28
|
-
if (sourceMimeType !== "image/ktx2" /* ImageMimeType.KTX2 */) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
texture.source = undefined;
|
|
32
|
-
texture.extensions || (texture.extensions = {});
|
|
33
|
-
texture.extensions[NAME] = {
|
|
34
|
-
source: imageIndex,
|
|
35
|
-
};
|
|
36
|
-
this._wasUsed = true;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_texture_basisu(exporter));
|
|
5
|
+
export * from "./KHR_texture_basisu.pure.js";
|
|
6
|
+
import { RegisterKHR_texture_basisu } from "./KHR_texture_basisu.pure.js";
|
|
7
|
+
RegisterKHR_texture_basisu();
|
|
40
8
|
//# sourceMappingURL=KHR_texture_basisu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KHR_texture_basisu.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_texture_basisu.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"KHR_texture_basisu.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_texture_basisu.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,2BAA2B,CAAC;AAE1C,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,0BAA0B,EAAE,CAAC","sourcesContent":["/**\n * Re-exports the pure implementation and applies the runtime registration side effect.\n * Import \"./KHR_texture_basisu.pure\" for tree-shakeable, side-effect-free usage.\n */\nexport * from \"./KHR_texture_basisu.pure\";\n\nimport { RegisterKHR_texture_basisu } from \"./KHR_texture_basisu.pure\";\nRegisterKHR_texture_basisu();\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
|
2
|
+
import { GLTFExporter } from "../glTFExporter.js";
|
|
3
|
+
/**
|
|
4
|
+
* [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_basisu/README.md)
|
|
5
|
+
*/
|
|
6
|
+
export declare class KHR_texture_basisu implements IGLTFExporterExtensionV2 {
|
|
7
|
+
readonly name = "KHR_texture_basisu";
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
required: boolean;
|
|
10
|
+
private _wasUsed;
|
|
11
|
+
get wasUsed(): boolean;
|
|
12
|
+
private _exporter;
|
|
13
|
+
constructor(exporter: GLTFExporter);
|
|
14
|
+
dispose(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Called after a texture is exported to register the encoded image MIME type.
|
|
17
|
+
* @param _ - the name of the exported babylon texture (unused)
|
|
18
|
+
* @param textureInfo - the glTF texture info for the exported texture
|
|
19
|
+
*/
|
|
20
|
+
postExportTexture(_: string, textureInfo: BABYLON.GLTF2.ITextureInfo): void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Registers the KHR_texture_basisu glTF serializer extension with the {@link GLTFExporter}.
|
|
24
|
+
* Safe to call multiple times; only the first call has an effect.
|
|
25
|
+
*/
|
|
26
|
+
export declare function RegisterKHR_texture_basisu(): void;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { GLTFExporter } from "../glTFExporter.js";
|
|
2
|
+
import { GetMimeType } from "@babylonjs/core/Misc/fileTools.pure.js";
|
|
3
|
+
const NAME = "KHR_texture_basisu";
|
|
4
|
+
/**
|
|
5
|
+
* [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_basisu/README.md)
|
|
6
|
+
*/
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
8
|
+
export class KHR_texture_basisu {
|
|
9
|
+
get wasUsed() {
|
|
10
|
+
return this._wasUsed;
|
|
11
|
+
}
|
|
12
|
+
constructor(exporter) {
|
|
13
|
+
this.name = NAME;
|
|
14
|
+
this.enabled = true;
|
|
15
|
+
this.required = true;
|
|
16
|
+
this._wasUsed = false;
|
|
17
|
+
this._exporter = exporter;
|
|
18
|
+
}
|
|
19
|
+
dispose() { }
|
|
20
|
+
/**
|
|
21
|
+
* Called after a texture is exported to register the encoded image MIME type.
|
|
22
|
+
* @param _ - the name of the exported babylon texture (unused)
|
|
23
|
+
* @param textureInfo - the glTF texture info for the exported texture
|
|
24
|
+
*/
|
|
25
|
+
postExportTexture(_, textureInfo) {
|
|
26
|
+
const texture = this._exporter._textures[textureInfo.index];
|
|
27
|
+
const imageIndex = texture.source;
|
|
28
|
+
if (imageIndex === undefined) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const image = this._exporter._images[imageIndex];
|
|
32
|
+
const sourceMimeType = image.mimeType || GetMimeType(image.uri);
|
|
33
|
+
if (sourceMimeType !== "image/ktx2" /* ImageMimeType.KTX2 */) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
texture.source = undefined;
|
|
37
|
+
texture.extensions || (texture.extensions = {});
|
|
38
|
+
texture.extensions[NAME] = {
|
|
39
|
+
source: imageIndex,
|
|
40
|
+
};
|
|
41
|
+
this._wasUsed = true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
let _Registered = false;
|
|
45
|
+
/**
|
|
46
|
+
* Registers the KHR_texture_basisu glTF serializer extension with the {@link GLTFExporter}.
|
|
47
|
+
* Safe to call multiple times; only the first call has an effect.
|
|
48
|
+
*/
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
50
|
+
export function RegisterKHR_texture_basisu() {
|
|
51
|
+
if (_Registered) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
_Registered = true;
|
|
55
|
+
GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_texture_basisu(exporter));
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=KHR_texture_basisu.pure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KHR_texture_basisu.pure.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_texture_basisu.pure.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,MAAM,IAAI,GAAG,oBAAoB,CAAC;AAElC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,kBAAkB;IAS3B,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAID,YAAY,QAAsB;QAdlB,SAAI,GAAG,IAAI,CAAC;QAErB,YAAO,GAAG,IAAI,CAA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*/\n/* eslint-disable babylonjs/available */\nimport { type IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\nimport { GLTFExporter } from \"../glTFExporter\";\nimport { GetMimeType } from \"core/Misc/fileTools.pure\";\nimport { ImageMimeType } from \"babylonjs-gltf2interface\";\n\nconst NAME = \"KHR_texture_basisu\";\n\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_basisu/README.md)\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class KHR_texture_basisu implements IGLTFExporterExtensionV2 {\n public readonly name = NAME;\n\n public enabled = true;\n\n public required = true;\n\n private _wasUsed = false;\n\n public get wasUsed() {\n return this._wasUsed;\n }\n\n private _exporter: GLTFExporter;\n\n constructor(exporter: GLTFExporter) {\n this._exporter = exporter;\n }\n\n public dispose() {}\n\n /**\n * Called after a texture is exported to register the encoded image MIME type.\n * @param _ - the name of the exported babylon texture (unused)\n * @param textureInfo - the glTF texture info for the exported texture\n */\n public postExportTexture(_: string, textureInfo: BABYLON.GLTF2.ITextureInfo): void {\n const texture = this._exporter._textures[textureInfo.index];\n const imageIndex = texture.source;\n if (imageIndex === undefined) {\n return;\n }\n\n const image = this._exporter._images[imageIndex];\n const sourceMimeType = image.mimeType || GetMimeType(image.uri!);\n if (sourceMimeType !== ImageMimeType.KTX2) {\n return;\n }\n\n texture.source = undefined;\n texture.extensions ||= {};\n texture.extensions[NAME] = {\n source: imageIndex,\n };\n\n this._wasUsed = true;\n }\n}\n\nlet _Registered = false;\n/**\n * Registers the KHR_texture_basisu glTF serializer extension with the {@link GLTFExporter}.\n * Safe to call multiple times; only the first call has an effect.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function RegisterKHR_texture_basisu(): void {\n if (_Registered) {\n return;\n }\n _Registered = true;\n\n GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_texture_basisu(exporter));\n}\n"]}
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
import { type ITextureInfo } from "babylonjs-gltf2interface";
|
|
2
|
-
import { type Texture } from "@babylonjs/core/Materials/Textures/texture.js";
|
|
3
|
-
import { type IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
|
4
1
|
/**
|
|
5
|
-
*
|
|
2
|
+
* Re-exports the pure implementation and applies the runtime registration side effect.
|
|
3
|
+
* Import "./KHR_texture_transform.pure" for tree-shakeable, side-effect-free usage.
|
|
6
4
|
*/
|
|
7
|
-
export
|
|
8
|
-
/** Name of this extension */
|
|
9
|
-
readonly name = "KHR_texture_transform";
|
|
10
|
-
/** Defines whether this extension is enabled */
|
|
11
|
-
enabled: boolean;
|
|
12
|
-
/** Defines whether this extension is required */
|
|
13
|
-
required: boolean;
|
|
14
|
-
/** Reference to the glTF exporter */
|
|
15
|
-
private _wasUsed;
|
|
16
|
-
constructor();
|
|
17
|
-
dispose(): void;
|
|
18
|
-
/** @internal */
|
|
19
|
-
get wasUsed(): boolean;
|
|
20
|
-
postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
|
|
21
|
-
}
|
|
5
|
+
export * from "./KHR_texture_transform.pure.js";
|