@configura/web-core 2.1.0-alpha.2 → 2.1.0-alpha.3
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/.eslintrc.json +5 -5
- package/LICENSE +201 -201
- package/README.md +1 -1
- package/dist/cm/basic/Color.d.ts +16 -16
- package/dist/cm/basic/Color.js +18 -18
- package/dist/cm/basic/ColorF.d.ts +9 -9
- package/dist/cm/basic/ColorF.js +10 -10
- package/dist/cm/basic/boolean.d.ts +2 -2
- package/dist/cm/basic/boolean.js +11 -11
- package/dist/cm/basic/number.d.ts +3 -3
- package/dist/cm/basic/number.js +18 -18
- package/dist/cm/basic/string.d.ts +2 -2
- package/dist/cm/basic/string.js +11 -11
- package/dist/cm/core3D/ATriMeshF.d.ts +96 -96
- package/dist/cm/core3D/ATriMeshF.js +197 -197
- package/dist/cm/core3D/GMaterial3D.d.ts +62 -62
- package/dist/cm/core3D/GMaterial3D.js +112 -112
- package/dist/cm/core3D/GMaterialClassic.d.ts +55 -55
- package/dist/cm/core3D/GMaterialClassic.js +171 -171
- package/dist/cm/core3D/GMaterialPBR.d.ts +73 -73
- package/dist/cm/core3D/GMaterialPBR.js +314 -314
- package/dist/cm/core3D/MultiGMaterial3D.d.ts +8 -8
- package/dist/cm/core3D/MultiGMaterial3D.js +17 -17
- package/dist/cm/core3D/uvmapper/UVMapEnv.d.ts +19 -19
- package/dist/cm/core3D/uvmapper/UVMapEnv.js +47 -47
- package/dist/cm/core3D/uvmapper/UVMapper.d.ts +41 -41
- package/dist/cm/core3D/uvmapper/UVMapper.js +94 -94
- package/dist/cm/core3D/uvmapper/UVMapperBox.d.ts +4 -4
- package/dist/cm/core3D/uvmapper/UVMapperBox.js +181 -181
- package/dist/cm/core3D/uvmapper/UVMapperCylinder.d.ts +9 -9
- package/dist/cm/core3D/uvmapper/UVMapperCylinder.js +96 -96
- package/dist/cm/core3D/uvmapper/UVMapperPlane.d.ts +3 -3
- package/dist/cm/core3D/uvmapper/UVMapperPlane.js +84 -84
- package/dist/cm/core3D/uvmapper/UVTransformer.d.ts +5 -5
- package/dist/cm/core3D/uvmapper/UVTransformer.js +5 -5
- package/dist/cm/core3D/uvmapper/instantiateUVMapper.d.ts +3 -3
- package/dist/cm/core3D/uvmapper/instantiateUVMapper.js +4 -4
- package/dist/cm/format/cmsym/InvalidationEnv.d.ts +9 -9
- package/dist/cm/format/cmsym/InvalidationEnv.js +13 -13
- package/dist/cm/format/cmsym/SymImportEnv.d.ts +9 -9
- package/dist/cm/format/cmsym/SymImportEnv.js +9 -9
- package/dist/cm/format/cmsym/SymInv.d.ts +8 -8
- package/dist/cm/format/cmsym/SymInv.js +17 -17
- package/dist/cm/format/cmsym/SymNode.d.ts +94 -94
- package/dist/cm/format/cmsym/SymNode.js +652 -652
- package/dist/cm/format/cmsym/components/SymBox.d.ts +15 -15
- package/dist/cm/format/cmsym/components/SymBox.js +39 -39
- package/dist/cm/format/cmsym/components/SymComponent.d.ts +29 -29
- package/dist/cm/format/cmsym/components/SymComponent.js +56 -56
- package/dist/cm/format/cmsym/components/SymConnector.d.ts +5 -5
- package/dist/cm/format/cmsym/components/SymConnector.js +10 -10
- package/dist/cm/format/cmsym/components/SymDexObj.d.ts +11 -11
- package/dist/cm/format/cmsym/components/SymDexObj.js +10 -10
- package/dist/cm/format/cmsym/components/SymGFX.d.ts +11 -11
- package/dist/cm/format/cmsym/components/SymGFX.js +20 -20
- package/dist/cm/format/cmsym/components/SymGMaterial.d.ts +19 -19
- package/dist/cm/format/cmsym/components/SymGMaterial.js +88 -88
- package/dist/cm/format/cmsym/components/SymGMaterialSelector.d.ts +17 -17
- package/dist/cm/format/cmsym/components/SymGMaterialSelector.js +22 -22
- package/dist/cm/format/cmsym/components/SymGetMeshEnv.d.ts +9 -9
- package/dist/cm/format/cmsym/components/SymGetMeshEnv.js +9 -9
- package/dist/cm/format/cmsym/components/SymLODGroup.d.ts +9 -9
- package/dist/cm/format/cmsym/components/SymLODGroup.js +13 -13
- package/dist/cm/format/cmsym/components/SymLight.d.ts +8 -8
- package/dist/cm/format/cmsym/components/SymLight.js +10 -10
- package/dist/cm/format/cmsym/components/SymLines2D.d.ts +5 -5
- package/dist/cm/format/cmsym/components/SymLines2D.js +7 -7
- package/dist/cm/format/cmsym/components/SymMeasure.d.ts +33 -33
- package/dist/cm/format/cmsym/components/SymMeasure.js +149 -149
- package/dist/cm/format/cmsym/components/SymMesh.d.ts +29 -29
- package/dist/cm/format/cmsym/components/SymMesh.js +130 -130
- package/dist/cm/format/cmsym/components/SymMeshLight.d.ts +8 -8
- package/dist/cm/format/cmsym/components/SymMeshLight.js +10 -10
- package/dist/cm/format/cmsym/components/SymMultiSelector.d.ts +13 -13
- package/dist/cm/format/cmsym/components/SymMultiSelector.js +48 -48
- package/dist/cm/format/cmsym/components/SymParams.d.ts +16 -16
- package/dist/cm/format/cmsym/components/SymParams.js +58 -58
- package/dist/cm/format/cmsym/components/SymPlane.d.ts +15 -15
- package/dist/cm/format/cmsym/components/SymPlane.js +30 -30
- package/dist/cm/format/cmsym/components/SymPlaneDivider.d.ts +4 -4
- package/dist/cm/format/cmsym/components/SymPlaneDivider.js +7 -7
- package/dist/cm/format/cmsym/components/SymPrimitive2D.d.ts +3 -3
- package/dist/cm/format/cmsym/components/SymPrimitive2D.js +3 -3
- package/dist/cm/format/cmsym/components/SymProgs.d.ts +32 -32
- package/dist/cm/format/cmsym/components/SymProgs.js +120 -120
- package/dist/cm/format/cmsym/components/SymProps.d.ts +54 -54
- package/dist/cm/format/cmsym/components/SymProps.js +171 -171
- package/dist/cm/format/cmsym/components/SymRep.d.ts +13 -13
- package/dist/cm/format/cmsym/components/SymRep.js +28 -28
- package/dist/cm/format/cmsym/components/SymReps.d.ts +36 -36
- package/dist/cm/format/cmsym/components/SymReps.js +230 -230
- package/dist/cm/format/cmsym/components/SymShape.d.ts +10 -10
- package/dist/cm/format/cmsym/components/SymShape.js +17 -17
- package/dist/cm/format/cmsym/components/SymSphere.d.ts +18 -18
- package/dist/cm/format/cmsym/components/SymSphere.js +33 -33
- package/dist/cm/format/cmsym/components/SymSpotlight.d.ts +8 -8
- package/dist/cm/format/cmsym/components/SymSpotlight.js +10 -10
- package/dist/cm/format/cmsym/components/SymTags.d.ts +11 -11
- package/dist/cm/format/cmsym/components/SymTags.js +20 -20
- package/dist/cm/format/cmsym/components/SymText2D.d.ts +5 -5
- package/dist/cm/format/cmsym/components/SymText2D.js +8 -8
- package/dist/cm/format/cmsym/components/SymText3D.d.ts +5 -5
- package/dist/cm/format/cmsym/components/SymText3D.js +8 -8
- package/dist/cm/format/cmsym/components/SymTransform.d.ts +23 -23
- package/dist/cm/format/cmsym/components/SymTransform.js +101 -101
- package/dist/cm/format/cmsym/components/SymUVMapper.d.ts +13 -13
- package/dist/cm/format/cmsym/components/SymUVMapper.js +50 -50
- package/dist/cm/format/cmsym/components/instantiate.d.ts +2 -2
- package/dist/cm/format/cmsym/components/instantiate.js +121 -121
- package/dist/cm/format/cmsym/components/legacy.d.ts +7 -7
- package/dist/cm/format/cmsym/components/legacy.js +27 -27
- package/dist/cm/format/cmsym/components/mesh.d.ts +8 -8
- package/dist/cm/format/cmsym/components/mesh.js +28 -28
- package/dist/cm/format/cmsym/invalidation.d.ts +4 -4
- package/dist/cm/format/cmsym/invalidation.js +72 -72
- package/dist/cm/format/dex/DexIRef.d.ts +9 -9
- package/dist/cm/format/dex/DexIRef.js +18 -18
- package/dist/cm/format/dex/DexInt.d.ts +11 -11
- package/dist/cm/format/dex/DexInt.js +18 -18
- package/dist/cm/format/dex/DexInternalizedXRef.d.ts +19 -19
- package/dist/cm/format/dex/DexInternalizedXRef.js +65 -65
- package/dist/cm/format/dex/DexLoader.d.ts +8 -8
- package/dist/cm/format/dex/DexLoader.js +12 -12
- package/dist/cm/format/dex/DexManager.d.ts +20 -20
- package/dist/cm/format/dex/DexManager.js +78 -78
- package/dist/cm/format/dex/DexObj.d.ts +15 -15
- package/dist/cm/format/dex/DexObj.js +86 -86
- package/dist/cm/format/dex/DexReader.d.ts +90 -90
- package/dist/cm/format/dex/DexReader.js +532 -532
- package/dist/cm/format/dex/DexRef.d.ts +6 -6
- package/dist/cm/format/dex/DexRef.js +8 -8
- package/dist/cm/format/dex/DexReplacedXRefs.d.ts +9 -9
- package/dist/cm/format/dex/DexReplacedXRefs.js +22 -22
- package/dist/cm/format/dex/DexURL.d.ts +4 -4
- package/dist/cm/format/dex/DexURL.js +5 -5
- package/dist/cm/format/dex/DexVersion.d.ts +15 -15
- package/dist/cm/format/dex/DexVersion.js +53 -53
- package/dist/cm/format/dex/DexXRef.d.ts +18 -18
- package/dist/cm/format/dex/DexXRef.js +51 -51
- package/dist/cm/format/dex/DexXRefTargetFilter.d.ts +4 -4
- package/dist/cm/format/dex/DexXRefTargetFilter.js +5 -5
- package/dist/cm/geometry/Angle.d.ts +9 -9
- package/dist/cm/geometry/Angle.js +18 -18
- package/dist/cm/geometry/AngleF.d.ts +5 -5
- package/dist/cm/geometry/AngleF.js +8 -8
- package/dist/cm/geometry/Box.d.ts +7 -7
- package/dist/cm/geometry/Box.js +9 -9
- package/dist/cm/geometry/DetailMask.d.ts +37 -37
- package/dist/cm/geometry/DetailMask.js +114 -114
- package/dist/cm/geometry/LayerExpr.d.ts +2 -2
- package/dist/cm/geometry/LayerExpr.js +2 -2
- package/dist/cm/geometry/Matrix22.d.ts +7 -7
- package/dist/cm/geometry/Matrix22.js +9 -9
- package/dist/cm/geometry/Matrix33.d.ts +42 -42
- package/dist/cm/geometry/Matrix33.js +124 -124
- package/dist/cm/geometry/Orientation.d.ts +7 -7
- package/dist/cm/geometry/Orientation.js +7 -7
- package/dist/cm/geometry/Plane.d.ts +8 -8
- package/dist/cm/geometry/Plane.js +14 -14
- package/dist/cm/geometry/Point.d.ts +21 -21
- package/dist/cm/geometry/Point.js +65 -65
- package/dist/cm/geometry/Point2D.d.ts +9 -9
- package/dist/cm/geometry/Point2D.js +23 -23
- package/dist/cm/geometry/PointF.d.ts +11 -11
- package/dist/cm/geometry/PointF.js +27 -27
- package/dist/cm/geometry/Transform.d.ts +11 -11
- package/dist/cm/geometry/Transform.js +61 -61
- package/dist/cm/geometry/Transform2D.d.ts +7 -7
- package/dist/cm/geometry/Transform2D.js +6 -6
- package/dist/cm/io/Semver.d.ts +18 -18
- package/dist/cm/io/Semver.js +61 -61
- package/dist/index.js +1 -1
- package/package.json +4 -4
|
@@ -1,314 +1,314 @@
|
|
|
1
|
-
import { ColorF } from "../basic/ColorF.js";
|
|
2
|
-
import { DexObj } from "../format/dex/DexObj.js";
|
|
3
|
-
import { AngleF } from "../geometry/AngleF.js";
|
|
4
|
-
import { GMaterial3D, GMaterial3DTexture, imageUrlFromDex, textureWrapFromDex, } from "./GMaterial3D.js";
|
|
5
|
-
// tslint:disable:max-classes-per-file
|
|
6
|
-
export class GMaterialPBR extends GMaterial3D {
|
|
7
|
-
constructor(log, obj) {
|
|
8
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
9
|
-
super(log, obj);
|
|
10
|
-
if (obj === undefined) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const pbr = obj.get("pbr");
|
|
14
|
-
if (!(pbr instanceof DexObj)) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
let txtType = "base" /* pbrBase */;
|
|
18
|
-
let prop = pbr.get(txtType);
|
|
19
|
-
if (prop instanceof DexObj) {
|
|
20
|
-
this.base = new PBRBase(loadColorF(log, txtType, prop, "factor"), loadTexture(log, txtType, prop));
|
|
21
|
-
}
|
|
22
|
-
txtType = "emissive" /* pbrEmissive */;
|
|
23
|
-
prop = pbr.get(txtType);
|
|
24
|
-
if (prop instanceof DexObj) {
|
|
25
|
-
this.emissive = new PBREmissive(loadColorF(log, txtType, prop, "factor"), loadTexture(log, txtType, prop));
|
|
26
|
-
}
|
|
27
|
-
txtType = "metallic" /* pbrMetallic */;
|
|
28
|
-
prop = pbr.get(txtType);
|
|
29
|
-
if (prop instanceof DexObj) {
|
|
30
|
-
const texture = loadTexture(log, txtType, prop);
|
|
31
|
-
let channel = texture && loadChannel(log, txtType, prop);
|
|
32
|
-
if (channel && channel !== "r" && channel !== "b") {
|
|
33
|
-
log.warn(`Unsupported ${txtType} texture channel: ${channel}`, "Fallback to b.");
|
|
34
|
-
channel = "b"; // B channel in ORM texture
|
|
35
|
-
}
|
|
36
|
-
this.metallic = new PBRMetallic((_a = loadNumber(log, txtType, prop, "factor")) !== null && _a !== void 0 ? _a : 1, texture, channel);
|
|
37
|
-
}
|
|
38
|
-
txtType = "normal" /* pbrNormal */;
|
|
39
|
-
prop = pbr.get(txtType);
|
|
40
|
-
if (prop instanceof DexObj) {
|
|
41
|
-
this.normal = new PBRNormal((_b = loadNumber(log, txtType, prop, "scale")) !== null && _b !== void 0 ? _b : 1, loadTexture(log, txtType, prop), loadChannels(log, txtType, prop));
|
|
42
|
-
}
|
|
43
|
-
txtType = "opacity" /* pbrOpacity */;
|
|
44
|
-
prop = pbr.get(txtType);
|
|
45
|
-
if (prop instanceof DexObj) {
|
|
46
|
-
const texture = loadTexture(log, txtType, prop);
|
|
47
|
-
let channel = texture && loadChannel(log, txtType, prop);
|
|
48
|
-
if (channel && channel !== "r" && channel !== "a") {
|
|
49
|
-
log.warn(`Unsupported ${txtType} texture channel: ${channel}`, "Fallback to a.");
|
|
50
|
-
channel = "a"; // Alpha channel, safest fallback
|
|
51
|
-
}
|
|
52
|
-
this.opacity = new PBROpacity((_c = loadNumber(log, txtType, prop, "factor")) !== null && _c !== void 0 ? _c : 1, loadOpacityMode(log, txtType, prop), (_d = loadNumber(log, txtType, prop, "maskThreshold")) !== null && _d !== void 0 ? _d : 0.5, texture, channel, loadBool(log, txtType, prop, "useAlphaFromBase"));
|
|
53
|
-
}
|
|
54
|
-
txtType = "occlusion" /* pbrOcclusion */;
|
|
55
|
-
prop = pbr.get(txtType);
|
|
56
|
-
if (prop instanceof DexObj) {
|
|
57
|
-
const texture = loadTexture(log, txtType, prop);
|
|
58
|
-
let channel = texture && loadChannel(log, txtType, prop);
|
|
59
|
-
if (channel && channel !== "r" && channel !== "a") {
|
|
60
|
-
log.warn(`Unsupported ${txtType} texture channel: ${channel}`, "Fallback to r.");
|
|
61
|
-
channel = "r"; // R channel in ORM texture
|
|
62
|
-
}
|
|
63
|
-
this.occlusion = new PBROcclusion((_e = loadNumber(log, txtType, prop, "strength")) !== null && _e !== void 0 ? _e : 0, texture, channel);
|
|
64
|
-
}
|
|
65
|
-
txtType = "refraction" /* pbrRefraction */;
|
|
66
|
-
prop = pbr.get(txtType);
|
|
67
|
-
if (prop instanceof DexObj) {
|
|
68
|
-
this.refraction = new PBRRefraction((_f = loadNumber(log, txtType, prop, "ior")) !== null && _f !== void 0 ? _f : 1);
|
|
69
|
-
}
|
|
70
|
-
txtType = "roughness" /* pbrRoughness */;
|
|
71
|
-
prop = pbr.get(txtType);
|
|
72
|
-
if (prop instanceof DexObj) {
|
|
73
|
-
const texture = loadTexture(log, txtType, prop);
|
|
74
|
-
let channel = texture && loadChannel(log, txtType, prop);
|
|
75
|
-
if (channel && channel !== "g" && channel !== "a") {
|
|
76
|
-
log.warn(`Unsupported ${txtType} texture channel: ${channel}`, "Fallback to g.");
|
|
77
|
-
channel = "g"; // G channel in ORM texture
|
|
78
|
-
}
|
|
79
|
-
this.roughness = new PBRRoughness((_g = loadNumber(log, txtType, prop, "factor")) !== null && _g !== void 0 ? _g : 1, texture, channel);
|
|
80
|
-
}
|
|
81
|
-
// PBRMaterial in CmSym will combine the Occlusion, Roughness and Metallness textures into a
|
|
82
|
-
// combined "ORM" texture. This is important since Babylon (like glTF 2.0) does not support
|
|
83
|
-
// using two different textures for Roughness and Metallness.
|
|
84
|
-
//
|
|
85
|
-
// The PBRMaterial specification in CmSym does not in itself guarantee this, so keep the
|
|
86
|
-
// check below to notice if this requirement is no longer meet in the future.
|
|
87
|
-
const metallicUrl = (_j = (_h = this.metallic) === null || _h === void 0 ? void 0 : _h.texture) === null || _j === void 0 ? void 0 : _j.textureUrl;
|
|
88
|
-
const roughnessUrl = (_l = (_k = this.roughness) === null || _k === void 0 ? void 0 : _k.texture) === null || _l === void 0 ? void 0 : _l.textureUrl;
|
|
89
|
-
if (metallicUrl !== undefined &&
|
|
90
|
-
roughnessUrl !== undefined &&
|
|
91
|
-
metallicUrl.value !== roughnessUrl.value) {
|
|
92
|
-
log.error("PBRMaterial uses different textures for Metallic and Roughness.", "This is not supported and the material will probably not render as expected.");
|
|
93
|
-
}
|
|
94
|
-
// log.info("Created PBR material:", obj, this);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
export class PBRTexture extends GMaterial3DTexture {
|
|
98
|
-
constructor(type, imageUrl) {
|
|
99
|
-
super(type);
|
|
100
|
-
this.textureUrl = imageUrl;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
export class PBRBase {
|
|
104
|
-
constructor(factor, texture) {
|
|
105
|
-
this.factor = factor;
|
|
106
|
-
this.texture = texture;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
export class PBREmissive {
|
|
110
|
-
constructor(factor, texture) {
|
|
111
|
-
this.factor = factor;
|
|
112
|
-
this.texture = texture;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
export class PBRMetallic {
|
|
116
|
-
constructor(factor, texture, channel // glTF 2.0 / ORM: b
|
|
117
|
-
) {
|
|
118
|
-
this.factor = factor;
|
|
119
|
-
this.texture = texture;
|
|
120
|
-
this.channel = channel;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
export class PBRNormal {
|
|
124
|
-
constructor(scale, texture, channels) {
|
|
125
|
-
this.scale = scale;
|
|
126
|
-
this.texture = texture;
|
|
127
|
-
this.channels = channels;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
export class PBROcclusion {
|
|
131
|
-
constructor(strength, // default 0
|
|
132
|
-
texture, channel // glTF 2.0 / ORM: r
|
|
133
|
-
) {
|
|
134
|
-
this.strength = strength;
|
|
135
|
-
this.texture = texture;
|
|
136
|
-
this.channel = channel;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
export class PBROpacity {
|
|
140
|
-
constructor(factor, mode, maskThreshold, texture, channels, // Undocumented in CmSym-spec, r seem to mean rgb
|
|
141
|
-
useAlphaFromBase // New in CmSym 4.5.0, see WEB-8500
|
|
142
|
-
) {
|
|
143
|
-
this.factor = factor;
|
|
144
|
-
this.mode = mode;
|
|
145
|
-
this.maskThreshold = maskThreshold;
|
|
146
|
-
this.texture = texture;
|
|
147
|
-
this.channels = channels;
|
|
148
|
-
this.useAlphaFromBase = useAlphaFromBase;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
export class PBRRefraction {
|
|
152
|
-
constructor(ior) {
|
|
153
|
-
this.ior = ior;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
export class PBRRoughness {
|
|
157
|
-
constructor(factor, texture, channel // glTF 2.0 / ORM: g
|
|
158
|
-
) {
|
|
159
|
-
this.factor = factor;
|
|
160
|
-
this.texture = texture;
|
|
161
|
-
this.channel = channel;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Loads and returns the specified texture. Returns undefined if the texture was not found (they
|
|
166
|
-
* are optional) or there was an problem loading the texture.
|
|
167
|
-
*/
|
|
168
|
-
function loadTexture(log, type, dex) {
|
|
169
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
170
|
-
const scope = type + ".texture";
|
|
171
|
-
const dexTxt = dex.get("texture");
|
|
172
|
-
if (dexTxt === undefined) {
|
|
173
|
-
return undefined;
|
|
174
|
-
}
|
|
175
|
-
if (!(dexTxt instanceof DexObj)) {
|
|
176
|
-
log.warn(`Texture property not valid (${scope}):`, dexTxt);
|
|
177
|
-
return undefined;
|
|
178
|
-
}
|
|
179
|
-
const imageUrl = imageUrlFromDex(log, dexTxt);
|
|
180
|
-
if (imageUrl === undefined) {
|
|
181
|
-
return undefined;
|
|
182
|
-
}
|
|
183
|
-
const txt = new PBRTexture(type, imageUrl);
|
|
184
|
-
const transform = dexTxt.get("transform");
|
|
185
|
-
if (transform instanceof DexObj) {
|
|
186
|
-
const inner = scope + ".transform";
|
|
187
|
-
txt.uScale = (_a = loadNumber(log, inner, transform, "uScale")) !== null && _a !== void 0 ? _a : txt.uScale;
|
|
188
|
-
txt.vScale = (_b = loadNumber(log, inner, transform, "vScale")) !== null && _b !== void 0 ? _b : txt.vScale;
|
|
189
|
-
txt.uOffset = (_c = loadNumber(log, inner, transform, "uOffset")) !== null && _c !== void 0 ? _c : txt.uOffset;
|
|
190
|
-
txt.vOffset = (_d = loadNumber(log, inner, transform, "vOffset")) !== null && _d !== void 0 ? _d : txt.vOffset;
|
|
191
|
-
txt.rot = (_e = loadAngle(log, inner, transform, "rot")) !== null && _e !== void 0 ? _e : txt.rot;
|
|
192
|
-
}
|
|
193
|
-
const sampler = dexTxt.get("sampler");
|
|
194
|
-
if (sampler instanceof DexObj) {
|
|
195
|
-
const inner = scope + ".sampler";
|
|
196
|
-
txt.wrapU = (_f = textureWrapFromDex(sampler)) !== null && _f !== void 0 ? _f : txt.wrapU;
|
|
197
|
-
txt.wrapV = (_g = textureWrapFromDex(sampler)) !== null && _g !== void 0 ? _g : txt.wrapV;
|
|
198
|
-
txt.minFilter = (_h = loadTextureFilter(log, inner, sampler, "minFilter")) !== null && _h !== void 0 ? _h : txt.minFilter;
|
|
199
|
-
txt.magFilter = (_j = loadTextureFilter(log, inner, sampler, "magFilter")) !== null && _j !== void 0 ? _j : txt.magFilter;
|
|
200
|
-
}
|
|
201
|
-
else if (sampler !== undefined) {
|
|
202
|
-
// TODO: Verify with Jimmie that the Sampler is optional (spec not clear, examples
|
|
203
|
-
// indicate that it is). If so, confirm the default values used.
|
|
204
|
-
log.warn(`Texture property not valid (${scope}.sampler):`, dexTxt);
|
|
205
|
-
}
|
|
206
|
-
return txt;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Loads and returns the TextureFilter specified by the name parameter.
|
|
210
|
-
* Returns undefined if the object was not found or not of the correct type.
|
|
211
|
-
*/
|
|
212
|
-
function loadTextureFilter(log, scope, dex, name) {
|
|
213
|
-
const obj = dex.get(name);
|
|
214
|
-
switch (obj) {
|
|
215
|
-
case "linear":
|
|
216
|
-
return 0 /* linear */;
|
|
217
|
-
case "nearest":
|
|
218
|
-
return 1 /* nearest */;
|
|
219
|
-
}
|
|
220
|
-
log.warn(`TextureFilter property not valid (${scope}.${name}): ${obj}`);
|
|
221
|
-
return undefined;
|
|
222
|
-
}
|
|
223
|
-
function loadChannel(log, scope, dex, name = "channel") {
|
|
224
|
-
const obj = dex.get(name);
|
|
225
|
-
switch (obj) {
|
|
226
|
-
case "r":
|
|
227
|
-
case "g":
|
|
228
|
-
case "b":
|
|
229
|
-
case "a":
|
|
230
|
-
return obj;
|
|
231
|
-
}
|
|
232
|
-
log.warn(`Channel property not valid (${scope}.${name}): ${obj}`);
|
|
233
|
-
return undefined;
|
|
234
|
-
}
|
|
235
|
-
function loadChannels(log, scope, dex, name = "channels") {
|
|
236
|
-
const obj = dex.get(name);
|
|
237
|
-
switch (obj) {
|
|
238
|
-
case "r":
|
|
239
|
-
case "g":
|
|
240
|
-
case "b":
|
|
241
|
-
case "a":
|
|
242
|
-
case "rgb":
|
|
243
|
-
case "rgba":
|
|
244
|
-
return obj;
|
|
245
|
-
}
|
|
246
|
-
log.warn(`Channels property not valid (${scope}.${name}): ${obj}`);
|
|
247
|
-
return undefined;
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Loads and returns the number specified by the name parameter.
|
|
251
|
-
* Returns undefined if the object was not found or not of the correct type.
|
|
252
|
-
*/
|
|
253
|
-
function loadNumber(log, scope, dex, name) {
|
|
254
|
-
const obj = dex.get(name);
|
|
255
|
-
if (obj !== undefined && typeof obj !== "number") {
|
|
256
|
-
log.warn(`Number property not valid (${scope}.${name}): ${obj}`);
|
|
257
|
-
return undefined;
|
|
258
|
-
}
|
|
259
|
-
return obj;
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Loads and returns the boolean specified by the name parameter.
|
|
263
|
-
* Returns undefined if the object was not found or not of the correct type.
|
|
264
|
-
*/
|
|
265
|
-
function loadBool(log, scope, dex, name) {
|
|
266
|
-
const obj = dex.get(name);
|
|
267
|
-
if (obj !== undefined && typeof obj !== "boolean") {
|
|
268
|
-
log.warn(`Bool property not valid (${scope}.${name}): ${obj}`);
|
|
269
|
-
return undefined;
|
|
270
|
-
}
|
|
271
|
-
return obj;
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Loads and returns the angle (in radians) specified by the name parameter.
|
|
275
|
-
* Returns undefined if the object was not found or not of the correct type.
|
|
276
|
-
*/
|
|
277
|
-
function loadAngle(log, scope, dex, name) {
|
|
278
|
-
const obj = dex.get(name);
|
|
279
|
-
if (obj !== undefined && !(obj instanceof AngleF)) {
|
|
280
|
-
log.warn(`Angle property not valid (${scope}.${name}): ${obj}`);
|
|
281
|
-
return undefined;
|
|
282
|
-
}
|
|
283
|
-
return obj === null || obj === void 0 ? void 0 : obj.radians;
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Loads and returns the ColorF specified by the name parameter.
|
|
287
|
-
* Returns <1,1,1,1> if the object was not found or not of the correct type.
|
|
288
|
-
*/
|
|
289
|
-
function loadColorF(log, scope, dex, name) {
|
|
290
|
-
const obj = dex.get(name);
|
|
291
|
-
if (!(obj instanceof ColorF)) {
|
|
292
|
-
if (obj !== undefined) {
|
|
293
|
-
log.warn(`ColorF property not valid (${scope}.${name}): ${obj}`);
|
|
294
|
-
}
|
|
295
|
-
return ColorF.WHITE;
|
|
296
|
-
}
|
|
297
|
-
return obj;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Loads and returns the PBROpacityMode mode.
|
|
301
|
-
* Returns "opaque" if the object was not found or not of the correct type.
|
|
302
|
-
*/
|
|
303
|
-
function loadOpacityMode(log, scope, dex) {
|
|
304
|
-
const obj = dex.get("mode");
|
|
305
|
-
switch (obj) {
|
|
306
|
-
case "opaque":
|
|
307
|
-
case "mask":
|
|
308
|
-
case "translucent":
|
|
309
|
-
case "translucentAndMask":
|
|
310
|
-
return obj;
|
|
311
|
-
}
|
|
312
|
-
log.warn(`Opacity property not valid (${scope}.mode): ${obj}`);
|
|
313
|
-
return "opaque";
|
|
314
|
-
}
|
|
1
|
+
import { ColorF } from "../basic/ColorF.js";
|
|
2
|
+
import { DexObj } from "../format/dex/DexObj.js";
|
|
3
|
+
import { AngleF } from "../geometry/AngleF.js";
|
|
4
|
+
import { GMaterial3D, GMaterial3DTexture, imageUrlFromDex, textureWrapFromDex, } from "./GMaterial3D.js";
|
|
5
|
+
// tslint:disable:max-classes-per-file
|
|
6
|
+
export class GMaterialPBR extends GMaterial3D {
|
|
7
|
+
constructor(log, obj) {
|
|
8
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
9
|
+
super(log, obj);
|
|
10
|
+
if (obj === undefined) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const pbr = obj.get("pbr");
|
|
14
|
+
if (!(pbr instanceof DexObj)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
let txtType = "base" /* pbrBase */;
|
|
18
|
+
let prop = pbr.get(txtType);
|
|
19
|
+
if (prop instanceof DexObj) {
|
|
20
|
+
this.base = new PBRBase(loadColorF(log, txtType, prop, "factor"), loadTexture(log, txtType, prop));
|
|
21
|
+
}
|
|
22
|
+
txtType = "emissive" /* pbrEmissive */;
|
|
23
|
+
prop = pbr.get(txtType);
|
|
24
|
+
if (prop instanceof DexObj) {
|
|
25
|
+
this.emissive = new PBREmissive(loadColorF(log, txtType, prop, "factor"), loadTexture(log, txtType, prop));
|
|
26
|
+
}
|
|
27
|
+
txtType = "metallic" /* pbrMetallic */;
|
|
28
|
+
prop = pbr.get(txtType);
|
|
29
|
+
if (prop instanceof DexObj) {
|
|
30
|
+
const texture = loadTexture(log, txtType, prop);
|
|
31
|
+
let channel = texture && loadChannel(log, txtType, prop);
|
|
32
|
+
if (channel && channel !== "r" && channel !== "b") {
|
|
33
|
+
log.warn(`Unsupported ${txtType} texture channel: ${channel}`, "Fallback to b.");
|
|
34
|
+
channel = "b"; // B channel in ORM texture
|
|
35
|
+
}
|
|
36
|
+
this.metallic = new PBRMetallic((_a = loadNumber(log, txtType, prop, "factor")) !== null && _a !== void 0 ? _a : 1, texture, channel);
|
|
37
|
+
}
|
|
38
|
+
txtType = "normal" /* pbrNormal */;
|
|
39
|
+
prop = pbr.get(txtType);
|
|
40
|
+
if (prop instanceof DexObj) {
|
|
41
|
+
this.normal = new PBRNormal((_b = loadNumber(log, txtType, prop, "scale")) !== null && _b !== void 0 ? _b : 1, loadTexture(log, txtType, prop), loadChannels(log, txtType, prop));
|
|
42
|
+
}
|
|
43
|
+
txtType = "opacity" /* pbrOpacity */;
|
|
44
|
+
prop = pbr.get(txtType);
|
|
45
|
+
if (prop instanceof DexObj) {
|
|
46
|
+
const texture = loadTexture(log, txtType, prop);
|
|
47
|
+
let channel = texture && loadChannel(log, txtType, prop);
|
|
48
|
+
if (channel && channel !== "r" && channel !== "a") {
|
|
49
|
+
log.warn(`Unsupported ${txtType} texture channel: ${channel}`, "Fallback to a.");
|
|
50
|
+
channel = "a"; // Alpha channel, safest fallback
|
|
51
|
+
}
|
|
52
|
+
this.opacity = new PBROpacity((_c = loadNumber(log, txtType, prop, "factor")) !== null && _c !== void 0 ? _c : 1, loadOpacityMode(log, txtType, prop), (_d = loadNumber(log, txtType, prop, "maskThreshold")) !== null && _d !== void 0 ? _d : 0.5, texture, channel, loadBool(log, txtType, prop, "useAlphaFromBase"));
|
|
53
|
+
}
|
|
54
|
+
txtType = "occlusion" /* pbrOcclusion */;
|
|
55
|
+
prop = pbr.get(txtType);
|
|
56
|
+
if (prop instanceof DexObj) {
|
|
57
|
+
const texture = loadTexture(log, txtType, prop);
|
|
58
|
+
let channel = texture && loadChannel(log, txtType, prop);
|
|
59
|
+
if (channel && channel !== "r" && channel !== "a") {
|
|
60
|
+
log.warn(`Unsupported ${txtType} texture channel: ${channel}`, "Fallback to r.");
|
|
61
|
+
channel = "r"; // R channel in ORM texture
|
|
62
|
+
}
|
|
63
|
+
this.occlusion = new PBROcclusion((_e = loadNumber(log, txtType, prop, "strength")) !== null && _e !== void 0 ? _e : 0, texture, channel);
|
|
64
|
+
}
|
|
65
|
+
txtType = "refraction" /* pbrRefraction */;
|
|
66
|
+
prop = pbr.get(txtType);
|
|
67
|
+
if (prop instanceof DexObj) {
|
|
68
|
+
this.refraction = new PBRRefraction((_f = loadNumber(log, txtType, prop, "ior")) !== null && _f !== void 0 ? _f : 1);
|
|
69
|
+
}
|
|
70
|
+
txtType = "roughness" /* pbrRoughness */;
|
|
71
|
+
prop = pbr.get(txtType);
|
|
72
|
+
if (prop instanceof DexObj) {
|
|
73
|
+
const texture = loadTexture(log, txtType, prop);
|
|
74
|
+
let channel = texture && loadChannel(log, txtType, prop);
|
|
75
|
+
if (channel && channel !== "g" && channel !== "a") {
|
|
76
|
+
log.warn(`Unsupported ${txtType} texture channel: ${channel}`, "Fallback to g.");
|
|
77
|
+
channel = "g"; // G channel in ORM texture
|
|
78
|
+
}
|
|
79
|
+
this.roughness = new PBRRoughness((_g = loadNumber(log, txtType, prop, "factor")) !== null && _g !== void 0 ? _g : 1, texture, channel);
|
|
80
|
+
}
|
|
81
|
+
// PBRMaterial in CmSym will combine the Occlusion, Roughness and Metallness textures into a
|
|
82
|
+
// combined "ORM" texture. This is important since Babylon (like glTF 2.0) does not support
|
|
83
|
+
// using two different textures for Roughness and Metallness.
|
|
84
|
+
//
|
|
85
|
+
// The PBRMaterial specification in CmSym does not in itself guarantee this, so keep the
|
|
86
|
+
// check below to notice if this requirement is no longer meet in the future.
|
|
87
|
+
const metallicUrl = (_j = (_h = this.metallic) === null || _h === void 0 ? void 0 : _h.texture) === null || _j === void 0 ? void 0 : _j.textureUrl;
|
|
88
|
+
const roughnessUrl = (_l = (_k = this.roughness) === null || _k === void 0 ? void 0 : _k.texture) === null || _l === void 0 ? void 0 : _l.textureUrl;
|
|
89
|
+
if (metallicUrl !== undefined &&
|
|
90
|
+
roughnessUrl !== undefined &&
|
|
91
|
+
metallicUrl.value !== roughnessUrl.value) {
|
|
92
|
+
log.error("PBRMaterial uses different textures for Metallic and Roughness.", "This is not supported and the material will probably not render as expected.");
|
|
93
|
+
}
|
|
94
|
+
// log.info("Created PBR material:", obj, this);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export class PBRTexture extends GMaterial3DTexture {
|
|
98
|
+
constructor(type, imageUrl) {
|
|
99
|
+
super(type);
|
|
100
|
+
this.textureUrl = imageUrl;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export class PBRBase {
|
|
104
|
+
constructor(factor, texture) {
|
|
105
|
+
this.factor = factor;
|
|
106
|
+
this.texture = texture;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export class PBREmissive {
|
|
110
|
+
constructor(factor, texture) {
|
|
111
|
+
this.factor = factor;
|
|
112
|
+
this.texture = texture;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
export class PBRMetallic {
|
|
116
|
+
constructor(factor, texture, channel // glTF 2.0 / ORM: b
|
|
117
|
+
) {
|
|
118
|
+
this.factor = factor;
|
|
119
|
+
this.texture = texture;
|
|
120
|
+
this.channel = channel;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export class PBRNormal {
|
|
124
|
+
constructor(scale, texture, channels) {
|
|
125
|
+
this.scale = scale;
|
|
126
|
+
this.texture = texture;
|
|
127
|
+
this.channels = channels;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
export class PBROcclusion {
|
|
131
|
+
constructor(strength, // default 0
|
|
132
|
+
texture, channel // glTF 2.0 / ORM: r
|
|
133
|
+
) {
|
|
134
|
+
this.strength = strength;
|
|
135
|
+
this.texture = texture;
|
|
136
|
+
this.channel = channel;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
export class PBROpacity {
|
|
140
|
+
constructor(factor, mode, maskThreshold, texture, channels, // Undocumented in CmSym-spec, r seem to mean rgb
|
|
141
|
+
useAlphaFromBase // New in CmSym 4.5.0, see WEB-8500
|
|
142
|
+
) {
|
|
143
|
+
this.factor = factor;
|
|
144
|
+
this.mode = mode;
|
|
145
|
+
this.maskThreshold = maskThreshold;
|
|
146
|
+
this.texture = texture;
|
|
147
|
+
this.channels = channels;
|
|
148
|
+
this.useAlphaFromBase = useAlphaFromBase;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
export class PBRRefraction {
|
|
152
|
+
constructor(ior) {
|
|
153
|
+
this.ior = ior;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
export class PBRRoughness {
|
|
157
|
+
constructor(factor, texture, channel // glTF 2.0 / ORM: g
|
|
158
|
+
) {
|
|
159
|
+
this.factor = factor;
|
|
160
|
+
this.texture = texture;
|
|
161
|
+
this.channel = channel;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Loads and returns the specified texture. Returns undefined if the texture was not found (they
|
|
166
|
+
* are optional) or there was an problem loading the texture.
|
|
167
|
+
*/
|
|
168
|
+
function loadTexture(log, type, dex) {
|
|
169
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
170
|
+
const scope = type + ".texture";
|
|
171
|
+
const dexTxt = dex.get("texture");
|
|
172
|
+
if (dexTxt === undefined) {
|
|
173
|
+
return undefined;
|
|
174
|
+
}
|
|
175
|
+
if (!(dexTxt instanceof DexObj)) {
|
|
176
|
+
log.warn(`Texture property not valid (${scope}):`, dexTxt);
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
const imageUrl = imageUrlFromDex(log, dexTxt);
|
|
180
|
+
if (imageUrl === undefined) {
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
const txt = new PBRTexture(type, imageUrl);
|
|
184
|
+
const transform = dexTxt.get("transform");
|
|
185
|
+
if (transform instanceof DexObj) {
|
|
186
|
+
const inner = scope + ".transform";
|
|
187
|
+
txt.uScale = (_a = loadNumber(log, inner, transform, "uScale")) !== null && _a !== void 0 ? _a : txt.uScale;
|
|
188
|
+
txt.vScale = (_b = loadNumber(log, inner, transform, "vScale")) !== null && _b !== void 0 ? _b : txt.vScale;
|
|
189
|
+
txt.uOffset = (_c = loadNumber(log, inner, transform, "uOffset")) !== null && _c !== void 0 ? _c : txt.uOffset;
|
|
190
|
+
txt.vOffset = (_d = loadNumber(log, inner, transform, "vOffset")) !== null && _d !== void 0 ? _d : txt.vOffset;
|
|
191
|
+
txt.rot = (_e = loadAngle(log, inner, transform, "rot")) !== null && _e !== void 0 ? _e : txt.rot;
|
|
192
|
+
}
|
|
193
|
+
const sampler = dexTxt.get("sampler");
|
|
194
|
+
if (sampler instanceof DexObj) {
|
|
195
|
+
const inner = scope + ".sampler";
|
|
196
|
+
txt.wrapU = (_f = textureWrapFromDex(sampler)) !== null && _f !== void 0 ? _f : txt.wrapU;
|
|
197
|
+
txt.wrapV = (_g = textureWrapFromDex(sampler)) !== null && _g !== void 0 ? _g : txt.wrapV;
|
|
198
|
+
txt.minFilter = (_h = loadTextureFilter(log, inner, sampler, "minFilter")) !== null && _h !== void 0 ? _h : txt.minFilter;
|
|
199
|
+
txt.magFilter = (_j = loadTextureFilter(log, inner, sampler, "magFilter")) !== null && _j !== void 0 ? _j : txt.magFilter;
|
|
200
|
+
}
|
|
201
|
+
else if (sampler !== undefined) {
|
|
202
|
+
// TODO: Verify with Jimmie that the Sampler is optional (spec not clear, examples
|
|
203
|
+
// indicate that it is). If so, confirm the default values used.
|
|
204
|
+
log.warn(`Texture property not valid (${scope}.sampler):`, dexTxt);
|
|
205
|
+
}
|
|
206
|
+
return txt;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Loads and returns the TextureFilter specified by the name parameter.
|
|
210
|
+
* Returns undefined if the object was not found or not of the correct type.
|
|
211
|
+
*/
|
|
212
|
+
function loadTextureFilter(log, scope, dex, name) {
|
|
213
|
+
const obj = dex.get(name);
|
|
214
|
+
switch (obj) {
|
|
215
|
+
case "linear":
|
|
216
|
+
return 0 /* linear */;
|
|
217
|
+
case "nearest":
|
|
218
|
+
return 1 /* nearest */;
|
|
219
|
+
}
|
|
220
|
+
log.warn(`TextureFilter property not valid (${scope}.${name}): ${obj}`);
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
function loadChannel(log, scope, dex, name = "channel") {
|
|
224
|
+
const obj = dex.get(name);
|
|
225
|
+
switch (obj) {
|
|
226
|
+
case "r":
|
|
227
|
+
case "g":
|
|
228
|
+
case "b":
|
|
229
|
+
case "a":
|
|
230
|
+
return obj;
|
|
231
|
+
}
|
|
232
|
+
log.warn(`Channel property not valid (${scope}.${name}): ${obj}`);
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
function loadChannels(log, scope, dex, name = "channels") {
|
|
236
|
+
const obj = dex.get(name);
|
|
237
|
+
switch (obj) {
|
|
238
|
+
case "r":
|
|
239
|
+
case "g":
|
|
240
|
+
case "b":
|
|
241
|
+
case "a":
|
|
242
|
+
case "rgb":
|
|
243
|
+
case "rgba":
|
|
244
|
+
return obj;
|
|
245
|
+
}
|
|
246
|
+
log.warn(`Channels property not valid (${scope}.${name}): ${obj}`);
|
|
247
|
+
return undefined;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Loads and returns the number specified by the name parameter.
|
|
251
|
+
* Returns undefined if the object was not found or not of the correct type.
|
|
252
|
+
*/
|
|
253
|
+
function loadNumber(log, scope, dex, name) {
|
|
254
|
+
const obj = dex.get(name);
|
|
255
|
+
if (obj !== undefined && typeof obj !== "number") {
|
|
256
|
+
log.warn(`Number property not valid (${scope}.${name}): ${obj}`);
|
|
257
|
+
return undefined;
|
|
258
|
+
}
|
|
259
|
+
return obj;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Loads and returns the boolean specified by the name parameter.
|
|
263
|
+
* Returns undefined if the object was not found or not of the correct type.
|
|
264
|
+
*/
|
|
265
|
+
function loadBool(log, scope, dex, name) {
|
|
266
|
+
const obj = dex.get(name);
|
|
267
|
+
if (obj !== undefined && typeof obj !== "boolean") {
|
|
268
|
+
log.warn(`Bool property not valid (${scope}.${name}): ${obj}`);
|
|
269
|
+
return undefined;
|
|
270
|
+
}
|
|
271
|
+
return obj;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Loads and returns the angle (in radians) specified by the name parameter.
|
|
275
|
+
* Returns undefined if the object was not found or not of the correct type.
|
|
276
|
+
*/
|
|
277
|
+
function loadAngle(log, scope, dex, name) {
|
|
278
|
+
const obj = dex.get(name);
|
|
279
|
+
if (obj !== undefined && !(obj instanceof AngleF)) {
|
|
280
|
+
log.warn(`Angle property not valid (${scope}.${name}): ${obj}`);
|
|
281
|
+
return undefined;
|
|
282
|
+
}
|
|
283
|
+
return obj === null || obj === void 0 ? void 0 : obj.radians;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Loads and returns the ColorF specified by the name parameter.
|
|
287
|
+
* Returns <1,1,1,1> if the object was not found or not of the correct type.
|
|
288
|
+
*/
|
|
289
|
+
function loadColorF(log, scope, dex, name) {
|
|
290
|
+
const obj = dex.get(name);
|
|
291
|
+
if (!(obj instanceof ColorF)) {
|
|
292
|
+
if (obj !== undefined) {
|
|
293
|
+
log.warn(`ColorF property not valid (${scope}.${name}): ${obj}`);
|
|
294
|
+
}
|
|
295
|
+
return ColorF.WHITE;
|
|
296
|
+
}
|
|
297
|
+
return obj;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Loads and returns the PBROpacityMode mode.
|
|
301
|
+
* Returns "opaque" if the object was not found or not of the correct type.
|
|
302
|
+
*/
|
|
303
|
+
function loadOpacityMode(log, scope, dex) {
|
|
304
|
+
const obj = dex.get("mode");
|
|
305
|
+
switch (obj) {
|
|
306
|
+
case "opaque":
|
|
307
|
+
case "mask":
|
|
308
|
+
case "translucent":
|
|
309
|
+
case "translucentAndMask":
|
|
310
|
+
return obj;
|
|
311
|
+
}
|
|
312
|
+
log.warn(`Opacity property not valid (${scope}.mode): ${obj}`);
|
|
313
|
+
return "opaque";
|
|
314
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { GMaterial3D } from "./GMaterial3D.js";
|
|
2
|
-
export declare class MultiGMaterial3D {
|
|
3
|
-
materialMap: Map<string, GMaterial3D>;
|
|
4
|
-
gmFile?: string;
|
|
5
|
-
constructor(materialMap?: Map<string, GMaterial3D>, realtimeMaterial3D?: GMaterial3D, renderMaterial3D?: GMaterial3D);
|
|
6
|
-
realtimeMaterial(): GMaterial3D | undefined;
|
|
7
|
-
renderMaterial(): GMaterial3D | undefined;
|
|
8
|
-
}
|
|
1
|
+
import { GMaterial3D } from "./GMaterial3D.js";
|
|
2
|
+
export declare class MultiGMaterial3D {
|
|
3
|
+
materialMap: Map<string, GMaterial3D>;
|
|
4
|
+
gmFile?: string;
|
|
5
|
+
constructor(materialMap?: Map<string, GMaterial3D>, realtimeMaterial3D?: GMaterial3D, renderMaterial3D?: GMaterial3D);
|
|
6
|
+
realtimeMaterial(): GMaterial3D | undefined;
|
|
7
|
+
renderMaterial(): GMaterial3D | undefined;
|
|
8
|
+
}
|
|
9
9
|
//# sourceMappingURL=MultiGMaterial3D.d.ts.map
|