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.
@@ -1,25 +1,28 @@
1
- import * as THREE from "three";
2
1
  export default function detector(cameraProp) {
3
- var cameraRay = cameraProp.cameraRay, intersectObjectMap = cameraProp.intersectObjectMap;
4
- var intersects = cameraRay.rayCast.intersectObjects(Object.values(intersectObjectMap));
5
- var intersectId = {};
6
- intersects.map(function (_a) {
7
- var object = _a.object;
8
- if (object instanceof THREE.Mesh) {
9
- intersectId[object.uuid] = true;
10
- }
11
- });
12
- Object.values(intersectObjectMap).map(function (mesh) {
13
- if (mesh instanceof THREE.Mesh && mesh.material instanceof THREE.Material) {
14
- var material = mesh.material;
15
- if (intersectId[mesh.uuid]) {
16
- material.opacity = 0.2;
17
- material.transparent = true;
18
- }
19
- else {
20
- material.opacity = 1;
21
- material.transparent = false;
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 { controllerInnerType } from "../controller/type";
2
- export default function Camera({ prop, control, }: {
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(_a) {
20
- var
21
- // refs,
22
- prop = _a.prop, control = _a.control;
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
- var intersectObjectMap = useMemo(function () { return ({}); }, []);
28
- var cameraProp = __assign(__assign({}, prop), { control: control, controllerContext: controllerContext, worldContext: worldContext, intersectObjectMap: intersectObjectMap });
29
- cameraProp.cameraRay.rayCast = new THREE.Raycaster(cameraProp.cameraRay.origin, cameraProp.cameraRay.dir, 0, -cameraOption.maxDistance);
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
- cameraProp.state = state;
40
- if (!worldContext.block.camera) {
41
- if (mode.control === "orbit") {
42
- orbit(cameraProp);
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(cameraProp);
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 = activeState.position;
59
- cameraOption.position = makeNormalCameraPosition(activeState, cameraOption);
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 = controllerInnerType & {
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gaesup-world",
3
- "version": "0.6.57",
3
+ "version": "0.6.58",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",