Script Rete Free

TypeScript editor example

TypeScript editor example picture
Author
bitbybit
Created
Sep 10, 2024, 10:41:36 AM
Last edit
Sep 14, 2024, 4:41:23 AM

Edit scriptPreview

Project

Magical Particles

This project demonstrates powerful new features of the Rete editor. We took the opportunity to create particle systems that react to parametric geometry nodes. You can now write custom TypeScript code with full intellisense for bitbybit and BabylonJS.

View full project
{
  "id": "rete-v2-json",
  "nodes": {
    "35ea8860176ceb8a": {
      "id": "35ea8860176ceb8a",
      "name": "bitbybit.code.typeScriptEditor",
      "async": true,
      "drawable": true,
      "data": {
        "genericNodeData": {
          "hide": false,
          "oneOnOne": false,
          "flatten": 0,
          "forceExecution": true
        },
        "options": {
          "width": 897,
          "height": 522
        },
        "code": {
          "code": "// DO NOT REMOVE THIS FUNCTION\nconst start35ea8860176ceb8a = async (inputs: {\n    color1: string,\n    color2: string,\n    position: [number, number, number],\n    nrParticles: number\n}, index: number) => {\n    // ADD YOUR CODE HERE\n    const scene = bitbybit.babylon.scene.getScene();\n    if (index === 0) {\n        scene.particleSystems.forEach(ps => ps.stop());\n    }\n\n    // Create a particle system\n    var particleSystem = new BABYLON.ParticleSystem(\"particles\" + index, inputs.nrParticles, scene);\n    particleSystem.id = \"my-particles-\" + index;\n    //Texture of each particle\n    particleSystem.particleTexture = new BABYLON.Texture(\"https://playground.babylonjs.com/textures/flare.png\", scene);\n\n    // Where the particles come from\n    particleSystem.emitter = new BABYLON.Vector3(...inputs.position); // the starting location\n\n    // Colors of all particles\n    const color1 = BABYLON.Color3.FromHexString(inputs.color1);\n    const color2 = BABYLON.Color3.FromHexString(inputs.color2);\n\n    particleSystem.color1 = new BABYLON.Color4(color1.r, color1.g, color1.b, 1.0);\n    particleSystem.color2 = new BABYLON.Color4(color2.r, color2.g, color2.b, 1.0);\n    particleSystem.colorDead = new BABYLON.Color4(0, 0, 0.2, 0.0);\n\n    // Size of each particle (random between...\n    particleSystem.minSize = 0.1;\n    particleSystem.maxSize = 0.5;\n\n    // Life time of each particle (random between...\n    particleSystem.minLifeTime = 0.3;\n    particleSystem.maxLifeTime = 1.5;\n\n    // Emission rate\n    particleSystem.emitRate = 1000;\n\n    /******* Emission Space ********/\n    particleSystem.createDirectedSphereEmitter(2, new BABYLON.Vector3(-0.5, 1, -0.5), new BABYLON.Vector3(0.5, 1, 0.5));\n\n    // Speed\n    particleSystem.minEmitPower = 2;\n    particleSystem.maxEmitPower = 4;\n    particleSystem.updateSpeed = 0.005;\n    particleSystem.disposeOnStop = true;\n\n    // Start the particle system\n    particleSystem.start();\n    return inputs;\n}"
        }
      },
      "inputs": {
        "inputs": {
          "connections": [
            {
              "node": "fd21f032624bf9ad",
              "output": "result",
              "data": {}
            }
          ]
        }
      },
      "position": [
        2909.891380699121,
        1375.3700267396769
      ]
    },
    "94383f27c6e7069a": {
      "id": "94383f27c6e7069a",
      "name": "bitbybit.json.createEmpty",
      "async": false,
      "drawable": false,
      "data": {
        "genericNodeData": {
          "hide": false,
          "oneOnOne": false,
          "flatten": 0,
          "forceExecution": false
        }
      },
      "inputs": {},
      "position": [
        410.68576942600765,
        1251.0524562881528
      ]
    },
    "eb263e9922c5be1e": {
      "id": "eb263e9922c5be1e",
      "name": "bitbybit.json.setValueOnProp",
      "async": false,
      "drawable": false,
      "data": {
        "genericNodeData": {
          "hide": false,
          "oneOnOne": false,
          "flatten": 0,
          "forceExecution": false
        },
        "property": "nrParticles"
      },
      "inputs": {
        "value": {
          "connections": [
            {
              "node": "d6be70106f938600",
              "output": "result",
              "data": {}
            }
          ]
        },
        "json": {
          "connections": [
            {
              "node": "94383f27c6e7069a",
              "output": "result",
              "data": {}
            }
          ]
        }
      },
      "position": [
        867.7832941273158,
        1339.8980028713845
      ]
    },
    "d6be70106f938600": {
      "id": "d6be70106f938600",
      "name": "bitbybit.math.numberSlider",
      "data": {
        "options": {
          "min": 100,
          "max": 3000,
          "step": 10,
          "width": 350,
          "updateOnDrag": false
        },
        "number": 3000
      },
      "inputs": {},
      "position": [
        226.41777540886915,
        1504.7093107761557
      ]
    },
    "fd21f032624bf9ad": {
      "id": "fd21f032624bf9ad",
      "name": "bitbybit.json.setValueOnProp",
      "async": false,
      "drawable": false,
      "data": {
        "genericNodeData": {
          "hide": false,
          "oneOnOne": false,
          "flatten": 0,
          "forceExecution": false
        },
        "property": "position"
      },
      "inputs": {
        "value": {
          "connections": [
            {
              "node": "a7e2e2379aaf7b31",
              "output": "result",
              "data": {}
            }
          ]
        },
        "json": {
          "connections": [
            {
              "node": "8199e24f86816c9c",
              "output": "result",
              "data": {}
            }
          ]
        }
      },
      "position": [
        2439.473276344556,
        1338.0599660397713
      ]
    },
    "1f1629e2ae5a21ba": {
      "id": "1f1629e2ae5a21ba",
      "name": "bitbybit.occt.shapes.wire.createCircleWire",
      "async": true,
      "drawable": true,
      "data": {
        "genericNodeData": {
          "hide": true,
          "oneOnOne": false,
          "flatten": 0,
          "forceExecution": false
        },
        "radius": 10,
        "center": [
          0,
          0,
          0
        ],
        "direction": [
          0,
          1,
          0
        ]
      },
      "inputs": {
        "radius": {
          "connections": [
            {
              "node": "b0ea8accbe13202c",
              "output": "result",
              "data": {}
            }
          ]
        }
      },
      "position": [
        -177.83830021944425,
        1858.0091956671577
      ]
    },
    "31f8fe312b3ad262": {
      "id": "31f8fe312b3ad262",
      "name": "bitbybit.occt.shapes.wire.divideWireByParamsToPoints",
      "async": true,
      "drawable": true,
      "data": {
        "genericNodeData": {
          "hide": true,
          "oneOnOne": false,
          "flatten": 0,
          "forceExecution": false
        },
        "nrOfDivisions": 10,
        "removeStartPoint": false,
        "removeEndPoint": false
      },
      "inputs": {
        "shape": {
          "connections": [
            {
              "node": "1f1629e2ae5a21ba",
              "output": "result",
              "data": {}
            }
          ]
        },
        "nrOfDivisions": {
          "connections": [
            {
              "node": "198267df45a6240c",
              "output": "result",
              "data": {}
            }
          ]
        }
      },
      "position": [
        744.1984525736938,
        1937.690697017307
      ]
    },
    "b0ea8accbe13202c": {
      "id": "b0ea8accbe13202c",
      "name": "bitbybit.math.numberSlider",
      "data": {
        "options": {
          "min": 5,
          "max": 30,
          "step": 1,
          "width": 350,
          "updateOnDrag": false
        },
        "number": 9
      },
      "inputs": {},
      "position": [
        -732.9596061110801,
        1710.1641635571914
      ]
    },
    "198267df45a6240c": {
      "id": "198267df45a6240c",
      "name": "bitbybit.math.numberSlider",
      "data": {
        "options": {
          "min": 5,
          "max": 100,
          "step": 1,
          "width": 350,
          "updateOnDrag": false
        },
        "number": 16
      },
      "inputs": {},
      "position": [
        161.37638574773192,
        2103.830385761359
      ]
    },
    "defd1b07fbe0cf90": {
      "id": "defd1b07fbe0cf90",
      "name": "bitbybit.occt.shapes.wire.createCircleWire",
      "async": true,
      "drawable": true,
      "data": {
        "genericNodeData": {
          "hide": false,
          "oneOnOne": false,
          "flatten": 0,
          "forceExecution": false
        },
        "radius": 3,
        "center": [
          0,
          0,
          0
        ],
        "direction": [
          0,
          1,
          0
        ]
      },
      "inputs": {
        "center": {
          "connections": [
            {
              "node": "a7e2e2379aaf7b31",
              "output": "result",
              "data": {}
            }
          ]
        }
      },
      "position": [
        1674.7470719495707,
        1931.0041996783202
      ]
    },
    "a7e2e2379aaf7b31": {
      "id": "a7e2e2379aaf7b31",
      "name": "bitbybit.lists.flatten",
      "data": {
        "nrLevels": 1
      },
      "inputs": {
        "list": {
          "connections": [
            {
              "node": "31f8fe312b3ad262",
              "output": "result",
              "data": {}
            }
          ]
        }
      },
      "position": [
        1285.8659460094254,
        1835.4087230914433
      ]
    },
    "854079a679367b0a": {
      "id": "854079a679367b0a",
      "name": "bitbybit.occt.transforms.translate",
      "async": true,
      "drawable": true,
      "data": {
        "genericNodeData": {
          "hide": false,
          "oneOnOne": false,
          "flatten": 0,
          "forceExecution": false
        },
        "translation": [
          0,
          0,
          0
        ]
      },
      "inputs": {
        "shape": {
          "connections": [
            {
              "node": "defd1b07fbe0cf90",
              "output": "result",
              "data": {}
            }
          ]
        },
        "translation": {
          "connections": [
            {
              "node": "c5f7aa95b56eb47b",
              "output": "result",
              "data": {}
            }
          ]
        }
      },
      "position": [
        2055.3079421698235,
        2158.0793704212438
      ]
    },
    "c5f7aa95b56eb47b": {
      "id": "c5f7aa95b56eb47b",
      "name": "bitbybit.vector.vectorXYZ",
      "async": false,
      "drawable": true,
      "data": {
        "genericNodeData": {
          "hide": true,
          "oneOnOne": false,
          "flatten": 0,
          "forceExecution": false
        },
        "x": 0,
        "y": -1,
        "z": 0
      },
      "inputs": {},
      "position": [
        1625.461627299713,
        2287.0151769877325
      ]
    },
    "7b5c22e32c8544c7": {
      "id": "7b5c22e32c8544c7",
      "name": "bitbybit.json.setValueOnProp",
      "async": false,
      "drawable": false,
      "data": {
        "genericNodeData": {
          "hide": false,
          "oneOnOne": false,
          "flatten": 0,
          "forceExecution": false
        },
        "property": "color1"
      },
      "inputs": {
        "value": {
          "connections": [
            {
              "node": "a11488e429acd6a2",
              "output": "result",
              "data": {}
            }
          ]
        },
        "json": {
          "connections": [
            {
              "node": "eb263e9922c5be1e",
              "output": "result",
              "data": {}
            }
          ]
        }
      },
      "position": [
        1423.5666145348887,
        863.1660946952355
      ]
    },
    "a11488e429acd6a2": {
      "id": "a11488e429acd6a2",
      "name": "bitbybit.color.hexColor",
      "async": false,
      "drawable": false,
      "data": {
        "genericNodeData": {
          "hide": false,
          "oneOnOne": false,
          "flatten": 0,
          "forceExecution": false
        },
        "color": "#5c67ff"
      },
      "inputs": {},
      "position": [
        1077.544219602157,
        992.0540990011638
      ]
    },
    "8199e24f86816c9c": {
      "id": "8199e24f86816c9c",
      "name": "bitbybit.json.setValueOnProp",
      "async": false,
      "drawable": false,
      "data": {
        "genericNodeData": {
          "hide": false,
          "oneOnOne": false,
          "flatten": 0,
          "forceExecution": false
        },
        "property": "color2"
      },
      "inputs": {
        "json": {
          "connections": [
            {
              "node": "7b5c22e32c8544c7",
              "output": "result",
              "data": {}
            }
          ]
        },
        "value": {
          "connections": [
            {
              "node": "0db84e9c30ca210e",
              "output": "result",
              "data": {}
            }
          ]
        }
      },
      "position": [
        1910.328582846355,
        861.5017501798043
      ]
    },
    "0db84e9c30ca210e": {
      "id": "0db84e9c30ca210e",
      "name": "bitbybit.color.hexColor",
      "async": false,
      "drawable": false,
      "data": {
        "genericNodeData": {
          "hide": false,
          "oneOnOne": false,
          "flatten": 0,
          "forceExecution": false
        },
        "color": "#8e97b8"
      },
      "inputs": {},
      "position": [
        1549.6305085777205,
        1242.6072677183674
      ]
    }
  }
}

Plans and pricing

Choose your plan

Editor plans for 3D development, API keys for server-side CAD algorithms

EnterpriseB2BCustompricing

Custom software development, dedicated servers and CAD automation at scale.

Learn moreContact us

CAD automation and software
  • Custom software development
  • Cloud CAD automation pipelines
  • 3D configurators (STEP & GLTF)
  • Batch export jobs
  • Custom algorithms & deployment
Infrastructure and support
  • Custom compute allocation
  • Dedicated / VPS server tenants
  • Long-running computation jobs
  • Custom upload limits & overage
  • SLA & premium support

All prices exclude applicable taxesView all plan details

Contact

Talk to us

Tell us what you are building or what is blocking you, through whichever channel suits you.