Skip to content

Commit

Permalink
Merge 9171e48 into f96204e
Browse files Browse the repository at this point in the history
  • Loading branch information
tsherif committed Nov 21, 2019
2 parents f96204e + 9171e48 commit cac6e9d
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Expand Up @@ -4,4 +4,4 @@ node_modules/
workers/
dist.js
*.min.js
mapbox-gl-dev.js
mapbox-gl.js
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -29,4 +29,3 @@ package-lock.json
*.rar
*.log
.exit_code
*.min.js
8 changes: 4 additions & 4 deletions examples/webpack.config.local.js
Expand Up @@ -21,18 +21,18 @@ function makeLocalDevConfig(EXAMPLE_DIR = LIB_DIR, linkToLuma) {
'@luma.gl/constants': `${ROOT_DIR}/../luma.gl/modules/constants/src`,
'@luma.gl/core': `${ROOT_DIR}/../luma.gl/modules/core/src`,
'@luma.gl/debug': `${ROOT_DIR}/../luma.gl/modules/debug/src`,
'@luma.gl/engine': `${ROOT_DIR}/../luma.gl/modules/engine/src`,
'@luma.gl/webgl': `${ROOT_DIR}/../luma.gl/modules/webgl/src`,
'@luma.gl/webgl-state-tracker': `${ROOT_DIR}/../luma.gl/modules/webgl-state-tracker/src`,
'@luma.gl/webgl2-polyfill': `${ROOT_DIR}/../luma.gl/modules/webgl2-polyfill/src`,
'@luma.gl/gltools': `${ROOT_DIR}/../luma.gl/modules/gltools/src`,
'@luma.gl/shadertools': `${ROOT_DIR}/../luma.gl/modules/shadertools/src`,
'@luma.gl/addons': `${ROOT_DIR}/../luma.gl/modules/addons/src`
};
const LUMA_LOCAL_ALIASES = {
'@luma.gl/constants': `${ROOT_DIR}/node_modules/@luma.gl/constants`,
'@luma.gl/core': `${ROOT_DIR}/node_modules/@luma.gl/core`,
'@luma.gl/engine': `${ROOT_DIR}/node_modules/@luma.gl/engine`,
'@luma.gl/webgl': `${ROOT_DIR}/node_modules/@luma.gl/webgl`,
'@luma.gl/webgl-state-tracker': `${ROOT_DIR}/node_modules/@luma.gl/webgl-state-tracker`,
'@luma.gl/webgl2-polyfill': `${ROOT_DIR}/node_modules/@luma.gl/webgl2-polyfill`,
'@luma.gl/gltools': `${ROOT_DIR}/node_modules/@luma.gl/gltools`,
'@luma.gl/shadertools': `${ROOT_DIR}/node_modules/@luma.gl/shadertools`,
'@luma.gl/addons': `${ROOT_DIR}/node_modules/@luma.gl/addons`,
// @luma.gl/addons is not available in the root node_modules, must be imported
Expand Down
1 change: 1 addition & 0 deletions modules/core/src/lib/deck.js
Expand Up @@ -476,6 +476,7 @@ export default class Deck {
height,
useDevicePixels,
autoResizeDrawingBuffer,
autoResizeViewport: false,
gl,
onCreateContext: opts =>
createGLContext(Object.assign({}, glOptions, opts, {canvas: this.canvas, debug})),
Expand Down
6 changes: 4 additions & 2 deletions modules/core/src/lib/layer.js
Expand Up @@ -27,7 +27,7 @@ import {diffProps, validateProps} from '../lifecycle/props';
import {count} from '../utils/count';
import log from '../utils/log';
import GL from '@luma.gl/constants';
import {withParameters} from '@luma.gl/core';
import {withParameters, setParameters} from '@luma.gl/core';
import assert from '../utils/assert';
import {mergeShaders} from '../utils/shader';
import {projectPosition, getWorldPosition} from '../shaderlib/project/project-functions';
Expand Down Expand Up @@ -702,12 +702,14 @@ export default class Layer extends Component {
// TODO - move to draw-layers
const {getPolygonOffset} = this.props;
const offsets = (getPolygonOffset && getPolygonOffset(uniforms)) || [0, 0];
parameters.polygonOffset = offsets;

setParameters({polygonOffset: offsets});

// Call subclass lifecycle method
withParameters(this.context.gl, parameters, () => {
this.draw({moduleParameters, uniforms, parameters, context: this.context});
});

// End lifecycle method

this.props = currentProps;
Expand Down
24 changes: 9 additions & 15 deletions modules/core/src/passes/layers-pass.js
@@ -1,12 +1,13 @@
import GL from '@luma.gl/constants';
import Pass from './pass';
import {clear, withParameters, cssToDeviceRatio} from '@luma.gl/core';
import {clear, setParameters, withParameters, cssToDeviceRatio} from '@luma.gl/core';

export default class LayersPass extends Pass {
render(props) {
const gl = this.gl;

return withParameters(gl, {framebuffer: props.target}, () => this._drawLayers(props));
setParameters(gl, {framebuffer: props.target});
return this._drawLayers(props);
}

// PRIVATE
Expand Down Expand Up @@ -68,6 +69,8 @@ export default class LayersPass extends Pass {
pickableCount: 0
};

setParameters({viewport: glViewport});

// render layers in normal colors
layers.forEach((layer, layerIndex) => {
// Check if we should draw layer
Expand All @@ -87,7 +90,7 @@ export default class LayersPass extends Pass {

const _moduleParameters = this._getModuleParameters(layer, effects, pass, moduleParameters);
const uniforms = Object.assign({}, layer.context.uniforms, {layerIndex});
const layerParameters = this._getLayerParameters(layer, layerIndex, glViewport);
const layerParameters = this.getLayerParameters(layer, layerIndex);

layer.drawLayer({
moduleParameters: _moduleParameters,
Expand All @@ -110,7 +113,7 @@ export default class LayersPass extends Pass {
}

getLayerParameters(layer, layerIndex) {
return null;
return layer.props.parameters;
}

/* Private */
Expand Down Expand Up @@ -144,14 +147,6 @@ export default class LayersPass extends Pass {

return Object.assign(moduleParameters, this.getModuleParameters(layer, effects), overrides);
}

_getLayerParameters(layer, layerIndex, glViewport) {
// All parameter resolving is done here instead of the layer
// Blend parameters must not be overridden during picking
return Object.assign({}, layer.props.parameters, this.getLayerParameters(layer, layerIndex), {
viewport: glViewport
});
}
}

// Convert viewport top-left CSS coordinates to bottom up WebGL coordinates
Expand All @@ -174,7 +169,6 @@ function clearGLCanvas(gl) {
const width = gl.drawingBufferWidth;
const height = gl.drawingBufferHeight;
// clear depth and color buffers, restoring transparency
withParameters(gl, {viewport: [0, 0, width, height]}, () => {
gl.clear(GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT);
});
setParameters(gl, {viewport: [0, 0, width, height]});
gl.clear(GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT);
}
5 changes: 4 additions & 1 deletion modules/core/src/passes/pick-layers-pass.js
Expand Up @@ -86,8 +86,11 @@ export default class PickLayersPass extends LayersPass {

getLayerParameters(layer, layerIndex) {
// These will override any layer parameters
return this.pickZ
const pickParameters = this.pickZ
? {blend: false}
: {...PICKING_PARAMETERS, blend: true, blendColor: [0, 0, 0, (layerIndex + 1) / 255]};

// Override layer parameters with pick parameters
return Object.assign({}, layer.props.parameters, pickParameters);
}
}
23 changes: 11 additions & 12 deletions modules/core/src/shaderlib/project/viewport-uniforms.js
Expand Up @@ -172,18 +172,17 @@ export function getUniformsFromViewport({
} = {}) {
assert(viewport);

return Object.assign(
{
project_uModelMatrix: modelMatrix || IDENTITY_MATRIX
},
getMemoizedViewportUniforms({
viewport,
devicePixelRatio,
coordinateSystem,
coordinateOrigin,
wrapLongitude
})
);
const uniforms = getMemoizedViewportUniforms({
viewport,
devicePixelRatio,
coordinateSystem,
coordinateOrigin,
wrapLongitude
});

uniforms.project_uModelMatrix = modelMatrix || IDENTITY_MATRIX;

return uniforms;
}

function calculateViewportUniforms({
Expand Down
23 changes: 11 additions & 12 deletions modules/layers/src/scatterplot-layer/scatterplot-layer.js
Expand Up @@ -126,18 +126,17 @@ export default class ScatterplotLayer extends Layer {
const widthMultiplier = lineWidthUnits === 'pixels' ? viewport.metersPerPixel : 1;

this.state.model
.setUniforms(
Object.assign({}, uniforms, {
stroked: stroked ? 1 : 0,
filled,
radiusScale,
radiusMinPixels,
radiusMaxPixels,
lineWidthScale: lineWidthScale * widthMultiplier,
lineWidthMinPixels,
lineWidthMaxPixels
})
)
.setUniforms(uniforms)
.setUniforms({
stroked: stroked ? 1 : 0,
filled,
radiusScale,
radiusMinPixels,
radiusMaxPixels,
lineWidthScale: lineWidthScale * widthMultiplier,
lineWidthMinPixels,
lineWidthMaxPixels
})
.draw();
}

Expand Down
4 changes: 2 additions & 2 deletions ocular-dev-tools.config.js
Expand Up @@ -5,9 +5,9 @@ const LUMA_ALIASES_LOCAL = {
'@luma.gl/constants': `${__dirname}/../luma.gl/modules/constants/src`,
'@luma.gl/core': `${__dirname}/../luma.gl/modules/core/src`,
'@luma.gl/debug': `${__dirname}/../luma.gl/modules/debug/src`,
'@luma.gl/engine': `${__dirname}/../luma.gl/modules/engine/src`,
'@luma.gl/webgl': `${__dirname}/../luma.gl/modules/webgl/src`,
'@luma.gl/webgl-state-tracker': `${__dirname}/../luma.gl/modules/webgl-state-tracker/src`,
'@luma.gl/webgl2-polyfill': `${__dirname}/../luma.gl/modules/webgl2-polyfill/src`
'@luma.gl/gltools': `${__dirname}/../luma.gl/modules/gltools/src`
};

const useLocalLuma = false;
Expand Down
1 change: 1 addition & 0 deletions test/apps/stress-tests/package.json
Expand Up @@ -5,6 +5,7 @@
"scripts": {
"start": "webpack-dev-server --progress --hot --open",
"start-local": "webpack-dev-server --env.local --progress --hot --open",
"start-luma": "webpack-dev-server --env.local --env.local-luma --progress --hot --open",
"build": "webpack -p"
},
"dependencies": {
Expand Down
25 changes: 25 additions & 0 deletions test/apps/stress-tests/pico-mercator/lib/pico-mercator.min.js

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions test/apps/stress-tests/pico-mercator/lib/picogl.min.js

Large diffs are not rendered by default.

0 comments on commit cac6e9d

Please sign in to comment.