From 79bcaf1ac3d8bc90b697c444ff5dfb694acb6962 Mon Sep 17 00:00:00 2001 From: Patrick Schönberger Date: Fri, 22 Jan 2021 16:57:38 +0100 Subject: fix spring force calculation --- Scripts/cloth.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Scripts/cloth.js') diff --git a/Scripts/cloth.js b/Scripts/cloth.js index 266af16..e39b95b 100644 --- a/Scripts/cloth.js +++ b/Scripts/cloth.js @@ -112,6 +112,9 @@ export class Cloth { let vertices = []; let faces = []; + this.numPointsWidth = numPointsWidth; + this.numPointsHeight = numPointsHeight; + /** * distance between two vertices horizontally/vertically * divide by the number of points minus one @@ -403,8 +406,8 @@ getAcceleration(vertexIndex, dt) { // Get the bounding springs and add them to the needed springs // TODO: optimize - const numPointsX = 10; - const numPointsY = 10; + const numPointsX = this.numPointsWidth; + const numPointsY = this.numPointsHeight; const numFacesX = numPointsX - 1; const numFacesY = numPointsY - 1; -- cgit v1.2.3