UNPKG

@polygonjs/polygonjs

Version:

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

42 lines (41 loc) 1.77 kB
"use strict"; import { ParamlessTypedJsNode } from "./_Base"; import { JsConnectionPoint, JsConnectionPointType, JS_CONNECTION_POINT_IN_NODE_DEF } from "../utils/io/connections/Js"; import { RBDCuboidProperty } from "../../../core/physics/shapes/RBDCuboid"; import { Vector3 } from "three"; import { inputObject3D } from "./_BaseObject3D"; import { Poly } from "../../Poly"; const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF; export class GetPhysicsRBDCuboidPropertyJsNode extends ParamlessTypedJsNode { static type() { return "getPhysicsRBDCuboidproperty"; } initializeNode() { this.io.inputs.setNamedInputConnectionPoints([ new JsConnectionPoint(JsConnectionPointType.OBJECT_3D, JsConnectionPointType.OBJECT_3D, CONNECTION_OPTIONS) ]); this.io.outputs.setNamedOutputConnectionPoints([ new JsConnectionPoint(RBDCuboidProperty.SIZES, JsConnectionPointType.VECTOR3) ]); } setLines(shadersCollectionController) { const usedOutputNames = this.io.outputs.used_output_names(); const object3D = inputObject3D(this, shadersCollectionController); const _f = (propertyName, functionName, type) => { if (!usedOutputNames.includes(propertyName)) { return; } const func = Poly.namedFunctionsRegister.getFunction(functionName, this, shadersCollectionController); const out = this.jsVarName(propertyName); const tmpVarName = shadersCollectionController.addVariable(this, new Vector3()); shadersCollectionController.addBodyOrComputed(this, [ { dataType: type, varName: out, value: func.asString(object3D, tmpVarName) } ]); }; _f(RBDCuboidProperty.SIZES, "getPhysicsRBDCuboidSizes", JsConnectionPointType.FLOAT); } }