@babylonjs/loaders 9.26.0 → 9.26.1
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/FBX/fbxConstraintBehavior.d.ts +188 -0
- package/FBX/fbxConstraintBehavior.js +532 -0
- package/FBX/fbxConstraintBehavior.js.map +1 -0
- package/FBX/fbxFileLoader.pure.d.ts +175 -6
- package/FBX/fbxFileLoader.pure.js +1521 -286
- package/FBX/fbxFileLoader.pure.js.map +1 -1
- package/FBX/index.d.ts +4 -1
- package/FBX/index.js +1 -0
- package/FBX/index.js.map +1 -1
- package/FBX/interpreter/animation.d.ts +73 -33
- package/FBX/interpreter/animation.js +620 -223
- package/FBX/interpreter/animation.js.map +1 -1
- package/FBX/interpreter/animationCurve.d.ts +91 -0
- package/FBX/interpreter/animationCurve.js +623 -0
- package/FBX/interpreter/animationCurve.js.map +1 -0
- package/FBX/interpreter/blendShapes.js +9 -18
- package/FBX/interpreter/blendShapes.js.map +1 -1
- package/FBX/interpreter/connections.d.ts +1 -1
- package/FBX/interpreter/connections.js +173 -34
- package/FBX/interpreter/connections.js.map +1 -1
- package/FBX/interpreter/constraints.d.ts +68 -0
- package/FBX/interpreter/constraints.js +143 -0
- package/FBX/interpreter/constraints.js.map +1 -0
- package/FBX/interpreter/fbxInterpreter.d.ts +89 -4
- package/FBX/interpreter/fbxInterpreter.js +474 -122
- package/FBX/interpreter/fbxInterpreter.js.map +1 -1
- package/FBX/interpreter/geometry.d.ts +1 -1
- package/FBX/interpreter/geometry.js +150 -92
- package/FBX/interpreter/geometry.js.map +1 -1
- package/FBX/interpreter/legacyDocument.d.ts +11 -0
- package/FBX/interpreter/legacyDocument.js +425 -0
- package/FBX/interpreter/legacyDocument.js.map +1 -0
- package/FBX/interpreter/materialModel.d.ts +71 -0
- package/FBX/interpreter/materialModel.js +622 -0
- package/FBX/interpreter/materialModel.js.map +1 -0
- package/FBX/interpreter/materials.d.ts +13 -1
- package/FBX/interpreter/materials.js +88 -5
- package/FBX/interpreter/materials.js.map +1 -1
- package/FBX/interpreter/nodeTransform.d.ts +32 -0
- package/FBX/interpreter/nodeTransform.js +54 -0
- package/FBX/interpreter/nodeTransform.js.map +1 -0
- package/FBX/interpreter/nurbs.d.ts +99 -0
- package/FBX/interpreter/nurbs.js +627 -0
- package/FBX/interpreter/nurbs.js.map +1 -0
- package/FBX/interpreter/propertyTemplates.d.ts +23 -0
- package/FBX/interpreter/propertyTemplates.js +109 -2
- package/FBX/interpreter/propertyTemplates.js.map +1 -1
- package/FBX/interpreter/rig.js +16 -0
- package/FBX/interpreter/rig.js.map +1 -1
- package/FBX/interpreter/sceneDiagnostics.js +28 -3
- package/FBX/interpreter/sceneDiagnostics.js.map +1 -1
- package/FBX/interpreter/skeleton.d.ts +4 -18
- package/FBX/interpreter/skeleton.js +16 -94
- package/FBX/interpreter/skeleton.js.map +1 -1
- package/FBX/parsers/fbxAsciiParser.js +119 -9
- package/FBX/parsers/fbxAsciiParser.js.map +1 -1
- package/FBX/parsers/fbxBinaryParser.js +74 -22
- package/FBX/parsers/fbxBinaryParser.js.map +1 -1
- package/FBX/pure.d.ts +1 -0
- package/FBX/pure.js +1 -0
- package/FBX/pure.js.map +1 -1
- package/FBX/types/fbxTypes.d.ts +18 -2
- package/FBX/types/fbxTypes.js +40 -12
- package/FBX/types/fbxTypes.js.map +1 -1
- package/USD/usdCommandProtocol.d.ts +20 -4
- package/USD/usdCommandProtocol.js +25 -3
- package/USD/usdCommandProtocol.js.map +1 -1
- package/USD/usdFileLoader.pure.js +2 -0
- package/USD/usdFileLoader.pure.js.map +1 -1
- package/USD/usdSceneMaterializer.js +430 -92
- package/USD/usdSceneMaterializer.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,622 @@
|
|
|
1
|
+
var Flag;
|
|
2
|
+
(function (Flag) {
|
|
3
|
+
Flag[Flag["DefaultW1"] = 1] = "DefaultW1";
|
|
4
|
+
Flag[Flag["WidenToRgb"] = 2] = "WidenToRgb";
|
|
5
|
+
Flag[Flag["MultiplyValue"] = 4] = "MultiplyValue";
|
|
6
|
+
})(Flag || (Flag = {}));
|
|
7
|
+
var Transform;
|
|
8
|
+
(function (Transform) {
|
|
9
|
+
Transform[Transform["None"] = 0] = "None";
|
|
10
|
+
Transform[Transform["InvertX"] = 1] = "InvertX";
|
|
11
|
+
Transform[Transform["UnknownShininess"] = 2] = "UnknownShininess";
|
|
12
|
+
})(Transform || (Transform = {}));
|
|
13
|
+
var FeatureFlag;
|
|
14
|
+
(function (FeatureFlag) {
|
|
15
|
+
FeatureFlag[FeatureFlag["Inverted"] = 1] = "Inverted";
|
|
16
|
+
FeatureFlag[FeatureFlag["IfExists"] = 2] = "IfExists";
|
|
17
|
+
FeatureFlag[FeatureFlag["IfTexture"] = 4] = "IfTexture";
|
|
18
|
+
FeatureFlag[FeatureFlag["IfAround1"] = 8] = "IfAround1";
|
|
19
|
+
})(FeatureFlag || (FeatureFlag = {}));
|
|
20
|
+
const BASE_FBX = [
|
|
21
|
+
["diffuseColor", 1 /* Flag.DefaultW1 */, 0, "Diffuse"],
|
|
22
|
+
["diffuseColor", 1 /* Flag.DefaultW1 */, 0, "DiffuseColor"],
|
|
23
|
+
["diffuseFactor", 0, 0, "DiffuseFactor"],
|
|
24
|
+
["specularColor", 1 /* Flag.DefaultW1 */, 0, "Specular"],
|
|
25
|
+
["specularColor", 1 /* Flag.DefaultW1 */, 0, "SpecularColor"],
|
|
26
|
+
["specularFactor", 0, 0, "SpecularFactor"],
|
|
27
|
+
["specularExponent", 0, 0, "Shininess"],
|
|
28
|
+
["specularExponent", 0, 0, "ShininessExponent"],
|
|
29
|
+
["reflectionColor", 1 /* Flag.DefaultW1 */, 0, "Reflection"],
|
|
30
|
+
["reflectionColor", 1 /* Flag.DefaultW1 */, 0, "ReflectionColor"],
|
|
31
|
+
["reflectionFactor", 0, 0, "ReflectionFactor"],
|
|
32
|
+
["transparencyColor", 1 /* Flag.DefaultW1 */, 0, "Transparent"],
|
|
33
|
+
["transparencyColor", 1 /* Flag.DefaultW1 */, 0, "TransparentColor"],
|
|
34
|
+
["transparencyFactor", 0, 0, "TransparentFactor"],
|
|
35
|
+
["transparencyFactor", 0, 0, "TransparencyFactor"],
|
|
36
|
+
["emissionColor", 1 /* Flag.DefaultW1 */, 0, "Emissive"],
|
|
37
|
+
["emissionColor", 1 /* Flag.DefaultW1 */, 0, "EmissiveColor"],
|
|
38
|
+
["emissionFactor", 0, 0, "EmissiveFactor"],
|
|
39
|
+
["ambientColor", 1 /* Flag.DefaultW1 */, 0, "Ambient"],
|
|
40
|
+
["ambientColor", 1 /* Flag.DefaultW1 */, 0, "AmbientColor"],
|
|
41
|
+
["ambientFactor", 0, 0, "AmbientFactor"],
|
|
42
|
+
["normalMap", 0, 0, "NormalMap"],
|
|
43
|
+
["bump", 0, 0, "Bump"],
|
|
44
|
+
["bumpFactor", 0, 0, "BumpFactor"],
|
|
45
|
+
["displacement", 0, 0, "Displacement"],
|
|
46
|
+
["displacementFactor", 0, 0, "DisplacementFactor"],
|
|
47
|
+
["vectorDisplacement", 0, 0, "VectorDisplacement"],
|
|
48
|
+
["vectorDisplacementFactor", 0, 0, "VectorDisplacementFactor"],
|
|
49
|
+
];
|
|
50
|
+
const LAMBERT_PBR = [
|
|
51
|
+
["baseColor", 1 /* Flag.DefaultW1 */, 0, "Diffuse"],
|
|
52
|
+
["baseColor", 1 /* Flag.DefaultW1 */, 0, "DiffuseColor"],
|
|
53
|
+
["baseFactor", 0, 0, "DiffuseFactor"],
|
|
54
|
+
["transmissionColor", 1 /* Flag.DefaultW1 */, 0, "Transparent"],
|
|
55
|
+
["transmissionColor", 1 /* Flag.DefaultW1 */, 0, "TransparentColor"],
|
|
56
|
+
["transmissionFactor", 0, 0, "TransparentFactor"],
|
|
57
|
+
["transmissionFactor", 0, 0, "TransparencyFactor"],
|
|
58
|
+
["emissionColor", 1 /* Flag.DefaultW1 */, 0, "Emissive"],
|
|
59
|
+
["emissionColor", 1 /* Flag.DefaultW1 */, 0, "EmissiveColor"],
|
|
60
|
+
["emissionFactor", 0, 0, "EmissiveFactor"],
|
|
61
|
+
["normalMap", 0, 0, "NormalMap"],
|
|
62
|
+
];
|
|
63
|
+
const PHONG_PBR = [
|
|
64
|
+
["baseColor", 1 /* Flag.DefaultW1 */, 0, "Diffuse"],
|
|
65
|
+
["baseColor", 1 /* Flag.DefaultW1 */, 0, "DiffuseColor"],
|
|
66
|
+
["baseFactor", 0, 0, "DiffuseFactor"],
|
|
67
|
+
["specularColor", 1 /* Flag.DefaultW1 */, 0, "Specular"],
|
|
68
|
+
["specularColor", 1 /* Flag.DefaultW1 */, 0, "SpecularColor"],
|
|
69
|
+
["specularFactor", 0, 0, "SpecularFactor"],
|
|
70
|
+
["roughness", 0, 2 /* Transform.UnknownShininess */, "Shininess"],
|
|
71
|
+
["roughness", 0, 2 /* Transform.UnknownShininess */, "ShininessExponent"],
|
|
72
|
+
["transmissionColor", 1 /* Flag.DefaultW1 */, 0, "Transparent"],
|
|
73
|
+
["transmissionColor", 1 /* Flag.DefaultW1 */, 0, "TransparentColor"],
|
|
74
|
+
["transmissionFactor", 0, 0, "TransparentFactor"],
|
|
75
|
+
["transmissionFactor", 0, 0, "TransparencyFactor"],
|
|
76
|
+
["emissionColor", 1 /* Flag.DefaultW1 */, 0, "Emissive"],
|
|
77
|
+
["emissionColor", 1 /* Flag.DefaultW1 */, 0, "EmissiveColor"],
|
|
78
|
+
["emissionFactor", 0, 0, "EmissiveFactor"],
|
|
79
|
+
["normalMap", 0, 0, "NormalMap"],
|
|
80
|
+
];
|
|
81
|
+
const OSL_PBR = [
|
|
82
|
+
["baseFactor", 0, 0, "base"],
|
|
83
|
+
["baseColor", 1 /* Flag.DefaultW1 */, 0, "base_color"],
|
|
84
|
+
["roughness", 0, 0, "specular_roughness"],
|
|
85
|
+
["diffuseRoughness", 0, 0, "diffuse_roughness"],
|
|
86
|
+
["metalness", 0, 0, "metalness"],
|
|
87
|
+
["specularFactor", 0, 0, "specular"],
|
|
88
|
+
["specularColor", 1 /* Flag.DefaultW1 */, 0, "specular_color"],
|
|
89
|
+
["specularIor", 0, 0, "specular_IOR"],
|
|
90
|
+
["specularAnisotropy", 0, 0, "specular_anisotropy"],
|
|
91
|
+
["specularRotation", 0, 0, "specular_rotation"],
|
|
92
|
+
["transmissionFactor", 0, 0, "transmission"],
|
|
93
|
+
["transmissionColor", 1 /* Flag.DefaultW1 */, 0, "transmission_color"],
|
|
94
|
+
["transmissionDepth", 0, 0, "transmission_depth"],
|
|
95
|
+
["transmissionScatter", 2 /* Flag.WidenToRgb */, 0, "transmission_scatter"],
|
|
96
|
+
["transmissionScatterAnisotropy", 0, 0, "transmission_scatter_anisotropy"],
|
|
97
|
+
["transmissionDispersion", 0, 0, "transmission_dispersion"],
|
|
98
|
+
["transmissionExtraRoughness", 0, 0, "transmission_extra_roughness"],
|
|
99
|
+
["subsurfaceFactor", 0, 0, "subsurface"],
|
|
100
|
+
["subsurfaceColor", 1 /* Flag.DefaultW1 */, 0, "subsurface_color"],
|
|
101
|
+
["subsurfaceRadius", 2 /* Flag.WidenToRgb */, 0, "subsurface_radius"],
|
|
102
|
+
["subsurfaceScale", 0, 0, "subsurface_scale"],
|
|
103
|
+
["subsurfaceAnisotropy", 0, 0, "subsurface_anisotropy"],
|
|
104
|
+
["sheenFactor", 0, 0, "sheen"],
|
|
105
|
+
["sheenColor", 1 /* Flag.DefaultW1 */, 0, "sheen_color"],
|
|
106
|
+
["sheenRoughness", 0, 0, "sheen_roughness"],
|
|
107
|
+
["coatFactor", 0, 0, "coat"],
|
|
108
|
+
["coatColor", 1 /* Flag.DefaultW1 */, 0, "coat_color"],
|
|
109
|
+
["coatRoughness", 0, 0, "coat_roughness"],
|
|
110
|
+
["coatIor", 0, 0, "coat_IOR"],
|
|
111
|
+
["coatAnisotropy", 0, 0, "coat_anisotropy"],
|
|
112
|
+
["coatRotation", 0, 0, "coat_rotation"],
|
|
113
|
+
["coatNormal", 0, 0, "coat_normal"],
|
|
114
|
+
["coatAffectBaseColor", 1 /* Flag.DefaultW1 */, 0, "coat_affect_color"],
|
|
115
|
+
["coatAffectBaseRoughness", 0, 0, "coat_affect_roughness"],
|
|
116
|
+
["thinFilmThickness", 0, 0, "thin_film_thickness"],
|
|
117
|
+
["thinFilmIor", 0, 0, "thin_film_IOR"],
|
|
118
|
+
["emissionFactor", 0, 0, "emission"],
|
|
119
|
+
["emissionColor", 1 /* Flag.DefaultW1 */, 0, "emission_color"],
|
|
120
|
+
["opacity", 2 /* Flag.WidenToRgb */, 0, "opacity"],
|
|
121
|
+
["normalMap", 0, 0, "NormalMap"],
|
|
122
|
+
["normalMap", 0, 0, "normalCamera"],
|
|
123
|
+
["tangentMap", 0, 0, "tangent"],
|
|
124
|
+
];
|
|
125
|
+
const OSL_FEATURES = [["thinWalled", 0, "thin_walled"]];
|
|
126
|
+
const ARNOLD_PBR = [
|
|
127
|
+
["baseFactor", 0, 0, "base"],
|
|
128
|
+
["baseColor", 1 /* Flag.DefaultW1 */, 0, "baseColor"],
|
|
129
|
+
["roughness", 0, 0, "specularRoughness"],
|
|
130
|
+
["diffuseRoughness", 0, 0, "diffuseRoughness"],
|
|
131
|
+
["metalness", 0, 0, "metalness"],
|
|
132
|
+
["specularFactor", 0, 0, "specular"],
|
|
133
|
+
["specularColor", 1 /* Flag.DefaultW1 */, 0, "specularColor"],
|
|
134
|
+
["specularIor", 0, 0, "specularIOR"],
|
|
135
|
+
["specularAnisotropy", 0, 0, "specularAnisotropy"],
|
|
136
|
+
["specularRotation", 0, 0, "specularRotation"],
|
|
137
|
+
["transmissionFactor", 0, 0, "transmission"],
|
|
138
|
+
["transmissionColor", 1 /* Flag.DefaultW1 */, 0, "transmissionColor"],
|
|
139
|
+
["transmissionDepth", 0, 0, "transmissionDepth"],
|
|
140
|
+
["transmissionScatter", 2 /* Flag.WidenToRgb */, 0, "transmissionScatter"],
|
|
141
|
+
["transmissionScatterAnisotropy", 0, 0, "transmissionScatterAnisotropy"],
|
|
142
|
+
["transmissionDispersion", 0, 0, "transmissionDispersion"],
|
|
143
|
+
["transmissionExtraRoughness", 0, 0, "transmissionExtraRoughness"],
|
|
144
|
+
["subsurfaceFactor", 0, 0, "subsurface"],
|
|
145
|
+
["subsurfaceColor", 1 /* Flag.DefaultW1 */, 0, "subsurfaceColor"],
|
|
146
|
+
["subsurfaceRadius", 2 /* Flag.WidenToRgb */, 0, "subsurfaceRadius"],
|
|
147
|
+
["subsurfaceScale", 0, 0, "subsurfaceScale"],
|
|
148
|
+
["subsurfaceAnisotropy", 0, 0, "subsurfaceAnisotropy"],
|
|
149
|
+
["sheenFactor", 0, 0, "sheen"],
|
|
150
|
+
["sheenColor", 1 /* Flag.DefaultW1 */, 0, "sheenColor"],
|
|
151
|
+
["sheenRoughness", 0, 0, "sheenRoughness"],
|
|
152
|
+
["coatFactor", 0, 0, "coat"],
|
|
153
|
+
["coatColor", 1 /* Flag.DefaultW1 */, 0, "coatColor"],
|
|
154
|
+
["coatRoughness", 0, 0, "coatRoughness"],
|
|
155
|
+
["coatIor", 0, 0, "coatIOR"],
|
|
156
|
+
["coatAnisotropy", 0, 0, "coatAnisotropy"],
|
|
157
|
+
["coatRotation", 0, 0, "coatRotation"],
|
|
158
|
+
["coatNormal", 0, 0, "coatNormal"],
|
|
159
|
+
["thinFilmThickness", 0, 0, "thinFilmThickness"],
|
|
160
|
+
["thinFilmIor", 0, 0, "thinFilmIOR"],
|
|
161
|
+
["emissionFactor", 0, 0, "emission"],
|
|
162
|
+
["emissionColor", 1 /* Flag.DefaultW1 */, 0, "emissionColor"],
|
|
163
|
+
["opacity", 2 /* Flag.WidenToRgb */, 0, "opacity"],
|
|
164
|
+
["indirectDiffuse", 0, 0, "indirectDiffuse"],
|
|
165
|
+
["indirectSpecular", 0, 0, "indirectSpecular"],
|
|
166
|
+
["normalMap", 0, 0, "NormalMap"],
|
|
167
|
+
["normalMap", 0, 0, "normalCamera"],
|
|
168
|
+
["tangentMap", 0, 0, "tangent"],
|
|
169
|
+
["matteColor", 1 /* Flag.DefaultW1 */, 0, "aiMatteColor"],
|
|
170
|
+
["matteFactor", 0, 0, "aiMatteColorA"],
|
|
171
|
+
["subsurfaceType", 0, 0, "subsurfaceType"],
|
|
172
|
+
["transmissionPriority", 0, 0, "dielectricPriority"],
|
|
173
|
+
["transmissionEnableInAov", 0, 0, "transmitAovs"],
|
|
174
|
+
];
|
|
175
|
+
const ARNOLD_FEATURES = [
|
|
176
|
+
["matte", 0, "aiEnableMatte"],
|
|
177
|
+
["thinWalled", 0, "thinWalled"],
|
|
178
|
+
["caustics", 0, "caustics"],
|
|
179
|
+
["internalReflections", 0, "internalReflections"],
|
|
180
|
+
["exitToBackground", 0, "exitToBackground"],
|
|
181
|
+
];
|
|
182
|
+
const MAX_PHYSICAL_PBR = [
|
|
183
|
+
["baseFactor", 0, 0, "base_weight"],
|
|
184
|
+
["baseColor", 1 /* Flag.DefaultW1 */, 0, "base_color"],
|
|
185
|
+
["roughness", 0, 0, "roughness"],
|
|
186
|
+
["diffuseRoughness", 0, 0, "diff_rough"],
|
|
187
|
+
["diffuseRoughness", 0, 0, "diff_roughness"],
|
|
188
|
+
["metalness", 0, 0, "metalness"],
|
|
189
|
+
["specularFactor", 0, 0, "reflectivity"],
|
|
190
|
+
["specularColor", 1 /* Flag.DefaultW1 */, 0, "refl_color"],
|
|
191
|
+
["specularAnisotropy", 0, 0, "anisotropy"],
|
|
192
|
+
["specularRotation", 0, 0, "aniso_angle"],
|
|
193
|
+
["specularRotation", 0, 0, "anisoangle"],
|
|
194
|
+
["specularIor", 0, 0, "trans_ior"],
|
|
195
|
+
["transmissionFactor", 0, 0, "transparency"],
|
|
196
|
+
["transmissionColor", 1 /* Flag.DefaultW1 */, 0, "trans_color"],
|
|
197
|
+
["transmissionDepth", 0, 0, "trans_depth"],
|
|
198
|
+
["transmissionRoughness", 0, 0, "trans_rough"],
|
|
199
|
+
["transmissionRoughness", 0, 0, "trans_roughness"],
|
|
200
|
+
["subsurfaceFactor", 0, 0, "scattering"],
|
|
201
|
+
["subsurfaceTintColor", 1 /* Flag.DefaultW1 */, 0, "sss_color"],
|
|
202
|
+
["subsurfaceColor", 1 /* Flag.DefaultW1 */, 0, "sss_scatter_color"],
|
|
203
|
+
["subsurfaceRadius", 2 /* Flag.WidenToRgb */, 0, "sss_depth"],
|
|
204
|
+
["subsurfaceScale", 0, 0, "sss_scale"],
|
|
205
|
+
["coatFactor", 0, 0, "coat"],
|
|
206
|
+
["coatFactor", 0, 0, "coating"],
|
|
207
|
+
["coatColor", 1 /* Flag.DefaultW1 */, 0, "coat_color"],
|
|
208
|
+
["coatRoughness", 0, 0, "coat_rough"],
|
|
209
|
+
["coatRoughness", 0, 0, "coat_roughness"],
|
|
210
|
+
["coatIor", 0, 0, "coat_ior"],
|
|
211
|
+
["coatNormal", 0, 0, "coat_bump"],
|
|
212
|
+
["coatNormal", 0, 0, "clearcoat_bump_map_amt"],
|
|
213
|
+
["coatAffectBaseColor", 1 /* Flag.DefaultW1 */, 0, "coat_affect_color"],
|
|
214
|
+
["coatAffectBaseRoughness", 0, 0, "coat_affect_roughness"],
|
|
215
|
+
["emissionFactor", 0, 0, "emission"],
|
|
216
|
+
["emissionColor", 1 /* Flag.DefaultW1 */, 0, "emit_color"],
|
|
217
|
+
["opacity", 2 /* Flag.WidenToRgb */, 0, "cutout"],
|
|
218
|
+
["normalMap", 0, 0, "bump"],
|
|
219
|
+
["normalMap", 0, 0, "bump_map_amt"],
|
|
220
|
+
["displacementMap", 0, 0, "displacement"],
|
|
221
|
+
["displacementMap", 0, 0, "displacement_map_amt"],
|
|
222
|
+
["subsurfaceType", 0, 0, "subsurfaceType"],
|
|
223
|
+
];
|
|
224
|
+
const MAX_PHYSICAL_FEATURES = [
|
|
225
|
+
["thinWalled", 0, "thin_walled"],
|
|
226
|
+
["specular", 0, "material_mode"],
|
|
227
|
+
["diffuseRoughness", 0, "material_mode"],
|
|
228
|
+
["transmissionRoughness", 1 /* FeatureFlag.Inverted */, "trans_roughness_lock"],
|
|
229
|
+
["roughnessAsGlossiness", 0, "roughness_inv"],
|
|
230
|
+
["transmissionRoughnessAsGlossiness", 0, "trans_roughness_inv"],
|
|
231
|
+
["coatRoughnessAsGlossiness", 0, "coat_roughness_inv"],
|
|
232
|
+
];
|
|
233
|
+
const GLTF_PBR = [
|
|
234
|
+
["baseColor", 1 /* Flag.DefaultW1 */, 0, "main|baseColor"],
|
|
235
|
+
["roughness", 0, 0, "main|roughness"],
|
|
236
|
+
["metalness", 0, 0, "main|metalness"],
|
|
237
|
+
["normalMap", 0, 0, "main|normal"],
|
|
238
|
+
["ambientOcclusion", 0, 0, "main|ambientOcclusion"],
|
|
239
|
+
["emissionColor", 1 /* Flag.DefaultW1 */, 0, "main|emission"],
|
|
240
|
+
["emissionColor", 1 /* Flag.DefaultW1 */, 0, "main|emissionColor"],
|
|
241
|
+
["opacity", 2 /* Flag.WidenToRgb */, 0, "main|Alpha"],
|
|
242
|
+
["coatFactor", 0, 0, "extension|clearcoat"],
|
|
243
|
+
["coatRoughness", 0, 0, "extension|clearcoatRoughness"],
|
|
244
|
+
["coatNormal", 0, 0, "extension|clearcoatNormal"],
|
|
245
|
+
["sheenColor", 1 /* Flag.DefaultW1 */, 0, "extension|sheenColor"],
|
|
246
|
+
["sheenRoughness", 0, 0, "extension|sheenRoughness"],
|
|
247
|
+
["specularFactor", 0, 0, "extension|specular"],
|
|
248
|
+
["specularFactor", 0, 0, "extension|Specular"],
|
|
249
|
+
["specularColor", 1 /* Flag.DefaultW1 */, 0, "extension|specularcolor"],
|
|
250
|
+
["specularColor", 1 /* Flag.DefaultW1 */, 0, "extension|specularColor"],
|
|
251
|
+
["transmissionFactor", 0, 0, "extension|transmission"],
|
|
252
|
+
["specularIor", 0, 0, "extension|indexOfRefraction"],
|
|
253
|
+
];
|
|
254
|
+
const GLTF_FEATURES = [
|
|
255
|
+
["doubleSided", 0, "main|DoubleSided"],
|
|
256
|
+
["sheen", 0, "extension|enableSheen"],
|
|
257
|
+
["coat", 0, "extension|enableClearCoat"],
|
|
258
|
+
["transmission", 0, "extension|enableTransmission"],
|
|
259
|
+
["ior", 0, "extension|enableIndexOfRefraction"],
|
|
260
|
+
["specular", 0, "extension|enableSpecular"],
|
|
261
|
+
["unlit", 0, "extension|unlit"],
|
|
262
|
+
];
|
|
263
|
+
const OPENPBR_PBR = [
|
|
264
|
+
["baseFactor", 0, 0, "base_weight"],
|
|
265
|
+
["baseColor", 1 /* Flag.DefaultW1 */, 0, "base_color"],
|
|
266
|
+
["roughness", 0, 0, "specular_roughness"],
|
|
267
|
+
["diffuseRoughness", 0, 0, "base_diffuse_roughness"],
|
|
268
|
+
["metalness", 0, 0, "base_metalness"],
|
|
269
|
+
["specularFactor", 0, 0, "specular_weight"],
|
|
270
|
+
["specularColor", 1 /* Flag.DefaultW1 */, 0, "specular_color"],
|
|
271
|
+
["specularAnisotropy", 0, 0, "specular_roughness_anisotropy"],
|
|
272
|
+
["specularIor", 0, 0, "specular_ior"],
|
|
273
|
+
["transmissionFactor", 0, 0, "transmission_weight"],
|
|
274
|
+
["transmissionColor", 1 /* Flag.DefaultW1 */, 0, "transmission_color"],
|
|
275
|
+
["transmissionDepth", 0, 0, "transmission_depth"],
|
|
276
|
+
["transmissionScatter", 2 /* Flag.WidenToRgb */, 0, "transmission_scatter"],
|
|
277
|
+
["transmissionScatterAnisotropy", 0, 0, "transmission_scatter_anisotropy"],
|
|
278
|
+
["transmissionDispersion", 0, 0, "transmission_dispersion_scale"],
|
|
279
|
+
["subsurfaceFactor", 0, 0, "subsurface_weight"],
|
|
280
|
+
["subsurfaceColor", 1 /* Flag.DefaultW1 */, 0, "subsurface_color"],
|
|
281
|
+
["subsurfaceRadius", 2 /* Flag.WidenToRgb */, 0, "subsurface_radius_scale"],
|
|
282
|
+
["subsurfaceScale", 0, 0, "subsurface_radius"],
|
|
283
|
+
["subsurfaceAnisotropy", 0, 0, "subsurface_scatter_anisotropy"],
|
|
284
|
+
["coatFactor", 0, 0, "coat_weight"],
|
|
285
|
+
["coatColor", 1 /* Flag.DefaultW1 */, 0, "coat_color"],
|
|
286
|
+
["coatRoughness", 0, 0, "coat_roughness"],
|
|
287
|
+
["coatAnisotropy", 0, 0, "coat_roughness_anisotropy"],
|
|
288
|
+
["coatIor", 0, 0, "coat_ior"],
|
|
289
|
+
["coatNormal", 0, 0, "coat_normal_map"],
|
|
290
|
+
["sheenFactor", 0, 0, "fuzz_weight"],
|
|
291
|
+
["sheenColor", 1 /* Flag.DefaultW1 */, 0, "fuzz_color"],
|
|
292
|
+
["sheenRoughness", 0, 0, "fuzz_roughness"],
|
|
293
|
+
["emissionFactor", 0, 0, "emission_weight"],
|
|
294
|
+
["emissionFactor", 4 /* Flag.MultiplyValue */, 0, "emission_luminance"],
|
|
295
|
+
["emissionColor", 1 /* Flag.DefaultW1 */, 0, "emission_color"],
|
|
296
|
+
["thinFilmFactor", 0, 0, "thin_film_weight"],
|
|
297
|
+
["thinFilmThickness", 0, 0, "thin_film_thickness"],
|
|
298
|
+
["thinFilmIor", 0, 0, "thin_film_ior"],
|
|
299
|
+
["normalMap", 0, 0, "bump"],
|
|
300
|
+
["normalMap", 0, 0, "bump_map_amt"],
|
|
301
|
+
["displacementMap", 0, 0, "displacement"],
|
|
302
|
+
["displacementMap", 0, 0, "displacement_map_amt"],
|
|
303
|
+
["coatNormal", 0, 0, "coat_bump"],
|
|
304
|
+
["coatNormal", 0, 0, "coat_bump_map_amt"],
|
|
305
|
+
["tangentMap", 0, 0, "geometry_tangent_map"],
|
|
306
|
+
["opacity", 2 /* Flag.WidenToRgb */, 0, "geometry_opacity"],
|
|
307
|
+
];
|
|
308
|
+
const OPENPBR_FEATURES = [["thinWalled", 0, "geometry_thin_walled"]];
|
|
309
|
+
const MAX_METAL_ROUGH_PBR = [
|
|
310
|
+
["baseColor", 1 /* Flag.DefaultW1 */, 0, "base_color"],
|
|
311
|
+
["baseColor", 1 /* Flag.DefaultW1 */, 0, "baseColor"],
|
|
312
|
+
["roughness", 0, 0, "roughness"],
|
|
313
|
+
["roughness", 0, 0, "Roughness_Map"],
|
|
314
|
+
["metalness", 0, 0, "metalness"],
|
|
315
|
+
["ambientOcclusion", 0, 0, "ao"],
|
|
316
|
+
["normalMap", 0, 0, "norm"],
|
|
317
|
+
["emissionColor", 1 /* Flag.DefaultW1 */, 0, "emit_color"],
|
|
318
|
+
["displacementMap", 0, 0, "displacement"],
|
|
319
|
+
["displacementMap", 0, 0, "displacement_amt"],
|
|
320
|
+
["opacity", 2 /* Flag.WidenToRgb */, 0, "opacity"],
|
|
321
|
+
];
|
|
322
|
+
const MAX_SPEC_GLOSS_PBR = [
|
|
323
|
+
["baseColor", 1 /* Flag.DefaultW1 */, 0, "base_color"],
|
|
324
|
+
["baseColor", 1 /* Flag.DefaultW1 */, 0, "baseColor"],
|
|
325
|
+
["specularColor", 1 /* Flag.DefaultW1 */, 0, "Specular"],
|
|
326
|
+
["specularColor", 1 /* Flag.DefaultW1 */, 0, "specular"],
|
|
327
|
+
["roughness", 0, 0, "glossiness"],
|
|
328
|
+
["ambientOcclusion", 0, 0, "ao"],
|
|
329
|
+
["normalMap", 0, 0, "norm"],
|
|
330
|
+
["emissionColor", 1 /* Flag.DefaultW1 */, 0, "emit_color"],
|
|
331
|
+
["displacementMap", 0, 0, "displacement"],
|
|
332
|
+
["displacementMap", 0, 0, "displacement_amt"],
|
|
333
|
+
["opacity", 2 /* Flag.WidenToRgb */, 0, "opacity"],
|
|
334
|
+
];
|
|
335
|
+
const MAX_PBR_FEATURES = [["roughnessAsGlossiness", 8 /* FeatureFlag.IfAround1 */, "useGlossiness"]];
|
|
336
|
+
const SHADERFX_PBR = [
|
|
337
|
+
["baseColor", 1 /* Flag.DefaultW1 */, 0, "color"],
|
|
338
|
+
["baseColor", 1 /* Flag.DefaultW1 */, 0, "base_color"],
|
|
339
|
+
["roughness", 0, 0, "roughness"],
|
|
340
|
+
["metalness", 0, 0, "metallic"],
|
|
341
|
+
["normalMap", 0, 0, "normal"],
|
|
342
|
+
["emissionFactor", 0, 0, "emissive_intensity"],
|
|
343
|
+
["emissionColor", 1 /* Flag.DefaultW1 */, 0, "emissive"],
|
|
344
|
+
["ambientOcclusion", 0, 0, "ao"],
|
|
345
|
+
];
|
|
346
|
+
const PBR_COMMON = ["pbr", "metalness", "diffuse", "specular", "coat", "sheen", "transmission", "opacity", "ior", "diffuseRoughness"];
|
|
347
|
+
const SHADER_TABLES = {
|
|
348
|
+
unknown: { maps: PHONG_PBR, features: [], defaultFeatures: ["diffuse", "specular", "emission", "transmission"] },
|
|
349
|
+
fbxLambert: { maps: LAMBERT_PBR, features: [], defaultFeatures: ["diffuse", "emission", "transmission"] },
|
|
350
|
+
fbxPhong: { maps: PHONG_PBR, features: [], defaultFeatures: ["diffuse", "specular", "emission", "transmission"] },
|
|
351
|
+
oslStandardSurface: { maps: OSL_PBR, features: OSL_FEATURES, defaultFeatures: PBR_COMMON },
|
|
352
|
+
arnoldStandardSurface: { maps: ARNOLD_PBR, features: ARNOLD_FEATURES, defaultFeatures: PBR_COMMON },
|
|
353
|
+
"3dsMaxPhysicalMaterial": {
|
|
354
|
+
maps: MAX_PHYSICAL_PBR,
|
|
355
|
+
features: MAX_PHYSICAL_FEATURES,
|
|
356
|
+
defaultFeatures: ["pbr", "metalness", "diffuse", "coat", "sheen", "transmission", "opacity", "ior"],
|
|
357
|
+
textureSuffix: "_map",
|
|
358
|
+
textureEnabledSuffix: "_map_on",
|
|
359
|
+
},
|
|
360
|
+
"3dsMaxPbrMetalRough": { maps: MAX_METAL_ROUGH_PBR, features: MAX_PBR_FEATURES, defaultFeatures: ["pbr", "metalness", "diffuse", "opacity"], textureSuffix: "_map" },
|
|
361
|
+
"3dsMaxPbrSpecGloss": { maps: MAX_SPEC_GLOSS_PBR, features: MAX_PBR_FEATURES, defaultFeatures: ["pbr", "specular", "diffuse", "opacity"], textureSuffix: "_map" },
|
|
362
|
+
gltfMaterial: {
|
|
363
|
+
maps: GLTF_PBR,
|
|
364
|
+
features: GLTF_FEATURES,
|
|
365
|
+
defaultFeatures: ["pbr", "metalness", "diffuse", "emission", "opacity", "ambientOcclusion"],
|
|
366
|
+
textureSuffix: "Map",
|
|
367
|
+
},
|
|
368
|
+
openPbrMaterial: { maps: OPENPBR_PBR, features: OPENPBR_FEATURES, defaultFeatures: PBR_COMMON, textureSuffix: "_map", textureEnabledSuffix: "_map_on" },
|
|
369
|
+
shaderFxGraph: {
|
|
370
|
+
maps: SHADERFX_PBR,
|
|
371
|
+
features: [],
|
|
372
|
+
defaultFeatures: ["pbr", "metalness", "diffuse", "emission", "ambientOcclusion"],
|
|
373
|
+
texturePrefix: "TEX_",
|
|
374
|
+
textureSuffix: "_map",
|
|
375
|
+
textureEnabledPrefix: "use_",
|
|
376
|
+
textureEnabledSuffix: "_map",
|
|
377
|
+
},
|
|
378
|
+
};
|
|
379
|
+
/** Shader types whose parameters are physically based; the loader emits PBR materials for them by default. */
|
|
380
|
+
export function isPbrShaderType(type) {
|
|
381
|
+
return type !== "unknown" && type !== "fbxLambert" && type !== "fbxPhong";
|
|
382
|
+
}
|
|
383
|
+
function applyTransform(transform, v) {
|
|
384
|
+
switch (transform) {
|
|
385
|
+
case 1 /* Transform.InvertX */:
|
|
386
|
+
v[0] = 1 - v[0];
|
|
387
|
+
break;
|
|
388
|
+
case 2 /* Transform.UnknownShininess */:
|
|
389
|
+
// Roughness from a Phong exponent, the same heuristic the FBX SDK / ufbx uses.
|
|
390
|
+
if (v[0] >= 0) {
|
|
391
|
+
v[0] = 1 - Math.sqrt(v[0]) * 0.1;
|
|
392
|
+
if (v[0] < 0) {
|
|
393
|
+
v[0] = 0;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
break;
|
|
397
|
+
default:
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
function numericValues(values) {
|
|
402
|
+
const out = [];
|
|
403
|
+
for (const v of values) {
|
|
404
|
+
if (typeof v === "number") {
|
|
405
|
+
out.push(v);
|
|
406
|
+
}
|
|
407
|
+
else if (typeof v === "boolean") {
|
|
408
|
+
out.push(v ? 1 : 0);
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
break;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
return out;
|
|
415
|
+
}
|
|
416
|
+
/** Detects the shader flavour of a material from its shading model name, connected shader and 3ds Max class ids. */
|
|
417
|
+
export function detectShaderType(source) {
|
|
418
|
+
let shaderType = "unknown";
|
|
419
|
+
const model = source.shadingModelName.toLowerCase();
|
|
420
|
+
if (model === "lambert") {
|
|
421
|
+
shaderType = "fbxLambert";
|
|
422
|
+
}
|
|
423
|
+
else if (model === "phong") {
|
|
424
|
+
shaderType = "fbxPhong";
|
|
425
|
+
}
|
|
426
|
+
if (source.shader) {
|
|
427
|
+
switch (source.shader.renderApi) {
|
|
428
|
+
case "ARNOLD_SHADER_ID":
|
|
429
|
+
return { shaderType: "arnoldStandardSurface", shaderPropPrefix: "" };
|
|
430
|
+
case "OSL":
|
|
431
|
+
return { shaderType: "oslStandardSurface", shaderPropPrefix: "" };
|
|
432
|
+
case "SFX_PBS_SHADER":
|
|
433
|
+
return { shaderType: "shaderFxGraph", shaderPropPrefix: "" };
|
|
434
|
+
default:
|
|
435
|
+
return { shaderType: "unknown", shaderPropPrefix: "" };
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
if (shaderType === "unknown") {
|
|
439
|
+
const a = (numericValues(source.props.get("3dsMax|ClassIDa")?.values ?? [])[0] ?? 0) >>> 0;
|
|
440
|
+
const b = (numericValues(source.props.get("3dsMax|ClassIDb")?.values ?? [])[0] ?? 0) >>> 0;
|
|
441
|
+
if (a === 0x3d6b1cec && b === 0xdeadc001) {
|
|
442
|
+
return { shaderType: "3dsMaxPhysicalMaterial", shaderPropPrefix: "3dsMax|Parameters|" };
|
|
443
|
+
}
|
|
444
|
+
if (a === 0xf1551e33 && b === 0x37fb1337) {
|
|
445
|
+
return { shaderType: "openPbrMaterial", shaderPropPrefix: "3dsMax|Parameters|" };
|
|
446
|
+
}
|
|
447
|
+
if (a === 0x38420192 && b === 0x45fe4e1b) {
|
|
448
|
+
return { shaderType: "gltfMaterial", shaderPropPrefix: "3dsMax|" };
|
|
449
|
+
}
|
|
450
|
+
if (a === 0xd00f1e00 && b === 0xbe77e500) {
|
|
451
|
+
return { shaderType: "3dsMaxPbrMetalRough", shaderPropPrefix: "3dsMax|main|" };
|
|
452
|
+
}
|
|
453
|
+
if (a === 0xd00f1e00 && b === 0x01dbad33) {
|
|
454
|
+
return { shaderType: "3dsMaxPbrSpecGloss", shaderPropPrefix: "3dsMax|main|" };
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return { shaderType, shaderPropPrefix: "" };
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Resolves the unified material model from raw material data.
|
|
461
|
+
*/
|
|
462
|
+
export function resolveMaterialModel(source) {
|
|
463
|
+
var _a;
|
|
464
|
+
const { shaderType, shaderPropPrefix } = detectShaderType(source);
|
|
465
|
+
const table = SHADER_TABLES[shaderType];
|
|
466
|
+
const model = { shaderType, shaderPropPrefix, fbx: {}, pbr: {}, features: {} };
|
|
467
|
+
for (const f of table.defaultFeatures) {
|
|
468
|
+
model.features[f] = { enabled: true, explicit: false };
|
|
469
|
+
}
|
|
470
|
+
const materialPropsFor = (semantic) => {
|
|
471
|
+
const bound = source.shader?.bindings.get(semantic);
|
|
472
|
+
return bound && bound.length > 0 ? bound : [semantic];
|
|
473
|
+
};
|
|
474
|
+
const prefix = source.shader ? "" : shaderPropPrefix;
|
|
475
|
+
const fetch = (entries, target, prefix2, suffix, wantValue, wantTexture, wantEnabled) => {
|
|
476
|
+
for (const [mapName, flags, transform, prop] of entries) {
|
|
477
|
+
const semantic = prefix + prefix2 + prop + suffix;
|
|
478
|
+
for (const name of materialPropsFor(semantic)) {
|
|
479
|
+
const entry = source.props.get(name);
|
|
480
|
+
const map = (target[mapName] ?? (target[mapName] = { valueComponents: 0, textureEnabled: false }));
|
|
481
|
+
if (wantValue && entry && entry.type !== "Reference") {
|
|
482
|
+
const nums = numericValues(entry.values);
|
|
483
|
+
if (nums.length > 0) {
|
|
484
|
+
const v = nums.slice(0, 4);
|
|
485
|
+
if (flags & 4 /* Flag.MultiplyValue */) {
|
|
486
|
+
v[0] *= map.value?.[0] ?? 1;
|
|
487
|
+
map.value = [v[0], ...(map.value?.slice(1) ?? [])];
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
map.value = v;
|
|
491
|
+
}
|
|
492
|
+
applyTransform(transform, map.value);
|
|
493
|
+
const components = nums.length >= 4 ? 4 : nums.length === 3 ? 3 : nums.length === 2 ? 2 : 1;
|
|
494
|
+
if (flags & 1 /* Flag.DefaultW1 */ && components < 4) {
|
|
495
|
+
map.value[3] = 1;
|
|
496
|
+
}
|
|
497
|
+
if (flags & 2 /* Flag.WidenToRgb */ && components === 1) {
|
|
498
|
+
map.value[1] = map.value[0];
|
|
499
|
+
map.value[2] = map.value[0];
|
|
500
|
+
}
|
|
501
|
+
map.valueComponents = components;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
if (wantTexture) {
|
|
505
|
+
const texture = source.texturesByProp.get(name);
|
|
506
|
+
if (texture) {
|
|
507
|
+
map.texture = texture;
|
|
508
|
+
map.textureEnabled = true;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
if (wantEnabled && entry) {
|
|
512
|
+
const nums = numericValues(entry.values);
|
|
513
|
+
if (nums.length > 0) {
|
|
514
|
+
map.textureEnabled = nums[0] !== 0;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
// Classic Lambert/Phong parameters are always read.
|
|
521
|
+
fetch(BASE_FBX, model.fbx, "", "", true, true, false);
|
|
522
|
+
// Shader specific parameters, textures with vendor prefix/suffix, and texture toggles.
|
|
523
|
+
if (table.texturePrefix || table.textureSuffix) {
|
|
524
|
+
fetch(table.maps, model.pbr, table.texturePrefix ?? "", table.textureSuffix ?? "", false, true, false);
|
|
525
|
+
}
|
|
526
|
+
fetch(table.maps, model.pbr, "", "", true, true, false);
|
|
527
|
+
if (table.textureEnabledPrefix || table.textureEnabledSuffix) {
|
|
528
|
+
fetch(table.maps, model.pbr, table.textureEnabledPrefix ?? "", table.textureEnabledSuffix ?? "", false, false, true);
|
|
529
|
+
}
|
|
530
|
+
// Feature toggles
|
|
531
|
+
for (const [feature, flags, prop] of table.features) {
|
|
532
|
+
const semantic = prefix + prop;
|
|
533
|
+
for (const name of materialPropsFor(semantic)) {
|
|
534
|
+
const entry = source.props.get(name);
|
|
535
|
+
const info = ((_a = model.features)[feature] ?? (_a[feature] = { enabled: false, explicit: false }));
|
|
536
|
+
if (entry && entry.type !== "Reference") {
|
|
537
|
+
const nums = numericValues(entry.values);
|
|
538
|
+
if (nums.length > 0) {
|
|
539
|
+
info.enabled = nums[0] !== 0;
|
|
540
|
+
info.explicit = true;
|
|
541
|
+
if (flags & 8 /* FeatureFlag.IfAround1 */) {
|
|
542
|
+
info.enabled = nums[0] >= 0.5 && nums[0] <= 1.5;
|
|
543
|
+
}
|
|
544
|
+
if (flags & 1 /* FeatureFlag.Inverted */) {
|
|
545
|
+
info.enabled = !info.enabled;
|
|
546
|
+
}
|
|
547
|
+
if (flags & 2 /* FeatureFlag.IfExists */) {
|
|
548
|
+
info.enabled = true;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
if (flags & 4 /* FeatureFlag.IfTexture */ && source.texturesByProp.has(name)) {
|
|
553
|
+
info.enabled = true;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
// Factors default to 1 when the matching colour is set and non-zero, 0 otherwise.
|
|
558
|
+
const updateFactor = (target, factorName, colorName) => {
|
|
559
|
+
const factor = (target[factorName] ?? (target[factorName] = { valueComponents: 0, textureEnabled: false }));
|
|
560
|
+
if (factor.value) {
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
const color = target[colorName];
|
|
564
|
+
const nonZero = color?.value && color.value.some((c) => c !== 0);
|
|
565
|
+
factor.value = [nonZero ? 1 : 0];
|
|
566
|
+
factor.valueComponents = 1;
|
|
567
|
+
};
|
|
568
|
+
updateFactor(model.fbx, "diffuseFactor", "diffuseColor");
|
|
569
|
+
updateFactor(model.fbx, "specularFactor", "specularColor");
|
|
570
|
+
updateFactor(model.fbx, "reflectionFactor", "reflectionColor");
|
|
571
|
+
updateFactor(model.fbx, "transparencyFactor", "transparencyColor");
|
|
572
|
+
updateFactor(model.fbx, "emissionFactor", "emissionColor");
|
|
573
|
+
updateFactor(model.fbx, "ambientFactor", "ambientColor");
|
|
574
|
+
updateFactor(model.pbr, "baseFactor", "baseColor");
|
|
575
|
+
updateFactor(model.pbr, "specularFactor", "specularColor");
|
|
576
|
+
updateFactor(model.pbr, "emissionFactor", "emissionColor");
|
|
577
|
+
updateFactor(model.pbr, "sheenFactor", "sheenColor");
|
|
578
|
+
updateFactor(model.pbr, "thinFilmFactor", "thinFilmThickness");
|
|
579
|
+
updateFactor(model.pbr, "transmissionFactor", "transmissionColor");
|
|
580
|
+
if (!model.pbr.transmissionRoughness?.value && model.pbr.roughness?.value && model.pbr.transmissionExtraRoughness?.value) {
|
|
581
|
+
model.pbr.transmissionRoughness = {
|
|
582
|
+
value: [model.pbr.roughness.value[0] + model.pbr.transmissionExtraRoughness.value[0]],
|
|
583
|
+
valueComponents: 1,
|
|
584
|
+
textureEnabled: false,
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
// Roughness <-> glossiness
|
|
588
|
+
const remaps = [
|
|
589
|
+
["roughnessAsGlossiness", "roughness", "glossiness"],
|
|
590
|
+
["coatRoughnessAsGlossiness", "coatRoughness", "coatGlossiness"],
|
|
591
|
+
["transmissionRoughnessAsGlossiness", "transmissionRoughness", "transmissionGlossiness"],
|
|
592
|
+
];
|
|
593
|
+
for (const [feature, roughName, glossName] of remaps) {
|
|
594
|
+
const rough = model.pbr[roughName];
|
|
595
|
+
if (model.features[feature]?.enabled) {
|
|
596
|
+
if (rough) {
|
|
597
|
+
model.pbr[glossName] = rough;
|
|
598
|
+
model.pbr[roughName] = rough.value ? { value: [1 - rough.value[0]], valueComponents: 1, textureEnabled: false } : { valueComponents: 0, textureEnabled: false };
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
else if (rough?.value) {
|
|
602
|
+
model.pbr[glossName] = { value: [1 - rough.value[0]], valueComponents: 1, textureEnabled: false };
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
return model;
|
|
606
|
+
}
|
|
607
|
+
/** Colour (first three components) of a map, or undefined. */
|
|
608
|
+
export function mapColor(map) {
|
|
609
|
+
if (!map?.value) {
|
|
610
|
+
return undefined;
|
|
611
|
+
}
|
|
612
|
+
const v = map.value;
|
|
613
|
+
if (map.valueComponents === 1) {
|
|
614
|
+
return [v[0], v[0], v[0]];
|
|
615
|
+
}
|
|
616
|
+
return [v[0], v[1] ?? v[0], v[2] ?? v[0]];
|
|
617
|
+
}
|
|
618
|
+
/** Scalar (first component) of a map, or undefined. */
|
|
619
|
+
export function mapScalar(map) {
|
|
620
|
+
return map?.value ? map.value[0] : undefined;
|
|
621
|
+
}
|
|
622
|
+
//# sourceMappingURL=materialModel.js.map
|