尝试复制此站点上存在的 Three.js 地球仪:
https://trijs.org/examples/misc_controls_fly.html
当我启动代码时出现错误:
starsGeometry[0].setAttribute 不是一个函数,前几天我一直被这样的问题困扰,我很想解决这个问题
我的初始化是这样的:
function init() {
camera = new THREE.PerspectiveCamera(25, SCREEN_WIDTH / SCREEN_HEIGHT, 50,
1e7);
camera.position.z = radius * 5;
scene = new THREE.Scene();
scene.fog = new THREE.FogExp2( 0x000000, 0.00000025 );
dirLight = new THREE.DirectionalLight(0xffffff);
dirLight.position.set(-1, 0, 1).normalize();
scene.add(dirLight);
var materialNormalMap = new THREE.MeshPhongMaterial({
specular: 0x333333,
shininess: 15,
map: textureLoader.load( "textures/planets/earth_atmos_2048.jpg" ),
specularMap: textureLoader.load( "textures/planets/earth_specular_2048.jpg" ),
normalMap: textureLoader.load( "textures/planets/earth_normal_2048.jpg" ),
normalScale: new THREE.Vector2( 0.85, 0.85 )
} );
//planet
geometry = new THREE.SphereBufferGeometry(radius, 100, 50); …Run Code Online (Sandbox Code Playgroud)