Skip to content

Commit

Permalink
alternative
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiaoji Chen committed Aug 2, 2019
1 parent 4f8bf81 commit e77402c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
9 changes: 5 additions & 4 deletions modules/core/src/lib/deck.js
Expand Up @@ -26,7 +26,7 @@ import Effect from './effect';
import DeckRenderer from './deck-renderer';
import DeckPicker from './deck-picker';
import log from '../utils/log';
import init from './init';
import deckGlobal from './init';

import GL from '@luma.gl/constants';
import {
Expand Down Expand Up @@ -123,9 +123,6 @@ const defaultProps = {
/* eslint-disable max-statements */
export default class Deck {
constructor(props) {
// Make sure we register default loaders and shaders
init();

props = Object.assign({}, defaultProps, props);

this.width = 0; // "read-only", auto-updated from canvas
Expand Down Expand Up @@ -828,3 +825,7 @@ function isIE11() {

Deck.getPropTypes = getPropTypes;
Deck.defaultProps = defaultProps;

// This is used to defeat tree shaking of init.js
// https://github.com/uber/deck.gl/issues/3213
Deck.VERSION = deckGlobal.VERSION;
16 changes: 4 additions & 12 deletions modules/core/src/lib/init.js
Expand Up @@ -46,18 +46,10 @@ if (!global.deck) {
version,
log
};
}

let initialized = false;

// This is wrapped in a function and imported by deck.js to defeat tree shaking
// https://github.com/uber/deck.gl/issues/3213
export default function init() {
if (!initialized) {
registerLoaders([jsonLoader, HTMLImageLoader]);
initializeShaderModules();
registerLoaders([jsonLoader, HTMLImageLoader]);

// Loaders and shaders are registered globally -- only call once
initialized = true;
}
initializeShaderModules();
}

export default global.deck;
4 changes: 1 addition & 3 deletions modules/core/src/shaderlib/index.js
Expand Up @@ -32,9 +32,7 @@ import project64 from './project64/project64';
import shadow from './shadow/shadow';

export function initializeShaderModules() {
registerShaderModules([fp32, project, project32, gouraudlighting, phonglighting, picking], {
ignoreMultipleRegistrations: true
});
registerShaderModules([fp32, project, project32, gouraudlighting, phonglighting, picking]);

setDefaultShaderModules([geometry, project]);

Expand Down

0 comments on commit e77402c

Please sign in to comment.