我想使用three.js所庫,它是一個JavaScript 3D庫...javascript代碼不工作
因此,代碼片段是這樣的:
var segments = 16, rings = 16;
//var radius = 50; <-- original
// create a new mesh with sphere geometry -
// we will cover the sphereMaterial next!
var scene = new THREE.Scene();
// My read from file snippet.
$.getJSON('sample.json', function(data) {
var radius = data.circles.r;
console.log(radius);
var sphere = new THREE.Mesh(
new THREE.SphereGeometry(radius, segments, rings),
sphereMaterial);
// add the sphere to the scene
scene.add(sphere);
});
// and the camera
scene.add(camera);
所以基本上早些時候代碼..半徑硬編碼(第二行),而不是硬編碼半徑..我正在從json文件中讀取它正在跟蹤?
{
"circles":
{"x":14,"y":2,"z":4,"r":20}
}
但它不顯示任何東西?而且我在螢火蟲中也看不到任何錯誤 有什麼建議嗎? 謝謝
它是否直接爲您工作,沒有JSON調用? – 2013-02-23 22:14:14