gaesup-world 0.5.22 → 0.5.23

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.
@@ -1,4 +1,4 @@
1
- import { ThreeEvent } from "@react-three/fiber";
1
+ import * as THREE from "three";
2
2
  export declare function useMovePoint(): {
3
- moveClicker: (e: ThreeEvent<MouseEvent>, isRun: boolean, type: "normal" | "ground") => void;
3
+ move: (position: THREE.Vector3, isRun: boolean) => void;
4
4
  };
@@ -2,23 +2,20 @@ import { useContext, useEffect } from "react";
2
2
  import { V3 } from "../../utils";
3
3
  import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../world/context";
4
4
  export function useMovePoint() {
5
- var _a = useContext(GaesupWorldContext), activeState = _a.activeState, clicker = _a.clicker, mode = _a.mode;
5
+ var _a = useContext(GaesupWorldContext), activeState = _a.activeState, clicker = _a.clicker;
6
6
  var dispatch = useContext(GaesupWorldDispatchContext);
7
- var moveClicker = function (e, isRun, type) {
8
- if (mode.controller !== "clicker" || type !== "ground")
9
- return;
7
+ var move = function (position, isRun) {
10
8
  var originPoint = activeState.position;
11
- var newPosition = e.point;
12
- var newAngle = Math.atan2(newPosition.z - originPoint.z, newPosition.x - originPoint.x);
13
- var norm = Math.sqrt(Math.pow(newPosition.z - originPoint.z, 2) +
14
- Math.pow(newPosition.x - originPoint.x, 2));
9
+ var newAngle = Math.atan2(position.z - originPoint.z, position.x - originPoint.x);
10
+ var norm = Math.sqrt(Math.pow(position.z - originPoint.z, 2) +
11
+ Math.pow(position.x - originPoint.x, 2));
15
12
  if (norm < 2)
16
13
  return;
17
14
  dispatch({
18
15
  type: "update",
19
16
  payload: {
20
17
  clicker: {
21
- point: V3(e.point.x, e.point.y, e.point.z),
18
+ point: V3(position.x, 0, position.z),
22
19
  angle: newAngle,
23
20
  isOn: true,
24
21
  isRun: isRun,
@@ -43,6 +40,6 @@ export function useMovePoint() {
43
40
  }
44
41
  }, [activeState.position, clicker.point]);
45
42
  return {
46
- moveClicker: moveClicker,
43
+ move: move,
47
44
  };
48
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gaesup-world",
3
- "version": "0.5.22",
3
+ "version": "0.5.23",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",