UNPKG

polygonjs-engine

Version:

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

51 lines (50 loc) 2.24 kB
import {MeshLambertMaterial as MeshLambertMaterial2} from "three/src/materials/MeshLambertMaterial"; import {FrontSide} from "three/src/constants"; import {TypedMatNode} from "./_Base"; import {NodeParamsConfig} from "../utils/params/ParamsConfig"; import {ColorsController as ColorsController2, ColorParamConfig} from "./utils/ColorsController"; import {SideController as SideController2, SideParamConfig} from "./utils/SideController"; import {DepthController as DepthController2, DepthParamConfig} from "./utils/DepthController"; import {SkinningController as SkinningController2, SkinningParamConfig} from "./utils/SkinningController"; import {TextureMapController as TextureMapController2, TextureMapParamConfig} from "./utils/TextureMapController"; import {TextureAlphaMapController as TextureAlphaMapController2, TextureAlphaMapParamConfig} from "./utils/TextureAlphaMapController"; class MeshLambertMatParamsConfig extends TextureAlphaMapParamConfig(TextureMapParamConfig(SkinningParamConfig(DepthParamConfig(SideParamConfig(ColorParamConfig(NodeParamsConfig)))))) { } const ParamsConfig2 = new MeshLambertMatParamsConfig(); export class MeshLambertMatNode extends TypedMatNode { constructor() { super(...arguments); this.params_config = ParamsConfig2; this.texture_map_controller = new TextureMapController2(this, {direct_params: true}); this.texture_alpha_map_controller = new TextureAlphaMapController2(this, { direct_params: true }); this.depth_controller = new DepthController2(this); } static type() { return "meshLambert"; } create_material() { return new MeshLambertMaterial2({ vertexColors: false, side: FrontSide, color: 16777215, opacity: 1 }); } initializeNode() { this.params.onParamsCreated("init controllers", () => { this.texture_map_controller.initializeNode(); this.texture_alpha_map_controller.initializeNode(); }); } async cook() { ColorsController2.update(this); SideController2.update(this); SkinningController2.update(this); this.texture_map_controller.update(); this.texture_alpha_map_controller.update(); this.depth_controller.update(); this.set_material(this.material); } }