我正在尝试创建一个三维星形视图,使用一个可移动的相机来使用three.js遍历星星(js对象)。在搜索某些东西让我开始/开始时,我找到了一些代码(下面)并将其修改为似乎在逻辑上的“#”;正确。代码:
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
var camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 500);
camera.position.set(0, 0, 100);
camera.lookAt(new THREE.Vector3(0, 0, 0));
var scene = new THREE.Scene();
var geometry = new THREE.Geometry();
// Starlist contains 1600+ stars
for (var i=0;i<oldstarlist.length;i++)
{
// Convert RA/DEC to x,y,z coordinates
var s0 = new Star(oldstarlist[i]['starname'], oldstarlist[i]['constellation'], oldstarlist[i]['RA'], oldstarlist[i]['DEC'], oldstarlist[i]['lightyears']);
var star = new THREE.Vector3();
star.x = s0.coordinates.X;
star.y = s0.coordinates.Y;
star.z = s0.coordinates.Z;
console.log(star.x,star.y,star.z);
geometry.vertices.push( star );
}
var starsMaterial = new THREE.PointsMaterial( { color: 0x888888 } );
var starField = new THREE.Points( geometry, starsMaterial );
scene.add( starField );
renderer.render(scene, camera);
我推测这些积分&#39;这是正确的,我仍然不知道在哪里放置相机。可以肯定的是,我查看了我能找到的任何示例和教程,但没有发现与我正在寻找的相似的内容。 可以在我的测试站点区域找到一个工作示例:
http://theangelfallseries.com/stars/sp/test3js.html
感谢任何帮助。