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.2-beta to 2.0.4-beta

28

dist/lib/FullModel.js

@@ -6,11 +6,10 @@ "use strict";

/** Default constructor. */
constructor(gl) {
this.gl = gl;
constructor() {
/** Number of model indices. */
this.numIndices = 0;
}
loadBuffer(buffer, target, arrayBuffer) {
loadBuffer(gl, buffer, target, arrayBuffer) {
var byteArray = new Uint8Array(arrayBuffer, 0, arrayBuffer.byteLength);
this.gl.bindBuffer(target, buffer);
this.gl.bufferData(target, byteArray, this.gl.STATIC_DRAW);
gl.bindBuffer(target, buffer);
gl.bufferData(target, byteArray, gl.STATIC_DRAW);
}

@@ -21,5 +20,6 @@ /**

* @param url Base URL to model indices and strides files.
* @param gl WebGL context.
* @returns Promise which resolves when model is loaded.
*/
async load(url) {
async load(url, gl) {
const dataIndices = await BinaryDataLoader_1.BinaryDataLoader.load(url + "-indices.bin");

@@ -29,14 +29,16 @@ const dataStrides = await BinaryDataLoader_1.BinaryDataLoader.load(url + "-strides.bin");

console.log(`Loaded + ${url}-strides.bin: ${dataStrides.byteLength} bytes.`);
this.bufferIndices = this.gl.createBuffer();
this.loadBuffer(this.bufferIndices, this.gl.ELEMENT_ARRAY_BUFFER, dataIndices);
this.bufferIndices = gl.createBuffer();
this.loadBuffer(gl, this.bufferIndices, gl.ELEMENT_ARRAY_BUFFER, dataIndices);
this.numIndices = dataIndices.byteLength / 2 / 3;
this.bufferStrides = this.gl.createBuffer();
this.loadBuffer(this.bufferStrides, this.gl.ARRAY_BUFFER, dataStrides);
this.bufferStrides = gl.createBuffer();
this.loadBuffer(gl, this.bufferStrides, gl.ARRAY_BUFFER, dataStrides);
}
/**
* Binds buffers for a `glDrawElements()` call.
*
* @param gl WebGL context.
*/
bindBuffers() {
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.bufferStrides);
this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.bufferIndices);
bindBuffers(gl) {
gl.bindBuffer(gl.ARRAY_BUFFER, this.bufferStrides);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.bufferIndices);
}

@@ -43,0 +45,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class UncompressedTextureLoader {
static load(url, gl, minFilter, magFilter, clamp = false) {
static load(url, gl, minFilter = gl.LINEAR, magFilter = gl.LINEAR, clamp = false) {
return new Promise((resolve, reject) => {

@@ -9,2 +9,3 @@ const texture = gl.createTexture();

reject("Error creating WebGL texture");
return;
}

@@ -16,4 +17,4 @@ const image = new Image();

gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter || gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter || gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
if (clamp === true) {

@@ -20,0 +21,0 @@ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);

export declare class FullModel {
protected gl: WebGLRenderingContext;
/** Indices buffer. */

@@ -10,3 +9,3 @@ protected bufferIndices: any;

/** Default constructor. */
constructor(gl: WebGLRenderingContext);
constructor();
private loadBuffer;

@@ -17,9 +16,12 @@ /**

* @param url Base URL to model indices and strides files.
* @param gl WebGL context.
* @returns Promise which resolves when model is loaded.
*/
load(url: string): Promise<void>;
load(url: string, gl: WebGLRenderingContext): Promise<void>;
/**
* Binds buffers for a `glDrawElements()` call.
*
* @param gl WebGL context.
*/
bindBuffers(): void;
bindBuffers(gl: WebGLRenderingContext): void;
/**

@@ -26,0 +28,0 @@ * Returns number of indices in model.

export declare class UncompressedTextureLoader {
static load(url: string, gl: WebGLRenderingContext, minFilter: number, magFilter: number, clamp?: boolean): Promise<WebGLTexture | null>;
static load(url: string, gl: WebGLRenderingContext, minFilter?: number, magFilter?: number, clamp?: boolean): Promise<WebGLTexture>;
}

@@ -70,3 +70,3 @@ class FullScreenUtils {

class UncompressedTextureLoader {
static load(url, gl, minFilter, magFilter, clamp = false) {
static load(url, gl, minFilter = gl.LINEAR, magFilter = gl.LINEAR, clamp = false) {
return new Promise((resolve, reject) => {

@@ -76,2 +76,3 @@ const texture = gl.createTexture();

reject("Error creating WebGL texture");
return;
}

@@ -83,4 +84,4 @@ const image = new Image();

gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter || gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter || gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
if (clamp === true) {

@@ -107,11 +108,10 @@ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);

/** Default constructor. */
constructor(gl) {
this.gl = gl;
constructor() {
/** Number of model indices. */
this.numIndices = 0;
}
loadBuffer(buffer, target, arrayBuffer) {
loadBuffer(gl, buffer, target, arrayBuffer) {
var byteArray = new Uint8Array(arrayBuffer, 0, arrayBuffer.byteLength);
this.gl.bindBuffer(target, buffer);
this.gl.bufferData(target, byteArray, this.gl.STATIC_DRAW);
gl.bindBuffer(target, buffer);
gl.bufferData(target, byteArray, gl.STATIC_DRAW);
}

@@ -122,5 +122,6 @@ /**

* @param url Base URL to model indices and strides files.
* @param gl WebGL context.
* @returns Promise which resolves when model is loaded.
*/
async load(url) {
async load(url, gl) {
const dataIndices = await BinaryDataLoader.load(url + "-indices.bin");

@@ -130,14 +131,16 @@ const dataStrides = await BinaryDataLoader.load(url + "-strides.bin");

console.log(`Loaded + ${url}-strides.bin: ${dataStrides.byteLength} bytes.`);
this.bufferIndices = this.gl.createBuffer();
this.loadBuffer(this.bufferIndices, this.gl.ELEMENT_ARRAY_BUFFER, dataIndices);
this.bufferIndices = gl.createBuffer();
this.loadBuffer(gl, this.bufferIndices, gl.ELEMENT_ARRAY_BUFFER, dataIndices);
this.numIndices = dataIndices.byteLength / 2 / 3;
this.bufferStrides = this.gl.createBuffer();
this.loadBuffer(this.bufferStrides, this.gl.ARRAY_BUFFER, dataStrides);
this.bufferStrides = gl.createBuffer();
this.loadBuffer(gl, this.bufferStrides, gl.ARRAY_BUFFER, dataStrides);
}
/**
* Binds buffers for a `glDrawElements()` call.
*
* @param gl WebGL context.
*/
bindBuffers() {
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.bufferStrides);
this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.bufferIndices);
bindBuffers(gl) {
gl.bindBuffer(gl.ARRAY_BUFFER, this.bufferStrides);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.bufferIndices);
}

@@ -144,0 +147,0 @@ /**

@@ -76,3 +76,3 @@ (function (global, factory) {

class UncompressedTextureLoader {
static load(url, gl, minFilter, magFilter, clamp = false) {
static load(url, gl, minFilter = gl.LINEAR, magFilter = gl.LINEAR, clamp = false) {
return new Promise((resolve, reject) => {

@@ -82,2 +82,3 @@ const texture = gl.createTexture();

reject("Error creating WebGL texture");
return;
}

@@ -89,4 +90,4 @@ const image = new Image();

gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter || gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter || gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
if (clamp === true) {

@@ -113,11 +114,10 @@ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);

/** Default constructor. */
constructor(gl) {
this.gl = gl;
constructor() {
/** Number of model indices. */
this.numIndices = 0;
}
loadBuffer(buffer, target, arrayBuffer) {
loadBuffer(gl, buffer, target, arrayBuffer) {
var byteArray = new Uint8Array(arrayBuffer, 0, arrayBuffer.byteLength);
this.gl.bindBuffer(target, buffer);
this.gl.bufferData(target, byteArray, this.gl.STATIC_DRAW);
gl.bindBuffer(target, buffer);
gl.bufferData(target, byteArray, gl.STATIC_DRAW);
}

@@ -128,5 +128,6 @@ /**

* @param url Base URL to model indices and strides files.
* @param gl WebGL context.
* @returns Promise which resolves when model is loaded.
*/
async load(url) {
async load(url, gl) {
const dataIndices = await BinaryDataLoader.load(url + "-indices.bin");

@@ -136,14 +137,16 @@ const dataStrides = await BinaryDataLoader.load(url + "-strides.bin");

console.log(`Loaded + ${url}-strides.bin: ${dataStrides.byteLength} bytes.`);
this.bufferIndices = this.gl.createBuffer();
this.loadBuffer(this.bufferIndices, this.gl.ELEMENT_ARRAY_BUFFER, dataIndices);
this.bufferIndices = gl.createBuffer();
this.loadBuffer(gl, this.bufferIndices, gl.ELEMENT_ARRAY_BUFFER, dataIndices);
this.numIndices = dataIndices.byteLength / 2 / 3;
this.bufferStrides = this.gl.createBuffer();
this.loadBuffer(this.bufferStrides, this.gl.ARRAY_BUFFER, dataStrides);
this.bufferStrides = gl.createBuffer();
this.loadBuffer(gl, this.bufferStrides, gl.ARRAY_BUFFER, dataStrides);
}
/**
* Binds buffers for a `glDrawElements()` call.
*
* @param gl WebGL context.
*/
bindBuffers() {
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.bufferStrides);
this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.bufferIndices);
bindBuffers(gl) {
gl.bindBuffer(gl.ARRAY_BUFFER, this.bufferStrides);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.bufferIndices);
}

@@ -150,0 +153,0 @@ /**

{
"name": "webgl-framework",
"version": "2.0.2-beta",
"version": "2.0.4-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