1

我正在研究 Three.js 来构建如下所示的地形。

    const segment = 25
    const geometry = new THREE.PlaneGeometry(dimension, dimension, segment, segment)
    for (let i = 0; i < vertices; i++) {
            const idx = i * vertices
            const fVal = (simplex.noise2D(ni, nj) + 1) / 2
            const sVal = (0.5 * simplex.noise2D(ni * 2, nj * 2) + 1) / 2
            const tVal = (0.25 * simplex.noise2D(ni * 4, nj * 4) + 1) / 2
            const vtx = (fVal + sVal + tVal) / 2.15
            geometry.attributes.position.setY(idx, Math.pow(vtx, 2.5) * 350)
    }

The application throws out an error saying: TypeError: Cannot read properties of undefined (reading 'position'), which points out geometry.attributes is null.

我的 three.js 版本是 0.124,目前我不想将其更新到 0.125,因为有许多功能依赖于当前版本。

我将如何解决这个问题。

更新,最后我把它更新到0.125版本,它可以工作了

4

0 回答 0