UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

27 lines (26 loc) 1.13 kB
"use strict"; import { Poly } from "../../Poly"; import { JsConnectionPoint, JsConnectionPointType } from "../utils/io/connections/Js"; import { BaseRayPlaneJsNode } from "./_BaseRayPlane"; const OUTPUT_NAME = "intersects"; export class RayIntersectsPlaneJsNode extends BaseRayPlaneJsNode { static type() { return "rayIntersectsPlane"; } initializeNode() { super.initializeNode(); this.io.outputs.setNamedOutputConnectionPoints([ new JsConnectionPoint(OUTPUT_NAME, JsConnectionPointType.BOOLEAN) ]); } setLines(shadersCollectionController) { const ray = this.variableForInput(shadersCollectionController, JsConnectionPointType.RAY); const plane = this.variableForInput(shadersCollectionController, JsConnectionPointType.PLANE); const out = this.jsVarName(OUTPUT_NAME); const func = Poly.namedFunctionsRegister.getFunction("rayIntersectsPlane", this, shadersCollectionController); const bodyLine = func.asString(ray, plane); shadersCollectionController.addBodyOrComputed(this, [ { dataType: JsConnectionPointType.VECTOR3, varName: out, value: bodyLine } ]); } }