gaesup-world 0.6.78 → 0.6.81

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 (36) hide show
  1. package/dist/gaesup/component/active/airplane/index.js +1 -1
  2. package/dist/gaesup/component/active/vehicle/index.js +1 -1
  3. package/dist/gaesup/component/index.js +2 -2
  4. package/dist/gaesup/component/inner/airplane/index.js +1 -5
  5. package/dist/gaesup/component/inner/common/InnerGroupRef.d.ts +11 -2
  6. package/dist/gaesup/component/inner/common/InnerGroupRef.js +7 -4
  7. package/dist/gaesup/component/inner/common/RigidbodyRef.d.ts +2 -0
  8. package/dist/gaesup/component/inner/common/RigidbodyRef.js +18 -18
  9. package/dist/gaesup/component/inner/common/type.d.ts +5 -1
  10. package/dist/gaesup/component/inner/rider/index.d.ts +1 -1
  11. package/dist/gaesup/component/inner/rider/index.js +1 -1
  12. package/dist/gaesup/component/inner/vehicle/index.js +1 -1
  13. package/dist/gaesup/component/passive/airplane/index.js +1 -1
  14. package/dist/gaesup/component/passive/character/index.js +1 -1
  15. package/dist/gaesup/component/passive/type.d.ts +1 -0
  16. package/dist/gaesup/component/passive/vehicle/index.js +1 -1
  17. package/dist/gaesup/hooks/useGaesupGltf/index.d.ts +1 -0
  18. package/dist/gaesup/hooks/useRideable/index.d.ts +4 -20
  19. package/dist/gaesup/hooks/useRideable/index.js +1 -0
  20. package/dist/gaesup/hooks/useRideable/type.d.ts +19 -0
  21. package/dist/gaesup/hooks/useRideable/type.js +1 -0
  22. package/dist/gaesup/physics/airplane/landing.js +26 -1
  23. package/dist/gaesup/physics/check/riding.js +1 -1
  24. package/dist/gaesup/physics/vehicle/landing.js +26 -1
  25. package/dist/gaesup/tools/jumpPortal/index.d.ts +0 -8
  26. package/dist/gaesup/tools/jumpPortal/index.js +0 -8
  27. package/dist/gaesup/tools/miniMap/index.js +3 -3
  28. package/dist/gaesup/tools/miniMap/type.d.ts +5 -1
  29. package/dist/gaesup/tools/rideable/index.js +1 -3
  30. package/dist/gaesup/tools/rideable/type.d.ts +2 -0
  31. package/dist/gaesup/world/context/index.js +1 -0
  32. package/dist/gaesup/world/context/reducer.d.ts +1 -1
  33. package/dist/gaesup/world/context/type.d.ts +2 -1
  34. package/dist/gaesup/world/initalize/index.d.ts +1 -1
  35. package/dist/gaesup/world/initalize/index.js +1 -20
  36. package/package.json +1 -1
@@ -12,5 +12,5 @@ var __assign = (this && this.__assign) || function () {
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { AirplaneInnerRef } from "../../inner/airplane";
14
14
  export function AirplaneRef(props) {
15
- return (_jsx(AirplaneInnerRef, __assign({ name: "airplane", isActive: true, currentAnimation: "idle", componentType: "airplane" }, props, { children: props.children })));
15
+ return (_jsx(AirplaneInnerRef, __assign({ name: "airplane", isActive: true, currentAnimation: "idle", componentType: "airplane", ridingUrl: props.ridingUrl }, props, { children: props.children })));
16
16
  }
@@ -12,5 +12,5 @@ var __assign = (this && this.__assign) || function () {
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { VehicleInnerRef } from "../../inner/vehicle";
14
14
  export function VehicleRef(props) {
15
- return (_jsx(VehicleInnerRef, __assign({ name: "vehicle", isActive: true, currentAnimation: "idle", componentType: "vehicle" }, props, { children: props.children })));
15
+ return (_jsx(VehicleInnerRef, __assign({ name: "vehicle", isActive: true, currentAnimation: "idle", componentType: "vehicle", ridingUrl: props.ridingUrl }, props, { children: props.children })));
16
16
  }
@@ -20,9 +20,9 @@ export function GaesupComponent(_a) {
20
20
  var props = _a.props, refs = _a.refs, urls = _a.urls;
21
21
  var _b = useContext(GaesupWorldContext), mode = _b.mode, states = _b.states, rideable = _b.rideable;
22
22
  var enableRiding = states.enableRiding, isRiderOn = states.isRiderOn, rideableId = states.rideableId;
23
- return (_jsxs(_Fragment, { children: [mode.type === "character" && (_jsx(CharacterRef, { props: props, refs: refs, urls: urls })), mode.type === "vehicle" && (_jsx(VehicleRef, __assign({ controllerOptions: props.controllerOptions, url: urls.vehicleUrl, wheelUrl: urls.wheelUrl, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
23
+ return (_jsxs(_Fragment, { children: [mode.type === "character" && (_jsx(CharacterRef, { props: props, refs: refs, urls: urls })), mode.type === "vehicle" && (_jsx(VehicleRef, __assign({ controllerOptions: props.controllerOptions, url: urls.vehicleUrl, wheelUrl: urls.wheelUrl, ridingUrl: urls.ridingUrl, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
24
24
  ? rideable[rideableId].offset
25
- : vec3() }, refs, { children: props.children }))), mode.type === "airplane" && (_jsx(AirplaneRef, __assign({ controllerOptions: props.controllerOptions, url: urls.airplaneUrl, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
25
+ : vec3() }, refs, { children: props.children }))), mode.type === "airplane" && (_jsx(AirplaneRef, __assign({ controllerOptions: props.controllerOptions, url: urls.airplaneUrl, ridingUrl: urls.ridingUrl, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
26
26
  ? rideable[rideableId].offset
27
27
  : vec3() }, refs, { children: props.children })))] }));
28
28
  }
@@ -10,13 +10,9 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
- import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
14
13
  import { OuterGroupRef } from "../common/OuterGroupRef";
15
14
  import { RigidBodyRef } from "../common/RigidbodyRef";
16
15
  export function AirplaneInnerRef(props) {
17
16
  var rigidBodyRef = props.rigidBodyRef, outerGroupRef = props.outerGroupRef;
18
- var size = useGltfAndSize({
19
- url: props.url,
20
- }).size;
21
- return (_jsx(OuterGroupRef, { ref: outerGroupRef, children: _jsx(RigidBodyRef, __assign({ ref: rigidBodyRef, name: props.name, componentType: "airplane" }, props, { children: props.children })) }));
17
+ return (_jsx(OuterGroupRef, { ref: outerGroupRef, children: _jsx(RigidBodyRef, __assign({ ref: rigidBodyRef, name: props.name, componentType: "airplane", ridingUrl: props.ridingUrl }, props, { children: props.children })) }));
22
18
  }
@@ -1,4 +1,13 @@
1
1
  /// <reference types="react" />
2
2
  import * as THREE from "three";
3
- import { InnerGroupRefType } from "./type";
4
- export declare const InnerGroupRef: import("react").ForwardRefExoticComponent<InnerGroupRefType & import("react").RefAttributes<THREE.Group<THREE.Object3DEventMap>>>;
3
+ export declare const InnerGroupRef: import("react").ForwardRefExoticComponent<{
4
+ children?: import("react").ReactNode;
5
+ objectNode: THREE.Object3D<THREE.Object3DEventMap>;
6
+ animationRef: import("react").MutableRefObject<THREE.Object3D<THREE.Object3DEventMap>>;
7
+ nodes: {
8
+ [name: string]: THREE.Object3D<THREE.Object3DEventMap>;
9
+ };
10
+ isActive?: boolean;
11
+ ridingUrl?: string;
12
+ offset?: THREE.Vector3;
13
+ } & import("./type").ridingType & import("react").RefAttributes<THREE.Group<THREE.Object3DEventMap>>>;
@@ -1,10 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  import * as THREE from "three";
4
- export var InnerGroupRef = forwardRef(function (_a, ref) {
5
- var children = _a.children, objectNode = _a.objectNode, animationRef = _a.animationRef, nodes = _a.nodes;
6
- return (_jsxs("group", { receiveShadow: true, castShadow: true, ref: ref, 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) {
7
- var node = nodes[name];
4
+ import RiderRef from "../rider";
5
+ export var InnerGroupRef = forwardRef(function (props, ref) {
6
+ return (_jsxs("group", { receiveShadow: true, castShadow: true, ref: ref, userData: { intangible: true }, children: [props.isRiderOn &&
7
+ props.enableRiding &&
8
+ props.isActive &&
9
+ props.ridingUrl && (_jsx(RiderRef, { url: props.ridingUrl, offset: props.offset })), props.children, props.objectNode && props.animationRef && (_jsx("primitive", { object: props.objectNode, visible: false, receiveShadow: true, castShadow: true, ref: props.animationRef })), Object.keys(props.nodes).map(function (name, key) {
10
+ var node = props.nodes[name];
8
11
  if (node instanceof THREE.SkinnedMesh) {
9
12
  return (_jsx("skinnedMesh", { castShadow: true, receiveShadow: true, material: node.material, geometry: node.geometry, skeleton: node.skeleton }, key));
10
13
  }
@@ -8,9 +8,11 @@ export declare const RigidBodyRef: import("react").ForwardRefExoticComponent<{
8
8
  };
9
9
  onCollisionEnter?: (e: import("@react-three/rapier").CollisionEnterPayload) => Promise<void>;
10
10
  isActive?: boolean;
11
+ ridingUrl?: string;
11
12
  } & {
12
13
  children?: import("react").ReactNode;
13
14
  url: string;
15
+ ridingUrl?: string;
14
16
  wheelUrl?: string;
15
17
  position?: THREE.Vector3;
16
18
  rotation?: THREE.Euler;
@@ -14,9 +14,9 @@ import { V3 } from "../../../utils";
14
14
  import { GaesupWorldContext } from "../../../world/context";
15
15
  import { calcCharacterColliderProps } from "../../inner/common/calc";
16
16
  import { InnerGroupRef } from "./InnerGroupRef";
17
- export var RigidBodyRef = forwardRef(function (_a, ref) {
18
- var children = _a.children, controllerOptions = _a.controllerOptions, name = _a.name, position = _a.position, rotation = _a.rotation, userData = _a.userData, onCollisionEnter = _a.onCollisionEnter, rigidbodyType = _a.rigidbodyType, outerGroupRef = _a.outerGroupRef, innerGroupRef = _a.innerGroupRef, colliderRef = _a.colliderRef, url = _a.url, isActive = _a.isActive, currentAnimation = _a.currentAnimation, componentType = _a.componentType;
19
- var size = useGltfAndSize({ url: url }).size;
17
+ export var RigidBodyRef = forwardRef(function (props, ref) {
18
+ var _a;
19
+ var size = useGltfAndSize({ url: props.url }).size;
20
20
  var collider = calcCharacterColliderProps(size);
21
21
  var groundRay = useMemo(function () {
22
22
  return {
@@ -42,13 +42,13 @@ export var RigidBodyRef = forwardRef(function (_a, ref) {
42
42
  groundRay.hit = world.castRay(groundRay.rayCast, groundRay.length, true, undefined, undefined);
43
43
  groundRay.parent = (_a = groundRay.hit) === null || _a === void 0 ? void 0 : _a.collider.parent();
44
44
  });
45
- var _c = useGLTF(url), scene = _c.scene, animations = _c.animations;
45
+ var _c = useGLTF(props.url), scene = _c.scene, animations = _c.animations;
46
46
  var _d = useAnimations(animations), actions = _d.actions, animationRef = _d.ref;
47
47
  var worldContext = useContext(GaesupWorldContext);
48
48
  var controllerContext = useContext(GaesupControllerContext);
49
- if (isActive) {
49
+ if (props.isActive) {
50
50
  subscribeActions({
51
- type: componentType,
51
+ type: props.componentType,
52
52
  groundRay: groundRay,
53
53
  animations: animations,
54
54
  });
@@ -56,36 +56,36 @@ export var RigidBodyRef = forwardRef(function (_a, ref) {
56
56
  state: null,
57
57
  worldContext: worldContext,
58
58
  controllerContext: controllerContext,
59
- controllerOptions: controllerOptions,
59
+ controllerOptions: props.controllerOptions,
60
60
  };
61
61
  useFrame(function (state) {
62
62
  cameraProps_1.state = state;
63
63
  });
64
64
  Camera(cameraProps_1);
65
65
  calculation({
66
- outerGroupRef: outerGroupRef,
67
- innerGroupRef: innerGroupRef,
66
+ outerGroupRef: props.outerGroupRef,
67
+ innerGroupRef: props.innerGroupRef,
68
68
  rigidBodyRef: ref,
69
- colliderRef: colliderRef,
69
+ colliderRef: props.colliderRef,
70
70
  groundRay: groundRay,
71
71
  });
72
72
  }
73
73
  playActions({
74
- type: componentType,
74
+ type: props.componentType,
75
75
  actions: actions,
76
76
  animationRef: animationRef,
77
- currentAnimation: isActive ? undefined : currentAnimation,
78
- isActive: isActive,
77
+ currentAnimation: props.isActive ? undefined : props.currentAnimation,
78
+ isActive: props.isActive,
79
79
  });
80
80
  var clone = useMemo(function () { return SkeletonUtils.clone(scene); }, [scene]);
81
81
  var nodes = useGraph(clone).nodes;
82
82
  var objectNode = Object.values(nodes).find(function (node) { return node.type === "Object3D"; });
83
83
  useFrame(function () {
84
- if (isActive || !position || !ref || !ref.current)
84
+ if (props.isActive || !props.position || !ref || !ref.current)
85
85
  return;
86
- ref.current.setTranslation(V3(THREE.MathUtils.lerp(ref.current.translation().x, position.x, controllerOptions.lerp.cameraPosition), THREE.MathUtils.lerp(ref.current.translation().y, position.y, controllerOptions.lerp.cameraPosition), THREE.MathUtils.lerp(ref.current.translation().z, position.z, controllerOptions.lerp.cameraPosition)), false);
86
+ ref.current.setTranslation(V3(THREE.MathUtils.lerp(ref.current.translation().x, props.position.x, props.controllerOptions.lerp.cameraPosition), THREE.MathUtils.lerp(ref.current.translation().y, props.position.y, props.controllerOptions.lerp.cameraPosition), THREE.MathUtils.lerp(ref.current.translation().z, props.position.z, props.controllerOptions.lerp.cameraPosition)), false);
87
87
  });
88
- return (_jsxs(RigidBody, { colliders: false, ref: ref, name: name, rotation: euler()
89
- .set(0, (rotation === null || rotation === void 0 ? void 0 : rotation.clone().y) || 0, 0)
90
- .clone(), userData: userData, onCollisionEnter: onCollisionEnter, type: rigidbodyType || (isActive ? "dynamic" : "fixed"), children: [_jsx(CapsuleCollider, { ref: colliderRef, args: [(size.y / 2 - size.x) * 1.2, size.x * 1.2], position: [0, (size.y / 2 + size.x / 2) * 1.2, 0] }), children, _jsx(InnerGroupRef, { objectNode: objectNode, animationRef: animationRef, nodes: nodes, ref: innerGroupRef, children: children })] }));
88
+ return (_jsxs(RigidBody, { colliders: false, ref: ref, name: props.name, rotation: euler()
89
+ .set(0, ((_a = props.rotation) === null || _a === void 0 ? void 0 : _a.clone().y) || 0, 0)
90
+ .clone(), userData: props.userData, onCollisionEnter: props.onCollisionEnter, type: props.rigidbodyType || (props.isActive ? "dynamic" : "fixed"), children: [_jsx(CapsuleCollider, { ref: props.colliderRef, args: [(size.y / 2 - size.x) * 1.2, size.x * 1.2], position: [0, (size.y / 2 + size.x / 2) * 1.2, 0] }), props.children, _jsx(InnerGroupRef, { objectNode: objectNode, animationRef: animationRef, nodes: nodes, ref: props.innerGroupRef, isActive: props.isActive, isRiderOn: props.isRiderOn, enableRiding: props.enableRiding, ridingUrl: props.ridingUrl, offset: props.offset, children: props.children })] }));
91
91
  });
@@ -18,7 +18,10 @@ export type InnerGroupRefType = {
18
18
  nodes: {
19
19
  [name: string]: THREE.Object3D<THREE.Object3DEventMap>;
20
20
  };
21
- };
21
+ isActive?: boolean;
22
+ ridingUrl?: string;
23
+ offset?: THREE.Vector3;
24
+ } & ridingType;
22
25
  export type ridingType = {
23
26
  isRiderOn?: boolean;
24
27
  enableRiding?: boolean;
@@ -51,4 +54,5 @@ export type rigidBodyRefType = {
51
54
  };
52
55
  onCollisionEnter?: (e: CollisionEnterPayload) => Promise<void>;
53
56
  isActive?: boolean;
57
+ ridingUrl?: string;
54
58
  } & passivePropsType & innerRefType;
@@ -7,4 +7,4 @@ export type riderRefType = {
7
7
  euler?: THREE.Euler;
8
8
  currentAnimation?: string;
9
9
  };
10
- export default function RiderRef({ url, children, offset, euler, currentAnimation, }: riderRefType): import("react/jsx-runtime").JSX.Element;
10
+ export default function RiderRef({ url, children, offset, currentAnimation, }: riderRefType): import("react/jsx-runtime").JSX.Element;
@@ -7,7 +7,7 @@ import { SkeletonUtils } from "three-stdlib";
7
7
  import playActions from "../../../animation/actions";
8
8
  import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
9
9
  export default function RiderRef(_a) {
10
- var url = _a.url, children = _a.children, offset = _a.offset, euler = _a.euler, currentAnimation = _a.currentAnimation;
10
+ var url = _a.url, children = _a.children, offset = _a.offset, currentAnimation = _a.currentAnimation;
11
11
  var gltf = useGltfAndSize({ url: url }).gltf;
12
12
  var animations = gltf.animations, scene = gltf.scene;
13
13
  var _b = useAnimations(animations), actions = _b.actions, animationRef = _b.ref;
@@ -18,5 +18,5 @@ export function VehicleInnerRef(props) {
18
18
  var size = useGltfAndSize({
19
19
  url: props.url,
20
20
  }).size;
21
- return (_jsx(OuterGroupRef, { ref: outerGroupRef, children: _jsx(RigidBodyRef, __assign({ ref: rigidBodyRef, name: props.name, componentType: "vehicle" }, props, { children: props.children })) }));
21
+ return (_jsx(OuterGroupRef, { ref: outerGroupRef, children: _jsx(RigidBodyRef, __assign({ ref: rigidBodyRef, name: props.name, componentType: "vehicle", ridingUrl: props.ridingUrl }, props, { children: props.children })) }));
22
22
  }
@@ -44,5 +44,5 @@ export function PassiveAirplane(props) {
44
44
  cameraTurn: 1,
45
45
  cameraPosition: 1,
46
46
  },
47
- }, position: props.position.clone(), rotation: props.rotation.clone(), currentAnimation: props.currentAnimation }, props, refs, { children: props.children })));
47
+ }, position: props.position, rotation: props.rotation, currentAnimation: props.currentAnimation, ridingUrl: props.ridingUrl }, props, refs, { children: props.children })));
48
48
  }
@@ -33,5 +33,5 @@ export function PassiveCharacter(props) {
33
33
  cameraTurn: 1,
34
34
  cameraPosition: 1,
35
35
  },
36
- }, position: props.position.clone(), rotation: props.rotation.clone(), currentAnimation: props.currentAnimation }, refs, props, { children: props.children })));
36
+ }, position: props.position, rotation: props.rotation, currentAnimation: props.currentAnimation }, refs, props, { children: props.children })));
37
37
  }
@@ -14,6 +14,7 @@ export type innerRefType = {
14
14
  export type passivePropsType = {
15
15
  children?: React.ReactNode;
16
16
  url: string;
17
+ ridingUrl?: string;
17
18
  wheelUrl?: string;
18
19
  position?: THREE.Vector3;
19
20
  rotation?: THREE.Euler;
@@ -28,5 +28,5 @@ export function PassiveVehicle(props) {
28
28
  cameraTurn: 1,
29
29
  cameraPosition: 1,
30
30
  },
31
- }, position: props.position.clone(), rotation: props.rotation.clone(), currentAnimation: props.currentAnimation }, props, refs, { children: props.children })));
31
+ }, position: props.position, rotation: props.rotation, currentAnimation: props.currentAnimation, ridingUrl: props.ridingUrl }, props, refs, { children: props.children })));
32
32
  }
@@ -21,5 +21,6 @@ export declare const useGaesupGltf: () => {
21
21
  vehicleUrl?: THREE.Vector3;
22
22
  airplaneUrl?: THREE.Vector3;
23
23
  wheelUrl?: THREE.Vector3;
24
+ ridingUrl?: THREE.Vector3;
24
25
  };
25
26
  };
@@ -1,32 +1,16 @@
1
1
  import { CollisionEnterPayload } from "@react-three/rapier";
2
- import * as THREE from "three";
2
+ import { rideableType } from "./type";
3
3
  export declare const rideableDefault: {
4
4
  objectkey: any;
5
5
  objectType: any;
6
6
  isRiderOn: boolean;
7
7
  url: any;
8
8
  wheelUrl: any;
9
- position: THREE.Vector3;
10
- rotation: THREE.Euler;
11
- offset: THREE.Vector3;
9
+ position: import("three").Vector3;
10
+ rotation: import("three").Euler;
11
+ offset: import("three").Vector3;
12
12
  visible: boolean;
13
13
  };
14
- export type rideableType = {
15
- objectkey: string;
16
- objectType?: "vehicle" | "airplane";
17
- enableRiding?: boolean;
18
- isRiderOn?: boolean;
19
- url?: string;
20
- wheelUrl?: string;
21
- position?: THREE.Vector3;
22
- rotation?: THREE.Euler;
23
- offset?: THREE.Vector3;
24
- landingOffset?: THREE.Vector3;
25
- visible?: boolean;
26
- vehicleSize?: THREE.Vector3;
27
- wheelSize?: THREE.Vector3;
28
- airplaneSize?: THREE.Vector3;
29
- };
30
14
  export declare function useRideable(): {
31
15
  initRideable: (props: rideableType) => void;
32
16
  setRideable: (props: rideableType) => void;
@@ -102,6 +102,7 @@ export function useRideable() {
102
102
  };
103
103
  var setUrl = function (props) { return __awaiter(_this, void 0, void 0, function () {
104
104
  return __generator(this, function (_a) {
105
+ urls.ridingUrl = props.ridingUrl || urls.characterUrl || null;
105
106
  if (props.objectType === "vehicle") {
106
107
  urls.vehicleUrl = props.url;
107
108
  urls.wheelUrl = props.wheelUrl || null;
@@ -0,0 +1,19 @@
1
+ import * as THREE from "three";
2
+ export type rideableType = {
3
+ objectkey: string;
4
+ objectType?: "vehicle" | "airplane";
5
+ enableRiding?: boolean;
6
+ isRiderOn?: boolean;
7
+ url?: string;
8
+ characterUrl?: string;
9
+ ridingUrl?: string;
10
+ wheelUrl?: string;
11
+ position?: THREE.Vector3;
12
+ rotation?: THREE.Euler;
13
+ offset?: THREE.Vector3;
14
+ landingOffset?: THREE.Vector3;
15
+ visible?: boolean;
16
+ vehicleSize?: THREE.Vector3;
17
+ wheelSize?: THREE.Vector3;
18
+ airplaneSize?: THREE.Vector3;
19
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,29 @@
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
  export default function landing(prop) {
2
13
  var _a = prop.worldContext, states = _a.states, rideable = _a.rideable, mode = _a.mode, dispatch = prop.dispatch;
3
- var isLanding = states.isLanding;
14
+ var isRiding = states.isRiding;
15
+ if (isRiding) {
16
+ rideable.objectType = null;
17
+ rideable.key = null;
18
+ mode.type = "character";
19
+ states.isRiding = false;
20
+ states.enableRiding = false;
21
+ }
22
+ dispatch({
23
+ type: "update",
24
+ payload: {
25
+ mode: __assign({}, mode),
26
+ rideable: __assign({}, rideable),
27
+ },
28
+ });
4
29
  }
@@ -2,6 +2,6 @@ export default function riding(prop) {
2
2
  var states = prop.worldContext.states;
3
3
  var isRiderOn = states.isRiderOn;
4
4
  if (isRiderOn && states.isPush["keyR"]) {
5
- states.isLanding = true;
5
+ states.isRiding = true;
6
6
  }
7
7
  }
@@ -1,4 +1,29 @@
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
  export default function landing(prop) {
2
13
  var _a = prop.worldContext, states = _a.states, rideable = _a.rideable, mode = _a.mode, dispatch = prop.dispatch;
3
- var isLanding = states.isLanding;
14
+ var isRiding = states.isRiding;
15
+ if (isRiding) {
16
+ rideable.objectType = null;
17
+ rideable.key = null;
18
+ mode.type = "character";
19
+ states.isRiding = false;
20
+ states.enableRiding = false;
21
+ }
22
+ dispatch({
23
+ type: "update",
24
+ payload: {
25
+ mode: __assign({}, mode),
26
+ rideable: __assign({}, rideable),
27
+ },
28
+ });
4
29
  }
@@ -6,12 +6,4 @@ export type JumpPortalType = {
6
6
  position: THREE.Vector3;
7
7
  jumpPortalStyle?: CSSProperties;
8
8
  };
9
- /**
10
- * JumpPortal component represents a clickable portal that teleports the user to a specified location.
11
- *
12
- * @param {JumpPortalType} props - The props for the JumpPortal component.
13
- * @param {string} props.text - (Optional) The text to display on the portal.
14
- * @param {THREE.Vector3} props.position - The target position to teleport to.
15
- * @param {CSSProperties} props.jumpPortalStyle - (Optional) CSS styles for the JumpPortal component.
16
- */
17
9
  export declare function JumpPortal({ text, position, jumpPortalStyle, }: JumpPortalType): import("react/jsx-runtime").JSX.Element;
@@ -1,14 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useTeleport } from "../../hooks/useTeleport";
3
3
  import "./style.css";
4
- /**
5
- * JumpPortal component represents a clickable portal that teleports the user to a specified location.
6
- *
7
- * @param {JumpPortalType} props - The props for the JumpPortal component.
8
- * @param {string} props.text - (Optional) The text to display on the portal.
9
- * @param {THREE.Vector3} props.position - The target position to teleport to.
10
- * @param {CSSProperties} props.jumpPortalStyle - (Optional) CSS styles for the JumpPortal component.
11
- */
12
4
  export function JumpPortal(_a) {
13
5
  var text = _a.text, position = _a.position, jumpPortalStyle = _a.jumpPortalStyle;
14
6
  var Teleport = useTeleport().Teleport;
@@ -19,7 +19,7 @@ import "./style.css";
19
19
  export function MiniMap(props) {
20
20
  var _a = useContext(GaesupWorldContext), minimap = _a.minimap, activeState = _a.activeState, mode = _a.mode;
21
21
  var _b = useState(props.scale || minimapDefault.scale), scale = _b[0], setscale = _b[1];
22
- var innerStyle = props.innerStyle, textStyle = props.textStyle, objectStyle = props.objectStyle, avatarStyle = props.avatarStyle, scaleStyle = props.scaleStyle, directionStyle = props.directionStyle, plusMinusStyle = props.plusMinusStyle;
22
+ var innerStyle = props.innerStyle, textStyle = props.textStyle, objectStyle = props.objectStyle, avatarStyle = props.avatarStyle, scaleStyle = props.scaleStyle, directionStyle = props.directionStyle, plusMinusStyle = props.plusMinusStyle, imageStyle = props.imageStyle;
23
23
  var upscale = useCallback(function () {
24
24
  var max = props.maxScale || minimapDefault.maxScale;
25
25
  setscale(function (scale) { return Math.min(max, scale + 0.1); });
@@ -37,7 +37,7 @@ export function MiniMap(props) {
37
37
  downscale();
38
38
  }, children: [_jsx("div", { className: "minimapOuter", style: objectStyle }), _jsxs("div", { className: "minimapInner", style: __assign({ transform: props.blockRotate || mode.control === "normal"
39
39
  ? "translate(-50%, -50%) rotate(180deg) "
40
- : "translate(-50%, -50%) rotate(".concat((activeState.euler.y * 180) / Math.PI + 180, "deg) ") }, innerStyle), children: [_jsx("div", { className: "east direction", style: __assign({ transform: props.blockRotate || mode.control === "normal"
40
+ : "translate(-50%, -50%) rotate(".concat((activeState.euler.y * 180) / Math.PI + 180, "deg) ") }, innerStyle), children: [" ", _jsx("div", { className: "east direction", style: __assign({ transform: props.blockRotate || mode.control === "normal"
41
41
  ? "translate(-50%, -50%) rotate(180deg) "
42
42
  : "translate(-50%, -50%) rotate(-".concat((activeState.euler.y * 180) / Math.PI + 180, "deg) ") }, directionStyle), children: "E" }), _jsx("div", { className: "west direction", style: __assign({ transform: props.blockRotate || mode.control === "normal"
43
43
  ? "translate(50%, -50%) rotate(180deg) "
@@ -45,7 +45,7 @@ export function MiniMap(props) {
45
45
  ? "translate(-50%, 50%) rotate(180deg) "
46
46
  : "translate(-50%, 50%) rotate(-".concat((activeState.euler.y * 180) / Math.PI + 180, "deg) ") }, directionStyle), children: "S" }), _jsx("div", { className: "north direction", style: __assign({ transform: props.blockRotate || mode.control === "normal"
47
47
  ? "translate(-50%, -50%) rotate(180deg) "
48
- : "translate(-50%, -50%) rotate(-".concat((activeState.euler.y * 180) / Math.PI + 180, "deg) ") }, directionStyle), children: "N" }), Object.values(minimap.props).map(function (_a, key) {
48
+ : "translate(-50%, -50%) rotate(-".concat((activeState.euler.y * 180) / Math.PI + 180, "deg) ") }, directionStyle), children: "N" }), props.isImage && (_jsx("img", { src: props.imageUrl, className: "minimapObject", style: __assign({ width: "".concat(100 * scale, "rem"), height: "".concat(100 * scale, "rem"), top: "50%", left: "50%", transform: "translate(-50.1%, -50.1%) translate(".concat(activeState.position.x * scale, "rem, ").concat(activeState.position.z, "rem)"), transformOrigin: "50% 50%", zIndex: 100 }, imageStyle) })), Object.values(minimap.props).map(function (_a, key) {
49
49
  var center = _a.center, size = _a.size, text = _a.text;
50
50
  var X = (center.x - activeState.position.x) * scale;
51
51
  var Z = (center.z - activeState.position.z) * scale;
@@ -14,7 +14,7 @@ export type minimapInnerType = {
14
14
  };
15
15
  };
16
16
  export type minimapType = {
17
- [key in "minimapStyle" | "outerStyle" | "innerStyle" | "textStyle" | "objectStyle" | "avatarStyle" | "directionStyle" | "scaleStyle" | "plusMinusStyle"]?: CSSProperties;
17
+ [key in "minimapStyle" | "outerStyle" | "innerStyle" | "textStyle" | "objectStyle" | "avatarStyle" | "directionStyle" | "scaleStyle" | "imageStyle" | "plusMinusStyle"]?: CSSProperties;
18
18
  } & {
19
19
  minScale?: number;
20
20
  maxScale?: number;
@@ -22,4 +22,8 @@ export type minimapType = {
22
22
  scale?: number;
23
23
  blockRotate?: boolean;
24
24
  blockScaleControl?: boolean;
25
+ isImage?: boolean;
26
+ imageUrl?: string;
27
+ imageWidth?: number;
28
+ imageHeight?: number;
25
29
  };
@@ -53,8 +53,6 @@ export function Rideable(props) {
53
53
  position: props.position || V3(0, 0, 0),
54
54
  rotation: props.rotation || euler(),
55
55
  }), _rideable = _d[0], set_Rideable = _d[1];
56
- // console.log(current);
57
- // if (!current) return null;
58
56
  useEffect(function () {
59
57
  initRideable(props);
60
58
  }, []);
@@ -75,5 +73,5 @@ export function Rideable(props) {
75
73
  }
76
74
  });
77
75
  }); };
78
- return (_jsx(_Fragment, { children: ((_a = rideable === null || rideable === void 0 ? void 0 : rideable[props.objectkey]) === null || _a === void 0 ? void 0 : _a.visible) && (_jsxs("group", { userData: { intangible: true }, children: [props.objectType === "vehicle" && (_jsx(PassiveVehicle, { controllerOptions: props.controllerOptions, position: _rideable.position, rotation: _rideable.rotation, currentAnimation: "idle", url: props.url, wheelUrl: props.wheelUrl, offset: props.offset, enableRiding: props.enableRiding, onCollisionEnter: onCollisionEnter })), props.objectType === "airplane" && (_jsx(PassiveAirplane, { controllerOptions: props.controllerOptions, position: _rideable.position, rotation: _rideable.rotation, currentAnimation: "idle", url: props.url, offset: props.offset, enableRiding: props.enableRiding, onCollisionEnter: onCollisionEnter }))] })) }));
76
+ return (_jsx(_Fragment, { children: ((_a = rideable === null || rideable === void 0 ? void 0 : rideable[props.objectkey]) === null || _a === void 0 ? void 0 : _a.visible) && (_jsxs("group", { userData: { intangible: true }, children: [props.objectType === "vehicle" && (_jsx(PassiveVehicle, { controllerOptions: props.controllerOptions, position: props.position, rotation: props.rotation, currentAnimation: "idle", url: props.url, wheelUrl: props.wheelUrl, ridingUrl: props.ridingUrl, offset: props.offset, enableRiding: props.enableRiding, onCollisionEnter: onCollisionEnter })), props.objectType === "airplane" && (_jsx(PassiveAirplane, { controllerOptions: props.controllerOptions, position: _rideable.position, rotation: _rideable.rotation, ridingUrl: props.ridingUrl, currentAnimation: "idle", url: props.url, offset: props.offset, enableRiding: props.enableRiding, onCollisionEnter: onCollisionEnter }))] })) }));
79
77
  }
@@ -7,6 +7,8 @@ export type rideablePropType = {
7
7
  enableRiding?: boolean;
8
8
  isRiderOn?: boolean;
9
9
  url?: string;
10
+ characterUrl?: string;
11
+ ridingUrl?: string;
10
12
  wheelUrl?: string;
11
13
  position?: THREE.Vector3;
12
14
  rotation?: THREE.Euler;
@@ -19,6 +19,7 @@ export var gaesupWorldDefault = {
19
19
  vehicleUrl: null,
20
20
  airplaneUrl: null,
21
21
  wheelUrl: null,
22
+ ridingUrl: null,
22
23
  },
23
24
  states: {
24
25
  rideableId: null,
@@ -20,7 +20,7 @@ export declare function gaesupWorldReducer(props: Partial<gaesupWorldContextType
20
20
  clicker?: import("./type").clickerType;
21
21
  moveTo?: (position: import("three").Vector3, target: import("three").Vector3) => Promise<void>;
22
22
  rideable?: {
23
- [key: string]: import("../../hooks/useRideable").rideableType;
23
+ [key: string]: import("../../hooks/useRideable/type").rideableType;
24
24
  };
25
25
  sizes?: import("./type").sizesType;
26
26
  block?: import("./type").blockType;
@@ -1,7 +1,7 @@
1
1
  import { CSSProperties } from "react";
2
2
  import { actionsType, refsType } from "../../controller/type";
3
3
  import * as THREE from "three";
4
- import { rideableType } from "../../hooks/useRideable";
4
+ import { rideableType } from "../../hooks/useRideable/type";
5
5
  import { joyStickInnerType } from "../../tools/joystick/type";
6
6
  import { keyboardMapType } from "../../tools/keyBoardToolTip/type";
7
7
  import { minimapInnerType } from "../../tools/miniMap/type";
@@ -57,6 +57,7 @@ export type urlsType = {
57
57
  vehicleUrl?: string;
58
58
  airplaneUrl?: string;
59
59
  wheelUrl?: string;
60
+ ridingUrl?: string;
60
61
  };
61
62
  export type animationAtomType = {
62
63
  tag: string;
@@ -20,7 +20,7 @@ export default function initGaesupWorld(props: gaesupWorldPropsType): {
20
20
  clicker?: import("../context/type").clickerType;
21
21
  moveTo?: (position: import("three").Vector3, target: import("three").Vector3) => Promise<void>;
22
22
  rideable?: {
23
- [key: string]: import("../../hooks/useRideable").rideableType;
23
+ [key: string]: import("../../hooks/useRideable/type").rideableType;
24
24
  };
25
25
  sizes?: import("../context/type").sizesType;
26
26
  block?: import("../context/type").blockType;
@@ -55,26 +55,7 @@ export default function initGaesupWorld(props) {
55
55
  },
56
56
  });
57
57
  }, []);
58
- var gaesupProps = useMemo(function () { return ({ value: value, dispatch: dispatch }); }, [
59
- value,
60
- value.activeState,
61
- value.mode,
62
- value.urls,
63
- value.states,
64
- value.rideable,
65
- value.debug,
66
- value.minimap,
67
- value.joystick,
68
- value.control,
69
- value.clicker,
70
- value.animationState,
71
- value.keyBoardMap,
72
- value.moveTo,
73
- value.block,
74
- value.sizes,
75
- value.callback,
76
- dispatch,
77
- ]);
58
+ var gaesupProps = useMemo(function () { return ({ value: value, dispatch: dispatch }); }, [value, dispatch]);
78
59
  initDebug({ value: gaesupProps.value, dispatch: dispatch });
79
60
  return {
80
61
  gaesupProps: gaesupProps,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gaesup-world",
3
- "version": "0.6.78",
3
+ "version": "0.6.81",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",