gaesup-world 0.7.31 → 0.7.32
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.
- package/dist/gaesup/component/active/character/index.js +1 -1
- package/dist/gaesup/component/inner/character/type.d.ts +2 -1
- package/dist/gaesup/component/inner/common/RigidbodyRef.d.ts +1 -1
- package/dist/gaesup/component/inner/common/RigidbodyRef.js +6 -0
- package/dist/gaesup/component/inner/common/type.d.ts +2 -1
- package/dist/gaesup/controller/initialize/callback/index.d.ts +9 -5
- package/dist/gaesup/controller/initialize/callback/index.js +31 -42
- package/dist/gaesup/controller/initialize/callback/type.d.ts +1 -4
- package/dist/gaesup/tools/miniMap/index.js +1 -1
- package/package.json +1 -1
|
@@ -13,5 +13,5 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
13
13
|
import { CharacterInnerRef } from "../../inner/character";
|
|
14
14
|
export function CharacterRef(_a) {
|
|
15
15
|
var props = _a.props, refs = _a.refs, urls = _a.urls;
|
|
16
|
-
return (_jsx(CharacterInnerRef, __assign({ url: urls.characterUrl, isActive: true, componentType: "character", rigidbodyType: "dynamic", controllerOptions: props.controllerOptions }, refs, { children: props.children })));
|
|
16
|
+
return (_jsx(CharacterInnerRef, __assign({ url: urls.characterUrl, isActive: true, componentType: "character", rigidbodyType: "dynamic", controllerOptions: props.controllerOptions, onAnimate: props.onAnimate, onFrame: props.onFrame, onReady: props.onReady, onDestory: props.onDestory }, refs, { children: props.children })));
|
|
17
17
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { callbackType } from "../../../controller/initialize/callback/type";
|
|
1
2
|
import { passiveCharacterPropsType } from "../../passive/character/type";
|
|
2
3
|
import { componentTypeString, innerRefType } from "../../passive/type";
|
|
3
4
|
export type characterInnerType = {
|
|
4
5
|
componentType: componentTypeString;
|
|
5
6
|
isActive?: boolean;
|
|
6
|
-
} & passiveCharacterPropsType & innerRefType;
|
|
7
|
+
} & passiveCharacterPropsType & innerRefType & callbackType;
|
|
@@ -25,4 +25,4 @@ export declare const RigidBodyRef: import("react").ForwardRefExoticComponent<{
|
|
|
25
25
|
userData?: {
|
|
26
26
|
intangible: boolean;
|
|
27
27
|
};
|
|
28
|
-
} & import("./type").ridingType & import("../../passive/type").innerRefType & import("react").RefAttributes<RapierRigidBody>>;
|
|
28
|
+
} & import("./type").ridingType & import("../../passive/type").innerRefType & import("../../../controller/initialize/callback/type").callbackType & import("react").RefAttributes<RapierRigidBody>>;
|
|
@@ -8,6 +8,7 @@ import { SkeletonUtils } from "three-stdlib";
|
|
|
8
8
|
import playActions, { subscribeActions } from "../../../animation/actions";
|
|
9
9
|
import Camera from "../../../camera";
|
|
10
10
|
import { GaesupControllerContext } from "../../../controller/context";
|
|
11
|
+
import initCallback from "../../../controller/initialize/callback";
|
|
11
12
|
import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
|
|
12
13
|
import calculation from "../../../physics";
|
|
13
14
|
import { V3 } from "../../../utils";
|
|
@@ -77,6 +78,11 @@ export var RigidBodyRef = forwardRef(function (props, ref) {
|
|
|
77
78
|
currentAnimation: props.isActive ? undefined : props.currentAnimation,
|
|
78
79
|
isActive: props.isActive,
|
|
79
80
|
});
|
|
81
|
+
initCallback({
|
|
82
|
+
props: props,
|
|
83
|
+
actions: actions,
|
|
84
|
+
componentType: props.componentType,
|
|
85
|
+
});
|
|
80
86
|
var clone = useMemo(function () { return SkeletonUtils.clone(scene); }, [scene]);
|
|
81
87
|
var nodes = useGraph(clone).nodes;
|
|
82
88
|
var objectNode = Object.values(nodes).find(function (node) { return node.type === "Object3D"; });
|
|
@@ -2,6 +2,7 @@ import { Collider } from "@dimforge/rapier3d-compat";
|
|
|
2
2
|
import { CollisionEnterPayload, RigidBodyTypeString } from "@react-three/rapier";
|
|
3
3
|
import { MutableRefObject, RefObject } from "react";
|
|
4
4
|
import * as THREE from "three";
|
|
5
|
+
import { callbackType } from "../../../controller/initialize/callback/type";
|
|
5
6
|
import { groundRayType } from "../../../controller/type";
|
|
6
7
|
import { urlsType } from "../../../world/context/type";
|
|
7
8
|
import { innerRefType, passivePropsType } from "../../passive/type";
|
|
@@ -55,4 +56,4 @@ export type rigidBodyRefType = {
|
|
|
55
56
|
onCollisionEnter?: (e: CollisionEnterPayload) => Promise<void>;
|
|
56
57
|
isActive?: boolean;
|
|
57
58
|
ridingUrl?: string;
|
|
58
|
-
} & passivePropsType & innerRefType;
|
|
59
|
+
} & passivePropsType & innerRefType & callbackType;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { AnimationAction } from "three";
|
|
2
|
+
import { rigidBodyRefType } from "../../../component/inner/common/type";
|
|
3
|
+
import { componentTypeString } from "../../../component/passive/type";
|
|
3
4
|
import { animationTagType } from "../../type";
|
|
4
|
-
export default function initCallback({
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export default function initCallback({ props, actions, componentType, }: {
|
|
6
|
+
props: rigidBodyRefType;
|
|
7
|
+
actions: {
|
|
8
|
+
[x: string]: AnimationAction;
|
|
9
|
+
};
|
|
10
|
+
componentType: componentTypeString;
|
|
7
11
|
}): {
|
|
8
12
|
subscribe: ({ tag, condition, action, animationName, key, }: import("../../../world/context/type").animationAtomType) => void;
|
|
9
13
|
playAnimation: (tag: keyof animationTagType, key: string) => void;
|
|
@@ -9,24 +9,22 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import {
|
|
12
|
+
import { useFrame } from "@react-three/fiber";
|
|
13
|
+
import { useContext, useEffect } from "react";
|
|
13
14
|
import { useGaesupAnimation } from "../../../hooks/useGaesupAnimation";
|
|
14
15
|
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../../world/context";
|
|
15
16
|
export default function initCallback(_a) {
|
|
16
|
-
var
|
|
17
|
-
// props,
|
|
18
|
-
animationResult = _a.animationResult, type = _a.type;
|
|
19
|
-
var actions = animationResult.actions;
|
|
17
|
+
var props = _a.props, actions = _a.actions, componentType = _a.componentType;
|
|
20
18
|
var animationState = useContext(GaesupWorldContext).animationState;
|
|
21
19
|
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
22
|
-
var store = useGaesupAnimation({ type:
|
|
20
|
+
var store = useGaesupAnimation({ type: componentType }).store;
|
|
23
21
|
var _b = useContext(GaesupWorldContext), activeState = _b.activeState, states = _b.states, control = _b.control;
|
|
24
|
-
var subscribe = useGaesupAnimation({ type:
|
|
22
|
+
var subscribe = useGaesupAnimation({ type: componentType }).subscribe;
|
|
25
23
|
var playAnimation = function (tag, key) {
|
|
26
24
|
if (!(key in control))
|
|
27
25
|
return;
|
|
28
|
-
if (control[key]) {
|
|
29
|
-
animationState[
|
|
26
|
+
if (control[key] && animationState[componentType]) {
|
|
27
|
+
animationState[componentType].current = tag;
|
|
30
28
|
var currentAnimation = store[tag];
|
|
31
29
|
if (currentAnimation === null || currentAnimation === void 0 ? void 0 : currentAnimation.action) {
|
|
32
30
|
currentAnimation.action();
|
|
@@ -39,39 +37,30 @@ export default function initCallback(_a) {
|
|
|
39
37
|
});
|
|
40
38
|
}
|
|
41
39
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// props.onAnimate({
|
|
67
|
-
// ...controllerProp,
|
|
68
|
-
// ...prop,
|
|
69
|
-
// actions,
|
|
70
|
-
// animationState,
|
|
71
|
-
// playAnimation,
|
|
72
|
-
// });
|
|
73
|
-
// }
|
|
74
|
-
// });
|
|
40
|
+
var controllerProp = {
|
|
41
|
+
activeState: activeState,
|
|
42
|
+
control: control,
|
|
43
|
+
states: states,
|
|
44
|
+
subscribe: subscribe,
|
|
45
|
+
};
|
|
46
|
+
useEffect(function () {
|
|
47
|
+
if (props.onReady) {
|
|
48
|
+
props.onReady(controllerProp);
|
|
49
|
+
}
|
|
50
|
+
return function () {
|
|
51
|
+
if (props.onDestory) {
|
|
52
|
+
props.onDestory(controllerProp);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}, []);
|
|
56
|
+
useFrame(function (prop) {
|
|
57
|
+
if (props.onFrame) {
|
|
58
|
+
props.onFrame(__assign(__assign({}, controllerProp), prop));
|
|
59
|
+
}
|
|
60
|
+
if (props.onAnimate) {
|
|
61
|
+
props.onAnimate(__assign(__assign(__assign({}, controllerProp), prop), { actions: actions, animationState: animationState, playAnimation: playAnimation }));
|
|
62
|
+
}
|
|
63
|
+
});
|
|
75
64
|
return {
|
|
76
65
|
subscribe: subscribe,
|
|
77
66
|
playAnimation: playAnimation,
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { RootState } from "@react-three/fiber";
|
|
2
2
|
import * as THREE from "three";
|
|
3
|
-
import { cameraRayType } from "../../../camera/type";
|
|
4
3
|
import { activeStateType, animationAtomType, animationStateType, keyControlType, statesType } from "../../../world/context/type";
|
|
5
|
-
import { actionsType
|
|
4
|
+
import { actionsType } from "../../type";
|
|
6
5
|
export type callbackPropType = {
|
|
7
6
|
activeState: activeStateType;
|
|
8
7
|
states: statesType;
|
|
9
|
-
groundRay: groundRayType;
|
|
10
|
-
cameraRay: cameraRayType;
|
|
11
8
|
control: keyControlType;
|
|
12
9
|
subscribe: (props: animationAtomType) => void;
|
|
13
10
|
};
|
|
@@ -51,7 +51,7 @@ export function MiniMap(props) {
|
|
|
51
51
|
(props.angle ? Math.sin(props.angle) : 1) *
|
|
52
52
|
scale;
|
|
53
53
|
var Z = (center.z - activeState.position.z) *
|
|
54
|
-
(props.angle ?
|
|
54
|
+
(props.angle ? Math.cos(props.angle) : 1) *
|
|
55
55
|
scale;
|
|
56
56
|
return (_jsxs("div", { children: [_jsx("div", { className: "minimapObject", style: __assign({ width: "".concat(size.x * scale, "rem"), height: "".concat(size.z * scale, "rem"), top: "50%", left: "50%", transform: "translate(-50.1%, -50.1%) translate(".concat(-X, "rem, ").concat(-Z, "rem)"), transformOrigin: "50% 50%", zIndex: 1 + key }, objectStyle) }, key), _jsx("div", { className: "imageObject", style: __assign({ width: "".concat(props.imageWidth * scale, "rem"), height: "".concat(props.imageHeight * scale, "rem"), top: "50%", left: "50%", transform: "translate(-50.1%, -50.1%) translate(".concat(-X, "rem, ").concat(-Z, "rem)"), transformOrigin: "50% 50%", zIndex: 1000 + key }, imageStyle) }, key + 10), _jsx("div", { className: "textObject", style: {
|
|
57
57
|
width: "".concat(size.x * scale, "rem"),
|