小编o1s*_*und的帖子

three.js r72不再支持THREE.LinePieces,如何将多个断开的行与THREE.LineSegments合并?

我刚刚更新到three.js r72,我在控制台中收到了关于THREE.LinePieces的以下警告......

THREE.Line: parameter THREE.LinePieces no longer supported. Created THREE.LineSegments instead.
Run Code Online (Sandbox Code Playgroud)

这些行将显示为断开连接,并显示警告,但是,对于以下示例,如果我将THREE.LinePieces更新为THREE.LineSegments,则所有断开的行都将连接.

var lineMaterial = new THREE.LineBasicMaterial({color: 0x000000, linewidth: 1});
var lineGeom = new THREE.Geometry();
var xstrt = 0;
for (nn=0; nn<numLines; nn++)
{
    lineGeom.vertices.push(new THREE.Vector3(xstrt, -5, 0));
    lineGeom.vertices.push(new THREE.Vector3(xstrt, 5, 0));
    xstrt += 5;
}
var Line  = new THREE.Line(lineGeom, lineMaterial, THREE.LinePieces); // seperate lines, but with warnings
//var Line  = new THREE.Line(lineGeom, lineMaterial, THREE.LineSegments); // connected as one line only :(
Run Code Online (Sandbox Code Playgroud)

我是否希望为每个线段创建单独的几何图形(包含两个顶点),或者可以将多个线段合并为一个几何图形,就像我使用LinePieces一样?

javascript three.js

7
推荐指数
1
解决办法
3235
查看次数

如何在Web音频API中反向播放,但同时也保持前进版本?

据我所知,谷歌浏览器(v21)中的Web Audio API不支持以下功能:

    source.playbackRate.value = -1; 
Run Code Online (Sandbox Code Playgroud)

我非常希望!我会耐心等待,但与此同时,这篇文章有一个不错的替代解决方案。我采用它来尝试反转从已加载的缓冲区列表加载的我自己的音频样本,希望每个加载的缓冲区都可以具有正向和反向版本,如下所示:

    function finishedLoading(bufferList)  {
        for (var it = 0; it < this.urlList.length; ++it) {  
            storedBuffer[it] = bufferList[it]; // assign bufferList to globals
            storedBufferR[it] = bufferList[it];

            // attempt to reverse storedBufferR only ...
            Array.prototype.reverse.call( storedBufferR[it].getChannelData(0) );
            Array.prototype.reverse.call( storedBufferR[it].getChannelData(1) ); 
        }
    }
Run Code Online (Sandbox Code Playgroud)

上面的函数确实可以反转播放,但是它可以同时反转'storedbufferR' 和 'storedbuffer',这样所有缓冲区都可以反转!

所以这是我迷路的地方...我知道Array.protoype影响所有数组,所以我想我可以看看'storedBufferR'上的反向方法如何影响'storedBuffer'。编辑:反向方法仅影响所讨论的数组

但是可以重写上面的函数以确保array.protoype仅影响我要反转的存储缓冲区吗?如果不是,是否还有另一种方式可以存储正向和反向版本?

javascript html5 google-chrome audiobuffer web-audio-api

3
推荐指数
1
解决办法
1578
查看次数