+/** call "init" when document is fully loaded */\r
+document.body.onload = init;\r
+\r
+function init() {\r
+ let mousePos = new Point();\r
+ let previousClothSimulation;\r
+ \r
+ /**\r
+ * Space left empty under canvas\r
+ * for UI elements\r
+ */\r
+ const canvasSpace = 200;\r
+\r
+ /** Constant Frame Time */\r
+ const frameTime = 1000.0 / 60.0;\r
+\r
+ /** Setup scene */\r
+ let [scene, camera, renderer] = setup_scene(canvasSpace);\r
+ \r
+ /** setup cloth and generate debug mesh */\r
+ let cloth = new Cloth();\r
+ cloth.createBasic(10, 10, 10, 10);\r
+ //cloth.createDebugMesh(scene);\r
+\r
+ const material = new THREE.MeshBasicMaterial({ color: 0x0000ff });\r
+ const mesh = new THREE.Mesh(cloth.geometry, material);\r
+ //const mesh = new THREE.WireframeGeometry(cloth.geometry);\r
+ //const line = new THREE.LineSegments(mesh);\r
+ //line.material.depthTest = false;\r
+ //line.material.opacity = 0.25;\r
+ //line.material.transparent = true;\r
+ scene.add(mesh);\r
+\r
+ /**\r
+ * function called every frame\r
+ * @param {number} dt - time passed since last frame\r
+ */\r