HTML5와 CSS3를 기반으로 한 3D 애니메이션 특수효과입니다. 기존의 3D 특수효과와 달리 여러 장의 사진을 겹쳐놓는 방식이 아닌 HTML5 기능을 완벽하게 구현한 것입니다. 이 3D 애니메이션의 또 다른 특징은 무한히 회전할 수 있어 HTML5 로고를 다양한 관점에서 관찰할 수 있다는 것입니다.
JavaScript 코드클립보드에 콘텐츠 복사
-
-
window.addEventListener('load', onloadHandler, false);
-
-
-
-
-
함수 onloadHandler()
-
{
-
var canvas = document.getElementById('canvas');
-
canvas.width = window.innerWidth;
-
canvas.height = window.innerHeight;
-
var k3dmain = new K3D.Controller(canvas, true );
-
-
-
-
var obj1 = new K3D.K3DObject();
-
함께 (obj1)
-
{
-
그리기 모드 = "단색";
-
쉐이드 모드 = "광원";
-
정렬 모드 = "정렬되지 않음";
-
addphi = -0.5;
-
abouty = -90;
-
perlevel = 1000;
-
초기화(
-
[{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}],
-
[],
-
[{색상:[227,76,38], 꼭지점:[0,1,2,3,0]},{색상:[235,235,235], 꼭지점:[4,5,6,7 ,8,9,10,11,4]},{색상:[235,235,235], 꼭짓점:[12,13,14,15,16,17,12]}]
-
);
-
}
-
k3dmain.addK3DObject(obj1);
-
-
var obj2 = new K3D.K3DObject();
-
함께 (obj2)
-
{
-
그리기 모드 = "단색";
-
쉐이드 모드 = "광원";
-
정렬 모드 = "정렬되지 않음";
-
addphi = -0.5;
-
abouty = -90;
-
perlevel = 1000;
-
초기화(
-
[{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}],
-
[],
-
[{색상:[227,76,38], 꼭지점:[0,1,2,3,0]},{색상:[240,101,41], 꼭지점:[4,5,6 ,7,4]},{색상:[235,235,235], 꼭지점:[8,9,10,11,8]},{색상:[235,235,235], 꼭지점:[12,13,14,15,16,17 ,18,19,12]}]
-
);
-
}
-
k3dmain.addK3DObject(obj2);
-
-
var obj3 = new K3D.K3DObject();
-
함께 (obj3)
-
{
-
그리기 모드 = "단색";
-
쉐이드 모드 = "광원";
-
정렬 모드 = "정렬되지 않음";
-
addphi = -0.5;
-
abouty = -90;
-
perlevel = 1000;
-
초기화(
-
[{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}],
-
[],
-
[{색상:[227,76,38], 꼭지점:[0,1,2,3,0]},{색상:[235,235,235], 꼭지점:[4,5,6,7 ,8,9,10,11,4]},{색상:[235,235,235], 꼭짓점:[12,13,14,15,16,17,12]}]
-
);
-
}
-
k3dmain.addK3DObject(obj3);
-
-
var obj4 = new K3D.K3DObject();
-
함께 (obj4)
-
{
-
그리기 모드 = "단색";
-
쉐이드 모드 = "광원";
-
정렬 모드 = "정렬되지 않음";
-
addphi = -0.5;
-
abouty = -90;
-
perlevel = 1000;
-
초기화(
-
[{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}],
-
[],
-
[{색상:[227,76,38], 꼭지점:[0,1,2,3,0]},{색상:[240,101,41], 꼭지점:[4,5,6 ,7,4]},{색상:[235,235,235], 꼭지점:[8,9,10,11,8]},{색상:[235,235,235], 꼭지점:[12,13,14,15,16,17 ,18,19,12]}]
-
);
-
}
-
k3dmain.addK3DObject(obj4);
-
-
var objBase = new K3D.K3DObject();
-
with (objBase)
-
{
-
그리기 모드 = "단색";
-
쉐이드 모드 = "광원";
-
정렬 모드 = "정렬되지 않음";
-
addphi = -0.5;
-
abouty = -90;
-
perlevel = 1000;
-
초기화(
-
[{x:0,y:0,z:-80},{x:-80,y:20,z:0},{x:0,y:0,z:80} ,{x:80,y:20,z:0}],
-
[],
-
[{색상:[227,76,38], 꼭지점:[0,2,1,0]},{색상:[227,76,38], 꼭지점:[0,3,2 ,0]}]
-
);
-
}
-
k3dmain.addK3DObject(objBase);
-
-
var objHtml = new K3D.K3DObject();
-
with (objHtml)
-
{
-
그리기 모드 = "단색";
-
쉐이드 모드 = "광원";
-
-
색상 = [64,64,64];
-
양면 = 사실;
-
addphi = -0.5;
-
대략 = 100;
-
규모 = 0.75;
-
perlevel = 1000;
-
초기화(
-
[{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}],
-
[],
-
[{꼭지점:[0,1,2,3,4,5,6,7,8,9,10,11,0]},{꼭지점:[12,13,14,15 ,16,17,18,19,12]},{꼭지점:[20,21,22,23,24,25,26,27,28,29,30,31,20]},{꼭지점:[32 ,33,34,35,36,37,32]}]
-
);
-
}
-
k3dmain.addK3DObject(objHtml);
-
-
-
var ctx = canvas.getContext('2d');
-
var rotationOffset = 0;
-
var len = (canvas.height > canvas.width ? canvas.height : canvas.width) * 0.7;
-
k3dmain.clearBackground = 거짓;
-
k3dmain.callback = 함수()
-
{
-
-
ctx.clearRect(0, 0, canvas.width, canvas.height);
-
-
-
ctx.save();
-
ctx.translate(canvas.width/2, canvas.height/2);
-
ctx.rotate(rotationOffset);
-
-
-
var RAYCOUNT = 24;
-
ctx.fillStyle = "#eee";
-
ctx.beginPath();
-
for (var i=0; i
- {
-
- ctx.rotate(TWOPI / RAYCOUNT);
- ctx.moveTo(0, 0);
- ctx.lineTo(-20, len);
- ctx.lineTo(20, len);
- }
- ctx.closePath();
- ctx.fill();
-
- ctx.fillStyle = "#fff";
- ctx.beginPath();
- for (var i=0; i
- {
-
- 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;
-
-
- for (var i=0, objs=k3dmain.objects; 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;
-
};
-
-
-
k3dmain.paused = 참;
-
setInterval(함수(){k3dmain.tick()}, 1000/60);
-
}
-
-
-
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);
-
-
함수 onDocumentMouseDown( 이벤트 ) {
-
-
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;
-
}
-
-
기능 onDocumentMouseMove( 이벤트 )
-
{
-
mouseX = event.clientX - windowHalfX;
-
targetRotationX = targetRotationOnMouseDownX (mouseX - mouseXOnMouseDown) * 0.02;
-
mouseY = event.clientY - windowHalfY;
-
targetRotationY = targetRotationOnMouseDownY (mouseY - mouseYOnMouseDown) * 0.02;
-
}
-
-
함수 onDocumentMouseUp( 이벤트 )
-
{
-
document.removeEventListener('mousemove', onDocumentMouseMove, false);
-
document.removeEventListener('mouseup', onDocumentMouseUp, false);
-
document.removeEventListener('mouseout', onDocumentMouseOut, false);
-
}
-
-
함수 onDocumentMouseOut( 이벤트 )
-
{
-
document.removeEventListener('mousemove', onDocumentMouseMove, false);
-
document.removeEventListener('mouseup', onDocumentMouseUp, false);
-
document.removeEventListener('mouseout', onDocumentMouseOut, false);
-
}
-
-
기능 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;
-
}
-
}
-
-
기능 onDocumentTouchMove( 이벤트 )
-
{
-
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;
-
}
-
}
以上就是本文의 전체 부서는 内容, 希望对大家의 학교입니다.