New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@thi.ng/webgl

Package Overview
Dependencies
Maintainers
1
Versions
291
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/webgl - npm Package Compare versions

Comparing version 0.2.4 to 0.3.2

2

api/blend.d.ts

@@ -1,2 +0,2 @@

import { Tuple } from "@thi.ng/api";
import type { Tuple } from "@thi.ng/api";
export declare const enum Blend {

@@ -3,0 +3,0 @@ ZERO = 0,

@@ -1,3 +0,3 @@

import { IBind, IRelease } from "@thi.ng/api";
import { ITexture } from "./texture";
import type { IBind, IRelease } from "@thi.ng/api";
import type { ITexture } from "./texture";
export declare type IndexBufferData = Uint16Array | Uint32Array;

@@ -4,0 +4,0 @@ export interface IWebGLBuffer<T> extends IBind<void>, IRelease {

@@ -1,2 +0,2 @@

import { WebGLExtensionMap } from "./ext";
import type { WebGLExtensionMap } from "./ext";
export interface WeblGLCanvasOpts {

@@ -3,0 +3,0 @@ canvas: string | HTMLCanvasElement;

@@ -1,2 +0,2 @@

import { IObjectOf } from "@thi.ng/api";
import type { IObjectOf } from "@thi.ng/api";
export declare const GL_EXT_INFO: IObjectOf<ExtensionInfo>;

@@ -3,0 +3,0 @@ export interface ExtensionInfo {

@@ -1,3 +0,3 @@

import { Tuple } from "@thi.ng/api";
import { Type } from "@thi.ng/shader-ast";
import type { Tuple } from "@thi.ng/api";
import type { Type } from "@thi.ng/shader-ast";
export declare type GLSL = Type;

@@ -4,0 +4,0 @@ export declare type GLVec = number[] | Float32Array;

@@ -1,2 +0,2 @@

import { GLVec3 } from "./glsl";
import type { GLVec3 } from "./glsl";
export interface Material {

@@ -3,0 +3,0 @@ ambientCol: GLVec3;

@@ -1,6 +0,6 @@

import { IObjectOf } from "@thi.ng/api";
import { AttribPool } from "@thi.ng/vector-pools";
import { IndexBufferSpec, IWebGLBuffer } from "./buffers";
import { AttribBufferData, IShader, UniformValues } from "./shader";
import { ITexture } from "./texture";
import type { IObjectOf } from "@thi.ng/api";
import type { IndexBufferSpec, IWebGLBuffer } from "./buffers";
import type { AttribBufferData, IShader, UniformValues } from "./shader";
import type { ITexture } from "./texture";
export declare type ModelAttributeSpecs = IObjectOf<ModelAttributeSpec>;

@@ -7,0 +7,0 @@ export interface ModelSpec {

@@ -1,7 +0,7 @@

import { IObjectOf } from "@thi.ng/api";
import { AttribPool } from "@thi.ng/vector-pools";
import { IFbo, IndexBufferSpec } from "./buffers";
import { InstancingSpec, ModelAttributeSpecs, ModelSpec } from "./model";
import { ShaderAttribSpecs, ShaderFn, ShaderState, ShaderVaryingSpecs, UniformDecl, UniformValues } from "./shader";
import { ITexture, TextureOpts } from "./texture";
import type { IObjectOf } from "@thi.ng/api";
import type { IFbo, IndexBufferSpec } from "./buffers";
import type { InstancingSpec, ModelAttributeSpecs, ModelSpec } from "./model";
import type { ShaderAttribSpecs, ShaderFn, ShaderState, ShaderVaryingSpecs, UniformDecl, UniformValues } from "./shader";
import type { ITexture, TextureOpts } from "./texture";
export interface Multipass {

@@ -8,0 +8,0 @@ start(): void;

@@ -1,10 +0,10 @@

import { Fn, Fn2, Fn3, Fn4, IBind, IDeref, IObjectOf, IRelease, NumericArray } from "@thi.ng/api";
import { Func, Sym } from "@thi.ng/shader-ast";
import { GLSLTarget } from "@thi.ng/shader-ast-glsl";
import { ReadonlyVec } from "@thi.ng/vectors";
import { BlendEquation, BlendFunc } from "./blend";
import { ExtensionBehaviors } from "./ext";
import { GLIntVec, GLIntVec2, GLIntVec3, GLIntVec4, GLMat2, GLMat3, GLMat4, GLSL, GLSLArrayType, GLSLScalarType, GLUintVec, GLVec, GLVec2, GLVec3, GLVec4 } from "./glsl";
import { ModelAttributeSpecs, ModelSpec } from "./model";
import { StencilFnParams, StencilOpParams } from "./stencil";
import type { Fn, Fn2, Fn3, Fn4, IBind, IDeref, IObjectOf, IRelease, NumericArray } from "@thi.ng/api";
import type { Func, Sym } from "@thi.ng/shader-ast";
import type { GLSLTarget } from "@thi.ng/shader-ast-glsl";
import type { ReadonlyVec } from "@thi.ng/vectors";
import type { ExtensionBehaviors } from "./ext";
import type { GLIntVec, GLIntVec2, GLIntVec3, GLIntVec4, GLMat2, GLMat3, GLMat4, GLSL, GLSLArrayType, GLSLScalarType, GLUintVec, GLVec, GLVec2, GLVec3, GLVec4 } from "./glsl";
import type { ModelAttributeSpecs, ModelSpec } from "./model";
import type { StencilFnParams, StencilOpParams } from "./stencil";
export interface GLSLSyntax {

@@ -11,0 +11,0 @@ number: number;

@@ -1,2 +0,2 @@

import { Tuple } from "@thi.ng/api";
import type { Tuple } from "@thi.ng/api";
export declare const enum StencilOp {

@@ -3,0 +3,0 @@ KEEP = 7680,

@@ -1,3 +0,3 @@

import { IBind, IObjectOf, IRelease } from "@thi.ng/api";
import { IConfigure } from "./buffers";
import type { IBind, IObjectOf, IRelease } from "@thi.ng/api";
import type { IConfigure } from "./buffers";
export declare const enum TextureFormat {

@@ -144,18 +144,95 @@ ALPHA = 6406,

export interface TextureOpts {
/**
* If this value is null or a typedarray then size options (i.e.
* `width`, `height`, `depth`) MUST be given (the latter only if
* `target` is TEXTURE_3D).
*/
image: ArrayBufferView | TexImageSource | null;
/**
* @defaultValue TextureTarget.TEXTURE_2D
*/
target: TextureTarget;
/**
* Only needed if overriding `format`'s default type.
*/
type: TextureType;
/**
* @defaultValue TextureFilter.NEAREST
*/
filter: TextureFilter | [TextureFilter, TextureFilter?];
/**
* @defaultValue TextureRepeat.CLAMP
*/
wrap: TextureRepeat | [TextureRepeat, TextureRepeat?, TextureRepeat?];
/**
* Min/max level-of-detail values.
*
* @defaultValue none
*/
lod: [number, number?];
/**
* Min/max mipmap levels (ints)
*
* @defaultValue none
*/
minMaxLevel: [number, number];
/**
* Mipmap level to configure (e.g. if providing custom mipmaps)
*
* @defaultValue 0
*/
level: number;
/**
* @defaultValue TextureFormat.RGBA
*/
format: TextureFormat;
/**
* Texture width in pixels. Only used if `image` is null or a typed
* array.
*
* @defaultValue none
*/
width: number;
/**
* Texture height in pixels. Only used if `image` is null or a typed
* array.
*
* @defaultValue none
*/
height: number;
/**
* Texture depth in pixels. Only used if `target` is
* `TextureTarget.TEXTURE_3D`
*
* @defaultValue none
*/
depth: number;
/**
* True, if mipmaps should be generated.
*
* @defaultValue false
*/
mipmap: boolean;
/**
* True, if source data should be flipped along its vertical axis.
*
* @defaultValue none
*/
flip: boolean;
/**
* True, if the source data's color channels should be
* pre-multiplied with the alpha channel.
*
* @defaultValue none
*/
premultiply: boolean;
/**
* True, if given `image` is only defining a sub-image (i.e. partial
* update of a previously configured texture). If true, also uses
* `pos` option.
*/
sub: boolean;
/**
* Pixel position offset for `sub` image updates.
*/
pos: number[];

@@ -162,0 +239,0 @@ }

@@ -1,5 +0,5 @@

import { TypedArray } from "@thi.ng/api";
import { AttribPool } from "@thi.ng/vector-pools";
import { IndexBufferSpec, IWebGLBuffer } from "./api/buffers";
import { ModelAttributeSpecs, ModelSpec } from "./api/model";
import type { TypedArray } from "@thi.ng/api";
import type { IndexBufferSpec, IWebGLBuffer } from "./api/buffers";
import type { ModelAttributeSpecs, ModelSpec } from "./api/model";
export declare class WebGLArrayBuffer<T extends TypedArray> implements IWebGLBuffer<T> {

@@ -6,0 +6,0 @@ gl: WebGLRenderingContext;

@@ -49,14 +49,14 @@ import { isGL2Context } from "./checks";

};
const initBuffer = (gl, src, type, mode) => {
if (src.buffer) {
src.data && src.buffer.set(src.data);
}
else {
src.buffer = new WebGLArrayBuffer(gl, src.data, type, mode);
}
};
const compileAttribs = (gl, attribs, mode) => {
if (attribs) {
for (let id in attribs) {
if (attribs.hasOwnProperty(id)) {
const attr = attribs[id];
if (attr.buffer) {
attr.data && attr.buffer.set(attr.data);
}
else {
attr.buffer = new WebGLArrayBuffer(gl, attr.data, gl.ARRAY_BUFFER, mode);
}
}
initBuffer(gl, attribs[id], gl.ARRAY_BUFFER, mode);
}

@@ -68,8 +68,3 @@ }

if (index) {
if (index.buffer) {
index.data && index.buffer.set(index.data);
}
else {
index.buffer = new WebGLArrayBuffer(gl, index.data, gl.ELEMENT_ARRAY_BUFFER, mode);
}
initBuffer(gl, index, gl.ELEMENT_ARRAY_BUFFER, mode);
}

@@ -76,0 +71,0 @@ return index;

@@ -1,3 +0,3 @@

import { WeblGLCanvasOpts } from "./api/canvas";
import { WebGLExtensionMap } from "./api/ext";
import type { WeblGLCanvasOpts } from "./api/canvas";
import type { WebGLExtensionMap } from "./api/ext";
export declare const glCanvas: (opts?: Partial<WeblGLCanvasOpts>) => {

@@ -4,0 +4,0 @@ canvas: HTMLCanvasElement;

@@ -6,3 +6,3 @@ # Change Log

## [0.2.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/webgl@0.2.3...@thi.ng/webgl@0.2.4) (2020-01-26)
## [0.3.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/webgl@0.3.1...@thi.ng/webgl@0.3.2) (2020-02-26)

@@ -15,40 +15,43 @@ **Note:** Version bump only for package @thi.ng/webgl

## [0.2.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/webgl@0.2.2...@thi.ng/webgl@0.2.3) (2020-01-24)
## [0.3.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/webgl@0.3.0...@thi.ng/webgl@0.3.1) (2020-02-26)
**Note:** Version bump only for package @thi.ng/webgl
### Bug Fixes
* **webgl:** webgl1 depth texture ([5c86165](https://github.com/thi-ng/umbrella/commit/5c861659c353076d01153d3258d3d98bc5113a1c))
# [0.3.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/webgl@0.2.4...@thi.ng/webgl@0.3.0) (2020-02-25)
## [0.2.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/webgl@0.2.1...@thi.ng/webgl@0.2.2) (2019-11-30)
### Features
* **webgl:** update Texture.config() default handling ([4c62d87](https://github.com/thi-ng/umbrella/commit/4c62d87016d6e73899d9c080e9c9f7fb03d841f2))
### Bug Fixes
* **webgl:** fix PHONG shader preset, minor update LAMBERT ([792379f](https://github.com/thi-ng/umbrella/commit/792379fd507cbc9ef684a1b255f3152cb55092b9))
* **webgl:** use LOGGER for warnings ([14d5025](https://github.com/thi-ng/umbrella/commit/14d502556717e1e0aded784294401ec0afc6d733))
## [0.2.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/webgl@0.2.2...@thi.ng/webgl@0.2.3) (2020-01-24)
### Bug Fixes
## [0.2.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/webgl@0.2.0...@thi.ng/webgl@0.2.1) (2019-11-09)
* **webgl:** webgl1 depth texture ([5c86165](https://github.com/thi-ng/umbrella/commit/5c861659c353076d01153d3258d3d98bc5113a1c))
## [0.2.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/webgl@0.2.1...@thi.ng/webgl@0.2.2) (2019-11-30)
### Bug Fixes
* **webgl:** add LOGGER, update initUniforms() ([4719110](https://github.com/thi-ng/umbrella/commit/471911084c8db79930cf273f222f345318671953))
* **webgl:** ensure system defaults for all uniforms, update equiv checks ([39dc83f](https://github.com/thi-ng/umbrella/commit/39dc83ff49c97fb7ba70f7bbf0f7244d612c7fc8))
* **webgl:** fix PHONG shader preset, minor update LAMBERT ([792379f](https://github.com/thi-ng/umbrella/commit/792379fd507cbc9ef684a1b255f3152cb55092b9))
* **webgl:** use LOGGER for warnings ([14d5025](https://github.com/thi-ng/umbrella/commit/14d502556717e1e0aded784294401ec0afc6d733))
## [0.2.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/webgl@0.2.0...@thi.ng/webgl@0.2.1) (2019-11-09)
### Bug Fixes
* **webgl:** add LOGGER, update initUniforms() ([4719110](https://github.com/thi-ng/umbrella/commit/471911084c8db79930cf273f222f345318671953))
* **webgl:** ensure system defaults for all uniforms, update equiv checks ([39dc83f](https://github.com/thi-ng/umbrella/commit/39dc83ff49c97fb7ba70f7bbf0f7244d612c7fc8))
# [0.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/webgl@0.1.7...@thi.ng/webgl@0.2.0) (2019-09-21)
### Bug Fixes

@@ -59,3 +62,2 @@

### Features

@@ -72,41 +74,4 @@

## [0.1.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/webgl@0.1.6...@thi.ng/webgl@0.1.7) (2019-08-21)
**Note:** Version bump only for package @thi.ng/webgl
## [0.1.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/webgl@0.1.5...@thi.ng/webgl@0.1.6) (2019-08-17)
**Note:** Version bump only for package @thi.ng/webgl
## [0.1.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/webgl@0.1.4...@thi.ng/webgl@0.1.5) (2019-08-16)
**Note:** Version bump only for package @thi.ng/webgl
## [0.1.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/webgl@0.1.3...@thi.ng/webgl@0.1.4) (2019-07-31)
**Note:** Version bump only for package @thi.ng/webgl
## [0.1.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/webgl@0.1.2...@thi.ng/webgl@0.1.3) (2019-07-31)
### Bug Fixes

@@ -116,25 +81,4 @@

## [0.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/webgl@0.1.1...@thi.ng/webgl@0.1.2) (2019-07-12)
**Note:** Version bump only for package @thi.ng/webgl
## [0.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/webgl@0.1.0...@thi.ng/webgl@0.1.1) (2019-07-08)
**Note:** Version bump only for package @thi.ng/webgl
# 0.1.0 (2019-07-07)
### Bug Fixes

@@ -151,3 +95,2 @@

### Features

@@ -154,0 +97,0 @@

@@ -1,3 +0,3 @@

import { ModelSpec } from "./api/model";
import type { ModelSpec } from "./api/model";
export declare const draw: (specs: ModelSpec | ModelSpec[]) => void;
//# sourceMappingURL=draw.d.ts.map

@@ -1,2 +0,2 @@

import { FboOpts, IFbo } from "./api/buffers";
import type { FboOpts, IFbo } from "./api/buffers";
/**

@@ -3,0 +3,0 @@ * WebGL framebuffer wrapper w/ automatic detection & support for

@@ -1,2 +0,2 @@

import { ModelSpec } from "../api/model";
import type { ModelSpec } from "../api/model";
export interface CubeOpts {

@@ -3,0 +3,0 @@ size: number;

@@ -1,3 +0,3 @@

import { ModelSpec } from "../api/model";
import type { ModelSpec } from "../api/model";
export declare const quad: (uv?: boolean) => ModelSpec;
//# sourceMappingURL=quad.d.ts.map

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@thi.ng/api"),require("@thi.ng/checks"),require("@thi.ng/associative"),require("@thi.ng/matrices"),require("@thi.ng/transducers"),require("@thi.ng/errors"),require("@thi.ng/shader-ast"),require("@thi.ng/shader-ast-glsl"),require("@thi.ng/equiv"),require("@thi.ng/vectors"),require("@thi.ng/shader-ast-stdlib"),require("@thi.ng/pixel")):"function"==typeof define&&define.amd?define(["exports","@thi.ng/api","@thi.ng/checks","@thi.ng/associative","@thi.ng/matrices","@thi.ng/transducers","@thi.ng/errors","@thi.ng/shader-ast","@thi.ng/shader-ast-glsl","@thi.ng/equiv","@thi.ng/vectors","@thi.ng/shader-ast-stdlib","@thi.ng/pixel"],t):t(((e=e||self).thi=e.thi||{},e.thi.ng=e.thi.ng||{},e.thi.ng.webgl={}),e.thi.ng.api,e.thi.ng.checks,e.thi.ng.associative,e.thi.ng.matrices,e.thi.ng.transducers,e.thi.ng.errors,e.thi.ng.shaderAst,e.thi.ng.shaderAstGlsl,e.thi.ng.equiv,e.thi.ng.vectors,e.thi.ng.shaderAstStdlib,e.thi.ng.pixel)}(this,(function(e,t,r,i,n,s,a,o,l,u,c,E,R){"use strict";var d,f;(d=e.Blend||(e.Blend={}))[d.ZERO=0]="ZERO",d[d.ONE=1]="ONE",d[d.SRC_COLOR=768]="SRC_COLOR",d[d.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",d[d.DST_COLOR=774]="DST_COLOR",d[d.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",d[d.SRC_ALPHA=770]="SRC_ALPHA",d[d.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",d[d.DST_ALPHA=772]="DST_ALPHA",d[d.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",d[d.CONSTANT_COLOR=32769]="CONSTANT_COLOR",d[d.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",d[d.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",d[d.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",d[d.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",(f=e.BlendEquation||(e.BlendEquation={}))[f.FUNC_ADD=32774]="FUNC_ADD",f[f.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",f[f.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",f[f.MAX=32776]="MAX",f[f.MIN=32775]="MIN";const _={WEBGL_draw_buffers:{gl:!0,alias:"GL_EXT_draw_buffers"},OES_standard_derivatives:{gl:!0,alias:"GL_OES_standard_derivatives"}};e.LOGGER=t.NULL_LOGGER;const h={fragColor:["vec4",0]};var g,A,m,T,v;(g=e.TextureFormat||(e.TextureFormat={}))[g.ALPHA=6406]="ALPHA",g[g.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",g[g.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",g[g.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",g[g.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",g[g.DEPTH_STENCIL=34041]="DEPTH_STENCIL",g[g.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",g[g.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",g[g.LUMINANCE=6409]="LUMINANCE",g[g.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",g[g.R11F_G11F_B10F=35898]="R11F_G11F_B10F",g[g.R16F=33325]="R16F",g[g.R16I=33331]="R16I",g[g.R16UI=33332]="R16UI",g[g.R32F=33326]="R32F",g[g.R32I=33333]="R32I",g[g.R32UI=33334]="R32UI",g[g.R8=33321]="R8",g[g.R8_SNORM=36756]="R8_SNORM",g[g.R8I=33329]="R8I",g[g.R8UI=33330]="R8UI",g[g.RED=6403]="RED",g[g.RED_INTEGER=36244]="RED_INTEGER",g[g.RG=33319]="RG",g[g.RG_INTEGER=33320]="RG_INTEGER",g[g.RG16F=33327]="RG16F",g[g.RG16I=33337]="RG16I",g[g.RG16UI=33338]="RG16UI",g[g.RG32F=33328]="RG32F",g[g.RG32I=33339]="RG32I",g[g.RG32UI=33340]="RG32UI",g[g.RG8=33323]="RG8",g[g.RG8_SNORM=36757]="RG8_SNORM",g[g.RG8I=33335]="RG8I",g[g.RG8UI=33336]="RG8UI",g[g.RGB=6407]="RGB",g[g.RGB_INTEGER=36248]="RGB_INTEGER",g[g.RGB10_A2=32857]="RGB10_A2",g[g.RGB10_A2UI=36975]="RGB10_A2UI",g[g.RGB16F=34843]="RGB16F",g[g.RGB16I=36233]="RGB16I",g[g.RGB16UI=36215]="RGB16UI",g[g.RGB32F=34837]="RGB32F",g[g.RGB32I=36227]="RGB32I",g[g.RGB32UI=36209]="RGB32UI",g[g.RGB5_A1=32855]="RGB5_A1",g[g.RGB565=36194]="RGB565",g[g.RGB8=32849]="RGB8",g[g.RGB8_SNORM=36758]="RGB8_SNORM",g[g.RGB8I=36239]="RGB8I",g[g.RGB8UI=36221]="RGB8UI",g[g.RGB9_E5=35901]="RGB9_E5",g[g.RGBA=6408]="RGBA",g[g.RGBA_INTEGER=36249]="RGBA_INTEGER",g[g.RGBA16F=34842]="RGBA16F",g[g.RGBA16I=36232]="RGBA16I",g[g.RGBA16UI=36214]="RGBA16UI",g[g.RGBA32F=34836]="RGBA32F",g[g.RGBA32I=36226]="RGBA32I",g[g.RGBA32UI=36208]="RGBA32UI",g[g.RGBA4=32854]="RGBA4",g[g.RGBA8=32856]="RGBA8",g[g.RGBA8_SNORM=36759]="RGBA8_SNORM",g[g.RGBA8I=36238]="RGBA8I",g[g.RGBA8UI=36220]="RGBA8UI",g[g.SRGB8=35905]="SRGB8",g[g.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",(A=e.TextureType||(e.TextureType={}))[A.BYTE=5120]="BYTE",A[A.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",A[A.SHORT=5122]="SHORT",A[A.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",A[A.INT=5124]="INT",A[A.UNSIGNED_INT=5125]="UNSIGNED_INT",A[A.FLOAT=5126]="FLOAT",A[A.HALF_FLOAT=5131]="HALF_FLOAT",A[A.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",A[A.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",A[A.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",A[A.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",A[A.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",A[A.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",A[A.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",A[A.HALF_FLOAT_OES=36193]="HALF_FLOAT_OES",A[A.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",(m=e.TextureTarget||(e.TextureTarget={}))[m.TEXTURE_2D=3553]="TEXTURE_2D",m[m.TEXTURE_3D=32879]="TEXTURE_3D",m[m.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",m[m.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",(T=e.TextureFilter||(e.TextureFilter={}))[T.LINEAR=9729]="LINEAR",T[T.NEAREST=9728]="NEAREST",T[T.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",T[T.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",T[T.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",T[T.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",(v=e.TextureRepeat||(e.TextureRepeat={}))[v.REPEAT=10497]="REPEAT",v[v.CLAMP=33071]="CLAMP",v[v.REPEAT_MIRROR=33648]="REPEAT_MIRROR";const b=(e,t,r,i=!1,n=!1,s=i)=>({format:e,types:t,render:i,renderExt:s,filter:n,num:r}),p={6406:b(6406,[5121,1,5131,2,36193,2,5126,4],1,!0,!0),6402:b(6402,[5123,2,5125,4],1,!0),33189:b(6402,[5123,2,5125,4],1,!0),33190:b(6402,[5125,4],1,!0),36012:b(6402,[5126,4],1,!0),34041:b(34041,[34042,4],1,!0),35056:b(34041,[34042,4],1,!0),36013:b(34041,[36269,4],1,!0),6410:b(6410,[5121,2,5131,4,36193,4,5126,8],2,!0,!0),6409:b(6409,[5121,1,5131,2,36193,2,5126,4],1,!0,!0),35898:b(6407,[5126,12,5131,6,35899,4],3,!1,!0,!0),33325:b(6403,[5126,4,5131,2],1,!1,!0,!0),33331:b(36244,[5122,2],1,!0),33332:b(36244,[5123,2],1,!0),33326:b(6403,[5126,4],1,!1,!1,!0),33333:b(36244,[5124,4],1,!0),33334:b(36244,[5125,4],1,!0),36756:b(6403,[5120,1],1,!1,!0),33321:b(6403,[5121,1],1,!0,!0),33329:b(36244,[5120,1],1,!0),33330:b(36244,[5121,1],1,!0),33327:b(33319,[5126,8,5131,4],2,!1,!0,!0),33337:b(33320,[5122,4],2,!0),33338:b(33320,[5123,4],2,!0),33328:b(33319,[5126,8],2,!1,!1,!0),33339:b(33320,[5124,8],2,!0),33340:b(33320,[5125,8],2,!0),36757:b(33319,[5120,2],2,!1,!0),33323:b(33319,[5121,2],2,!0,!0),33335:b(33320,[5120,2],2,!0),33336:b(33320,[5121,2],2,!0),6407:b(6407,[5121,3,5131,6,36193,6,5126,12,33635,2],3,!0,!0),32857:b(6408,[33640,4],4,!0,!0),36975:b(36249,[33640,4],4,!0),34843:b(6407,[5126,12,5131,6],3,!1,!0),36233:b(36248,[5122,6],3),36215:b(36248,[5123,6],3),34837:b(6407,[5126,12],3),36227:b(36248,[5124,12],3),36209:b(36248,[5125,12],3),32855:b(6408,[5121,4,32820,2,33640,4],4,!0,!0),36194:b(6407,[5121,3,33635,2],3,!0,!0),36758:b(6407,[5120,3],3,!1,!0),32849:b(6407,[5121,3],3,!0,!0),36239:b(36248,[5120,3],3),36221:b(36248,[5121,3],3),35901:b(6407,[5126,12,5131,6,35902,4],3,!1,!0),6408:b(6408,[5121,4,5131,8,36193,8,5126,16,32819,2,32820,2],4,!0,!0),34842:b(6408,[5126,16,5131,8],4,!1,!0,!0),36232:b(36249,[5122,8],4,!0),36214:b(36249,[5123,8],4,!0),34836:b(6408,[5126,16],4,!1,!1,!0),36226:b(36249,[5124,16],4,!0),36208:b(36249,[5125,16],4,!0),32854:b(6408,[5121,4,32819,2],4,!0,!0),36759:b(6408,[5120,4],4,!1,!0),32856:b(6408,[5121,4],4,!0,!0),36238:b(36249,[5120,4],4,!0),36220:b(36249,[5121,4],4,!0),35907:b(6408,[5121,4],4,!0,!0),35905:b(6407,[5121,3],3,!1,!0)},N=e=>"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext,O=e=>5126===e.type||5131===e.type||36193===e.type||36269===e.type;class S extends Error{constructor(e){super(`WebGL error ${e?": "+e:""}`)}}const I=e=>{throw new S(e)};class G{constructor(e,t,r=e.ARRAY_BUFFER,i=e.STATIC_DRAW){this.gl=e,this.buffer=e.createBuffer()||I("error creating WebGL buffer"),this.target=r,this.mode=i,t&&this.set(t)}bind(){return this.gl.bindBuffer(this.target,this.buffer),!0}unbind(){return this.gl.bindBuffer(this.target,null),!0}release(){return this.buffer&&(this.gl.deleteBuffer(this.buffer),delete this.buffer),!0}set(e,t=this.mode){this.bind(),this.gl.bufferData(this.target,e,t)}setChunk(e,t=0){this.bind(),this.gl.bufferSubData(this.target,t,e)}}const F=(e,t,r=e.ARRAY_BUFFER,i=e.STATIC_DRAW)=>new G(e,t,r,i),L=(e,t,r=e.STATIC_DRAW)=>(t.attribPool?t.attribs=U(e,t.attribPool,void 0,e.ARRAY_BUFFER,r):P(e,t.attribs,r),t.instances&&P(e,t.instances.attribs,r),x(e,t.indices,r),null==t.mode&&(t.mode=e.TRIANGLES),t),P=(e,t,r)=>{if(t)for(let i in t)if(t.hasOwnProperty(i)){const n=t[i];n.buffer?n.data&&n.buffer.set(n.data):n.buffer=new G(e,n.data,e.ARRAY_BUFFER,r)}return t},x=(e,t,r=e.STATIC_DRAW)=>(t&&(t.buffer?t.data&&t.buffer.set(t.data):t.buffer=new G(e,t.data,e.ELEMENT_ARRAY_BUFFER,r)),t),U=(e,t,r,i=e.ARRAY_BUFFER,n=e.STATIC_DRAW)=>{const s=F(e,t.bytes(),i,n),a={};for(let e of r||Object.keys(t.specs)){const r=t.specs[e];a[e]={buffer:s,size:r.size,type:r.type,stride:t.byteStride,offset:r.byteOffset}}return a},B={alpha:!0,antialias:!0,depth:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1,stencil:!1},C=(e,t,r=!0)=>{const i={};if(t)for(let n of t)i[n]=e.getExtension(n),r&&!i[n]&&I(`extension ${n} not available`);return i},D=(e,t,r)=>{const i=window.devicePixelRatio||1;return 1!=i&&(e.style.width=`${t}px`,e.style.height=`${r}px`),e.width=t*i,e.height=r*i,i},M=e=>{if(e)for(let t,r=e.length;--r>=0;)(t=e[r])&&t.bind(r)};class y{constructor(e,t={}){this.gl=e,this.tex=e.createTexture()||I("error creating WebGL texture"),this.configure(t)}configure(e={}){const t=this.gl,i=N(t),n=e.target||this.target||3553,s=e.format||this.format||6408,a=p[s],o=a.format,l=e.type||this.type||a.types[0];let u,c,E;if(!this.target&&(this.target=n),this.format=s,this.type=l,t.bindTexture(this.target,this.tex),void 0!==e.flip&&t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flip?1:0),void 0!==e.premultiply&&t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiply?1:0),void 0!==e.image){const r=e.level||0,i=e.pos||[0,0,0];32879===n?e.width&&e.height&&e.depth&&(e.sub?t.texSubImage3D(n,r,i[0],i[1],i[2],e.width,e.height,e.depth,o,l,e.image):(0===r&&(this.size=[e.width,e.height,e.depth]),t.texImage3D(n,r,s,e.width,e.height,e.depth,0,o,l,e.image))):e.width&&e.height?e.sub?t.texSubImage2D(n,r,i[0],i[1],e.width,e.height,o,l,e.image):(0===r&&(this.size=[e.width,e.height]),t.texImage2D(n,r,s,e.width,e.height,0,o,l,e.image)):e.sub?t.texSubImage2D(n,r,i[0],i[1],o,l,e.image):(null!=e.image&&0==r&&(this.size=[e.image.width,e.image.height]),t.texImage2D(n,r,s,o,l,e.image))}if(e.mipmap&&t.generateMipmap(n),e.filter){const i=e.filter;r.isArray(i)?(u=i[0],c=i[1]):u=c=i,u&&t.texParameteri(n,t.TEXTURE_MIN_FILTER,u),c&&t.texParameteri(n,t.TEXTURE_MAG_FILTER,c)}if(e.wrap){const s=e.wrap;r.isArray(s)?(u=s[0],c=s[1],E=s[2]):u=c=E=s,u&&t.texParameteri(n,t.TEXTURE_WRAP_S,u),c&&t.texParameteri(n,t.TEXTURE_WRAP_T,c),E&&i&&n===t.TEXTURE_3D&&t.texParameteri(n,t.TEXTURE_WRAP_R,E)}if(e.lod){const[r,i]=e.lod;r&&t.texParameteri(n,t.TEXTURE_MIN_LOD,r),i&&t.texParameteri(n,t.TEXTURE_MAX_LOD,i)}if(e.minMaxLevel){const[r,i]=e.minMaxLevel;t.texParameteri(n,t.TEXTURE_BASE_LEVEL,r),t.texParameteri(n,t.TEXTURE_MAX_LEVEL,i)}return!0}bind(e=0){const t=this.gl;return t.activeTexture(t.TEXTURE0+e),t.bindTexture(this.target,this.tex),!0}unbind(e=0){const t=this.gl;return t.activeTexture(t.TEXTURE0+e),t.bindTexture(this.target,null),!0}release(){return!!this.tex&&(this.gl.deleteTexture(this.tex),delete this.tex,delete this.gl,!0)}}const w=(e,t)=>new y(e,t),H=e=>{const t=r.isArray(e)?e:[e];for(let e=0,r=t.length;e<r;e++){const r=t[e],i=r.indices,n=r.shader.gl;r.textures&&M(r.textures),r.shader.prepareState(),r.shader.bind(r),i&&i.buffer?(i.buffer.bind(),r.instances?$(n,r):n.drawElements(r.mode,r.num,i.data instanceof Uint32Array?n.UNSIGNED_INT:n.UNSIGNED_SHORT,0)):r.instances?$(n,r):n.drawArrays(r.mode,0,r.num),r.shader.unbind(null)}},$=(e,t)=>{const r=N(e),i=r?void 0:e.getExtension("ANGLE_instanced_arrays");r||i||I("instancing not supported");const n=t.shader.attribs,s=t.instances.attribs;t.shader.bindAttribs(s);for(let t in s){const a=n[t];if(a){let n=s[t].divisor;n=void 0!==n?n:1,r?e.vertexAttribDivisor(a.loc,n):i.vertexAttribDivisorANGLE(a.loc,n)}}if(t.indices){const n=t.indices.data instanceof Uint32Array?e.UNSIGNED_INT:e.UNSIGNED_SHORT;r?e.drawElementsInstanced(t.mode,t.num,n,0,t.instances.num):i.drawElementsInstancedANGLE(t.mode,t.num,n,0,t.instances.num)}else r?e.drawArraysInstanced(t.mode,0,t.num,t.instances.num):i.drawArraysInstancedANGLE(t.mode,0,t.num,t.instances.num);for(let t in s){const s=n[t];s&&(r?e.vertexAttribDivisor(s.loc,0):i.vertexAttribDivisorANGLE(s.loc,0))}t.shader.unbind(null)};class j{constructor(e,t){this.gl=e,this.buffer=e.createRenderbuffer()||I("error creating RBO"),this.configure(t)}bind(){return this.gl.bindRenderbuffer(this.gl.RENDERBUFFER,this.buffer),!0}unbind(){return this.gl.bindRenderbuffer(this.gl.RENDERBUFFER,null),!0}release(){return this.gl.deleteRenderbuffer(this.buffer),delete this.buffer,!0}configure(e){const t=this.gl;return this.bind(),this.format=e.format||t.DEPTH_COMPONENT16,this.width=e.width,this.height=e.height,t.renderbufferStorage(t.RENDERBUFFER,e.format||t.DEPTH_COMPONENT16,e.width,e.height),this.unbind(),!0}}class X{constructor(e,t){this.gl=e,this.fbo=e.createFramebuffer()||I("error creating FBO"),this.ext=!N(e)&&t&&t.tex&&t.tex.length>1?e.getExtension("WEBGL_draw_buffers")||I("missing WEBGL_draw_buffers ext"):void 0,this.maxAttachments=e.getParameter(36063),t&&this.configure(t)}bind(){return this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this.fbo),!0}unbind(){return this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null),!0}release(){return this.gl.deleteFramebuffer(this.fbo),delete this.fbo,delete this.ext,!0}configure(e){const r=this.gl;if(this.bind(),e.tex){t.assert(e.tex.length<this.maxAttachments,`too many attachments (max. ${this.maxAttachments})`);const i=[];for(let n=0;n<e.tex.length;n++){const s=e.tex[n];t.assert(!(!p[s.format].render&&!p[s.format].renderExt),`texture #${n} has non-renderable format`);const a=36064+n;r.framebufferTexture2D(r.FRAMEBUFFER,a,r.TEXTURE_2D,s.tex,0),i[n]=a}this.ext?this.ext.drawBuffersWEBGL(i):N(r)&&r.drawBuffers(i)}return e.depth&&(e.depth instanceof j?r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,e.depth.buffer):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,e.depth.tex,0)),this.validate()}validate(){const e=this.gl,t=e.checkFramebufferStatus(e.FRAMEBUFFER);switch(t){case e.FRAMEBUFFER_COMPLETE:return!0;case e.FRAMEBUFFER_UNSUPPORTED:I("FBO unsupported");case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:I("FBO incomplete attachment");case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:I("FBO incomplete dimensions");case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:I("FBO incomplete missing attachment");default:return I(`FBO error: ${t}`)}}}const V=(e,t)=>new X(e,t),q={ambientCol:[.1,.1,.1],diffuseCol:[.8,.8,.8],specularCol:[1,1,1]},z={ambientCol:"vec3",diffuseCol:"vec3",specularCol:"vec3"},W=(e={},t={},r=q)=>Object.keys(r).reduce((i,n)=>(!1!==t[n]&&(i[n]=[z[n],e[n]||r[n]]),i),{}),Z=(e,t,r)=>e[r]||t[r].defaultVal||n.IDENT44,k=(e="model")=>(t,r)=>n.normal44([],Z(r,t,e)),Y=(e="model",t="view")=>(r,i)=>n.normal44(null,n.mulM44([],Z(i,r,t),Z(i,r,e)));const K=(e=!0)=>({attribs:Object.assign({position:{data:new Float32Array([-1,-1,1,-1,-1,1,1,1]),size:2}},e?{uv:{data:new Float32Array([0,0,1,0,0,1,1,1]),size:2}}:null),uniforms:{},shader:null,mode:5,num:4}),J={a:"",v:"",u:"",o:""},Q={100:{number:100,attrib:(e,t,i)=>`attribute ${r.isArray(t)?t[0]:t} ${i.a}${e};`,varying:{vs:(e,t,r)=>ee("varying",t,r.v+e),fs:(e,t,r)=>ee("varying",t,r.v+e)},uniform:(e,t,r)=>ee("uniform",t,r.u+e),output:(e,t,i)=>r.isArray(t)?`#define ${i.o}${e} gl_FragData[${t[1]}]`:""},"300 es":{number:300,attrib:(e,t,i)=>r.isArray(t)?`layout(location=${t[1]}) in ${t[0]} ${i.a}${e};`:`in ${t} ${i.a}${e};`,varying:{vs:(e,t,r)=>ee("out",t,r.v+e),fs:(e,t,r)=>ee("in",t,r.v+e)},uniform:(e,t,r)=>ee("uniform",t,r.u+e),output:(e,t,i)=>r.isArray(t)?`layout(location=${t[1]}) out ${t[0]} ${i.o}${e};`:`out ${t} ${i.o}${e};`}},ee=(e,t,i)=>{const n=r.isArray(t)?t[0]:t;return n.indexOf("[]")>0?`${e} ${n.replace("[]","")} ${i}[${t[1]}];`:`${e} ${n} ${i};`},te=(e,t,r="")=>{let i=">=";return t||(t=r,r=null,i="<"),`#if __VERSION__ ${i} ${e}\n${t}${r?`\n#else\n${r}`:""}\n#endif`},re=te(300,"","#define texture texture2D"),ie="#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp int;\nprecision highp float;\n#else\nprecision mediump int;\nprecision mediump float;\n#endif\n#ifndef PI\n#define PI 3.141592653589793\n#endif\n#ifndef TAU\n#define TAU 6.283185307179586\n#endif\n#ifndef HALF_PI\n#define HALF_PI 1.570796326794896\n#endif\n",ne=e=>(t,r,i=0)=>{let n;return s=>{(s=void 0===s?i:s)!==n&&(t["uniform1"+e](r,s),n=s)}},se=(e,t)=>(r,i,n=t)=>{let s=[];return t=>{t=void 0===t?n:t,u.equivArrayLike(s,t)||(r["uniform"+e](i,t),s=[...t])}},ae=(e,t)=>(r,i,n=t)=>{let s=[];return t=>{t=void 0===t?n:t,u.equivArrayLike(s,t)||(r["uniformMatrix"+e](i,!1,t),s=[...t])}},oe=[0],le={bool:ne("i"),float:ne("f"),int:ne("i"),uint:ne("ui"),bvec2:se("2iv",c.ZERO2),bvec3:se("3iv",c.ZERO3),bvec4:se("4iv",c.ZERO4),ivec2:se("2iv",c.ZERO2),ivec3:se("3iv",c.ZERO3),ivec4:se("4iv",c.ZERO4),vec2:se("2fv",c.ZERO2),vec3:se("3fv",c.ZERO3),vec4:se("4fv",c.ZERO4),mat2:ae("2fv",n.IDENT22),mat3:ae("3fv",n.IDENT33),mat4:ae("4fv",n.IDENT44),sampler2D:ne("i"),sampler2DShadow:ne("i"),sampler3D:ne("i"),samplerCube:ne("i"),samplerCubeShadow:ne("i"),"bool[]":se("1iv",oe),"float[]":se("1fv",oe),"int[]":se("1iv",oe),"uint[]":se("1uiv",oe),"bvec2[]":se("2iv",c.ZERO2),"bvec3[]":se("3iv",c.ZERO3),"bvec4[]":se("4iv",c.ZERO4),"ivec2[]":se("2iv",c.ZERO2),"ivec3[]":se("3iv",c.ZERO3),"ivec4[]":se("4iv",c.ZERO4),"vec2[]":se("2fv",c.ZERO2),"vec3[]":se("3fv",c.ZERO3),"vec4[]":se("4fv",c.ZERO4),"mat2[]":ae("2fv",c.ZERO2),"mat3[]":ae("3fv",c.ZERO3),"mat4[]":ae("4fv",c.ZERO4),"sampler2D[]":se("1iv",oe),"sampler2DShadow[]":se("1iv",oe),"sampler3D[]":se("1iv",oe),"samplerCube[]":se("1iv",oe),"samplerCubeShadow[]":se("1iv",oe)},ue=/ERROR: \d+:(\d+): (.*)/;class ce{constructor(e,t,r,i,n){this.gl=e,this.program=t,this.attribs=r,this.uniforms=i,this.state=n||{}}bind(e){return!!this.program&&(this.gl.useProgram(this.program),this.bindAttribs(e.attribs),this.bindUniforms(e.uniforms),!0)}unbind(){return this.gl.useProgram(null),!0}release(){return!!this.program&&(this.gl.deleteProgram(this.program),delete this.program,!0)}bindAttribs(t){const r=this.gl;let i;for(let n in t)if(i=this.attribs[n]){const e=t[n];e.buffer.bind(),r.enableVertexAttribArray(i.loc),r.vertexAttribPointer(i.loc,e.size||3,e.type||r.FLOAT,e.normalized||!1,e.stride||0,e.offset||0)}else e.LOGGER.warn(`unknown attrib: ${n}`)}bindUniforms(t={}){const i=this.uniforms;for(let n in t){const s=i[n];if(s){let e=t[n];e=r.isFunction(e)?e(i,t):r.implementsFunction(e,"deref")?e.deref():e,s.setter(e)}else e.LOGGER.warn(`unknown uniform: ${n}`)}for(let e in i)if(i.hasOwnProperty(e)&&(!t||!r.existsAndNotNull(t[e]))){const r=i[e],n=r.defaultFn?r.defaultFn(i,t):r.defaultVal;r.setter(n)}}prepareState(e=this.state){const t=this.gl;void 0!==e.depth&&this.setState(t.DEPTH_TEST,e.depth),void 0!==e.cull&&(this.setState(t.CULL_FACE,e.cull),e.cullMode&&t.cullFace(e.cullMode)),void 0!==e.blend&&(this.setState(t.BLEND,e.blend),e.blendFn&&t.blendFunc(e.blendFn[0],e.blendFn[1]),void 0!==e.blendEq&&t.blendEquation(e.blendEq)),void 0!==e.stencil&&(this.setState(t.STENCIL_TEST,e.stencil),e.stencilFn&&t.stencilFunc(e.stencilFn[0],e.stencilFn[1],e.stencilFn[2]),e.stencilOp&&t.stencilOp(e.stencilOp[0],e.stencilOp[1],e.stencilOp[2]),void 0!==e.stencilMask&&t.stencilMask(e.stencilMask))}setState(e,t){t?this.gl.enable(e):this.gl.disable(e)}}const Ee=(e,t)=>{const i=N(e)?"300 es":"100",n=r.isFunction(t.vs)?_e(t,"vs",i):he(t,"vs",i),s=r.isFunction(t.fs)?_e(t,"fs",i):he(t,"fs",i);console.log(n),console.log(s),fe(e,t.ext);const a=ge(e,e.VERTEX_SHADER,n),o=ge(e,e.FRAGMENT_SHADER,s),l=e.createProgram()||I("error creating shader program");if(e.attachShader(l,a),e.attachShader(l,o),e.linkProgram(l),e.getProgramParameter(l,e.LINK_STATUS)){const r=me(e,l,t.attribs),i=Te(e,l,t.uniforms);return e.deleteShader(a),e.deleteShader(o),new ce(e,l,r,i,t.state)}throw new Error(`Error linking shader: ${e.getProgramInfoLog(l)}`)},Re=(e,t,r)=>{let i=[];for(let n in e)e.hasOwnProperty(n)&&i.push(t(n,e[n],r));return i.push(""),i.join("\n")},de=(e,t,i)=>{const n=_[e],s="300 es"===i;return n&&(!s&&n.gl||s&&n.gl2)?`#extension ${n&&n.alias||e} : ${r.isBoolean(t)?t?"enable":"disable":t}\n`:""},fe=(e,t)=>{if(t)for(let r in t){const i=t[r];!0!==i&&"require"!==i||C(e,[r],"require"===i)}},_e=(e,t,i)=>{let n="";if(n+=e.pre?e.replacePrelude?e.pre:e.pre+"\n"+ie:ie,e.ext)for(let t in e.ext)n+=de(t,e.ext[t],i);const u={},c={},E={},R={};if(e.uniforms)for(let t in e.uniforms){const i=e.uniforms[t];R[t]=r.isArray(i)?i[0].indexOf("[]")>0?o.uniform(i[0],t,{num:i[1]}):o.uniform(i[0],t):o.uniform(i,t)}if("vs"===t){for(let t in e.attribs){const i=e.attribs[t];u[t]=r.isArray(i)?o.input(i[0],t,{loc:i[1]}):o.input(i,t)}if(e.varying)for(let t in e.varying){const i=e.varying[t];c[t]=r.isArray(i)?o.output(i[0],t,{num:i[1]}):o.output(i,t)}}else{if(e.varying)for(let t in e.varying){const i=e.varying[t];u[t]=r.isArray(i)?o.input(i[0],t,{num:i[1]}):o.input(i,t)}const t=e.outputs||h;if(i>="300 es")for(let e in t){const i=t[e];c[e]=r.isArray(i)?o.output(i[0],e,{loc:i[1]}):o.output(i,e)}else for(let e in t){const s=t[e];r.isArray(s)&&"vec4"===s[0]?(n+=`#define ${e} gl_FragData[${s[1]}]\n`,E[e]=o.sym("vec4",e)):a.unsupported(`GLSL ${i} doesn't support output vars`)}}const d=l.targetGLSL({type:t,version:i,prelude:n});return d(o.program([...s.vals(R),...s.vals(u),...s.vals(c),...e[t](d,R,u,Object.assign(Object.assign({},c),E))]))+(e.post?"\n"+e.post:"")},he=(e,t,r)=>{const i=Q[r],n=Object.assign(Object.assign({},J),e.declPrefixes),s="vs"===t;let a="";if(a+=`#version ${r}\n`,a+=e.pre?e.replacePrelude?e.pre:e.pre+"\n"+ie:ie,e.ext)for(let t in e.ext)a+=de(t,e.ext[t],r);return!1!==e.generateDecls&&(a+=s?Re(e.attribs,i.attrib,n):Re(e.outputs||h,i.output,n),a+=Re(e.varying,i.varying[t],n),a+=Re(e.uniforms,i.uniform,n)),a+=e[t],e.post&&(a+="\n"+e.post),a},ge=(e,t,r)=>{const i=e.createShader(t)||I("error creating shader");return e.shaderSource(i,r),e.compileShader(i),e.getShaderParameter(i,e.COMPILE_STATUS)?i:Ae(e,i,r)},Ae=(e,t,i)=>{const n=i.split("\n"),s=e.getShaderInfoLog(t).split("\n").map(e=>{const t=ue.exec(e),r=t?t[1]:null;if(r)return`line ${r}: ${t[2]}\n${n[parseInt(r)-1]}`}).filter(r.existsAndNotNull).join("\n");return I(`Error compiling shader:\n${s}`)},me=(e,t,i)=>{const n={};for(let s in i){const a=i[s],[o,l]=r.isArray(a)?a:[a,null],u=s;null!=l?(e.bindAttribLocation(t,l,u),n[s]={type:o,loc:l}):n[s]={type:o,loc:e.getAttribLocation(t,u)}}return n},Te=(t,i,n={})=>{const s={};for(let a in n){const o=n[a];let l,u,c,E,R;r.isArray(o)?([l,u,c]=o,E=l.indexOf("[]")<0?u:c,r.isFunction(E)&&(R=E,E=void 0)):l=o;const d=t.getUniformLocation(i,a);if(null!=d){const e=le[l];e?s[a]={loc:d,setter:e(t,d,E),defaultFn:R,defaultVal:E,type:l}:I(`invalid uniform type: ${l}`)}else e.LOGGER.warn(`unknown uniform: ${a}`)}return s},ve=(e,t,r)=>[o.defMain(()=>[o.assign(e.gl_Position,o.vec4(r.position,o.FLOAT0,o.FLOAT1))])],be=(e,t,r,i)=>[o.defMain(()=>[o.assign(i.v_uv,r.uv),o.assign(e.gl_Position,o.vec4(r.position,o.FLOAT0,o.FLOAT1))])],pe=(e,t,r,i)=>[o.defMain(()=>[o.assign(i.fragColor,o.$xy(e.gl_FragCoord))])],Ne=(e,t,r,i)=>[o.defMain(()=>[o.assign(i.fragColor,o.texture(t.tex,r.v_uv))])],Oe={vs:ve,fs:pe,attribs:{position:"vec2"},varying:{},uniforms:{},state:{depth:!1},ext:{}},Se={vs:be,fs:Ne,attribs:{position:"vec2",uv:"vec2"},varying:{v_uv:"vec2"},uniforms:{tex:"sampler2D"},state:{depth:!1},ext:{}},Ie=(e,t,r="position")=>e.instancePos?o.add(t[r],t[e.instancePos]):t[r],Ge=(e,t,r)=>e.instanceColor?o.mul(t[e.instanceColor],r):e.color?o.mul(t[e.color],r):r;e.ALIAS_TEXTURE=re,e.BLEND_ADD=[770,772],e.BLEND_NORMAL=[770,771],e.DEFAULT_MATERIAL=q,e.DEFAULT_OUTPUT=h,e.EXPORT_FRAGCOL=(e="col",t="o_fragColor")=>te(300,`${t}=${e};`,`gl_FragColor=${e};`),e.FBO=X,e.FX_SHADER_SPEC=Oe,e.FX_SHADER_SPEC_UV=Se,e.GLSL_HEADER=ie,e.GL_EXT_INFO=_,e.LAMBERT=(e={})=>({vs:(t,r,i,n)=>[o.defMain(()=>[e.uv?o.assign(n.vuv,i[e.uv]):null,o.assign(n.vcolor,Ge(e,i,r.diffuseCol)),o.assign(n.vnormal,E.surfaceNormal(i.normal,r.normalMat)),o.assign(t.gl_Position,E.transformMVP(Ie(e,i),r.model,r.view,r.proj))])],fs:(t,r,i,n)=>[o.defMain(()=>[o.assign(n.fragColor,o.vec4(E.diffuseLighting((!1!==e.bidir?E.halfLambert:E.lambert)(o.normalize(i.vnormal),r.lightDir),e.uv?o.mul(o.$(o.texture(r.tex,i.vuv),"xyz"),i.vcolor):i.vcolor,r.lightCol,r.ambientCol),1))])],attribs:Object.assign(Object.assign(Object.assign(Object.assign({position:"vec3",normal:"vec3"},e.uv?{[e.uv]:"vec2"}:null),e.color&&!e.instanceColor?{[e.color]:"vec3"}:null),e.instancePos?{[e.instancePos]:"vec3"}:null),e.instanceColor?{[e.instanceColor]:"vec3"}:null),varying:Object.assign({vcolor:"vec3",vnormal:"vec3"},e.uv?{vuv:"vec2"}:null),uniforms:Object.assign(Object.assign({model:"mat4",view:"mat4",proj:"mat4",normalMat:["mat4",Y()],lightDir:["vec3",[0,1,0]],lightCol:["vec3",[1,1,1]]},W(Object.assign({diffuseCol:[1,1,1]},e.material),{specularCol:!1})),e.uv?{tex:"sampler2D"}:null),state:Object.assign({depth:!0,cull:!0},e.state)}),e.NO_PREFIXES=J,e.PASSTHROUGH_FS=pe,e.PASSTHROUGH_FS_UV=Ne,e.PASSTHROUGH_VS=ve,e.PASSTHROUGH_VS_UV=be,e.PHONG=(e={})=>({vs:(t,r,i,n)=>[o.defMain(()=>{let s;return[s=o.sym(o.mul(r.model,o.vec4(Ie(e,i),1))),o.assign(n.vnormal,E.surfaceNormal(i.normal,r.normalMat)),o.assign(n.vlight,o.sub(r.lightPos,o.$(s,"xyz"))),o.assign(n.veye,o.sub(r.eyePos,o.$(s,"xyz"))),o.assign(n.vcolor,Ge(e,i,r.diffuseCol)),o.assign(t.gl_Position,o.mul(o.mul(r.proj,r.view),s))]})],fs:(e,t,r,i)=>[o.defMain(()=>{let e,n,s,a;return[e=o.sym(o.normalize(r.vnormal)),n=o.sym(o.normalize(r.vlight)),s=o.sym(o.max(o.dot(e,n),o.FLOAT0)),a=o.sym(o.ternary(o.gt(s,o.FLOAT0),o.pow(o.dot(e,o.normalize(o.add(n,o.normalize(r.veye)))),t.shininess),o.FLOAT0)),o.assign(i.fragColor,o.vec4(o.add(E.diffuseLighting(s,r.vcolor,t.lightCol,t.ambientCol),o.mul(t.specularCol,a)),1))]})],attribs:Object.assign(Object.assign(Object.assign({position:"vec3",normal:"vec3"},e.color&&!e.instanceColor?{[e.color]:"vec3"}:null),e.instancePos?{[e.instancePos]:"vec3"}:null),e.instanceColor?{[e.instanceColor]:"vec3"}:null),varying:{vnormal:"vec3",veye:"vec3",vlight:"vec3",vcolor:"vec3"},uniforms:Object.assign({model:"mat4",normalMat:["mat4",k()],view:"mat4",proj:"mat4",shininess:["float",32],eyePos:"vec3",lightPos:["vec3",[0,0,2]],lightCol:["vec3",[1,1,1]]},W(e.material)),state:Object.assign({depth:!0,cull:!0},e.state)}),e.PREFIXES={a:"a_",v:"v_",u:"u_",o:"o_"},e.RBO=j,e.SYNTAX=Q,e.Shader=ce,e.TEX_FORMATS=p,e.Texture=y,e.VERSION_CHECK=te,e.WebGLArrayBuffer=G,e.WebGLError=S,e.adaptDPI=D,e.autoNormalMatrix1=k,e.autoNormalMatrix2=Y,e.bindTextures=M,e.buffer=F,e.checkerboard=e=>{const t=(e=Object.assign({size:16,col1:4294967295,col2:4278190080,cornerCols:[4294901760,4278255360,4278190335,4294967040]},e)).size,r=R.ARGB8888.toABGR(e.col1),i=R.ARGB8888.toABGR(e.col2),{canvas:n,ctx:s,img:a,pixels:o}=R.canvasPixels(t);for(let e=0,n=0;e<t;e++)for(let s=0;s<t;s++,n++)o[n]=1&e^1&s?r:i;if(e.corners){const r=e.cornerCols.map(R.ARGB8888.toABGR);o[0]=r[0],o[t-1]=r[1],o[o.length-t]=r[2],o[o.length-1]=r[3]}return s.putImageData(a,0,0),n},e.colorAttrib=Ge,e.compileAttribPool=U,e.compileIndices=x,e.compileModel=L,e.compileShader=ge,e.compileVAO=(e,t)=>{if(t.shader){const r=N(e),i=r?null:e.getExtension("OES_vertex_array_object");if(r||i){let n;return r?(n=e.createVertexArray(),e.bindVertexArray(n)):(n=i.createVertexArrayOES(),i.bindVertexArrayOES(n)),n&&I("error creating VAO"),t.shader.bindAttribs(t.attribs),t.indices&&t.indices.buffer.bind(),t.shader.unbind(null),r?e.bindVertexArray(null):i.bindVertexArrayOES(null),n}}},e.cube=e=>{const t=(e=Object.assign({size:1,normal:!0,uv:!0},e)).size,r={attribs:{position:{data:new Float32Array([t,t,-t,t,t,t,t,-t,t,t,-t,-t,-t,t,t,-t,t,-t,-t,-t,-t,-t,-t,t,-t,t,t,t,t,t,t,t,-t,-t,t,-t,-t,-t,-t,t,-t,-t,t,-t,t,-t,-t,t,t,t,t,-t,t,t,-t,-t,t,t,-t,t,-t,t,-t,t,t,-t,t,-t,-t,-t,-t,-t])}},indices:{data:new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23])},uniforms:{},shader:null,num:36};return e.normal&&(r.attribs.normal={data:new Float32Array([1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1])}),e.uv&&(r.attribs.uv={data:new Float32Array([1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1]),size:2}),r},e.cubeMap=(e,t,r={})=>{const n=new y(e,{target:e.TEXTURE_CUBE_MAP}),s=i.withoutKeysObj(r,["target","image","filter","mipmap"]);for(let r=0;r<6;r++)s.target=e.TEXTURE_CUBE_MAP_POSITIVE_X+r,s.image=t[r],n.configure(s);return n.configure({filter:r.filter,mipmap:r.mipmap}),n},e.defMaterial=W,e.draw=H,e.error=I,e.fbo=V,e.floatTexture=(e,t,r,i,n,s)=>new y(e,{filter:e.NEAREST,wrap:e.CLAMP_TO_EDGE,format:n||(N(e)?34836:6408),type:s||e.FLOAT,image:t,width:r,height:i}),e.getExtensions=C,e.glCanvas=(e={})=>{const t=e.canvas?r.isString(e.canvas)?document.getElementById(e.canvas):e.canvas:document.createElement("canvas");e.width&&(t.width=e.width),e.height&&(t.height=e.height),!1!==e.autoScale&&D(t,t.width,t.height),e.parent&&e.parent.appendChild(t);const i=t.getContext(2===e.version?"webgl2":"webgl",Object.assign(Object.assign({},B),e.opts));return i||I("WebGL unavailable"),e.onContextLost&&t.addEventListener("webglcontextlost",e.onContextLost),{canvas:t,gl:i,ext:C(i,e.ext)}},e.isFloatTexture=O,e.isGL2Context=N,e.multipass=e=>{const r=e.gl,i=N(r),n=e.passes.length;t.assert(n>0,"require at least one shader pass");const a=Object.keys(e.textures).reduce((t,i)=>(t[i]=w(r,Object.assign({width:e.width,height:e.height,filter:r.NEAREST,wrap:r.CLAMP_TO_EDGE,image:null},e.textures[i])),t),{}),o=L(r,K(!1)),l=e.passes.map(e=>{const t=e.model?L(r,e.model):Object.assign({},o);return t.shader=(e=>{const t=e.inputs.length,n=e.outputs.length,o={},l={vs:e.vs||ve,fs:e.fs,attribs:e.attribs||{position:"vec2"},varying:e.varying,uniforms:Object.assign(Object.assign({},e.uniforms),t?{inputs:["sampler2D[]",t,[...s.range(t)]]}:null),outputs:n?s.transduce(s.map(e=>[`output${e}`,["vec4",e]]),s.assocObj(),s.range(n)):void 0,state:e.state,pre:e.pre,post:e.post,replacePrelude:e.replacePrelude,generateDecls:e.generateDecls,ext:o},u=s.some(e=>O(a[e]),e.inputs),c=s.some(e=>O(a[e]),e.outputs);return i||(u&&(o.OES_texture_float="require"),n>1&&(o.WEBGL_draw_buffers="require")),c&&(o[i?"EXT_color_buffer_float":"WEBGL_color_buffer_float"]="require"),Ee(r,l)})(e),t.uniforms=Object.assign({},e.uniformVals),e.inputs.length>0&&(t.textures=e.inputs.map(e=>a[e])),t}),u=!e.passes[n-1].outputs.length,c=(u?e.passes.slice(0,n-1):e.passes).map(e=>V(r,{tex:e.outputs.map(e=>a[e])})),E=(t,i)=>{const n=e.passes[t],s=l[t],o=s.shader,u=n.outputs.length?a[n.outputs[0]].size:[r.drawingBufferWidth,r.drawingBufferHeight];o.uniforms.resolution&&(s.uniforms.resolution=u),o.uniforms.time&&(s.uniforms.time=i),r.viewport(0,0,u[0],u[1]),H(s)},R=e=>{for(let t=0;t<c.length;t++)c[t].bind(),E(t,e),c[t].unbind();u&&E(n-1,e)},d=()=>{R(.001*(Date.now()-h)),f&&(_=requestAnimationFrame(d))};let f,_,h=Date.now();return{start(){h=Date.now(),f=!0,_=requestAnimationFrame(d)},stop(){f&&(f=!1,cancelAnimationFrame(_))},update(e){R(e)},passes:e.passes,fbos:c,models:l,textures:a}},e.positionAttrib=Ie,e.prepareShaderSource=he,e.quad=K,e.rbo=(e,t)=>new j(e,t),e.readPixels=(e,t,r,i,n,s,a,o)=>(e.readPixels(t,r,i,n,s,a,o),o),e.readTexture=(e,t,r,i,n)=>{const s=new X(e,{tex:[t]});return e.readPixels(0,0,t.size[0],t.size[1],r,i,n),s.unbind(),s.release(),n},e.screen2d=function(e,t){return r.isNumber(e)?n.ortho([],0,e,t,0,-1,1):n.ortho([],0,e.drawingBufferWidth,e.drawingBufferHeight,0,-1,1)},e.setLogger=t=>e.LOGGER=t,e.shader=Ee,e.shaderSourceFromAST=_e,e.stripes=e=>{const t=(e=Object.assign({size:16,col1:4294967295,col2:4278190080},e)).size,r=R.ARGB8888.toABGR(e.col1),i=R.ARGB8888.toABGR(e.col2),{canvas:n,ctx:s,img:a,pixels:o}=e.horizontal?R.canvasPixels(1,t):R.canvasPixels(t,1);for(let e=t;--e>=0;)o[e]=1&e?r:i;return s.putImageData(a,0,0),n},e.texture=w,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@thi.ng/api"),require("@thi.ng/checks"),require("@thi.ng/associative"),require("@thi.ng/matrices"),require("@thi.ng/transducers"),require("@thi.ng/errors"),require("@thi.ng/shader-ast"),require("@thi.ng/shader-ast-glsl"),require("@thi.ng/equiv"),require("@thi.ng/vectors"),require("@thi.ng/shader-ast-stdlib"),require("@thi.ng/pixel")):"function"==typeof define&&define.amd?define(["exports","@thi.ng/api","@thi.ng/checks","@thi.ng/associative","@thi.ng/matrices","@thi.ng/transducers","@thi.ng/errors","@thi.ng/shader-ast","@thi.ng/shader-ast-glsl","@thi.ng/equiv","@thi.ng/vectors","@thi.ng/shader-ast-stdlib","@thi.ng/pixel"],t):t(((e=e||self).thi=e.thi||{},e.thi.ng=e.thi.ng||{},e.thi.ng.webgl={}),e.thi.ng.api,e.thi.ng.checks,e.thi.ng.associative,e.thi.ng.matrices,e.thi.ng.transducers,e.thi.ng.errors,e.thi.ng.shaderAst,e.thi.ng.shaderAstGlsl,e.thi.ng.equiv,e.thi.ng.vectors,e.thi.ng.shaderAstStdlib,e.thi.ng.pixel)}(this,(function(e,t,r,i,n,s,a,o,l,u,c,E,R){"use strict";var d,_;(d=e.Blend||(e.Blend={}))[d.ZERO=0]="ZERO",d[d.ONE=1]="ONE",d[d.SRC_COLOR=768]="SRC_COLOR",d[d.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",d[d.DST_COLOR=774]="DST_COLOR",d[d.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",d[d.SRC_ALPHA=770]="SRC_ALPHA",d[d.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",d[d.DST_ALPHA=772]="DST_ALPHA",d[d.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",d[d.CONSTANT_COLOR=32769]="CONSTANT_COLOR",d[d.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",d[d.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",d[d.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",d[d.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",(_=e.BlendEquation||(e.BlendEquation={}))[_.FUNC_ADD=32774]="FUNC_ADD",_[_.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",_[_.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",_[_.MAX=32776]="MAX",_[_.MIN=32775]="MIN";const f={WEBGL_draw_buffers:{gl:!0,alias:"GL_EXT_draw_buffers"},OES_standard_derivatives:{gl:!0,alias:"GL_OES_standard_derivatives"}};e.LOGGER=t.NULL_LOGGER;const h={fragColor:["vec4",0]};var g,A,m,T,v;(g=e.TextureFormat||(e.TextureFormat={}))[g.ALPHA=6406]="ALPHA",g[g.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",g[g.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",g[g.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",g[g.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",g[g.DEPTH_STENCIL=34041]="DEPTH_STENCIL",g[g.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",g[g.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",g[g.LUMINANCE=6409]="LUMINANCE",g[g.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",g[g.R11F_G11F_B10F=35898]="R11F_G11F_B10F",g[g.R16F=33325]="R16F",g[g.R16I=33331]="R16I",g[g.R16UI=33332]="R16UI",g[g.R32F=33326]="R32F",g[g.R32I=33333]="R32I",g[g.R32UI=33334]="R32UI",g[g.R8=33321]="R8",g[g.R8_SNORM=36756]="R8_SNORM",g[g.R8I=33329]="R8I",g[g.R8UI=33330]="R8UI",g[g.RED=6403]="RED",g[g.RED_INTEGER=36244]="RED_INTEGER",g[g.RG=33319]="RG",g[g.RG_INTEGER=33320]="RG_INTEGER",g[g.RG16F=33327]="RG16F",g[g.RG16I=33337]="RG16I",g[g.RG16UI=33338]="RG16UI",g[g.RG32F=33328]="RG32F",g[g.RG32I=33339]="RG32I",g[g.RG32UI=33340]="RG32UI",g[g.RG8=33323]="RG8",g[g.RG8_SNORM=36757]="RG8_SNORM",g[g.RG8I=33335]="RG8I",g[g.RG8UI=33336]="RG8UI",g[g.RGB=6407]="RGB",g[g.RGB_INTEGER=36248]="RGB_INTEGER",g[g.RGB10_A2=32857]="RGB10_A2",g[g.RGB10_A2UI=36975]="RGB10_A2UI",g[g.RGB16F=34843]="RGB16F",g[g.RGB16I=36233]="RGB16I",g[g.RGB16UI=36215]="RGB16UI",g[g.RGB32F=34837]="RGB32F",g[g.RGB32I=36227]="RGB32I",g[g.RGB32UI=36209]="RGB32UI",g[g.RGB5_A1=32855]="RGB5_A1",g[g.RGB565=36194]="RGB565",g[g.RGB8=32849]="RGB8",g[g.RGB8_SNORM=36758]="RGB8_SNORM",g[g.RGB8I=36239]="RGB8I",g[g.RGB8UI=36221]="RGB8UI",g[g.RGB9_E5=35901]="RGB9_E5",g[g.RGBA=6408]="RGBA",g[g.RGBA_INTEGER=36249]="RGBA_INTEGER",g[g.RGBA16F=34842]="RGBA16F",g[g.RGBA16I=36232]="RGBA16I",g[g.RGBA16UI=36214]="RGBA16UI",g[g.RGBA32F=34836]="RGBA32F",g[g.RGBA32I=36226]="RGBA32I",g[g.RGBA32UI=36208]="RGBA32UI",g[g.RGBA4=32854]="RGBA4",g[g.RGBA8=32856]="RGBA8",g[g.RGBA8_SNORM=36759]="RGBA8_SNORM",g[g.RGBA8I=36238]="RGBA8I",g[g.RGBA8UI=36220]="RGBA8UI",g[g.SRGB8=35905]="SRGB8",g[g.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",(A=e.TextureType||(e.TextureType={}))[A.BYTE=5120]="BYTE",A[A.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",A[A.SHORT=5122]="SHORT",A[A.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",A[A.INT=5124]="INT",A[A.UNSIGNED_INT=5125]="UNSIGNED_INT",A[A.FLOAT=5126]="FLOAT",A[A.HALF_FLOAT=5131]="HALF_FLOAT",A[A.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",A[A.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",A[A.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",A[A.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",A[A.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",A[A.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",A[A.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",A[A.HALF_FLOAT_OES=36193]="HALF_FLOAT_OES",A[A.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",(m=e.TextureTarget||(e.TextureTarget={}))[m.TEXTURE_2D=3553]="TEXTURE_2D",m[m.TEXTURE_3D=32879]="TEXTURE_3D",m[m.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",m[m.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",(T=e.TextureFilter||(e.TextureFilter={}))[T.LINEAR=9729]="LINEAR",T[T.NEAREST=9728]="NEAREST",T[T.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",T[T.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",T[T.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",T[T.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",(v=e.TextureRepeat||(e.TextureRepeat={}))[v.REPEAT=10497]="REPEAT",v[v.CLAMP=33071]="CLAMP",v[v.REPEAT_MIRROR=33648]="REPEAT_MIRROR";const b=(e,t,r,i=!1,n=!1,s=i)=>({format:e,types:t,render:i,renderExt:s,filter:n,num:r}),p={6406:b(6406,[5121,1,5131,2,36193,2,5126,4],1,!0,!0),6402:b(6402,[5123,2,5125,4],1,!0),33189:b(6402,[5123,2,5125,4],1,!0),33190:b(6402,[5125,4],1,!0),36012:b(6402,[5126,4],1,!0),34041:b(34041,[34042,4],1,!0),35056:b(34041,[34042,4],1,!0),36013:b(34041,[36269,4],1,!0),6410:b(6410,[5121,2,5131,4,36193,4,5126,8],2,!0,!0),6409:b(6409,[5121,1,5131,2,36193,2,5126,4],1,!0,!0),35898:b(6407,[5126,12,5131,6,35899,4],3,!1,!0,!0),33325:b(6403,[5126,4,5131,2],1,!1,!0,!0),33331:b(36244,[5122,2],1,!0),33332:b(36244,[5123,2],1,!0),33326:b(6403,[5126,4],1,!1,!1,!0),33333:b(36244,[5124,4],1,!0),33334:b(36244,[5125,4],1,!0),36756:b(6403,[5120,1],1,!1,!0),33321:b(6403,[5121,1],1,!0,!0),33329:b(36244,[5120,1],1,!0),33330:b(36244,[5121,1],1,!0),33327:b(33319,[5126,8,5131,4],2,!1,!0,!0),33337:b(33320,[5122,4],2,!0),33338:b(33320,[5123,4],2,!0),33328:b(33319,[5126,8],2,!1,!1,!0),33339:b(33320,[5124,8],2,!0),33340:b(33320,[5125,8],2,!0),36757:b(33319,[5120,2],2,!1,!0),33323:b(33319,[5121,2],2,!0,!0),33335:b(33320,[5120,2],2,!0),33336:b(33320,[5121,2],2,!0),6407:b(6407,[5121,3,5131,6,36193,6,5126,12,33635,2],3,!0,!0),32857:b(6408,[33640,4],4,!0,!0),36975:b(36249,[33640,4],4,!0),34843:b(6407,[5126,12,5131,6],3,!1,!0),36233:b(36248,[5122,6],3),36215:b(36248,[5123,6],3),34837:b(6407,[5126,12],3),36227:b(36248,[5124,12],3),36209:b(36248,[5125,12],3),32855:b(6408,[5121,4,32820,2,33640,4],4,!0,!0),36194:b(6407,[5121,3,33635,2],3,!0,!0),36758:b(6407,[5120,3],3,!1,!0),32849:b(6407,[5121,3],3,!0,!0),36239:b(36248,[5120,3],3),36221:b(36248,[5121,3],3),35901:b(6407,[5126,12,5131,6,35902,4],3,!1,!0),6408:b(6408,[5121,4,5131,8,36193,8,5126,16,32819,2,32820,2],4,!0,!0),34842:b(6408,[5126,16,5131,8],4,!1,!0,!0),36232:b(36249,[5122,8],4,!0),36214:b(36249,[5123,8],4,!0),34836:b(6408,[5126,16],4,!1,!1,!0),36226:b(36249,[5124,16],4,!0),36208:b(36249,[5125,16],4,!0),32854:b(6408,[5121,4,32819,2],4,!0,!0),36759:b(6408,[5120,4],4,!1,!0),32856:b(6408,[5121,4],4,!0,!0),36238:b(36249,[5120,4],4,!0),36220:b(36249,[5121,4],4,!0),35907:b(6408,[5121,4],4,!0,!0),35905:b(6407,[5121,3],3,!1,!0)},N=e=>"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext,O=e=>5126===e.type||5131===e.type||36193===e.type||36269===e.type;class S extends Error{constructor(e){super(`WebGL error ${e?": "+e:""}`)}}const I=e=>{throw new S(e)};class G{constructor(e,t,r=e.ARRAY_BUFFER,i=e.STATIC_DRAW){this.gl=e,this.buffer=e.createBuffer()||I("error creating WebGL buffer"),this.target=r,this.mode=i,t&&this.set(t)}bind(){return this.gl.bindBuffer(this.target,this.buffer),!0}unbind(){return this.gl.bindBuffer(this.target,null),!0}release(){return this.buffer&&(this.gl.deleteBuffer(this.buffer),delete this.buffer),!0}set(e,t=this.mode){this.bind(),this.gl.bufferData(this.target,e,t)}setChunk(e,t=0){this.bind(),this.gl.bufferSubData(this.target,t,e)}}const F=(e,t,r=e.ARRAY_BUFFER,i=e.STATIC_DRAW)=>new G(e,t,r,i),L=(e,t,r=e.STATIC_DRAW)=>(t.attribPool?t.attribs=B(e,t.attribPool,void 0,e.ARRAY_BUFFER,r):x(e,t.attribs,r),t.instances&&x(e,t.instances.attribs,r),U(e,t.indices,r),null==t.mode&&(t.mode=e.TRIANGLES),t),P=(e,t,r,i)=>{t.buffer?t.data&&t.buffer.set(t.data):t.buffer=new G(e,t.data,r,i)},x=(e,t,r)=>{if(t)for(let i in t)P(e,t[i],e.ARRAY_BUFFER,r);return t},U=(e,t,r=e.STATIC_DRAW)=>(t&&P(e,t,e.ELEMENT_ARRAY_BUFFER,r),t),B=(e,t,r,i=e.ARRAY_BUFFER,n=e.STATIC_DRAW)=>{const s=F(e,t.bytes(),i,n),a={};for(let e of r||Object.keys(t.specs)){const r=t.specs[e];a[e]={buffer:s,size:r.size,type:r.type,stride:t.byteStride,offset:r.byteOffset}}return a},C={alpha:!0,antialias:!0,depth:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1,stencil:!1},D=(e,t,r=!0)=>{const i={};if(t)for(let n of t)i[n]=e.getExtension(n),r&&!i[n]&&I(`extension ${n} not available`);return i},M=(e,t,r)=>{const i=window.devicePixelRatio||1;return 1!=i&&(e.style.width=`${t}px`,e.style.height=`${r}px`),e.width=t*i,e.height=r*i,i},y=e=>{if(e)for(let t,r=e.length;--r>=0;)(t=e[r])&&t.bind(r)};class w{constructor(e,t={}){this.gl=e,this.tex=e.createTexture()||I("error creating WebGL texture"),this.configure(t)}configure(e={}){const t=this.gl,i=N(t),n=e.target||this.target||3553,s=e.format||this.format||6408,a=p[s],o=a.format,l=e.type||this.type||a.types[0];let u,c,E;if(!this.target&&(this.target=n),this.format=s,this.type=l,t.bindTexture(this.target,this.tex),void 0!==e.flip&&t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flip?1:0),void 0!==e.premultiply&&t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiply?1:0),void 0!==e.image){const r=e.level||0,i=e.pos||[0,0,0];32879===n?e.width&&e.height&&e.depth&&(e.sub?t.texSubImage3D(n,r,i[0],i[1],i[2],e.width,e.height,e.depth,o,l,e.image):(0===r&&(this.size=[e.width,e.height,e.depth]),t.texImage3D(n,r,s,e.width,e.height,e.depth,0,o,l,e.image))):e.width&&e.height?e.sub?t.texSubImage2D(n,r,i[0],i[1],e.width,e.height,o,l,e.image):(0===r&&(this.size=[e.width,e.height]),t.texImage2D(n,r,s,e.width,e.height,0,o,l,e.image)):e.sub?t.texSubImage2D(n,r,i[0],i[1],o,l,e.image):(null!=e.image&&0==r&&(this.size=[e.image.width,e.image.height]),t.texImage2D(n,r,s,o,l,e.image))}e.mipmap&&t.generateMipmap(n);const R=e.filter||9728;r.isArray(R)?(u=R[0],c=R[1]):u=c=R,u&&t.texParameteri(n,t.TEXTURE_MIN_FILTER,u),c&&t.texParameteri(n,t.TEXTURE_MAG_FILTER,c);const d=e.wrap||33071;if(r.isArray(d)?(u=d[0],c=d[1],E=d[2]):u=c=E=d,u&&t.texParameteri(n,t.TEXTURE_WRAP_S,u),c&&t.texParameteri(n,t.TEXTURE_WRAP_T,c),E&&i&&n===t.TEXTURE_3D&&t.texParameteri(n,t.TEXTURE_WRAP_R,E),e.lod){const[r,i]=e.lod;r&&t.texParameteri(n,t.TEXTURE_MIN_LOD,r),i&&t.texParameteri(n,t.TEXTURE_MAX_LOD,i)}if(e.minMaxLevel){const[r,i]=e.minMaxLevel;t.texParameteri(n,t.TEXTURE_BASE_LEVEL,r),t.texParameteri(n,t.TEXTURE_MAX_LEVEL,i)}return!0}bind(e=0){const t=this.gl;return t.activeTexture(t.TEXTURE0+e),t.bindTexture(this.target,this.tex),!0}unbind(e=0){const t=this.gl;return t.activeTexture(t.TEXTURE0+e),t.bindTexture(this.target,null),!0}release(){return!!this.tex&&(this.gl.deleteTexture(this.tex),delete this.tex,delete this.gl,!0)}}const H=(e,t)=>new w(e,t),$=e=>{const t=r.isArray(e)?e:[e];for(let e=0,r=t.length;e<r;e++){const r=t[e],i=r.indices,n=r.shader.gl;r.textures&&y(r.textures),r.shader.prepareState(),r.shader.bind(r),i&&i.buffer?(i.buffer.bind(),r.instances?j(n,r):n.drawElements(r.mode,r.num,i.data instanceof Uint32Array?n.UNSIGNED_INT:n.UNSIGNED_SHORT,0)):r.instances?j(n,r):n.drawArrays(r.mode,0,r.num),r.shader.unbind(null)}},j=(e,t)=>{const r=N(e),i=r?void 0:e.getExtension("ANGLE_instanced_arrays");r||i||I("instancing not supported");const n=t.shader.attribs,s=t.instances.attribs;t.shader.bindAttribs(s);for(let t in s){const a=n[t];if(a){let n=s[t].divisor;n=void 0!==n?n:1,r?e.vertexAttribDivisor(a.loc,n):i.vertexAttribDivisorANGLE(a.loc,n)}}if(t.indices){const n=t.indices.data instanceof Uint32Array?e.UNSIGNED_INT:e.UNSIGNED_SHORT;r?e.drawElementsInstanced(t.mode,t.num,n,0,t.instances.num):i.drawElementsInstancedANGLE(t.mode,t.num,n,0,t.instances.num)}else r?e.drawArraysInstanced(t.mode,0,t.num,t.instances.num):i.drawArraysInstancedANGLE(t.mode,0,t.num,t.instances.num);for(let t in s){const s=n[t];s&&(r?e.vertexAttribDivisor(s.loc,0):i.vertexAttribDivisorANGLE(s.loc,0))}t.shader.unbind(null)};class X{constructor(e,t){this.gl=e,this.buffer=e.createRenderbuffer()||I("error creating RBO"),this.configure(t)}bind(){return this.gl.bindRenderbuffer(this.gl.RENDERBUFFER,this.buffer),!0}unbind(){return this.gl.bindRenderbuffer(this.gl.RENDERBUFFER,null),!0}release(){return this.gl.deleteRenderbuffer(this.buffer),delete this.buffer,!0}configure(e){const t=this.gl;return this.bind(),this.format=e.format||t.DEPTH_COMPONENT16,this.width=e.width,this.height=e.height,t.renderbufferStorage(t.RENDERBUFFER,e.format||t.DEPTH_COMPONENT16,e.width,e.height),this.unbind(),!0}}class V{constructor(e,t){this.gl=e,this.fbo=e.createFramebuffer()||I("error creating FBO"),this.ext=!N(e)&&t&&t.tex&&t.tex.length>1?e.getExtension("WEBGL_draw_buffers")||I("missing WEBGL_draw_buffers ext"):void 0,this.maxAttachments=e.getParameter(36063),t&&this.configure(t)}bind(){return this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this.fbo),!0}unbind(){return this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null),!0}release(){return this.gl.deleteFramebuffer(this.fbo),delete this.fbo,delete this.ext,!0}configure(e){const r=this.gl;if(this.bind(),e.tex){t.assert(e.tex.length<this.maxAttachments,`too many attachments (max. ${this.maxAttachments})`);const i=[];for(let n=0;n<e.tex.length;n++){const s=e.tex[n];t.assert(!(!p[s.format].render&&!p[s.format].renderExt),`texture #${n} has non-renderable format`);const a=36064+n;r.framebufferTexture2D(r.FRAMEBUFFER,a,r.TEXTURE_2D,s.tex,0),i[n]=a}this.ext?this.ext.drawBuffersWEBGL(i):N(r)&&r.drawBuffers(i)}return e.depth&&(e.depth instanceof X?r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,e.depth.buffer):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,e.depth.tex,0)),this.validate()}validate(){const e=this.gl,t=e.checkFramebufferStatus(e.FRAMEBUFFER);switch(t){case e.FRAMEBUFFER_COMPLETE:return!0;case e.FRAMEBUFFER_UNSUPPORTED:I("FBO unsupported");case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:I("FBO incomplete attachment");case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:I("FBO incomplete dimensions");case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:I("FBO incomplete missing attachment");default:return I(`FBO error: ${t}`)}}}const q=(e,t)=>new V(e,t),z={ambientCol:[.1,.1,.1],diffuseCol:[.8,.8,.8],specularCol:[1,1,1]},W={ambientCol:"vec3",diffuseCol:"vec3",specularCol:"vec3"},Z=(e={},t={},r=z)=>Object.keys(r).reduce((i,n)=>(!1!==t[n]&&(i[n]=[W[n],e[n]||r[n]]),i),{}),k=(e,t,r)=>e[r]||t[r].defaultVal||n.IDENT44,Y=(e="model")=>(t,r)=>n.normal44([],k(r,t,e)),K=(e="model",t="view")=>(r,i)=>n.normal44(null,n.mulM44([],k(i,r,t),k(i,r,e)));const J=(e=!0)=>({attribs:Object.assign({position:{data:new Float32Array([-1,-1,1,-1,-1,1,1,1]),size:2}},e?{uv:{data:new Float32Array([0,0,1,0,0,1,1,1]),size:2}}:null),uniforms:{},shader:null,mode:5,num:4}),Q={a:"",v:"",u:"",o:""},ee={100:{number:100,attrib:(e,t,i)=>`attribute ${r.isArray(t)?t[0]:t} ${i.a}${e};`,varying:{vs:(e,t,r)=>te("varying",t,r.v+e),fs:(e,t,r)=>te("varying",t,r.v+e)},uniform:(e,t,r)=>te("uniform",t,r.u+e),output:(e,t,i)=>r.isArray(t)?`#define ${i.o}${e} gl_FragData[${t[1]}]`:""},"300 es":{number:300,attrib:(e,t,i)=>r.isArray(t)?`layout(location=${t[1]}) in ${t[0]} ${i.a}${e};`:`in ${t} ${i.a}${e};`,varying:{vs:(e,t,r)=>te("out",t,r.v+e),fs:(e,t,r)=>te("in",t,r.v+e)},uniform:(e,t,r)=>te("uniform",t,r.u+e),output:(e,t,i)=>r.isArray(t)?`layout(location=${t[1]}) out ${t[0]} ${i.o}${e};`:`out ${t} ${i.o}${e};`}},te=(e,t,i)=>{const n=r.isArray(t)?t[0]:t;return n.indexOf("[]")>0?`${e} ${n.replace("[]","")} ${i}[${t[1]}];`:`${e} ${n} ${i};`},re=(e,t,r="")=>{let i=">=";return t||(t=r,r=null,i="<"),`#if __VERSION__ ${i} ${e}\n${t}${r?`\n#else\n${r}`:""}\n#endif`},ie=re(300,"","#define texture texture2D"),ne="#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp int;\nprecision highp float;\n#else\nprecision mediump int;\nprecision mediump float;\n#endif\n#ifndef PI\n#define PI 3.141592653589793\n#endif\n#ifndef TAU\n#define TAU 6.283185307179586\n#endif\n#ifndef HALF_PI\n#define HALF_PI 1.570796326794896\n#endif\n",se=e=>(t,r,i=0)=>{let n;return s=>{(s=void 0===s?i:s)!==n&&(t["uniform1"+e](r,s),n=s)}},ae=(e,t)=>(r,i,n=t)=>{let s=[];return t=>{t=void 0===t?n:t,u.equivArrayLike(s,t)||(r["uniform"+e](i,t),s=[...t])}},oe=(e,t)=>(r,i,n=t)=>{let s=[];return t=>{t=void 0===t?n:t,u.equivArrayLike(s,t)||(r["uniformMatrix"+e](i,!1,t),s=[...t])}},le=[0],ue={bool:se("i"),float:se("f"),int:se("i"),uint:se("ui"),bvec2:ae("2iv",c.ZERO2),bvec3:ae("3iv",c.ZERO3),bvec4:ae("4iv",c.ZERO4),ivec2:ae("2iv",c.ZERO2),ivec3:ae("3iv",c.ZERO3),ivec4:ae("4iv",c.ZERO4),vec2:ae("2fv",c.ZERO2),vec3:ae("3fv",c.ZERO3),vec4:ae("4fv",c.ZERO4),mat2:oe("2fv",n.IDENT22),mat3:oe("3fv",n.IDENT33),mat4:oe("4fv",n.IDENT44),sampler2D:se("i"),sampler2DShadow:se("i"),sampler3D:se("i"),samplerCube:se("i"),samplerCubeShadow:se("i"),"bool[]":ae("1iv",le),"float[]":ae("1fv",le),"int[]":ae("1iv",le),"uint[]":ae("1uiv",le),"bvec2[]":ae("2iv",c.ZERO2),"bvec3[]":ae("3iv",c.ZERO3),"bvec4[]":ae("4iv",c.ZERO4),"ivec2[]":ae("2iv",c.ZERO2),"ivec3[]":ae("3iv",c.ZERO3),"ivec4[]":ae("4iv",c.ZERO4),"vec2[]":ae("2fv",c.ZERO2),"vec3[]":ae("3fv",c.ZERO3),"vec4[]":ae("4fv",c.ZERO4),"mat2[]":oe("2fv",c.ZERO2),"mat3[]":oe("3fv",c.ZERO3),"mat4[]":oe("4fv",c.ZERO4),"sampler2D[]":ae("1iv",le),"sampler2DShadow[]":ae("1iv",le),"sampler3D[]":ae("1iv",le),"samplerCube[]":ae("1iv",le),"samplerCubeShadow[]":ae("1iv",le)},ce=/ERROR: \d+:(\d+): (.*)/;class Ee{constructor(e,t,r,i,n){this.gl=e,this.program=t,this.attribs=r,this.uniforms=i,this.state=n||{}}bind(e){return!!this.program&&(this.gl.useProgram(this.program),this.bindAttribs(e.attribs),this.bindUniforms(e.uniforms),!0)}unbind(){return this.gl.useProgram(null),!0}release(){return!!this.program&&(this.gl.deleteProgram(this.program),delete this.program,!0)}bindAttribs(t){const r=this.gl;let i;for(let n in t)if(i=this.attribs[n]){const e=t[n];e.buffer.bind(),r.enableVertexAttribArray(i.loc),r.vertexAttribPointer(i.loc,e.size||3,e.type||r.FLOAT,e.normalized||!1,e.stride||0,e.offset||0)}else e.LOGGER.warn(`unknown attrib: ${n}`)}bindUniforms(t={}){const i=this.uniforms;for(let n in t){const s=i[n];if(s){let e=t[n];e=r.isFunction(e)?e(i,t):r.implementsFunction(e,"deref")?e.deref():e,s.setter(e)}else e.LOGGER.warn(`unknown uniform: ${n}`)}for(let e in i)if(i.hasOwnProperty(e)&&(!t||!r.existsAndNotNull(t[e]))){const r=i[e],n=r.defaultFn?r.defaultFn(i,t):r.defaultVal;r.setter(n)}}prepareState(e=this.state){const t=this.gl;void 0!==e.depth&&this.setState(t.DEPTH_TEST,e.depth),void 0!==e.cull&&(this.setState(t.CULL_FACE,e.cull),e.cullMode&&t.cullFace(e.cullMode)),void 0!==e.blend&&(this.setState(t.BLEND,e.blend),e.blendFn&&t.blendFunc(e.blendFn[0],e.blendFn[1]),void 0!==e.blendEq&&t.blendEquation(e.blendEq)),void 0!==e.stencil&&(this.setState(t.STENCIL_TEST,e.stencil),e.stencilFn&&t.stencilFunc(e.stencilFn[0],e.stencilFn[1],e.stencilFn[2]),e.stencilOp&&t.stencilOp(e.stencilOp[0],e.stencilOp[1],e.stencilOp[2]),void 0!==e.stencilMask&&t.stencilMask(e.stencilMask))}setState(e,t){t?this.gl.enable(e):this.gl.disable(e)}}const Re=(e,t)=>{const i=N(e)?"300 es":"100",n=r.isFunction(t.vs)?he(t,"vs",i):ge(t,"vs",i),s=r.isFunction(t.fs)?he(t,"fs",i):ge(t,"fs",i);console.log(n),console.log(s),fe(e,t.ext);const a=Ae(e,e.VERTEX_SHADER,n),o=Ae(e,e.FRAGMENT_SHADER,s),l=e.createProgram()||I("error creating shader program");if(e.attachShader(l,a),e.attachShader(l,o),e.linkProgram(l),e.getProgramParameter(l,e.LINK_STATUS)){const r=Te(e,l,t.attribs),i=ve(e,l,t.uniforms);return e.deleteShader(a),e.deleteShader(o),new Ee(e,l,r,i,t.state)}throw new Error(`Error linking shader: ${e.getProgramInfoLog(l)}`)},de=(e,t,r)=>{let i=[];for(let n in e)e.hasOwnProperty(n)&&i.push(t(n,e[n],r));return i.push(""),i.join("\n")},_e=(e,t,i)=>{const n=f[e],s="300 es"===i;return n&&(!s&&n.gl||s&&n.gl2)?`#extension ${n&&n.alias||e} : ${r.isBoolean(t)?t?"enable":"disable":t}\n`:""},fe=(e,t)=>{if(t)for(let r in t){const i=t[r];!0!==i&&"require"!==i||D(e,[r],"require"===i)}},he=(e,t,i)=>{let n="";if(n+=e.pre?e.replacePrelude?e.pre:e.pre+"\n"+ne:ne,e.ext)for(let t in e.ext)n+=_e(t,e.ext[t],i);const u={},c={},E={},R={};if(e.uniforms)for(let t in e.uniforms){const i=e.uniforms[t];R[t]=r.isArray(i)?i[0].indexOf("[]")>0?o.uniform(i[0],t,{num:i[1]}):o.uniform(i[0],t):o.uniform(i,t)}if("vs"===t){for(let t in e.attribs){const i=e.attribs[t];u[t]=r.isArray(i)?o.input(i[0],t,{loc:i[1]}):o.input(i,t)}if(e.varying)for(let t in e.varying){const i=e.varying[t];c[t]=r.isArray(i)?o.output(i[0],t,{num:i[1]}):o.output(i,t)}}else{if(e.varying)for(let t in e.varying){const i=e.varying[t];u[t]=r.isArray(i)?o.input(i[0],t,{num:i[1]}):o.input(i,t)}const t=e.outputs||h;if(i>="300 es")for(let e in t){const i=t[e];c[e]=r.isArray(i)?o.output(i[0],e,{loc:i[1]}):o.output(i,e)}else for(let e in t){const s=t[e];r.isArray(s)&&"vec4"===s[0]?(n+=`#define ${e} gl_FragData[${s[1]}]\n`,E[e]=o.sym("vec4",e)):a.unsupported(`GLSL ${i} doesn't support output vars`)}}const d=l.targetGLSL({type:t,version:i,prelude:n});return d(o.program([...s.vals(R),...s.vals(u),...s.vals(c),...e[t](d,R,u,Object.assign(Object.assign({},c),E))]))+(e.post?"\n"+e.post:"")},ge=(e,t,r)=>{const i=ee[r],n=Object.assign(Object.assign({},Q),e.declPrefixes),s="vs"===t;let a="";if(a+=`#version ${r}\n`,a+=e.pre?e.replacePrelude?e.pre:e.pre+"\n"+ne:ne,e.ext)for(let t in e.ext)a+=_e(t,e.ext[t],r);return!1!==e.generateDecls&&(a+=s?de(e.attribs,i.attrib,n):de(e.outputs||h,i.output,n),a+=de(e.varying,i.varying[t],n),a+=de(e.uniforms,i.uniform,n)),a+=e[t],e.post&&(a+="\n"+e.post),a},Ae=(e,t,r)=>{const i=e.createShader(t)||I("error creating shader");return e.shaderSource(i,r),e.compileShader(i),e.getShaderParameter(i,e.COMPILE_STATUS)?i:me(e,i,r)},me=(e,t,i)=>{const n=i.split("\n"),s=e.getShaderInfoLog(t).split("\n").map(e=>{const t=ce.exec(e),r=t?t[1]:null;if(r)return`line ${r}: ${t[2]}\n${n[parseInt(r)-1]}`}).filter(r.existsAndNotNull).join("\n");return I(`Error compiling shader:\n${s}`)},Te=(e,t,i)=>{const n={};for(let s in i){const a=i[s],[o,l]=r.isArray(a)?a:[a,null],u=s;null!=l?(e.bindAttribLocation(t,l,u),n[s]={type:o,loc:l}):n[s]={type:o,loc:e.getAttribLocation(t,u)}}return n},ve=(t,i,n={})=>{const s={};for(let a in n){const o=n[a];let l,u,c,E,R;r.isArray(o)?([l,u,c]=o,E=l.indexOf("[]")<0?u:c,r.isFunction(E)&&(R=E,E=void 0)):l=o;const d=t.getUniformLocation(i,a);if(null!=d){const e=ue[l];e?s[a]={loc:d,setter:e(t,d,E),defaultFn:R,defaultVal:E,type:l}:I(`invalid uniform type: ${l}`)}else e.LOGGER.warn(`unknown uniform: ${a}`)}return s},be=(e,t,r)=>[o.defMain(()=>[o.assign(e.gl_Position,o.vec4(r.position,o.FLOAT0,o.FLOAT1))])],pe=(e,t,r,i)=>[o.defMain(()=>[o.assign(i.v_uv,r.uv),o.assign(e.gl_Position,o.vec4(r.position,o.FLOAT0,o.FLOAT1))])],Ne=(e,t,r,i)=>[o.defMain(()=>[o.assign(i.fragColor,o.$xy(e.gl_FragCoord))])],Oe=(e,t,r,i)=>[o.defMain(()=>[o.assign(i.fragColor,o.texture(t.tex,r.v_uv))])],Se={vs:be,fs:Ne,attribs:{position:"vec2"},varying:{},uniforms:{},state:{depth:!1},ext:{}},Ie={vs:pe,fs:Oe,attribs:{position:"vec2",uv:"vec2"},varying:{v_uv:"vec2"},uniforms:{tex:"sampler2D"},state:{depth:!1},ext:{}},Ge=(e,t,r="position")=>e.instancePos?o.add(t[r],t[e.instancePos]):t[r],Fe=(e,t,r)=>e.instanceColor?o.mul(t[e.instanceColor],r):e.color?o.mul(t[e.color],r):r;e.ALIAS_TEXTURE=ie,e.BLEND_ADD=[770,772],e.BLEND_NORMAL=[770,771],e.DEFAULT_MATERIAL=z,e.DEFAULT_OUTPUT=h,e.EXPORT_FRAGCOL=(e="col",t="o_fragColor")=>re(300,`${t}=${e};`,`gl_FragColor=${e};`),e.FBO=V,e.FX_SHADER_SPEC=Se,e.FX_SHADER_SPEC_UV=Ie,e.GLSL_HEADER=ne,e.GL_EXT_INFO=f,e.LAMBERT=(e={})=>({vs:(t,r,i,n)=>[o.defMain(()=>[e.uv?o.assign(n.vuv,i[e.uv]):null,o.assign(n.vcolor,Fe(e,i,r.diffuseCol)),o.assign(n.vnormal,E.surfaceNormal(i.normal,r.normalMat)),o.assign(t.gl_Position,E.transformMVP(Ge(e,i),r.model,r.view,r.proj))])],fs:(t,r,i,n)=>[o.defMain(()=>[o.assign(n.fragColor,o.vec4(E.diffuseLighting((!1!==e.bidir?E.halfLambert:E.lambert)(o.normalize(i.vnormal),r.lightDir),e.uv?o.mul(o.$(o.texture(r.tex,i.vuv),"xyz"),i.vcolor):i.vcolor,r.lightCol,r.ambientCol),1))])],attribs:Object.assign(Object.assign(Object.assign(Object.assign({position:"vec3",normal:"vec3"},e.uv?{[e.uv]:"vec2"}:null),e.color&&!e.instanceColor?{[e.color]:"vec3"}:null),e.instancePos?{[e.instancePos]:"vec3"}:null),e.instanceColor?{[e.instanceColor]:"vec3"}:null),varying:Object.assign({vcolor:"vec3",vnormal:"vec3"},e.uv?{vuv:"vec2"}:null),uniforms:Object.assign(Object.assign({model:"mat4",view:"mat4",proj:"mat4",normalMat:["mat4",K()],lightDir:["vec3",[0,1,0]],lightCol:["vec3",[1,1,1]]},Z(Object.assign({diffuseCol:[1,1,1]},e.material),{specularCol:!1})),e.uv?{tex:"sampler2D"}:null),state:Object.assign({depth:!0,cull:!0},e.state)}),e.NO_PREFIXES=Q,e.PASSTHROUGH_FS=Ne,e.PASSTHROUGH_FS_UV=Oe,e.PASSTHROUGH_VS=be,e.PASSTHROUGH_VS_UV=pe,e.PHONG=(e={})=>({vs:(t,r,i,n)=>[o.defMain(()=>{let s;return[s=o.sym(o.mul(r.model,o.vec4(Ge(e,i),1))),o.assign(n.vnormal,E.surfaceNormal(i.normal,r.normalMat)),o.assign(n.vlight,o.sub(r.lightPos,o.$(s,"xyz"))),o.assign(n.veye,o.sub(r.eyePos,o.$(s,"xyz"))),o.assign(n.vcolor,Fe(e,i,r.diffuseCol)),o.assign(t.gl_Position,o.mul(o.mul(r.proj,r.view),s))]})],fs:(e,t,r,i)=>[o.defMain(()=>{let e,n,s,a;return[e=o.sym(o.normalize(r.vnormal)),n=o.sym(o.normalize(r.vlight)),s=o.sym(o.max(o.dot(e,n),o.FLOAT0)),a=o.sym(o.ternary(o.gt(s,o.FLOAT0),o.pow(o.dot(e,o.normalize(o.add(n,o.normalize(r.veye)))),t.shininess),o.FLOAT0)),o.assign(i.fragColor,o.vec4(o.add(E.diffuseLighting(s,r.vcolor,t.lightCol,t.ambientCol),o.mul(t.specularCol,a)),1))]})],attribs:Object.assign(Object.assign(Object.assign({position:"vec3",normal:"vec3"},e.color&&!e.instanceColor?{[e.color]:"vec3"}:null),e.instancePos?{[e.instancePos]:"vec3"}:null),e.instanceColor?{[e.instanceColor]:"vec3"}:null),varying:{vnormal:"vec3",veye:"vec3",vlight:"vec3",vcolor:"vec3"},uniforms:Object.assign({model:"mat4",normalMat:["mat4",Y()],view:"mat4",proj:"mat4",shininess:["float",32],eyePos:"vec3",lightPos:["vec3",[0,0,2]],lightCol:["vec3",[1,1,1]]},Z(e.material)),state:Object.assign({depth:!0,cull:!0},e.state)}),e.PREFIXES={a:"a_",v:"v_",u:"u_",o:"o_"},e.RBO=X,e.SYNTAX=ee,e.Shader=Ee,e.TEX_FORMATS=p,e.Texture=w,e.VERSION_CHECK=re,e.WebGLArrayBuffer=G,e.WebGLError=S,e.adaptDPI=M,e.autoNormalMatrix1=Y,e.autoNormalMatrix2=K,e.bindTextures=y,e.buffer=F,e.checkerboard=e=>{const t=(e=Object.assign({size:16,col1:4294967295,col2:4278190080,cornerCols:[4294901760,4278255360,4278190335,4294967040]},e)).size,r=R.ARGB8888.toABGR(e.col1),i=R.ARGB8888.toABGR(e.col2),{canvas:n,ctx:s,img:a,pixels:o}=R.canvasPixels(t);for(let e=0,n=0;e<t;e++)for(let s=0;s<t;s++,n++)o[n]=1&e^1&s?r:i;if(e.corners){const r=e.cornerCols.map(R.ARGB8888.toABGR);o[0]=r[0],o[t-1]=r[1],o[o.length-t]=r[2],o[o.length-1]=r[3]}return s.putImageData(a,0,0),n},e.colorAttrib=Fe,e.compileAttribPool=B,e.compileIndices=U,e.compileModel=L,e.compileShader=Ae,e.compileVAO=(e,t)=>{if(t.shader){const r=N(e),i=r?null:e.getExtension("OES_vertex_array_object");if(r||i){let n;return r?(n=e.createVertexArray(),e.bindVertexArray(n)):(n=i.createVertexArrayOES(),i.bindVertexArrayOES(n)),n&&I("error creating VAO"),t.shader.bindAttribs(t.attribs),t.indices&&t.indices.buffer.bind(),t.shader.unbind(null),r?e.bindVertexArray(null):i.bindVertexArrayOES(null),n}}},e.cube=e=>{const t=(e=Object.assign({size:1,normal:!0,uv:!0},e)).size,r={attribs:{position:{data:new Float32Array([t,t,-t,t,t,t,t,-t,t,t,-t,-t,-t,t,t,-t,t,-t,-t,-t,-t,-t,-t,t,-t,t,t,t,t,t,t,t,-t,-t,t,-t,-t,-t,-t,t,-t,-t,t,-t,t,-t,-t,t,t,t,t,-t,t,t,-t,-t,t,t,-t,t,-t,t,-t,t,t,-t,t,-t,-t,-t,-t,-t])}},indices:{data:new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23])},uniforms:{},shader:null,num:36};return e.normal&&(r.attribs.normal={data:new Float32Array([1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1])}),e.uv&&(r.attribs.uv={data:new Float32Array([1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1]),size:2}),r},e.cubeMap=(e,t,r={})=>{const n=new w(e,{target:e.TEXTURE_CUBE_MAP}),s=i.withoutKeysObj(r,["target","image","filter","mipmap"]);for(let r=0;r<6;r++)s.target=e.TEXTURE_CUBE_MAP_POSITIVE_X+r,s.image=t[r],n.configure(s);return n.configure({filter:r.filter,mipmap:r.mipmap}),n},e.defMaterial=Z,e.draw=$,e.error=I,e.fbo=q,e.floatTexture=(e,t,r,i,n,s)=>new w(e,{filter:e.NEAREST,wrap:e.CLAMP_TO_EDGE,format:n||(N(e)?34836:6408),type:s||e.FLOAT,image:t,width:r,height:i}),e.getExtensions=D,e.glCanvas=(e={})=>{const t=e.canvas?r.isString(e.canvas)?document.getElementById(e.canvas):e.canvas:document.createElement("canvas");e.width&&(t.width=e.width),e.height&&(t.height=e.height),!1!==e.autoScale&&M(t,t.width,t.height),e.parent&&e.parent.appendChild(t);const i=t.getContext(2===e.version?"webgl2":"webgl",Object.assign(Object.assign({},C),e.opts));return i||I("WebGL unavailable"),e.onContextLost&&t.addEventListener("webglcontextlost",e.onContextLost),{canvas:t,gl:i,ext:D(i,e.ext)}},e.isFloatTexture=O,e.isGL2Context=N,e.multipass=e=>{const r=e.gl,i=N(r),n=e.passes.length;t.assert(n>0,"require at least one shader pass");const a=Object.keys(e.textures).reduce((t,i)=>(t[i]=H(r,Object.assign({width:e.width,height:e.height,filter:r.NEAREST,wrap:r.CLAMP_TO_EDGE,image:null},e.textures[i])),t),{}),o=L(r,J(!1)),l=e.passes.map(e=>{const t=e.model?L(r,e.model):Object.assign({},o);return t.shader=(e=>{const t=e.inputs.length,n=e.outputs.length,o={},l={vs:e.vs||be,fs:e.fs,attribs:e.attribs||{position:"vec2"},varying:e.varying,uniforms:Object.assign(Object.assign({},e.uniforms),t?{inputs:["sampler2D[]",t,[...s.range(t)]]}:null),outputs:n?s.transduce(s.map(e=>[`output${e}`,["vec4",e]]),s.assocObj(),s.range(n)):void 0,state:e.state,pre:e.pre,post:e.post,replacePrelude:e.replacePrelude,generateDecls:e.generateDecls,ext:o},u=s.some(e=>O(a[e]),e.inputs),c=s.some(e=>O(a[e]),e.outputs);return i||(u&&(o.OES_texture_float="require"),n>1&&(o.WEBGL_draw_buffers="require")),c&&(o[i?"EXT_color_buffer_float":"WEBGL_color_buffer_float"]="require"),Re(r,l)})(e),t.uniforms=Object.assign({},e.uniformVals),e.inputs.length>0&&(t.textures=e.inputs.map(e=>a[e])),t}),u=!e.passes[n-1].outputs.length,c=(u?e.passes.slice(0,n-1):e.passes).map(e=>q(r,{tex:e.outputs.map(e=>a[e])})),E=(t,i)=>{const n=e.passes[t],s=l[t],o=s.shader,u=n.outputs.length?a[n.outputs[0]].size:[r.drawingBufferWidth,r.drawingBufferHeight];o.uniforms.resolution&&(s.uniforms.resolution=u),o.uniforms.time&&(s.uniforms.time=i),r.viewport(0,0,u[0],u[1]),$(s)},R=e=>{for(let t=0;t<c.length;t++)c[t].bind(),E(t,e),c[t].unbind();u&&E(n-1,e)},d=()=>{R(.001*(Date.now()-h)),_&&(f=requestAnimationFrame(d))};let _,f,h=Date.now();return{start(){h=Date.now(),_=!0,f=requestAnimationFrame(d)},stop(){_&&(_=!1,cancelAnimationFrame(f))},update(e){R(e)},passes:e.passes,fbos:c,models:l,textures:a}},e.positionAttrib=Ge,e.prepareShaderSource=ge,e.quad=J,e.rbo=(e,t)=>new X(e,t),e.readPixels=(e,t,r,i,n,s,a,o)=>(e.readPixels(t,r,i,n,s,a,o),o),e.readTexture=(e,t,r,i,n)=>{const s=new V(e,{tex:[t]});return e.readPixels(0,0,t.size[0],t.size[1],r,i,n),s.unbind(),s.release(),n},e.screen2d=function(e,t){return r.isNumber(e)?n.ortho([],0,e,t,0,-1,1):n.ortho([],0,e.drawingBufferWidth,e.drawingBufferHeight,0,-1,1)},e.setLogger=t=>e.LOGGER=t,e.shader=Re,e.shaderSourceFromAST=he,e.stripes=e=>{const t=(e=Object.assign({size:16,col1:4294967295,col2:4278190080},e)).size,r=R.ARGB8888.toABGR(e.col1),i=R.ARGB8888.toABGR(e.col2),{canvas:n,ctx:s,img:a,pixels:o}=e.horizontal?R.canvasPixels(1,t):R.canvasPixels(t,1);for(let e=t;--e>=0;)o[e]=1&e?r:i;return s.putImageData(a,0,0),n},e.texture=H,Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -1,5 +0,5 @@

import { Material } from "./api/material";
import { ShaderUniformSpecs } from "./api/shader";
import type { Material } from "./api/material";
import type { ShaderUniformSpecs } from "./api/shader";
export declare const DEFAULT_MATERIAL: Material;
export declare const defMaterial: (mat?: Partial<Material>, flags?: Partial<Record<"ambientCol" | "diffuseCol" | "specularCol", boolean>>, base?: Material) => ShaderUniformSpecs;
//# sourceMappingURL=material.d.ts.map

@@ -1,4 +0,4 @@

import { IObjectOf } from "@thi.ng/api";
import { GLMat4 } from "./api/glsl";
import { ShaderUniforms } from "./api/shader";
import type { IObjectOf } from "@thi.ng/api";
import type { GLMat4 } from "./api/glsl";
import type { ShaderUniforms } from "./api/shader";
/**

@@ -5,0 +5,0 @@ * Computes the inverse transpose of given 4x4 matrix uniform, i.e.

@@ -1,3 +0,3 @@

import { Multipass, MultipassOpts } from "./api/multipass";
import type { Multipass, MultipassOpts } from "./api/multipass";
export declare const multipass: (opts: MultipassOpts) => Multipass;
//# sourceMappingURL=multipass.d.ts.map
{
"name": "@thi.ng/webgl",
"version": "0.2.4",
"version": "0.3.2",
"description": "WebGL & GLSL abstraction layer",

@@ -31,26 +31,26 @@ "module": "./index.js",

"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@microsoft/api-extractor": "^7.7.7",
"@types/mocha": "^5.2.7",
"@types/node": "^13.5.0",
"mocha": "^7.0.0",
"@microsoft/api-extractor": "^7.7.8",
"@types/mocha": "^7.0.1",
"@types/node": "^13.7.4",
"mocha": "^7.0.1",
"nyc": "^15.0.0",
"ts-node": "^8.6.2",
"typedoc": "^0.16.8",
"typescript": "^3.7.5"
"typedoc": "^0.16.10",
"typescript": "^3.8.2"
},
"dependencies": {
"@thi.ng/api": "^6.7.1",
"@thi.ng/associative": "^3.1.3",
"@thi.ng/binary": "^1.2.1",
"@thi.ng/checks": "^2.5.0",
"@thi.ng/equiv": "^1.0.12",
"@thi.ng/errors": "^1.2.3",
"@thi.ng/matrices": "^0.5.12",
"@thi.ng/pixel": "^0.1.8",
"@thi.ng/shader-ast": "^0.3.5",
"@thi.ng/shader-ast-glsl": "^0.1.11",
"@thi.ng/shader-ast-stdlib": "^0.3.4",
"@thi.ng/transducers": "^6.2.1",
"@thi.ng/vector-pools": "^1.0.12",
"@thi.ng/vectors": "^4.0.3"
"@thi.ng/api": "^6.8.2",
"@thi.ng/associative": "^3.1.6",
"@thi.ng/binary": "^1.3.2",
"@thi.ng/checks": "^2.5.3",
"@thi.ng/equiv": "^1.0.15",
"@thi.ng/errors": "^1.2.6",
"@thi.ng/matrices": "^0.6.2",
"@thi.ng/pixel": "^0.1.11",
"@thi.ng/shader-ast": "^0.3.8",
"@thi.ng/shader-ast-glsl": "^0.1.14",
"@thi.ng/shader-ast-stdlib": "^0.3.7",
"@thi.ng/transducers": "^6.3.2",
"@thi.ng/vector-pools": "^1.0.15",
"@thi.ng/vectors": "^4.1.2"
},

@@ -87,3 +87,3 @@ "keywords": [

},
"gitHead": "38d193103121815a5794ae242817f8f306b6ddd4"
"gitHead": "d426e5ee02515cbc6a769458a08c0677fe003ec9"
}

@@ -1,2 +0,2 @@

import { IRenderBuffer, RboOpts } from "./api/buffers";
import type { IRenderBuffer, RboOpts } from "./api/buffers";
export declare class RBO implements IRenderBuffer {

@@ -3,0 +3,0 @@ gl: WebGLRenderingContext;

<!-- This file is generated - DO NOT EDIT! -->
# @thi.ng/webgl
# ![@thi.ng/webgl](https://media.thi.ng/umbrella/banners/thing-webgl.svg?1581297788)

@@ -5,0 +5,0 @@ [![npm version](https://img.shields.io/npm/v/@thi.ng/webgl.svg)](https://www.npmjs.com/package/@thi.ng/webgl)

@@ -1,2 +0,2 @@

# ${pkg.name}
# ${pkg.banner}

@@ -3,0 +3,0 @@ [![npm version](https://img.shields.io/npm/v/${pkg.name}.svg)](https://www.npmjs.com/package/${pkg.name})

@@ -1,5 +0,5 @@

import { IObjectOf } from "@thi.ng/api";
import { GLSLVersion } from "@thi.ng/shader-ast-glsl";
import { ModelAttributeSpecs, ModelSpec } from "./api/model";
import { IShader, ShaderAttrib, ShaderSpec, ShaderState, ShaderUniforms, UniformValues } from "./api/shader";
import type { IObjectOf } from "@thi.ng/api";
import type { ModelAttributeSpecs, ModelSpec } from "./api/model";
export declare class Shader implements IShader {

@@ -6,0 +6,0 @@ gl: WebGLRenderingContext;

@@ -1,3 +0,3 @@

import { Material } from "../api/material";
import { ShaderOpts, ShaderSpec } from "../api/shader";
import type { Material } from "../api/material";
import type { ShaderOpts, ShaderSpec } from "../api/shader";
export interface LambertOpts extends ShaderOpts<Pick<Material, "ambientCol" | "diffuseCol">> {

@@ -4,0 +4,0 @@ bidir: boolean;

@@ -1,5 +0,5 @@

import { Material } from "../api/material";
import { ShaderOpts, ShaderSpec } from "../api/shader";
import type { Material } from "../api/material";
import type { ShaderOpts, ShaderSpec } from "../api/shader";
export declare type PhongOpts = ShaderOpts<Pick<Material, "ambientCol" | "diffuseCol" | "specularCol">>;
export declare const PHONG: (opts?: Partial<PhongOpts>) => ShaderSpec;
//# sourceMappingURL=phong.d.ts.map

@@ -1,2 +0,2 @@

import { ShaderFn, ShaderSpec } from "../api/shader";
import type { ShaderFn, ShaderSpec } from "../api/shader";
export declare const PASSTHROUGH_VS: ShaderFn;

@@ -3,0 +3,0 @@ export declare const PASSTHROUGH_VS_UV: ShaderFn;

import { GLSLVersion } from "@thi.ng/shader-ast-glsl";
import { GLSLDeclPrefixes, GLSLSyntax } from "./api/shader";
import type { GLSLDeclPrefixes, GLSLSyntax } from "./api/shader";
export declare const PREFIXES: GLSLDeclPrefixes;

@@ -4,0 +4,0 @@ export declare const NO_PREFIXES: GLSLDeclPrefixes;

@@ -81,31 +81,27 @@ import { withoutKeysObj } from "@thi.ng/associative";

opts.mipmap && gl.generateMipmap(target);
if (opts.filter) {
const flt = opts.filter;
if (isArray(flt)) {
t1 = flt[0];
t2 = flt[1];
}
else {
t1 = t2 = flt;
}
t1 && gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, t1);
t2 && gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, t2);
const flt = opts.filter || 9728 /* NEAREST */;
if (isArray(flt)) {
t1 = flt[0];
t2 = flt[1];
}
if (opts.wrap) {
const wrap = opts.wrap;
if (isArray(wrap)) {
t1 = wrap[0];
t2 = wrap[1];
t3 = wrap[2];
}
else {
t1 = t2 = t3 = wrap;
}
t1 && gl.texParameteri(target, gl.TEXTURE_WRAP_S, t1);
t2 && gl.texParameteri(target, gl.TEXTURE_WRAP_T, t2);
t3 &&
isGL2 &&
target === gl.TEXTURE_3D &&
gl.texParameteri(target, gl.TEXTURE_WRAP_R, t3);
else {
t1 = t2 = flt;
}
t1 && gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, t1);
t2 && gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, t2);
const wrap = opts.wrap || 33071 /* CLAMP */;
if (isArray(wrap)) {
t1 = wrap[0];
t2 = wrap[1];
t3 = wrap[2];
}
else {
t1 = t2 = t3 = wrap;
}
t1 && gl.texParameteri(target, gl.TEXTURE_WRAP_S, t1);
t2 && gl.texParameteri(target, gl.TEXTURE_WRAP_T, t2);
t3 &&
isGL2 &&
target === gl.TEXTURE_3D &&
gl.texParameteri(target, gl.TEXTURE_WRAP_R, t3);
if (opts.lod) {

@@ -112,0 +108,0 @@ const [t1, t2] = opts.lod;

@@ -1,5 +0,5 @@

import { Fn, Fn3, IObjectOf } from "@thi.ng/api";
import { ReadonlyVec } from "@thi.ng/vectors";
import { UniformValue } from "./api/shader";
import type { Fn, Fn3, IObjectOf } from "@thi.ng/api";
import type { UniformValue } from "./api/shader";
export declare const UNIFORM_SETTERS: IObjectOf<Fn3<WebGLRenderingContext, WebGLUniformLocation, number | ReadonlyVec | undefined, Fn<UniformValue | undefined | null, void>>>;
//# sourceMappingURL=uniforms.d.ts.map

@@ -1,6 +0,6 @@

import { IObjectOf } from "@thi.ng/api";
import { Sym, Term } from "@thi.ng/shader-ast";
import { ShaderOpts } from "./api/shader";
import type { IObjectOf } from "@thi.ng/api";
import type { ShaderOpts } from "./api/shader";
export declare const positionAttrib: (opts: Partial<ShaderOpts<any>>, attribs: IObjectOf<Sym<any>>, pos?: string) => Sym<any> | import("@thi.ng/shader-ast").Op2<any>;
export declare const colorAttrib: (opts: Partial<ShaderOpts<any>>, attribs: IObjectOf<Sym<any>>, fallback: Sym<"vec3">) => Term<"vec3">;
//# sourceMappingURL=utils.d.ts.map

Sorry, the diff of this file is too big to display

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