0
在使用JSON加載器加載模型時,我在Chrome和Safari中看到了不同的結果。在Safari中,以下代碼一次加載1000個模型,而在Chrome中它們在大約20秒內逐一加載。我想讓他們在Chrome中同時出現,有什麼想法?在ThreeJS JSON中加載模型
// Add Models
for(var i = 0; i < noOfMeshesToBuild;i++){
var object;
var loaderJ = new THREE.JSONLoader();
loaderJ.load(meshNames[Math.floor(Math.random() * meshNames.length)], function (geometry, materials) {
// Workaround to make faces flat shaded with lambert material
geometry.computeFaceNormals();
for (var i = 0; i < geometry.faces.length; i ++) {
geometry.faces[ i ].vertexNormals = [];
}
geometry = new THREE.BufferGeometry().fromGeometry(geometry);
// Add objects to scene, array
object = new THREE.Mesh(geometry, new THREE.MeshLambertMaterial()); // this makes a new material for each object
theLoadedMeshes.push(object);
scene.add(object);
// Randomise stuff
RandomisePosition(object);
RandomiseRotation(object);
RandomiseScale(object);
RandomiseColors(object);
// Add edges
edge = new THREE.EdgesHelper(object, edgeColor, 5.0);
edge.material.linewidth = 1;
scene.add(edge);
//Add direction, distance to translate the objects
var transAmount = 1.0/(object.scale.x + Math.random()) * masterSpeed;
var posMin = [-1,1];
var direction = Math.floor(Math.random()+ 0.5);
var posMinChoice = posMin[Math.floor(Math.random() * posMin.length)];
transArray.push(transAmount);
directionArray.push(direction);
posMinArray.push(posMinChoice);
});
}
如何在瀏覽器控制檯查看網絡選項卡?您可以通過返回JSON中的多個模型來避免與同一主機並行執行一千個請求嗎? – Kenney
謝謝你指點我正確的方向! – wxxhrt