geometry = new THREE.SphereGeometry( radius, 100, 50 );
geometry.computeTangents();
meshPlanet = new THREE.Mesh( geometry, materialNormalMap );
meshPlanet.rotation.y = 1.3;
meshPlanet.rotation.z = tilt;
scene.add( meshPlanet );
×îºó¿´Ò»ÏÂÕâ¸öÌí¼Óµ½sceneÀïµÄMeshµÄ×é³Éͼ
2. ½¨ÔÂÇòºÍÔƲãÒ²ÊÇÒÀ·¨ÅÚÖÆ£¬ÔƲãÒòΪÊÇpng¸ñʽËùÒÔÓаë͸Ã÷Ч¹û¡£
3. ´´½¨Æ½Ðйâ
´´½¨Ò»¸ö¹âÕÕÊǺܼòµ¥µÄ£¬tree.jsµÄµÆ¹â¶ÔÏóÖ÷Òª¾ÍÊDZ£´æµÆ¹â²ÎÊýµÄ×÷Ó㬶ø¹âÕÕµÄʵ¼Ê¼ÆËãÊÇ·ÅÔÚshaderÀÎÒÃÇÔÝʱ²»ÓùØÐÄ
dirLight = new THREE.DirectionalLight( 0xFFFFFF );
dirLight.position.set( -1, 0, 1 ).normalize();
scene.add( dirLight );
³¡¾°µÄ»¥¶¯
sampleÖÐÎÒÃÇ¿ÉÒÔʹÓÃÊó±ê¿ØÖÆÉãÏñ»úµÄÐýת£¬three.jsΪÎÒÃÇÌṩһЩ³£ÓõÄÉãÏñ»ú¿ØÖƽӿڣ¬Õâ¸ösampleÀïÓõÄÊǹ켣Çò
controls = new THREE.TrackballControls( camera, renderer.domElement );
controls.rotateSpeed = 1.0;
controls.zoomSpeed = 1.2;
controls.panSpeed = 0.2;
controls.noZoom = false;
controls.noPan = false;
controls.staticMoving = false;
controls.dynamicDampingFactor = 0.3;
controls.minDistance = radius * 1.1;
controls.maxDistance = radius * 100;
ÎÒÃÇ¿ÉÒÔÔÚsrc/extras/controlsÏÂÃæ¿´µ½¼¸¸ö³£ÓõÄÉãÏñ»ú¿ØÖÆ
äÖȾ
ÎÒÃÇ×îºóÀ´¿´¿´renderº¯ÊýÀïµÄ´úÂë
var t = new Date().getTime(),
dt = ( t - time ) / 1000;
time = t;
meshPlanet.rotation.y += rotationSpeed * dt;
meshClouds.rotation.y += 1.25 * rotationSpeed * dt;
var angle = dt * rotationSpeed;
meshMoon.position = new THREE.Vector3(
Math.cos( angle ) * meshMoon.position.x - Math.sin( angle ) * meshMoon.position.z,
0,
Math.sin( angle ) * meshMoon.position.x + Math.cos( angle ) * meshMoon.position.z
);
meshMoon.rotation.y -= angle;
controls.update();
renderer.clear();
renderer.render( scene, camera );
Õâ¸öº¯ÊýÖ÷Òª×öÁËÿһ֡¶¼Òª×öµÄ¼¸¼þÊ£º
×îºórenderº¯ÊýÀïÐèÒªÁ½¸ö²ÎÊý£¬sceneºÍcamera£¬ÎÒÃÇÈç¹û¿´ÏÂrenderÀïµÄ´úÂë»°¾Í¿ÉÒÔÖªµÀ£¬Ã¿´ÎrenderµÄʱºò£¬¶¼ÐèÒª±éÀúÒ»±éscene graph£¬äÖȾÀïÃæÿ¸öÐèÒªäÖȾµÄ¶ÔÏ󣬶øÉãÏñ»úµÄ×÷ÓþÍÖ»ÊÇÌṩһ¸öÊӽDZ任¾ØÕóºÍͶӰ¾ØÕó¡£Õâ¸öÒÔºó¿´WebGLRendererÀïµÄ´úÂëµÄʱºò»á¼ÌÐøÉîÈë¡£
Õâ¸öº¯Êý»áʹÓÃsetInterval¶¨Ê±µ÷Óã¬À´ÊµÏÖ¶¯»µÄЧ¹û¡£
¡¡