sigma
Version:
A JavaScript library aimed at visualizing graphs of thousands of nodes and edges.
63 lines (62 loc) • 2.67 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 NodeFastProgram = /** @class */ (function (_super) {
__extends(NodeFastProgram, _super);
function NodeFastProgram(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;
}
NodeFastProgram.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 = (0, utils_1.floatColor)(data.color);
array[i++] = data.x;
array[i++] = data.y;
array[i++] = data.size;
array[i] = color;
};
NodeFastProgram.prototype.render = function (params) {
if (this.hasNothingToRender())
return;
var gl = this.gl;
var program = this.program;
gl.useProgram(program);
gl.uniform1f(this.ratioLocation, 1 / Math.sqrt(params.ratio));
gl.uniform1f(this.scaleLocation, params.scalingRatio);
gl.uniformMatrix3fv(this.matrixLocation, false, params.matrix);
gl.drawArrays(gl.POINTS, 0, this.array.length / ATTRIBUTES);
};
return NodeFastProgram;
}(node_1.AbstractNodeProgram));
exports.default = NodeFastProgram;