diff --git a/.cz-config.js b/.cz-config.js index 185348aa3..f5d8f3b43 100755 --- a/.cz-config.js +++ b/.cz-config.js @@ -15,6 +15,7 @@ module.exports = { ], scopes: [ + { name: "focus" }, { name: "scene-view" }, { name: "scene-tree" }, { name: "left-header" }, diff --git a/src/core/utils/engine/job/init/initHotKeysJob/FocusUtils.re b/src/core/utils/engine/job/init/initHotKeysJob/FocusUtils.re index 5c206ac49..c4e9b27fc 100644 --- a/src/core/utils/engine/job/init/initHotKeysJob/FocusUtils.re +++ b/src/core/utils/engine/job/init/initHotKeysJob/FocusUtils.re @@ -1,7 +1,5 @@ let _setArcballCameraControllerFocusRelatedAttribute = - (arcballCameraController, (distance, target), engineState) => { - Js.log(distance); - + (arcballCameraController, (distance, target), engineState) => engineState |> ArcballCameraEngineService.setArcballCameraControllerTarget( arcballCameraController, @@ -11,14 +9,6 @@ let _setArcballCameraControllerFocusRelatedAttribute = distance, arcballCameraController, ); -}; - -let _getTargetGameObjectMaxScale = (targetGameObjectTransform, engineState) => { - let (scaleX, scaleY, scaleZ) = - engineState |> TransformEngineService.getScale(targetGameObjectTransform); - - Js.Math.max_float(scaleX, scaleY) |> Js.Math.max_float(scaleZ); -}; let _buildAllPointsAndLocalToWolrdMatrices = (targetGameObject, engineState) => engineState @@ -50,16 +40,13 @@ let _calcGeometrySphereCenterAndRadius = (targetGameObject, engineState) => { AABBShapeUtils.setFromAllPointsAndLocalToWolrdMatrices( _buildAllPointsAndLocalToWolrdMatrices(targetGameObject, engineState), ); + let center = AABBShapeUtils.getCenter(aabb); (center, AABBShapeUtils.calcRadiusOfAABB(aabb, center)); }; -let _calcArcballCameraControllerDistance = - (distance, targetGameObjectTransform, engineState) => - _getTargetGameObjectMaxScale(targetGameObjectTransform, engineState) - *. distance - *. 2.5; +let _calcArcballCameraControllerDistance = distance => distance *. 2.5; let setEditorCameraFocusTargetGameObject = (editCamera, targetGameObject, editorState, engineState) => { @@ -103,14 +90,7 @@ let setEditorCameraFocusTargetGameObject = _setArcballCameraControllerFocusRelatedAttribute( editorCameraArcballControllerComponent, - ( - engineState - |> _calcArcballCameraControllerDistance( - radius, - targetGameObjectTransform, - ), - center, - ), + (_calcArcballCameraControllerDistance(radius), center), engineState, ); }; \ No newline at end of file diff --git a/test/integration/job/initHotKeysJob_test.re b/test/integration/job/initHotKeysJob_test.re index 3529bdf74..edd58ae72 100755 --- a/test/integration/job/initHotKeysJob_test.re +++ b/test/integration/job/initHotKeysJob_test.re @@ -160,7 +160,7 @@ let _ = {| calc currentSceneTreeNode's all children and its self->aabb; use aabb's center as arcball camera controller target; - use aabb's radius * max scale of target gameObject * factor as arcball camera controller distance; + use aabb's radius * factor as arcball camera controller distance; |}, () => { let _getDistance = ((editorState, engineState)) => @@ -218,7 +218,7 @@ let _ = _getDistance |> StateLogicService.getStateToGetData, _getTarget |> StateLogicService.getStateToGetData, ) - |> expect == (67.708, ((-1.5), 0., 0.)); + |> expect == (22.569, ((-1.5), 0., 0.)); }); test("test the currentSceneTreeNode is scene children", () => { @@ -254,7 +254,7 @@ let _ = _getDistance |> StateLogicService.getStateToGetData, _getTarget |> StateLogicService.getStateToGetData, ) - |> expect == (12.437, (2., 0., 0.)); + |> expect == (4.146, (2., 0., 0.)); }); }, )