index.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import React, { Suspense } from 'react'
  2. import styles from './index.module.scss'
  3. import { useSelector } from 'react-redux'
  4. import { RootState } from '@/store'
  5. import classNames from 'classnames'
  6. // import * as THREE from 'three'
  7. import { Canvas } from '@react-three/fiber'
  8. import SceneSetup from './SceneSetup'
  9. import Model from './Model'
  10. import A0btn from './A0btn'
  11. function A0model() {
  12. const { isShow } = useSelector((state: RootState) => state.A0model)
  13. return (
  14. <div
  15. style={{ backgroundImage: `url(${serverUrl}0/0_bac.jpg)` }}
  16. className={classNames(styles.A0model, isShow ? styles.A0modelShow : '')}
  17. >
  18. <Canvas
  19. shadows
  20. camera={{ position: [0, 1000, 5], fov: 50 }}
  21. gl={{
  22. antialias: true, // 开启抗锯齿,使边缘更平滑
  23. alpha: true // 允许 Canvas 背景透明
  24. }}
  25. // onCreated={({ gl }) => {
  26. // gl.setClearColor(new THREE.Color(0x000000))
  27. // }}
  28. >
  29. <Suspense>
  30. {/* 场景与控制器 */}
  31. <SceneSetup />
  32. <Model />
  33. </Suspense>
  34. </Canvas>
  35. <A0btn />
  36. </div>
  37. )
  38. }
  39. const MemoA0model = React.memo(A0model)
  40. export default MemoA0model