@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
144 lines (143 loc) • 5.41 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 {
TextureBumpMapController,
BumpMapParamConfig
} from "./utils/TextureBumpMapController";
import {
TextureEmissiveMapController,
EmissiveMapParamConfig
} from "./utils/TextureEmissiveMapController";
import { TextureEnvMapController, EnvMapParamConfig } from "./utils/TextureEnvMapController";
import { TextureAOMapController, AOMapParamConfig } from "./utils/TextureAOMapController";
import {
TextureNormalMapController,
NormalMapParamConfig
} from "./utils/TextureNormalMapController";
import {
TextureMetalnessRoughnessMapController,
MetalnessRoughnessMapParamConfig
} from "./utils/TextureMetalnessRoughnessMapController";
import {
TextureLightMapController,
LightMapParamConfig
} from "./utils/TextureLightMapController";
import {
TextureDisplacementMapController,
DisplacementMapParamConfig
} from "./utils/TextureDisplacementMapController";
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 { DefaultFolderParamConfig } from "./utils/DefaultFolder";
import { TexturesFolderParamConfig } from "./utils/TexturesFolder";
import { AdvancedFolderParamConfig } from "./utils/AdvancedFolder";
import { PCSSController, PCSSParamConfig } from "./utils/PCSSController";
import {
CustomMaterialMeshParamConfig,
materialMeshAssemblerCustomMaterialRequested
} from "./utils/customMaterials/CustomMaterialMesh";
import { MatType } from "../../poly/registers/nodes/types/Mat";
class MeshStandardBuilderMatParamsConfig extends CustomMaterialMeshParamConfig(
PCSSParamConfig(
FogParamConfig(
WireframeShaderMaterialParamsConfig(
AdvancedCommonParamConfig(
BaseBuilderParamConfig(
/* advanced */
AdvancedFolderParamConfig(
MetalnessRoughnessMapParamConfig(
NormalMapParamConfig(
LightMapParamConfig(
EnvMapParamConfig(
EmissiveMapParamConfig(
DisplacementMapParamConfig(
BumpMapParamConfig(
AOMapParamConfig(
AlphaMapParamConfig(
MapParamConfig(
/* textures */
TexturesFolderParamConfig(
UniformsTransparencyParamConfig(
DefaultFolderParamConfig(NodeParamsConfig)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
) {
}
const ParamsConfig = new MeshStandardBuilderMatParamsConfig();
export class MeshStandardBuilderMatNode 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 TextureEnvMapController(this),
lightMap: new TextureLightMapController(this),
map: new TextureMapController(this),
metalnessRoughnessMap: new TextureMetalnessRoughnessMapController(this),
normalMap: new TextureNormalMapController(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_STANDARD_BUILDER;
}
usedAssembler() {
return AssemblerName.GL_MESH_STANDARD;
}
_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);
}
}