@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
83 lines (82 loc) • 3.16 kB
JavaScript
;
import { ParamlessTypedJsNode } from "./_Base";
import { JsConnectionPoint, JsConnectionPointType, JS_CONNECTION_POINT_IN_NODE_DEF } from "../utils/io/connections/Js";
import { Vector3 } from "three";
import { Poly } from "../../Poly";
const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF;
export var GetTrackedHandPropertyJsNodeInputName = /* @__PURE__ */ ((GetTrackedHandPropertyJsNodeInputName2) => {
GetTrackedHandPropertyJsNodeInputName2["thumbDirection"] = "thumbDirection";
GetTrackedHandPropertyJsNodeInputName2["indexDirection"] = "indexDirection";
GetTrackedHandPropertyJsNodeInputName2["middleDirection"] = "middleDirection";
GetTrackedHandPropertyJsNodeInputName2["ringDirection"] = "ringDirection";
GetTrackedHandPropertyJsNodeInputName2["pinkyDirection"] = "pinkyDirection";
return GetTrackedHandPropertyJsNodeInputName2;
})(GetTrackedHandPropertyJsNodeInputName || {});
const DIRECTION_PROPERTIES = [
"thumbDirection" /* thumbDirection */,
"indexDirection" /* indexDirection */,
"middleDirection" /* middleDirection */,
"ringDirection" /* ringDirection */,
"pinkyDirection" /* pinkyDirection */
];
export class GetTrackedHandPropertyJsNode extends ParamlessTypedJsNode {
static type() {
return "getTrackedHandProperty";
}
initializeNode() {
this.io.inputs.setNamedInputConnectionPoints([
new JsConnectionPoint(
JsConnectionPointType.VECTOR4_ARRAY,
JsConnectionPointType.VECTOR4_ARRAY,
CONNECTION_OPTIONS
)
]);
this.io.outputs.setNamedOutputConnectionPoints([
...DIRECTION_PROPERTIES.map((prop) => new JsConnectionPoint(prop, JsConnectionPointType.VECTOR3))
]);
}
setLines(shadersCollectionController) {
const usedOutputNames = this.io.outputs.used_output_names();
const values = this.variableForInput(shadersCollectionController, JsConnectionPointType.VECTOR4_ARRAY);
const _v3 = (propertyName, functionName, type) => {
if (!usedOutputNames.includes(propertyName)) {
return;
}
const varName = this.jsVarName(propertyName);
const tmpVarName = shadersCollectionController.addVariable(this, new Vector3());
const func = Poly.namedFunctionsRegister.getFunction(functionName, this, shadersCollectionController);
shadersCollectionController.addBodyOrComputed(this, [
{
dataType: type,
varName,
value: func.asString(values, tmpVarName)
}
]);
};
_v3(
"thumbDirection" /* thumbDirection */,
"getTrackedHandThumbDirection",
JsConnectionPointType.VECTOR3
);
_v3(
"indexDirection" /* indexDirection */,
"getTrackedHandIndexDirection",
JsConnectionPointType.VECTOR3
);
_v3(
"middleDirection" /* middleDirection */,
"getTrackedHandIndexDirection",
JsConnectionPointType.VECTOR3
);
_v3(
"ringDirection" /* ringDirection */,
"getTrackedHandRingDirection",
JsConnectionPointType.VECTOR3
);
_v3(
"pinkyDirection" /* pinkyDirection */,
"getTrackedHandPinkyDirection",
JsConnectionPointType.VECTOR3
);
}
}