microboard-temp 0.13.4 → 0.13.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4674,7 +4674,13 @@ var conf = {
4674
4674
  CARD_DIMENSIONS: { width: 250, height: 400 },
4675
4675
  DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
4676
4676
  MAX_CARD_SIZE: 500,
4677
- CONNECTOR_ITEM_OFFSET: 20
4677
+ CONNECTOR_ITEM_OFFSET: 20,
4678
+ GRAVITY_G: 80,
4679
+ GRAVITY_G_CENTER: 120,
4680
+ GRAVITY_DAMPING: 0.96,
4681
+ GRAVITY_RESTITUTION: 0.5,
4682
+ GRAVITY_REPULSION: 200,
4683
+ GRAVITY_MAX_DISTANCE: 3000
4678
4684
  };
4679
4685
  initDefaultI18N();
4680
4686
 
@@ -54348,13 +54354,8 @@ class GravityEngine {
54348
54354
  tickTimer = null;
54349
54355
  syncTimer = null;
54350
54356
  lastSyncedPositions = new Map;
54351
- G = 80;
54352
- G_CENTER = 120;
54353
- DAMPING = 0.92;
54354
- REPULSION = 800;
54355
54357
  TICK_MS = 33;
54356
54358
  SYNC_MS = 300;
54357
- MAX_DISTANCE = 3000;
54358
54359
  SOFTENING_SQ = 50 * 50;
54359
54360
  MIN_MOVE_PX = 0.1;
54360
54361
  constructor(board) {
@@ -54423,8 +54424,8 @@ class GravityEngine {
54423
54424
  const dcx = centerX - s1.cx;
54424
54425
  const dcy = centerY - s1.cy;
54425
54426
  const distCenter = Math.sqrt(dcx * dcx + dcy * dcy) + 1;
54426
- ax += this.G_CENTER * dcx / distCenter;
54427
- ay += this.G_CENTER * dcy / distCenter;
54427
+ ax += conf.GRAVITY_G_CENTER * dcx / distCenter;
54428
+ ay += conf.GRAVITY_G_CENTER * dcy / distCenter;
54428
54429
  for (let j = 0;j < snap.length; j++) {
54429
54430
  if (i === j)
54430
54431
  continue;
@@ -54432,7 +54433,7 @@ class GravityEngine {
54432
54433
  const dx = s2.cx - s1.cx;
54433
54434
  const dy = s2.cy - s1.cy;
54434
54435
  const dist = Math.sqrt(dx * dx + dy * dy) + 0.001;
54435
- if (dist > this.MAX_DISTANCE)
54436
+ if (dist > conf.GRAVITY_MAX_DISTANCE)
54436
54437
  continue;
54437
54438
  const overlapping = s1.right > s2.left && s2.right > s1.left && s1.bottom > s2.top && s2.bottom > s1.top;
54438
54439
  if (overlapping) {
@@ -54440,20 +54441,27 @@ class GravityEngine {
54440
54441
  const overlapY = Math.min(s1.bottom, s2.bottom) - Math.max(s1.top, s2.top);
54441
54442
  if (overlapX < overlapY) {
54442
54443
  const sign = s1.cx < s2.cx ? -1 : 1;
54443
- ax += sign * this.REPULSION * overlapX;
54444
+ if (sign * vel.vx < 0)
54445
+ vel.vx = -vel.vx * conf.GRAVITY_RESTITUTION;
54446
+ ax += sign * conf.GRAVITY_REPULSION * overlapX;
54444
54447
  } else {
54445
54448
  const sign = s1.cy < s2.cy ? -1 : 1;
54446
- ay += sign * this.REPULSION * overlapY;
54449
+ if (sign * vel.vy < 0)
54450
+ vel.vy = -vel.vy * conf.GRAVITY_RESTITUTION;
54451
+ ay += sign * conf.GRAVITY_REPULSION * overlapY;
54447
54452
  }
54448
54453
  } else {
54454
+ const touchDist = (s1.w + s2.w + s1.h + s2.h) * 0.25;
54455
+ if (dist < touchDist + 5)
54456
+ continue;
54449
54457
  const distSq = dx * dx + dy * dy;
54450
- const gravAcc = this.G * s2.mass / (distSq + this.SOFTENING_SQ);
54458
+ const gravAcc = conf.GRAVITY_G * s2.mass / (distSq + this.SOFTENING_SQ);
54451
54459
  ax += gravAcc * dx / dist;
54452
54460
  ay += gravAcc * dy / dist;
54453
54461
  }
54454
54462
  }
54455
- vel.vx = (vel.vx + ax * dt) * this.DAMPING;
54456
- vel.vy = (vel.vy + ay * dt) * this.DAMPING;
54463
+ vel.vx = (vel.vx + ax * dt) * conf.GRAVITY_DAMPING;
54464
+ vel.vy = (vel.vy + ay * dt) * conf.GRAVITY_DAMPING;
54457
54465
  const moveX = vel.vx * dt;
54458
54466
  const moveY = vel.vy * dt;
54459
54467
  if (Math.abs(moveX) >= this.MIN_MOVE_PX || Math.abs(moveY) >= this.MIN_MOVE_PX) {
package/dist/cjs/index.js CHANGED
@@ -4674,7 +4674,13 @@ var conf = {
4674
4674
  CARD_DIMENSIONS: { width: 250, height: 400 },
4675
4675
  DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
4676
4676
  MAX_CARD_SIZE: 500,
4677
- CONNECTOR_ITEM_OFFSET: 20
4677
+ CONNECTOR_ITEM_OFFSET: 20,
4678
+ GRAVITY_G: 80,
4679
+ GRAVITY_G_CENTER: 120,
4680
+ GRAVITY_DAMPING: 0.96,
4681
+ GRAVITY_RESTITUTION: 0.5,
4682
+ GRAVITY_REPULSION: 200,
4683
+ GRAVITY_MAX_DISTANCE: 3000
4678
4684
  };
4679
4685
  initDefaultI18N();
4680
4686
 
@@ -54348,13 +54354,8 @@ class GravityEngine {
54348
54354
  tickTimer = null;
54349
54355
  syncTimer = null;
54350
54356
  lastSyncedPositions = new Map;
54351
- G = 80;
54352
- G_CENTER = 120;
54353
- DAMPING = 0.92;
54354
- REPULSION = 800;
54355
54357
  TICK_MS = 33;
54356
54358
  SYNC_MS = 300;
54357
- MAX_DISTANCE = 3000;
54358
54359
  SOFTENING_SQ = 50 * 50;
54359
54360
  MIN_MOVE_PX = 0.1;
54360
54361
  constructor(board) {
@@ -54423,8 +54424,8 @@ class GravityEngine {
54423
54424
  const dcx = centerX - s1.cx;
54424
54425
  const dcy = centerY - s1.cy;
54425
54426
  const distCenter = Math.sqrt(dcx * dcx + dcy * dcy) + 1;
54426
- ax += this.G_CENTER * dcx / distCenter;
54427
- ay += this.G_CENTER * dcy / distCenter;
54427
+ ax += conf.GRAVITY_G_CENTER * dcx / distCenter;
54428
+ ay += conf.GRAVITY_G_CENTER * dcy / distCenter;
54428
54429
  for (let j = 0;j < snap.length; j++) {
54429
54430
  if (i === j)
54430
54431
  continue;
@@ -54432,7 +54433,7 @@ class GravityEngine {
54432
54433
  const dx = s2.cx - s1.cx;
54433
54434
  const dy = s2.cy - s1.cy;
54434
54435
  const dist = Math.sqrt(dx * dx + dy * dy) + 0.001;
54435
- if (dist > this.MAX_DISTANCE)
54436
+ if (dist > conf.GRAVITY_MAX_DISTANCE)
54436
54437
  continue;
54437
54438
  const overlapping = s1.right > s2.left && s2.right > s1.left && s1.bottom > s2.top && s2.bottom > s1.top;
54438
54439
  if (overlapping) {
@@ -54440,20 +54441,27 @@ class GravityEngine {
54440
54441
  const overlapY = Math.min(s1.bottom, s2.bottom) - Math.max(s1.top, s2.top);
54441
54442
  if (overlapX < overlapY) {
54442
54443
  const sign = s1.cx < s2.cx ? -1 : 1;
54443
- ax += sign * this.REPULSION * overlapX;
54444
+ if (sign * vel.vx < 0)
54445
+ vel.vx = -vel.vx * conf.GRAVITY_RESTITUTION;
54446
+ ax += sign * conf.GRAVITY_REPULSION * overlapX;
54444
54447
  } else {
54445
54448
  const sign = s1.cy < s2.cy ? -1 : 1;
54446
- ay += sign * this.REPULSION * overlapY;
54449
+ if (sign * vel.vy < 0)
54450
+ vel.vy = -vel.vy * conf.GRAVITY_RESTITUTION;
54451
+ ay += sign * conf.GRAVITY_REPULSION * overlapY;
54447
54452
  }
54448
54453
  } else {
54454
+ const touchDist = (s1.w + s2.w + s1.h + s2.h) * 0.25;
54455
+ if (dist < touchDist + 5)
54456
+ continue;
54449
54457
  const distSq = dx * dx + dy * dy;
54450
- const gravAcc = this.G * s2.mass / (distSq + this.SOFTENING_SQ);
54458
+ const gravAcc = conf.GRAVITY_G * s2.mass / (distSq + this.SOFTENING_SQ);
54451
54459
  ax += gravAcc * dx / dist;
54452
54460
  ay += gravAcc * dy / dist;
54453
54461
  }
54454
54462
  }
54455
- vel.vx = (vel.vx + ax * dt) * this.DAMPING;
54456
- vel.vy = (vel.vy + ay * dt) * this.DAMPING;
54463
+ vel.vx = (vel.vx + ax * dt) * conf.GRAVITY_DAMPING;
54464
+ vel.vy = (vel.vy + ay * dt) * conf.GRAVITY_DAMPING;
54457
54465
  const moveX = vel.vx * dt;
54458
54466
  const moveY = vel.vy * dt;
54459
54467
  if (Math.abs(moveX) >= this.MIN_MOVE_PX || Math.abs(moveY) >= this.MIN_MOVE_PX) {
package/dist/cjs/node.js CHANGED
@@ -5711,7 +5711,13 @@ var conf = {
5711
5711
  CARD_DIMENSIONS: { width: 250, height: 400 },
5712
5712
  DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
5713
5713
  MAX_CARD_SIZE: 500,
5714
- CONNECTOR_ITEM_OFFSET: 20
5714
+ CONNECTOR_ITEM_OFFSET: 20,
5715
+ GRAVITY_G: 80,
5716
+ GRAVITY_G_CENTER: 120,
5717
+ GRAVITY_DAMPING: 0.96,
5718
+ GRAVITY_RESTITUTION: 0.5,
5719
+ GRAVITY_REPULSION: 200,
5720
+ GRAVITY_MAX_DISTANCE: 3000
5715
5721
  };
5716
5722
  initDefaultI18N();
5717
5723
 
@@ -56821,13 +56827,8 @@ class GravityEngine {
56821
56827
  tickTimer = null;
56822
56828
  syncTimer = null;
56823
56829
  lastSyncedPositions = new Map;
56824
- G = 80;
56825
- G_CENTER = 120;
56826
- DAMPING = 0.92;
56827
- REPULSION = 800;
56828
56830
  TICK_MS = 33;
56829
56831
  SYNC_MS = 300;
56830
- MAX_DISTANCE = 3000;
56831
56832
  SOFTENING_SQ = 50 * 50;
56832
56833
  MIN_MOVE_PX = 0.1;
56833
56834
  constructor(board) {
@@ -56896,8 +56897,8 @@ class GravityEngine {
56896
56897
  const dcx = centerX - s1.cx;
56897
56898
  const dcy = centerY - s1.cy;
56898
56899
  const distCenter = Math.sqrt(dcx * dcx + dcy * dcy) + 1;
56899
- ax += this.G_CENTER * dcx / distCenter;
56900
- ay += this.G_CENTER * dcy / distCenter;
56900
+ ax += conf.GRAVITY_G_CENTER * dcx / distCenter;
56901
+ ay += conf.GRAVITY_G_CENTER * dcy / distCenter;
56901
56902
  for (let j = 0;j < snap.length; j++) {
56902
56903
  if (i === j)
56903
56904
  continue;
@@ -56905,7 +56906,7 @@ class GravityEngine {
56905
56906
  const dx = s2.cx - s1.cx;
56906
56907
  const dy = s2.cy - s1.cy;
56907
56908
  const dist = Math.sqrt(dx * dx + dy * dy) + 0.001;
56908
- if (dist > this.MAX_DISTANCE)
56909
+ if (dist > conf.GRAVITY_MAX_DISTANCE)
56909
56910
  continue;
56910
56911
  const overlapping = s1.right > s2.left && s2.right > s1.left && s1.bottom > s2.top && s2.bottom > s1.top;
56911
56912
  if (overlapping) {
@@ -56913,20 +56914,27 @@ class GravityEngine {
56913
56914
  const overlapY = Math.min(s1.bottom, s2.bottom) - Math.max(s1.top, s2.top);
56914
56915
  if (overlapX < overlapY) {
56915
56916
  const sign = s1.cx < s2.cx ? -1 : 1;
56916
- ax += sign * this.REPULSION * overlapX;
56917
+ if (sign * vel.vx < 0)
56918
+ vel.vx = -vel.vx * conf.GRAVITY_RESTITUTION;
56919
+ ax += sign * conf.GRAVITY_REPULSION * overlapX;
56917
56920
  } else {
56918
56921
  const sign = s1.cy < s2.cy ? -1 : 1;
56919
- ay += sign * this.REPULSION * overlapY;
56922
+ if (sign * vel.vy < 0)
56923
+ vel.vy = -vel.vy * conf.GRAVITY_RESTITUTION;
56924
+ ay += sign * conf.GRAVITY_REPULSION * overlapY;
56920
56925
  }
56921
56926
  } else {
56927
+ const touchDist = (s1.w + s2.w + s1.h + s2.h) * 0.25;
56928
+ if (dist < touchDist + 5)
56929
+ continue;
56922
56930
  const distSq = dx * dx + dy * dy;
56923
- const gravAcc = this.G * s2.mass / (distSq + this.SOFTENING_SQ);
56931
+ const gravAcc = conf.GRAVITY_G * s2.mass / (distSq + this.SOFTENING_SQ);
56924
56932
  ax += gravAcc * dx / dist;
56925
56933
  ay += gravAcc * dy / dist;
56926
56934
  }
56927
56935
  }
56928
- vel.vx = (vel.vx + ax * dt) * this.DAMPING;
56929
- vel.vy = (vel.vy + ay * dt) * this.DAMPING;
56936
+ vel.vx = (vel.vx + ax * dt) * conf.GRAVITY_DAMPING;
56937
+ vel.vy = (vel.vy + ay * dt) * conf.GRAVITY_DAMPING;
56930
56938
  const moveX = vel.vx * dt;
56931
56939
  const moveY = vel.vy * dt;
56932
56940
  if (Math.abs(moveX) >= this.MIN_MOVE_PX || Math.abs(moveY) >= this.MIN_MOVE_PX) {
@@ -4494,7 +4494,13 @@ var conf = {
4494
4494
  CARD_DIMENSIONS: { width: 250, height: 400 },
4495
4495
  DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
4496
4496
  MAX_CARD_SIZE: 500,
4497
- CONNECTOR_ITEM_OFFSET: 20
4497
+ CONNECTOR_ITEM_OFFSET: 20,
4498
+ GRAVITY_G: 80,
4499
+ GRAVITY_G_CENTER: 120,
4500
+ GRAVITY_DAMPING: 0.96,
4501
+ GRAVITY_RESTITUTION: 0.5,
4502
+ GRAVITY_REPULSION: 200,
4503
+ GRAVITY_MAX_DISTANCE: 3000
4498
4504
  };
4499
4505
  initDefaultI18N();
4500
4506
 
@@ -54177,13 +54183,8 @@ class GravityEngine {
54177
54183
  tickTimer = null;
54178
54184
  syncTimer = null;
54179
54185
  lastSyncedPositions = new Map;
54180
- G = 80;
54181
- G_CENTER = 120;
54182
- DAMPING = 0.92;
54183
- REPULSION = 800;
54184
54186
  TICK_MS = 33;
54185
54187
  SYNC_MS = 300;
54186
- MAX_DISTANCE = 3000;
54187
54188
  SOFTENING_SQ = 50 * 50;
54188
54189
  MIN_MOVE_PX = 0.1;
54189
54190
  constructor(board) {
@@ -54252,8 +54253,8 @@ class GravityEngine {
54252
54253
  const dcx = centerX - s1.cx;
54253
54254
  const dcy = centerY - s1.cy;
54254
54255
  const distCenter = Math.sqrt(dcx * dcx + dcy * dcy) + 1;
54255
- ax += this.G_CENTER * dcx / distCenter;
54256
- ay += this.G_CENTER * dcy / distCenter;
54256
+ ax += conf.GRAVITY_G_CENTER * dcx / distCenter;
54257
+ ay += conf.GRAVITY_G_CENTER * dcy / distCenter;
54257
54258
  for (let j = 0;j < snap.length; j++) {
54258
54259
  if (i === j)
54259
54260
  continue;
@@ -54261,7 +54262,7 @@ class GravityEngine {
54261
54262
  const dx = s2.cx - s1.cx;
54262
54263
  const dy = s2.cy - s1.cy;
54263
54264
  const dist = Math.sqrt(dx * dx + dy * dy) + 0.001;
54264
- if (dist > this.MAX_DISTANCE)
54265
+ if (dist > conf.GRAVITY_MAX_DISTANCE)
54265
54266
  continue;
54266
54267
  const overlapping = s1.right > s2.left && s2.right > s1.left && s1.bottom > s2.top && s2.bottom > s1.top;
54267
54268
  if (overlapping) {
@@ -54269,20 +54270,27 @@ class GravityEngine {
54269
54270
  const overlapY = Math.min(s1.bottom, s2.bottom) - Math.max(s1.top, s2.top);
54270
54271
  if (overlapX < overlapY) {
54271
54272
  const sign = s1.cx < s2.cx ? -1 : 1;
54272
- ax += sign * this.REPULSION * overlapX;
54273
+ if (sign * vel.vx < 0)
54274
+ vel.vx = -vel.vx * conf.GRAVITY_RESTITUTION;
54275
+ ax += sign * conf.GRAVITY_REPULSION * overlapX;
54273
54276
  } else {
54274
54277
  const sign = s1.cy < s2.cy ? -1 : 1;
54275
- ay += sign * this.REPULSION * overlapY;
54278
+ if (sign * vel.vy < 0)
54279
+ vel.vy = -vel.vy * conf.GRAVITY_RESTITUTION;
54280
+ ay += sign * conf.GRAVITY_REPULSION * overlapY;
54276
54281
  }
54277
54282
  } else {
54283
+ const touchDist = (s1.w + s2.w + s1.h + s2.h) * 0.25;
54284
+ if (dist < touchDist + 5)
54285
+ continue;
54278
54286
  const distSq = dx * dx + dy * dy;
54279
- const gravAcc = this.G * s2.mass / (distSq + this.SOFTENING_SQ);
54287
+ const gravAcc = conf.GRAVITY_G * s2.mass / (distSq + this.SOFTENING_SQ);
54280
54288
  ax += gravAcc * dx / dist;
54281
54289
  ay += gravAcc * dy / dist;
54282
54290
  }
54283
54291
  }
54284
- vel.vx = (vel.vx + ax * dt) * this.DAMPING;
54285
- vel.vy = (vel.vy + ay * dt) * this.DAMPING;
54292
+ vel.vx = (vel.vx + ax * dt) * conf.GRAVITY_DAMPING;
54293
+ vel.vy = (vel.vy + ay * dt) * conf.GRAVITY_DAMPING;
54286
54294
  const moveX = vel.vx * dt;
54287
54295
  const moveY = vel.vy * dt;
54288
54296
  if (Math.abs(moveX) >= this.MIN_MOVE_PX || Math.abs(moveY) >= this.MIN_MOVE_PX) {
package/dist/esm/index.js CHANGED
@@ -4487,7 +4487,13 @@ var conf = {
4487
4487
  CARD_DIMENSIONS: { width: 250, height: 400 },
4488
4488
  DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
4489
4489
  MAX_CARD_SIZE: 500,
4490
- CONNECTOR_ITEM_OFFSET: 20
4490
+ CONNECTOR_ITEM_OFFSET: 20,
4491
+ GRAVITY_G: 80,
4492
+ GRAVITY_G_CENTER: 120,
4493
+ GRAVITY_DAMPING: 0.96,
4494
+ GRAVITY_RESTITUTION: 0.5,
4495
+ GRAVITY_REPULSION: 200,
4496
+ GRAVITY_MAX_DISTANCE: 3000
4491
4497
  };
4492
4498
  initDefaultI18N();
4493
4499
 
@@ -54170,13 +54176,8 @@ class GravityEngine {
54170
54176
  tickTimer = null;
54171
54177
  syncTimer = null;
54172
54178
  lastSyncedPositions = new Map;
54173
- G = 80;
54174
- G_CENTER = 120;
54175
- DAMPING = 0.92;
54176
- REPULSION = 800;
54177
54179
  TICK_MS = 33;
54178
54180
  SYNC_MS = 300;
54179
- MAX_DISTANCE = 3000;
54180
54181
  SOFTENING_SQ = 50 * 50;
54181
54182
  MIN_MOVE_PX = 0.1;
54182
54183
  constructor(board) {
@@ -54245,8 +54246,8 @@ class GravityEngine {
54245
54246
  const dcx = centerX - s1.cx;
54246
54247
  const dcy = centerY - s1.cy;
54247
54248
  const distCenter = Math.sqrt(dcx * dcx + dcy * dcy) + 1;
54248
- ax += this.G_CENTER * dcx / distCenter;
54249
- ay += this.G_CENTER * dcy / distCenter;
54249
+ ax += conf.GRAVITY_G_CENTER * dcx / distCenter;
54250
+ ay += conf.GRAVITY_G_CENTER * dcy / distCenter;
54250
54251
  for (let j = 0;j < snap.length; j++) {
54251
54252
  if (i === j)
54252
54253
  continue;
@@ -54254,7 +54255,7 @@ class GravityEngine {
54254
54255
  const dx = s2.cx - s1.cx;
54255
54256
  const dy = s2.cy - s1.cy;
54256
54257
  const dist = Math.sqrt(dx * dx + dy * dy) + 0.001;
54257
- if (dist > this.MAX_DISTANCE)
54258
+ if (dist > conf.GRAVITY_MAX_DISTANCE)
54258
54259
  continue;
54259
54260
  const overlapping = s1.right > s2.left && s2.right > s1.left && s1.bottom > s2.top && s2.bottom > s1.top;
54260
54261
  if (overlapping) {
@@ -54262,20 +54263,27 @@ class GravityEngine {
54262
54263
  const overlapY = Math.min(s1.bottom, s2.bottom) - Math.max(s1.top, s2.top);
54263
54264
  if (overlapX < overlapY) {
54264
54265
  const sign = s1.cx < s2.cx ? -1 : 1;
54265
- ax += sign * this.REPULSION * overlapX;
54266
+ if (sign * vel.vx < 0)
54267
+ vel.vx = -vel.vx * conf.GRAVITY_RESTITUTION;
54268
+ ax += sign * conf.GRAVITY_REPULSION * overlapX;
54266
54269
  } else {
54267
54270
  const sign = s1.cy < s2.cy ? -1 : 1;
54268
- ay += sign * this.REPULSION * overlapY;
54271
+ if (sign * vel.vy < 0)
54272
+ vel.vy = -vel.vy * conf.GRAVITY_RESTITUTION;
54273
+ ay += sign * conf.GRAVITY_REPULSION * overlapY;
54269
54274
  }
54270
54275
  } else {
54276
+ const touchDist = (s1.w + s2.w + s1.h + s2.h) * 0.25;
54277
+ if (dist < touchDist + 5)
54278
+ continue;
54271
54279
  const distSq = dx * dx + dy * dy;
54272
- const gravAcc = this.G * s2.mass / (distSq + this.SOFTENING_SQ);
54280
+ const gravAcc = conf.GRAVITY_G * s2.mass / (distSq + this.SOFTENING_SQ);
54273
54281
  ax += gravAcc * dx / dist;
54274
54282
  ay += gravAcc * dy / dist;
54275
54283
  }
54276
54284
  }
54277
- vel.vx = (vel.vx + ax * dt) * this.DAMPING;
54278
- vel.vy = (vel.vy + ay * dt) * this.DAMPING;
54285
+ vel.vx = (vel.vx + ax * dt) * conf.GRAVITY_DAMPING;
54286
+ vel.vy = (vel.vy + ay * dt) * conf.GRAVITY_DAMPING;
54279
54287
  const moveX = vel.vx * dt;
54280
54288
  const moveY = vel.vy * dt;
54281
54289
  if (Math.abs(moveX) >= this.MIN_MOVE_PX || Math.abs(moveY) >= this.MIN_MOVE_PX) {
package/dist/esm/node.js CHANGED
@@ -5271,7 +5271,13 @@ var conf = {
5271
5271
  CARD_DIMENSIONS: { width: 250, height: 400 },
5272
5272
  DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
5273
5273
  MAX_CARD_SIZE: 500,
5274
- CONNECTOR_ITEM_OFFSET: 20
5274
+ CONNECTOR_ITEM_OFFSET: 20,
5275
+ GRAVITY_G: 80,
5276
+ GRAVITY_G_CENTER: 120,
5277
+ GRAVITY_DAMPING: 0.96,
5278
+ GRAVITY_RESTITUTION: 0.5,
5279
+ GRAVITY_REPULSION: 200,
5280
+ GRAVITY_MAX_DISTANCE: 3000
5275
5281
  };
5276
5282
  initDefaultI18N();
5277
5283
 
@@ -56638,13 +56644,8 @@ class GravityEngine {
56638
56644
  tickTimer = null;
56639
56645
  syncTimer = null;
56640
56646
  lastSyncedPositions = new Map;
56641
- G = 80;
56642
- G_CENTER = 120;
56643
- DAMPING = 0.92;
56644
- REPULSION = 800;
56645
56647
  TICK_MS = 33;
56646
56648
  SYNC_MS = 300;
56647
- MAX_DISTANCE = 3000;
56648
56649
  SOFTENING_SQ = 50 * 50;
56649
56650
  MIN_MOVE_PX = 0.1;
56650
56651
  constructor(board) {
@@ -56713,8 +56714,8 @@ class GravityEngine {
56713
56714
  const dcx = centerX - s1.cx;
56714
56715
  const dcy = centerY - s1.cy;
56715
56716
  const distCenter = Math.sqrt(dcx * dcx + dcy * dcy) + 1;
56716
- ax += this.G_CENTER * dcx / distCenter;
56717
- ay += this.G_CENTER * dcy / distCenter;
56717
+ ax += conf.GRAVITY_G_CENTER * dcx / distCenter;
56718
+ ay += conf.GRAVITY_G_CENTER * dcy / distCenter;
56718
56719
  for (let j = 0;j < snap.length; j++) {
56719
56720
  if (i === j)
56720
56721
  continue;
@@ -56722,7 +56723,7 @@ class GravityEngine {
56722
56723
  const dx = s2.cx - s1.cx;
56723
56724
  const dy = s2.cy - s1.cy;
56724
56725
  const dist = Math.sqrt(dx * dx + dy * dy) + 0.001;
56725
- if (dist > this.MAX_DISTANCE)
56726
+ if (dist > conf.GRAVITY_MAX_DISTANCE)
56726
56727
  continue;
56727
56728
  const overlapping = s1.right > s2.left && s2.right > s1.left && s1.bottom > s2.top && s2.bottom > s1.top;
56728
56729
  if (overlapping) {
@@ -56730,20 +56731,27 @@ class GravityEngine {
56730
56731
  const overlapY = Math.min(s1.bottom, s2.bottom) - Math.max(s1.top, s2.top);
56731
56732
  if (overlapX < overlapY) {
56732
56733
  const sign = s1.cx < s2.cx ? -1 : 1;
56733
- ax += sign * this.REPULSION * overlapX;
56734
+ if (sign * vel.vx < 0)
56735
+ vel.vx = -vel.vx * conf.GRAVITY_RESTITUTION;
56736
+ ax += sign * conf.GRAVITY_REPULSION * overlapX;
56734
56737
  } else {
56735
56738
  const sign = s1.cy < s2.cy ? -1 : 1;
56736
- ay += sign * this.REPULSION * overlapY;
56739
+ if (sign * vel.vy < 0)
56740
+ vel.vy = -vel.vy * conf.GRAVITY_RESTITUTION;
56741
+ ay += sign * conf.GRAVITY_REPULSION * overlapY;
56737
56742
  }
56738
56743
  } else {
56744
+ const touchDist = (s1.w + s2.w + s1.h + s2.h) * 0.25;
56745
+ if (dist < touchDist + 5)
56746
+ continue;
56739
56747
  const distSq = dx * dx + dy * dy;
56740
- const gravAcc = this.G * s2.mass / (distSq + this.SOFTENING_SQ);
56748
+ const gravAcc = conf.GRAVITY_G * s2.mass / (distSq + this.SOFTENING_SQ);
56741
56749
  ax += gravAcc * dx / dist;
56742
56750
  ay += gravAcc * dy / dist;
56743
56751
  }
56744
56752
  }
56745
- vel.vx = (vel.vx + ax * dt) * this.DAMPING;
56746
- vel.vy = (vel.vy + ay * dt) * this.DAMPING;
56753
+ vel.vx = (vel.vx + ax * dt) * conf.GRAVITY_DAMPING;
56754
+ vel.vy = (vel.vy + ay * dt) * conf.GRAVITY_DAMPING;
56747
56755
  const moveX = vel.vx * dt;
56748
56756
  const moveY = vel.vy * dt;
56749
56757
  if (Math.abs(moveX) >= this.MIN_MOVE_PX || Math.abs(moveY) >= this.MIN_MOVE_PX) {
@@ -5,13 +5,8 @@ export declare class GravityEngine {
5
5
  private tickTimer;
6
6
  private syncTimer;
7
7
  private lastSyncedPositions;
8
- readonly G = 80;
9
- readonly G_CENTER = 120;
10
- readonly DAMPING = 0.92;
11
- readonly REPULSION = 800;
12
8
  readonly TICK_MS = 33;
13
9
  readonly SYNC_MS = 300;
14
- readonly MAX_DISTANCE = 3000;
15
10
  readonly SOFTENING_SQ: number;
16
11
  readonly MIN_MOVE_PX = 0.1;
17
12
  constructor(board: Board);
@@ -247,6 +247,12 @@ export declare const conf: {
247
247
  };
248
248
  MAX_CARD_SIZE: number;
249
249
  CONNECTOR_ITEM_OFFSET: number;
250
+ GRAVITY_G: number;
251
+ GRAVITY_G_CENTER: number;
252
+ GRAVITY_DAMPING: number;
253
+ GRAVITY_RESTITUTION: number;
254
+ GRAVITY_REPULSION: number;
255
+ GRAVITY_MAX_DISTANCE: number;
250
256
  };
251
257
  export type Settings = typeof conf;
252
258
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.13.4",
3
+ "version": "0.13.6",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",