Skip to content

Commit

Permalink
Merge pull request #15 from jpooleycodes/look_at_selection
Browse files Browse the repository at this point in the history
Double clicking GameObject looks at object
  • Loading branch information
JamesTKhan authored Apr 18, 2022
2 parents 6d1f3f8 + 4e16cd7 commit 7e03e32
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions editor/src/main/com/mbrlabs/mundus/editor/ui/modules/Outline.kt
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,39 @@ class Outline : VisTable(),

})

// right click menu listener
tree.addListener(object : InputListener() {
tree.addListener(object : ClickListener() {
override fun clicked(event: InputEvent?, x: Float, y: Float) {
if (tapCount != 2)
return

val go = tree.getNodeAt(y)?.value

if (go != null) {
val context = projectManager.current()
val pos = Vector3()
go.transform.getTranslation(pos)

// just lerp in the direction of the object if certain distance away
if (pos.dst(context.currScene.cam.position) > 100)
context.currScene.cam.position.lerp(pos.cpy().add(0f,40f,0f), 0.5f)

context.currScene.cam.lookAt(pos)
context.currScene.cam.up.set(Vector3.Y)
}

}

override fun touchDown(event: InputEvent?, x: Float, y: Float, pointer: Int, button: Int): Boolean {
if (Input.Buttons.LEFT != button) {
return true
}
return super.touchDown(event, x, y, pointer, button)
}

// right click menu listener
override fun touchUp(event: InputEvent?, x: Float, y: Float, pointer: Int, button: Int) {
if (Input.Buttons.RIGHT != button) {
super.touchUp(event, x, y, pointer, button)
return
}

Expand All @@ -235,9 +264,6 @@ class Outline : VisTable(),
rightClickMenu.show(go, Gdx.input.x.toFloat(), (Gdx.graphics.height - Gdx.input.y).toFloat())
}

override fun touchDown(event: InputEvent?, x: Float, y: Float, pointer: Int, button: Int): Boolean {
return true
}
})

// select listener
Expand Down

0 comments on commit 7e03e32

Please sign in to comment.