diff --git a/app/src/main/java/com/plweegie/magmolecular/ar/MagMolActivity.kt b/app/src/main/java/com/plweegie/magmolecular/ar/MagMolActivity.kt index 6990bfd..750b891 100644 --- a/app/src/main/java/com/plweegie/magmolecular/ar/MagMolActivity.kt +++ b/app/src/main/java/com/plweegie/magmolecular/ar/MagMolActivity.kt @@ -88,6 +88,7 @@ class MagMolActivity : AppCompatActivity() { } transformableNode = TransformableNode(arFragment.transformationSystem).apply { setParent(anchorNode) + worldPosition = position.adjustPosition() } arFragment.arSceneView.scene.addChild(anchorNode) @@ -97,9 +98,9 @@ class MagMolActivity : AppCompatActivity() { loading_pb?.visibility = View.GONE Node().apply { + setParent(transformableNode) worldPosition = position.adjustPosition() renderable = ShapeFactory.makeSphere(0.05f, Vector3.zero(), material) - setParent(transformableNode) } } @@ -117,4 +118,4 @@ class MagMolActivity : AppCompatActivity() { } fun Vector3.adjustPosition(): Vector3 = - Vector3.subtract(this.scaled(0.05f), Vector3(0.0f, 0.2f, 0.5f)) \ No newline at end of file + Vector3.subtract(this.scaled(0.05f), Vector3(0.0f, 0.2f, 0.7f)) \ No newline at end of file diff --git a/app/src/main/java/com/plweegie/magmolecular/ar/MagMolFragment.kt b/app/src/main/java/com/plweegie/magmolecular/ar/MagMolFragment.kt index 3a6d4c7..ee19ef7 100644 --- a/app/src/main/java/com/plweegie/magmolecular/ar/MagMolFragment.kt +++ b/app/src/main/java/com/plweegie/magmolecular/ar/MagMolFragment.kt @@ -53,16 +53,11 @@ class MagMolFragment : ArFragment() { override fun onUpdated(gesture: DragGesture?) { endPosition = gesture?.position val angle = getRotationAngle(startPosition, endPosition) - val rotationAxis = gesture?.targetNode?.parent?.parent?.worldPosition - rotationAxis?.let { axis -> - val adjustedRotationAxis = Vector3(axis.x, axis.y, axis.z) - - gesture.targetNode?.parent?.parent?.worldRotation = Quaternion.multiply( - gesture.targetNode?.parent?.parent?.worldRotation, - Quaternion.axisAngle(adjustedRotationAxis, angle) - ) - } + gesture?.targetNode?.parent?.localRotation = Quaternion.multiply( + gesture?.targetNode?.parent?.localRotation, + Quaternion.axisAngle(Vector3.up().scaled(4.0f), angle) + ) } override fun onFinished(gesture: DragGesture?) {}