UNPKG

polygonjs-engine

Version:

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

40 lines (39 loc) 1.33 kB
import {TypedBuilderMatNode} from "./_BaseBuilder"; import {NodeParamsConfig, ParamConfig} from "../utils/params/ParamsConfig"; import {VolumeController as VolumeController2} from "./utils/VolumeController"; import {AssemblerName} from "../../poly/registers/assemblers/_BaseRegister"; import {Poly as Poly2} from "../../Poly"; class VolumeMatParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); this.color = ParamConfig.COLOR([1, 1, 1]); this.stepSize = ParamConfig.FLOAT(0.01); this.density = ParamConfig.FLOAT(1); this.shadowDensity = ParamConfig.FLOAT(1); this.lightDir = ParamConfig.VECTOR3([-1, -1, -1]); } } const ParamsConfig2 = new VolumeMatParamsConfig(); export class VolumeBuilderMatNode extends TypedBuilderMatNode { constructor() { super(...arguments); this.params_config = ParamsConfig2; this._volume_controller = new VolumeController2(this); } static type() { return "volumeBuilder"; } usedAssembler() { return AssemblerName.GL_VOLUME; } _create_assembler_controller() { return Poly2.assemblersRegister.assembler(this, this.usedAssembler()); } initializeNode() { } async cook() { this.compile_if_required(); this._volume_controller.update_uniforms_from_params(); this.set_material(this.material); } }