UNPKG

@polygonjs/polygonjs

Version:

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

45 lines (44 loc) 1.84 kB
"use strict"; import { TypedJsNode } from "./_Base"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { JsConnectionPoint, JsConnectionPointType, JS_CONNECTION_POINT_IN_NODE_DEF } from "../utils/io/connections/Js"; import { Box3 } from "three"; import { Poly } from "../../Poly"; import { inputObject3D } from "./_BaseObject3D"; const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF; class Box3SetFromObjectJsParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param precise */ this.precise = ParamConfig.BOOLEAN(false); } } const ParamsConfig = new Box3SetFromObjectJsParamsConfig(); export class Box3SetFromObjectJsNode extends TypedJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "box3SetFromObject"; } initializeNode() { this.io.inputs.setNamedInputConnectionPoints([ new JsConnectionPoint(JsConnectionPointType.OBJECT_3D, JsConnectionPointType.OBJECT_3D, CONNECTION_OPTIONS) ]); this.io.outputs.setNamedOutputConnectionPoints([ new JsConnectionPoint(JsConnectionPointType.BOX3, JsConnectionPointType.BOX3, CONNECTION_OPTIONS) ]); } setLines(linesController) { const object3D = inputObject3D(this, linesController); const precise = this.variableForInputParam(linesController, this.p.precise); const out = this.jsVarName(JsConnectionPointType.BOX3); const tmpVarName = linesController.addVariable(this, new Box3()); const func = Poly.namedFunctionsRegister.getFunction("box3SetFromObject", this, linesController); const bodyLine = func.asString(object3D, precise, tmpVarName); linesController.addBodyOrComputed(this, [ { dataType: JsConnectionPointType.PLANE, varName: out, value: bodyLine } ]); } }