UNPKG

@polygonjs/polygonjs

Version:

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

50 lines (49 loc) 1.53 kB
"use strict"; import { LineBasicMaterial } from "three"; import { PrimitiveMatNode } from "./_Base"; import { AdvancedCommonController, AdvancedCommonParamConfig } from "./utils/AdvancedCommonController"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { MatType } from "../../poly/registers/nodes/types/Mat"; class LineBasicMatParamsConfig extends AdvancedCommonParamConfig(NodeParamsConfig) { constructor() { super(...arguments); /** @param line color */ this.color = ParamConfig.COLOR([1, 1, 1]); /** @param line width */ this.lineWidth = ParamConfig.FLOAT(1, { range: [1, 10], rangeLocked: [true, false] }); } } const ParamsConfig = new LineBasicMatParamsConfig(); export class LineBasicMatNode extends PrimitiveMatNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; this.controllers = { advancedCommon: new AdvancedCommonController(this) }; this.controllersList = Object.values(this.controllers); } static type() { return MatType.LINE_BASIC; } createMaterial() { return new LineBasicMaterial({ color: 16777215, linewidth: 1 }); } async cook() { this._material = this._material || this.createMaterial(); await Promise.all(this.controllersPromises(this._material)); this._material.color.copy(this.pv.color); this._material.linewidth = this.pv.lineWidth; this._material.needsUpdate = true; this.setMaterial(this._material); } }