diff --git a/src/service/record/main/camera_controller/arcball/RecordArcballCameraControllerService.re b/src/service/record/main/camera_controller/arcball/RecordArcballCameraControllerService.re index 7f86165b7b..6ba2f833ae 100755 --- a/src/service/record/main/camera_controller/arcball/RecordArcballCameraControllerService.re +++ b/src/service/record/main/camera_controller/arcball/RecordArcballCameraControllerService.re @@ -2,15 +2,15 @@ open StateDataMainType; let create = () => { index: 0, - pointDragStartEventHandleFuncMap: + pointDragStartEventHandleFuncListMap: WonderCommonlib.MutableSparseMapService.createEmpty(), - pointDragDropEventHandleFuncMap: + pointDragDropEventHandleFuncListMap: WonderCommonlib.MutableSparseMapService.createEmpty(), - pointDragOverEventHandleFuncMap: + pointDragOverEventHandleFuncListMap: WonderCommonlib.MutableSparseMapService.createEmpty(), - pointScaleEventHandleFuncMap: + pointScaleEventHandleFuncListMap: WonderCommonlib.MutableSparseMapService.createEmpty(), - keydownEventHandleFuncMap: + keydownEventHandleFuncListMap: WonderCommonlib.MutableSparseMapService.createEmpty(), dirtyArray: WonderCommonlib.ArrayService.createEmpty(), distanceMap: WonderCommonlib.MutableSparseMapService.createEmpty(), @@ -31,11 +31,11 @@ let deepCopyForRestore = ( { index, - pointDragStartEventHandleFuncMap, - pointDragDropEventHandleFuncMap, - pointDragOverEventHandleFuncMap, - pointScaleEventHandleFuncMap, - keydownEventHandleFuncMap, + pointDragStartEventHandleFuncListMap, + pointDragDropEventHandleFuncListMap, + pointDragOverEventHandleFuncListMap, + pointScaleEventHandleFuncListMap, + keydownEventHandleFuncListMap, dirtyArray, distanceMap, minDistanceMap, @@ -52,17 +52,21 @@ let deepCopyForRestore = }, ) => { index, - pointDragStartEventHandleFuncMap: - pointDragStartEventHandleFuncMap |> WonderCommonlib.MutableSparseMapService.copy, - pointDragDropEventHandleFuncMap: - pointDragDropEventHandleFuncMap |> WonderCommonlib.MutableSparseMapService.copy, - pointDragOverEventHandleFuncMap: - pointDragOverEventHandleFuncMap |> WonderCommonlib.MutableSparseMapService.copy, - pointScaleEventHandleFuncMap: - pointScaleEventHandleFuncMap + pointDragStartEventHandleFuncListMap: + pointDragStartEventHandleFuncListMap + |> WonderCommonlib.MutableSparseMapService.copy, + pointDragDropEventHandleFuncListMap: + pointDragDropEventHandleFuncListMap + |> WonderCommonlib.MutableSparseMapService.copy, + pointDragOverEventHandleFuncListMap: + pointDragOverEventHandleFuncListMap + |> WonderCommonlib.MutableSparseMapService.copy, + pointScaleEventHandleFuncListMap: + pointScaleEventHandleFuncListMap + |> WonderCommonlib.MutableSparseMapService.copy, + keydownEventHandleFuncListMap: + keydownEventHandleFuncListMap |> WonderCommonlib.MutableSparseMapService.copy, - keydownEventHandleFuncMap: - keydownEventHandleFuncMap |> WonderCommonlib.MutableSparseMapService.copy, dirtyArray: dirtyArray |> Js.Array.copy, distanceMap: distanceMap |> WonderCommonlib.MutableSparseMapService.copy, minDistanceMap: diff --git a/src/service/state/main/camera_controller/arcball/DisposeArcballCameraControllerMainService.re b/src/service/state/main/camera_controller/arcball/DisposeArcballCameraControllerMainService.re index f5903f8266..cb9cf3fb89 100755 --- a/src/service/state/main/camera_controller/arcball/DisposeArcballCameraControllerMainService.re +++ b/src/service/state/main/camera_controller/arcball/DisposeArcballCameraControllerMainService.re @@ -10,9 +10,6 @@ let _disposeData = (cameraController, state) => { |> EventArcballCameraControllerMainService.unbindEvent(cameraController); let { - pointDragOverEventHandleFuncMap, - pointScaleEventHandleFuncMap, - keydownEventHandleFuncMap, dirtyArray, distanceMap, minDistanceMap, diff --git a/src/service/state/main/camera_controller/arcball/EventArcballCameraControllerMainService.re b/src/service/state/main/camera_controller/arcball/EventArcballCameraControllerMainService.re index 34dfbe7dcc..36b6873f8e 100755 --- a/src/service/state/main/camera_controller/arcball/EventArcballCameraControllerMainService.re +++ b/src/service/state/main/camera_controller/arcball/EventArcballCameraControllerMainService.re @@ -2,74 +2,94 @@ open StateDataMainType; open EventType; -let _setEventHandleFunc = (cameraController, handleFunc, eventHandleFuncMap) => - eventHandleFuncMap - |> WonderCommonlib.MutableSparseMapService.set(cameraController, handleFunc); +let _addEventHandleFunc = + (cameraController, handleFunc, eventHandleFuncListMap) => + switch ( + eventHandleFuncListMap + |> WonderCommonlib.MutableSparseMapService.get(cameraController) + ) { + | None => + eventHandleFuncListMap + |> WonderCommonlib.MutableSparseMapService.set( + cameraController, + [handleFunc], + ) + | Some(eventHandleFuncList) => + eventHandleFuncListMap + |> WonderCommonlib.MutableSparseMapService.set( + cameraController, + [handleFunc, ...eventHandleFuncList], + ) + }; -let _setPointDragStartEventHandleFunc = +let _addPointDragStartEventHandleFunc = ( cameraController, handleFunc, - {pointDragStartEventHandleFuncMap} as record, + {pointDragStartEventHandleFuncListMap} as record, ) => { ...record, - pointDragStartEventHandleFuncMap: - _setEventHandleFunc( + pointDragStartEventHandleFuncListMap: + _addEventHandleFunc( cameraController, handleFunc, - pointDragStartEventHandleFuncMap, + pointDragStartEventHandleFuncListMap, ), }; -let _setPointDragDropEventHandleFunc = +let _addPointDragDropEventHandleFunc = ( cameraController, handleFunc, - {pointDragDropEventHandleFuncMap} as record, + {pointDragDropEventHandleFuncListMap} as record, ) => { ...record, - pointDragDropEventHandleFuncMap: - _setEventHandleFunc( + pointDragDropEventHandleFuncListMap: + _addEventHandleFunc( cameraController, handleFunc, - pointDragDropEventHandleFuncMap, + pointDragDropEventHandleFuncListMap, ), }; -let _setPointDragOverEventHandleFunc = +let _addPointDragOverEventHandleFunc = ( cameraController, handleFunc, - {pointDragOverEventHandleFuncMap} as record, + {pointDragOverEventHandleFuncListMap} as record, ) => { ...record, - pointDragOverEventHandleFuncMap: - _setEventHandleFunc( + pointDragOverEventHandleFuncListMap: + _addEventHandleFunc( cameraController, handleFunc, - pointDragOverEventHandleFuncMap, + pointDragOverEventHandleFuncListMap, ), }; -let _setPointScaleEventHandleFunc = - (cameraController, handleFunc, {pointScaleEventHandleFuncMap} as record) => { +let _addPointScaleEventHandleFunc = + ( + cameraController, + handleFunc, + {pointScaleEventHandleFuncListMap} as record, + ) => { ...record, - pointScaleEventHandleFuncMap: - _setEventHandleFunc( + pointScaleEventHandleFuncListMap: + _addEventHandleFunc( cameraController, handleFunc, - pointScaleEventHandleFuncMap, + pointScaleEventHandleFuncListMap, ), }; -let _setKeydownEventHandleFunc = - (cameraController, handleFunc, {keydownEventHandleFuncMap} as record) => { +let _addKeydownEventHandleFunc = + (cameraController, handleFunc, {keydownEventHandleFuncListMap} as record) => { ...record, - keydownEventHandleFuncMap: - _setEventHandleFunc( + keydownEventHandleFuncListMap: + _addEventHandleFunc( cameraController, handleFunc, - keydownEventHandleFuncMap, + keydownEventHandleFuncListMap, ), }; @@ -200,23 +220,23 @@ let prepareBindEvent = (cameraController, state) => { ...state, arcballCameraControllerRecord: state.arcballCameraControllerRecord - |> _setPointDragStartEventHandleFunc( + |> _addPointDragStartEventHandleFunc( cameraController, pointDragStartHandleFunc, ) - |> _setPointDragDropEventHandleFunc( + |> _addPointDragDropEventHandleFunc( cameraController, pointDragDropHandleFunc, ) - |> _setPointDragOverEventHandleFunc( + |> _addPointDragOverEventHandleFunc( cameraController, pointDragOverHandleFunc, ) - |> _setPointScaleEventHandleFunc( + |> _addPointScaleEventHandleFunc( cameraController, pointScaleHandleFunc, ) - |> _setKeydownEventHandleFunc(cameraController, keydownHandleFunc), + |> _addKeydownEventHandleFunc(cameraController, keydownHandleFunc), }; ( @@ -300,141 +320,166 @@ let _unbindKeyboardEvent = (eventName, handleFunc, state) => ~state, ); -let _disposePointDragStartEventHandleFuncMap = +let _disposePointDragStartEventHandleFuncListMap = (cameraController, {arcballCameraControllerRecord} as state) => { - let {pointDragStartEventHandleFuncMap} = arcballCameraControllerRecord; + let {pointDragStartEventHandleFuncListMap} = arcballCameraControllerRecord; switch ( - pointDragStartEventHandleFuncMap + pointDragStartEventHandleFuncListMap |> WonderCommonlib.MutableSparseMapService.get(cameraController) ) { | None => state - | Some(pointDragStartEventHandleFunc) => + | Some(pointDragStartEventHandleFuncList) => let state = - _unbindPointEvent( - NameEventService.getPointDragStartEventName(), - pointDragStartEventHandleFunc, - state, - ); + pointDragStartEventHandleFuncList + |> List.fold_left( + (state, func) => + _unbindPointEvent( + NameEventService.getPointDragStartEventName(), + func, + state, + ), + state, + ); { ...state, arcballCameraControllerRecord: { ...arcballCameraControllerRecord, - pointDragStartEventHandleFuncMap: - pointDragStartEventHandleFuncMap + pointDragStartEventHandleFuncListMap: + pointDragStartEventHandleFuncListMap |> DisposeComponentService.disposeSparseMapData(cameraController), }, }; }; }; -let _disposePointDragDropEventHandleFuncMap = +let _disposePointDragDropEventHandleFuncListMap = (cameraController, {arcballCameraControllerRecord} as state) => { - let {pointDragDropEventHandleFuncMap} = arcballCameraControllerRecord; + let {pointDragDropEventHandleFuncListMap} = arcballCameraControllerRecord; switch ( - pointDragDropEventHandleFuncMap + pointDragDropEventHandleFuncListMap |> WonderCommonlib.MutableSparseMapService.get(cameraController) ) { | None => state - | Some(pointDragDropEventHandleFunc) => + | Some(pointDragDropEventHandleFuncList) => let state = - _unbindPointEvent( - NameEventService.getPointDragDropEventName(), - pointDragDropEventHandleFunc, - state, - ); + pointDragDropEventHandleFuncList + |> List.fold_left( + (state, func) => + _unbindPointEvent( + NameEventService.getPointDragDropEventName(), + func, + state, + ), + state, + ); { ...state, arcballCameraControllerRecord: { ...arcballCameraControllerRecord, - pointDragDropEventHandleFuncMap: - pointDragDropEventHandleFuncMap + pointDragDropEventHandleFuncListMap: + pointDragDropEventHandleFuncListMap |> DisposeComponentService.disposeSparseMapData(cameraController), }, }; }; }; -let _disposePointDragOverEventHandleFuncMap = +let _disposePointDragOverEventHandleFuncListMap = (cameraController, {arcballCameraControllerRecord} as state) => { - let {pointDragOverEventHandleFuncMap} = arcballCameraControllerRecord; + let {pointDragOverEventHandleFuncListMap} = arcballCameraControllerRecord; switch ( - pointDragOverEventHandleFuncMap + pointDragOverEventHandleFuncListMap |> WonderCommonlib.MutableSparseMapService.get(cameraController) ) { | None => state - | Some(pointDragOverEventHandleFunc) => + | Some(pointDragOverEventHandleFuncList) => let state = - _unbindPointEvent( - NameEventService.getPointDragOverEventName(), - pointDragOverEventHandleFunc, - state, - ); + pointDragOverEventHandleFuncList + |> List.fold_left( + (state, func) => + _unbindPointEvent( + NameEventService.getPointDragOverEventName(), + func, + state, + ), + state, + ); { ...state, arcballCameraControllerRecord: { ...arcballCameraControllerRecord, - pointDragOverEventHandleFuncMap: - pointDragOverEventHandleFuncMap + pointDragOverEventHandleFuncListMap: + pointDragOverEventHandleFuncListMap |> DisposeComponentService.disposeSparseMapData(cameraController), }, }; }; }; -let _disposePointScaleEventHandleFuncMap = +let _disposePointScaleEventHandleFuncListMap = (cameraController, {arcballCameraControllerRecord} as state) => { - let {pointScaleEventHandleFuncMap} = arcballCameraControllerRecord; + let {pointScaleEventHandleFuncListMap} = arcballCameraControllerRecord; switch ( - pointScaleEventHandleFuncMap + pointScaleEventHandleFuncListMap |> WonderCommonlib.MutableSparseMapService.get(cameraController) ) { | None => state - | Some(pointScaleEventHandleFunc) => + | Some(pointScaleEventHandleFuncList) => let state = - _unbindPointEvent( - NameEventService.getPointScaleEventName(), - pointScaleEventHandleFunc, - state, - ); + pointScaleEventHandleFuncList + |> List.fold_left( + (state, func) => + _unbindPointEvent( + NameEventService.getPointScaleEventName(), + func, + state, + ), + state, + ); { ...state, arcballCameraControllerRecord: { ...arcballCameraControllerRecord, - pointScaleEventHandleFuncMap: - pointScaleEventHandleFuncMap + pointScaleEventHandleFuncListMap: + pointScaleEventHandleFuncListMap |> DisposeComponentService.disposeSparseMapData(cameraController), }, }; }; }; -let _disposeKeyDownEventHandleFuncMap = +let _disposeKeyDownEventHandleFuncListMap = (cameraController, {arcballCameraControllerRecord} as state) => { - let {keydownEventHandleFuncMap} = arcballCameraControllerRecord; + let {keydownEventHandleFuncListMap} = arcballCameraControllerRecord; switch ( - keydownEventHandleFuncMap + keydownEventHandleFuncListMap |> WonderCommonlib.MutableSparseMapService.get(cameraController) ) { | None => state - | Some(keydownEventHandleFunc) => + | Some(keydownEventHandleFuncList) => let state = - _unbindKeyboardEvent(EventType.KeyDown, keydownEventHandleFunc, state); + keydownEventHandleFuncList + |> List.fold_left( + (state, func) => + _unbindKeyboardEvent(EventType.KeyDown, func, state), + state, + ); { ...state, arcballCameraControllerRecord: { ...arcballCameraControllerRecord, - keydownEventHandleFuncMap: - keydownEventHandleFuncMap + keydownEventHandleFuncListMap: + keydownEventHandleFuncListMap |> DisposeComponentService.disposeSparseMapData(cameraController), }, }; @@ -443,16 +488,16 @@ let _disposeKeyDownEventHandleFuncMap = let unbindEvent = (cameraController, state) => state - |> _disposePointDragStartEventHandleFuncMap(cameraController) - |> _disposePointDragDropEventHandleFuncMap(cameraController) - |> _disposePointDragOverEventHandleFuncMap(cameraController) - |> _disposePointScaleEventHandleFuncMap(cameraController) - |> _disposeKeyDownEventHandleFuncMap(cameraController); + |> _disposePointDragStartEventHandleFuncListMap(cameraController) + |> _disposePointDragDropEventHandleFuncListMap(cameraController) + |> _disposePointDragOverEventHandleFuncListMap(cameraController) + |> _disposePointScaleEventHandleFuncListMap(cameraController) + |> _disposeKeyDownEventHandleFuncListMap(cameraController); let isBindEvent = (cameraController, {arcballCameraControllerRecord} as state) => { - let {pointDragStartEventHandleFuncMap} = arcballCameraControllerRecord; + let {pointDragStartEventHandleFuncListMap} = arcballCameraControllerRecord; - pointDragStartEventHandleFuncMap + pointDragStartEventHandleFuncListMap |> WonderCommonlib.MutableSparseMapService.has(cameraController); }; \ No newline at end of file diff --git a/src/service/state/main/data/StateDataMainType.re b/src/service/state/main/data/StateDataMainType.re index 2428b28e1c..78e1076f05 100755 --- a/src/service/state/main/data/StateDataMainType.re +++ b/src/service/state/main/data/StateDataMainType.re @@ -163,21 +163,21 @@ and eventRecord = { keyboardEventData: EventType.keyboardEventData, touchEventData: EventType.touchEventData, } -and pointEventHandleFuncMap = +and pointEventHandleFuncListMap = WonderCommonlib.MutableSparseMapService.t( - (. EventType.customEvent, state) => (state, EventType.customEvent), + list((. EventType.customEvent, state) => (state, EventType.customEvent)), ) -and keyboardEventHandleFuncMap = +and keyboardEventHandleFuncListMap = WonderCommonlib.MutableSparseMapService.t( - (. EventType.keyboardEvent, state) => state, + list((. EventType.keyboardEvent, state) => state), ) and arcballCameraControllerRecord = { index: int, - pointDragStartEventHandleFuncMap: pointEventHandleFuncMap, - pointDragDropEventHandleFuncMap: pointEventHandleFuncMap, - pointDragOverEventHandleFuncMap: pointEventHandleFuncMap, - pointScaleEventHandleFuncMap: pointEventHandleFuncMap, - keydownEventHandleFuncMap: keyboardEventHandleFuncMap, + pointDragStartEventHandleFuncListMap: pointEventHandleFuncListMap, + pointDragDropEventHandleFuncListMap: pointEventHandleFuncListMap, + pointDragOverEventHandleFuncListMap: pointEventHandleFuncListMap, + pointScaleEventHandleFuncListMap: pointEventHandleFuncListMap, + keydownEventHandleFuncListMap: keyboardEventHandleFuncListMap, dirtyArray: ArcballCameraControllerType.dirtyArray, distanceMap: WonderCommonlib.MutableSparseMapService.t(float), minDistanceMap: WonderCommonlib.MutableSparseMapService.t(float), diff --git a/test/integration/no_worker/asset_bundle/load/loadWAB_test.re b/test/integration/no_worker/asset_bundle/load/loadWAB_test.re old mode 100644 new mode 100755 diff --git a/test/tool/service/camera_controller/ArcballCameraControllerTool.re b/test/tool/service/camera_controller/ArcballCameraControllerTool.re index f5f6e614d1..e758f38d0e 100755 --- a/test/tool/service/camera_controller/ArcballCameraControllerTool.re +++ b/test/tool/service/camera_controller/ArcballCameraControllerTool.re @@ -82,66 +82,59 @@ let setArcballCameraControllerData = (cameraController, state) => { let getDirtyArray = state => state.arcballCameraControllerRecord.dirtyArray; -let getPointDragStartEventHandleFuncMap = - ({arcballCameraControllerRecord} as state) => - arcballCameraControllerRecord.pointDragStartEventHandleFuncMap; +/* let getPointDragStartEventHandleFuncMap = + ({arcballCameraControllerRecord} as state) => + arcballCameraControllerRecord.pointDragStartEventHandleFuncMap; */ -let setPointDragStartEventHandleFunc = +let addPointDragStartEventHandleFunc = (cameraController, handleFunc, {arcballCameraControllerRecord} as state) => { ...state, arcballCameraControllerRecord: - EventArcballCameraControllerMainService._setPointDragStartEventHandleFunc( + EventArcballCameraControllerMainService._addPointDragStartEventHandleFunc( cameraController, handleFunc, arcballCameraControllerRecord, ), }; -let getPointDragDropEventHandleFuncMap = ({arcballCameraControllerRecord} as state) => - arcballCameraControllerRecord.pointDragDropEventHandleFuncMap; - -let setPointDragDropEventHandleFunc = +let addPointDragDropEventHandleFunc = (cameraController, handleFunc, {arcballCameraControllerRecord} as state) => { ...state, arcballCameraControllerRecord: - EventArcballCameraControllerMainService._setPointDragDropEventHandleFunc( + EventArcballCameraControllerMainService._addPointDragDropEventHandleFunc( cameraController, handleFunc, arcballCameraControllerRecord, ), }; -let getPointDragOverEventHandleFuncMap = - ({arcballCameraControllerRecord} as state) => - arcballCameraControllerRecord.pointDragOverEventHandleFuncMap; - -let setPointDragOverEventHandleFunc = +let addPointDragOverEventHandleFunc = (cameraController, handleFunc, {arcballCameraControllerRecord} as state) => { ...state, arcballCameraControllerRecord: - EventArcballCameraControllerMainService._setPointDragOverEventHandleFunc( + EventArcballCameraControllerMainService._addPointDragOverEventHandleFunc( cameraController, handleFunc, arcballCameraControllerRecord, ), }; -let setPointScaleEventHandleFunc = +let addPointScaleEventHandleFunc = (cameraController, handleFunc, {arcballCameraControllerRecord} as state) => { ...state, arcballCameraControllerRecord: - EventArcballCameraControllerMainService._setPointScaleEventHandleFunc( + EventArcballCameraControllerMainService._addPointScaleEventHandleFunc( cameraController, handleFunc, arcballCameraControllerRecord, ), }; -let setKeydownEventHandleFunc = +let addKeydownEventHandleFunc = (cameraController, handleFunc, {arcballCameraControllerRecord} as state) => { ...state, arcballCameraControllerRecord: - EventArcballCameraControllerMainService._setKeydownEventHandleFunc( + EventArcballCameraControllerMainService._addKeydownEventHandleFunc( cameraController, handleFunc, arcballCameraControllerRecord, diff --git a/test/unit/asset_bundle/ImportABSystem_test.re b/test/unit/asset_bundle/ImportABSystem_test.re old mode 100644 new mode 100755 diff --git a/test/unit/asset_bundle/OperateRABAssetBundleMainService_test.re b/test/unit/asset_bundle/OperateRABAssetBundleMainService_test.re old mode 100644 new mode 100755 diff --git a/test/unit/asset_bundle/OperateSABAssetBundleMainService_test.re b/test/unit/asset_bundle/OperateSABAssetBundleMainService_test.re old mode 100644 new mode 100755 diff --git a/test/unit/ecs/component/cameraController/ArcballCameraController_test.re b/test/unit/ecs/component/cameraController/ArcballCameraController_test.re index 177cbdf0cc..48163dd584 100755 --- a/test/unit/ecs/component/cameraController/ArcballCameraController_test.re +++ b/test/unit/ecs/component/cameraController/ArcballCameraController_test.re @@ -222,42 +222,64 @@ let _ = state.arcballCameraControllerRecord; ( distanceMap - |> WonderCommonlib.MutableSparseMapService.has(cameraController1), + |> WonderCommonlib.MutableSparseMapService.has( + cameraController1, + ), minDistanceMap - |> WonderCommonlib.MutableSparseMapService.has(cameraController1), + |> WonderCommonlib.MutableSparseMapService.has( + cameraController1, + ), phiMap - |> WonderCommonlib.MutableSparseMapService.has(cameraController1), + |> WonderCommonlib.MutableSparseMapService.has( + cameraController1, + ), thetaMap - |> WonderCommonlib.MutableSparseMapService.has(cameraController1), + |> WonderCommonlib.MutableSparseMapService.has( + cameraController1, + ), thetaMarginMap - |> WonderCommonlib.MutableSparseMapService.has(cameraController1), + |> WonderCommonlib.MutableSparseMapService.has( + cameraController1, + ), targetMap - |> WonderCommonlib.MutableSparseMapService.has(cameraController1), + |> WonderCommonlib.MutableSparseMapService.has( + cameraController1, + ), moveSpeedXMap - |> WonderCommonlib.MutableSparseMapService.has(cameraController1), + |> WonderCommonlib.MutableSparseMapService.has( + cameraController1, + ), moveSpeedYMap - |> WonderCommonlib.MutableSparseMapService.has(cameraController1), + |> WonderCommonlib.MutableSparseMapService.has( + cameraController1, + ), rotateSpeedMap - |> WonderCommonlib.MutableSparseMapService.has(cameraController1), + |> WonderCommonlib.MutableSparseMapService.has( + cameraController1, + ), wheelSpeedMap - |> WonderCommonlib.MutableSparseMapService.has(cameraController1), + |> WonderCommonlib.MutableSparseMapService.has( + cameraController1, + ), gameObjectMap - |> WonderCommonlib.MutableSparseMapService.has(cameraController1), + |> WonderCommonlib.MutableSparseMapService.has( + cameraController1, + ), ) - |> - expect == ( - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - ); + |> expect + == ( + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + ); }, ); @@ -322,23 +344,23 @@ let _ = ); let state = state - |> ArcballCameraControllerTool.setPointDragStartEventHandleFunc( + |> ArcballCameraControllerTool.addPointDragStartEventHandleFunc( cameraController1, pointDownHandleFunc, ) - |> ArcballCameraControllerTool.setPointDragDropEventHandleFunc( + |> ArcballCameraControllerTool.addPointDragDropEventHandleFunc( cameraController1, pointUpHandleFunc, ) - |> ArcballCameraControllerTool.setPointDragOverEventHandleFunc( + |> ArcballCameraControllerTool.addPointDragOverEventHandleFunc( cameraController1, pointDragHandleFunc, ) - |> ArcballCameraControllerTool.setPointScaleEventHandleFunc( + |> ArcballCameraControllerTool.addPointScaleEventHandleFunc( cameraController1, pointScaleHandleFunc, ) - |> ArcballCameraControllerTool.setKeydownEventHandleFunc( + |> ArcballCameraControllerTool.addKeydownEventHandleFunc( cameraController1, keydownHandleFunc, ); @@ -410,23 +432,23 @@ let _ = }; let state = state - |> ArcballCameraControllerTool.setPointDragStartEventHandleFunc( + |> ArcballCameraControllerTool.addPointDragStartEventHandleFunc( cameraController1, pointDownHandleFunc, ) - |> ArcballCameraControllerTool.setPointDragDropEventHandleFunc( + |> ArcballCameraControllerTool.addPointDragDropEventHandleFunc( cameraController1, pointUpHandleFunc, ) - |> ArcballCameraControllerTool.setPointDragOverEventHandleFunc( + |> ArcballCameraControllerTool.addPointDragOverEventHandleFunc( cameraController1, pointDragHandleFunc, ) - |> ArcballCameraControllerTool.setPointScaleEventHandleFunc( + |> ArcballCameraControllerTool.addPointScaleEventHandleFunc( cameraController1, pointScaleHandleFunc, ) - |> ArcballCameraControllerTool.setKeydownEventHandleFunc( + |> ArcballCameraControllerTool.addKeydownEventHandleFunc( cameraController1, keydownHandleFunc, ); @@ -439,24 +461,34 @@ let _ = ); let { - pointDragStartEventHandleFuncMap, - pointDragDropEventHandleFuncMap, - pointDragOverEventHandleFuncMap, - pointScaleEventHandleFuncMap, - keydownEventHandleFuncMap, + pointDragStartEventHandleFuncListMap, + pointDragDropEventHandleFuncListMap, + pointDragOverEventHandleFuncListMap, + pointScaleEventHandleFuncListMap, + keydownEventHandleFuncListMap, } = state.arcballCameraControllerRecord; ( - pointDragStartEventHandleFuncMap - |> WonderCommonlib.MutableSparseMapService.has(cameraController1), - pointDragDropEventHandleFuncMap - |> WonderCommonlib.MutableSparseMapService.has(cameraController1), - pointDragOverEventHandleFuncMap - |> WonderCommonlib.MutableSparseMapService.has(cameraController1), - pointScaleEventHandleFuncMap - |> WonderCommonlib.MutableSparseMapService.has(cameraController1), - keydownEventHandleFuncMap - |> WonderCommonlib.MutableSparseMapService.has(cameraController1), + pointDragStartEventHandleFuncListMap + |> WonderCommonlib.MutableSparseMapService.has( + cameraController1, + ), + pointDragDropEventHandleFuncListMap + |> WonderCommonlib.MutableSparseMapService.has( + cameraController1, + ), + pointDragOverEventHandleFuncListMap + |> WonderCommonlib.MutableSparseMapService.has( + cameraController1, + ), + pointScaleEventHandleFuncListMap + |> WonderCommonlib.MutableSparseMapService.has( + cameraController1, + ), + keydownEventHandleFuncListMap + |> WonderCommonlib.MutableSparseMapService.has( + cameraController1, + ), ) |> expect == (false, false, false, false, false); }); diff --git a/test/unit/ecs/component/cameraController/EventArcballCameraController_test.re b/test/unit/ecs/component/cameraController/EventArcballCameraController_test.re index 1ce26c5a5c..c9de672971 100755 --- a/test/unit/ecs/component/cameraController/EventArcballCameraController_test.re +++ b/test/unit/ecs/component/cameraController/EventArcballCameraController_test.re @@ -587,6 +587,55 @@ let _ = preventDefaultFunc |> expect |> not_ |> toCalled; }); + + describe("fix bug", () => + test( + "unbind should unbind cameraController's all binded functions", + () => { + let state = _prepareMouseEvent(); + let (state, requestPointerLockStub) = + _prepareForPointerLock(sandbox, state); + let ( + state, + gameObject, + transform, + ( + cameraController, + basicCameraView, + perspectiveCameraProjection, + ), + ) = + ArcballCameraControllerTool.createGameObject(state); + let state = state |> NoWorkerJobTool.execInitJobs; + let preventDefaultFunc = + createEmptyStubWithJsObjSandbox(sandbox); + + let state = + ArcballCameraControllerAPI.bindArcballCameraControllerEvent( + cameraController, + state, + ); + let state = + ArcballCameraControllerAPI.bindArcballCameraControllerEvent( + cameraController, + state, + ); + let state = + ArcballCameraControllerAPI.unbindArcballCameraControllerEvent( + cameraController, + state, + ); + let state = MainStateTool.setState(state); + EventTool.triggerDomEvent( + "mousedown", + EventTool.getPointEventBindedDom(state), + MouseEventTool.buildMouseEvent(~preventDefaultFunc, ()), + ); + let state = EventTool.restore(state); + + requestPointerLockStub |> expect |> not_ |> toCalled; + }) + ); }); }); diff --git a/test/unit/job/no_worker/InitEventJob_test.re b/test/unit/job/no_worker/InitEventJob_test.re index 0125a902b3..77ef6673f9 100755 --- a/test/unit/job/no_worker/InitEventJob_test.re +++ b/test/unit/job/no_worker/InitEventJob_test.re @@ -789,7 +789,7 @@ let _ = MouseEventTool.prepare( ~sandbox, ~offsetLeft=0, - ~offsetTop=2, + ~offsetTop=0, (), ); MouseEventTool.setNotPointerLocked(.); @@ -836,7 +836,7 @@ let _ = ); let state = EventTool.restore(state); - locationInViewArr |> expect == [||]; + locationInViewArr |> expect == [|(55, 110), (60, 110)|]; }); });