@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
105 lines (104 loc) • 4.36 kB
JavaScript
;
import { TypedJsNode } from "./_Base";
import { JsConnectionPoint, JsConnectionPointType } from "../utils/io/connections/Js";
import { NodeParamsConfig } from "../utils/params/ParamsConfig";
import { Matrix4, Quaternion, Vector3 } from "three";
import { Poly } from "../../Poly";
export var GetARSessionPropertyJsNodeOutputName = /* @__PURE__ */ ((GetARSessionPropertyJsNodeOutputName2) => {
GetARSessionPropertyJsNodeOutputName2["hitDetected"] = "hitDetected";
GetARSessionPropertyJsNodeOutputName2["hitMatrix"] = "hitMatrix";
GetARSessionPropertyJsNodeOutputName2["hitPosition"] = "hitPosition";
GetARSessionPropertyJsNodeOutputName2["hitQuaternion"] = "hitQuaternion";
return GetARSessionPropertyJsNodeOutputName2;
})(GetARSessionPropertyJsNodeOutputName || {});
class GetWebXRARSessionPropertyJsParamsConfig extends NodeParamsConfig {
}
const ParamsConfig = new GetWebXRARSessionPropertyJsParamsConfig();
export class GetWebXRARSessionPropertyJsNode extends TypedJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "getWebXRARSessionProperty";
}
initializeNode() {
this.io.inputs.setNamedInputConnectionPoints([]);
this.io.outputs.setNamedOutputConnectionPoints([
new JsConnectionPoint("hitDetected" /* hitDetected */, JsConnectionPointType.BOOLEAN),
new JsConnectionPoint("hitMatrix" /* hitMatrix */, JsConnectionPointType.MATRIX4),
new JsConnectionPoint("hitPosition" /* hitPosition */, JsConnectionPointType.VECTOR3),
new JsConnectionPoint("hitQuaternion" /* hitQuaternion */, JsConnectionPointType.QUATERNION)
]);
}
setLines(shadersCollectionController) {
const usedOutputNames = this.io.outputs.used_output_names();
const _b = (propertyName, functionName, type) => {
if (!usedOutputNames.includes(propertyName)) {
return;
}
const varName = this.jsVarName(propertyName);
const func = Poly.namedFunctionsRegister.getFunction(functionName, this, shadersCollectionController);
shadersCollectionController.addBodyOrComputed(this, [
{
dataType: type,
varName,
value: func.asString()
}
]);
};
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(tmpVarName)
}
]);
};
const _m4 = (propertyName, functionName, type) => {
if (!usedOutputNames.includes(propertyName)) {
return;
}
const varName = this.jsVarName(propertyName);
const tmpVarName = shadersCollectionController.addVariable(this, new Matrix4());
const func = Poly.namedFunctionsRegister.getFunction(functionName, this, shadersCollectionController);
shadersCollectionController.addBodyOrComputed(this, [
{
dataType: type,
varName,
value: func.asString(tmpVarName)
}
]);
};
const _q = (propertyName, functionName, type) => {
if (!usedOutputNames.includes(propertyName)) {
return;
}
const varName = this.jsVarName(propertyName);
const tmpVarName = shadersCollectionController.addVariable(this, new Quaternion());
const func = Poly.namedFunctionsRegister.getFunction(functionName, this, shadersCollectionController);
shadersCollectionController.addBodyOrComputed(this, [
{
dataType: type,
varName,
value: func.asString(tmpVarName)
}
]);
};
_b("hitDetected" /* hitDetected */, "getWebXRARHitDetected", JsConnectionPointType.BOOLEAN);
_m4("hitMatrix" /* hitMatrix */, "getWebXRARHitMatrix", JsConnectionPointType.MATRIX4);
_v3("hitPosition" /* hitPosition */, "getWebXRARHitPosition", JsConnectionPointType.VECTOR3);
_q(
"hitQuaternion" /* hitQuaternion */,
"getWebXRARHitQuaternion",
JsConnectionPointType.QUATERNION
);
}
}