@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
42 lines (41 loc) • 1.32 kB
JavaScript
;
import { ShadowMaterial } 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 { MatType } from "../../poly/registers/nodes/types/Mat";
class ShadowMatParamsConfig extends AdvancedCommonParamConfig(ColorParamConfig(NodeParamsConfig)) {
}
const ParamsConfig = new ShadowMatParamsConfig();
export class ShadowMatNode extends PrimitiveMatNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
this.controllers = {
colors: new ColorsController(this),
advancedCommon: new AdvancedCommonController(this)
};
this.controllersList = Object.values(this.controllers);
}
static type() {
return MatType.SHADOW;
}
createMaterial() {
return new ShadowMaterial({
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);
}
}