@fils/phy-three 0.0.2 → 0.0.3

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.
@@ -55,12 +55,28 @@ export class PhyThreeHelper extends Object3D {
55
55
  dummy.position.copy(p.position);
56
56
  dummy.updateMatrix();
57
57
  this.particles.setMatrixAt(i, dummy.matrix);
58
+ this.particles.setColorAt(i, p.locked ? color1 : color2);
58
59
  }
59
60
  this.particles.instanceMatrix.needsUpdate = true;
61
+ this.particles.instanceColor.needsUpdate = true;
60
62
  const pos = this.springs.geometry.attributes.position;
63
+ const color = this.springs.geometry.attributes.color;
61
64
  let k = 0;
65
+ function updateSpringColor(s) {
66
+ const i1 = k;
67
+ const i2 = k + 1;
68
+ const c1 = s.a.locked ? color1 : color2;
69
+ const c2 = s.b.locked ? color1 : color2;
70
+ color[i1 * 3] = c1.r;
71
+ color[i1 * 3 + 1] = c1.g;
72
+ color[i1 * 3 + 2] = c1.b;
73
+ color[i2 * 3] = c2.r;
74
+ color[i2 * 3 + 1] = c2.g;
75
+ color[i2 * 3 + 2] = c2.b;
76
+ }
62
77
  for (let i = 0, len = this.physics.springs.length; i < len; i++) {
63
78
  const s = this.physics.springs[i];
79
+ updateSpringColor(s);
64
80
  pos.array[k * 3] = s.a.position.x;
65
81
  pos.array[k * 3 + 1] = s.a.position.y;
66
82
  pos.array[k * 3 + 2] = s.a.position.z;
@@ -71,5 +87,6 @@ export class PhyThreeHelper extends Object3D {
71
87
  k++;
72
88
  }
73
89
  pos.needsUpdate = true;
90
+ color.needsUpdate = true;
74
91
  }
75
92
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fils/phy-three",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "ThreeJS utils for @phy/three",
5
5
  "main": "lib/main.js",
6
6
  "repository": "git@github.com:fil-studio/fils.git",
@@ -8,7 +8,7 @@
8
8
  "author": "Fil Studio <hello@fil.studio>",
9
9
  "license": "Apache-2.0",
10
10
  "scripts": {
11
- "prepare": "yarn build",
11
+ "prepublishOnly": "yarn build",
12
12
  "build": "tsc"
13
13
  },
14
14
  "files": [