Skip to content

Commit 196416b

Browse files
Fix some UI issues (#638)
* avoid error when attrValue is undefined (for example material component set via a mixin for shortOrange entity) * fix wrong number type for animation loop property * prevent copy to clipboard buttons to expand/collapse the panel * refresh SceneGraph after cloning entity * remove unused variables (this fixes the warning for SphereBufferGeometry in three r144) * call helper update() only if the helper has an update method
1 parent 1dade31 commit 196416b

File tree

7 files changed

+22
-11
lines changed

7 files changed

+22
-11
lines changed

src/components/components/CommonComponents.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export default class CommonComponents extends React.Component {
105105
className="gltfIcon"
106106
onClick={event => {
107107
this.exportToGLTF();
108+
event.preventDefault();
108109
event.stopPropagation();
109110
}} >
110111
<img src={process.env.NODE_ENV === 'production' ? 'https://aframe.io/aframe-inspector/assets/gltf.svg' : '../assets/gltf.svg'} />
@@ -114,7 +115,10 @@ export default class CommonComponents extends React.Component {
114115
title="Copy entity HTML to clipboard"
115116
data-action="copy-entity-to-clipboard"
116117
className="button fa fa-clipboard"
117-
onClick={event => event.stopPropagation()}
118+
onClick={event => {
119+
event.preventDefault();
120+
event.stopPropagation();
121+
}}
118122
/>
119123
</div>
120124
);

src/components/components/Component.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ export default class Component extends React.Component {
149149
data-component={subComponentName || componentName}
150150
className="button fa fa-clipboard"
151151
href="#"
152+
onClick={event => {
153+
event.preventDefault();
154+
event.stopPropagation();
155+
}}
152156
/>
153157
<a
154158
title="Remove component"

src/components/components/PropertyRow.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ export default class PropertyRow extends React.Component {
4646
const isMap =
4747
props.componentname === 'material' &&
4848
(props.name === 'envMap' || props.name === 'src');
49-
const type = props.schema.type;
49+
let type = props.schema.type;
50+
if (props.componentname === 'animation' && props.name === 'loop') {
51+
// fix wrong number type for animation loop property
52+
type = 'boolean';
53+
}
5054

5155
const value =
5256
props.schema.type === 'selector'

src/components/scenegraph/SceneGraph.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export default class SceneGraph extends React.Component {
4747
this.rebuildEntityOptions();
4848
Events.on('entityidchange', this.rebuildEntityOptions);
4949
Events.on('entitycreated', this.rebuildEntityOptions);
50+
Events.on('entityclone', this.rebuildEntityOptions);
5051
}
5152

5253
/**

src/components/widgets/TextureWidget.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ export default class TextureWidget extends React.Component {
9393
if (!component) {
9494
return;
9595
}
96-
var newValue = component.attrValue[this.props.name];
96+
// component.attrValue may be undefined if component is from a mixin
97+
var newValue = component.attrValue && component.attrValue[this.props.name];
9798

9899
// This will be triggered typically when the element is changed directly with element.setAttribute
99100
if (newValue && newValue !== this.state.value) {

src/index.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,6 @@ Inspector.prototype = {
103103
},
104104

105105
addHelper: (function() {
106-
const geometry = new THREE.SphereBufferGeometry(2, 4, 2);
107-
const material = new THREE.MeshBasicMaterial({
108-
color: 0xff0000,
109-
visible: false
110-
});
111-
112106
return function(object) {
113107
let helper;
114108

@@ -132,7 +126,10 @@ Inspector.prototype = {
132126
helper.visible = false;
133127
this.sceneHelpers.add(helper);
134128
this.helpers[object.uuid] = helper;
135-
helper.update();
129+
// SkeletonHelper doesn't have an update method
130+
if (helper.update) {
131+
helper.update();
132+
}
136133
};
137134
})(),
138135

src/lib/viewport.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function Viewport(inspector) {
4141

4242
function updateHelpers(object) {
4343
object.traverse(node => {
44-
if (inspector.helpers[node.uuid]) {
44+
if (inspector.helpers[node.uuid] && inspector.helpers[node.uuid].update) {
4545
inspector.helpers[node.uuid].update();
4646
}
4747
});

0 commit comments

Comments
 (0)