为什么没有`geometry.verticesNeedUpdate = true;`允许我改变顶点?

时间:2016-02-03 19:49:02

标签: javascript three.js render vertices

我有这个被重复调用的函数,但顶点没有改变:

function renderChart() {
    requestAnimationFrame(renderChart);
    // Copy frequency data to frequencyData array.
    analyser.getByteFrequencyData(frequencyData); //frequencyData is an array that changes over time.  

    var dat = 79600;  
    var step = dat/frequencyData.length
    var f = 0;  
    for(v=0; v<dat; v+=step){
        globe._baseGeometry.verticesNeedUpdate = true;
        globe.points.geometry.verticesNeedUpdate = true;
        globe._baseGeometry.vertices[v].z = globe._baseGeometry.vertices[v].z * frequencyData[f]
        globe._baseGeometry.vertices[v].y = globe._baseGeometry.vertices[v].y * frequencyData[f]
        globe._baseGeometry.vertices[v].x = globe._baseGeometry.vertices[v].x * frequencyData[f]
        f++; 
    }
}

// Run the loop
renderChart();

如果我在$(document).ready(function(){...中运行它,它将成功运行一次。有什么变化

1 个答案:

答案 0 :(得分:0)

这里讨论解决方案:

https://github.com/mrdoob/three.js/issues/8021

  

#7179中所述,您无法重新分配顶点数组。请改用copy()。&#34;