我正在尝试使用 three.js 库,它是一个 javascript 3d 库...
所以代码片段是这样的:
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}
}
但它没有显示任何东西?而且我在萤火虫中也没有看到任何错误有什么建议吗?谢谢