gaesup-world 0.6.35 → 0.6.52

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.
@@ -7,12 +7,9 @@ export var makeNormalCameraPosition = function (activeState, cameraOption) {
7
7
  return cameraPosition;
8
8
  };
9
9
  export default function normal(prop) {
10
- var delta = prop.delta, state = prop.state, _a = prop.worldContext, activeState = _a.activeState, cameraOption = _a.cameraOption;
10
+ var state = prop.state, cameraOption = prop.worldContext.cameraOption;
11
11
  if (!state || !state.camera)
12
12
  return;
13
- // const cameraPosition = activeState.position
14
- // .clone()
15
- // .add(V3(0, cameraOption.YDistance, cameraOption.ZDistance));
16
13
  state.camera.position.lerp(cameraOption.position.clone(), 1);
17
14
  state.camera.lookAt(cameraOption.target);
18
15
  }
@@ -11,8 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { CameraControls } from "@react-three/drei";
14
- import { useFrame, useThree } from "@react-three/fiber";
15
- import { vec3 } from "@react-three/rapier";
14
+ import { useFrame } from "@react-three/fiber";
16
15
  import { useContext, useEffect, useMemo, useRef } from "react";
17
16
  import * as THREE from "three";
18
17
  import { GaesupControllerContext } from "../controller/context";
@@ -25,17 +24,10 @@ export default function Camera(_a) {
25
24
  var controllerContext = useContext(GaesupControllerContext);
26
25
  var mode = worldContext.mode, cameraOption = worldContext.cameraOption, activeState = worldContext.activeState;
27
26
  var rigidBodyRef = refs.rigidBodyRef, outerGroupRef = refs.outerGroupRef;
28
- var camera = useThree().camera;
29
27
  var cameraRef = useRef();
30
28
  var intersectObjectMap = useMemo(function () { return ({}); }, []);
31
29
  var cameraProp = __assign(__assign({}, prop), { control: control, controllerContext: controllerContext, worldContext: worldContext, intersectObjectMap: intersectObjectMap });
32
- var position = useMemo(function () { return camera.position; }, []);
33
- var dir = useMemo(function () { return vec3(); }, []);
34
30
  cameraProp.cameraRay.rayCast = new THREE.Raycaster(cameraProp.cameraRay.origin, cameraProp.cameraRay.dir, 0, -cameraOption.maxDistance);
35
- useEffect(function () {
36
- cameraProp.cameraRay.origin.copy(position);
37
- cameraProp.cameraRay.dir.copy(camera.getWorldDirection(dir));
38
- }, [cameraProp]);
39
31
  useFrame(function (state, delta) {
40
32
  if (!rigidBodyRef ||
41
33
  !rigidBodyRef.current ||
@@ -51,7 +43,6 @@ export default function Camera(_a) {
51
43
  else if (mode.control === "normal") {
52
44
  normal(cameraProp);
53
45
  }
54
- // detector(cameraProp);
55
46
  }
56
47
  });
57
48
  // zoom
@@ -26,7 +26,6 @@ export default function useClicker() {
26
26
  },
27
27
  });
28
28
  };
29
- // const moveClicker = _.throttle(moveClick, 100);
30
29
  // 거리 계산
31
30
  useEffect(function () {
32
31
  if (mode.controller !== "clicker")
@@ -1,7 +1,7 @@
1
1
  import { quat } from "@react-three/rapier";
2
2
  import { V3 } from "../../utils/vector";
3
3
  export default function direction(prop) {
4
- var innerGroupRef = prop.innerGroupRef, rigidBodyRef = prop.rigidBodyRef, _a = prop.worldContext, joystick = _a.joystick, activeState = _a.activeState, control = _a.control, mode = _a.mode, airplane = prop.controllerContext.airplane, matchSizes = prop.matchSizes;
4
+ var innerGroupRef = prop.innerGroupRef, _a = prop.worldContext, joystick = _a.joystick, activeState = _a.activeState, control = _a.control, mode = _a.mode, airplane = prop.controllerContext.airplane, matchSizes = prop.matchSizes;
5
5
  var forward = control.forward, backward = control.backward, leftward = control.leftward, rightward = control.rightward, shift = control.shift, space = control.space;
6
6
  var angleDelta = airplane.angleDelta, maxAngle = airplane.maxAngle, accelRatio = airplane.accelRatio;
7
7
  if (!matchSizes || !matchSizes["airplaneUrl"])
@@ -1,14 +1,2 @@
1
1
  import { calcPropType } from "../type";
2
- /**
3
- * This function calculates and sets gravity.
4
- *
5
- * @param {calcPropType} prop - An object containing properties necessary for gravity calculation.
6
- * @param {object} prop.rigidBodyRef - A reference to the physical object where gravity is being set.
7
- * @param {object} prop.worldContext - An object representing the current state of the game world.
8
- * @param {number} prop.worldContext.activeState.position.y - The current Y-coordinate position.
9
- *
10
- * Gravity is calculated based on altitude and buoyancy. When altitude is less than 10, gravity is calculated as follows:
11
- * Gravity = ((1 - buoyancy) / (0 - 10)) * current Y-coordinate + buoyancy
12
- * Otherwise, gravity is set to 0.1.
13
- */
14
2
  export default function gravity(prop: calcPropType): void;
@@ -1,17 +1,5 @@
1
- /**
2
- * This function calculates and sets gravity.
3
- *
4
- * @param {calcPropType} prop - An object containing properties necessary for gravity calculation.
5
- * @param {object} prop.rigidBodyRef - A reference to the physical object where gravity is being set.
6
- * @param {object} prop.worldContext - An object representing the current state of the game world.
7
- * @param {number} prop.worldContext.activeState.position.y - The current Y-coordinate position.
8
- *
9
- * Gravity is calculated based on altitude and buoyancy. When altitude is less than 10, gravity is calculated as follows:
10
- * Gravity = ((1 - buoyancy) / (0 - 10)) * current Y-coordinate + buoyancy
11
- * Otherwise, gravity is set to 0.1.
12
- */
13
1
  export default function gravity(prop) {
14
- var rigidBodyRef = prop.rigidBodyRef, activeState = prop.worldContext.activeState, matchSizes = prop.matchSizes;
2
+ var rigidBodyRef = prop.rigidBodyRef, activeState = prop.worldContext.activeState;
15
3
  rigidBodyRef.current.setGravityScale(activeState.position.y < 10
16
4
  ? ((1 - 0.1) / (0 - 10)) * activeState.position.y + 1
17
5
  : 0.1, false);
@@ -10,7 +10,6 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { useFrame } from "@react-three/fiber";
13
- import { useRapier } from "@react-three/rapier";
14
13
  import { useContext, useEffect } from "react";
15
14
  import { GaesupControllerContext } from "../controller/context";
16
15
  import { useGaesupGltf } from "../hooks/useGaesupGltf";
@@ -21,7 +20,6 @@ import characterCalculation from "./character";
21
20
  import check from "./check";
22
21
  import vehicleCalculation from "./vehicle";
23
22
  export default function calculation(prop) {
24
- var world = useRapier().world;
25
23
  var worldContext = useContext(GaesupWorldContext);
26
24
  var controllerContext = useContext(GaesupControllerContext);
27
25
  var dispatch = useContext(GaesupWorldDispatchContext);
@@ -46,7 +44,7 @@ export default function calculation(prop) {
46
44
  return null;
47
45
  if (block.control)
48
46
  return null;
49
- var calcProp = __assign(__assign({}, prop), { state: state, delta: delta, worldContext: worldContext, controllerContext: controllerContext, dispatch: dispatch, world: world, matchSizes: getSizesByUrls(controllerContext === null || controllerContext === void 0 ? void 0 : controllerContext.urls) });
47
+ var calcProp = __assign(__assign({}, prop), { state: state, delta: delta, worldContext: worldContext, controllerContext: controllerContext, dispatch: dispatch, matchSizes: getSizesByUrls(controllerContext === null || controllerContext === void 0 ? void 0 : controllerContext.urls) });
50
48
  if (mode.type === "vehicle")
51
49
  vehicleCalculation(calcProp);
52
50
  else if (mode.type === "character")
@@ -1,5 +1,4 @@
1
1
  import { RootState } from "@react-three/fiber";
2
- import { World } from "@dimforge/rapier3d-compat";
3
2
  import * as THREE from "three";
4
3
  import { gaesupControllerType } from "../controller/context/type";
5
4
  import { controllerInnerType, refsType } from "../controller/type";
@@ -19,7 +18,6 @@ export type calcPropType = controllerInnerType & {
19
18
  };
20
19
  delta?: number;
21
20
  dispatch?: dispatchType<gaesupWorldContextType>;
22
- world: World;
23
21
  };
24
22
  export type intersectObjectMapType = {
25
23
  [uuid: string]: THREE.Mesh;
@@ -1,7 +1,7 @@
1
1
  import { vec3 } from "@react-three/rapier";
2
2
  import { V3 } from "../../utils/vector";
3
3
  export function joystick(prop) {
4
- var state = prop.state, _a = prop.worldContext, activeState = _a.activeState, joystick = _a.joystick;
4
+ var _a = prop.worldContext, activeState = _a.activeState, joystick = _a.joystick;
5
5
  var zAxis = joystick.joyStickOrigin.isOn ? 1 : 0;
6
6
  var front = vec3().set(zAxis, 0, zAxis);
7
7
  if (joystick.joyStickOrigin.isCenter)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gaesup-world",
3
- "version": "0.6.35",
3
+ "version": "0.6.52",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",