r3-legacy/src/r3-d3-api-material-standard.js

222 lines
6.4 KiB
JavaScript
Raw Normal View History

2018-04-09 09:35:04 +02:00
/**
* R3.D3.API.Material.Standard
2019-10-06 21:11:18 +02:00
* @param apiComponent
*
* @property alphaMap
* @property aoMap
* @property aoMapIntensity
* @property bumpMap
* @property bumpScale
* @property color
* @property displacementMap
* @property displacementScale
* @property displacementBias
* @property emissive
* @property emissiveMap
* @property emissiveIntensity
* @property envMap
* @property envMapIntensity
* @property lightMap
* @property lightMapIntensity
* @property diffuseMap
* @property metalness
* @property metalnessMap
* @property morphNormals
* @property morphTargets
* @property normalMap
* @property normalScale
* @property refractionRatio
* @property roughness
* @property roughnessMap
* @property skinning
* @property wireframe
* @property wireframeLinecap
* @property wireframeLinejoin
* @property wireframeLinewidth
*
2018-04-09 09:35:04 +02:00
* @constructor
*/
R3.D3.API.Material.Standard = function(
2019-10-06 21:11:18 +02:00
apiComponent
2018-04-09 09:35:04 +02:00
) {
2019-10-06 21:11:18 +02:00
__API_MATERIAL__;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.alphaMap)) {
apiComponent.alphaMap = null;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.alphaMap = apiComponent.alphaMap;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.aoMap)) {
apiComponent.aoMap = null;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.aoMap = apiComponent.aoMap;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.aoMapIntensity)) {
apiComponent.aoMapIntensity = 1;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.aoMapIntensity = apiComponent.aoMapIntensity;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.bumpMap)) {
apiComponent.bumpMap = null;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.bumpMap = apiComponent.bumpMap;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.bumpScale)) {
apiComponent.bumpScale = 1;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.bumpScale = apiComponent.bumpScale;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.color)) {
apiComponent.color = new R3.API.Color(
{
parent : this,
register : true,
r : 1,
g : 1,
b : 1,
a : 1
}
);
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.color = apiComponent.color;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.displacementMap)) {
apiComponent.displacementMap = null;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.displacementMap = apiComponent.displacementMap;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.displacementBias)) {
apiComponent.displacementBias = 0;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.displacementBias = apiComponent.displacementBias;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.displacementScale)) {
apiComponent.displacementScale = 1;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.displacementScale = apiComponent.displacementScale;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.emissive)) {
apiComponent.emissive = new R3.API.Color(
{
parent : this,
register : true,
r : 0,
g : 0,
b : 0,
a : 0
}
);
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.emissive = apiComponent.emissive;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.emissiveMap)) {
apiComponent.emissiveMap = null;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.emissiveMap = apiComponent.emissiveMap;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.emissiveIntensity)) {
apiComponent.emissiveIntensity = 1;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.emissiveIntensity = apiComponent.emissiveIntensity;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.envMap)) {
apiComponent.envMap = null;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.envMap = apiComponent.envMap;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.envMapIntensity)) {
apiComponent.envMapIntensity = 1;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.envMapIntensity = apiComponent.envMapIntensity;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.lightMap)) {
apiComponent.lightMap = null;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.lightMap = apiComponent.lightMap;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.lightMapIntensity)) {
apiComponent.lightMapIntensity = 1;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.lightMapIntensity = apiComponent.lightMapIntensity;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.diffuseMap)) {
apiComponent.diffuseMap = null;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.diffuseMap = apiComponent.diffuseMap;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.metalness)) {
apiComponent.metalness = 0.5;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.metalness = apiComponent.metalness;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.metalnessMap)) {
apiComponent.metalnessMap = null;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.metalnessMap = apiComponent.metalnessMap;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.morphNormals)) {
apiComponent.morphNormals = false;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.morphNormals = apiComponent.morphNormals;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.morphTargets)) {
apiComponent.morphTargets = false;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.morphTargets = apiComponent.morphTargets;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.normalMap)) {
apiComponent.normalMap = null;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.normalMap = apiComponent.normalMap;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.normalScale)) {
apiComponent.normalScale = 1;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.normalScale = apiComponent.normalScale;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.refractionRatio)) {
apiComponent.refractionRatio = 0.98;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.refractionRatio = apiComponent.refractionRatio;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.roughness)) {
apiComponent.roughness = 0.5;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.roughness = apiComponent.roughness;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.roughnessMap)) {
apiComponent.roughnessMap = null;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.roughnessMap = apiComponent.roughnessMap;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.skinning)) {
apiComponent.skinning = false;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.skinning = apiComponent.skinning;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.wireframe)) {
apiComponent.wireframe = false;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.wireframe = apiComponent.wireframe;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.wireframeLinecap)) {
apiComponent.wireframeLinecap = 'round';
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.wireframeLinecap = apiComponent.wireframeLinecap;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.wireframeLinejoin)) {
apiComponent.wireframeLinejoin = 'round';
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.wireframeLinejoin = apiComponent.wireframeLinejoin;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.wireframeLinewidth)) {
apiComponent.wireframeLinewidth = 1;
2018-04-09 09:35:04 +02:00
}
2019-10-06 21:11:18 +02:00
this.wireframeLinewidth = apiComponent.wireframeLinewidth;
2018-04-09 09:35:04 +02:00
};
R3.D3.API.Material.Standard.prototype = Object.create(R3.D3.API.Material.prototype);
R3.D3.API.Material.Standard.prototype.constructor = R3.D3.API.Material.Standard;