@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
49 lines (48 loc) • 1.8 kB
JavaScript
"use strict";
import {
JsConnectionPointTypeFromArrayTypeMap
} from "../utils/io/connections/Js";
import { NodeParamsConfig } from "../utils/params/ParamsConfig";
import { createVariable } from "./code/assemblers/_BaseJsPersistedConfigUtils";
import { Poly } from "../../Poly";
import { BaseArrayElementJsNode } from "./_BaseArrayToElement";
class ArrayPopJsParamsConfig extends NodeParamsConfig {
}
const ParamsConfig = new ArrayPopJsParamsConfig();
export class ArrayPopJsNode extends BaseArrayElementJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "arrayPop";
}
_setLinesAsPrimitive(linesController) {
const array = this.variableForInput(linesController, this._expectedInputName(0));
const dataType = this._expectedInputTypes()[0];
const varName = this.jsVarName(this._expectedOutputName(0));
const func = Poly.namedFunctionsRegister.getFunction("arrayPopPrimitive", this, linesController);
linesController.addBodyOrComputed(this, [
{
dataType,
varName,
value: func.asString(array)
}
]);
}
_setLinesAsVector(linesController) {
const array = this.variableForInput(linesController, this._expectedInputName(0));
const dataType = this._expectedInputTypes()[0];
const varName = this.jsVarName(this._expectedOutputName(0));
const elementType = JsConnectionPointTypeFromArrayTypeMap[dataType];
const tmpVarName = linesController.addVariable(this, createVariable(elementType));
const func = Poly.namedFunctionsRegister.getFunction("arrayPopVector", this, linesController);
linesController.addBodyOrComputed(this, [
{
dataType,
varName,
value: func.asString(array, tmpVarName)
}
]);
}
}