diff options
| author | Ramtin Naraghi | 2021-01-18 13:10:26 +0100 |
|---|---|---|
| committer | Ramtin Naraghi | 2021-01-18 13:10:26 +0100 |
| commit | e05a5c0a7aa891179af219eff0df34647acc8eb3 (patch) | |
| tree | a519c7871d0b6ce7356c52d1eba7233b1ae1e508 /Scripts/main.js | |
| parent | fcfb3d929c2fefdfdcb6cb9351bcdd0d2d14f9f2 (diff) | |
| download | cloth_sim-e05a5c0a7aa891179af219eff0df34647acc8eb3.tar.gz cloth_sim-e05a5c0a7aa891179af219eff0df34647acc8eb3.zip | |
WIP Cloth Simulation
Diffstat (limited to 'Scripts/main.js')
| -rw-r--r-- | Scripts/main.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Scripts/main.js b/Scripts/main.js index a0387ac..5ed1866 100644 --- a/Scripts/main.js +++ b/Scripts/main.js @@ -57,7 +57,8 @@ document.body.onload = init; function init() {
let mousePos = new Point();
-
+ let previousClothSimulation;
+
/**
* Space left empty under canvas
* for UI elements
@@ -74,6 +75,11 @@ function init() { const material = new THREE.MeshBasicMaterial({ color: 0x0000ff });
const mesh = new THREE.Mesh(cloth.geometry, material);
+ //const mesh = new THREE.WireframeGeometry(cloth.geometry);
+ //const line = new THREE.LineSegments(mesh);
+ //line.material.depthTest = false;
+ //line.material.opacity = 0.25;
+ //line.material.transparent = true;
scene.add(mesh);
/**
@@ -81,7 +87,12 @@ function init() { * @param {number} dt - time passed since last frame
*/
function animate(dt) {
- requestAnimationFrame(animate);
+
+ cloth.simulate(dt);
+
+ setTimeout(() => {
+ animate(2000);
+ }, 2000);
renderer.render(scene, camera);
}
|
