Comparing version 0.0.26 to 0.0.27
{ | ||
"name": "ogl", | ||
"version": "0.0.26", | ||
"version": "0.0.27", | ||
"description": "WebGL Framework", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -295,3 +295,3 @@ <p align="center"> | ||
- [ ] Reflections | ||
- [ ] Shadow maps | ||
- [x] Shadow maps | ||
- [ ] Distortion (refraction) | ||
@@ -298,0 +298,0 @@ - [x] Post Fluid Distortion |
import pkg from './package.json'; | ||
export default [{ | ||
input: 'src/index.js', | ||
output: [ | ||
{ file: pkg.browser, format: 'cjs' }, | ||
{ file: pkg.module, format: 'es' }, | ||
{ file: pkg.unpkg, format: 'umd', name: 'ogl' } | ||
] | ||
input: 'src/index.js', | ||
output: [ | ||
{ file: pkg.browser, format: 'cjs' }, | ||
{ file: pkg.module, format: 'es' }, | ||
{ file: pkg.unpkg, format: 'umd', name: 'ogl' }, | ||
], | ||
}]; |
@@ -31,8 +31,21 @@ import {Transform} from './Transform.js'; | ||
this.normalMatrix = new Mat3(); | ||
this.beforeRenderCallbacks = []; | ||
this.afterRenderCallbacks = []; | ||
} | ||
onBeforeRender(f) { | ||
this.beforeRenderCallbacks.push(f); | ||
return this; | ||
} | ||
onAfterRender(f) { | ||
this.afterRenderCallbacks.push(f); | ||
return this; | ||
} | ||
draw({ | ||
camera, | ||
} = {}) { | ||
this.onBeforeRender && this.onBeforeRender({mesh: this, camera}); | ||
this.beforeRenderCallbacks.forEach(f => f && f({mesh: this, camera})); | ||
@@ -72,4 +85,4 @@ // Set the matrix uniforms | ||
this.onAfterRender && this.onAfterRender({mesh: this, camera}); | ||
this.afterRenderCallbacks.forEach(f => f && f({mesh: this, camera})); | ||
} | ||
} |
@@ -29,2 +29,3 @@ // TODO: multi target rendering | ||
this.height = height; | ||
this.depth = depth; | ||
this.buffer = this.gl.createFramebuffer(); | ||
@@ -55,10 +56,8 @@ this.target = target; | ||
this.depthTexture = new Texture(gl, { | ||
width, height, wrapS, wrapT, | ||
width, height, | ||
minFilter: this.gl.NEAREST, | ||
magFilter: this.gl.NEAREST, | ||
flipY: false, | ||
format: this.gl.DEPTH_COMPONENT, | ||
internalFormat: gl.renderer.isWebgl2 ? this.gl.DEPTH_COMPONENT24 : this.gl.DEPTH_COMPONENT, | ||
internalFormat: gl.renderer.isWebgl2 ? this.gl.DEPTH_COMPONENT16 : this.gl.DEPTH_COMPONENT, | ||
type: this.gl.UNSIGNED_INT, | ||
generateMipmaps: false, | ||
}); | ||
@@ -65,0 +64,0 @@ this.depthTexture.update(); |
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 too big to display
23858
823633
48