javascript3dライブラリであるthree.jsライブラリを使用しようとしています...
したがって、コードスニペットは次のとおりです。
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);
したがって、基本的に以前のこのコード..半径はハードコーディングされていました(2行目)が、半径をハードコーディングする代わりに..次のjsonファイルから読み取っていますか?
{
"circles":
{"x":14,"y":2,"z":4,"r":20}
}
しかし、それは何も表示しませんか?また、firebugにもエラーは表示されません。何か提案はありますか?ありがとう