@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
62 lines (61 loc) • 1.66 kB
JavaScript
;
import { isBoolean, isNumber, isString, isArray } from "../../core/Type";
import { TypedNodePathParamValue, TypedParamPathParamValue } from "../../core/Walker";
export const OPERATIONS_COMPOSER_NODE_TYPE = "operationsComposer";
export class BaseOperation {
constructor(_scene, states, _node) {
this._scene = _scene;
this.states = states;
this._node = _node;
}
static type() {
throw "type to be overriden";
}
type() {
const c = this.constructor;
return c.type();
}
static context() {
console.error("operation has no node_context", this);
throw "context requires override";
}
context() {
const c = this.constructor;
return c.context();
}
scene() {
return this._scene;
}
cook(input_contents, params) {
}
convertExportParamData(options) {
const { params, paramName, paramData } = options;
const default_param = params[paramName];
if (isBoolean(paramData)) {
return paramData;
}
if (isNumber(paramData)) {
if (isBoolean(default_param)) {
return paramData >= 1 ? true : false;
} else {
return paramData;
}
}
if (isString(paramData)) {
if (default_param) {
if (default_param instanceof TypedNodePathParamValue) {
return default_param.setPath(paramData);
}
if (default_param instanceof TypedParamPathParamValue) {
return default_param.setPath(paramData);
}
}
return paramData;
}
if (isArray(paramData)) {
params[paramName].fromArray(paramData);
}
}
}
BaseOperation.DEFAULT_PARAMS = {};
BaseOperation.INPUT_CLONED_STATE = [];