gaesup-world 0.5.4 → 0.5.22

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 * as THREE from "three";
1
+ import { ThreeEvent } from "@react-three/fiber";
2
2
  export declare function useMovePoint(): {
3
- move: (position: THREE.Vector3, isRun: boolean) => void;
3
+ moveClicker: (e: ThreeEvent<MouseEvent>, isRun: boolean, type: "normal" | "ground") => void;
4
4
  };
@@ -2,20 +2,23 @@ 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;
5
+ var _a = useContext(GaesupWorldContext), activeState = _a.activeState, clicker = _a.clicker, mode = _a.mode;
6
6
  var dispatch = useContext(GaesupWorldDispatchContext);
7
- var move = function (position, isRun) {
7
+ var moveClicker = function (e, isRun, type) {
8
+ if (mode.controller !== "clicker" || type !== "ground")
9
+ return;
8
10
  var originPoint = activeState.position;
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));
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));
12
15
  if (norm < 2)
13
16
  return;
14
17
  dispatch({
15
18
  type: "update",
16
19
  payload: {
17
20
  clicker: {
18
- point: V3(position.x, 0, position.z),
21
+ point: V3(e.point.x, e.point.y, e.point.z),
19
22
  angle: newAngle,
20
23
  isOn: true,
21
24
  isRun: isRun,
@@ -40,6 +43,6 @@ export function useMovePoint() {
40
43
  }
41
44
  }, [activeState.position, clicker.point]);
42
45
  return {
43
- move: move,
46
+ moveClicker: moveClicker,
44
47
  };
45
48
  }
@@ -4,8 +4,7 @@ export function useTeleport() {
4
4
  var refs = useContext(GaesupWorldContext).refs;
5
5
  var Teleport = function (position) {
6
6
  var _a, _b;
7
- if (refs && refs.rigidBodyRef && refs.rigidBodyRef.current)
8
- (_b = (_a = refs.rigidBodyRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.setTranslation(position, true);
7
+ (_b = (_a = refs.rigidBodyRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.setTranslation(position, true);
9
8
  };
10
9
  return {
11
10
  Teleport: Teleport,
@@ -17,7 +17,7 @@ import initDebug from "../debug";
17
17
  export default function initGaesupWorld(props) {
18
18
  var _a = useReducer(gaesupWorldReducer, {
19
19
  debug: (props.debug && isDesktop) || gaesupWorldDefault.debug,
20
- activeState: __assign(__assign({}, gaesupWorldDefault.activeState), { position: props.startPosition || gaesupWorldDefault.activeState.position }),
20
+ activeState: gaesupWorldDefault.activeState,
21
21
  cameraOption: Object.assign(gaesupWorldDefault.cameraOption, props.cameraOption || {}),
22
22
  mode: Object.assign(gaesupWorldDefault.mode, props.mode || {}),
23
23
  urls: Object.assign(gaesupWorldDefault.urls, props.urls || {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gaesup-world",
3
- "version": "0.5.4",
3
+ "version": "0.5.22",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",