@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
46 lines (45 loc) • 1.95 kB
JavaScript
;
import { JsConnectionPoint, JsConnectionPointType, JS_CONNECTION_POINT_IN_NODE_DEF } from "../utils/io/connections/Js";
import { Poly } from "../../Poly";
import { inputObject3D } from "./_BaseObject3D";
import { TypedJsNode } from "./_Base";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF;
class RayIntersectObjectJsParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
this.recursive = ParamConfig.BOOLEAN(0);
}
}
const ParamsConfig = new RayIntersectObjectJsParamsConfig();
export class RayIntersectObjectJsNode extends TypedJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "rayIntersectObject";
}
initializeNode() {
this.io.inputs.setNamedInputConnectionPoints([
new JsConnectionPoint(JsConnectionPointType.RAY, JsConnectionPointType.RAY, CONNECTION_OPTIONS),
new JsConnectionPoint(JsConnectionPointType.OBJECT_3D, JsConnectionPointType.OBJECT_3D, CONNECTION_OPTIONS)
]);
this.io.outputs.setNamedOutputConnectionPoints([
new JsConnectionPoint(
JsConnectionPointType.INTERSECTION,
JsConnectionPointType.INTERSECTION,
CONNECTION_OPTIONS
)
]);
}
setLines(linesController) {
const object3D = inputObject3D(this, linesController);
const ray = this.variableForInput(linesController, JsConnectionPointType.RAY);
const recursive = this.variableForInputParam(linesController, this.p.recursive);
const varName = this.jsVarName(JsConnectionPointType.INTERSECTION);
const func = Poly.namedFunctionsRegister.getFunction("rayIntersectObject3D", this, linesController);
const bodyLine = func.asString(ray, object3D, recursive);
linesController.addBodyOrComputed(this, [{ dataType: JsConnectionPointType.VECTOR3, varName, value: bodyLine }]);
}
}