UNPKG

@polygonjs/polygonjs

Version:

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

86 lines (85 loc) 3.32 kB
"use strict"; import { TypedJsNode } from "./_Base"; import { NodeParamsConfig } from "../utils/params/ParamsConfig"; import { JsConnectionPointType } from "../utils/io/connections/Js"; import { inputObject3D, setObject3DOutputLine } from "./_BaseObject3D"; import { Poly } from "../../Poly"; export const SetGeometryInstanceQuaternionsInputName = { [JsConnectionPointType.TRIGGER]: JsConnectionPointType.TRIGGER, [JsConnectionPointType.OBJECT_3D]: JsConnectionPointType.OBJECT_3D, quaternion: "quaternion", lerp: "lerp", attributeNeedsUpdate: "attributeNeedsUpdate" }; const INPUT_NAMES = [ SetGeometryInstanceQuaternionsInputName.trigger, SetGeometryInstanceQuaternionsInputName.Object3D, SetGeometryInstanceQuaternionsInputName.quaternion, SetGeometryInstanceQuaternionsInputName.lerp, SetGeometryInstanceQuaternionsInputName.attributeNeedsUpdate ]; const DefaultValues = { [SetGeometryInstanceQuaternionsInputName.lerp]: 1, [SetGeometryInstanceQuaternionsInputName.attributeNeedsUpdate]: true }; class SetGeometryInstanceQuaternionsJsParamsConfig extends NodeParamsConfig { } const ParamsConfig = new SetGeometryInstanceQuaternionsJsParamsConfig(); export class SetGeometryInstanceQuaternionsJsNode extends TypedJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "setGeometryInstanceQuaternions"; } initializeNode() { super.initializeNode(); this.io.connection_points.set_expected_input_types_function(this.expectedInputTypes.bind(this)); this.io.connection_points.set_expected_output_types_function(this._expectedOutputTypes.bind(this)); this.io.connection_points.set_output_name_function( (i) => [JsConnectionPointType.TRIGGER, JsConnectionPointType.OBJECT_3D][i] ); this.io.connection_points.set_input_name_function(this._expectedInputName.bind(this)); } paramDefaultValue(name) { return DefaultValues[name]; } expectedInputTypes() { return [ JsConnectionPointType.TRIGGER, JsConnectionPointType.OBJECT_3D, JsConnectionPointType.QUATERNION_ARRAY, JsConnectionPointType.FLOAT, JsConnectionPointType.BOOLEAN ]; } _expectedOutputTypes() { return [JsConnectionPointType.TRIGGER, JsConnectionPointType.OBJECT_3D]; } _expectedInputName(index) { return INPUT_NAMES[index]; } setLines(linesController) { setObject3DOutputLine(this, linesController); } setTriggerableLines(shadersCollectionController) { const object3D = inputObject3D(this, shadersCollectionController); const quaternions = this.variableForInput( shadersCollectionController, SetGeometryInstanceQuaternionsInputName.quaternion ); const lerp = this.variableForInput(shadersCollectionController, SetGeometryInstanceQuaternionsInputName.lerp); const attributeNeedsUpdate = this.variableForInput( shadersCollectionController, SetGeometryInstanceQuaternionsInputName.attributeNeedsUpdate ); const func = Poly.namedFunctionsRegister.getFunction( "setGeometryInstanceQuaternions", this, shadersCollectionController ); const bodyLine = func.asString(object3D, quaternions, lerp, attributeNeedsUpdate); shadersCollectionController.addTriggerableLines(this, [bodyLine]); } }