mirror of
https://github.com/DaanVandenBosch/phantasmal-world.git
synced 2025-04-04 06:28:28 +08:00
Fixed camera reset bug in model viewer.
This commit is contained in:
parent
9cbc12cc24
commit
423c3e252b
@ -31,6 +31,7 @@ class MeshRenderer(
|
|||||||
private var animation: Animation? = null
|
private var animation: Animation? = null
|
||||||
private var updateAnimationTime = true
|
private var updateAnimationTime = true
|
||||||
private var charClassActive = false
|
private var charClassActive = false
|
||||||
|
private var resetCamera = true
|
||||||
|
|
||||||
override val context = addDisposable(
|
override val context = addDisposable(
|
||||||
RenderContext(
|
RenderContext(
|
||||||
@ -56,9 +57,11 @@ class MeshRenderer(
|
|||||||
)
|
)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
observeNow(viewerStore.currentNinjaGeometry) { rebuildMesh(resetCamera = true) }
|
observeNow(viewerStore.currentNinjaGeometry, viewerStore.currentTextures) { _, _ ->
|
||||||
observeNow(viewerStore.currentTextures) { rebuildMesh(resetCamera = true) }
|
resetCamera = true
|
||||||
observeNow(viewerStore.applyTextures) { rebuildMesh(resetCamera = false) }
|
rebuildMesh()
|
||||||
|
}
|
||||||
|
observeNow(viewerStore.applyTextures) { rebuildMesh() }
|
||||||
observeNow(viewerStore.currentNinjaMotion, ::ninjaMotionChanged)
|
observeNow(viewerStore.currentNinjaMotion, ::ninjaMotionChanged)
|
||||||
observeNow(viewerStore.showSkeleton) { skeletonHelper?.visible = it }
|
observeNow(viewerStore.showSkeleton) { skeletonHelper?.visible = it }
|
||||||
observeNow(viewerStore.animationPlaying, ::animationPlayingChanged)
|
observeNow(viewerStore.animationPlaying, ::animationPlayingChanged)
|
||||||
@ -87,7 +90,7 @@ class MeshRenderer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun rebuildMesh(resetCamera: Boolean) {
|
private fun rebuildMesh() {
|
||||||
throttleRebuildMesh {
|
throttleRebuildMesh {
|
||||||
// Remove the previous mesh.
|
// Remove the previous mesh.
|
||||||
obj3d?.let { mesh ->
|
obj3d?.let { mesh ->
|
||||||
@ -149,6 +152,7 @@ class MeshRenderer(
|
|||||||
1.5 / tan(degToRad((context.camera as PerspectiveCamera).fov) / 2)
|
1.5 / tan(degToRad((context.camera as PerspectiveCamera).fov) / 2)
|
||||||
val cameraPos = CAMERA_POS * (bSphere.radius * cameraDistFactor)
|
val cameraPos = CAMERA_POS * (bSphere.radius * cameraDistFactor)
|
||||||
inputManager.lookAt(cameraPos, bSphere.center)
|
inputManager.lookAt(cameraPos, bSphere.center)
|
||||||
|
resetCamera = false
|
||||||
}
|
}
|
||||||
|
|
||||||
context.scene.add(obj3d)
|
context.scene.add(obj3d)
|
||||||
|
Loading…
Reference in New Issue
Block a user