我想使用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