HTML5¼¼Êõ

THREE.js ѧϰ±Ê¼Ç£¨Ò»£© - jerrylsxu(2)

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£º²©¿ÍÔ° 2016-06-03 16:00 ÎÒÒªÆÀÂÛ( )

geometry = new THREE.SphereGeometry( radius, 100, 50 ); geometry.computeTangents(); meshPlanet = new THREE.Mesh( geometry, materialNormalMap ); meshPlanet.rotation.y = 1.3; meshPlanet.rotation.z = ti

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

 

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¶¨Ê±µ÷Óã¬À´ÊµÏÖ¶¯»­µÄЧ¹û¡£

¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • HTTPЭÒéѧϰËæ±Ê - ÌÇ´×ËáÀ±½·

    HTTPЭÒéѧϰËæ±Ê - ÌÇ´×ËáÀ±½·

    2017-05-01 18:03

  • ¡¾reactѧϰ¡¿¹ØÓÚreact¿ò¼ÜʹÓõÄһЩϸ½ÚÒªµãµÄ˼¿¼ - ÍâÆŵÄÅíºþÍå

    ¡¾reactѧϰ¡¿¹ØÓÚreact¿ò¼ÜʹÓõÄһЩϸ½ÚÒªµãµÄ˼¿¼ - ÍâÆŵÄÅíºþ

    2017-04-16 18:00

  • ¼ÆËã»úÍøÂ硪¡ªDNSЭÒéµÄѧϰÓëʵÏÖ - ѧÊýѧµÄ³ÌÐòÔ³

    ¼ÆËã»úÍøÂ硪¡ªDNSЭÒéµÄѧϰÓëʵÏÖ - ѧÊýѧµÄ³ÌÐòÔ³

    2017-04-16 10:00

  • ASP.NET Core MVC Ô´Âëѧϰ£ºÏê½â Action µÄ¼¤»î - Savorboard

    ASP.NET Core MVC Ô´Âëѧϰ£ºÏê½â Action µÄ¼¤»î - Savorboard

    2017-04-14 13:04

ÍøÓѵãÆÀ
Ç