【发布时间】:2023-04-04 00:50:01
【问题描述】:
我正在尝试将法线贴图(在本例中为木质纹理)添加到我使用 THREE.BufferGeometry() 和顶点创建的自定义部分。
对于这个特定的部分:
//edit initially I left out this part while posting. My script sees this folder and gives no errors
const woodPattern = new THREE.TextureLoader();
const woodTexture = woodPattern.load('/textures/wood_pattern.jpg');
const frame_upper_part_geometry = new THREE.BufferGeometry();
const frame_upper_part_positions = [
0.8, 0.8, 0.95,
-0.8, 0.8, 0.95,
-0.8, 0.8, 0.75,
-0.8, 0.8, 0.75,
0.8, 0.8, 0.75,
0.8, 0.8, 0.95,
0.6, 0.6, 0.95,
-0.6, 0.6, 0.95,
-0.6, 0.6, 0.75,
-0.6, 0.6, 0.75,
0.6, 0.6, 0.75,
0.6, 0.6, 0.95,
0.8, 0.8, 0.95,
0.6, 0.6, 0.95,
0.6, 0.6, 0.75,
0.6, 0.6, 0.75,
0.8, 0.8, 0.75,
0.8, 0.8, 0.95,
-0.8, 0.8, 0.95,
-0.6, 0.6, 0.95,
-0.6, 0.6, 0.75,
-0.6, 0.6, 0.75,
-0.8, 0.8, 0.75,
-0.8, 0.8, 0.95,
0.8, 0.8, 0.75,
-0.8, 0.8, 0.75,
-0.6, 0.6, 0.75,
-0.6, 0.6, 0.75,
0.6, 0.6, 0.75,
0.8, 0.8, 0.75,
];
frame_upper_part_geometry.setAttribute(
'position',
new THREE.Float32BufferAttribute( frame_upper_part_positions, 3 )
);
frame_upper_part_geometry.computeVertexNormals();
const frame_material = new THREE.MeshStandardMaterial({normalMap:woodTexture})
frame_material.side = THREE.DoubleSide;
frame_material.color = new THREE.Color(0x654321)
const frame_upper_part = new THREE.Mesh(frame_upper_part_geometry, frame_material)
scene.add(frame_upper_part)
我没有收到任何错误,但是添加法线贴图似乎并没有改变任何事情,即使我以与预定义几何图形相同的方式添加它,它也应该可以工作。我错过了什么吗?
result I'm getting, no errors, however effects of normal map are not present.
【问题讨论】:
标签: javascript three.js textures