polygonjs-engine
Version:
node-based webgl 3D engine https://polygonjs.com
96 lines (95 loc) • 3.32 kB
JavaScript
import {ParamType as ParamType2} from "../../../../poly/ParamType";
import {RampParam} from "../../../../params/Ramp";
export var GlConnectionPointType;
(function(GlConnectionPointType2) {
GlConnectionPointType2["BOOL"] = "bool";
GlConnectionPointType2["INT"] = "int";
GlConnectionPointType2["FLOAT"] = "float";
GlConnectionPointType2["VEC2"] = "vec2";
GlConnectionPointType2["VEC3"] = "vec3";
GlConnectionPointType2["VEC4"] = "vec4";
GlConnectionPointType2["SAMPLER_2D"] = "sampler2D";
})(GlConnectionPointType || (GlConnectionPointType = {}));
export const GL_CONNECTION_POINT_TYPES = [
GlConnectionPointType.BOOL,
GlConnectionPointType.INT,
GlConnectionPointType.FLOAT,
GlConnectionPointType.VEC2,
GlConnectionPointType.VEC3,
GlConnectionPointType.VEC4
];
export const GlConnectionPointTypeToParamTypeMap = {
[]: ParamType2.BOOLEAN,
[]: ParamType2.INTEGER,
[]: ParamType2.FLOAT,
[]: ParamType2.VECTOR2,
[]: ParamType2.VECTOR3,
[]: ParamType2.VECTOR4,
[]: ParamType2.RAMP
};
export const GLParamTypeToConnectionPointTypeMap = {
[]: GlConnectionPointType.BOOL,
[]: GlConnectionPointType.VEC3,
[]: GlConnectionPointType.INT,
[]: GlConnectionPointType.FLOAT,
[]: void 0,
[]: GlConnectionPointType.VEC2,
[]: GlConnectionPointType.VEC3,
[]: GlConnectionPointType.VEC4,
[]: void 0,
[]: void 0,
[]: void 0,
[]: void 0,
[]: void 0,
[]: void 0,
[]: void 0
};
export const GlConnectionPointInitValueMap = {
[]: false,
[]: 0,
[]: 0,
[]: [0, 0],
[]: [0, 0, 0],
[]: [0, 0, 0, 0],
[]: RampParam.DEFAULT_VALUE_JSON
};
export const GlConnectionPointComponentsCountMap = {
[]: 1,
[]: 1,
[]: 1,
[]: 2,
[]: 3,
[]: 4,
[]: 1
};
import {BaseConnectionPoint} from "./_Base";
export class GlConnectionPoint extends BaseConnectionPoint {
constructor(_name, _type, _init_value) {
super(_name, _type);
this._name = _name;
this._type = _type;
this._init_value = _init_value;
this._init_value = this._init_value || GlConnectionPointInitValueMap[this._type];
}
type() {
return this._type;
}
are_types_matched(src_type, dest_type) {
return src_type == dest_type;
}
get param_type() {
return GlConnectionPointTypeToParamTypeMap[this._type];
}
get init_value() {
return this._init_value;
}
toJSON() {
return this._json = this._json || this._create_json();
}
_create_json() {
return {
name: this._name,
type: this._type
};
}
}