Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webgl-framework

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webgl-framework - npm Package Compare versions

Comparing version 2.0.5-beta to 2.0.7-beta

dist/lib/DrawableShader.js

21

dist/lib/BaseRenderer.js

@@ -173,4 +173,25 @@ "use strict";

}
/** @inheritdoc */
unbindBuffers() {
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null);
this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, null);
}
/** @inheritdoc */
getMVPMatrix() {
return this.mMVPMatrix;
}
/** @inheritdoc */
getOrthoMatrix() {
return this.matOrtho;
}
/** @inheritdoc */
getModelMatrix() {
return this.mMMatrix;
}
/** @inheritdoc */
getViewMatrix() {
return this.mVMatrix;
}
}
exports.BaseRenderer = BaseRenderer;
//# sourceMappingURL=BaseRenderer.js.map

2

dist/lib/webgl-framework.js

@@ -17,2 +17,4 @@ "use strict";

exports.BaseRenderer = BaseRenderer_1.BaseRenderer;
var DiffuseShader_1 = require("./shaders/DiffuseShader");
exports.DiffuseShader = DiffuseShader_1.DiffuseShader;
//# sourceMappingURL=webgl-framework.js.map

21

dist/types/BaseRenderer.d.ts
import { mat4type } from "gl-matrix-ts/dist/common";
export declare abstract class BaseRenderer {
import { RendererWithExposedMethods } from "./RendererWithExposedMethods";
export declare abstract class BaseRenderer implements RendererWithExposedMethods {
protected mMMatrix: Float32Array;

@@ -16,3 +17,3 @@ protected mVMatrix: Float32Array;

/** Getter for current WebGL context. */
protected get gl(): WebGLRenderingContext | WebGL2RenderingContext;
get gl(): WebGLRenderingContext | WebGL2RenderingContext;
/** Logs last GL error to console */

@@ -27,3 +28,3 @@ logGLError(): void;

*/
protected setTexture2D(textureUnit: number, texture: WebGLTexture, uniform: WebGLUniformLocation): void;
setTexture2D(textureUnit: number, texture: WebGLTexture, uniform: WebGLUniformLocation): void;
/**

@@ -36,3 +37,3 @@ * Binds cubemap texture.

*/
protected setTextureCubemap(textureUnit: number, texture: WebGLTexture, uniform: WebGLUniformLocation): void;
setTextureCubemap(textureUnit: number, texture: WebGLTexture, uniform: WebGLUniformLocation): void;
/**

@@ -94,3 +95,13 @@ * Calculates FOV for matrix.

*/
protected checkGlError(operation: string): void;
checkGlError(operation: string): void;
/** @inheritdoc */
unbindBuffers(): void;
/** @inheritdoc */
getMVPMatrix(): Float32Array;
/** @inheritdoc */
getOrthoMatrix(): Float32Array;
/** @inheritdoc */
getModelMatrix(): Float32Array;
/** @inheritdoc */
getViewMatrix(): Float32Array;
}

@@ -8,1 +8,2 @@ export { FullScreenUtils } from "./utils/FullScreenUtils";

export { BaseRenderer } from "./BaseRenderer";
export { DiffuseShader } from "./shaders/DiffuseShader";

@@ -978,5 +978,71 @@ class FullScreenUtils {

}
/** @inheritdoc */
unbindBuffers() {
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null);
this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, null);
}
/** @inheritdoc */
getMVPMatrix() {
return this.mMVPMatrix;
}
/** @inheritdoc */
getOrthoMatrix() {
return this.matOrtho;
}
/** @inheritdoc */
getModelMatrix() {
return this.mMMatrix;
}
/** @inheritdoc */
getViewMatrix() {
return this.mVMatrix;
}
}
export { FullScreenUtils, BinaryDataLoader, CompressedTextureLoader, UncompressedTextureLoader, FullModel, BaseShader, BaseRenderer };
class DiffuseShader extends BaseShader {
/** @inheritdoc */
fillCode() {
this.vertexShaderCode = 'uniform mat4 view_proj_matrix;\n' +
'attribute vec4 rm_Vertex;\n' +
'attribute vec2 rm_TexCoord0;\n' +
'varying vec2 vTextureCoord;\n' +
'\n' +
'void main() {\n' +
' gl_Position = view_proj_matrix * rm_Vertex;\n' +
' vTextureCoord = rm_TexCoord0;\n' +
'}';
this.fragmentShaderCode = 'precision mediump float;\n' +
'varying vec2 vTextureCoord;\n' +
'uniform sampler2D sTexture;\n' +
'\n' +
'void main() {\n' +
' gl_FragColor = texture2D(sTexture, vTextureCoord);\n' +
'}';
}
/** @inheritdoc */
fillUniformsAttributes() {
this.view_proj_matrix = this.getUniform('view_proj_matrix');
this.rm_Vertex = this.getAttrib('rm_Vertex');
this.rm_TexCoord0 = this.getAttrib('rm_TexCoord0');
this.sTexture = this.getUniform('sTexture');
}
/** @inheritdoc */
drawModel(renderer, model, tx, ty, tz, rx, ry, rz, sx, sy, sz) {
if (this.rm_Vertex === undefined || this.rm_TexCoord0 === undefined || this.view_proj_matrix === undefined) {
return;
}
const gl = renderer.gl;
model.bindBuffers(gl);
gl.enableVertexAttribArray(this.rm_Vertex);
gl.enableVertexAttribArray(this.rm_TexCoord0);
gl.vertexAttribPointer(this.rm_Vertex, 3, gl.FLOAT, false, 4 * (3 + 2), 0);
gl.vertexAttribPointer(this.rm_TexCoord0, 2, gl.FLOAT, false, 4 * (3 + 2), 4 * 3);
renderer.calculateMVPMatrix(tx, ty, tz, rx, ry, rz, sx, sy, sz);
gl.uniformMatrix4fv(this.view_proj_matrix, false, renderer.getMVPMatrix());
gl.drawElements(gl.TRIANGLES, model.getNumIndices() * 3, gl.UNSIGNED_SHORT, 0);
renderer.checkGlError("DiffuseShader glDrawElements");
}
}
export { FullScreenUtils, BinaryDataLoader, CompressedTextureLoader, UncompressedTextureLoader, FullModel, BaseShader, BaseRenderer, DiffuseShader };
//# sourceMappingURL=webgl-framework.es6.js.map

@@ -984,4 +984,70 @@ (function (global, factory) {

}
/** @inheritdoc */
unbindBuffers() {
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null);
this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, null);
}
/** @inheritdoc */
getMVPMatrix() {
return this.mMVPMatrix;
}
/** @inheritdoc */
getOrthoMatrix() {
return this.matOrtho;
}
/** @inheritdoc */
getModelMatrix() {
return this.mMMatrix;
}
/** @inheritdoc */
getViewMatrix() {
return this.mVMatrix;
}
}
class DiffuseShader extends BaseShader {
/** @inheritdoc */
fillCode() {
this.vertexShaderCode = 'uniform mat4 view_proj_matrix;\n' +
'attribute vec4 rm_Vertex;\n' +
'attribute vec2 rm_TexCoord0;\n' +
'varying vec2 vTextureCoord;\n' +
'\n' +
'void main() {\n' +
' gl_Position = view_proj_matrix * rm_Vertex;\n' +
' vTextureCoord = rm_TexCoord0;\n' +
'}';
this.fragmentShaderCode = 'precision mediump float;\n' +
'varying vec2 vTextureCoord;\n' +
'uniform sampler2D sTexture;\n' +
'\n' +
'void main() {\n' +
' gl_FragColor = texture2D(sTexture, vTextureCoord);\n' +
'}';
}
/** @inheritdoc */
fillUniformsAttributes() {
this.view_proj_matrix = this.getUniform('view_proj_matrix');
this.rm_Vertex = this.getAttrib('rm_Vertex');
this.rm_TexCoord0 = this.getAttrib('rm_TexCoord0');
this.sTexture = this.getUniform('sTexture');
}
/** @inheritdoc */
drawModel(renderer, model, tx, ty, tz, rx, ry, rz, sx, sy, sz) {
if (this.rm_Vertex === undefined || this.rm_TexCoord0 === undefined || this.view_proj_matrix === undefined) {
return;
}
const gl = renderer.gl;
model.bindBuffers(gl);
gl.enableVertexAttribArray(this.rm_Vertex);
gl.enableVertexAttribArray(this.rm_TexCoord0);
gl.vertexAttribPointer(this.rm_Vertex, 3, gl.FLOAT, false, 4 * (3 + 2), 0);
gl.vertexAttribPointer(this.rm_TexCoord0, 2, gl.FLOAT, false, 4 * (3 + 2), 4 * 3);
renderer.calculateMVPMatrix(tx, ty, tz, rx, ry, rz, sx, sy, sz);
gl.uniformMatrix4fv(this.view_proj_matrix, false, renderer.getMVPMatrix());
gl.drawElements(gl.TRIANGLES, model.getNumIndices() * 3, gl.UNSIGNED_SHORT, 0);
renderer.checkGlError("DiffuseShader glDrawElements");
}
}
exports.FullScreenUtils = FullScreenUtils;

@@ -994,2 +1060,3 @@ exports.BinaryDataLoader = BinaryDataLoader;

exports.BaseRenderer = BaseRenderer;
exports.DiffuseShader = DiffuseShader;

@@ -996,0 +1063,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

{
"name": "webgl-framework",
"version": "2.0.5-beta",
"version": "2.0.7-beta",
"description": "Basic low-level WebGL framework",

@@ -5,0 +5,0 @@ "author": "Oleksandr Popov (github.com/keaukraine/)",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc