Skip to content

Commit

Permalink
feat(event): now not each point event will trigger loopBody when stop…
Browse files Browse the repository at this point in the history
…;arcball now not bind keydown event;
  • Loading branch information
yyc-git committed Feb 9, 2019
1 parent b99e3f1 commit 4a281e3
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 183 deletions.
6 changes: 6 additions & 0 deletions src/core/job/init/InitCameraControllerJob.re
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ let _refreshInspector = () => {
let _handleTriggerRefreshInspectorEvent = engineState =>
_isCurrentSceneTreeNodeHasArcballCameraControllerComponent(engineState) ?
{
engineState |> StateEngineService.setState |> ignore;

_refreshInspector();

let engineState =
StateEngineService.unsafeGetState() |> StateLogicService.renderWhenStop;

engineState;
} :
engineState;
Expand Down
20 changes: 6 additions & 14 deletions src/core/job/init/InitEventJob.re
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ module PointEvent = {
engineState,
);

switch (eventTarget) {
| Scene => StateLogicService.loopBodyWhenStop(engineState)
| _ => engineState
};
engineState;
} :
engineState,
~state=engineState,
Expand Down Expand Up @@ -400,16 +397,11 @@ module DomEvent = {
event,
) :
_isTriggerSceneViewEvent() ?
{
_execKeyboardEventHandle(
sceneViewEventName
|> EventType.editorDomEventNameToEngineDomEventName,
event,
);

StateLogicService.loopBodyWhenStop
|> StateLogicService.getAndSetEngineState;
} :
_execKeyboardEventHandle(
sceneViewEventName
|> EventType.editorDomEventNameToEngineDomEventName,
event,
) :
();

let _fromPCDomEventArr = engineState => [|
Expand Down
2 changes: 2 additions & 0 deletions src/core/job/init/InitPickingJob.re
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ let _handlePicking = (event: EventType.customEvent, engineState) => {
| Some(gameObject) => _handlePickSuccess(gameObject, engineState)
};

let engineState = StateLogicService.renderWhenStop(engineState);

(engineState, event);
};

Expand Down
34 changes: 31 additions & 3 deletions src/core/job/init/InitTransformGizmosJob.re
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ let _bindEvent = (editorState, engineState) => {
engineState,
);

let engineState = StateLogicService.renderWhenStop(engineState);

editorState |> StateEditorService.setState |> ignore;

(engineState, event);
Expand Down Expand Up @@ -112,7 +114,13 @@ let _bindEvent = (editorState, engineState) => {
(editorState, engineState),
);

_refreshInspector(editorState, engineState);
let (editorState, engineState) =
_refreshInspector(editorState, engineState);

let engineState =
StateLogicService.renderWhenStop(engineState);

(editorState, engineState);
} :
SelectRotationGizmoSceneViewEditorService.isSelectAnyRotationGizmo(
editorState,
Expand All @@ -124,7 +132,16 @@ let _bindEvent = (editorState, engineState) => {
(editorState, engineState),
);

_refreshInspector(editorState, engineState);
let engineState =
StateLogicService.loopBodyWhenStop(engineState);

let (editorState, engineState) =
_refreshInspector(editorState, engineState);

let engineState =
StateLogicService.renderWhenStop(engineState);

(editorState, engineState);
} :
(editorState, engineState);

Expand Down Expand Up @@ -180,7 +197,11 @@ let _bindEvent = (editorState, engineState) => {
),
);

(StateEngineService.unsafeGetState(), event);
let engineState = StateEngineService.unsafeGetState();
let engineState =
StateLogicService.renderWhenStop(engineState);

(engineState, event);
} :
{
let editorState =
Expand All @@ -197,6 +218,11 @@ let _bindEvent = (editorState, engineState) => {

editorState |> StateEditorService.setState |> ignore;

let engineState =
StateLogicService.renderWhenStop(engineState);

(engineState, event);

(engineState, event);
};
} :
Expand All @@ -222,6 +248,8 @@ let _bindEvent = (editorState, engineState) => {
engineState,
);

let engineState = StateLogicService.renderWhenStop(engineState);

(engineState, event);
} :
(engineState, event),
Expand Down
2 changes: 1 addition & 1 deletion src/core/job/loop/RenderTransformGizmosJob.re
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ let _renderRotationGizmos = (editorState, engineState) =>
let renderJob = (_, engineState) => {
open SceneViewType;

/* WonderLog.Log.print("render gizmo") |> ignore; */
WonderLog.Log.print("render gizmo") |> ignore;

let editorState = StateEditorService.getState();

Expand Down
33 changes: 21 additions & 12 deletions src/service/stateTuple/logic/ArcballCameraControllerLogicService.re
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
let _renderWhenStop = (event, handleFunc, engineState) => {
let (engineState, event) = handleFunc(. event, engineState);

let engineState = StateLogicService.renderWhenStop(engineState);

(engineState, event);
};

let bindArcballCameraControllerEventForSceneView =
(cameraController, engineState) => {
let (
Expand All @@ -6,7 +14,7 @@ let bindArcballCameraControllerEventForSceneView =
pointDragDropHandleFunc,
pointDragOverHandleFunc,
pointScaleHandleFunc,
keydownHandleFunc,
_,
) =
ArcballCameraEngineService.prepareBindEvent(
cameraController,
Expand All @@ -19,7 +27,7 @@ let bindArcballCameraControllerEventForSceneView =
~handleFunc=
(. event, engineState) =>
MouseEventService.isRightMouseButton(event) ?
pointDragStartHandleFunc(. event, engineState) :
_renderWhenStop(event, pointDragStartHandleFunc, engineState) :
(engineState, event),
~state=engineState,
(),
Expand All @@ -31,7 +39,7 @@ let bindArcballCameraControllerEventForSceneView =
~handleFunc=
(. event, engineState) =>
MouseEventService.isRightMouseButton(event) ?
pointDragDropHandleFunc(. event, engineState) :
_renderWhenStop(event, pointDragDropHandleFunc, engineState) :
(engineState, event),
~state=engineState,
(),
Expand All @@ -43,7 +51,7 @@ let bindArcballCameraControllerEventForSceneView =
~handleFunc=
(. event, engineState) =>
MouseEventService.isRightMouseButton(event) ?
pointDragOverHandleFunc(. event, engineState) :
_renderWhenStop(event, pointDragOverHandleFunc, engineState) :
(engineState, event),
~state=engineState,
(),
Expand All @@ -53,18 +61,19 @@ let bindArcballCameraControllerEventForSceneView =
ManageEventEngineService.onCustomGlobalEvent(
~eventName=SceneViewEventEditorService.getPointScaleEventName(),
~handleFunc=
(. event, engineState) => pointScaleHandleFunc(. event, engineState),
(. event, engineState) =>
_renderWhenStop(event, pointScaleHandleFunc, engineState),
~state=engineState,
(),
);

let engineState =
ManageEventEngineService.onKeyboardEvent(
~eventName=EventType.KeyDown_SceneView |> Obj.magic,
~handleFunc=keydownHandleFunc,
~state=engineState,
(),
);
/* let engineState =
ManageEventEngineService.onKeyboardEvent(
~eventName=EventType.KeyDown_SceneView |> Obj.magic,
~handleFunc=keydownHandleFunc,
~state=engineState,
(),
); */

engineState;
};
Expand Down
4 changes: 4 additions & 0 deletions src/service/stateTuple/logic/StateLogicService.re
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ let getAndRefreshEngineStateWhenStop = () =>
|> StateEngineService.setState
|> ignore;

let renderWhenStop = engineState =>
StateEditorService.getIsRun() ?
engineState : engineState |> DirectorEngineService.loopBody(0.);

let getEditorState = handleFunc => StateEditorService.getState() |> handleFunc;

let getAndSetEditorState = handleFunc =>
Expand Down
Loading

0 comments on commit 4a281e3

Please sign in to comment.