@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
100 lines (99 loc) • 3.32 kB
JavaScript
"use strict";
import { MeshMatcapMaterial } from "three";
import { FrontSide } from "three";
import { PrimitiveMatNode } from "./_Base";
import { NodeParamsConfig } from "../utils/params/ParamsConfig";
import { ColorsController, ColorParamConfig } from "./utils/ColorsController";
import {
AdvancedCommonController,
AdvancedCommonParamConfig
} from "./utils/AdvancedCommonController";
import { TextureMapController, MapParamConfig } from "./utils/TextureMapController";
import {
TextureAlphaMapController,
AlphaMapParamConfig
} from "./utils/TextureAlphaMapController";
import {
TextureBumpMapController,
BumpMapParamConfig
} from "./utils/TextureBumpMapController";
import {
TextureNormalMapController,
NormalMapParamConfig
} from "./utils/TextureNormalMapController";
import {
TextureDisplacementMapController,
DisplacementMapParamConfig
} from "./utils/TextureDisplacementMapController";
import {
TextureMatcapMapController,
MatcapMapParamConfig
} from "./utils/TextureMatcapMapController";
import { FlatShadingController, FlatShadingParamConfig } from "./utils/FlatShadingController";
import { FogController, FogParamConfig } from "./utils/FogController";
import { DefaultFolderParamConfig } from "./utils/DefaultFolder";
import { TexturesFolderParamConfig } from "./utils/TexturesFolder";
import { AdvancedFolderParamConfig } from "./utils/AdvancedFolder";
import { MatType } from "../../poly/registers/nodes/types/Mat";
class MeshMatCapMatParamsConfig extends FogParamConfig(
AdvancedCommonParamConfig(
FlatShadingParamConfig(
/* advanced */
AdvancedFolderParamConfig(
NormalMapParamConfig(
DisplacementMapParamConfig(
BumpMapParamConfig(
AlphaMapParamConfig(
MapParamConfig(
MatcapMapParamConfig(
/* textures */
TexturesFolderParamConfig(
ColorParamConfig(DefaultFolderParamConfig(NodeParamsConfig))
)
)
)
)
)
)
)
)
)
)
) {
}
const ParamsConfig = new MeshMatCapMatParamsConfig();
export class MeshMatcapMatNode extends PrimitiveMatNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
this.controllers = {
colors: new ColorsController(this),
advancedCommon: new AdvancedCommonController(this),
alphaMap: new TextureAlphaMapController(this),
bumpMap: new TextureBumpMapController(this),
displacementMap: new TextureDisplacementMapController(this),
fog: new FogController(this),
flatShading: new FlatShadingController(this),
map: new TextureMapController(this),
matcap: new TextureMatcapMapController(this),
normalMap: new TextureNormalMapController(this)
};
this.controllersList = Object.values(this.controllers);
}
static type() {
return MatType.MESH_MATCAP;
}
createMaterial() {
return new MeshMatcapMaterial({
vertexColors: false,
side: FrontSide,
color: 16777215,
opacity: 1
});
}
async cook() {
this._material = this._material || this.createMaterial();
await Promise.all(this.controllersPromises(this._material));
this.setMaterial(this._material);
}
}