pointLight 无法在反应三/纤维中用于博览会反应本机

问题描述 投票:0回答:1

我想使用 React Native 来处理三个 js,为此我正在遵循一个教程。 我遇到了一个问题,点光源似乎不起作用,我也使用了环境光,它工作正常并照亮了物体,但这使物体看起来是 2D 的。以下是代码。 `

import React from 'react';
import { Canvas } from '@react-three/fiber';

export default function App() {
  return (
    <Canvas>
      {/* <ambientLight intensity={5} /> */}
      <pointLight position={[0, 10, -5]} intensity={1} color="#fff" distance={100}/>
      <mesh rotation={[Math.PI / 4, 0, 0]}>
        <sphereGeometry args={[1, 32, 32]} />
        <meshStandardMaterial color={'orange'} />
      </mesh>
    </Canvas>
  );
}

`

以下是我正在使用的依赖项:

"dependencies": {
    "@expo/webpack-config": "^18.1.2",
    "@react-three/fiber": "^8.13.6",
    "expo": "~49.0.7",
    "expo-gl": "~13.0.1",
    "expo-status-bar": "~1.6.0",
    "expo-three": "^7.0.0",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-native": "0.72.3",
    "react-native-web": "~0.19.6",
    "three": "^0.155.0"
  },

帮我找到解决方案

我尝试使用构造函数中的所有值单独或集体填充点光源,但对象始终保持黑色。

reactjs react-native three.js expo react-three-fiber
1个回答
0
投票

将 package.json 文件中的这些版本降级到这些版本可能会解决问题:

"three": "0.149.0"
"@react-spring/three": "^9.7.3"
"@react-three/drei": "9.96.1"
"@react-three/fiber": "^8.15.14"
© www.soinside.com 2019 - 2024. All rights reserved.