Skip to content

Commit

Permalink
Remove unused/unfinished classes (#1000)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsherif committed Mar 22, 2019
1 parent 0859f92 commit e22e541
Show file tree
Hide file tree
Showing 30 changed files with 166 additions and 110 deletions.
1 change: 1 addition & 0 deletions .prettierignore
@@ -1,3 +1,4 @@
**/dist*/**/*.js
workers/
*.min.js
wip/
55 changes: 42 additions & 13 deletions examples/core/dof/app.js
Expand Up @@ -7,6 +7,7 @@ import {
Program,
Texture2D,
VertexArray,
UniformBufferLayout,
Buffer,
isWebGL2,
Cube
Expand Down Expand Up @@ -184,10 +185,12 @@ precision highp float;
#define MAX_BLUR 20.0
uniform vec2 uDepthRange;
uniform float uFocusDistance;
uniform float uBlurCoefficient;
uniform float uPPM;
uniform DOFUniforms {
vec2 uDepthRange;
float uFocusDistance;
float uBlurCoefficient;
float uPPM;
};
uniform vec2 uTexelOffset;
Expand Down Expand Up @@ -255,15 +258,31 @@ export const animationLoopOptions = {
// Create postprocessing pass program.
///////////////////////////////////////

const dofUniformsLayout = new UniformBufferLayout({
uDepthRange: gl.FLOAT_VEC2,
uFocusDistance: gl.FLOAT,
uBlurCoefficient: gl.FLOAT,
uPPM: gl.FLOAT
}).setUniforms({
uDepthRange: [NEAR, FAR]
});

const dofUniforms = new Buffer(gl, {
target: GL.UNIFORM_BUFFER,
data: dofUniformsLayout.getData(),
accessor: {
index: 0
}
});

const dofProgram = new Program(gl, {
id: 'DOF_PROGRAM',
vs: DOF_VERTEX,
fs: DOF_FRAGMENT,
uniforms: {
uDepthRange: [NEAR, FAR]
}
fs: DOF_FRAGMENT
});

dofProgram.uniformBlockBinding(dofProgram.getUniformBlockIndex('DOFUniforms'), 0);

//////////////////////
// Set up frambuffers.
//////////////////////
Expand Down Expand Up @@ -419,6 +438,8 @@ export const animationLoopOptions = {
dofFramebuffer,
quadVertexArray,
dofProgram,
dofUniforms,
dofUniformsLayout,
statsWidget
};
},
Expand All @@ -436,6 +457,8 @@ export const animationLoopOptions = {
dofFramebuffer,
quadVertexArray,
dofProgram,
dofUniforms,
dofUniformsLayout,
statsWidget
}) => {
if (!isDemoSupported) {
Expand Down Expand Up @@ -502,10 +525,17 @@ export const animationLoopOptions = {
texelOffset[0] = 1;
texelOffset[1] = 0;

dofProgram.setUniforms({
dofUniformsLayout.setUniforms({
uFocusDistance: focusDistance,
uBlurCoefficient: blurCoefficient,
uPPM: ppm,
uPPM: ppm
});

dofUniforms.setData(dofUniformsLayout.getData());

dofUniforms.bind();

dofProgram.setUniforms({
uTexelOffset: texelOffset,
uColor: sceneFramebuffer.color,
uDepth: sceneFramebuffer.depth
Expand All @@ -525,9 +555,6 @@ export const animationLoopOptions = {
texelOffset[1] = 1;

dofProgram.setUniforms({
uFocusDistance: focusDistance,
uBlurCoefficient: blurCoefficient,
uPPM: ppm,
uTexelOffset: texelOffset,
uColor: sceneFramebuffer.color,
uDepth: sceneFramebuffer.depth
Expand All @@ -538,6 +565,8 @@ export const animationLoopOptions = {
drawMode: gl.TRIANGLE_STRIP,
vertexCount: 4
});

dofUniforms.unbind();
}
};

Expand Down
5 changes: 4 additions & 1 deletion examples/core/dof/package.json
Expand Up @@ -9,7 +9,10 @@
"start-local": "webpack-dev-server --env.local --progress --hot --open -d"
},
"dependencies": {
"@luma.gl/core": "^7.0.0-alpha"
"@luma.gl/constants": "^7.0.0-alpha.3",
"@luma.gl/core": "^7.0.0-alpha",
"@probe.gl/stats-widget": "^3.0.0-alpha.3",
"math.gl": "^2.3.1"
},
"devDependencies": {
"html-webpack-plugin": "^3.2.0",
Expand Down
75 changes: 45 additions & 30 deletions examples/core/instancing/app.js
@@ -1,11 +1,11 @@
import {
AnimationLoop,
setParameters,
// pickModels,
Cube,
picking,
dirlight,
lumaStats
lumaStats,
readPixelsToArray
} from '@luma.gl/core';
import {Matrix4, radians} from 'math.gl';
import {StatsWidget} from '@probe.gl/stats-widget';
Expand All @@ -18,6 +18,10 @@ A luma.gl <code>Cube</code>, rendering 65,536 instances in a
single GPU draw call using instanced vertex attributes.
`;

function getDevicePixelRatio() {
return typeof window !== 'undefined' ? window.devicePixelRatio : 1;
}

const SIDE = 256;

// Make a cube with 65K instances and attributes to control offset and color of each instance
Expand Down Expand Up @@ -181,38 +185,21 @@ class AppAnimationLoop extends AnimationLoop {
}

onRender(animationProps) {
const {
gl,
timeWidget,
memWidget
} = animationProps;
const {gl, timeWidget, memWidget} = animationProps;

timeWidget.update();
memWidget.update();

/*
const {
framebuffer,
useDevicePixels,
_mousePosition,
} = animationProps;
// "Pick" the cube under the mouse
const pickInfo =
_mousePosition &&
pickModels(gl, {
models: [this.cube],
position: _mousePosition,
useDevicePixels,
framebuffer
});
// Highlight it
const pickingSelectedColor = (pickInfo && pickInfo.color) || null;
this.cube.updateModuleSettings({
pickingSelectedColor
});
*/
const {framebuffer, useDevicePixels, _mousePosition} = animationProps;

if (_mousePosition) {
const dpr = useDevicePixels ? getDevicePixelRatio() : 1;

const pickX = _mousePosition[0] * dpr;
const pickY = gl.canvas.height - _mousePosition[1] * dpr;

pickInstance(gl, pickX, pickY, this.cube, framebuffer);
}

// Draw the cubes
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
Expand All @@ -224,6 +211,34 @@ class AppAnimationLoop extends AnimationLoop {
}
}

function pickInstance(gl, pickX, pickY, model, framebuffer) {
framebuffer.clear({color: true, depth: true});
// Render picking colors
/* eslint-disable camelcase */
model.setUniforms({picking_uActive: 1});
model.draw({framebuffer});
model.setUniforms({picking_uActive: 0});

const color = readPixelsToArray(framebuffer, {
sourceX: pickX,
sourceY: pickY,
sourceWidth: 1,
sourceHeight: 1,
sourceFormat: gl.RGBA,
sourceType: gl.UNSIGNED_BYTE
});

if (color[0] + color[1] + color[2] > 0) {
model.updateModuleSettings({
pickingSelectedColor: color
});
} else {
model.updateModuleSettings({
pickingSelectedColor: null
});
}
}

const animationLoop = new AppAnimationLoop();

export default animationLoop;
Expand Down
4 changes: 3 additions & 1 deletion examples/core/instancing/package.json
Expand Up @@ -5,7 +5,9 @@
"build": "webpack --env.local --env.analyze --profile --json > stats.json"
},
"dependencies": {
"@luma.gl/core": "7.0.0-alpha"
"@luma.gl/core": "7.0.0-alpha",
"@probe.gl/stats-widget": "^3.0.0-alpha.3",
"math.gl": "^2.3.1"
},
"devDependencies": {
"html-webpack-plugin": "^3.2.0",
Expand Down

0 comments on commit e22e541

Please sign in to comment.