UNPKG

@polygonjs/polygonjs

Version:

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

47 lines (46 loc) 1.33 kB
"use strict"; import { BaseController } from "./_BaseController"; import { TypedMatNode } from "../_Base"; import { NodeParamsConfig, ParamConfig } from "../../utils/params/ParamsConfig"; import { isBooleanTrue } from "../../../../core/BooleanValue"; export function FogParamConfig(Base) { return class Mixin extends Base { constructor() { super(...arguments); /** @param toggle on if you have a fog in the scene and the material should be affected by it */ this.useFog = ParamConfig.BOOLEAN(0); } }; } class FogUniformsParamsConfig extends FogParamConfig(NodeParamsConfig) { } function isValidFogMaterial(material) { if (!material) { return false; } return material.fog != null; } class FogUniformsMatNode extends TypedMatNode { } export class UniformFogController extends BaseController { constructor(node) { super(node); this.node = node; } static async update(node) { const material = await node.material(); if (!isValidFogMaterial(material)) { return; } node.controllers.uniformFog.updateMaterial(material); } updateMaterial(material) { const pv = this.node.pv; material.fog = isBooleanTrue(pv.useFog); } getTextures(material, record) { } setParamsFromMaterial(material, record) { this.node.p.useFog.set(material.fog); } }