@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
133 lines (132 loc) • 5.12 kB
JavaScript
;
import { ParamlessTypedJsNode } from "./_Base";
import { JsConnectionPoint, JsConnectionPointType, JS_CONNECTION_POINT_IN_NODE_DEF } from "../utils/io/connections/Js";
import { inputObject3D } from "./_BaseObject3D";
import { Poly } from "../../Poly";
import { PrimitiveArray, VectorArray } from "./code/assemblers/_BaseJsPersistedConfigUtils";
import { Vector3 } from "three";
const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF;
var GetChildrenPhysicsRBDPropertiesJsNodeInputName = /* @__PURE__ */ ((GetChildrenPhysicsRBDPropertiesJsNodeInputName2) => {
GetChildrenPhysicsRBDPropertiesJsNodeInputName2["linVel"] = "linVel";
GetChildrenPhysicsRBDPropertiesJsNodeInputName2["angVel"] = "angVel";
GetChildrenPhysicsRBDPropertiesJsNodeInputName2["linearDamping"] = "linearDamping";
GetChildrenPhysicsRBDPropertiesJsNodeInputName2["angularDamping"] = "angularDamping";
GetChildrenPhysicsRBDPropertiesJsNodeInputName2["isSleeping"] = "isSleeping";
GetChildrenPhysicsRBDPropertiesJsNodeInputName2["isMoving"] = "isMoving";
return GetChildrenPhysicsRBDPropertiesJsNodeInputName2;
})(GetChildrenPhysicsRBDPropertiesJsNodeInputName || {});
export class GetChildrenPhysicsRBDPropertiesJsNode extends ParamlessTypedJsNode {
static type() {
return "getChildrenPhysicsRBDProperties";
}
initializeNode() {
this.io.inputs.setNamedInputConnectionPoints([
new JsConnectionPoint(JsConnectionPointType.OBJECT_3D, JsConnectionPointType.OBJECT_3D, CONNECTION_OPTIONS)
]);
this.io.outputs.setNamedOutputConnectionPoints([
new JsConnectionPoint(
"linVel" /* linVel */,
JsConnectionPointType.VECTOR3_ARRAY
),
new JsConnectionPoint(
"angVel" /* angVel */,
JsConnectionPointType.VECTOR3_ARRAY
),
new JsConnectionPoint(
"linearDamping" /* linearDamping */,
JsConnectionPointType.FLOAT_ARRAY
),
new JsConnectionPoint(
"angularDamping" /* angularDamping */,
JsConnectionPointType.FLOAT_ARRAY
),
new JsConnectionPoint(
"isSleeping" /* isSleeping */,
JsConnectionPointType.BOOLEAN_ARRAY
),
new JsConnectionPoint(
"isMoving" /* isMoving */,
JsConnectionPointType.BOOLEAN_ARRAY
)
]);
}
setLines(shadersCollectionController) {
const usedOutputNames = this.io.outputs.used_output_names();
const object3D = inputObject3D(this, shadersCollectionController);
const _v3 = (propertyName, functionName, type) => {
if (!usedOutputNames.includes(propertyName)) {
return;
}
const varName = this.jsVarName(propertyName);
const tmpVarName = shadersCollectionController.addVariable(this, new VectorArray([new Vector3()]));
const func = Poly.namedFunctionsRegister.getFunction(functionName, this, shadersCollectionController);
shadersCollectionController.addBodyOrComputed(this, [
{
dataType: type,
varName,
value: func.asString(object3D, tmpVarName)
}
]);
};
const _f = (propertyName, functionName, type) => {
if (!usedOutputNames.includes(propertyName)) {
return;
}
const varName = this.jsVarName(propertyName);
const tmpVarName = shadersCollectionController.addVariable(this, new PrimitiveArray([0]));
const func = Poly.namedFunctionsRegister.getFunction(functionName, this, shadersCollectionController);
shadersCollectionController.addBodyOrComputed(this, [
{
dataType: type,
varName,
value: func.asString(object3D, tmpVarName)
}
]);
};
const _b = (propertyName, functionName, type) => {
if (!usedOutputNames.includes(propertyName)) {
return;
}
const varName = this.jsVarName(propertyName);
const tmpVarName = shadersCollectionController.addVariable(this, new PrimitiveArray([0]));
const func = Poly.namedFunctionsRegister.getFunction(functionName, this, shadersCollectionController);
shadersCollectionController.addBodyOrComputed(this, [
{
dataType: type,
varName,
value: func.asString(object3D, tmpVarName)
}
]);
};
_v3(
"angVel" /* angVel */,
"getChildrenPhysicsRBDPropertiesAngularVelocity",
JsConnectionPointType.VECTOR3_ARRAY
);
_v3(
"linVel" /* linVel */,
"getChildrenPhysicsRBDPropertiesLinearVelocity",
JsConnectionPointType.VECTOR3_ARRAY
);
_f(
"angularDamping" /* angularDamping */,
"getChildrenPhysicsRBDPropertiesAngularDamping",
JsConnectionPointType.FLOAT_ARRAY
);
_f(
"linearDamping" /* linearDamping */,
"getChildrenPhysicsRBDPropertiesLinearDamping",
JsConnectionPointType.FLOAT_ARRAY
);
_b(
"isMoving" /* isMoving */,
"getChildrenPhysicsRBDPropertiesIsMoving",
JsConnectionPointType.BOOLEAN_ARRAY
);
_b(
"isSleeping" /* isSleeping */,
"getChildrenPhysicsRBDPropertiesIsSleeping",
JsConnectionPointType.BOOLEAN_ARRAY
);
}
}