Skip to content

Commit

Permalink
Fix scene hierarchy view
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsol committed Jun 22, 2019
1 parent 22227dd commit 967edc6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/core/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ Actor.prototype.setParent = function(parent, keep_local)
parent.obj.add(this.obj);
} else {
if (this.parent) {
THREE.SceneUtils.detach(this.obj, this.parent.obj, scene.obj);
scene.obj.attach(this.obj);
}
if (parent && parent !== scene) {
THREE.SceneUtils.attach(this.obj, scene.obj, parent.obj);
parent.obj.attach(this.obj);
}
}
if (this.parent) {
Expand Down
1 change: 0 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

<script src="../lib/jscolor-2.0.5/jscolor.js"></script>

<script src="../node_modules/three/examples/js/utils/SceneUtils.js"></script>
<script src="../node_modules/three/examples/js/controls/TransformControls.js"></script>
<script src="../node_modules/three/examples/js/loaders/FBXLoader.js"></script>
<script src="../node_modules/three/examples/js/loaders/OBJLoader.js"></script>
Expand Down
5 changes: 3 additions & 2 deletions src/views/scene-hierarchy.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ function SceneHierarchyView(container, state)
check_callback: true,
data: self.buildHierarchy(scene),
},
plugins: ['state', 'dnd'],
plugins: ['state', 'dnd', 'types'],
state: {key: 'scene-hierarchy_state'},
types: {'#': {max_children: 1}},
});
this.tree = this.hierarchy.jstree(true);

Expand Down Expand Up @@ -166,7 +167,7 @@ SceneHierarchyView.prototype.onNodeMove = function(event, data)
if (data.parent != data.old_parent) {
let node = data.node;
let actor = scene.getActor(node.id);
let parent = scene.getActor(data.parent);
let parent = scene.getActor(data.parent) || scene;
actor.setParent(parent);
for (let sibling of this.tree.get_siblings(node)) {
if (sibling.data.order > node.data.order) {
Expand Down

0 comments on commit 967edc6

Please sign in to comment.