这是一款基于HTML5和CSS3的3D动画特效,与之前的3D特效不同的是,这款是完全用HTML5特性实现的,而并非用多张图片叠加起来。这款3D动画还有一个特点是可以无限的旋转,从而可以从多个视角来观察HTML5 Logo。
在线演示 源码下载
HTML代码
XML/HTML Code复制内容到剪贴板- <div class="link-overlay">
- </div>
- <canvas id="canvas" style="background-color:#ddd"></canvas>
JavaScript代码
JavaScript Code复制内容到剪贴板- // bind to window onload handler
- window.addEventListener('load', onloadHandler, false);
- /**
- * Window onload handler
- */
- function onloadHandler()
- {
- var canvas = document.getElementById('canvas');
- canvas.width = window.innerWidth;
- canvas.height = window.innerHeight;
- var k3dmain = new K3D.Controller(canvas, true);
- // generate 3D objects
- var obj1 = new K3D.K3DObject();
- with (obj1)
- {
- drawmode = "solid";
- shademode = "lightsource";
- sortmode = "unsorted";
- addphi = -0.5;
- abouty = -90;
- perslevel = 1000;
- init(
- [{x:-80,y:180,z:0},{x:0,y:180,z:-80},{x:0,y:0,z:-80},{x:-80,y:20,z:0},{x:-50,y:150,z:-30},{x:0,y:150,z:-80},{x:0,y:130,z:-80},{x:-30,y:130,z:-50},{x:-28,y:110,z:-52},{x:0,y:110,z:-80},{x:0,y:90,z:-80},{x:-45,y:90,z:-35},{x:-44,y:80,z:-36},{x:-25,y:80,z:-55},{x:-22,y:66,z:-58},{x:0,y:60,z:-80},{x:0,y:40,z:-80},{x:-40,y:50,z:-40}],
- [],
- [{color:[227,76,38],vertices:[0,1,2,3,0]},{color:[235,235,235],vertices:[4,5,6,7,8,9,10,11,4]},{color:[235,235,235],vertices:[12,13,14,15,16,17,12]}]
- );
- }
- k3dmain.addK3DObject(obj1);
- var obj2 = new K3D.K3DObject();
- with (obj2)
- {
- drawmode = "solid";
- shademode = "lightsource";
- sortmode = "unsorted";
- addphi = -0.5;
- abouty = -90;
- perslevel = 1000;
- init(
- [{x:0,y:180,z:-80},{x:80,y:180,z:0},{x:80,y:20,z:0},{x:0,y:0,z:-80},{x:0,y:165,z:-80},{x:68,y:165,z:-12},{x:55,y:35,z:-25},{x:0,y:20,z:-80},{x:0,y:150,z:-80},{x:50,y:150,z:-30},{x:47,y:130,z:-33},{x:0,y:130,z:-80},{x:0,y:110,z:-80},{x:45,y:110,z:-35},{x:40,y:50,z:-40},{x:0,y:40,z:-80},{x:0,y:60,z:-80},{x:20,y:66,z:-60},{x:23,y:90,z:-57},{x:0,y:90,z:-80}],
- [],
- [{color:[227,76,38],vertices:[0,1,2,3,0]},{color:[240,101,41],vertices:[4,5,6,7,4]},{color:[235,235,235],vertices:[8,9,10,11,8]},{color:[235,235,235],vertices:[12,13,14,15,16,17,18,19,12]}]
- );
- }
- k3dmain.addK3DObject(obj2);
- var obj3 = new K3D.K3DObject();
- with (obj3)
- {
- drawmode = "solid";
- shademode = "lightsource";
- sortmode = "unsorted";
- addphi = -0.5;
- abouty = -90;
- perslevel = 1000;
- init(
- [{x:80,y:180,z:0},{x:0,y:180,z:80},{x:0,y:0,z:80},{x:80,y:20,z:0},{x:50,y:150,z:30},{x:0,y:150,z:80},{x:0,y:130,z:80},{x:30,y:130,z:50},{x:28,y:110,z:52},{x:0,y:110,z:80},{x:0,y:90,z:80},{x:45,y:90,z:35},{x:44,y:80,z:36},{x:25,y:80,z:55},{x:22,y:66,z:58},{x:0,y:60,z:80},{x:0,y:40,z:80},{x:40,y:50,z:40}],
- [],
- [{color:[227,76,38],vertices:[0,1,2,3,0]},{color:[235,235,235],vertices:[4,5,6,7,8,9,10,11,4]},{color:[235,235,235],vertices:[12,13,14,15,16,17,12]}]
- );
- }
- k3dmain.addK3DObject(obj3);
- var obj4 = new K3D.K3DObject();
- with (obj4)
- {
- drawmode = "solid";
- shademode = "lightsource";
- sortmode = "unsorted";
- addphi = -0.5;
- abouty = -90;
- perslevel = 1000;
- init(
- [{x:0,y:180,z:80},{x:-80,y:180,z:0},{x:-80,y:20,z:0},{x:0,y:0,z:80},{x:0,y:165,z:80},{x:-68,y:165,z:12},{x:-55,y:35,z:25},{x:0,y:20,z:80},{x:0,y:150,z:80},{x:-50,y:150,z:30},{x:-47,y:130,z:33},{x:0,y:130,z:80},{x:0,y:110,z:80},{x:-45,y:110,z:35},{x:-40,y:50,z:40},{x:0,y:40,z:80},{x:0,y:60,z:80},{x:-20,y:66,z:60},{x:-23,y:90,z:57},{x:0,y:90,z:80}],
- [],
- [{color:[227,76,38],vertices:[0,1,2,3,0]},{color:[240,101,41],vertices:[4,5,6,7,4]},{color:[235,235,235],vertices:[8,9,10,11,8]},{color:[235,235,235],vertices:[12,13,14,15,16,17,18,19,12]}]
- );
- }
- k3dmain.addK3DObject(obj4);
- var objBase = new K3D.K3DObject();
- with (objBase)
- {
- drawmode = "solid";
- shademode = "lightsource";
- sortmode = "unsorted";
- addphi = -0.5;
- abouty = -90;
- perslevel = 1000;
- init(
- [{x:0,y:0,z:-80},{x:-80,y:20,z:0},{x:0,y:0,z:80},{x:80,y:20,z:0}],
- [],
- [{color:[227,76,38],vertices:[0,2,1,0]},{color:[227,76,38],vertices:[0,3,2,0]}]
- );
- }
- k3dmain.addK3DObject(objBase);
- var objHtml = new K3D.K3DObject();
- with (objHtml)
- {
- drawmode = "solid";
- shademode = "lightsource";
- //sortmode = "unsorted";
- color = [64,64,64];
- doublesided = true;
- addphi = -0.5;
- abouty = 100;
- scale = 0.75;
- perslevel = 1000;
- init(
- [{x:-80,y:40,z:0},{x:-70,y:40,z:0},{x:-70,y:30,z:0},{x:-60,y:30,z:0},{x:-60,y:40,z:0},{x:-50,y:40,z:0},{x:-50,y:10,z:0},{x:-60,y:10,z:0},{x:-60,y:20,z:0},{x:-70,y:20,z:0},{x:-70,y:10,z:0},{x:-80,y:10,z:0},{x:-40,y:40,z:0},{x:-10,y:40,z:0},{x:-10,y:30,z:0},{x:-20,y:30,z:0},{x:-20,y:10,z:0},{x:-30,y:10,z:0},{x:-30,y:30,z:0},{x:-40,y:30,z:0},{x:0,y:40,z:0},{x:10,y:40,z:0},{x:20,y:30,z:0},{x:30,y:40,z:0},{x:40,y:40,z:0},{x:40,y:10,z:0},{x:30,y:10,z:0},{x:30,y:30,z:0},{x:20,y:20,z:0},{x:10,y:30,z:0},{x:10,y:10,z:0},{x:0,y:10,z:0},{x:50,y:40,z:0},{x:60,y:40,z:0},{x:60,y:20,z:0},{x:80,y:20,z:0},{x:80,y:10,z:0},{x:50,y:10,z:0}],
- [],
- [{vertices:[0,1,2,3,4,5,6,7,8,9,10,11,0]},{vertices:[12,13,14,15,16,17,18,19,12]},{vertices:[20,21,22,23,24,25,26,27,28,29,30,31,20]},{vertices:[32,33,34,35,36,37,32]}]
- );
- }
- k3dmain.addK3DObject(objHtml);
- // add render loop callback
- var ctx = canvas.getContext('2d');
- var rotationOffset = 0;
- var len = (canvas.height > canvas.width ? canvas.height : canvas.width) * 0.7;
- k3dmain.clearBackground = false;
- k3dmain.callback = function()
- {
- // manually clear bg - as we want to render some extra goodies
- ctx.clearRect(0, 0, canvas.width, canvas.height);
- // draw bg effect before K3D does its 3D rendering
- ctx.save();
- ctx.translate(canvas.width/2, canvas.height/2);
- ctx.rotate(rotationOffset);
- // first fill pass - outer rays
- var RAYCOUNT = 24;
- ctx.fillStyle = "#eee";
- ctx.beginPath();
- for (var i=0; i<RAYCOUNT; i++)
- {
- // rotate context
- ctx.rotate(TWOPI / RAYCOUNT);
- ctx.moveTo(0, 0);
- ctx.lineTo(-20, len);
- ctx.lineTo(20, len);
- }
- ctx.closePath();
- ctx.fill();
- // second fill pass - inner rays
- ctx.fillStyle = "#fff";
- ctx.beginPath();
- for (var i=0; i<RAYCOUNT; i++)
- {
- // rotate context
- ctx.rotate(TWOPI / RAYCOUNT);
- ctx.moveTo(0, 0);
- ctx.lineTo(-15, len);
- ctx.lineTo(15, len);
- }
- ctx.closePath();
- ctx.fill();
- ctx.restore();
- rotationOffset += 0.005;
- // apply user interaction to rotation
- for (var i=0, objs=k3dmain.objects; i<objs.length; i++)
- {
- objs[i].ophi += targetRotationX;
- }
- if (targetRotationX > -0.5) targetRotationX -= 0.05;
- else if (targetRotationX < -0.55) targetRotationX += 0.05;
- if (targetRotationX > -0.55 && targetRotationX < -0.5) targetRotationX = -0.5;
- };
- // start demo loop
- k3dmain.paused = true;
- setInterval(function(){k3dmain.tick()}, 1000/60);
- }
- // nifty drag/touch event capture code borrowed from Mr Doob http://mrdoob.com/
- var targetRotationX = 0;
- var targetRotationOnMouseDownX = 0;
- var mouseX = 0;
- var mouseXOnMouseDown = 0;
- var targetRotationY = 0;
- var targetRotationOnMouseDownY = 0;
- var mouseY = 0;
- var mouseYOnMouseDown = 0;
- var windowHalfX = window.innerWidth / 2;
- var windowHalfY = window.innerHeight / 2;
- document.addEventListener('mousedown', onDocumentMouseDown, false);
- document.addEventListener('touchstart', onDocumentTouchStart, false);
- document.addEventListener('touchmove', onDocumentTouchMove, false);
- function onDocumentMouseDown( event ) {
- event.preventDefault();
- document.addEventListener('mousemove', onDocumentMouseMove, false);
- document.addEventListener('mouseup', onDocumentMouseUp, false);
- document.addEventListener('mouseout', onDocumentMouseOut, false);
- mouseXOnMouseDown = event.clientX - windowHalfX;
- targetRotationOnMouseDownX = targetRotationX;
- mouseYOnMouseDown = event.clientY - windowHalfY;
- targetRotationOnMouseDownY = targetRotationY;
- }
- function onDocumentMouseMove( event )
- {
- mouseX = event.clientX - windowHalfX;
- targetRotationX = targetRotationOnMouseDownX + (mouseX - mouseXOnMouseDown) * 0.02;
- mouseY = event.clientY - windowHalfY;
- targetRotationY = targetRotationOnMouseDownY + (mouseY - mouseYOnMouseDown) * 0.02;
- }
- function onDocumentMouseUp( event )
- {
- document.removeEventListener('mousemove', onDocumentMouseMove, false);
- document.removeEventListener('mouseup', onDocumentMouseUp, false);
- document.removeEventListener('mouseout', onDocumentMouseOut, false);
- }
- function onDocumentMouseOut( event )
- {
- document.removeEventListener('mousemove', onDocumentMouseMove, false);
- document.removeEventListener('mouseup', onDocumentMouseUp, false);
- document.removeEventListener('mouseout', onDocumentMouseOut, false);
- }
- function onDocumentTouchStart( event )
- {
- if (event.touches.length == 1)
- {
- event.preventDefault();
- mouseXOnMouseDown = event.touches[0].pageX - windowHalfX;
- targetRotationOnMouseDownX = targetRotationX;
- mouseYOnMouseDown = event.touches[0].pageY - windowHalfY;
- targetRotationOnMouseDownY = targetRotationY;
- }
- }
- function onDocumentTouchMove( event )
- {
- if (event.touches.length == 1)
- {
- event.preventDefault();
- mouseX = event.touches[0].pageX - windowHalfX;
- targetRotationX = targetRotationOnMouseDownX + (mouseX - mouseXOnMouseDown) * 0.05;
- mouseY = event.touches[0].pageY - windowHalfY;
- targetRotationY = targetRotationOnMouseDownY + (mouseX - mouseYOnMouseDown) * 0.05;
- }
- }
以上就是本文的全部内容,希望对大家的学习有所帮助。
标签:
HTML5,Logo,3D旋转
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
暂无“多视角3D可旋转的HTML5 Logo动画”评论...
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。
更新动态
20240901
20240901
- 《庄心妍 实力唱将 发烧音乐精选集》[WAV+CUE][380MB]
- [音展纪念碟]2006年《TAA台湾第十六届国际HI-ENDHI-FI音响展》2cd[WAV]
- 中国音乐地图之听见西藏山歌牧歌酒歌2020[WAV分轨]
- 王宏伟2017-永远的红飘带[太平洋影音][WAV+CUE]
- 费翔.1997-NOW现在【第一中国】【WAV+CUE】
- 新格合唱团.1981-我唱你和2辑(滚石新格民歌系列)【新格】【WAV+CUE】
- 陈柏宇.2011-QUINQUENNIUM【SONY】【WAV+CUE】
- 雨果唱片-《金唛系列-蔷薇依韵琼瑶》WAV
- 陈百强《凝望(2012华纳LPCD45限量版)[DMI]》[WAV整轨]
- 模拟之声慢刻CD《徐小凤45周年》[德国母带][低速原抓WAV+CUE]
- 《庄心妍 实力唱将 发烧音乐精选集》[WAV+CUE][380MB]
- 《王菲 单曲合集》[FlAC/分轨][520MB]
- 《费玉清 原味再现 水长流》[WAV+CUE][430MB]
- 群星.1992-畅销榜老歌金曲10CD【风格】【WAV+CUE】
- 孙悦.2024-时光音乐会【金蜂】【WAV+CUE】