Comparing version 0.0.39 to 0.0.40
{ | ||
"name": "ogl", | ||
"version": "0.0.39", | ||
"version": "0.0.40", | ||
"description": "WebGL Library", | ||
@@ -5,0 +5,0 @@ "main": "src/index.mjs", |
@@ -58,6 +58,6 @@ <p align="center"> | ||
------------ | -------------: | ||
Core | 6kb | ||
Math | 7kb | ||
Extras | 9kb | ||
Total | 22kb | ||
Core | 8kb | ||
Math | 6kb | ||
Extras | 10kb | ||
Total | 24kb | ||
@@ -64,0 +64,0 @@ With tree-shaking applied in a build step, one can expect the final size to be much lighter than the values above. |
@@ -193,3 +193,3 @@ // attribute params | ||
const attr = this.attributes.position; | ||
if (attr.min) return [attr.min, attr.max]; | ||
if (attr.min) return [...attr.min, ...attr.max]; | ||
if (attr.data) return attr.data; | ||
@@ -196,0 +196,0 @@ if (isBoundsWarned) return; |
@@ -13,2 +13,3 @@ import {RenderTarget} from '../core/RenderTarget.js'; | ||
dissipation = 0.98, // affects the speed that the stamp fades. Closer to 1 is slower | ||
type, // Pass in gl.FLOAT to force it, defaults to gl.HALF_FLOAT | ||
} = {}) { | ||
@@ -45,13 +46,20 @@ const _this = this; | ||
function createFBOs() { | ||
let supportLinearFiltering = gl.renderer.extensions[`OES_texture_${gl.renderer.isWebgl2 ? `` : `half_`}float_linear`]; | ||
// Requested type not supported, fall back to half float | ||
if (!type) type = gl.HALF_FLOAT || gl.renderer.extensions['OES_texture_half_float'].HALF_FLOAT_OES; | ||
let minFilter = (() => { | ||
if (gl.renderer.isWebgl2) return gl.LINEAR; | ||
if (gl.renderer.extensions[`OES_texture_${type === gl.FLOAT ? '' : 'half_'}float_linear`]) return gl.LINEAR; | ||
return gl.NEAREST; | ||
})(); | ||
const options = { | ||
width: size, | ||
height: size, | ||
type: gl.renderer.isWebgl2 ? gl.HALF_FLOAT : | ||
gl.renderer.extensions['OES_texture_half_float'] ? gl.renderer.extensions['OES_texture_half_float'].HALF_FLOAT_OES : | ||
gl.UNSIGNED_BYTE, | ||
type, | ||
format: gl.RGBA, | ||
internalFormat: gl.renderer.isWebgl2 ? gl.RGBA16F : gl.RGBA, | ||
minFilter: supportLinearFiltering ? gl.LINEAR : gl.NEAREST, | ||
internalFormat: gl.renderer.isWebgl2 | ||
? (type === gl.FLOAT ? gl.RGBA32F : gl.RGBA16F) | ||
: gl.RGBA, | ||
minFilter, | ||
depth: false, | ||
@@ -58,0 +66,0 @@ }; |
@@ -89,25 +89,25 @@ import { Geometry } from '../core/Geometry.js'; | ||
// Threejs GLTF Loader https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/GLTFLoader.js#L1085 | ||
static resolveURI(uri, dir) { | ||
// Invalid URI | ||
if (typeof uri !== 'string' || uri === '') return ''; | ||
static resolveURI(uri, dir) { | ||
// Invalid URI | ||
if (typeof uri !== 'string' || uri === '') return ''; | ||
// Host Relative URI | ||
if (/^https?:\/\//i.test(dir) && /^\//.test(uri)) { | ||
dir = dir.replace( /(^https?:\/\/[^\/]+).*/i, '$1' ); | ||
} | ||
// Host Relative URI | ||
if (/^https?:\/\//i.test(dir) && /^\//.test(uri)) { | ||
dir = dir.replace( /(^https?:\/\/[^\/]+).*/i, '$1' ); | ||
} | ||
// Absolute URI http://, https://, // | ||
if ( /^(https?:)?\/\//i.test(uri)) return uri; | ||
// Absolute URI http://, https://, // | ||
if ( /^(https?:)?\/\//i.test(uri)) return uri; | ||
// Data URI | ||
if (/^data:.*,.*$/i.test(uri)) return uri; | ||
// Data URI | ||
if (/^data:.*,.*$/i.test(uri)) return uri; | ||
// Blob URI | ||
if (/^blob:.*$/i.test(uri)) return uri; | ||
// Blob URI | ||
if (/^blob:.*$/i.test(uri)) return uri; | ||
// Relative URI | ||
return dir + uri; | ||
} | ||
// Relative URI | ||
return dir + uri; | ||
} | ||
static async loadBuffers(desc, dir) { | ||
static async loadBuffers(desc, dir) { | ||
return await Promise.all(desc.buffers.map(buffer => { | ||
@@ -169,3 +169,3 @@ const uri = this.resolveURI(buffer.uri, dir); | ||
static parseMeshes(gl, desc, bufferViews) { | ||
static parseMeshes(gl, desc, bufferViews) { | ||
return desc.meshes.map(({ | ||
@@ -218,3 +218,3 @@ primitives, // required | ||
static parseAccessor(index, desc, bufferViews) { | ||
static parseAccessor(index, desc, bufferViews) { | ||
// TODO: init missing bufferView with 0s | ||
@@ -221,0 +221,0 @@ // TODO: support sparse |
@@ -14,2 +14,3 @@ import {Program} from '../core/Program.js'; | ||
geometry = new Triangle(gl), | ||
type, // Pass in gl.FLOAT to force it, defaults to gl.HALF_FLOAT | ||
}) { | ||
@@ -65,7 +66,7 @@ this.gl = gl; | ||
height: this.size, | ||
type: gl.renderer.isWebgl2 ? gl.HALF_FLOAT : | ||
gl.renderer.extensions['OES_texture_half_float'] ? gl.renderer.extensions['OES_texture_half_float'].HALF_FLOAT_OES : | ||
gl.UNSIGNED_BYTE, | ||
type: type || gl.HALF_FLOAT || gl.renderer.extensions['OES_texture_half_float'].HALF_FLOAT_OES, | ||
format: gl.RGBA, | ||
internalFormat: gl.renderer.isWebgl2 ? gl.RGBA16F : gl.RGBA, | ||
internalFormat: gl.renderer.isWebgl2 | ||
? (type === gl.FLOAT ? gl.RGBA32F : gl.RGBA16F) | ||
: gl.RGBA, | ||
minFilter: gl.NEAREST, | ||
@@ -72,0 +73,0 @@ depth: false, |
@@ -100,3 +100,3 @@ import { Texture } from '../core/Texture.js'; | ||
}); | ||
texture = loaded = this.loadImage(gl, src, texture); | ||
texture.loaded = this.loadImage(gl, src, texture); | ||
break; | ||
@@ -108,3 +108,3 @@ default: | ||
texture.format = ext; | ||
texture.ext = ext; | ||
@@ -119,4 +119,7 @@ // TODO: store in cache | ||
const extensions = { | ||
pvrtc: gl.renderer.getExtension('WEBGL_compressed_texture_pvrtc'), | ||
s3tc: gl.renderer.getExtension('WEBGL_compressed_texture_s3tc'), | ||
pvrtc: gl.renderer.getExtension('WEBGL_compressed_texture_pvrtc') | ||
|| gl.renderer.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc'), | ||
s3tc: gl.renderer.getExtension('WEBGL_compressed_texture_s3tc') | ||
|| gl.renderer.getExtension('MOZ_WEBGL_compressed_texture_s3tc') | ||
|| gl.renderer.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc'), | ||
etc: gl.renderer.getExtension('WEBGL_compressed_texture_etc'), | ||
@@ -123,0 +126,0 @@ etc1: gl.renderer.getExtension('WEBGL_compressed_texture_etc1'), |
Sorry, the diff of this file is too big to display
460021
12608