gaesup-world 0.6.55 → 0.6.57

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,8 +1,7 @@
1
- import { controllerInnerType, refsType } from "../controller/type";
2
- export default function Camera({ refs, prop, control, }: {
3
- refs: refsType;
1
+ import { controllerInnerType } from "../controller/type";
2
+ export default function Camera({ prop, control, }: {
4
3
  prop: controllerInnerType;
5
4
  control: {
6
5
  [key: string]: boolean;
7
6
  };
8
- }): import("react/jsx-runtime").JSX.Element;
7
+ }): void;
@@ -9,31 +9,32 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import { CameraControls } from "@react-three/drei";
14
12
  import { useFrame } from "@react-three/fiber";
15
- import { useContext, useEffect, useMemo, useRef } from "react";
13
+ import { useContext, useMemo } from "react";
16
14
  import * as THREE from "three";
17
15
  import { GaesupControllerContext } from "../controller/context";
18
16
  import { GaesupWorldContext } from "../world/context";
19
17
  import normal, { makeNormalCameraPosition } from "./control/normal";
20
18
  import orbit from "./control/orbit";
21
19
  export default function Camera(_a) {
22
- var refs = _a.refs, prop = _a.prop, control = _a.control;
20
+ var
21
+ // refs,
22
+ prop = _a.prop, control = _a.control;
23
23
  var worldContext = useContext(GaesupWorldContext);
24
24
  var controllerContext = useContext(GaesupControllerContext);
25
25
  var mode = worldContext.mode, cameraOption = worldContext.cameraOption, activeState = worldContext.activeState;
26
- var rigidBodyRef = refs.rigidBodyRef, outerGroupRef = refs.outerGroupRef;
27
- var cameraRef = useRef();
26
+ // const cameraRef = useRef<CameraControls>();
28
27
  var intersectObjectMap = useMemo(function () { return ({}); }, []);
29
28
  var cameraProp = __assign(__assign({}, prop), { control: control, controllerContext: controllerContext, worldContext: worldContext, intersectObjectMap: intersectObjectMap });
30
29
  cameraProp.cameraRay.rayCast = new THREE.Raycaster(cameraProp.cameraRay.origin, cameraProp.cameraRay.dir, 0, -cameraOption.maxDistance);
31
30
  useFrame(function (state, delta) {
32
- if (!rigidBodyRef ||
33
- !rigidBodyRef.current ||
34
- !outerGroupRef ||
35
- !outerGroupRef.current)
36
- return;
31
+ // if (
32
+ // !rigidBodyRef ||
33
+ // !rigidBodyRef.current ||
34
+ // !outerGroupRef ||
35
+ // !outerGroupRef.current
36
+ // )
37
+ // return;
37
38
  cameraProp.delta = delta;
38
39
  cameraProp.state = state;
39
40
  if (!worldContext.block.camera) {
@@ -46,11 +47,11 @@ export default function Camera(_a) {
46
47
  }
47
48
  });
48
49
  // zoom
49
- useEffect(function () {
50
- if (cameraRef.current) {
51
- cameraRef.current.zoomTo(worldContext.cameraOption.zoom, true);
52
- }
53
- }, [worldContext.cameraOption.zoom]);
50
+ // useEffect(() => {
51
+ // if (cameraRef.current) {
52
+ // cameraRef.current.zoomTo(worldContext.cameraOption.zoom, true);
53
+ // }
54
+ // }, [worldContext.cameraOption.zoom]);
54
55
  // 포커스가 아닐 때 카메라 activeStae 따라가기
55
56
  useFrame(function () {
56
57
  if (!cameraOption.focus) {
@@ -58,5 +59,4 @@ export default function Camera(_a) {
58
59
  cameraOption.position = makeNormalCameraPosition(activeState, cameraOption);
59
60
  }
60
61
  });
61
- return _jsx(CameraControls, { ref: cameraRef });
62
62
  }
@@ -1,7 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { vec3 } from "@react-three/rapier";
3
3
  import { useContext } from "react";
4
- import Camera from "../camera";
5
4
  import calculation from "../physics";
6
5
  import { GaesupWorldContext } from "../world/context";
7
6
  import { AirplaneRef } from "./active/airplane";
@@ -12,7 +11,7 @@ export function GaesupComponent(_a) {
12
11
  var _b = useContext(GaesupWorldContext), mode = _b.mode, states = _b.states, rideable = _b.rideable;
13
12
  var enableRiding = states.enableRiding, isRiderOn = states.isRiderOn, rideableId = states.rideableId;
14
13
  calculation(props);
15
- return (_jsxs(_Fragment, { children: [_jsx(Camera, { refs: refs, prop: props, control: props.keyControl }), mode.type === "character" && (_jsx(CharacterRef, { props: props, refs: refs, urls: urls })), mode.type === "vehicle" && (_jsx(VehicleRef, { props: props, groundRay: props.groundRay, refs: refs, urls: urls, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
14
+ return (_jsxs(_Fragment, { children: [mode.type === "character" && (_jsx(CharacterRef, { props: props, refs: refs, urls: urls })), mode.type === "vehicle" && (_jsx(VehicleRef, { props: props, groundRay: props.groundRay, refs: refs, urls: urls, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
16
15
  ? rideable[rideableId].offset
17
16
  : vec3(), children: props.children })), mode.type === "airplane" && (_jsx(AirplaneRef, { props: props, groundRay: props.groundRay, refs: refs, urls: urls, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
18
17
  ? rideable[rideableId].offset
@@ -13,6 +13,7 @@ var __assign = (this && this.__assign) || function () {
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { useContext, useMemo, useReducer, useRef } from "react";
15
15
  import { KeyboardControls } from "@react-three/drei";
16
+ import Camera from "../camera";
16
17
  import { GaesupComponent } from "../component";
17
18
  import { GaesupWorldContext } from "../world/context";
18
19
  import { GaesupControllerContext, GaesupControllerDispatchContext, gaesupControllerDefault, } from "./context";
@@ -70,5 +71,9 @@ export function GaesupControllerInner(props) {
70
71
  controllerContext: gaesupControl.value,
71
72
  controllerDispatch: gaesupControl.dispatch,
72
73
  });
74
+ Camera({
75
+ prop: prop,
76
+ control: prop.keyControl,
77
+ });
73
78
  return (_jsx(GaesupControllerContext.Provider, { value: gaesupControl.value, children: _jsx(GaesupControllerDispatchContext.Provider, { value: gaesupControl.dispatch, children: _jsx(GaesupComponent, { props: prop, refs: refs, urls: props.urls }) }) }));
74
79
  }
@@ -1,16 +1,2 @@
1
1
  import { calcPropType } from "../type";
2
- /**
3
- * This function applies an impulse to a rigid body in the game world.
4
- *
5
- * @param {calcPropType} prop - An object containing properties necessary for applying the impulse.
6
- * @param {object} prop.rigidBodyRef - A reference to the rigid body to which the impulse is applied.
7
- * @param {object} prop.worldContext - An object representing the current state of the game world.
8
- * @param {object} prop.controllerContext - An object containing controller-specific context data.
9
- * @param {object} prop.controllerContext.vehicle - An object representing the vehicle controller context.
10
- * @param {number} prop.controllerContext.vehicle.maxSpeed - The maximum speed of the vehicle.
11
- *
12
- * This function calculates the current speed of the rigid body and compares it to the maximum speed.
13
- * If the current speed is greater than the maximum speed, no impulse is applied.
14
- * Otherwise, an impulse is applied to the rigid body in the direction specified by `activeState.dir.
15
- */
16
2
  export default function impulse(prop: calcPropType): void;
@@ -1,24 +1,9 @@
1
1
  import { vec3 } from "@react-three/rapier";
2
- /**
3
- * This function applies an impulse to a rigid body in the game world.
4
- *
5
- * @param {calcPropType} prop - An object containing properties necessary for applying the impulse.
6
- * @param {object} prop.rigidBodyRef - A reference to the rigid body to which the impulse is applied.
7
- * @param {object} prop.worldContext - An object representing the current state of the game world.
8
- * @param {object} prop.controllerContext - An object containing controller-specific context data.
9
- * @param {object} prop.controllerContext.vehicle - An object representing the vehicle controller context.
10
- * @param {number} prop.controllerContext.vehicle.maxSpeed - The maximum speed of the vehicle.
11
- *
12
- * This function calculates the current speed of the rigid body and compares it to the maximum speed.
13
- * If the current speed is greater than the maximum speed, no impulse is applied.
14
- * Otherwise, an impulse is applied to the rigid body in the direction specified by `activeState.dir.
15
- */
16
2
  export default function impulse(prop) {
17
3
  var rigidBodyRef = prop.rigidBodyRef, _a = prop.worldContext, activeState = _a.activeState, control = _a.control, mode = _a.mode, joystick = _a.joystick, vehicle = prop.controllerContext.vehicle;
18
4
  var shift = control.shift;
19
5
  var maxSpeed = vehicle.maxSpeed, accelRatio = vehicle.accelRatio;
20
6
  var velocity = rigidBodyRef.current.linvel();
21
- // const V = vec3(velocity).length();
22
7
  // a = v / t (t = 1) (approximate calculation)
23
8
  var V = vec3(velocity).length();
24
9
  if (V < maxSpeed) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gaesup-world",
3
- "version": "0.6.55",
3
+ "version": "0.6.57",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",