Commit ff30c509 authored by wuhao's avatar wuhao 🎯

kiill

parent 89c5182a
Pipeline #7649 failed with stages
in 89 minutes and 2 seconds
export default { export default {
dev: { dev: {
REACT_APP_URL: "http://jmcl.nangaoyun.com/vstp", // http://tasks-dev.nangaoyun.com REACT_APP_URL: "/vstp", // http://tasks-dev.nangaoyun.com
DEFAULT_HEAD_IMG: "./assets/images/avatars/avatar_21.jpg", DEFAULT_HEAD_IMG: "./assets/images/avatars/avatar_21.jpg",
DEFAULT_404_IMG: "./assets/illustrations/illustration_404.svg", DEFAULT_404_IMG: "./assets/illustrations/illustration_404.svg",
DOWNLOAD_URL: "http://192.168.40.2", DOWNLOAD_URL: "http://192.168.40.2",
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
export default { export default {
dev: { dev: {
"/vstp/": { "/vstp/": {
target: "http://jmcl.nangaoyun.com/vstp/", // "http://jmcl.nangaoyun.com/vstp/", target: "http://192.168.40.146:8044/", // "http://jmcl.nangaoyun.com/vstp/",
changeOrigin: true, changeOrigin: true,
// pathRewrite: { "^/vstp": "" }, // pathRewrite: { "^/vstp": "" },
}, },
......
...@@ -8,10 +8,12 @@ ...@@ -8,10 +8,12 @@
* *
* Copyright (c) 2023 by ${git_name_email}, All Rights Reserved. * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
*/ */
import { Gltf, OrbitControls, Stage } from "@react-three/drei"; import { Gltf, OrbitControls, Stage, useGLTF } from "@react-three/drei";
import { Canvas } from "@react-three/fiber"; import { Canvas, useThree } from "@react-three/fiber";
import { useRef } from "react"; import { useEffect, useRef, useState } from "react";
import * as THREE from "three";
import "./index.less"; import "./index.less";
import { useTimeout } from "ahooks";
function Sphere({ position, CoordinatePoint, CurGongjianPoint }) { function Sphere({ position, CoordinatePoint, CurGongjianPoint }) {
const meshRef = useRef(); const meshRef = useRef();
...@@ -42,19 +44,70 @@ function Sphere({ position, CoordinatePoint, CurGongjianPoint }) { ...@@ -42,19 +44,70 @@ function Sphere({ position, CoordinatePoint, CurGongjianPoint }) {
); );
} }
function PointViewer({ position, CoordinatePoint, CurGongjianPoint }) { const Model = ({ url }) => {
const { camera } = useThree();
const cameraRef = useRef(camera);
const { scene } = useGLTF(url);
const [position, setPosition] = useState([0, 0, 0]);
useEffect(() => {
// 计算模型的包围盒
const box = new THREE.Box3().setFromObject(scene);
const center = new THREE.Vector3();
box.getCenter(center);
let position = [-center.x * 240, -center.y * 240, -center.z * 240];
setPosition(position);
cameraRef.current.position.set(8, 8, 16); // 设置摄像机位置为 (5, 5, 5)
cameraRef.current.lookAt(0, 0, 0); // 使摄像机指向原点
}, [scene]);
return (
<Gltf
src={url}
receiveShadow
castShadow
position={position}
scale={240}
inject={
<meshPhysicalMaterial
color="white"
metalness={1} // 控制金属感,1 表示完全金属
roughness={0} // 控制光滑度,0 表示非常光滑
/>
}
/>
);
};
function PointViewer({
position,
CoordinatePoint,
CurGongjianPoint,
CurGongjianData,
}) {
console.log("====================================");
console.log(CurGongjianData);
console.log("====================================");
const [url, seturl] = useState(null);
useTimeout(()=>{
seturl(`./glb/${CurGongjianData.ModelPath}.glb`)
},100)
return ( return (
<div className="bar-block-component"> <div className="bar-block-component">
{CurGongjianPoint && ( {CurGongjianPoint && (
<Canvas <Canvas
shadows shadows
dpr={[1, 1.5]} dpr={[1, 1.5]}
gl={{ antialias: false }} gl={{ antialias: true }}
camera={{ position: [8, 8, 16], fov: 75 }} camera={{ position: [8, 8, 16], fov: 75 }}
style={{ height: "100%", width: "100%" }} style={{ height: "100%", width: "100%" }}
id={"sada"} id={"rrt"}
> >
<color attach="background" args={["white"]} /> <color attach="background" args={["#333"]} />
<Stage <Stage
intensity={0.5} intensity={0.5}
preset="rembrandt" preset="rembrandt"
...@@ -65,21 +118,10 @@ function PointViewer({ position, CoordinatePoint, CurGongjianPoint }) { ...@@ -65,21 +118,10 @@ function PointViewer({ position, CoordinatePoint, CurGongjianPoint }) {
files: "env.hdr", files: "env.hdr",
}} }}
> >
<axesHelper args={[20]}></axesHelper> <axesHelper args={[20]} position={[0, 0, 0]}></axesHelper>
<Gltf {url && (
src={"./model.glb"} <Model url={url}></Model>
receiveShadow )}
castShadow
position={[0, 0, 0]}
scale={240}
inject={
<meshPhysicalMaterial
color="white"
metalness={1} // 控制金属感,1 表示完全金属
roughness={0} // 控制光滑度,0 表示非常光滑
/>
}
/>
<Sphere <Sphere
position={position} position={position}
CoordinatePoint={CoordinatePoint} CoordinatePoint={CoordinatePoint}
......
...@@ -475,13 +475,14 @@ function Checkhomework() { ...@@ -475,13 +475,14 @@ function Checkhomework() {
<div style={{ position: "relative", minHeight: 360 }}> <div style={{ position: "relative", minHeight: 360 }}>
<Drawer <Drawer
{...drawer} {...drawer}
getContainer={false} width={"100%"} //fixer
title={false} title={false}
closable={false} closable={false}
destroyOnClose destroyOnClose
> >
<PointViewer <PointViewer
position={drawer?.position} position={drawer?.position}
CurGongjianData={dialogprops?.tabdata?.CurGongjianData}
CoordinatePoint={dialogprops?.tabdata?.CoordinatePoint} CoordinatePoint={dialogprops?.tabdata?.CoordinatePoint}
CurGongjianPoint={dialogprops?.tabdata?.CurGongjianPoint} CurGongjianPoint={dialogprops?.tabdata?.CurGongjianPoint}
></PointViewer> ></PointViewer>
......
...@@ -266,13 +266,14 @@ function Record() { ...@@ -266,13 +266,14 @@ function Record() {
<div style={{ position: "relative", minHeight: 360 }}> <div style={{ position: "relative", minHeight: 360 }}>
<Drawer <Drawer
{...drawer} {...drawer}
getContainer={false} width={"100%"} //fixer
title={false} title={false}
closable={false} closable={false}
destroyOnClose destroyOnClose
> >
<PointViewer <PointViewer
position={drawer?.position} position={drawer?.position}
CurGongjianData={dialogprops?.tabdata?.CurGongjianData}
CoordinatePoint={dialogprops?.tabdata?.CoordinatePoint} CoordinatePoint={dialogprops?.tabdata?.CoordinatePoint}
CurGongjianPoint={dialogprops?.tabdata?.CurGongjianPoint} CurGongjianPoint={dialogprops?.tabdata?.CurGongjianPoint}
></PointViewer> ></PointViewer>
......
...@@ -435,13 +435,14 @@ function Dolessons() { ...@@ -435,13 +435,14 @@ function Dolessons() {
<div style={{ position: "relative", minHeight: 360 }}> <div style={{ position: "relative", minHeight: 360 }}>
<Drawer <Drawer
{...drawer} {...drawer}
getContainer={false} width={"100%"} //fixer
title={false} title={false}
closable={false} closable={false}
destroyOnClose destroyOnClose
> >
<PointViewer <PointViewer
position={drawer?.position} position={drawer?.position}
CurGongjianData={dialogprops?.tabdata?.CurGongjianData}
CoordinatePoint={dialogprops?.tabdata?.CoordinatePoint} CoordinatePoint={dialogprops?.tabdata?.CoordinatePoint}
CurGongjianPoint={dialogprops?.tabdata?.CurGongjianPoint} CurGongjianPoint={dialogprops?.tabdata?.CurGongjianPoint}
></PointViewer> ></PointViewer>
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment