Skip to content

Commit

Permalink
fix scenegraph example bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiaoji Chen committed May 31, 2019
1 parent 1e61b1c commit 53cb2bd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
11 changes: 1 addition & 10 deletions examples/layer-browser/src/app.js
Expand Up @@ -211,15 +211,6 @@ export default class App extends PureComponent {
return new Layer(layerProps);
}

// Flatten layer props
_getLayerSettings(props) {
const settings = {};
for (const key in props) {
settings[key] = props[key];
}
return settings;
}

/* eslint-disable max-depth */
_renderExamples() {
let index = 1;
Expand All @@ -235,7 +226,7 @@ export default class App extends PureComponent {
const layer = this._renderExampleLayer(example, settings, index++);

if (typeof settings !== 'object') {
activeExamples[exampleName] = this._getLayerSettings(layer.props);
activeExamples[exampleName] = LayerControls.getSettingValues(layer.props);
}

layers.push(layer);
Expand Down
32 changes: 19 additions & 13 deletions examples/layer-browser/src/components/layer-controls.js
Expand Up @@ -27,14 +27,31 @@ const PROP_BLACK_LIST = new Set([
'onClick',
'highlightedObjectIndex',
'parameters',
'uniforms'
'uniforms',
'scenegraph'
]);

function isAccessor(settingName) {
return settingName.indexOf('get') === 0;
}

export default class LayerControls extends PureComponent {
static getSettingValues(props) {
const keys = [];
for (const key in props) {
if (!PROP_BLACK_LIST.has(key)) {
keys.push(key);
}
}
keys.sort();

const settings = {};
for (const key of keys) {
settings[key] = props[key];
}
return settings;
}

constructor(props) {
super(props);
autobind(this);
Expand All @@ -52,17 +69,6 @@ export default class LayerControls extends PureComponent {
return Object.assign({}, layer && layer._propTypes, propTypes);
}

// Get all inherited property keys
_getAllPropKeys(object) {
const keys = [];
for (const key in object) {
if (!PROP_BLACK_LIST.has(key)) {
keys.push(key);
}
}
return keys.sort();
}

_onToggleTransition(settingName, transitioned) {
const {settings} = this.props;
const newSettings = {
Expand Down Expand Up @@ -269,7 +275,7 @@ export default class LayerControls extends PureComponent {
return (
<div className="layer-controls">
{title && <h4>{title}</h4>}
{this._getAllPropKeys(settings).map(key =>
{Object.keys(settings).map(key =>
this._renderSetting({
settingName: key,
value: settings[key],
Expand Down

0 comments on commit 53cb2bd

Please sign in to comment.