diff --git a/DESIGN.md b/DESIGN.md index 6259d21..d6a3630 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -41,7 +41,7 @@ Data, either streaming or batched, that contains the state of the HTM system. Sh # Configuring an HTM Network for Highbrow -HTM Networks consiste of CorticalColumns, Layers, Neurons, and (sometimes) MiniColumns. HTM Networks can be defined in a configuration file, which is enough information to render the structures in 3D. The configuration is a JSON object that looks like this: +HTM Networks consists of CorticalColumns, Layers, Neurons, and (sometimes) MiniColumns. HTM Networks can be defined in a configuration file, which is enough information to render the structures in 3D. The configuration is a JSON object that looks like this: ```json { @@ -67,12 +67,21 @@ Each node in this tree represents a Renderable object. The top level is an HtmNe Layers must have dimensions. The dimensions of CorticalColumns and HtmNetworks are calculated from the layers. +## Scale and Spacing + +Scale is basically how large the rendering will be. You can think of it also has how big each neuron's renderable space is. By default it is 1 unit, which is pretty small in most spaces. A reasonable scale is `100`, which would give each neuron a space of 100x100x100 unit for rendering. + +Spacing represents how much empty space will be between renderable objects. When spacing is applied to the CorticalColumn configuration, it affects how much space is between layers in the column. When applied to Layer configuration, it affects how much space is between Neurons in the Layer. + +When applying scale and spacing, be sure to present the spacing values within the scale. For example, if your Layer scale is `100` and you want cells to be spaced with 1/2 a cell width between them, you should set the Layer spacing to `50`. # Objects ## Neuron -Represents a pyramidal neuron. Neurons can be put into different states. Must be created with a `position` corresponding to its XYZ location in the layer cell grid. Neurons are created by their parent Layer objects. +Represents a pyramidal neuron. Neurons can be put into different states. Must be created with a `position` corresponding to its XYZ location in the layer cell grid. Neurons are created by their parent Layer objects, which decides its `origin` at time of creation. + +To get the XYZ origin (the renderable 3D coordinate) of a Neuron, call `neuron.getOrigin()`. To get its position in the cellular grid within the layer, call `neuron.getPosition()`. ## Layer diff --git a/bin/highbrow-0.0.1.bundle.js b/bin/highbrow-0.0.1.bundle.js index b20f67a..8c061b4 100644 --- a/bin/highbrow-0.0.1.bundle.js +++ b/bin/highbrow-0.0.1.bundle.js @@ -536,7 +536,6 @@ class CorticalColumn extends Renderable { _buildColumn() { let columnOrigin = this.getOrigin(); let scale = this.getScale(); - // let accumulationForLayerY = 0 let processedLayers = []; // Reverse the layer configuration so that they render from bottom to @@ -544,7 +543,11 @@ class CorticalColumn extends Renderable { let reversedLayers = this._config.layers.slice().reverse(); reversedLayers.map((layerConfigOriginal, layerIndex) => { let layerConfig = Object.assign({}, layerConfigOriginal); - layerConfig.scale = scale; + // Only pass along the column's scale if there is no user-defined + // scale present. + if (layerConfig.scale == undefined) { + layerConfig.scale = scale; + } layerConfig.origin = this.getOrigin(); // Default cell spacing for layers will be 10% of scale, or 0 @@ -553,29 +556,21 @@ class CorticalColumn extends Renderable { if (layerConfig.spacing < 1) layerConfig.spacing = 0; } - // Get the total height of previously processed layers. - let layerBuffer = processedLayers.map(processedLayer => { + // Get the total height of previously processed layers so we know + // where to put the origin for this layer. + let layerY = processedLayers.map(processedLayer => { let ydim = processedLayer.getDimensions().y; let cellHeight = ydim * processedLayer.getScale(); let spacingHeight = (ydim - 1) * processedLayer.getSpacing(); let columnSpacing = this.getSpacing(); - console.log("---- %s Y dimensions:", processedLayer.getName()); - console.log("cell height: %s\tspacing height: %s\tcolumn spacing: %s", cellHeight, spacingHeight, columnSpacing); return cellHeight + spacingHeight + columnSpacing; }).reduce((sum, value) => { return sum + value; }, 0); - // Layers need spacing in between them, which will affect their - // origin points in the Y direction. If there are multiple layers, - // their Y origins get updated here using the scale, column spacing, - // and the sizes of lower layers. Each layer is rendered below the - // last to keep the config alignment the same as the visual - // alignment. - layerConfig.origin.y = layerConfig.origin.y + layerBuffer; + layerConfig.origin.y = layerConfig.origin.y + layerY; let layer = new Layer(layerConfig, this); - // accumulationForLayerY += layer.getDimensions().y processedLayers.push(layer); return layer; }); diff --git a/src/cortical-column.js b/src/cortical-column.js index 52e242f..06e0478 100644 --- a/src/cortical-column.js +++ b/src/cortical-column.js @@ -26,7 +26,11 @@ class CorticalColumn extends Renderable { let reversedLayers = this._config.layers.slice().reverse() reversedLayers.map((layerConfigOriginal, layerIndex) => { let layerConfig = Object.assign({}, layerConfigOriginal) - layerConfig.scale = scale + // Only pass along the column's scale if there is no user-defined + // scale present. + if (layerConfig.scale == undefined) { + layerConfig.scale = scale + } layerConfig.origin = this.getOrigin() // Default cell spacing for layers will be 10% of scale, or 0