- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Three.js 问题在这里。不确定为什么当我在第 10 行调用 MeshStandardMaterial 时我的代码不工作。当我将它切换到 MeshBasicMaterial 时它工作,但我需要 MeshStandardMaterial 的功能以便将 .bumpMap 添加到我的渲染中。有人可以帮忙吗?
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
const renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
const geometry = new THREE.SphereGeometry(5,32,32);
// const texture = new THREE.TextureLoader().load( 'textures/8081_earthmap10k.jpg' );
const material = new THREE.MeshBasicMaterial( { color: 0xffffff } );
const cube = new THREE.Mesh( geometry, material );
scene.add( cube );
camera.position.z = 15;
const animate = function () {
requestAnimationFrame( animate );
// cube.rotation.x += 0.01;
cube.rotation.y += 0.01;
renderer.render( scene, camera );
};
animate();
上面的代码可以正常工作并在黑色背景上显示一个旋转的白色 (0xffffff) 球体,但下面的代码不起作用,它只显示黑色背景..
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
const renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
const geometry = new THREE.SphereGeometry(5,32,32);
// const texture = new THREE.TextureLoader().load( 'textures/8081_earthmap10k.jpg' );
const material = new THREE.MeshStandardMaterial( { color: 0xffffff } );
const cube = new THREE.Mesh( geometry, material );
scene.add( cube );
camera.position.z = 15;
const animate = function () {
requestAnimationFrame( animate );
// cube.rotation.x += 0.01;
cube.rotation.y += 0.01;
renderer.render( scene, camera );
};
animate();
同样,我唯一要改变的是第 10 行对 MeshStandardMaterial 的调用......我在这里遗漏了什么吗?
最佳答案
MeshBasicMaterial
是一种不发光的 Material 。 MeshStandardMaterial
是一种光照 Material 。
因此,只要您不向场景添加灯光或向 Material 添加环境贴图,具有 MeshStandardMaterial
的对象将是黑色的。
关于three.js - 从 MeshBasicMaterial 切换到 MeshStandardMaterial 只是显示黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66342169/
Three.js 问题在这里。不确定为什么当我在第 10 行调用 MeshStandardMaterial 时我的代码不工作。当我将它切换到 MeshBasicMaterial 时它工作,但我需要 M
Three.js 问题在这里。不确定为什么当我在第 10 行调用 MeshStandardMaterial 时我的代码不工作。当我将它切换到 MeshBasicMaterial 时它工作,但我需要 M
我有以下代码在场景中添加立方体,当我在PC上的浏览器中打开页面时,它工作正常,但当我在移动设备中打开时,控制太慢。触摸需要 3-4 秒才能得到响应,移动速度也变慢。 就好像我将 MeshStandar
总的来说,我是 Three.js 和 3D 图形的初学者。这对我来说主要是一个学习练习。 我正在尝试显示具有金属外观的十二面体,但是大约一半的面是黑色的并且不反射。其他面孔看起来正确。 我知道有一个内
据我所知,应该可以使用 MeshStandardMaterial 在 Three.js 中定义类金属 Material ,它应该遵循 pbr-roughness-metalness-workflow
我是一名优秀的程序员,十分优秀!