特效描述:html5 canvas 月食动画特效。html5月食动画

代码结构

1. 引入JS

2. HTML代码

varying vec3 vNormal; void main() { vNormal = normalize( normalMatrix * normal ); gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }

varying vec3 vNormal; void main() { float intensity = pow( 0.7 - dot( vNormal, vec3( 0.0, 0.0, 0.5 ) ), 4.0 ); gl_FragColor = vec4( 1.3, 1.0, 1.0, 1.0 ) * intensity; }

var renderer, scene, camera, composer, circle, particle, luminor, halo, galaxy;

var lights = [];

window.onload = function() {

init();

animate();

}

function init() {

renderer = new THREE.WebGLRenderer({

antialias: true,

alpha: true

});

renderer.setPixelRatio((window.devicePixelRatio) ? window.devicePixelRatio : 1);

renderer.setSize(window.innerWidth, window.innerHeight);

renderer.autoClear = false;

renderer.setClearColor(0x000000, 0.0);

document.getElementById('canvas').appendChild(renderer.domElement);

scene = new THREE.Scene();

camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 1000);

camera.position.z = 400;

scene.add(camera);

circle = new THREE.Object3D();

particle = new THREE.Object3D();

halo = new THREE.Object3D();

luminor = new THREE.Object3D();

scene.add(circle);

scene.add(particle);

scene.add(halo);

scene.add(luminor);

var geometry = new THREE.TetrahedronGeometry(1, 1);

var geo_planet = new THREE.SphereGeometry(10, 64, 32);

var geom3 = new THREE.SphereGeometry(16, 32, 16);

var geo_star = new THREE.SphereGeometry(90, 64, 64);

var material = new THREE.MeshPhongMaterial({

color: 0x111111,

shading: THREE.FlatShading

});

for (var i = 0; i < 500; i++) {

var mesh = new THREE.Mesh(geometry, material);

mesh.position.set(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5).normalize();

mesh.position.multiplyScalar( 200 + (Math.random() * 500));

mesh.rotation.set(Math.random() * 2, Math.random() * 2, Math.random() * 2);

particle.add(mesh);

}

var mat = new THREE.MeshPhongMaterial({

color: 0xcea3a3,

emissive: 0x000000,

//shading: THREE.FlatShading,

shading : THREE.SmoothShading,

map: THREE.ImageUtils.loadTexture('img/Generic_Celestia_asteroid_texture.jpg'),

bumpMap: THREE.ImageUtils.loadTexture('img/Generic_Celestia_asteroid_texture.jpg'),

bumpScale: 0.025,

specularMap: THREE.ImageUtils.loadTexture('img/Generic_Celestia_asteroid_texture.jpg'),

specular: new THREE.Color('grey')

});

var mat3 = new THREE.ShaderMaterial({

uniforms: {},

vertexShader: document.getElementById('vertexShader').textContent,

fragmentShader: document.getElementById('fragmentShader').textContent,

side: THREE.BackSide,

blending: THREE.AdditiveBlending,

transparent: true

});

var planet = new THREE.Mesh(geo_planet, mat);

planet.scale.x = planet.scale.y = planet.scale.z = 15;

circle.add(planet);

var ball = new THREE.Mesh(geom3, mat3);

ball.scale.x = ball.scale.y = ball.scale.z = 16;

halo.add(ball);

var ball2 = new THREE.Mesh(geom3, mat3);

ball2.scale.x = ball2.scale.y = ball2.scale.z = 12;

ball2.position.set(25,5,1)

halo.add(ball2);

var ambientLight = new THREE.AmbientLight(0x000000);

scene.add(ambientLight);

var hemiLight = new THREE.HemisphereLight(0x000000, 0x1111111, 20);

hemiLight.position.set(-1, -1, 2);

luminor.add(hemiLight);

lights[1] = new THREE.DirectionalLight(0x000000, 7);

lights[1].position.set(-1, 0, 0.5);

lights[2] = new THREE.DirectionalLight(0x000000, 7);

lights[2].position.set(1, 0, 0.5);

scene.add(lights[1]);

scene.add(lights[2]);

window.addEventListener('resize', onWindowResize, false);

};

function onWindowResize() {

camera.aspect = window.innerWidth / window.innerHeight;

camera.updateProjectionMatrix();

renderer.setSize(window.innerWidth, window.innerHeight);

}

function animate() {

var timer = 0.0001 * Date.now();

requestAnimationFrame(animate);

particle.rotation.x += 0.0000;

particle.rotation.y -= 0.0040;

circle.rotation.x -= 0.001;

circle.rotation.y -= 0.001;

halo.rotation.z -= 0.005;

luminor.rotation.z -= 0.005;

//halo.scale.x = Math.sin( timer * 3) * 0.09 + 1;

//halo.scale.y = Math.sin( timer * 7 ) * 0.09 + 1;

renderer.clear();

renderer.render(scene, camera)

};

五十个html js特效动画,html5 canvas酷炫的月食动画特效相关推荐

  1. 表白html特效在线,html5 canvas酷炫表白爱心动画特效

    特效描述:酷炫表白动画 表白爱心动画 动画特效.html5爱心动画 代码结构 1. 引入JS 2. HTML代码 var container; var camera, scene, renderer; ...

  2. android 漩涡动画,html5 canvas酷炫的粒子漩涡动画特效

    特效描述:html5 canvas 粒子漩涡 动画特效.html5粒子漩涡动画,酷炫的粒子动画特效 代码结构 1. HTML代码 function project3D(x,y,z,vars){ var ...

  3. html5 canvas酷炫3D背景打开动画特效

    html5 canvas酷炫3D背景打开动画特效 点击跳转到演示地址 点击进入资源下载地址

  4. html5 canvas 烟花,html5 canvas酷炫的烟花爆炸动画特效

    特效描述:html5canvas 酷炫的 烟花爆炸动画特效.html5点击页面烟花爆炸动画,3D烟花动画,酷炫的烟花特效. 代码结构 1. 引入JS 2. HTML代码 点击页面 (function( ...

  5. android气球上升的属性动画,html5 canvas告白气球上升背景动画特效

    特效描述:html5 canvas 告白气球上升 背景动画特效.html5基于canvas绘制各种卡通气球上升动画.告白气球背景动画特效. 代码结构 1. 引入JS 2. HTML代码 Balloon ...

  6. html飞机动画,html5 canvas纸飞机跟随鼠标飞行动画

    这是一款效果很酷的html5 canvas纸飞机跟随鼠标飞行动画.插件中使用了paper.js来构建场景中的各种元素. HTML html结构只需要一个canvas,并给它一个id triangle- ...

  7. 动态打字效果 html,html5 svg酷炫的打字动画特效

    特效描述:html5 svg打字动画特效.html5 svg在input文本框里面输入文字,酷炫的动态打字动画特效. 代码结构 1. 引入CSS 2. 引入JS 3. HTML代码 const sel ...

  8. 用html语言制作表白动画,HTML5 Canvas程序员经典爱情表白动画

    JavaScript 语言: JaveScriptBabelCoffeeScript 确定 var $window = $(window), gardenCtx, gardenCanvas, $gar ...

  9. HTML+CSS+JS实现 ❤️canvas酷炫表白爱心动画❤️

最新文章

  1. 在 RedHat 使用 gdc-client 下载 TCGA 数据
  2. python的range()函数用法
  3. report service常见处理办法
  4. spring和mybatis结合做简单的增删查改系统_如何从零开始设计权限管理系统
  5. P6177-Count on a tree II/[模板]树分块
  6. android 遍历所有view,Android 算法:遍历ViewGroup找出所有子View
  7. linq to entity 错误 1 错误 75: 类型 视图名称 的键部分 “主键的列名1”无效。该键的所有部分都必须不可以为 null。(转)...
  8. 第五章 运输层[练习题+课后习题]
  9. 在办公室说话要注意哪些?
  10. linux 跨网段ping,Linux中跨网段ping问题
  11. Android VLc编译
  12. ORACLE 碎片整理小结
  13. RK3288 android添加HAL 层导致无法进入主界面原因分析,重复打印 camsys_marvin(deaa1510) is closed
  14. xml遍历文件夹vector_怎么统计指定文件夹下含有.xml格式的文件数目
  15. /?、//、/'……等等是一个字符
  16. 可以重写static方法和private方法吗
  17. CMS漏洞复现小结--沙窝李的王
  18. openwrt+php+not+found,openwrt搜不到wifi
  19. 任何计算机病毒一定会有清楚的办法,计算机病毒及其防治等级考试练习题
  20. 各路厂商花式入局,打开元宇宙的正确方式究竟是?

热门文章

  1. 如何在HTML5页面中使用鼠标滚轮事件
  2. HTML+CSS+JavaScript制作浪漫烟花告白(程序员撩妹手到擒来~)
  3. SDNU__1025.马踏飞燕
  4. 2021-2027全球与中国实验室通风系统市场现状及未来发展趋势
  5. Android 7.0 以后抛出的 android.os.TransactionTooLargeException 异常
  6. 周鸿祎的“寄生战略”
  7. 名帖209 赵孟頫 行书《千字文》
  8. Janet八股文集锦
  9. 小米12 Pro天玑版游戏实测成绩太顶了,首发天玑9000+赚大了
  10. HDU 4499 DFS