通过遵循three.js教程,我正在尝试使用这创建一条河流。
这是我的位移/高度图:

这是我的流程图(透明):

下面是我用来创建这条河的代码:
//Creating a texture loader
var textureLoader = new THREE.TextureLoader();
let s = 1;
//DisplacementMap
const disMap = textureLoader.load('Assets/Textures/heightmap1.jpg')
disMap.wrapS = disMap.wrapT = THREE.RepeatWrapping;
disMap.repeat.set(s, s);
//The plane
var planeGeometry = new THREE.PlaneBufferGeometry(5000, 5000);
var planeMaterial = new THREE.MeshStandardMaterial({
color: 0x90EE90,
displacementMap: disMap,
displacementScale: 2
});
var plane = new THREE.Mesh(planeGeometry, planeMaterial);
scene.add(plane);
//The flowmap and the river plane
const flowMap = textureLoader.load('Assets/Textures/flowmap1.png')
const river1Geo = new THREE.PlaneGeometry(5000, 5000)
//The water itself
const water = new THREE.Water(river1Geo, {
scale: .1,
textureWidth: 512,
textureHeight: 512,
flowSpeed: 0.04,
reflectivity: 0.35,
flowMap: flowMap,
color: 0x87CEEB
});
//Positioning and stuff.
water.position.z = 20;
water.rotation.x = Math.PI*2;
scene.add(water);我的问题是:
这就是我希望看到的:

一条蓝色的河流,在透明的地方什么也没有。相反,我看到的是:

水在透明区域向一个一致的方向流动。,这是为什么?在本教程中,它似乎运行良好..。有什么具体的事情我需要做吗?
编辑:
谢谢@Mugen87!

发布于 2022-07-20 05:20:36
我的飞机布置得不好。我需要改变这一点:
var planeGeometry = new THREE.PlaneBufferGeometry(5000, 5000);至:
var planeGeometry = new THREE.PlaneBufferGeometry(5000, 5000, 512, 512);这为displacementMap增加了更多的顶点。
希望这能帮助其他人解决同样的问题~
https://stackoverflow.com/questions/72945563
复制相似问题