为什么 ThreeJS 照明很有趣,例如点光源和环境光,不适用于版本“三”:“^0.164.1”

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

我正在使用 vite 和 Threejs 库做我的第一个 ThreeJS 小项目

我在js文件中添加了这些灯光功能,

// emit light evenly in all directions from specific point in space
const pointLight = new Three.PointLight( 0xff0000, 1, 100 );
pointLight.position.set(5, 5, 5);



// to spread the lighting across the entire scene
const ambientLight = new Three.AmbientLight(0xffffff);
scene.add(pointLight, ambientLight);

package.json 内部,

{
  "name": "three-demo",
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "serve": "vite preview"
  },
  "devDependencies": {
    "vite": "^5.2.0"
    
  },
  "dependencies": {
    "three": "^0.128.0"
  }
}

问题是照明功能可以与三个依赖项完美配合“三”:“^0.128.0”,但是当更改为最新版本“三”:“^0.164.1”并运行npm install时,则照明功能不工作

javascript reactjs three.js react-three-fiber three-tier
1个回答
0
投票

如果我必须拍摄,可能会与灯光的强度有关,自从

r155
以来灯光的强度已经发生了变化。

我认为“不工作”意味着光/物体是不可见的。 尝试设置

const pointLight = new Three.PointLight( 0xff0000, 100, 100 ); pointLight.position.set(5, 5, 5);

不过,一般来说,如果您能提供更多详细信息,如 
derpirscher

建议的那样,那就太好了。 另请看一下此线程:

https://discourse.thirdjs.org/t/updates-to-lighting-in- Three-js-r155/53733

© www.soinside.com 2019 - 2024. All rights reserved.