0

ドゥーブ氏は、サークルを作るための彼のフォーラム/サイトにこれを追加しました

var resolution = 100;
var amplitude = 100;
var size = 360 / resolution;

var geometry = new THREE.Geometry();
var material = new THREE.LineBasicMaterial( { color: 0xFFFFFF, opacity: 1.0} );
for(var i = 0; i <= resolution; i++) {
    var segment = ( i * size ) * Math.PI / 180;
    geometry.vertices.push( new THREE.Vertex( new THREE.Vector3( Math.cos( segment ) * amplitude, 0, Math.sin( segment ) * amplitude ) ) );         
}

var line = new THREE.Line( geometry, material );
scene.add(line);

作成したいくつかの円を削除したいのですが、「 scene.remove(line) 」を使用してもうまくいきません...

PS

これは私のコードの一部で、1秒間円を作成した後、再びそれを取り除きたい.

 var feetcircle;
        var resolution = 100;
        var amplitude = 140;
        var size = 360 / resolution;

        var geometry = new THREE.Geometry();
        var material = new THREE.LineBasicMaterial({
            color: 0x00FF00,
            opacity: 1.0
        });




        for (var i = 0; i <= resolution; i++) {
            var segment = (i * size) * Math.PI / 180;
            geometry.vertices.push(new THREE.Vertex(new THREE.Vector3((Math.cos(segment) * amplitude) +  (moves[move][move + '_mrfoot0'][0][0] * scale)-30, 0, (Math.sin(segment) * amplitude) + 375)));
        }

        for (var i = 0; i <= resolution; i++) {
            var segment = (i * size) * Math.PI / 180;
            geometry.vertices.push(new THREE.Vertex(new THREE.Vector3((Math.cos(segment) * amplitude) +  (moves[move][move + '_mrfoot0'][0][0] * scale)-30, 410, (Math.sin(segment) * amplitude) + 375)));
        }

        for (var i = 0; i <= resolution; i++) {
            var segment = (i * size) * Math.PI / 180;
            geometry.vertices.push(new THREE.Vertex(new THREE.Vector3((Math.cos(segment) * amplitude) +  (moves[move][move + '_mrfoot0'][0][0] * scale)-30, 285, (Math.sin(segment) * amplitude) + 375)));
        }


        feetcircle = new THREE.Line(geometry, new THREE.LineBasicMaterial({
            color: 0x00ff00, opacity: 1.0
        }));
        feetcircle.geometry.dynamic = true;
        scene.add(feetcircle);
4

1 に答える 1

0

個々のオブジェクトを追加していません。これらの頂点はすべて同じオブジェクトに属しているため、単純に削除することはできません。代わりに行う必要があるのは次のとおりです。

    for (var i = 0; i <= resolution; i++) {
        var segment = (i * size) * Math.PI / 180;
        geometry.vertices.push(new THREE.Vertex(new THREE.Vector3((Math.cos(segment) * amplitude) +  (moves[move][move + '_mrfoot0'][0][0] * scale)-30, 0, (Math.sin(segment) * amplitude) + 375)));
    }

    feetcircle = new THREE.Line(geometry, new THREE.LineBasicMaterial({
        color: 0x00ff00, opacity: 1.0
    }));
    feetcircle.geometry.dynamic = true;
    scene.add(feetcircle);

    geometry = new THREE.Geometry();
    for (var i = 0; i <= resolution; i++) {
        var segment = (i * size) * Math.PI / 180;
        geometry.vertices.push(new THREE.Vertex(new THREE.Vector3((Math.cos(segment) * amplitude) +  (moves[move][move + '_mrfoot0'][0][0] * scale)-30, 410, (Math.sin(segment) * amplitude) + 375)));
    }

    var feetcircle2 = new THREE.Line(geometry, new THREE.LineBasicMaterial({
        color: 0x00ff00, opacity: 1.0
    }));
    feetcircle2.geometry.dynamic = true;
    scene.add(feetcircle2);

    ...
    scene.remove(feetcircle);
    scene.remove(feetcircle2);

など...もちろん、実際にそれらを削除できるようにしたい場合は、それらに個別の変数名を付けるか、配列に入れます。

var circles = new Array();

for (int i = 0; i < 3; i++)
{
    geometry = new THREE.Geometry();
    for (var j = 0;j <= resolution; j++) {
            var segment = (j* size) * Math.PI / 180;
            geometry.vertices.push(new THREE.Vertex(new THREE.Vector3((Math.cos(segment) * amplitude) +  (moves[move][move + '_mrfoot0'][0][0] * scale)-30, 410, (Math.sin(segment) * amplitude) + 375)));
    }
    feetcircle = new THREE.Line(geometry, new THREE.LineBasicMaterial({
        color: 0x00ff00, opacity: 1.0
    }));
    feetcircle.geometry.dynamic = true;
    circles.push(feetcircle);
    scene.add(circles[i]);
}

for (int i = 0; i < circles.length; i++)
     scene.remove(circles[i]);
于 2013-05-07T04:10:36.947 に答える