Skip to content

defineNodeAttribute

method

Back to Helios Network JS/WASM API

Kind
method
Source
src/js/HeliosNetwork.js:5678

Description

Defines a node attribute backed by linear WASM memory.

Signature

defineNodeAttribute(name, type, dimension = 1) {

Parameters

NameTypeAttributesDefaultDescription
namestringAttribute identifier.
typeAttributeTypeAttribute type constant.
dimensionnumberoptional1Number of elements per node.

Returns

Type void

Example

import HeliosNetwork, { AttributeType } from 'helios-network';
const net = await HeliosNetwork.create({ initialNodes: 2 });
net.defineNodeAttribute('weight', AttributeType.Float);
net.withBufferAccess(() => {
  const weightBuffer = net.getNodeAttributeBuffer('weight').view;
  weightBuffer[0] = 1.5;
});