Skip to main content

Introduction To Bitbybit Runner: Your First 3D Website

Make Your Own 3D Website

If you're looking for ways to create your own interactive 3D website, you're in the right place! This tutorial introduces you to bitbybit-runner.js, a powerful JavaScript library that hosts robust CAD (Computer-Aided Design) algorithms naturally embedded within the Babylon.js game engine.

We will guide you through:

  1. Coding a simple visual script in Bitbybit to create a 3D cube.
  2. Setting up a very basic website on StackBlitz (a free online IDE).
  3. Including the bitbybit-runner-babylonjs.js file from our CDN.
  4. Writing simple HTML and JavaScript to integrate your visual programming script into this website.
  5. Controlling the cube's size property dynamically through a UI input element on your website.

Final Result & Code

You can either check this live demo of the completed StackBlitz project or use the code snippets below to recreate it on your own website.

Bitbybit Platform

StackBlitz - Bitbybit Runner With Rete

Rete Script (The Visual Program)

The following Bitbybit Rete script is the visual program we'll be creating. The JavaScript code used in the StackBlitz example is what gets generated when you use the "Export to Runner" feature from this script.

Bitbybit Platform

Bitbybit Rete Editor - Simple Cube for Runner Tutorial

rete logoRete
Script Source (rete)
{
"id": "rete-v2-json",
"nodes": {
"45909d014224403a": {
"id": "45909d014224403a",
"name": "bitbybit.runner.getRunnerInputValue",
"customName": "get runner input value",
"data": {
"property": "size"
},
"inputs": {},
"position": [
-521.6513277440567,
906.7005999247051
]
},
"5ade90b2e39fbbd6": {
"id": "5ade90b2e39fbbd6",
"name": "bitbybit.occt.shapes.solid.createCube",
"customName": "cube",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"size": 1,
"center": [
0,
0,
0
],
"originOnCenter": true
},
"inputs": {
"size": {
"connections": [
{
"node": "45909d014224403a",
"output": "result",
"data": {}
}
]
}
},
"position": [
-123.37365841813889,
871.1855234207264
]
},
"4d7550cb4d269c13": {
"id": "4d7550cb4d269c13",
"name": "bitbybit.occt.fillets.filletEdges",
"customName": "fillet edges",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 0.4
},
"inputs": {
"shape": {
"connections": [
{
"node": "5ade90b2e39fbbd6",
"output": "result",
"data": {}
}
]
}
},
"position": [
253.82842989423855,
894.432642393281
]
},
"43f7daeee3510bb5": {
"id": "43f7daeee3510bb5",
"name": "bitbybit.draw.drawAnyAsync",
"customName": "draw async",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
}
},
"inputs": {
"entity": {
"connections": [
{
"node": "4d7550cb4d269c13",
"output": "result",
"data": {}
}
]
},
"options": {
"connections": [
{
"node": "f20336603c0fe064",
"output": "result",
"data": {}
}
]
}
},
"position": [
773.9966577904605,
976.0937521830105
]
},
"f20336603c0fe064": {
"id": "f20336603c0fe064",
"name": "bitbybit.draw.optionsOcctShapeSimple",
"customName": "occt shape simple",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"precision": 0.005,
"drawFaces": true,
"faceColour": "#0400ff",
"drawEdges": true,
"edgeColour": "#ffffff",
"edgeWidth": 1
},
"inputs": {},
"position": [
232.13661076142694,
1322.8535815563612
]
},
"0c165e235980b047": {
"id": "0c165e235980b047",
"name": "bitbybit.runner.setRunnerResultValue",
"customName": "set runner result value",
"data": {
"property": "cubeMesh"
},
"inputs": {
"value": {
"connections": [
{
"node": "43f7daeee3510bb5",
"output": "result",
"data": {}
}
]
}
},
"position": [
1219.2348134976,
988.4699420445694
]
}
}
}

Complete Code for Your Website

Below are the index.html and script.js files you would use on StackBlitz or your own website.

<!DOCTYPE html>
<html lang="en">
<head>
<title>Home</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="styles.css" />
<script src="https://cdn.jsdelivr.net/gh/bitbybit-dev/bitbybit-assets@0.20.4/runner/bitbybit-runner-babylonjs.js"></script>
<script type="module" src="script.js"></script>
</head>
<body>
<div class="myCanvasZone">
<canvas id="myCanvas"></canvas>
</div>
<label for="size">Size</label>
<input
id="size"
type="number"
value="1"
min="1"
max="10"
step="1"
onchange="changeSize(event.target.value)"
/>
</body>
</html>


By following this tutorial and exploring the code, you'll get a hands-on understanding of how to leverage Bitbybit Runner to bring dynamic, parametrically controlled 3D content to your own web projects.