198 lines
4.4 KiB
JavaScript
198 lines
4.4 KiB
JavaScript
/**
|
|
* R3.D3.Material.Standard
|
|
* @param apiComponent
|
|
* @constructor
|
|
*/
|
|
R3.D3.Material.Standard = function(
|
|
apiComponent
|
|
) {
|
|
|
|
__RUNTIME_COMPONENT__;
|
|
|
|
R3.D3.Material.Shader.call(
|
|
this,
|
|
apiComponent,
|
|
true
|
|
);
|
|
|
|
|
|
};
|
|
|
|
R3.D3.Material.Standard.prototype = Object.create(R3.D3.Material.prototype);
|
|
R3.D3.Material.Standard.prototype.constructor = R3.D3.Material.Standard;
|
|
|
|
/**
|
|
* Creates an instance of our texture object
|
|
* @returns {*}
|
|
*/
|
|
R3.D3.Material.Standard.prototype.createInstance = function() {
|
|
|
|
this.instance = this.graphics.MaterialStandard(this);
|
|
|
|
__CREATE_INSTANCE__;
|
|
|
|
};
|
|
|
|
/**
|
|
* Updates the instance with the current state
|
|
*/
|
|
R3.D3.Material.Standard.prototype.updateInstance = function(property) {
|
|
|
|
if (property === 'alphaMap') {
|
|
this.assignTexture('alphaMap', property);
|
|
return;
|
|
}
|
|
|
|
if (property === 'aoMap') {
|
|
this.assignTexture('aoMap', property);
|
|
return;
|
|
}
|
|
|
|
if (property === 'aoMapIntensity') {
|
|
this.instance.aoMapIntensity = this.aoMapIntensity;
|
|
return;
|
|
}
|
|
|
|
if (property === 'bumpMap') {
|
|
this.assignTexture('bumpMap', property);
|
|
return;
|
|
}
|
|
|
|
if (property === 'bumpScale') {
|
|
this.instance.bumpScale = this.bumpScale;
|
|
return;
|
|
}
|
|
|
|
if (property === 'color') {
|
|
this.instance.color = this.color.instance;
|
|
return;
|
|
}
|
|
|
|
if (property === 'displacementMap') {
|
|
this.assignTexture('displacementMap', property);
|
|
return;
|
|
}
|
|
|
|
if (property === 'displacementScale') {
|
|
this.instance.displacementScale = this.displacementScale;
|
|
return;
|
|
}
|
|
|
|
if (property === 'displacementBias') {
|
|
this.instance.displacementBias = this.displacementBias;
|
|
return;
|
|
}
|
|
|
|
if (property === 'emissive') {
|
|
this.instance.emissive = this.emissive.instance;
|
|
return;
|
|
}
|
|
|
|
if (property === 'emissiveMap') {
|
|
this.assignTexture('emissiveMap', property);
|
|
return;
|
|
}
|
|
|
|
if (property === 'emissiveIntensity') {
|
|
this.instance.emissiveIntensity = this.emissiveIntensity;
|
|
return;
|
|
}
|
|
|
|
if (property === 'envMap') {
|
|
this.assignTexture('envMap', property);
|
|
return;
|
|
}
|
|
|
|
if (property === 'envMapIntensity') {
|
|
this.instance.envMapIntensity = this.envMapIntensity;
|
|
return;
|
|
}
|
|
|
|
if (property === 'lightMap') {
|
|
this.assignTexture('lightMap', property);
|
|
return;
|
|
}
|
|
|
|
if (property === 'lightMapIntensity') {
|
|
this.instance.lightMapIntensity = this.lightMapIntensity;
|
|
return;
|
|
}
|
|
|
|
if (property === 'diffuseMap') {
|
|
this.assignTexture('map', property);
|
|
return;
|
|
}
|
|
|
|
if (property === 'metalness') {
|
|
this.instance.metalness = this.metalness;
|
|
return;
|
|
}
|
|
|
|
if (property === 'metalnessMap') {
|
|
this.assignTexture('metalnessMap', property);
|
|
return;
|
|
}
|
|
|
|
if (property === 'morphNormals') {
|
|
this.instance.morphNormals = this.morphNormals;
|
|
return;
|
|
}
|
|
|
|
if (property === 'morphTargets') {
|
|
this.instance.morphTargets = this.morphTargets;
|
|
return;
|
|
}
|
|
|
|
if (property === 'normalMap') {
|
|
this.assignTexture('normalMap', property);
|
|
return;
|
|
}
|
|
|
|
if (property === 'normalScale') {
|
|
this.instance.normalScale = this.normalScale;
|
|
return;
|
|
}
|
|
|
|
if (property === 'refractionRatio') {
|
|
this.instance.refractionRatio = this.refractionRatio;
|
|
return;
|
|
}
|
|
|
|
if (property === 'roughness') {
|
|
this.instance.roughness = this.roughness;
|
|
return;
|
|
}
|
|
|
|
if (property === 'roughnessMap') {
|
|
this.assignTexture('roughnessMap', property);
|
|
return;
|
|
}
|
|
|
|
if (property === 'skinning') {
|
|
this.instance.skinning = this.skinning;
|
|
return;
|
|
}
|
|
|
|
if (property === 'wireframe') {
|
|
this.instance.wireframe = this.wireframe;
|
|
return;
|
|
}
|
|
|
|
if (property === 'wireframeLinecap') {
|
|
this.instance.wireframeLinecap = this.wireframeLinecap;
|
|
return;
|
|
}
|
|
|
|
if (property === 'wireframeLinejoin') {
|
|
this.instance.wireframeLinejoin = this.wireframeLinejoin;
|
|
return;
|
|
}
|
|
|
|
if (property === 'wireframeLinewidth') {
|
|
this.instance.wireframeLinewidth = this.wireframeLinewidth;
|
|
return;
|
|
}
|
|
|
|
R3.D3.Material.prototype.updateInstance.call(this, property);
|
|
};
|