DakshBeniwal111 commited on
Commit
1435d27
Β·
verified Β·
1 Parent(s): 085405c

Update threejs_component.py

Browse files
Files changed (1) hide show
  1. threejs_component.py +11 -11
threejs_component.py CHANGED
@@ -142,36 +142,36 @@ for (let l=0; l<N_LAYERS; l++) {{
142
  // ── Edges β€” also added to pivot so they rotate with neurons ───────────────
143
  const bdhEdgeMats = [], tfEdgeMats = [];
144
 
145
- function addEdges(meshes, color, maxEdgesPerLayer, edgeMatsArr) {
146
  const pts = [];
147
- for (let l=0; l<N_LAYERS-1; l++) {
148
  const base = l*N_NEURONS;
149
  let count = 0;
150
  // Connect neurons between current layer (l) and next layer (l+1)
151
- for (let ni=0; ni<N_NEURONS; ni++) {
152
  const src = meshes[base+ni];
153
  if (src.userData.silent) continue;
154
 
155
- for (let nj=0; nj<N_NEURONS; nj+=2) { // nj+=2 spreads edges out visually
156
  const dst = meshes[base+N_NEURONS+nj];
157
  if (dst.userData.silent) continue;
158
 
159
- if (count < maxEdgesPerLayer) {
160
  pts.push(src.position.x, src.position.y, src.position.z,
161
  dst.position.x, dst.position.y, dst.position.z);
162
  count++;
163
- }
164
- }
165
- }
166
- }
167
  const geo = new THREE.BufferGeometry();
168
  geo.setAttribute("position", new THREE.Float32BufferAttribute(pts, 3));
169
- const mat = new THREE.LineBasicMaterial({color, transparent:true, opacity:0.18});
170
  const lines = new THREE.LineSegments(geo, mat);
171
  pivot.add(lines);
172
  edgeMatsArr.push(mat);
173
  return mat;
174
- }
175
 
176
  // Update the function calls right below it to pass edges PER LAYER:
177
  addEdges(bdhMeshes, 0xf97316, 40, bdhEdgeMats); // 40 lines max between each BDH layer
 
142
  // ── Edges β€” also added to pivot so they rotate with neurons ───────────────
143
  const bdhEdgeMats = [], tfEdgeMats = [];
144
 
145
+ function addEdges(meshes, color, maxEdgesPerLayer, edgeMatsArr) {{
146
  const pts = [];
147
+ for (let l=0; l<N_LAYERS-1; l++) {{
148
  const base = l*N_NEURONS;
149
  let count = 0;
150
  // Connect neurons between current layer (l) and next layer (l+1)
151
+ for (let ni=0; ni<N_NEURONS; ni++) {{
152
  const src = meshes[base+ni];
153
  if (src.userData.silent) continue;
154
 
155
+ for (let nj=0; nj<N_NEURONS; nj+=2) {{ // nj+=2 spreads edges out visually
156
  const dst = meshes[base+N_NEURONS+nj];
157
  if (dst.userData.silent) continue;
158
 
159
+ if (count < maxEdgesPerLayer) {{
160
  pts.push(src.position.x, src.position.y, src.position.z,
161
  dst.position.x, dst.position.y, dst.position.z);
162
  count++;
163
+ }}
164
+ }}
165
+ }}
166
+ }}
167
  const geo = new THREE.BufferGeometry();
168
  geo.setAttribute("position", new THREE.Float32BufferAttribute(pts, 3));
169
+ const mat = new THREE.LineBasicMaterial({{color, transparent:true, opacity:0.18}});
170
  const lines = new THREE.LineSegments(geo, mat);
171
  pivot.add(lines);
172
  edgeMatsArr.push(mat);
173
  return mat;
174
+ }}
175
 
176
  // Update the function calls right below it to pass edges PER LAYER:
177
  addEdges(bdhMeshes, 0xf97316, 40, bdhEdgeMats); // 40 lines max between each BDH layer