gaesup-world 0.6.57 → 0.6.61

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.
Files changed (89) hide show
  1. package/dist/gaesup/animation/actions.d.ts +6 -19
  2. package/dist/gaesup/animation/actions.js +27 -33
  3. package/dist/gaesup/camera/control/orbit.js +1 -1
  4. package/dist/gaesup/camera/detector/index.js +26 -23
  5. package/dist/gaesup/camera/index.d.ts +2 -7
  6. package/dist/gaesup/camera/index.js +12 -50
  7. package/dist/gaesup/component/active/airplane/index.d.ts +2 -4
  8. package/dist/gaesup/component/active/airplane/index.js +2 -34
  9. package/dist/gaesup/component/active/character/index.js +2 -35
  10. package/dist/gaesup/component/active/vehicle/index.d.ts +2 -4
  11. package/dist/gaesup/component/active/vehicle/index.js +2 -34
  12. package/dist/gaesup/component/index.js +2 -4
  13. package/dist/gaesup/component/inner/airplane/index.d.ts +2 -2
  14. package/dist/gaesup/component/inner/airplane/index.js +15 -7
  15. package/dist/gaesup/component/inner/character/index.d.ts +2 -16
  16. package/dist/gaesup/component/inner/character/index.js +15 -10
  17. package/dist/gaesup/component/inner/character/type.d.ts +18 -0
  18. package/dist/gaesup/component/inner/character/type.js +1 -0
  19. package/dist/gaesup/component/inner/common/InnerGroupRef.d.ts +6 -5
  20. package/dist/gaesup/component/inner/common/InnerGroupRef.js +3 -17
  21. package/dist/gaesup/component/inner/common/RigidbodyRef.d.ts +10 -6
  22. package/dist/gaesup/component/inner/common/RigidbodyRef.js +85 -12
  23. package/dist/gaesup/component/inner/common/setGroundRay.d.ts +1 -8
  24. package/dist/gaesup/component/inner/common/setGroundRay.js +5 -0
  25. package/dist/gaesup/component/inner/common/type.d.ts +32 -2
  26. package/dist/gaesup/component/inner/rider/index.js +6 -4
  27. package/dist/gaesup/component/inner/vehicle/index.d.ts +2 -2
  28. package/dist/gaesup/component/inner/vehicle/index.js +16 -9
  29. package/dist/gaesup/component/inner/vehicle/type.d.ts +28 -0
  30. package/dist/gaesup/component/inner/vehicle/type.js +1 -0
  31. package/dist/gaesup/component/passive/airplane/index.d.ts +1 -14
  32. package/dist/gaesup/component/passive/airplane/index.js +15 -12
  33. package/dist/gaesup/component/passive/airplane/type.d.ts +16 -0
  34. package/dist/gaesup/component/passive/airplane/type.js +1 -0
  35. package/dist/gaesup/component/passive/character/index.js +1 -1
  36. package/dist/gaesup/component/passive/vehicle/index.d.ts +1 -14
  37. package/dist/gaesup/component/passive/vehicle/index.js +12 -2
  38. package/dist/gaesup/component/passive/vehicle/type.d.ts +16 -0
  39. package/dist/gaesup/component/passive/vehicle/type.js +1 -0
  40. package/dist/gaesup/controller/index.js +0 -5
  41. package/dist/gaesup/controller/initialize/callback/index.d.ts +7 -4
  42. package/dist/gaesup/controller/initialize/callback/index.js +42 -22
  43. package/dist/gaesup/hooks/useGaesupAnimation/index.js +1 -1
  44. package/dist/gaesup/hooks/useRideable/index.d.ts +0 -8
  45. package/dist/gaesup/hooks/useRideable/index.js +0 -38
  46. package/dist/gaesup/physics/airplane/damping.d.ts +2 -2
  47. package/dist/gaesup/physics/airplane/direction.d.ts +2 -2
  48. package/dist/gaesup/physics/airplane/gravity.d.ts +2 -2
  49. package/dist/gaesup/physics/airplane/impulse.d.ts +2 -16
  50. package/dist/gaesup/physics/airplane/impulse.js +0 -14
  51. package/dist/gaesup/physics/airplane/index.d.ts +2 -2
  52. package/dist/gaesup/physics/airplane/innerCalc.d.ts +2 -2
  53. package/dist/gaesup/physics/airplane/landing.d.ts +2 -2
  54. package/dist/gaesup/physics/airplane/landing.js +0 -3
  55. package/dist/gaesup/physics/character/direction.d.ts +2 -2
  56. package/dist/gaesup/physics/character/impulse.d.ts +2 -2
  57. package/dist/gaesup/physics/character/index.d.ts +2 -2
  58. package/dist/gaesup/physics/character/innerCalc.d.ts +2 -2
  59. package/dist/gaesup/physics/character/innerCalc.js +8 -17
  60. package/dist/gaesup/physics/character/stop.d.ts +2 -2
  61. package/dist/gaesup/physics/check/ground.d.ts +2 -2
  62. package/dist/gaesup/physics/check/ground.js +13 -4
  63. package/dist/gaesup/physics/check/index.d.ts +2 -2
  64. package/dist/gaesup/physics/check/moving.d.ts +2 -2
  65. package/dist/gaesup/physics/check/moving.js +1 -3
  66. package/dist/gaesup/physics/check/push.d.ts +2 -2
  67. package/dist/gaesup/physics/check/riding.d.ts +2 -2
  68. package/dist/gaesup/physics/check/rotate.d.ts +2 -2
  69. package/dist/gaesup/physics/index.d.ts +7 -2
  70. package/dist/gaesup/physics/index.js +17 -15
  71. package/dist/gaesup/physics/type.d.ts +17 -11
  72. package/dist/gaesup/physics/type.js +1 -0
  73. package/dist/gaesup/physics/vehicle/damping.d.ts +2 -2
  74. package/dist/gaesup/physics/vehicle/direction.d.ts +4 -4
  75. package/dist/gaesup/physics/vehicle/impulse.d.ts +2 -2
  76. package/dist/gaesup/physics/vehicle/index.d.ts +2 -2
  77. package/dist/gaesup/physics/vehicle/innerCalc.d.ts +2 -2
  78. package/dist/gaesup/physics/vehicle/innerCalc.js +1 -18
  79. package/dist/gaesup/physics/vehicle/landing.d.ts +2 -2
  80. package/dist/gaesup/physics/vehicle/landing.js +0 -3
  81. package/dist/gaesup/tools/rideable/index.js +6 -5
  82. package/dist/gaesup/world/context/index.d.ts +2 -2
  83. package/dist/gaesup/world/context/index.js +2 -0
  84. package/dist/gaesup/world/context/reducer.d.ts +19 -19
  85. package/dist/gaesup/world/context/type.d.ts +2 -0
  86. package/dist/gaesup/world/debug/index.d.ts +1 -1
  87. package/dist/gaesup/world/initalize/index.d.ts +21 -19
  88. package/dist/gaesup/world/initalize/index.js +37 -5
  89. package/package.json +1 -1
@@ -13,8 +13,10 @@ export type Api<T extends AnimationClip> = {
13
13
  };
14
14
  export type playActionsType = {
15
15
  type: "character" | "vehicle" | "airplane";
16
- animationResult: Api<AnimationClip>;
17
16
  currentAnimation?: string;
17
+ actions: actionsType;
18
+ animationRef: Ref<Object3D<Object3DEventMap>>;
19
+ isActive: boolean;
18
20
  };
19
21
  export type subscribeActionsType = {
20
22
  type: "character" | "vehicle" | "airplane";
@@ -28,23 +30,8 @@ export type playResultType = {
28
30
  actions: actionsType;
29
31
  ref: Ref<Object3D<Object3DEventMap>>;
30
32
  };
31
- export declare function subscribeActions({ type, groundRay, animations, }: subscribeActionsType): {
32
- animationResult: {
33
- ref: import("react").MutableRefObject<THREE.Object3D<THREE.Object3DEventMap>>;
34
- clips: THREE.AnimationClip[];
35
- mixer: THREE.AnimationMixer;
36
- names: string[];
37
- actions: {
38
- [x: string]: THREE.AnimationAction;
39
- };
40
- };
41
- };
42
- export default function playActions({ type, animationResult, currentAnimation, }: playActionsType): {
43
- animationRef: import("react").MutableRefObject<THREE.Object3D<THREE.Object3DEventMap>>;
33
+ export declare function subscribeActions({ type }: subscribeActionsType): void;
34
+ export default function playActions({ type, actions, animationRef, currentAnimation, isActive, }: playActionsType): {
35
+ animationRef: Ref<THREE.Object3D<THREE.Object3DEventMap>>;
44
36
  currentAnimation: string;
45
37
  };
46
- export declare const setAnimation: ({ currentAnimation, actions, type, }: {
47
- currentAnimation?: string;
48
- actions?: actionsType;
49
- type?: "character" | "vehicle" | "airplane";
50
- }) => void;
@@ -9,16 +9,14 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import { useAnimations } from "@react-three/drei";
13
12
  import { useFrame } from "@react-three/fiber";
14
13
  import { useContext, useEffect } from "react";
15
14
  import { useGaesupAnimation } from "../hooks/useGaesupAnimation";
16
15
  import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../world/context";
17
16
  export function subscribeActions(_a) {
18
- var type = _a.type, groundRay = _a.groundRay, animations = _a.animations;
19
- var _b = useContext(GaesupWorldContext), states = _b.states, activeState = _b.activeState;
17
+ var type = _a.type;
18
+ var states = useContext(GaesupWorldContext).states;
20
19
  var subscribeAll = useGaesupAnimation({ type: type }).subscribeAll;
21
- var animationResult = useAnimations(animations);
22
20
  // 초기 기본 애니메이션 등록
23
21
  useEffect(function () {
24
22
  subscribeAll([
@@ -43,13 +41,6 @@ export function subscribeActions(_a) {
43
41
  animationName: "jump",
44
42
  key: "jump",
45
43
  },
46
- {
47
- tag: "fall",
48
- condition: function () { return groundRay.hit === null && activeState.velocity.y < 0; },
49
- action: function () { },
50
- animationName: "fall",
51
- key: "fall",
52
- },
53
44
  {
54
45
  tag: "ride",
55
46
  condition: function () { return states.isPush["keyR"]; },
@@ -57,19 +48,32 @@ export function subscribeActions(_a) {
57
48
  animationName: "ride",
58
49
  key: "ride",
59
50
  },
51
+ {
52
+ tag: "land",
53
+ condition: function () { return states.isLanding; },
54
+ action: function () { },
55
+ animationName: "land",
56
+ key: "land",
57
+ },
58
+ {
59
+ tag: "fall",
60
+ condition: function () { return states.isFalling; },
61
+ action: function () { },
62
+ animationName: "fall",
63
+ key: "fall",
64
+ },
60
65
  ]);
61
66
  }, []);
62
- return {
63
- animationResult: animationResult,
64
- };
65
67
  }
66
68
  export default function playActions(_a) {
67
- var _b;
68
- var type = _a.type, animationResult = _a.animationResult, currentAnimation = _a.currentAnimation;
69
- var _c = useContext(GaesupWorldContext), mode = _c.mode, animationState = _c.animationState, block = _c.block;
69
+ var _b, _c;
70
+ var type = _a.type, actions = _a.actions, animationRef = _a.animationRef, currentAnimation = _a.currentAnimation, isActive = _a.isActive;
71
+ var _d = useContext(GaesupWorldContext), mode = _d.mode, animationState = _d.animationState, block = _d.block;
70
72
  var dispatch = useContext(GaesupWorldDispatchContext);
71
- var _d = useGaesupAnimation({ type: type }), notify = _d.notify, store = _d.store;
72
- var actions = animationResult.actions, ref = animationResult.ref;
73
+ var _e = useGaesupAnimation({ type: type }), notify = _e.notify, store = _e.store;
74
+ if (isActive) {
75
+ currentAnimation = (_b = animationState === null || animationState === void 0 ? void 0 : animationState[type]) === null || _b === void 0 ? void 0 : _b.current;
76
+ }
73
77
  var play = function (tag) {
74
78
  animationState[type].current = tag;
75
79
  var currentAnimation = store[tag];
@@ -99,25 +103,15 @@ export default function playActions(_a) {
99
103
  return function () {
100
104
  action === null || action === void 0 ? void 0 : action.fadeOut(0.2);
101
105
  };
102
- }, [currentAnimation, mode.type, block.animation]);
106
+ }, [currentAnimation, mode.type, block.animation, type]);
103
107
  useFrame(function () {
104
- if (!currentAnimation) {
108
+ if (isActive) {
105
109
  var tag = notify();
106
110
  play(tag);
107
111
  }
108
112
  });
109
113
  return {
110
- animationRef: ref,
111
- currentAnimation: (_b = animationState === null || animationState === void 0 ? void 0 : animationState[type]) === null || _b === void 0 ? void 0 : _b.current,
114
+ animationRef: animationRef,
115
+ currentAnimation: (_c = animationState === null || animationState === void 0 ? void 0 : animationState[type]) === null || _c === void 0 ? void 0 : _c.current,
112
116
  };
113
117
  }
114
- export var setAnimation = function (_a) {
115
- var currentAnimation = _a.currentAnimation, actions = _a.actions, type = _a.type;
116
- useEffect(function () {
117
- var _a;
118
- var action = (_a = actions[currentAnimation]) === null || _a === void 0 ? void 0 : _a.reset().fadeIn(0.2).play();
119
- return function () {
120
- action === null || action === void 0 ? void 0 : action.fadeOut(0.2);
121
- };
122
- }, [currentAnimation, type]);
123
- };
@@ -13,7 +13,7 @@ export default function orbit(prop) {
13
13
  if (!state || !state.camera)
14
14
  return;
15
15
  var cameraPosition = makeOrbitCameraPosition(activeState, cameraOption);
16
- state.camera.position.lerp(cameraPosition, 1);
16
+ state.camera.position.lerp(cameraPosition.clone(), 0.2);
17
17
  state.camera.quaternion.copy(activeState.quat
18
18
  .clone()
19
19
  .multiply(quat().setFromAxisAngle(V3(0, 1, 0), Math.PI)));
@@ -1,25 +1,28 @@
1
- import * as THREE from "three";
2
1
  export default function detector(cameraProp) {
3
- var cameraRay = cameraProp.cameraRay, intersectObjectMap = cameraProp.intersectObjectMap;
4
- var intersects = cameraRay.rayCast.intersectObjects(Object.values(intersectObjectMap));
5
- var intersectId = {};
6
- intersects.map(function (_a) {
7
- var object = _a.object;
8
- if (object instanceof THREE.Mesh) {
9
- intersectId[object.uuid] = true;
10
- }
11
- });
12
- Object.values(intersectObjectMap).map(function (mesh) {
13
- if (mesh instanceof THREE.Mesh && mesh.material instanceof THREE.Material) {
14
- var material = mesh.material;
15
- if (intersectId[mesh.uuid]) {
16
- material.opacity = 0.2;
17
- material.transparent = true;
18
- }
19
- else {
20
- material.opacity = 1;
21
- material.transparent = false;
22
- }
23
- }
24
- });
2
+ // const { cameraRay, intersectObjectMap } = cameraProp;
3
+ //
4
+ // const intersects = cameraRay.rayCast.intersectObjects(
5
+ // Object.values(intersectObjectMap)
6
+ // );
7
+ //
8
+ // const intersectId = {};
9
+ //
10
+ // intersects.map(({ object }) => {
11
+ // if (object instanceof THREE.Mesh) {
12
+ // intersectId[object.uuid] = true;
13
+ // }
14
+ // });
15
+ //
16
+ // Object.values(intersectObjectMap).map((mesh) => {
17
+ // if (mesh instanceof THREE.Mesh && mesh.material instanceof THREE.Material) {
18
+ // const material = mesh.material;
19
+ // if (intersectId[mesh.uuid]) {
20
+ // material.opacity = 0.2;
21
+ // material.transparent = true;
22
+ // } else {
23
+ // material.opacity = 1;
24
+ // material.transparent = false;
25
+ // }
26
+ // }
27
+ // });
25
28
  }
@@ -1,7 +1,2 @@
1
- import { controllerInnerType } from "../controller/type";
2
- export default function Camera({ prop, control, }: {
3
- prop: controllerInnerType;
4
- control: {
5
- [key: string]: boolean;
6
- };
7
- }): void;
1
+ import { cameraPropType } from "../physics/type";
2
+ export default function Camera(prop: cameraPropType): void;
@@ -1,62 +1,24 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
1
  import { useFrame } from "@react-three/fiber";
13
- import { useContext, useMemo } from "react";
14
- import * as THREE from "three";
15
- import { GaesupControllerContext } from "../controller/context";
16
- import { GaesupWorldContext } from "../world/context";
17
2
  import normal, { makeNormalCameraPosition } from "./control/normal";
18
3
  import orbit from "./control/orbit";
19
- export default function Camera(_a) {
20
- var
21
- // refs,
22
- prop = _a.prop, control = _a.control;
23
- var worldContext = useContext(GaesupWorldContext);
24
- var controllerContext = useContext(GaesupControllerContext);
25
- var mode = worldContext.mode, cameraOption = worldContext.cameraOption, activeState = worldContext.activeState;
26
- // const cameraRef = useRef<CameraControls>();
27
- var intersectObjectMap = useMemo(function () { return ({}); }, []);
28
- var cameraProp = __assign(__assign({}, prop), { control: control, controllerContext: controllerContext, worldContext: worldContext, intersectObjectMap: intersectObjectMap });
29
- cameraProp.cameraRay.rayCast = new THREE.Raycaster(cameraProp.cameraRay.origin, cameraProp.cameraRay.dir, 0, -cameraOption.maxDistance);
30
- useFrame(function (state, delta) {
31
- // if (
32
- // !rigidBodyRef ||
33
- // !rigidBodyRef.current ||
34
- // !outerGroupRef ||
35
- // !outerGroupRef.current
36
- // )
37
- // return;
38
- cameraProp.delta = delta;
39
- cameraProp.state = state;
40
- if (!worldContext.block.camera) {
41
- if (mode.control === "orbit") {
42
- orbit(cameraProp);
4
+ export default function Camera(prop) {
5
+ useFrame(function (state) {
6
+ prop.state = state;
7
+ if (!prop.worldContext.block.camera) {
8
+ if (prop.worldContext.mode.control === "orbit") {
9
+ orbit(prop);
43
10
  }
44
- else if (mode.control === "normal") {
45
- normal(cameraProp);
11
+ else if (prop.worldContext.mode.control === "normal") {
12
+ normal(prop);
46
13
  }
47
14
  }
48
15
  });
49
- // zoom
50
- // useEffect(() => {
51
- // if (cameraRef.current) {
52
- // cameraRef.current.zoomTo(worldContext.cameraOption.zoom, true);
53
- // }
54
- // }, [worldContext.cameraOption.zoom]);
55
16
  // 포커스가 아닐 때 카메라 activeStae 따라가기
56
17
  useFrame(function () {
57
- if (!cameraOption.focus) {
58
- cameraOption.target = activeState.position;
59
- cameraOption.position = makeNormalCameraPosition(activeState, cameraOption);
18
+ if (!prop.worldContext.cameraOption.focus) {
19
+ prop.worldContext.cameraOption.target =
20
+ prop.worldContext.activeState.position;
21
+ prop.worldContext.cameraOption.position = makeNormalCameraPosition(prop.worldContext.activeState, prop.worldContext.cameraOption);
60
22
  }
61
23
  });
62
24
  }
@@ -1,11 +1,9 @@
1
1
  import { ReactNode } from "react";
2
2
  import * as THREE from "three";
3
- import { controllerInnerType, groundRayType, refsType } from "../../../controller/type";
3
+ import { refsType } from "../../../controller/type";
4
4
  import { urlsType } from "../../../world/context/type";
5
- export declare function AirplaneRef({ children, props, groundRay, enableRiding, isRiderOn, offset, refs, urls, }: {
5
+ export declare function AirplaneRef({ children, enableRiding, isRiderOn, offset, refs, urls, }: {
6
6
  children: ReactNode;
7
- props: controllerInnerType;
8
- groundRay: groundRayType;
9
7
  enableRiding?: boolean;
10
8
  isRiderOn?: boolean;
11
9
  offset?: THREE.Vector3;
@@ -1,38 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { vec3 } from "@react-three/rapier";
3
- import playActions, { subscribeActions } from "../../../animation/actions";
4
- import initCallback from "../../../controller/initialize/callback";
5
- import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
6
2
  import { AirplaneInnerRef } from "../../inner/airplane";
7
- import { setGroundRay } from "../../inner/common/setGroundRay";
8
3
  export function AirplaneRef(_a) {
9
- var children = _a.children, props = _a.props, groundRay = _a.groundRay, enableRiding = _a.enableRiding, isRiderOn = _a.isRiderOn, offset = _a.offset, refs = _a.refs, urls = _a.urls;
10
- var colliderRef = refs.colliderRef;
11
- var _b = useGltfAndSize({ url: urls.vehicleUrl }), size = _b.size, gltf = _b.gltf;
12
- groundRay.offset = vec3({
13
- x: 0,
14
- y: size.y * 5,
15
- z: 0,
16
- });
17
- setGroundRay({
18
- groundRay: groundRay,
19
- length: size.y * 5,
20
- colliderRef: colliderRef,
21
- });
22
- var animationResult = subscribeActions({
23
- type: "airplane",
24
- groundRay: groundRay,
25
- animations: gltf.animations,
26
- }).animationResult;
27
- var currentAnimation = playActions({
28
- type: "airplane",
29
- animationResult: animationResult,
30
- }).currentAnimation;
31
- // callback
32
- initCallback({
33
- props: props,
34
- animationResult: animationResult,
35
- type: "airplane",
36
- });
37
- return (_jsx(AirplaneInnerRef, { refs: refs, urls: urls, isRiderOn: isRiderOn, enableRiding: enableRiding, offset: offset, currentAnimation: currentAnimation, children: children }));
4
+ var children = _a.children, enableRiding = _a.enableRiding, isRiderOn = _a.isRiderOn, offset = _a.offset, refs = _a.refs, urls = _a.urls;
5
+ return (_jsx(AirplaneInnerRef, { refs: refs, urls: urls, name: "airplane", isRiderOn: isRiderOn, enableRiding: enableRiding, offset: offset, outerGroupRef: refs.outerGroupRef, innerGroupRef: refs.innerGroupRef, rigidBodyRef: refs.rigidBodyRef, colliderRef: refs.colliderRef, isActive: true, currentAnimation: "idle", componentType: "airplane", children: children }));
38
6
  }
@@ -1,39 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { vec3 } from "@react-three/rapier";
3
- import playActions, { subscribeActions } from "../../../animation/actions";
4
- import initCallback from "../../../controller/initialize/callback";
5
- import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
6
- import { CharacterInnerRef, calcCharacterColliderProps, } from "../../inner/character";
7
- import { setGroundRay } from "../../inner/common/setGroundRay";
2
+ import { CharacterInnerRef } from "../../inner/character";
8
3
  export function CharacterRef(_a) {
9
4
  var props = _a.props, refs = _a.refs, urls = _a.urls;
10
- var colliderRef = refs.colliderRef;
11
- var _b = useGltfAndSize({ url: urls.characterUrl }), size = _b.size, gltf = _b.gltf;
12
- var collider = calcCharacterColliderProps(size);
13
- props.groundRay.offset = vec3({
14
- x: 0,
15
- y: (collider === null || collider === void 0 ? void 0 : collider.halfHeight) ? -(collider === null || collider === void 0 ? void 0 : collider.halfHeight) : -1,
16
- z: 0,
17
- });
18
- setGroundRay({
19
- groundRay: props.groundRay,
20
- length: ((collider === null || collider === void 0 ? void 0 : collider.height) || 0) + 2,
21
- colliderRef: colliderRef,
22
- });
23
- var animationResult = subscribeActions({
24
- type: "character",
25
- groundRay: props.groundRay,
26
- animations: gltf.animations,
27
- }).animationResult;
28
- var _c = playActions({
29
- type: "character",
30
- animationResult: animationResult,
31
- }), animationRef = _c.animationRef, currentAnimation = _c.currentAnimation;
32
- // callback
33
- initCallback({
34
- props: props,
35
- animationResult: animationResult,
36
- type: "character",
37
- });
38
- return (_jsx(CharacterInnerRef, { animationRef: animationRef, refs: refs, urls: urls, currentAnimation: currentAnimation, children: props.children }));
5
+ return (_jsx(CharacterInnerRef, { refs: refs, urls: urls, outerGroupRef: refs.outerGroupRef, innerGroupRef: refs.innerGroupRef, rigidBodyRef: refs.rigidBodyRef, colliderRef: refs.colliderRef, isActive: true, componentType: "character", children: props.children }));
39
6
  }
@@ -1,11 +1,9 @@
1
1
  import { ReactNode } from "react";
2
2
  import * as THREE from "three";
3
- import { controllerInnerType, groundRayType, refsType } from "../../../controller/type";
3
+ import { refsType } from "../../../controller/type";
4
4
  import { urlsType } from "../../../world/context/type";
5
- export declare function VehicleRef({ children, props, groundRay, enableRiding, isRiderOn, offset, refs, urls, }: {
5
+ export declare function VehicleRef({ children, enableRiding, isRiderOn, offset, refs, urls, }: {
6
6
  children: ReactNode;
7
- props: controllerInnerType;
8
- groundRay: groundRayType;
9
7
  enableRiding?: boolean;
10
8
  isRiderOn?: boolean;
11
9
  offset?: THREE.Vector3;
@@ -1,38 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { vec3 } from "@react-three/rapier";
3
- import playActions, { subscribeActions } from "../../../animation/actions";
4
- import initCallback from "../../../controller/initialize/callback";
5
- import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
6
- import { setGroundRay } from "../../inner/common/setGroundRay";
7
2
  import { VehicleInnerRef } from "../../inner/vehicle";
8
3
  export function VehicleRef(_a) {
9
- var children = _a.children, props = _a.props, groundRay = _a.groundRay, enableRiding = _a.enableRiding, isRiderOn = _a.isRiderOn, offset = _a.offset, refs = _a.refs, urls = _a.urls;
10
- var colliderRef = refs.colliderRef;
11
- var _b = useGltfAndSize({ url: urls.vehicleUrl }), size = _b.size, gltf = _b.gltf;
12
- groundRay.offset = vec3({
13
- x: 0,
14
- y: size.y * 3,
15
- z: 0,
16
- });
17
- setGroundRay({
18
- groundRay: groundRay,
19
- length: size.y * 3,
20
- colliderRef: colliderRef,
21
- });
22
- var animationResult = subscribeActions({
23
- type: "vehicle",
24
- groundRay: groundRay,
25
- animations: gltf.animations,
26
- }).animationResult;
27
- var currentAnimation = playActions({
28
- type: "vehicle",
29
- animationResult: animationResult,
30
- }).currentAnimation;
31
- // callback
32
- initCallback({
33
- props: props,
34
- animationResult: animationResult,
35
- type: "vehicle",
36
- });
37
- return (_jsx(VehicleInnerRef, { refs: refs, urls: urls, isRiderOn: isRiderOn, enableRiding: enableRiding, offset: offset, currentAnimation: currentAnimation, children: children }));
4
+ var children = _a.children, enableRiding = _a.enableRiding, isRiderOn = _a.isRiderOn, offset = _a.offset, refs = _a.refs, urls = _a.urls;
5
+ return (_jsx(VehicleInnerRef, { refs: refs, urls: urls, name: "vehicle", isRiderOn: isRiderOn, enableRiding: enableRiding, offset: offset, outerGroupRef: refs.outerGroupRef, innerGroupRef: refs.innerGroupRef, rigidBodyRef: refs.rigidBodyRef, colliderRef: refs.colliderRef, isActive: true, currentAnimation: "idle", componentType: "vehicle", children: children }));
38
6
  }
@@ -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 calculation from "../physics";
5
4
  import { GaesupWorldContext } from "../world/context";
6
5
  import { AirplaneRef } from "./active/airplane";
7
6
  import { CharacterRef } from "./active/character";
@@ -10,10 +9,9 @@ export function GaesupComponent(_a) {
10
9
  var props = _a.props, refs = _a.refs, urls = _a.urls;
11
10
  var _b = useContext(GaesupWorldContext), mode = _b.mode, states = _b.states, rideable = _b.rideable;
12
11
  var enableRiding = states.enableRiding, isRiderOn = states.isRiderOn, rideableId = states.rideableId;
13
- calculation(props);
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]
12
+ return (_jsxs(_Fragment, { children: [mode.type === "character" && (_jsx(CharacterRef, { props: props, refs: refs, urls: urls })), mode.type === "vehicle" && (_jsx(VehicleRef, { refs: refs, urls: urls, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
15
13
  ? rideable[rideableId].offset
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]
14
+ : vec3(), children: props.children })), mode.type === "airplane" && (_jsx(AirplaneRef, { refs: refs, urls: urls, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
17
15
  ? rideable[rideableId].offset
18
16
  : vec3(), children: props.children }))] }));
19
17
  }
@@ -1,2 +1,2 @@
1
- import { refPropsType } from "../common/type";
2
- export declare function AirplaneInnerRef({ children, refs, urls, isRiderOn, enableRiding, offset, name, position, rotation, userData, onCollisionEnter, type, }: refPropsType): import("react/jsx-runtime").JSX.Element;
1
+ import { vehicleInnerType } from "../vehicle/type";
2
+ export declare function AirplaneInnerRef(props: vehicleInnerType): import("react/jsx-runtime").JSX.Element;
@@ -1,16 +1,24 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
13
  import { CuboidCollider } from "@react-three/rapier";
3
14
  import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
4
- import { InnerGroupRef } from "../common/InnerGroupRef";
5
15
  import { OuterGroupRef } from "../common/OuterGroupRef";
6
16
  import { RigidBodyRef } from "../common/RigidbodyRef";
7
- import RiderRef from "../rider";
8
- export function AirplaneInnerRef(_a) {
9
- var children = _a.children, refs = _a.refs, urls = _a.urls, isRiderOn = _a.isRiderOn, enableRiding = _a.enableRiding, offset = _a.offset, name = _a.name, position = _a.position, rotation = _a.rotation, userData = _a.userData, onCollisionEnter = _a.onCollisionEnter, type = _a.type;
10
- var airplaneUrl = urls.airplaneUrl;
11
- var rigidBodyRef = refs.rigidBodyRef, innerGroupRef = refs.innerGroupRef, outerGroupRef = refs.outerGroupRef;
17
+ export function AirplaneInnerRef(props) {
18
+ var airplaneUrl = props.urls.airplaneUrl;
19
+ var _a = props.refs, rigidBodyRef = _a.rigidBodyRef, innerGroupRef = _a.innerGroupRef, outerGroupRef = _a.outerGroupRef, colliderRef = _a.colliderRef;
12
20
  var size = useGltfAndSize({
13
21
  url: airplaneUrl,
14
22
  }).size;
15
- return (_jsx(OuterGroupRef, { ref: outerGroupRef, children: airplaneUrl && (_jsxs(RigidBodyRef, { ref: rigidBodyRef, name: name, position: position, rotation: rotation, userData: userData, onCollisionEnter: onCollisionEnter, type: type, children: [_jsx(CuboidCollider, { args: [size.x / 2, size.y / 2, size.z / 2], position: [0, size.y / 2, 0] }), children, _jsx(InnerGroupRef, { type: "airplane", url: airplaneUrl, currentAnimation: "idle", ref: innerGroupRef, children: enableRiding && isRiderOn && urls.characterUrl && (_jsx(RiderRef, { urls: urls, offset: offset })) })] })) }));
23
+ return (_jsx(OuterGroupRef, { ref: outerGroupRef, children: airplaneUrl && (_jsxs(RigidBodyRef, __assign({ ref: rigidBodyRef, name: props.name, url: props.urls.vehicleUrl, outerGroupRef: outerGroupRef, innerGroupRef: innerGroupRef, rigidBodyRef: rigidBodyRef, colliderRef: colliderRef, componentType: "vehicle" }, props, { children: [_jsx(CuboidCollider, { args: [size.x / 2, size.y / 2, size.z / 2], position: [0, size.y / 2, 0] }), props.children] }))) }));
16
24
  }
@@ -1,9 +1,5 @@
1
- import { refsType } from "../../../controller/type";
2
- import { RigidBodyTypeString } from "@react-three/rapier";
3
- import { ReactNode, Ref } from "react";
4
1
  import * as THREE from "three";
5
- import { Object3D, Object3DEventMap } from "three";
6
- import { urlsType } from "../../../world/context/type";
2
+ import { characterInnerType } from "./type";
7
3
  export declare const calcCharacterColliderProps: (characterSize: THREE.Vector3) => {
8
4
  height: number;
9
5
  halfHeight: number;
@@ -16,14 +12,4 @@ export type characterColliderType = {
16
12
  radius: number;
17
13
  diameter: number;
18
14
  };
19
- export declare function CharacterInnerRef({ children, refs, urls, position, euler, currentAnimation, positionLerp, type, }: {
20
- children: ReactNode;
21
- refs: Partial<refsType>;
22
- urls: urlsType;
23
- position?: THREE.Vector3;
24
- euler?: THREE.Euler;
25
- animationRef?: Ref<Object3D<Object3DEventMap>>;
26
- currentAnimation?: string;
27
- positionLerp?: number;
28
- type?: RigidBodyTypeString;
29
- }): import("react/jsx-runtime").JSX.Element;
15
+ export declare function CharacterInnerRef(props: characterInnerType): import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,15 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { CapsuleCollider } from "@react-three/rapier";
3
- import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
4
- import { InnerGroupRef } from "../common/InnerGroupRef";
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
5
13
  import { OuterGroupRef } from "../common/OuterGroupRef";
6
14
  import { RigidBodyRef } from "../common/RigidbodyRef";
7
15
  export var calcCharacterColliderProps = function (characterSize) {
@@ -19,10 +27,7 @@ export var calcCharacterColliderProps = function (characterSize) {
19
27
  diameter: diameter,
20
28
  };
21
29
  };
22
- export function CharacterInnerRef(_a) {
23
- var children = _a.children, refs = _a.refs, urls = _a.urls, position = _a.position, euler = _a.euler, currentAnimation = _a.currentAnimation, positionLerp = _a.positionLerp, type = _a.type;
24
- var outerGroupRef = refs.outerGroupRef, rigidBodyRef = refs.rigidBodyRef, colliderRef = refs.colliderRef, innerGroupRef = refs.innerGroupRef;
25
- var size = useGltfAndSize({ url: urls.characterUrl }).size;
26
- var collider = calcCharacterColliderProps(size);
27
- return (_jsx(_Fragment, { children: collider && (_jsx(OuterGroupRef, { ref: outerGroupRef, children: _jsxs(RigidBodyRef, { ref: rigidBodyRef, name: "character", position: position, positionLerp: positionLerp, rotation: euler, type: type, children: [_jsx(CapsuleCollider, { ref: colliderRef, args: [collider.height, collider.radius], position: [0, collider.height + collider.radius, 0] }), _jsx(InnerGroupRef, { type: "character", ref: innerGroupRef, url: urls.characterUrl, currentAnimation: currentAnimation, children: children })] }) })) }));
30
+ export function CharacterInnerRef(props) {
31
+ var _a = props.refs, outerGroupRef = _a.outerGroupRef, rigidBodyRef = _a.rigidBodyRef, colliderRef = _a.colliderRef, innerGroupRef = _a.innerGroupRef;
32
+ return (_jsx(OuterGroupRef, { ref: outerGroupRef, children: _jsx(RigidBodyRef, __assign({ ref: rigidBodyRef, name: "character", url: props.urls.characterUrl, outerGroupRef: outerGroupRef, innerGroupRef: innerGroupRef, rigidBodyRef: rigidBodyRef, colliderRef: colliderRef }, props, { children: props.children })) }));
28
33
  }
@@ -0,0 +1,18 @@
1
+ import { RigidBodyTypeString } from "@react-three/rapier";
2
+ import { ReactNode } from "react";
3
+ import * as THREE from "three";
4
+ import { refsType } from "../../../controller/type";
5
+ import { propInnerType } from "../../../physics/type";
6
+ import { urlsType } from "../../../world/context/type";
7
+ export type characterInnerType = {
8
+ children: ReactNode;
9
+ refs: Partial<refsType>;
10
+ urls: urlsType;
11
+ position?: THREE.Vector3;
12
+ positionLerp?: number;
13
+ euler?: THREE.Euler;
14
+ type?: RigidBodyTypeString;
15
+ componentType: "character" | "vehicle" | "airplane";
16
+ currentAnimation?: string;
17
+ isActive?: boolean;
18
+ } & propInnerType;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,10 +1,11 @@
1
- /// <reference types="react" />
1
+ import { MutableRefObject } from "react";
2
2
  import * as THREE from "three";
3
3
  export type InnerGroupRefType = {
4
4
  children?: React.ReactNode;
5
- type: "character" | "vehicle" | "airplane";
6
- currentAnimation: string;
7
- url: string;
8
- rotation?: THREE.Euler;
5
+ objectNode: THREE.Object3D;
6
+ animationRef: MutableRefObject<THREE.Object3D<THREE.Object3DEventMap>>;
7
+ nodes: {
8
+ [name: string]: THREE.Object3D<THREE.Object3DEventMap>;
9
+ };
9
10
  };
10
11
  export declare const InnerGroupRef: import("react").ForwardRefExoticComponent<InnerGroupRefType & import("react").RefAttributes<THREE.Group<THREE.Object3DEventMap>>>;