| 2799 | } |
| 2800 | |
| 2801 | applyNodeColors(layer, values, scale, layerIndex) { |
| 2802 | const { mesh, type } = layer; |
| 2803 | const activeSelection = this.selectedNeuron; |
| 2804 | if (type === "input") { |
| 2805 | for (let i = 0; i < values.length; i += 1) { |
| 2806 | const value = clamp(values[i], 0, 1); |
| 2807 | const isSelected = |
| 2808 | activeSelection && |
| 2809 | layerIndex === activeSelection.layerIndex && |
| 2810 | i === activeSelection.neuronIndex; |
| 2811 | if (isSelected) { |
| 2812 | this.tempColor.copy(this.highlightColor); |
| 2813 | } else { |
| 2814 | this.tempColor.setRGB(value, value, value); |
| 2815 | } |
| 2816 | mesh.setColorAt(i, this.tempColor); |
| 2817 | } |
| 2818 | mesh.instanceColor.needsUpdate = true; |
| 2819 | return; |
| 2820 | } |
| 2821 | |
| 2822 | const safeScale = scale > 1e-6 ? scale : 1; |
| 2823 | for (let i = 0; i < values.length; i += 1) { |
| 2824 | const value = values[i]; |
| 2825 | const normalized = clamp(value / safeScale, 0, 1); |
| 2826 | const isSelected = |
| 2827 | activeSelection && |
| 2828 | layerIndex === activeSelection.layerIndex && |
| 2829 | i === activeSelection.neuronIndex; |
| 2830 | if (isSelected) { |
| 2831 | this.tempColor.copy(this.highlightColor); |
| 2832 | } else { |
| 2833 | this.tempColor.setRGB(normalized, normalized, normalized); |
| 2834 | } |
| 2835 | mesh.setColorAt(i, this.tempColor); |
| 2836 | } |
| 2837 | mesh.instanceColor.needsUpdate = true; |
| 2838 | } |
| 2839 | |
| 2840 | applyConnectionColors(group, sourceValues) { |
| 2841 | const contributions = new Float32Array(group.connections.length); |