X-Git-Url: https://gitweb.ps.run/cloth_sim/blobdiff_plain/323d38f395da1cae25ba629d3365c37c30f53fdf..56f6324db4aa55946a6b5ef7de3e1df8b0e22bca:/Scripts/main.js diff --git a/Scripts/main.js b/Scripts/main.js index d54aa9f..7611601 100644 --- a/Scripts/main.js +++ b/Scripts/main.js @@ -75,7 +75,7 @@ function init() { const canvasSpace = 200; /** Constant Frame Time */ - const frameTime = 1000.0 / 60.0; + const frameTime = 1000.0 / 200.0; /** Setup scene */ let [scene, camera, renderer] = setup_scene(canvasSpace); @@ -83,7 +83,7 @@ function init() { //const loader = new THREE.TextureLoader(); //Red color: 0xC70039 - const cloth = new Cloth(1, 0.5, 20, 10); + const cloth = new Cloth(1, 0.5, 40, 20); const clothGeometry = cloth.generateGeometry(); //const clothMaterial = new THREE.MeshStandardMaterial({ map: loader.load('Textures/DeutschlandFlagge.jpg'), color: 0xffffff, side: THREE.DoubleSide, flatShading: false}); const clothMaterial = new THREE.MeshStandardMaterial({ color: 0xC70039, side: THREE.DoubleSide, flatShading: false }); @@ -98,7 +98,9 @@ function init() { * @param {number} dt - time passed since last frame in ms */ function animate(dt) { - // simulate cloth + cloth.simulate(dt / 1000); + + cloth.updateGeometry(clothGeometry); raycaster.setFromCamera( new THREE.Vector2((mousePos.x / w) * 2 - 1, ((h - mousePos.y) / h) * 2 - 1), camera );