@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
47 lines (46 loc) • 2.08 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;
var GetRayPropertyJsNodeInputName = /* @__PURE__ */ ((GetRayPropertyJsNodeInputName2) => {
GetRayPropertyJsNodeInputName2["origin"] = "origin";
GetRayPropertyJsNodeInputName2["direction"] = "direction";
return GetRayPropertyJsNodeInputName2;
})(GetRayPropertyJsNodeInputName || {});
export class GetRayPropertyJsNode extends ParamlessTypedJsNode {
static type() {
return "getRayProperty";
}
initializeNode() {
this.io.inputs.setNamedInputConnectionPoints([
new JsConnectionPoint(JsConnectionPointType.RAY, JsConnectionPointType.RAY, CONNECTION_OPTIONS)
]);
this.io.outputs.setNamedOutputConnectionPoints([
new JsConnectionPoint("origin" /* origin */, JsConnectionPointType.VECTOR3),
new JsConnectionPoint("direction" /* direction */, JsConnectionPointType.VECTOR3)
]);
}
setLines(shadersCollectionController) {
const usedOutputNames = this.io.outputs.used_output_names();
const ray = this.variableForInput(shadersCollectionController, JsConnectionPointType.RAY);
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(ray, tmpVarName)
}
]);
};
_v3("origin" /* origin */, "getRayOrigin", JsConnectionPointType.VECTOR3);
_v3("direction" /* direction */, "getRayDirection", JsConnectionPointType.VECTOR3);
}
}