2012-02-28 2 views
1

非常に不安定なマウス座標でオブジェクトを特定するために、私は1つまたは2つ以上飛び越して、広範囲のベクトルインデックスを使用しました。しかし、これは私のベクトルに6000かそこらの値のためのスペースを割り当てることを意味しますか?それは何かを遅くするか?それともOKですか?javascript配列の効率

// ---- starting position ---- 
    mouse.x  = screen.w/2; 
    mouse.xd  = mouse.x; 
    camera.x  = scene.startX || 0; 
    camera.z  = scene.startZ || 0; 
    camera.targetX = scene.targetX || 0; 
    camera.targetZ = scene.targetZ || 0; 
    var picIndex=new Array(1,101,2101,4101,4401,5401,6401,6301,2301,2001); // pics position in room 
    var myPics=new Array(); // 
    myPics[1]="This is picture 1"; // 
    myPics[101]="This is picture 2"; 
    myPics[2101]="This is picture 3"; 
    myPics[4101]="This is picture 4"; 
    myPics[4401]="This is picture 5"; 
    myPics[5401]="This is picture 6"; 
    myPics[6401]="This is picture 7"; 
    myPics[6301]="This is picture 8"; 
    myPics[2301]="This is picture 9"; 
    myPics[2001]="This is picture 10"; 


    // then show picture identification 


    setInterval(function() { 
    uniqueID = (camera.targetZ*2)+camera.targetX+3201; 
    showInfo = document.getElementById('dynamic_info'); 
    showInfo.innerHTML = myPics[uniqueID] ; 
     //document.getElementById('dynamic_info2').innerHTML = camera.targetX ; 
     //document.getElementById('dynamic_info3').innerHTML = uniqueID; 
     //document.getElementById('dynamic_info4').innerHTML = camera.z ; 
     //document.getElementById('npoly').innerHTML = npoly * 2; 
     //fps = 0; 
     //npoly = 0; 
    }, 500); // update every 0.5 seconds 
+0

プディングのプルーフです。一般に、合理的な間隔でユーザー入力をサンプリングすることは許容される方法ですが、試してみるかどうかは、試してみるときに起こります。 – HackedByChinese

+0

サンプリングはこれまでのところ問題ではありませんでした - 私は配列[link](http://mindprints.org)を心配していました。 – Mindprints

答えて

関連する問題