UNPKG

@tokens-studio/graph-engine

Version:

An execution engine to handle Token Studios generators and resolvers

22 lines 765 B
import { Node } from '../../programmatic/node.js'; import { NumberSchema, Vec2Schema } from '../../schemas/index.js'; export default class NodeDefinition extends Node { static title = 'Vector2 Length'; static type = 'studio.tokens.vector2.length'; static description = 'Calculates the magnitude (length) of a 2D vector'; constructor(props) { super(props); this.addInput('vector', { type: Vec2Schema }); this.addOutput('value', { type: NumberSchema }); } execute() { const { vector } = this.getAllInputs(); const length = Math.sqrt(vector[0] * vector[0] + vector[1] * vector[1]); this.outputs.value.set(length); } } //# sourceMappingURL=length.js.map