Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
154 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Test rendering to a frame buffer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import {Deck} from '@deck.gl/core'; | ||
import {BitmapLayer, GeoJsonLayer} from '@deck.gl/layers'; | ||
import {Framebuffer, Texture2D} from '@luma.gl/core'; | ||
import GL from '@luma.gl/constants'; | ||
|
||
import sfZipcodes from '../../../examples/layer-browser/data/sf.zip.geo.json'; | ||
|
||
let framebuffer; | ||
|
||
const deck = new Deck({ | ||
onWebGLInitialized: onInitialize, | ||
onLoad, | ||
initialViewState: { | ||
longitude: -122.45, | ||
latitude: 37.76, | ||
zoom: 11, | ||
bearing: 0, | ||
pitch: 30 | ||
}, | ||
controller: true | ||
}); | ||
|
||
function noop() {} | ||
|
||
function onInitialize(gl) { | ||
framebuffer = new Framebuffer(gl); | ||
framebuffer.attach({ | ||
[GL.COLOR_ATTACHMENT0]: new Texture2D(gl, { | ||
mipmaps: false, | ||
parameters: { | ||
[GL.TEXTURE_MIN_FILTER]: GL.LINEAR, | ||
[GL.TEXTURE_MAG_FILTER]: GL.LINEAR, | ||
[GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE, | ||
[GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
function onLoad() { | ||
framebuffer.resize(); | ||
|
||
deck.setProps({ | ||
layers: [ | ||
new GeoJsonLayer({ | ||
data: sfZipcodes, | ||
opacity: 0.5, | ||
extruded: true, | ||
getFillColor: [255, 0, 0], | ||
getElevation: d => Math.random() * 3000 | ||
}) | ||
], | ||
_framebuffer: framebuffer, | ||
onAfterRender | ||
}); | ||
} | ||
|
||
function onAfterRender() { | ||
const texture = framebuffer.color; | ||
framebuffer.attach({ | ||
[GL.COLOR_ATTACHMENT0]: null | ||
}); | ||
|
||
deck.setProps({ | ||
layers: [ | ||
new BitmapLayer({ | ||
bounds: [-122.519, 37.7045, -122.355, 37.829], | ||
image: texture | ||
}) | ||
], | ||
_framebuffer: null, | ||
onAfterRender: noop | ||
}); | ||
} | ||
|
||
/* global document */ | ||
document.body.style.margin = '0px'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "video", | ||
"version": "0.0.0", | ||
"license": "MIT", | ||
"scripts": { | ||
"start-local": "webpack-dev-server --env.local --progress --hot --open", | ||
"start": "webpack-dev-server --progress --hot --open" | ||
}, | ||
"dependencies": { | ||
"deck.gl": "^7.3.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.4.0", | ||
"@babel/preset-react": "^7.0.0", | ||
"babel-loader": "^8.0.5", | ||
"html-webpack-plugin": "^4.0.0-beta.5", | ||
"webpack": "^4.20.2", | ||
"webpack-cli": "^3.1.2", | ||
"webpack-dev-server": "^3.1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// NOTE: To use this example standalone (e.g. outside of deck.gl repo) | ||
// delete the local development overrides at the bottom of this file | ||
const HTMLWebpackPlugin = require('html-webpack-plugin'); | ||
|
||
const CONFIG = { | ||
mode: 'development', | ||
|
||
entry: { | ||
app: './app.js' | ||
}, | ||
|
||
output: { | ||
library: 'App' | ||
}, | ||
|
||
module: { | ||
rules: [ | ||
{ | ||
// Transpile ES6 to ES5 with babel | ||
// Remove if your app does not use JSX or you don't need to support old browsers | ||
test: /\.js$/, | ||
loader: 'babel-loader', | ||
exclude: [/node_modules/] | ||
} | ||
] | ||
}, | ||
|
||
plugins: [new HTMLWebpackPlugin()] | ||
}; | ||
|
||
// This line enables bundling against src in this repo rather than installed module | ||
module.exports = env => (env ? require('../webpack.config.local')(CONFIG)(env) : CONFIG); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1 @@ | ||
// This file contains webpack configuration settings that allow | ||
// examples to be built against the deck.gl source code in this repo instead | ||
// of building against their installed version of deck.gl. | ||
// | ||
// This enables using the examples to debug the main deck.gl library source | ||
// without publishing or npm linking, with conveniences such hot reloading etc. | ||
|
||
// avoid destructuring for older Node version support | ||
const resolve = require('path').resolve; | ||
const webpack = require('webpack'); | ||
|
||
const LIB_DIR = resolve(__dirname, '../..'); | ||
const SRC_DIR = resolve(LIB_DIR, 'modules'); | ||
|
||
const ALIASES = require('ocular-dev-tools/config/ocular.config')({ | ||
root: resolve(__dirname, '../..') | ||
}).aliases; | ||
|
||
// Support for hot reloading changes to the deck.gl library: | ||
function makeLocalDevConfig(EXAMPLE_DIR = LIB_DIR) { | ||
return { | ||
// TODO - Uncomment when all examples use webpack 4 for faster bundling | ||
// mode: 'development', | ||
|
||
// suppress warnings about bundle size | ||
devServer: { | ||
stats: { | ||
warnings: false | ||
} | ||
}, | ||
|
||
devtool: 'source-map', | ||
|
||
resolve: { | ||
alias: Object.assign({}, ALIASES, { | ||
// Use luma.gl specified by root package.json | ||
'luma.gl': resolve(LIB_DIR, './node_modules/luma.gl'), | ||
// Important: ensure shared dependencies come from the main node_modules dir | ||
// Versions will be controlled by the deck.gl top level package.json | ||
'math.gl': resolve(LIB_DIR, './node_modules/math.gl'), | ||
'viewport-mercator-project': resolve(LIB_DIR, './node_modules/viewport-mercator-project'), | ||
seer: resolve(LIB_DIR, './node_modules/seer'), | ||
react: resolve(LIB_DIR, './node_modules/react') | ||
}) | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
// Unfortunately, webpack doesn't import library sourcemaps on its own... | ||
test: /\.js$/, | ||
use: ['source-map-loader'], | ||
enforce: 'pre' | ||
}, | ||
{ | ||
// Compile source using babel. This is not necessary for src to run in the browser | ||
// However class inheritance cannot happen between transpiled/non-transpiled code | ||
// Which affects some examples | ||
test: /\.js$/, | ||
loader: 'babel-loader', | ||
options: { | ||
presets: ['@babel/env'] | ||
}, | ||
include: [SRC_DIR] | ||
} | ||
] | ||
}, | ||
// Optional: Enables reading mapbox token from environment variable | ||
plugins: [new webpack.EnvironmentPlugin(['MapboxAccessToken'])] | ||
}; | ||
} | ||
|
||
function addLocalDevSettings(config, exampleDir) { | ||
const LOCAL_DEV_CONFIG = makeLocalDevConfig(exampleDir); | ||
config = Object.assign({}, LOCAL_DEV_CONFIG, config); | ||
config.resolve = config.resolve || {}; | ||
config.resolve.alias = config.resolve.alias || {}; | ||
Object.assign(config.resolve.alias, LOCAL_DEV_CONFIG.resolve.alias); | ||
|
||
config.module = config.module || {}; | ||
Object.assign(config.module, { | ||
rules: (config.module.rules || []).concat(LOCAL_DEV_CONFIG.module.rules) | ||
}); | ||
return config; | ||
} | ||
|
||
module.exports = (config, exampleDir) => env => { | ||
// npm run start-local now transpiles the lib | ||
if (env && env.local) { | ||
config = addLocalDevSettings(config, exampleDir); | ||
} | ||
|
||
// npm run start-es6 does not transpile the lib | ||
if (env && env.es6) { | ||
config = addLocalDevSettings(config, exampleDir); | ||
} | ||
|
||
// console.warn(JSON.stringify(config, null, 2)); // uncomment to debug config | ||
return config; | ||
}; | ||
module.exports = require('../../examples/webpack.config.local'); |