UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

119 lines (118 loc) 4.32 kB
"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 { PCSSController, PCSSParamConfig } from "./utils/PCSSController"; import { DefaultFolderParamConfig } from "./utils/DefaultFolder"; import { TexturesFolderParamConfig } from "./utils/TexturesFolder"; import { AdvancedFolderParamConfig } from "./utils/AdvancedFolder"; import { MatType } from "../../poly/registers/nodes/types/Mat"; import { CustomMaterialMeshParamConfig, materialMeshAssemblerCustomMaterialRequested } from "./utils/customMaterials/CustomMaterialMesh"; class MeshLambertBuilderMatParamsConfig extends CustomMaterialMeshParamConfig( PCSSParamConfig( FogParamConfig( WireframeShaderMaterialParamsConfig( AdvancedCommonParamConfig( BaseBuilderParamConfig( /* advanced */ AdvancedFolderParamConfig( LightMapParamConfig( EnvMapSimpleParamConfig( EmissiveMapParamConfig( AOMapParamConfig( AlphaMapParamConfig( MapParamConfig( /* textures */ TexturesFolderParamConfig( UniformsTransparencyParamConfig( DefaultFolderParamConfig(NodeParamsConfig) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) { } const ParamsConfig = new MeshLambertBuilderMatParamsConfig(); export class MeshLambertBuilderMatNode extends TypedBuilderMatNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; this.controllers = { advancedCommon: new AdvancedCommonController(this), alphaMap: new TextureAlphaMapController(this), aoMap: new TextureAOMapController(this), emissiveMap: new TextureEmissiveMapController(this), envMap: new TextureEnvMapSimpleController(this), lightMap: new TextureLightMapController(this), map: new TextureMapController(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_LAMBERT_BUILDER; } usedAssembler() { return AssemblerName.GL_MESH_LAMBERT; } _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); } }