diff --git a/src/editor/components/components/CommonComponents.js b/src/editor/components/components/CommonComponents.js index 0ad8c99f1..c076056d7 100644 --- a/src/editor/components/components/CommonComponents.js +++ b/src/editor/components/components/CommonComponents.js @@ -34,15 +34,14 @@ export default class CommonComponents extends React.Component { if (detail.entity !== this.props.entity) { return; } - if (DEFAULT_COMPONENTS.indexOf(detail.component) !== -1) { + if ( + DEFAULT_COMPONENTS.indexOf(detail.component) !== -1 || + detail.component === 'mixin' + ) { this.forceUpdate(); } }); - Events.on('refreshsidebarobject3d', () => { - this.forceUpdate(); - }); - var clipboard = new Clipboard('[data-action="copy-entity-to-clipboard"]', { text: (trigger) => { return getEntityClipboardRepresentation(this.props.entity); diff --git a/src/editor/components/components/ComponentsContainer.js b/src/editor/components/components/ComponentsContainer.js index 64d513b0f..d53e4400e 100644 --- a/src/editor/components/components/ComponentsContainer.js +++ b/src/editor/components/components/ComponentsContainer.js @@ -4,14 +4,22 @@ import Component from './Component'; import DEFAULT_COMPONENTS from './DefaultComponents'; import PropTypes from 'prop-types'; import React from 'react'; +import Events from '../../lib/Events'; export default class ComponentsContainer extends React.Component { static propTypes = { entity: PropTypes.object }; - refresh = () => { - this.forceUpdate(); - }; + componentDidMount() { + Events.on('entityupdate', (detail) => { + if (detail.entity !== this.props.entity) { + return; + } + if (detail.component === 'mixin') { + this.forceUpdate(); + } + }); + } render() { const entity = this.props.entity; diff --git a/src/editor/components/components/PropertyRow.js b/src/editor/components/components/PropertyRow.js index a8b1eb6a6..2076a5bfc 100644 --- a/src/editor/components/components/PropertyRow.js +++ b/src/editor/components/components/PropertyRow.js @@ -2,8 +2,6 @@ import React from 'react'; import classNames from 'classnames'; import PropTypes from 'prop-types'; -import debounce from 'lodash-es/debounce'; -import Events from '../../lib/Events'; import BooleanWidget from '../widgets/BooleanWidget'; import ColorWidget from '../widgets/ColorWidget'; @@ -36,19 +34,6 @@ export default class PropertyRow extends React.Component { constructor(props) { super(props); this.id = props.componentname + ':' + props.name; - - if ( - ['position', 'rotation', 'scale'].indexOf(this.props.componentname) !== -1 - ) { - Events.on( - 'entitytransformed', - debounce((entity) => { - if (entity === props.entity) { - this.forceUpdate(); - } - }, 250) - ); - } } getWidget() { diff --git a/src/editor/components/scenegraph/SceneGraph.js b/src/editor/components/scenegraph/SceneGraph.js index 4fda3af41..71cfffbb4 100644 --- a/src/editor/components/scenegraph/SceneGraph.js +++ b/src/editor/components/scenegraph/SceneGraph.js @@ -52,6 +52,11 @@ export default class SceneGraph extends React.Component { Events.on('entityidchange', this.rebuildEntityOptions); Events.on('entitycreated', this.rebuildEntityOptions); Events.on('entityclone', this.rebuildEntityOptions); + Events.on('entityupdate', (detail) => { + if (detail.component === 'mixin') { + this.rebuildEntityOptions(); + } + }); } /** diff --git a/src/editor/lib/viewport.js b/src/editor/lib/viewport.js index 784f216a8..602e0dcaf 100644 --- a/src/editor/lib/viewport.js +++ b/src/editor/lib/viewport.js @@ -106,8 +106,6 @@ export function Viewport(inspector) { updateHelpers(object); - Events.emit('refreshsidebarobject3d', object); - // Emit update event for watcher. let component; let value; @@ -135,8 +133,6 @@ export function Viewport(inspector) { property: '', value: value }); - - Events.emit('entitytransformed', transformControls.object.el); }); transformControls.addEventListener('mouseDown', () => {