Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

add: "Street Segments" and "imagery" entities are expanded upon load … #69

Merged
merged 1 commit into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions src/components/scenegraph/Entity.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import { cloneEntity, printEntity, removeEntity } from '../../lib/entity';

import PropTypes from 'prop-types';
import React from 'react';
import classnames from 'classnames';
import { printEntity, removeEntity, cloneEntity } from '../../lib/entity';

const Events = require('../../lib/Events.js');

Expand All @@ -13,23 +14,29 @@ export default class Entity extends React.Component {
isFiltering: PropTypes.bool,
isSelected: PropTypes.bool,
selectEntity: PropTypes.func,
toggleExpandedCollapsed: PropTypes.func
toggleExpandedCollapsed: PropTypes.func,
isInitiallyExpanded: PropTypes.bool,
initiallyExpandEntity: PropTypes.func
};

constructor(props) {
super(props);
this.state = {};
}

onClick = (evt) => {
componentDidMount() {
!this.props.isInitiallyExpanded && this.props.initiallyExpandEntity();
}

onClick = evt => {
if (!evt.target.classList.contains('fa')) {
this.props.selectEntity(this.props.entity);
}
}
}
};

onDoubleClick = () => Events.emit('objectfocus', this.props.entity.object3D);

toggleVisibility = (evt) => {
toggleVisibility = evt => {
const entity = this.props.entity;
const visible =
entity.tagName.toLowerCase() === 'a-scene'
Expand Down Expand Up @@ -68,13 +75,20 @@ export default class Entity extends React.Component {
);

// Add spaces depending on depth.
const pad = (this.props.depth > 1)? '    '.repeat(this.props.depth):'';
const pad =
this.props.depth > 1
? '    '.repeat(this.props.depth)
: '';

let collapse;
if (entity.children.length > 0 && !isFiltering && !!entity.hasAttribute('data-layer-show-children')) {
if (
entity.children.length > 0 &&
!isFiltering &&
!!entity.hasAttribute('data-layer-show-children')
) {
collapse = (
<span
onClick={(evt) => {
onClick={evt => {
evt.stopPropagation();
this.props.toggleExpandedCollapsed(entity);
}}
Expand Down
18 changes: 17 additions & 1 deletion src/components/scenegraph/SceneGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export default class SceneGraph extends React.Component {
filter: '',
filteredEntities: [],
selectedIndex: -1,
leftBarHide: false
leftBarHide: false,
initiallyExpandedEntities: []
};

this.rebuildEntityOptions = debounce(
Expand Down Expand Up @@ -279,6 +280,21 @@ export default class SceneGraph extends React.Component {
isSelected={this.props.selectedEntity === entityOption.entity}
selectEntity={this.selectEntity}
toggleExpandedCollapsed={this.toggleExpandedCollapsed}
isInitiallyExpanded={this.state.initiallyExpandedEntities.some(
item => item === entityOption.entity.id
)}
initiallyExpandEntity={() => {
this.toggleExpandedCollapsed(entityOption.entity);
this.setState(prevState => ({
...prevState,
initiallyExpandedEntities: [
...prevState.initiallyExpandedEntities.filter(
item => item !== entityOption.entity.id
),
entityOption.entity.id
]
}));
}}
/>
);
layerEntities.push(entity);
Expand Down