I recently downloaded three.js and tried creating an earth in the universe. It's all working quite good, but when I try to put a texture on my Sphere, nothing happens, except, I'm not seeing the Sphere anymore... I tried finding a solution here and on other websites, but nothing is working :-/
我最近下载了三个.js并尝试在宇宙中创建一个地球。这一切都很好,但是当我尝试在我的球体上放置纹理时,没有任何反应,除了,我不再看到球体了......我试图在这里和其他网站上找到解决方案,但没有任何工作: - /
Please guys, help me. I ran out of ideas and this is making me going crazy :D
请伙计们,帮助我。我的想法用完了,这让我发疯了:D
This is the code, where I'm stuck on:
这是代码,我坚持下去:
var geometry = new THREE.SphereGeometry(0.5, 32, 32);
var material = new THREE.MeshPhongMaterial({
color: 0x4682B4,
map: THREE.ImageUtils.loadTexture('2_no_clouds_16k_002.jpg', {}),
bumpMap: THREE.ImageUtils.loadTexture('elev_bump_16k_002.jpg'),
specularMap: THREE.ImageUtils.loadTexture('water_16k_002.jpg'),
specular: new THREE.Color('grey')
});
var mesh = new THREE.MeshPhongMaterial({
color: new THREE.Color('red'),
wireframe: true
});
var sphere = new THREE.Mesh(geometry, material);
var earthMesh = new THREE.Mesh(geometry, mesh);
scene.add(sphere);
scene.add(earthMesh);
//--- Renderer --
function render
{
requestAnimationFrame(render);
sphere.rotation.y = + new Date() / 7000; //movement is added
renderer.render(scene, camera);
}
render();
1 个解决方案
#1
0
I found out, why it didn't work. First of all, the images were indeed too big. Also it was in jpg, which it just didn't want to work with (I don't know why...) Instead I used png. Also it's working on my server, but not locally. Which I also don't know why :D Sometimes I think my computer has it's own mind... Like in iRobot :-D
我发现了,为什么它不起作用。首先,图像确实太大了。它也是在jpg,它只是不想与之合作(我不知道为什么......)而是我使用了png。它也在我的服务器上工作,但不在本地。其中我也不知道为什么:D有时我认为我的电脑有自己的想法...就像在iRobot中:-D
Thank you guys for trying to help! You are the best <3 Cheers, Vicky
谢谢你们试图帮助!你是最好的<3干杯,Vicky
#1
0
I found out, why it didn't work. First of all, the images were indeed too big. Also it was in jpg, which it just didn't want to work with (I don't know why...) Instead I used png. Also it's working on my server, but not locally. Which I also don't know why :D Sometimes I think my computer has it's own mind... Like in iRobot :-D
我发现了,为什么它不起作用。首先,图像确实太大了。它也是在jpg,它只是不想与之合作(我不知道为什么......)而是我使用了png。它也在我的服务器上工作,但不在本地。其中我也不知道为什么:D有时我认为我的电脑有自己的想法...就像在iRobot中:-D
Thank you guys for trying to help! You are the best <3 Cheers, Vicky
谢谢你们试图帮助!你是最好的<3干杯,Vicky