keplergl / kepler.gl

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
http://kepler.gl
MIT License
10.26k stars 1.72k forks source link

[Bug] Scenegraphs dont load from saved config #2051

Open backnotprop opened 1 year ago

backnotprop commented 1 year ago

Describe the bug Scenegraphs dont load from saved config

Scenegraph needs to be added to scenegraphVisConfigs in class scenegraph-layer and in class base-layer you all need to either add supported LAYER_VIS_CONFIGS for scenegraph (if possible in the wild west of abstractions), or create an additional else if statement supporting special case scenegraph.

To Reproduce I explained your code above. To fix*, fix your typescript files:

My lazy fix... I hacked the npm module files by modifying scenegraph-layer:

scenegraphVisConfigs = {
...
  colorRange: 'colorRange',
  scenegraph: 'scenegraph', // this
  sizeScale: 'sizeScale',
...
}

and in base layer

if (typeof configItem === 'string' && _constants.LAYER_VIS_CONFIGS[configItem]) {
 ...
} else if ((0, _typeof2["default"])(configItem) === 'object' && ['type', 'defaultValue'].every(function (p) {
  ...
})) {
} else if(configItem === "scenegraph") {
  _this3.config.visConfig[item] = "scenegraph"; // this
}

Expected behavior Custom scenegraphs can be saved in config, and loaded again (duck is only so cute for a little while)

DenisovKirill commented 1 year ago

@backnotprop, I have the same problem with config. Can you please specify exactly which files you are changing? Did this help to solve the problem?

backnotprop commented 1 year ago

@DenisovKirill

Kepler v3.0.0-alpha.0

node_modules/@kepler.gl/layers/dist/scenegraph-layer/scenegraph-layer.js

// ~ line 100
var scenegraphVisConfigs = {
  opacity: 'opacity',
  colorRange: 'colorRange',
  scenegraph: 'scenegraph', // <------ added this
  sizeScale: 'sizeScale',
 // angleX: ...

}

node_modules/@kepler.gl/layers/dist/base-layer.js

// ~550-570 (if block in registerVisConfig)
if (typeof configItem === 'string' && _constants.LAYER_VIS_CONFIGS[configItem]) {
    // ...
} else if ((0, _typeof2["default"])(configItem) === 'object' && ['type', 'defaultValue'].every(function (p) { return configItem.hasOwnProperty(p); })) {
  // ...
} else if(configItem === "scenegraph") {       // <------ added this additional else if
  _this3.config.visConfig[item] = "scenegraph";  
}