From 6c238c4ff0fb437de1983eed6b7f340b06402341 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 17 六月 2024 16:32:37 +0800
Subject: [PATCH] #
---
src/components/house.jsx | 2 +-
src/store/index.js | 2 ++
src/components/camera.jsx | 21 +++++++++++++++++----
src/components/agv.jsx | 12 ++++++++++++
4 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/src/components/agv.jsx b/src/components/agv.jsx
index a7ee415..a7cd6fc 100644
--- a/src/components/agv.jsx
+++ b/src/components/agv.jsx
@@ -5,6 +5,7 @@
import Box from './box';
import * as Common from '../utils/common';
import * as TWEEN from "@tweenjs/tween.js";
+import { useStore } from '@/store';
import {
INTERVAL_TIME,
MODEL_AGV_SCALE,
@@ -171,6 +172,17 @@
const [loaderAngle, setLoaderAngle] = useState(0);
const [forkDis, setForkDis] = useState(0);
const [realTrayList, setRealTrayList] = useState([]);
+ const store = useStore();
+
+ useEffect(() => {
+ if (store.autoCruise && agvNo === '1') {
+ // store.lookAt = groupPos;
+
+ store.lookAt.x = groupPos.x;
+ store.lookAt.y = loaderHeight;
+ store.lookAt.z = groupPos.z;
+ }
+ }, [groupPos, loaderHeight])
useEffect(() => {
if (!props || Object.keys(props).length === 0) {
diff --git a/src/components/camera.jsx b/src/components/camera.jsx
index b450ce9..8d61220 100644
--- a/src/components/camera.jsx
+++ b/src/components/camera.jsx
@@ -1,16 +1,29 @@
-import React, { useState, useEffect } from 'react';
-import { useThree } from '@react-three/fiber';
+import React, { useState, useEffect, useRef } from 'react';
+import { useThree, useFrame } from '@react-three/fiber';
import {
PerspectiveCamera,
} from '@react-three/drei';
+import { useStore } from '@/store';
const Camera = (props) => {
- const threeObj = useThree();
- const camera = threeObj.camera;
+ const cameraRef = useRef();
+ const { camera } = useThree();
+
+ const store = useStore();
+
+ useFrame((state, delta) => {
+ const { autoCruise, lookAt } = store;
+
+ if (autoCruise) {
+ cameraRef.current.position.set(lookAt.x - 0, lookAt.y + 200, lookAt.z + 500);
+ camera.lookAt(lookAt.x, lookAt.y + 100, lookAt.z);
+ }
+ })
return (
<>
<PerspectiveCamera
+ ref={cameraRef}
makeDefault
position={[0, 350, 1150]}
fov={48}
diff --git a/src/components/house.jsx b/src/components/house.jsx
index b397353..3bb80e4 100644
--- a/src/components/house.jsx
+++ b/src/components/house.jsx
@@ -9,7 +9,7 @@
const House = (props) => {
const {
wallThickness = 2,
- wallOpacity = 1,
+ wallOpacity = .9,
width = DEBUG ? 14000 : 1400,
length = DEBUG ? 12000 : 1200,
height = DEBUG ? 4000 : 400,
diff --git a/src/store/index.js b/src/store/index.js
index b8505d2..b5b1590 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -5,6 +5,8 @@
{
text: 'Hello World',
shelfList: {},
+ autoCruise: true,
+ lookAt: { x: 0, y: 0, z: 0 },
}
);
--
Gitblit v1.9.1