(layerIndex, neuronIndex)
| 2003 | } |
| 2004 | |
| 2005 | setSelectedNeuron(layerIndex, neuronIndex) { |
| 2006 | if (!Number.isInteger(layerIndex) || !Number.isInteger(neuronIndex)) return; |
| 2007 | const layer = this.layerMeshes[layerIndex]; |
| 2008 | if (!layer) return; |
| 2009 | const boundedIndex = Math.max(0, Math.min(layer.positions.length - 1, neuronIndex)); |
| 2010 | if ( |
| 2011 | this.selectedNeuron && |
| 2012 | this.selectedNeuron.layerIndex === layerIndex && |
| 2013 | this.selectedNeuron.neuronIndex === boundedIndex |
| 2014 | ) { |
| 2015 | this.clearSelection(); |
| 2016 | return; |
| 2017 | } |
| 2018 | this.selectedNeuron = { layerIndex, neuronIndex: boundedIndex }; |
| 2019 | this.updateConnectionVisibility(); |
| 2020 | this.buildSelectionConnectionMeshes(); |
| 2021 | if (this.lastDisplayActivations && this.lastNetworkActivations) { |
| 2022 | this.update(this.lastDisplayActivations, this.lastNetworkActivations, this.lastPreActivations); |
| 2023 | } else if (typeof this.requestRender === "function") { |
| 2024 | this.requestRender(); |
| 2025 | } |
| 2026 | } |
| 2027 | |
| 2028 | clearSelection() { |
| 2029 | if (!this.selectedNeuron) return; |
no test coverage detected