@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
28 lines (27 loc) • 1.23 kB
JavaScript
;
import { BaseRayBox3JsNode } from "./_BaseRayBox3";
import { JsConnectionPoint, JsConnectionPointType, JS_CONNECTION_POINT_IN_NODE_DEF } from "../utils/io/connections/Js";
import { Poly } from "../../Poly";
const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF;
const OUTPUT_NAME = "intersects";
export class RayIntersectsBoxJsNode extends BaseRayBox3JsNode {
static type() {
return "rayIntersectsBox";
}
initializeNode() {
super.initializeNode();
this.io.outputs.setNamedOutputConnectionPoints([
new JsConnectionPoint(OUTPUT_NAME, JsConnectionPointType.BOOLEAN, CONNECTION_OPTIONS)
]);
}
setLines(shadersCollectionController) {
const ray = this.variableForInput(shadersCollectionController, JsConnectionPointType.RAY);
const box3 = this.variableForInput(shadersCollectionController, JsConnectionPointType.BOX3);
const out = this.jsVarName(OUTPUT_NAME);
const func = Poly.namedFunctionsRegister.getFunction("rayIntersectsBox3", this, shadersCollectionController);
const bodyLine = func.asString(ray, box3);
shadersCollectionController.addBodyOrComputed(this, [
{ dataType: JsConnectionPointType.VECTOR3, varName: out, value: bodyLine }
]);
}
}