UNPKG

@polygonjs/polygonjs

Version:

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

49 lines (48 loc) 1.7 kB
"use strict"; import { NodeParamsConfig } from "../utils/params/ParamsConfig"; import { UniformsTransparencyParamConfig, UniformsTransparencyController } from "./utils/UniformsTransparencyController"; import { AdvancedCommonController, AdvancedCommonParamConfig } from "./utils/AdvancedCommonController"; import { BaseBuilderParamConfig, TypedBuilderMatNode } from "./_BaseBuilder"; import { AssemblerName } from "../../poly/registers/assemblers/_BaseRegister"; import { Poly } from "../../Poly"; import { MatType } from "../../poly/registers/nodes/types/Mat"; class MeshDistanceBuilderMatParamsConfig extends AdvancedCommonParamConfig( BaseBuilderParamConfig(UniformsTransparencyParamConfig(NodeParamsConfig)) ) { } const ParamsConfig = new MeshDistanceBuilderMatParamsConfig(); export class MeshDistanceBuilderMatNode extends TypedBuilderMatNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; this.controllers = { advancedCommon: new AdvancedCommonController(this), uniformTransparency: new UniformsTransparencyController(this) }; this.controllersList = Object.values(this.controllers); } static type() { return MatType.MESH_DISTANCE_BUILDER; } usedAssembler() { return AssemblerName.GL_MESH_DISTANCE; } _createAssemblerController() { return Poly.assemblersRegister.assembler(this, this.usedAssembler()); } customMaterialRequested(customName) { return false; } async cook() { this._material = this._material || this.createMaterial(); await Promise.all(this.controllersPromises(this._material)); this.compileIfRequired(this._material); this.setMaterial(this._material); } }