sigma
Version:
A JavaScript library dedicated to graph drawing.
61 lines (60 loc) • 2.63 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("../../../utils");
var node_fast_vert_glsl_1 = __importDefault(require("../shaders/node.fast.vert.glsl.js"));
var node_fast_frag_glsl_1 = __importDefault(require("../shaders/node.fast.frag.glsl.js"));
var node_1 = require("./common/node");
var POINTS = 1, ATTRIBUTES = 4;
var NodeProgramFast = /** @class */ (function (_super) {
__extends(NodeProgramFast, _super);
function NodeProgramFast(gl) {
var _this = _super.call(this, gl, node_fast_vert_glsl_1.default, node_fast_frag_glsl_1.default, POINTS, ATTRIBUTES) || this;
_this.bind();
return _this;
}
NodeProgramFast.prototype.process = function (data, hidden, offset) {
var array = this.array;
var i = offset * POINTS * ATTRIBUTES;
if (hidden) {
array[i++] = 0;
array[i++] = 0;
array[i++] = 0;
array[i++] = 0;
return;
}
var color = utils_1.floatColor(data.color);
array[i++] = data.x;
array[i++] = data.y;
array[i++] = data.size;
array[i] = color;
};
NodeProgramFast.prototype.render = function (params) {
var gl = this.gl;
var program = this.program;
gl.useProgram(program);
gl.uniform1f(this.ratioLocation, 1 / Math.pow(params.ratio, params.nodesPowRatio));
gl.uniform1f(this.scaleLocation, params.scalingRatio);
gl.uniformMatrix3fv(this.matrixLocation, false, params.matrix);
gl.drawArrays(gl.POINTS, 0, this.array.length / ATTRIBUTES);
};
return NodeProgramFast;
}(node_1.AbstractNodeProgram));
exports.default = NodeProgramFast;