gaesup-world 0.6.3 → 0.6.5

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
@@ -67,33 +58,5 @@ export default function Camera(_a) {
67
58
  cameraOption.position = makeNormalCameraPosition(activeState, cameraOption);
68
59
  }
69
60
  });
70
- // lookat
71
- // useEffect(() => {
72
- // if (cameraRef.current) {
73
- // const currentCamera = camera.position.clone();
74
- // if (cameraOption.focus) {
75
- // cameraRef.current.setLookAt(
76
- // currentCamera.x,
77
- // currentCamera.y,
78
- // currentCamera.z,
79
- // cameraOption.target.x,
80
- // cameraOption.target.y,
81
- // cameraOption.target.z,
82
- // true
83
- // );
84
- // // 포커스 품
85
- // } else if (!cameraOption.focus) {
86
- // cameraRef.current.setLookAt(
87
- // currentCamera.x,
88
- // currentCamera.y,
89
- // currentCamera.z,
90
- // activeState.position.x,
91
- // activeState.position.y,
92
- // activeState.position.z,
93
- // true
94
- // );
95
- // }
96
- // }
97
- // }, [cameraOption.focus]);
98
61
  return _jsx(CameraControls, { ref: cameraRef });
99
62
  }
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useGraph } from "@react-three/fiber";
3
- import { Suspense, forwardRef, useMemo } from "react";
3
+ import { forwardRef, useMemo } from "react";
4
4
  import * as THREE from "three";
5
5
  import { SkeletonUtils } from "three-stdlib";
6
6
  import { useAnimations, useGLTF } from "@react-three/drei";
@@ -17,13 +17,13 @@ export var InnerGroupRef = forwardRef(function (_a, ref) {
17
17
  var clone = useMemo(function () { return SkeletonUtils.clone(scene); }, [scene]);
18
18
  var nodes = useGraph(clone).nodes;
19
19
  var objectNode = Object.values(nodes).find(function (node) { return node.type === "Object3D"; });
20
- return (_jsx(Suspense, { fallback: null, children: _jsxs("group", { receiveShadow: true, castShadow: true, ref: ref, rotation: rotation, userData: { intangible: true }, children: [children, objectNode && animationRef && (_jsx("primitive", { object: objectNode, visible: false, receiveShadow: true, castShadow: true, ref: animationRef })), Object.keys(nodes).map(function (name, key) {
21
- var node = nodes[name];
22
- if (node instanceof THREE.SkinnedMesh) {
23
- return (_jsx("skinnedMesh", { castShadow: true, receiveShadow: true, material: node.material, geometry: node.geometry, skeleton: node.skeleton }, key));
24
- }
25
- else if (node instanceof THREE.Mesh) {
26
- return (_jsx("mesh", { castShadow: true, receiveShadow: true, material: node.material, geometry: node.geometry }, key));
27
- }
28
- })] }) }));
20
+ return (_jsxs("group", { receiveShadow: true, castShadow: true, ref: ref, rotation: rotation, userData: { intangible: true }, children: [children, objectNode && animationRef && (_jsx("primitive", { object: objectNode, visible: false, receiveShadow: true, castShadow: true, ref: animationRef })), Object.keys(nodes).map(function (name, key) {
21
+ var node = nodes[name];
22
+ if (node instanceof THREE.SkinnedMesh) {
23
+ return (_jsx("skinnedMesh", { castShadow: true, receiveShadow: true, material: node.material, geometry: node.geometry, skeleton: node.skeleton }, key));
24
+ }
25
+ else if (node instanceof THREE.Mesh) {
26
+ return (_jsx("mesh", { castShadow: true, receiveShadow: true, material: node.material, geometry: node.geometry }, key));
27
+ }
28
+ })] }));
29
29
  });
@@ -22,7 +22,7 @@ export function PassiveCharacter(props) {
22
22
  };
23
23
  }, [props]), position = _a.position, euler = _a.euler;
24
24
  useEffect(function () {
25
- if (rigidBodyRef || rigidBodyRef.current) {
25
+ if (rigidBodyRef && rigidBodyRef.current) {
26
26
  rigidBodyRef.current.setEnabledRotations(false, false, false, false);
27
27
  }
28
28
  }, []);
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { vec3 } from "@react-three/rapier";
14
- import { Suspense, useContext, useEffect, useRef } from "react";
14
+ import { useContext, useEffect, useRef } from "react";
15
15
  import * as THREE from "three";
16
16
  import useClicker from "../hooks/useClicker";
17
17
  import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../world/context";
@@ -42,5 +42,5 @@ export function GaeSupProps(_a) {
42
42
  });
43
43
  }
44
44
  }, []);
45
- return (_jsx(Suspense, { fallback: null, children: _jsx("group", { ref: groupRef, position: position, onPointerDown: function (e) { return moveClicker(e, false, type); }, onDoubleClick: function (e) { return moveClicker(e, true, type); }, children: children }) }));
45
+ return (_jsx("group", { ref: groupRef, position: position, onPointerDown: function (e) { return moveClicker(e, false, type); }, onDoubleClick: function (e) { return moveClicker(e, true, type); }, children: children }));
46
46
  }
@@ -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,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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gaesup-world",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,10 +20,10 @@
20
20
  "@dimforge/rapier3d": "^0.12.0",
21
21
  "@dimforge/rapier3d-compat": "^0.12.0",
22
22
  "@react-icons/all-files": "^4.1.0",
23
- "@react-three/drei": "9.102.6",
24
- "@react-three/fiber": "8.16.1",
25
- "@react-three/rapier": "^1.3.0",
26
- "@types/three": "^0.162.0",
23
+ "@react-three/drei": "9.105.4",
24
+ "@react-three/fiber": "8.16.2",
25
+ "@react-three/rapier": "^1.3.1",
26
+ "@types/three": "^0.163.0",
27
27
  "gh-pages": "^6.1.1",
28
28
  "leva": "0.9.35",
29
29
  "lodash": "^4.17.21",
@@ -38,10 +38,10 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/lodash": "^4.17.0",
41
- "@types/react": "^18.2.73",
42
- "@types/react-dom": "^18.2.23",
43
- "@typescript-eslint/eslint-plugin": "^7.4.0",
44
- "@typescript-eslint/parser": "^7.4.0",
41
+ "@types/react": "^18.2.78",
42
+ "@types/react-dom": "^18.2.25",
43
+ "@typescript-eslint/eslint-plugin": "^7.6.0",
44
+ "@typescript-eslint/parser": "^7.6.0",
45
45
  "@vanilla-extract/css": "^1.14.2",
46
46
  "@vanilla-extract/dynamic": "^2.1.0",
47
47
  "@vanilla-extract/recipes": "^0.5.2",
@@ -49,15 +49,15 @@
49
49
  "@vanilla-extract/vite-plugin": "^4.0.7",
50
50
  "@vitejs/plugin-react-swc": "^3.6.0",
51
51
  "copyfiles": "^2.4.1",
52
- "css-loader": "^6.10.0",
53
- "eslint": "^8.57.0",
52
+ "css-loader": "^7.1.1",
53
+ "eslint": "^9.0.0",
54
54
  "eslint-plugin-react-hooks": "^4.6.0",
55
55
  "eslint-plugin-react-refresh": "^0.4.6",
56
56
  "path": "^0.12.7",
57
57
  "prettier": "^3.2.5",
58
58
  "rimraf": "^5.0.5",
59
- "typescript": "^5.4.3",
60
- "vite": "^5.2.7",
59
+ "typescript": "^5.4.5",
60
+ "vite": "^5.2.8",
61
61
  "vite-plugin-svgr": "^4.2.0"
62
62
  },
63
63
  "description": "Web 3D Character Controller and World Platform Library",