@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
47 lines (46 loc) • 1.81 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 ArrayShiftJsParamsConfig extends NodeParamsConfig {
}
const ParamsConfig = new ArrayShiftJsParamsConfig();
export class ArrayShiftJsNode extends BaseArrayElementJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "arrayShift";
}
_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("arrayShiftPrimitive", 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("arrayShiftVector", this, linesController);
linesController.addBodyOrComputed(this, [
{
dataType,
varName,
value: func.asString(array, tmpVarName)
}
]);
}
}