gaesup-world 0.9.55 → 0.9.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,159 +1,3 @@
1
- // import { useAnimations, useGLTF } from "@react-three/drei";
2
- // import { useFrame, useGraph } from "@react-three/fiber";
3
- // import {
4
- // CapsuleCollider,
5
- // RapierRigidBody,
6
- // RigidBody,
7
- // euler,
8
- // } from "@react-three/rapier";
9
- // import { MutableRefObject, forwardRef, useContext, useMemo } from "react";
10
- // import * as THREE from "three";
11
- // import { SkeletonUtils } from "three-stdlib";
12
- // import playActions, { subscribeActions } from "../../../animation/actions";
13
- // import Camera from "../../../camera";
14
- // import { GaesupControllerContext } from "../../../controller/context";
15
- // import initCallback from "../../../controller/initialize/callback";
16
- // import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
17
- // import calculation from "../../../physics";
18
- // import { cameraPropType } from "../../../physics/type";
19
- // import { V3 } from "../../../utils";
20
- // import { GaesupWorldContext } from "../../../world/context";
21
- // import { InnerGroupRef } from "./InnerGroupRef";
22
- // import { PartsGroupRef } from "./partsGroupRef";
23
- // import { setGroundRay } from "./setGroundRay";
24
- // import { rigidBodyRefType } from "./type";
25
- //
26
- // export const RigidBodyRef = forwardRef(
27
- // (props: rigidBodyRefType, ref: MutableRefObject<RapierRigidBody>) => {
28
- // const { size } = useGltfAndSize({ url: props.url });
29
- //
30
- // props.groundRay &&
31
- // setGroundRay({
32
- // groundRay: props.groundRay,
33
- // length: 0.5,
34
- // colliderRef: props.colliderRef,
35
- // });
36
- // const { scene, animations } = useGLTF(props.url);
37
- // const { actions, ref: animationRef } = useAnimations(animations);
38
- // const worldContext = useContext(GaesupWorldContext);
39
- // const controllerContext = useContext(GaesupControllerContext);
40
- // if (props.isActive) {
41
- // subscribeActions({
42
- // type: props.componentType,
43
- // groundRay: props.groundRay,
44
- // animations: animations,
45
- // });
46
- // const cameraProps: cameraPropType = {
47
- // state: null,
48
- // worldContext,
49
- // controllerContext,
50
- // controllerOptions: props.controllerOptions,
51
- // };
52
- //
53
- // Camera(cameraProps);
54
- // calculation({
55
- // outerGroupRef: props.outerGroupRef,
56
- // innerGroupRef: props.innerGroupRef,
57
- // rigidBodyRef: ref,
58
- // colliderRef: props.colliderRef,
59
- // groundRay: props.groundRay,
60
- // });
61
- // }
62
- // playActions({
63
- // type: props.componentType,
64
- // actions,
65
- // animationRef,
66
- // currentAnimation: props.isActive ? undefined : props.currentAnimation,
67
- // isActive: props.isActive,
68
- // });
69
- // initCallback({
70
- // props,
71
- // actions,
72
- // componentType: props.componentType,
73
- // });
74
- // const clone = useMemo(() => SkeletonUtils.clone(scene), [scene]);
75
- // const { nodes } = useGraph(clone);
76
- // const objectNode = Object.values(nodes).find(
77
- // (node) => node.type === "Object3D"
78
- // );
79
- // useFrame(() => {
80
- // if (props.isActive || !props.position || !ref || !ref.current) return;
81
- // ref.current.setTranslation(
82
- // V3(
83
- // THREE.MathUtils.lerp(
84
- // ref.current.translation().x,
85
- // props.position.x,
86
- // props.controllerOptions.lerp.cameraPosition
87
- // ),
88
- // THREE.MathUtils.lerp(
89
- // ref.current.translation().y,
90
- // props.position.y,
91
- // props.controllerOptions.lerp.cameraPosition
92
- // ),
93
- // THREE.MathUtils.lerp(
94
- // ref.current.translation().z,
95
- // props.position.z,
96
- // props.controllerOptions.lerp.cameraPosition
97
- // )
98
- // ),
99
- // false
100
- // );
101
- // });
102
- // return (
103
- // <RigidBody
104
- // colliders={false}
105
- // ref={ref}
106
- // name={props.name}
107
- // rotation={euler()
108
- // .set(0, props.rotation?.clone().y || 0, 0)
109
- // .clone()}
110
- // userData={props.userData}
111
- // type={props.rigidbodyType || (props.isActive ? "dynamic" : "fixed")}
112
- // sensor={props.sensor}
113
- // onIntersectionEnter={props.onIntersectionEnter}
114
- // onCollisionEnter={props.onCollisionEnter}
115
- // {...props.rigidBodyProps}
116
- // >
117
- // {!props.isNotColliding && (
118
- // <CapsuleCollider
119
- // ref={props.colliderRef as any}
120
- // args={[(size.y / 2 - size.x) * 1.2, size.x * 1.2]}
121
- // position={[0, (size.y / 2 + size.x / 2) * 1.2, 0]}
122
- // />
123
- // )}
124
- // <InnerGroupRef
125
- // objectNode={objectNode}
126
- // animationRef={animationRef}
127
- // nodes={nodes}
128
- // ref={props.innerGroupRef}
129
- // isActive={props.isActive}
130
- // isRiderOn={props.isRiderOn}
131
- // enableRiding={props.enableRiding}
132
- // ridingUrl={props.ridingUrl}
133
- // offset={props.offset}
134
- // parts={props.parts}
135
- // >
136
- // {props.children}
137
- // {props.parts &&
138
- // props.parts.length > 0 &&
139
- // props.parts.map(({ url, color }, key) => {
140
- // if (!url) return null;
141
- // return (
142
- // <PartsGroupRef
143
- // url={url}
144
- // isActive={props.isActive}
145
- // componentType={props.componentType}
146
- // currentAnimation={props.currentAnimation}
147
- // color={color}
148
- // key={key + url}
149
- // />
150
- // );
151
- // })}
152
- // </InnerGroupRef>
153
- // </RigidBody>
154
- // );
155
- // }
156
- // );
157
1
  import { useAnimations, useGLTF } from "@react-three/drei";
158
2
  import { useFrame, useGraph } from "@react-three/fiber";
159
3
  import {
@@ -176,12 +20,13 @@ import { V3 } from "../../../utils";
176
20
  import { GaesupWorldContext } from "../../../world/context";
177
21
  import { InnerGroupRef } from "./InnerGroupRef";
178
22
  import { PartsGroupRef } from "./partsGroupRef";
179
- import { setGroundRay } from "./setGroundRay";
23
+ import { useSetGroundRay } from "./setGroundRay";
180
24
  import { rigidBodyRefType } from "./type";
181
25
 
182
26
  export const RigidBodyRef = forwardRef(
183
27
  (props: rigidBodyRefType, ref: MutableRefObject<RapierRigidBody>) => {
184
28
  const { size } = useGltfAndSize({ url: props.url });
29
+ const setGroundRay = useSetGroundRay();
185
30
 
186
31
  props.groundRay &&
187
32
  setGroundRay({
@@ -1,19 +1,25 @@
1
+ // useSetGroundRay.ts
1
2
  import { useRapier } from "@react-three/rapier";
2
3
  import { groundRayType } from "../../../controller/type";
3
4
  import { getRayHit } from "../../../utils";
4
5
  import { setGroundRayType } from "./type";
5
6
 
6
- export function setGroundRay({
7
- groundRay,
8
- length,
9
- colliderRef,
10
- }: setGroundRayType) {
7
+ export function useSetGroundRay() {
11
8
  const { rapier } = useRapier();
12
- groundRay.length = length;
13
- groundRay.rayCast = new rapier.Ray(groundRay.origin, groundRay.dir);
14
- groundRay.hit = getRayHit<groundRayType>({
15
- ray: groundRay,
16
- ref: colliderRef,
17
- });
18
- groundRay.parent = groundRay.hit?.collider.parent();
9
+
10
+ const setGroundRay = ({
11
+ groundRay,
12
+ length,
13
+ colliderRef,
14
+ }: setGroundRayType) => {
15
+ groundRay.length = length;
16
+ groundRay.rayCast = new rapier.Ray(groundRay.origin, groundRay.dir);
17
+ groundRay.hit = getRayHit<groundRayType>({
18
+ ray: groundRay,
19
+ ref: colliderRef,
20
+ });
21
+ groundRay.parent = groundRay.hit?.collider.parent();
22
+ };
23
+
24
+ return setGroundRay;
19
25
  }
@@ -2,7 +2,7 @@
2
2
  import { useContext } from "react";
3
3
  import { GaesupWorldContext } from "../../world/context";
4
4
  import GamePadButton from "./GamePadButton";
5
- import * as S from "./style.css.ts";
5
+ import * as S from "./style.css";
6
6
  import { gameBoyDirectionType, gamepadType } from "./type";
7
7
 
8
8
  export const gamepadDefault = {
@@ -1,6 +1,6 @@
1
1
  // JumpPortal.tsx
2
2
  import { useTeleport } from "../../hooks/useTeleport";
3
- import * as S from "./style.css.ts";
3
+ import * as S from "./style.css";
4
4
  import { JumpPortalType } from "./type.ts";
5
5
 
6
6
  export function JumpPortal({
@@ -2,7 +2,7 @@
2
2
  import { useCallback, useContext, useState } from "react";
3
3
 
4
4
  import { GaesupWorldContext } from "../../world/context";
5
- import * as S from "./style.css.ts";
5
+ import * as S from "./style.css";
6
6
 
7
7
  // X 축은 동(+) 서(-) 방향, 즉 경도를 나타낸다.
8
8
  // Z 축은 남(+) 북(-) 방향, 즉 위도를 나타낸다.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gaesup-world",
3
- "version": "0.9.55",
3
+ "version": "0.9.57",
4
4
  "type": "module",
5
5
  "main": "dist/index.ts",
6
6
  "types": "dist/index.d.ts",
@@ -1,19 +0,0 @@
1
- // style.css.ts
2
- import { style } from "@vanilla-extract/css";
3
-
4
- export const ridable = style({
5
- display: "flex",
6
- justifyContent: "center",
7
- alignItems: "center",
8
- textAlign: "center",
9
- margin: "1rem",
10
- fontSize: "0.8rem",
11
- borderRadius: "50%",
12
- width: "5rem",
13
- height: "5rem",
14
- color: "white",
15
- background: "rgba(0, 0, 0, 0.6)",
16
- boxShadow: "0 0 5px 0 rgba(0, 0, 0, 0.6)",
17
- transition: "all 0.2s ease-in",
18
- cursor: "pointer",
19
- });