UNPKG

@polygonjs/polygonjs

Version:

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

154 lines (153 loc) 6.26 kB
"use strict"; 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 { Quaternion, Vector3 } from "three"; const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF; export var GetChildrenPropertiesJsNodeOutputName = /* @__PURE__ */ ((GetChildrenPropertiesJsNodeOutputName2) => { GetChildrenPropertiesJsNodeOutputName2["position"] = "position"; GetChildrenPropertiesJsNodeOutputName2["quaternion"] = "quaternion"; GetChildrenPropertiesJsNodeOutputName2["scale"] = "scale"; GetChildrenPropertiesJsNodeOutputName2["visible"] = "visible"; GetChildrenPropertiesJsNodeOutputName2["castShadow"] = "castShadow"; GetChildrenPropertiesJsNodeOutputName2["receiveShadow"] = "receiveShadow"; GetChildrenPropertiesJsNodeOutputName2["frustumCulled"] = "frustumCulled"; GetChildrenPropertiesJsNodeOutputName2["up"] = "up"; GetChildrenPropertiesJsNodeOutputName2["matrixAutoUpdate"] = "matrixAutoUpdate"; return GetChildrenPropertiesJsNodeOutputName2; })(GetChildrenPropertiesJsNodeOutputName || {}); export class GetChildrenPropertiesJsNode extends ParamlessTypedJsNode { static type() { return "getChildrenProperties"; } initializeNode() { this.io.inputs.setNamedInputConnectionPoints([ new JsConnectionPoint(JsConnectionPointType.OBJECT_3D, JsConnectionPointType.OBJECT_3D, CONNECTION_OPTIONS) ]); this.io.outputs.setNamedOutputConnectionPoints([ new JsConnectionPoint("position" /* position */, JsConnectionPointType.VECTOR3_ARRAY), new JsConnectionPoint( "quaternion" /* quaternion */, JsConnectionPointType.QUATERNION_ARRAY ), new JsConnectionPoint("scale" /* scale */, JsConnectionPointType.VECTOR3_ARRAY), // new JsConnectionPoint( // GetChildrenPropertiesJsNodeInputName.matrix, // JsConnectionPointType.MATRIX4_ARRAY // ), new JsConnectionPoint("up" /* up */, JsConnectionPointType.VECTOR3_ARRAY), new JsConnectionPoint("visible" /* visible */, JsConnectionPointType.BOOLEAN_ARRAY), new JsConnectionPoint( "matrixAutoUpdate" /* matrixAutoUpdate */, JsConnectionPointType.BOOLEAN_ARRAY ), new JsConnectionPoint( "castShadow" /* castShadow */, JsConnectionPointType.BOOLEAN_ARRAY ), new JsConnectionPoint( "receiveShadow" /* receiveShadow */, JsConnectionPointType.BOOLEAN_ARRAY ), new JsConnectionPoint( "frustumCulled" /* frustumCulled */, JsConnectionPointType.BOOLEAN_ARRAY ) // new JsConnectionPoint(GetChildrenPropertiesJsNodeInputName.id, JsConnectionPointType.INTEGER), // new JsConnectionPoint(GetChildrenPropertiesJsNodeInputName.uuid, JsConnectionPointType.BOOLEAN), // new JsConnectionPoint(MATERIAL_OUTPUT, JsConnectionPointType.MATERIAL), ]); } 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 _q = (propertyName, functionName, type) => { if (!usedOutputNames.includes(propertyName)) { return; } const varName = this.jsVarName(propertyName); const tmpVarName = shadersCollectionController.addVariable(this, new VectorArray([new Quaternion()])); 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([false])); const func = Poly.namedFunctionsRegister.getFunction(functionName, this, shadersCollectionController); shadersCollectionController.addBodyOrComputed(this, [ { dataType: type, varName, value: func.asString(object3D, tmpVarName) } ]); }; _v3( "position" /* position */, "getChildrenPropertiesPosition", JsConnectionPointType.VECTOR3_ARRAY ); _v3( "scale" /* scale */, "getChildrenPropertiesScale", JsConnectionPointType.VECTOR3_ARRAY ); _v3("up" /* up */, "getChildrenPropertiesUp", JsConnectionPointType.VECTOR3_ARRAY); _q( "quaternion" /* quaternion */, "getChildrenPropertiesQuaternion", JsConnectionPointType.QUATERNION_ARRAY ); _b( "visible" /* visible */, "getChildrenPropertiesVisible", JsConnectionPointType.BOOLEAN_ARRAY ); _b( "matrixAutoUpdate" /* matrixAutoUpdate */, "getChildrenPropertiesMatrixAutoUpdate", JsConnectionPointType.BOOLEAN_ARRAY ); _b( "castShadow" /* castShadow */, "getChildrenPropertiesCastShadow", JsConnectionPointType.BOOLEAN_ARRAY ); _b( "receiveShadow" /* receiveShadow */, "getChildrenPropertiesReceiveShadow", JsConnectionPointType.BOOLEAN_ARRAY ); _b( "frustumCulled" /* frustumCulled */, "getChildrenPropertiesFrustumCulled", JsConnectionPointType.BOOLEAN_ARRAY ); } }