UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

90 lines (89 loc) 2.7 kB
"use strict"; import { TypedGLDefinitionCollection } from "./GLDefinitionCollection"; import { GlConnectionPointType } from "../../utils/io/connections/Gl"; export var GLDefinitionType = /* @__PURE__ */ ((GLDefinitionType2) => { GLDefinitionType2["ATTRIBUTE"] = "attribute"; GLDefinitionType2["FUNCTION"] = "function"; GLDefinitionType2["PRECISION"] = "precision"; GLDefinitionType2["UNIFORM"] = "uniform"; GLDefinitionType2["VARYING"] = "varying"; return GLDefinitionType2; })(GLDefinitionType || {}); export class TypedGLDefinition { // constructor(protected _node: BaseGlNodeType, protected _name: string) {} constructor(_definition_type, _data_type, _node, _name) { this._definition_type = _definition_type; this._data_type = _data_type; this._node = _node; this._name = _name; } get definition_type() { return this._definition_type; } get data_type() { return this._data_type; } get node() { return this._node; } name() { return this._name; } collection_instance() { return new TypedGLDefinitionCollection(); } } export class AttributeGLDefinition extends TypedGLDefinition { constructor(_node, _data_type, _name) { super("attribute" /* ATTRIBUTE */, _data_type, _node, _name); this._node = _node; this._data_type = _data_type; this._name = _name; } get line() { return `attribute ${this.data_type} ${this.name()}`; } } export class FunctionGLDefinition extends TypedGLDefinition { constructor(_node, _name) { super("function" /* FUNCTION */, GlConnectionPointType.FLOAT, _node, _name); this._node = _node; this._name = _name; } get line() { return this.name(); } } export class UniformGLDefinition extends TypedGLDefinition { constructor(_node, _data_type, _name) { super("uniform" /* UNIFORM */, _data_type, _node, _name); this._node = _node; this._data_type = _data_type; this._name = _name; } get line() { return `uniform ${this.data_type} ${this.name()}`; } } export class PrecisionGLDefinition extends TypedGLDefinition { constructor(_node, _data_type, _name = "highp") { super("precision" /* PRECISION */, _data_type, _node, _name); this._node = _node; this._data_type = _data_type; this._name = _name; } get line() { return `precision ${this.name()} ${this.data_type}`; } } export class VaryingGLDefinition extends TypedGLDefinition { constructor(_node, _data_type, _name) { super("varying" /* VARYING */, _data_type, _node, _name); this._node = _node; this._data_type = _data_type; this._name = _name; } get line() { return `varying ${this.data_type} ${this.name()}`; } }