gaesup-world 0.6.57 → 0.6.58
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/camera/detector/index.js +26 -23
- package/dist/gaesup/camera/index.d.ts +2 -7
- package/dist/gaesup/camera/index.js +29 -35
- package/dist/gaesup/component/inner/common/InnerGroupRef.js +16 -2
- package/dist/gaesup/controller/index.js +0 -5
- package/dist/gaesup/physics/type.d.ts +1 -7
- package/package.json +1 -1
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
import * as THREE from "three";
|
|
2
1
|
export default function detector(cameraProp) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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 {
|
|
2
|
-
export default function Camera(
|
|
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,32 +1,25 @@
|
|
|
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(
|
|
20
|
-
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
var worldContext = useContext(GaesupWorldContext);
|
|
24
|
-
var controllerContext = useContext(GaesupControllerContext);
|
|
25
|
-
var mode = worldContext.mode, cameraOption = worldContext.cameraOption, activeState = worldContext.activeState;
|
|
4
|
+
export default function Camera(prop) {
|
|
5
|
+
// const worldContext = useContext(GaesupWorldContext);
|
|
6
|
+
// const controllerContext = useContext(GaesupControllerContext);
|
|
7
|
+
// const { mode, cameraOption, activeState } = worldContext;
|
|
26
8
|
// const cameraRef = useRef<CameraControls>();
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
9
|
+
// const intersectObjectMap: intersectObjectMapType = useMemo(() => ({}), []);
|
|
10
|
+
// const cameraProp: cameraPropType = {
|
|
11
|
+
// ...prop,
|
|
12
|
+
// // control,
|
|
13
|
+
// controllerContext,
|
|
14
|
+
// worldContext,
|
|
15
|
+
// // intersectObjectMap,
|
|
16
|
+
// };
|
|
17
|
+
// cameraProp.cameraRay.rayCast = new THREE.Raycaster(
|
|
18
|
+
// cameraProp.cameraRay.origin,
|
|
19
|
+
// cameraProp.cameraRay.dir,
|
|
20
|
+
// 0,
|
|
21
|
+
// -cameraOption.maxDistance
|
|
22
|
+
// );
|
|
30
23
|
useFrame(function (state, delta) {
|
|
31
24
|
// if (
|
|
32
25
|
// !rigidBodyRef ||
|
|
@@ -35,14 +28,14 @@ export default function Camera(_a) {
|
|
|
35
28
|
// !outerGroupRef.current
|
|
36
29
|
// )
|
|
37
30
|
// return;
|
|
38
|
-
cameraProp.delta = delta;
|
|
39
|
-
|
|
40
|
-
if (!worldContext.block.camera) {
|
|
41
|
-
if (mode.control === "orbit") {
|
|
42
|
-
orbit(
|
|
31
|
+
// cameraProp.delta = delta;
|
|
32
|
+
prop.state = state;
|
|
33
|
+
if (!prop.worldContext.block.camera) {
|
|
34
|
+
if (prop.worldContext.mode.control === "orbit") {
|
|
35
|
+
orbit(prop);
|
|
43
36
|
}
|
|
44
|
-
else if (mode.control === "normal") {
|
|
45
|
-
normal(
|
|
37
|
+
else if (prop.worldContext.mode.control === "normal") {
|
|
38
|
+
normal(prop);
|
|
46
39
|
}
|
|
47
40
|
}
|
|
48
41
|
});
|
|
@@ -54,9 +47,10 @@ export default function Camera(_a) {
|
|
|
54
47
|
// }, [worldContext.cameraOption.zoom]);
|
|
55
48
|
// 포커스가 아닐 때 카메라 activeStae 따라가기
|
|
56
49
|
useFrame(function () {
|
|
57
|
-
if (!cameraOption.focus) {
|
|
58
|
-
cameraOption.target =
|
|
59
|
-
|
|
50
|
+
if (!prop.worldContext.cameraOption.focus) {
|
|
51
|
+
prop.worldContext.cameraOption.target =
|
|
52
|
+
prop.worldContext.activeState.position;
|
|
53
|
+
prop.worldContext.cameraOption.position = makeNormalCameraPosition(prop.worldContext.activeState, prop.worldContext.cameraOption);
|
|
60
54
|
}
|
|
61
55
|
});
|
|
62
56
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useGraph } from "@react-three/fiber";
|
|
3
|
-
import { forwardRef, useMemo } from "react";
|
|
2
|
+
import { useFrame, useGraph } from "@react-three/fiber";
|
|
3
|
+
import { forwardRef, useContext, useMemo } from "react";
|
|
4
4
|
import * as THREE from "three";
|
|
5
5
|
import { SkeletonUtils } from "three-stdlib";
|
|
6
6
|
import { useAnimations, useGLTF } from "@react-three/drei";
|
|
7
7
|
import playActions from "../../../animation/actions";
|
|
8
|
+
import Camera from "../../../camera";
|
|
9
|
+
import { GaesupControllerContext } from "../../../controller/context";
|
|
10
|
+
import { GaesupWorldContext } from "../../../world/context";
|
|
8
11
|
export var InnerGroupRef = forwardRef(function (_a, ref) {
|
|
9
12
|
var children = _a.children, type = _a.type, currentAnimation = _a.currentAnimation, url = _a.url, rotation = _a.rotation;
|
|
10
13
|
var _b = useGLTF(url), scene = _b.scene, animations = _b.animations;
|
|
@@ -17,6 +20,17 @@ export var InnerGroupRef = forwardRef(function (_a, ref) {
|
|
|
17
20
|
var clone = useMemo(function () { return SkeletonUtils.clone(scene); }, [scene]);
|
|
18
21
|
var nodes = useGraph(clone).nodes;
|
|
19
22
|
var objectNode = Object.values(nodes).find(function (node) { return node.type === "Object3D"; });
|
|
23
|
+
var worldContext = useContext(GaesupWorldContext);
|
|
24
|
+
var controllerContext = useContext(GaesupControllerContext);
|
|
25
|
+
var props = {
|
|
26
|
+
state: null,
|
|
27
|
+
worldContext: worldContext,
|
|
28
|
+
controllerContext: controllerContext,
|
|
29
|
+
};
|
|
30
|
+
useFrame(function (state, delta) {
|
|
31
|
+
props.state = state;
|
|
32
|
+
});
|
|
33
|
+
Camera(props);
|
|
20
34
|
return (_jsxs("group", { receiveShadow: true, castShadow: true, ref: ref, rotation: rotation, 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) {
|
|
21
35
|
var node = nodes[name];
|
|
22
36
|
if (node instanceof THREE.SkinnedMesh) {
|
|
@@ -13,7 +13,6 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { useContext, useMemo, useReducer, useRef } from "react";
|
|
15
15
|
import { KeyboardControls } from "@react-three/drei";
|
|
16
|
-
import Camera from "../camera";
|
|
17
16
|
import { GaesupComponent } from "../component";
|
|
18
17
|
import { GaesupWorldContext } from "../world/context";
|
|
19
18
|
import { GaesupControllerContext, GaesupControllerDispatchContext, gaesupControllerDefault, } from "./context";
|
|
@@ -71,9 +70,5 @@ export function GaesupControllerInner(props) {
|
|
|
71
70
|
controllerContext: gaesupControl.value,
|
|
72
71
|
controllerDispatch: gaesupControl.dispatch,
|
|
73
72
|
});
|
|
74
|
-
Camera({
|
|
75
|
-
prop: prop,
|
|
76
|
-
control: prop.keyControl,
|
|
77
|
-
});
|
|
78
73
|
return (_jsx(GaesupControllerContext.Provider, { value: gaesupControl.value, children: _jsx(GaesupControllerDispatchContext.Provider, { value: gaesupControl.dispatch, children: _jsx(GaesupComponent, { props: prop, refs: refs, urls: props.urls }) }) }));
|
|
79
74
|
}
|
|
@@ -22,14 +22,8 @@ export type calcPropType = controllerInnerType & {
|
|
|
22
22
|
export type intersectObjectMapType = {
|
|
23
23
|
[uuid: string]: THREE.Mesh;
|
|
24
24
|
};
|
|
25
|
-
export type cameraPropType =
|
|
26
|
-
control: {
|
|
27
|
-
[key: string]: boolean;
|
|
28
|
-
};
|
|
25
|
+
export type cameraPropType = {
|
|
29
26
|
state?: RootState;
|
|
30
27
|
worldContext?: gaesupWorldContextType;
|
|
31
28
|
controllerContext?: gaesupControllerType;
|
|
32
|
-
intersectObjectMap?: intersectObjectMapType;
|
|
33
|
-
delta?: number;
|
|
34
|
-
dist?: number;
|
|
35
29
|
};
|