gaesup-world 0.8.25 → 0.8.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,7 @@ export function GaeSupProps(_a) {
21
21
  var _c = useContext(GaesupWorldContext), minimap = _c.minimap, clickerOption = _c.clickerOption;
22
22
  var dispatch = useContext(GaesupWorldDispatchContext);
23
23
  // clicker
24
- var moveClicker = useClicker().moveClicker;
24
+ var _d = useClicker(), moveClicker = _d.moveClicker, moveDoubleClicker = _d.moveDoubleClicker;
25
25
  useEffect(function () {
26
26
  if (groupRef.current) {
27
27
  var box = new THREE.Box3().setFromObject(groupRef.current);
@@ -42,22 +42,9 @@ export function GaeSupProps(_a) {
42
42
  });
43
43
  }
44
44
  }, []);
45
- var lastClickTime = 0;
46
- function handleClick(e, cb, gap) {
47
- var currentTime = new Date().getTime();
48
- var timeDiff = currentTime - lastClickTime;
49
- if (timeDiff < gap) {
50
- e.preventDefault();
51
- return;
52
- }
53
- else {
54
- cb(e);
55
- lastClickTime = currentTime;
56
- }
57
- }
58
45
  return (_jsx("group", { ref: groupRef, position: position, onPointerDown: function (e) {
59
46
  moveClicker(e, false, type);
60
47
  }, onDoubleClick: function (e) {
61
- e.stopPropagation();
48
+ moveDoubleClicker(e, true, type);
62
49
  }, children: children }));
63
50
  }
@@ -1,4 +1,5 @@
1
1
  import { ThreeEvent } from "@react-three/fiber";
2
2
  export declare function useClicker(): {
3
3
  moveClicker: (e: ThreeEvent<MouseEvent>, isRun: boolean, type: "normal" | "ground") => void;
4
+ moveDoubleClicker: (e: ThreeEvent<MouseEvent>, isRun: boolean, type: "normal" | "ground") => void;
4
5
  };
@@ -2,51 +2,51 @@ import { useContext } from "react";
2
2
  import { V3, calcNorm } from "../../utils";
3
3
  import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../world/context";
4
4
  export function useClicker() {
5
- var _a = useContext(GaesupWorldContext), activeState = _a.activeState, clicker = _a.clicker, mode = _a.mode, refs = _a.refs;
5
+ var _a = useContext(GaesupWorldContext), activeState = _a.activeState, mode = _a.mode, clicker = _a.clicker, clickerOption = _a.clickerOption;
6
6
  var dispatch = useContext(GaesupWorldDispatchContext);
7
7
  var moveClicker = function (e, isRun, type) {
8
8
  if (mode.controller !== "clicker" || type !== "ground")
9
9
  return;
10
10
  var u = activeState.position;
11
11
  var v = V3(e.point.x, e.point.y, e.point.z);
12
- var newAngle = Math.atan2(v.z - u.z, v.x - u.x);
13
12
  var norm = calcNorm(u, v, false);
14
- // console.log(e, v);
15
- // refs.rigidBodyRef.current?.setLinvel(V3(10, 0, 10), true);
16
13
  if (norm < 2)
17
14
  return;
18
- dispatch({
19
- type: "update",
20
- payload: {
21
- clicker: {
22
- point: v,
23
- angle: newAngle,
24
- isOn: true,
25
- isRun: isRun,
26
- },
27
- },
28
- });
15
+ var newAngle = Math.atan2(v.z - u.z, v.x - u.x);
16
+ clicker.point = v;
17
+ clicker.angle = newAngle;
18
+ clicker.isOn = true;
19
+ clicker.isRun = isRun;
20
+ // dispatch({
21
+ // type: "update",
22
+ // payload: {
23
+ // clicker: {
24
+ // point: v,
25
+ // angle: newAngle,
26
+ // isOn: true,
27
+ // isRun: isRun,
28
+ // },
29
+ // },
30
+ // });
31
+ };
32
+ var moveDoubleClicker = function (e, isRun, type) {
33
+ if (!clicker.isOn || !clickerOption.isRun)
34
+ return;
35
+ clicker.isRun = isRun;
36
+ // dispatch({
37
+ // type: "update",
38
+ // payload: {
39
+ // clicker: {
40
+ // point: v,
41
+ // angle: newAngle,
42
+ // isOn: true,
43
+ // isRun: isRun,
44
+ // },
45
+ // },
46
+ // });
29
47
  };
30
- // // 거리 계산
31
- // useEffect(() => {
32
- // if (mode.controller !== "clicker") return;
33
- // const originPoint = activeState.position;
34
- // const newPosition = clicker.point;
35
- // const norm = Math.sqrt(
36
- // Math.pow(newPosition.z - originPoint.z, 2) +
37
- // Math.pow(newPosition.x - originPoint.x, 2)
38
- // );
39
- // if (norm < 1) {
40
- // clicker.isOn = false;
41
- // dispatch({
42
- // type: "update",
43
- // payload: {
44
- // clicker: clicker,
45
- // },
46
- // });
47
- // }
48
- // }, [activeState.position, clicker.point]);
49
48
  return {
50
49
  moveClicker: moveClicker,
50
+ moveDoubleClicker: moveDoubleClicker,
51
51
  };
52
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gaesup-world",
3
- "version": "0.8.25",
3
+ "version": "0.8.27",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",