UNPKG

@polygonjs/polygonjs

Version:

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

55 lines (54 loc) 2.36 kB
"use strict"; import { PHYSICS_GRAVITY_DEFAULT } from "./../../../core/physics/PhysicsWorld"; import { ParamConfig } from "./../utils/params/ParamsConfig"; import { TRIGGER_CONNECTION_NAME, TypedJsNode } from "./_Base"; import { NodeParamsConfig } from "../utils/params/ParamsConfig"; import { JsConnectionPoint, JsConnectionPointType, JS_CONNECTION_POINT_IN_NODE_DEF } from "../utils/io/connections/Js"; import { inputObject3D, setObject3DOutputLine } from "./_BaseObject3D"; import { Poly } from "../../Poly"; const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF; class SetPhysicsWorldGravityJsParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); this.gravity = ParamConfig.VECTOR3(PHYSICS_GRAVITY_DEFAULT); this.lerp = ParamConfig.FLOAT(1, { range: [0, 1], rangeLocked: [true, true] }); } } const ParamsConfig = new SetPhysicsWorldGravityJsParamsConfig(); export class SetPhysicsWorldGravityJsNode extends TypedJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "setPhysicsWorldGravity"; } initializeNode() { this.io.inputs.setNamedInputConnectionPoints([ new JsConnectionPoint(TRIGGER_CONNECTION_NAME, JsConnectionPointType.TRIGGER, CONNECTION_OPTIONS), new JsConnectionPoint(JsConnectionPointType.OBJECT_3D, JsConnectionPointType.OBJECT_3D, CONNECTION_OPTIONS) ]); this.io.outputs.setNamedOutputConnectionPoints([ new JsConnectionPoint(TRIGGER_CONNECTION_NAME, JsConnectionPointType.TRIGGER), new JsConnectionPoint(JsConnectionPointType.OBJECT_3D, JsConnectionPointType.OBJECT_3D, CONNECTION_OPTIONS) ]); } setLines(linesController) { setObject3DOutputLine(this, linesController); } setTriggerableLines(shadersCollectionController) { const object3D = inputObject3D(this, shadersCollectionController); const gravity = this.variableForInputParam(shadersCollectionController, this.p.gravity); const lerp = this.variableForInputParam(shadersCollectionController, this.p.lerp); const func = Poly.namedFunctionsRegister.getFunction( "setPhysicsWorldGravity", this, shadersCollectionController ); const bodyLine = func.asString(object3D, gravity, lerp); shadersCollectionController.addTriggerableLines(this, [bodyLine]); } }