mylingo3d
Version:
Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor
212 lines • 6.08 kB
JavaScript
import { Color, ObjectSpaceNormalMap, TangentSpaceNormalMap, Vector2 } from "three";
import loadTexture from "../../utils/loaders/loadTexture";
import TexturedBasicMixin from "./TexturedBasicMixin";
const mapNames = [
"map",
"alphaMap",
"envMap",
"aoMap",
"bumpMap",
"displacementMap",
"emissiveMap",
"lightMap",
"metalnessMap",
"roughnessMap",
"normalMap"
];
export default class TexturedStandardMixin extends TexturedBasicMixin {
get wireframe() {
return this.material.wireframe;
}
set wireframe(val) {
this.tryCloneMaterial();
this.material.wireframe = val;
}
_envMap;
get envMap() {
return this._envMap;
}
set envMap(val) {
this.tryCloneMaterial();
this._envMap = val;
this.material.envMap = val ? loadTexture(val) : null;
this.applyTexture(mapNames);
}
_aoMap;
get aoMap() {
return this._aoMap;
}
set aoMap(val) {
this.tryCloneMaterial();
this._aoMap = val;
this.material.aoMap = val ? loadTexture(val) : null;
this.applyTexture(mapNames);
}
get aoMapIntensity() {
return this.material.aoMapIntensity;
}
set aoMapIntensity(val) {
this.tryCloneMaterial();
this.material.aoMapIntensity = val;
}
_bumpMap;
get bumpMap() {
return this._bumpMap;
}
set bumpMap(val) {
this.tryCloneMaterial();
this._bumpMap = val;
this.material.bumpMap = val ? loadTexture(val) : null;
this.applyTexture(mapNames);
}
get bumpScale() {
return this.material.bumpScale;
}
set bumpScale(val) {
this.tryCloneMaterial();
this.material.bumpScale = val;
}
_displacementMap;
get displacementMap() {
return this._displacementMap;
}
set displacementMap(val) {
this.tryCloneMaterial();
this._displacementMap = val;
this.material.displacementMap = val ? loadTexture(val) : null;
this.applyTexture(mapNames);
}
get displacementScale() {
return this.material.displacementScale;
}
set displacementScale(val) {
this.tryCloneMaterial();
this.material.displacementScale = val;
}
get displacementBias() {
return this.material.displacementBias;
}
set displacementBias(val) {
this.tryCloneMaterial();
this.material.displacementBias = val;
}
get emissiveColor() {
return "#" + this.material.emissive.getHexString();
}
set emissiveColor(val) {
this.tryCloneMaterial();
this.material.emissive = new Color(val);
}
_emissiveMap;
get emissiveMap() {
return this._emissiveMap;
}
set emissiveMap(val) {
this.tryCloneMaterial();
this._emissiveMap = val;
this.material.emissiveMap = val ? loadTexture(val) : null;
this.applyTexture(mapNames);
}
get emissiveIntensity() {
return this.material.emissiveIntensity;
}
set emissiveIntensity(val) {
this.tryCloneMaterial();
this.material.emissiveIntensity = val;
}
_emissive;
get emissive() {
return !!this._emissive;
}
set emissive(val) {
this._emissive = val;
if (!val)
return;
this.tryCloneMaterial();
this.material.emissiveMap = this.material.map;
this.material.emissive = this.material.color;
//todo: make this property reversible
}
_lightMap;
get lightMap() {
return this._lightMap;
}
set lightMap(val) {
this.tryCloneMaterial();
this._lightMap = val;
this.material.lightMap = val ? loadTexture(val) : null;
this.applyTexture(mapNames);
}
get lightMapIntensity() {
return this.material.lightMapIntensity;
}
set lightMapIntensity(val) {
this.tryCloneMaterial();
this.material.lightMapIntensity = val;
}
_metalnessMap;
get metalnessMap() {
return this._metalnessMap;
}
set metalnessMap(val) {
this.tryCloneMaterial();
this._metalnessMap = val;
this.material.metalnessMap = val ? loadTexture(val) : null;
this.applyTexture(mapNames);
}
get metalness() {
return this.material.metalness;
}
set metalness(val) {
this.tryCloneMaterial();
this.material.metalness = val;
}
_roughnessMap;
get roughnessMap() {
return this._roughnessMap;
}
set roughnessMap(val) {
this.tryCloneMaterial();
this._roughnessMap = val;
this.material.roughnessMap = val ? loadTexture(val) : null;
this.applyTexture(mapNames);
}
get roughness() {
return this.material.roughness;
}
set roughness(val) {
this.tryCloneMaterial();
this.material.roughness = val;
}
_normalMap;
get normalMap() {
return this._normalMap;
}
set normalMap(val) {
this.tryCloneMaterial();
this._normalMap = val;
this.material.normalMap = val ? loadTexture(val) : null;
this.applyTexture(mapNames);
}
get normalScale() {
return this.material.normalScale;
}
set normalScale(val) {
this.tryCloneMaterial();
if (typeof val === "number")
this.material.normalScale = new Vector2(val, val);
else
this.material.normalScale = val;
}
_normalMapType;
get normalMapType() {
return this._normalMapType;
}
set normalMapType(val) {
this.tryCloneMaterial();
this._normalMapType = val;
this.material.normalMapType =
val === "objectSpace" ? ObjectSpaceNormalMap : TangentSpaceNormalMap;
}
}
//# sourceMappingURL=TexturedStandardMixin.js.map