|
@@ -5,10 +5,13 @@ import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader'
|
|
|
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'
|
|
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'
|
|
|
import { forwardRef, useImperativeHandle } from 'react'
|
|
import { forwardRef, useImperativeHandle } from 'react'
|
|
|
import { OrbitControls } from '@react-three/drei'
|
|
import { OrbitControls } from '@react-three/drei'
|
|
|
-import store from '@/store'
|
|
|
|
|
import { envFlag } from '@/utils/http'
|
|
import { envFlag } from '@/utils/http'
|
|
|
|
|
|
|
|
-function Model(_: any, ref: any) {
|
|
|
|
|
|
|
+type Props = {
|
|
|
|
|
+ setPlanFu: (val: number) => void
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function Model({ setPlanFu }: Props, ref: any) {
|
|
|
// 轨道控制器
|
|
// 轨道控制器
|
|
|
const controlsRef = useRef<any>(null)
|
|
const controlsRef = useRef<any>(null)
|
|
|
useFrame(() => {
|
|
useFrame(() => {
|
|
@@ -123,14 +126,14 @@ function Model(_: any, ref: any) {
|
|
|
if (xhr.lengthComputable) {
|
|
if (xhr.lengthComputable) {
|
|
|
const percentComplete = (xhr.loaded / xhr.total) * 100
|
|
const percentComplete = (xhr.loaded / xhr.total) * 100
|
|
|
const baiNum = percentComplete.toFixed(0)
|
|
const baiNum = percentComplete.toFixed(0)
|
|
|
-
|
|
|
|
|
- store.dispatch({ type: 'A1/plan', payload: Number(baiNum) })
|
|
|
|
|
|
|
+ setPlanFu(Number(baiNum))
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
error => {
|
|
error => {
|
|
|
console.error('加载模型出错:', error)
|
|
console.error('加载模型出错:', error)
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
|
|
+ // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
}, [handleModelLoaded])
|
|
}, [handleModelLoaded])
|
|
|
|
|
|
|
|
// 点击不同部位
|
|
// 点击不同部位
|
|
@@ -182,6 +185,7 @@ function Model(_: any, ref: any) {
|
|
|
maxDistance={2} // 根据初始缩放比例调整
|
|
maxDistance={2} // 根据初始缩放比例调整
|
|
|
minDistance={0.3} // 根据初始缩放比例调整[9](@ref)
|
|
minDistance={0.3} // 根据初始缩放比例调整[9](@ref)
|
|
|
screenSpacePanning={true} // 移动端友好的平移方式
|
|
screenSpacePanning={true} // 移动端友好的平移方式
|
|
|
|
|
+ enablePan={false}
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
|
{groupRef.current ? <primitive object={groupRef.current} /> : null}
|
|
{groupRef.current ? <primitive object={groupRef.current} /> : null}
|