@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
147 lines (146 loc) • 5.37 kB
JavaScript
"use strict";
import { NodeParamsConfig } from "../utils/params/ParamsConfig";
import {
UniformsTransparencyParamConfig,
UniformsTransparencyController
} from "./utils/UniformsTransparencyController";
import {
AdvancedCommonController,
AdvancedCommonParamConfig
} from "./utils/AdvancedCommonController";
import { MapParamConfig, TextureMapController } from "./utils/TextureMapController";
import {
AlphaMapParamConfig,
TextureAlphaMapController
} from "./utils/TextureAlphaMapController";
import { BaseBuilderParamConfig, TypedBuilderMatNode } from "./_BaseBuilder";
import { AssemblerName } from "../../poly/registers/assemblers/_BaseRegister";
import { Poly } from "../../Poly";
import { FogParamConfig, UniformFogController } from "./utils/UniformsFogController";
import {
WireframeShaderMaterialController,
WireframeShaderMaterialParamsConfig
} from "./utils/WireframeShaderMaterialController";
import { TextureAOMapController, AOMapParamConfig } from "./utils/TextureAOMapController";
import {
TextureEnvMapSimpleController,
EnvMapSimpleParamConfig
} from "./utils/TextureEnvMapSimpleController";
import {
TextureLightMapController,
LightMapParamConfig
} from "./utils/TextureLightMapController";
import {
TextureEmissiveMapController,
EmissiveMapParamConfig
} from "./utils/TextureEmissiveMapController";
import { DefaultFolderParamConfig } from "./utils/DefaultFolder";
import { TexturesFolderParamConfig } from "./utils/TexturesFolder";
import { AdvancedFolderParamConfig } from "./utils/AdvancedFolder";
import {
TextureBumpMapController,
BumpMapParamConfig
} from "./utils/TextureBumpMapController";
import {
TextureDisplacementMapController,
DisplacementMapParamConfig
} from "./utils/TextureDisplacementMapController";
import {
TextureNormalMapController,
NormalMapParamConfig
} from "./utils/TextureNormalMapController";
import {
TextureSpecularMapController,
SpecularMapParamConfig
} from "./utils/TextureSpecularMapController";
import { PCSSController, PCSSParamConfig } from "./utils/PCSSController";
import { MatType } from "../../poly/registers/nodes/types/Mat";
import {
CustomMaterialMeshParamConfig,
materialMeshAssemblerCustomMaterialRequested
} from "./utils/customMaterials/CustomMaterialMesh";
class MeshPhongBuilderMatParamsConfig extends CustomMaterialMeshParamConfig(
PCSSParamConfig(
FogParamConfig(
WireframeShaderMaterialParamsConfig(
AdvancedCommonParamConfig(
BaseBuilderParamConfig(
/* advanced */
AdvancedFolderParamConfig(
SpecularMapParamConfig(
NormalMapParamConfig(
LightMapParamConfig(
EnvMapSimpleParamConfig(
EmissiveMapParamConfig(
DisplacementMapParamConfig(
BumpMapParamConfig(
AOMapParamConfig(
AlphaMapParamConfig(
MapParamConfig(
/* textures */
TexturesFolderParamConfig(
UniformsTransparencyParamConfig(
DefaultFolderParamConfig(NodeParamsConfig)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
) {
}
const ParamsConfig = new MeshPhongBuilderMatParamsConfig();
export class MeshPhongBuilderMatNode extends TypedBuilderMatNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
this.controllers = {
advancedCommon: new AdvancedCommonController(this),
alphaMap: new TextureAlphaMapController(this),
aoMap: new TextureAOMapController(this),
bumpMap: new TextureBumpMapController(this),
displacementMap: new TextureDisplacementMapController(this),
emissiveMap: new TextureEmissiveMapController(this),
envMap: new TextureEnvMapSimpleController(this),
lightMap: new TextureLightMapController(this),
map: new TextureMapController(this),
normalMap: new TextureNormalMapController(this),
specularMap: new TextureSpecularMapController(this),
PCSS: new PCSSController(this),
uniformFog: new UniformFogController(this),
uniformTransparency: new UniformsTransparencyController(this),
wireframeShader: new WireframeShaderMaterialController(this)
};
this.controllersList = Object.values(this.controllers);
}
static type() {
return MatType.MESH_PHONG_BUILDER;
}
usedAssembler() {
return AssemblerName.GL_MESH_PHONG;
}
_createAssemblerController() {
return Poly.assemblersRegister.assembler(this, this.usedAssembler());
}
customMaterialRequested(customName) {
return materialMeshAssemblerCustomMaterialRequested(this, customName);
}
async cook() {
this._material = this._material || this.createMaterial();
await Promise.all(this.controllersPromises(this._material));
this.compileIfRequired(this._material);
this.setMaterial(this._material);
}
}