diff options
| author | Ramtin Naraghi | 2021-01-24 12:29:57 +0100 |
|---|---|---|
| committer | Ramtin Naraghi | 2021-01-24 12:29:57 +0100 |
| commit | f0c64cdbb2ad2e1ae9a110e1d291db57c5b8d85d (patch) | |
| tree | 3e705a902a0b738bf59b4955774d754c23d6a0ad /Scripts/main.js | |
| parent | 1e3751f45e04a76ce2b11c67aa70e7c65efaad89 (diff) | |
| download | cloth_sim-f0c64cdbb2ad2e1ae9a110e1d291db57c5b8d85d.tar.gz cloth_sim-f0c64cdbb2ad2e1ae9a110e1d291db57c5b8d85d.zip | |
Distinguish between right and left mouse click for wind and dragging
Diffstat (limited to 'Scripts/main.js')
| -rw-r--r-- | Scripts/main.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Scripts/main.js b/Scripts/main.js index c269982..5f6595e 100644 --- a/Scripts/main.js +++ b/Scripts/main.js @@ -91,7 +91,7 @@ function init() { intersects = raycaster.intersectObject( mesh );
- if ( intersects.length > 0 ) {
+ if ( intersects.length > 0 && rightMousePressed) {
cloth.wind(intersects);
}
setTimeout(() => {
@@ -149,12 +149,15 @@ function init() { };
canvas.onmousedown = (evt) => {
- if(intersects.length > 0){
+ rightMousePressed = evt.button == 2;
+
+ if(intersects.length > 0 && evt.button == 0){
cloth.mousePress(intersects);
- }
+ }
}
canvas.onmouseup = (evt) => {
cloth.mouseRelease();
+ rightMousePressed = false;
}
}
\ No newline at end of file |
