@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
29 lines (28 loc) • 1.25 kB
JavaScript
;
import { Vector3 } from "three";
import { Poly } from "../../Poly";
import { JsConnectionPoint, JsConnectionPointType } from "../utils/io/connections/Js";
import { BaseRayPlaneJsNode } from "./_BaseRayPlane";
const OUTPUT_NAME = "position";
export class RayIntersectPlaneJsNode extends BaseRayPlaneJsNode {
static type() {
return "rayIntersectPlane";
}
initializeNode() {
super.initializeNode();
this.io.outputs.setNamedOutputConnectionPoints([
new JsConnectionPoint(OUTPUT_NAME, JsConnectionPointType.VECTOR3)
]);
}
setLines(shadersCollectionController) {
const ray = this.variableForInput(shadersCollectionController, JsConnectionPointType.RAY);
const plane = this.variableForInput(shadersCollectionController, JsConnectionPointType.PLANE);
const out = this.jsVarName(OUTPUT_NAME);
const tmpVarName = shadersCollectionController.addVariable(this, new Vector3());
const func = Poly.namedFunctionsRegister.getFunction("rayIntersectPlane", this, shadersCollectionController);
const bodyLine = func.asString(ray, plane, tmpVarName);
shadersCollectionController.addBodyOrComputed(this, [
{ dataType: JsConnectionPointType.VECTOR3, varName: out, value: bodyLine }
]);
}
}