gaesup-world 0.8.51 → 0.8.52
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/inner/common/RigidbodyRef.d.ts +1 -1
- package/dist/gaesup/component/inner/common/RigidbodyRef.js +4 -2
- package/dist/gaesup/component/inner/common/partsGroupRef.d.ts +2 -1
- package/dist/gaesup/component/inner/common/partsGroupRef.js +19 -6
- package/dist/gaesup/component/passive/type.d.ts +2 -2
- package/dist/gaesup/controller/type.d.ts +8 -1
- package/dist/gaesup/utils/getTag.d.ts +3 -0
- package/dist/gaesup/utils/getTag.js +4 -0
- package/package.json +1 -1
|
@@ -33,5 +33,5 @@ export declare const RigidBodyRef: import("react").ForwardRefExoticComponent<{
|
|
|
33
33
|
rigidBodyProps?: import("@react-three/rapier").RigidBodyProps;
|
|
34
34
|
outerGroupProps?: THREE.Group<THREE.Object3DEventMap>;
|
|
35
35
|
innerGroupProps?: THREE.Group<THREE.Object3DEventMap>;
|
|
36
|
-
parts?:
|
|
36
|
+
parts?: import("../../../controller/type").partsType;
|
|
37
37
|
} & import("./type").ridingType & import("../../passive/type").innerRefType & import("../../../controller/initialize/callback/type").callbackType & import("react").RefAttributes<RapierRigidBody>>;
|
|
@@ -87,7 +87,9 @@ export var RigidBodyRef = forwardRef(function (props, ref) {
|
|
|
87
87
|
return (_jsxs(RigidBody, __assign({ colliders: false, ref: ref, name: props.name, rotation: euler()
|
|
88
88
|
.set(0, ((_a = props.rotation) === null || _a === void 0 ? void 0 : _a.clone().y) || 0, 0)
|
|
89
89
|
.clone(), userData: props.userData, type: props.rigidbodyType || (props.isActive ? "dynamic" : "fixed"), sensor: props.sensor, onIntersectionEnter: props.onIntersectionEnter, onCollisionEnter: props.onCollisionEnter }, props.rigidBodyProps, { 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] }), _jsxs(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, parts: props.parts, children: [props.children, props.parts &&
|
|
90
|
-
props.parts.map(function (
|
|
91
|
-
|
|
90
|
+
props.parts.map(function (_a, key) {
|
|
91
|
+
var url = _a.url, color = _a.color;
|
|
92
|
+
console.log(url, color);
|
|
93
|
+
return (_jsx(PartsGroupRef, { url: url, isActive: props.isActive, componentType: props.componentType, currentAnimation: props.currentAnimation, color: color }, key + url));
|
|
92
94
|
})] })] })));
|
|
93
95
|
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { componentTypeString } from "../../passive/type";
|
|
2
|
-
export declare const PartsGroupRef: ({ url, isActive, componentType, currentAnimation, }: {
|
|
2
|
+
export declare const PartsGroupRef: ({ url, isActive, componentType, currentAnimation, color, }: {
|
|
3
3
|
url: string;
|
|
4
4
|
isActive: boolean;
|
|
5
5
|
componentType: componentTypeString;
|
|
6
6
|
currentAnimation: string;
|
|
7
|
+
color?: string;
|
|
7
8
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useAnimations, useGLTF } from "@react-three/drei";
|
|
3
3
|
import { useGraph } from "@react-three/fiber";
|
|
4
|
+
import { isEqual } from "lodash";
|
|
4
5
|
import { useMemo } from "react";
|
|
5
6
|
import * as THREE from "three";
|
|
6
7
|
import { SkeletonUtils } from "three-stdlib";
|
|
7
8
|
import playActions from "../../../animation/actions";
|
|
8
9
|
export var PartsGroupRef = function (_a) {
|
|
9
|
-
var url = _a.url, isActive = _a.isActive, componentType = _a.componentType, currentAnimation = _a.currentAnimation;
|
|
10
|
+
var url = _a.url, isActive = _a.isActive, componentType = _a.componentType, currentAnimation = _a.currentAnimation, color = _a.color;
|
|
10
11
|
var _b = useGLTF(url), scene = _b.scene, animations = _b.animations;
|
|
11
|
-
var clone = useMemo(function () { return SkeletonUtils.clone(scene); }, [scene]);
|
|
12
|
+
var clone = useMemo(function () { return SkeletonUtils.clone(scene); }, [scene, color]);
|
|
12
13
|
var _c = useAnimations(animations), actions = _c.actions, ref = _c.ref;
|
|
13
14
|
var nodes = useGraph(clone).nodes;
|
|
14
15
|
var objectNode = Object.values(nodes).find(function (node) { return node.type === "Object3D"; });
|
|
@@ -20,12 +21,24 @@ export var PartsGroupRef = function (_a) {
|
|
|
20
21
|
isActive: isActive,
|
|
21
22
|
});
|
|
22
23
|
return (_jsxs(_Fragment, { children: [_jsx("primitive", { object: objectNode, visible: false, receiveShadow: true, castShadow: true, ref: ref }), Object.keys(nodes).map(function (name, key) {
|
|
23
|
-
var node = nodes[name];
|
|
24
|
+
var node = nodes === null || nodes === void 0 ? void 0 : nodes[name];
|
|
24
25
|
if (node instanceof THREE.SkinnedMesh) {
|
|
25
|
-
|
|
26
|
+
if (isEqual("color", node) && color) {
|
|
27
|
+
return (_jsx("skinnedMesh", { castShadow: true, receiveShadow: true, geometry: node.geometry, skeleton: node.skeleton, children: _jsx("meshStandardMaterial", { color: color }) }, key));
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return (_jsx("skinnedMesh", { castShadow: true, receiveShadow: true, material: node.material, geometry: node.geometry, skeleton: node.skeleton }, key));
|
|
31
|
+
}
|
|
26
32
|
}
|
|
27
|
-
else if (node instanceof THREE.Mesh
|
|
28
|
-
|
|
33
|
+
else if (node instanceof THREE.Mesh &&
|
|
34
|
+
isEqual("color", node) &&
|
|
35
|
+
color) {
|
|
36
|
+
if (isEqual("color", node) && color) {
|
|
37
|
+
return (_jsx("mesh", { castShadow: true, receiveShadow: true, geometry: node.geometry, children: _jsx("meshStandardMaterial", { color: color }) }, key));
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return (_jsx("mesh", { castShadow: true, receiveShadow: true, material: node.material, geometry: node.geometry }, key));
|
|
41
|
+
}
|
|
29
42
|
}
|
|
30
43
|
})] }));
|
|
31
44
|
};
|
|
@@ -2,7 +2,7 @@ import { Collider } from "@dimforge/rapier3d-compat";
|
|
|
2
2
|
import { CollisionEnterPayload, RapierRigidBody, RigidBodyProps, RigidBodyTypeString } from "@react-three/rapier";
|
|
3
3
|
import { MutableRefObject } from "react";
|
|
4
4
|
import * as THREE from "three";
|
|
5
|
-
import { controllerOptionsType, groundRayType } from "../../controller/type";
|
|
5
|
+
import { controllerOptionsType, groundRayType, partsType } from "../../controller/type";
|
|
6
6
|
import { ridingType } from "../inner/common/type";
|
|
7
7
|
export type componentTypeString = "character" | "vehicle" | "airplane";
|
|
8
8
|
export type innerRefType = {
|
|
@@ -33,5 +33,5 @@ export type passivePropsType = {
|
|
|
33
33
|
rigidBodyProps?: RigidBodyProps;
|
|
34
34
|
outerGroupProps?: THREE.Group;
|
|
35
35
|
innerGroupProps?: THREE.Group;
|
|
36
|
-
parts?:
|
|
36
|
+
parts?: partsType;
|
|
37
37
|
} & ridingType;
|
|
@@ -90,7 +90,14 @@ export interface controllerOtherPropType extends RigidBodyProps {
|
|
|
90
90
|
rigidBodyProps?: RigidBodyProps;
|
|
91
91
|
debug?: boolean;
|
|
92
92
|
}
|
|
93
|
-
export type
|
|
93
|
+
export type partType = {
|
|
94
|
+
url: string;
|
|
95
|
+
color?: string;
|
|
96
|
+
position?: THREE.Vector3;
|
|
97
|
+
rotation?: THREE.Euler;
|
|
98
|
+
scale?: THREE.Vector3;
|
|
99
|
+
};
|
|
100
|
+
export type partsType = partType[];
|
|
94
101
|
export type controllerType = controllerOtherPropType & urlsType & Partial<gaesupControllerContextPropType> & callbackType & {
|
|
95
102
|
controllerOptions?: controllerOptionsType;
|
|
96
103
|
parts?: partsType;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// split한 태그의 첫번째 문자열을 가져오는 함수.
|
|
2
|
+
export var getTag = function (node) { var _a, _b; return (_b = (_a = node === null || node === void 0 ? void 0 : node.name) === null || _a === void 0 ? void 0 : _a.split("_")) === null || _b === void 0 ? void 0 : _b[0]; };
|
|
3
|
+
// 태그와 이름이 일치하는지 확인
|
|
4
|
+
export var isEqual = function (tag, node) { var _a, _b; return ((_b = (_a = node === null || node === void 0 ? void 0 : node.name) === null || _a === void 0 ? void 0 : _a.split("_")) === null || _b === void 0 ? void 0 : _b[0]) === tag; };
|