Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Multi-view 3D rotatable Mark Animation by HTML5

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

The knowledge of this article "HTML5 how to achieve multi-view 3D rotatable logo animation" is not understood by most people, so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "HTML5 how to achieve multi-view 3D rotatable logo animation" article.

HTML code

XML / HTML code copies content to text

< div class = "链接叠加" >

< canvas id = " canvas" style = " background-color:#ddd" >

JavaScript code

The JavaScript code copies the content to

/ / bind to the window onload handler

Window.addEventListener ('load', onloadHandler, false)

/ * *

* window load 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 ()

And (obj1)

{

Drawmode = "solid"

Shademode = "lightsource"

Sortmode = "unsorted"

Addphi =-0.5

Approximately =-90

Perslevel = 1000

Inside (

[{xRAPH] 80}, {xRX 0Magre yRV 180}, {XRV 0J ZRV 80}, {XRV 0J YRV 0J ZRV 80}, {XRV 80L y: 20J ZRV 0}, {xRV 50L yRV 150Z RV RT 30}, {xRV 0150J ZRV RT 80}, {XRV 0J JZ 130, zRV 80}, {XRV RT 30J yJR 130Z ZRZ 50}, {xRV 28 YRV 110 ~ (th), {x ~ (14) O, {x ~ (10) Z:-80}, {x ~ () 0, y ~ (90), z ~ (40)}, {x ~ (14), 4 ~ (th), 4 ~ (th), 4 ~ (th), 8 ~ (th), {x ~ (th), y ~ (25) ~ (th), {x ~ (14), y, and y: 40) ZRV Mustang 80}, {xRU Rue 40 Ji Jing YJ 50 Ji Ji ZRU Ling 40}]

[]

[{color: [227pence76], vertex: [0gradent1rection2re3re0]}, {color: [235235235], vertex: [4, 5, 6, 7, 8, 10, 11]}, {color: [235235235], vertex: [12, 13, 14, 15, 16, 17]

)

}

K3dmain.addK3DObject (obj1)

Var obj2 = new K3D.K3DObject ()

And (obj2)

{

Drawmode = "solid"

Shademode = "lightsource"

Sortmode = "unsorted"

Addphi =-0.5

Approximately =-90

Perslevel = 1000

Inside (

[{XRO], {XRX 80], {xRX 80], {xRZ 80], {xRZ 80], {xRX 0} y: 0Reagle zRV 80}, {XRV 0LRO linger y: 0J ZRV 80}, {XRX 0pl 165pr ZRV 80}, {xRV 68pr yRV 165e ZRV 12}, {xRV 55cr 35z:-25}, {XRO YJO YJO ZRZ 80}, {xRX 0RO YRO ZRZ 80}, {xRX 0REY 150 ZRV Lay 80}, {xRV 50cr yrez 150J ZRV Lou 30}, {XRV 47Magi yrex 130RZ ZRV 33}, {XRV 0pr yrex 130J ZRV 80}, {XRV 0pr 110pr zRAME 80}, {xRV 45y: 110pm zRV 35}, {xRV 40cet yRV 50th ZRV 40}, {xRL 0JZ 40 ZL 80}, {XRV 0Q YJ 60Q z:-80}, {XRV 20 YRV 650 ZRV 60}, {XRU 23 Ji 90 JJ ZRV 57}, {XRX 0pm YJ 90 ZRL Lue 80}]]

[]

[{color: [227pence76]], vertex: [0grad1], [2pyrr3]}, {color: [240pj101], vertex: [4pyrone, 5pyrone, 6pyrrine, 4]}, {color: [235235235], vertex: [8miere, 9pr, 10pr, 11pr 8]}, {color: [235235235], vertex: [12pr, 13pr, 14mrr, 15pr, 16pr, 17pr, 1912]]

)

}

K3dmain.addK3DObject (obj2)

Var obj3 = new K3D.K3DObject ()

And (obj3)

{

Drawmode = "solid"

Shademode = "lightsource"

Sortmode = "unsorted"

Addphi =-0.5

Approximately =-90

Perslevel = 1000

Inside (

[{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: [227pence76], vertex: [0gradent1rection2re3re0]}, {color: [235235235], vertex: [4, 5, 6, 7, 8, 10, 11]}, {color: [235235235], vertex: [12, 13, 14, 15, 16, 17]

)

}

K3dmain.addK3DObject (obj3)

Var obj4 = new K3D.K3DObject ()

And (obj4)

{

Drawmode = "solid"

Shademode = "lightsource"

Sortmode = "unsorted"

Addphi =-0.5

Approximately =-90

Perslevel = 1000

Inside (

[{XRV 0JZ 180 ZRO}, {xRV 80J YRV 180 ZRX 0}, {XRV 80J YRO ZRO ZRO}, {XRV 0J y: 0J ZRV 80}, {XRV 0ME YRV 165J ZRV 80}, {xRV 68ML yRV 165J ZRO 12}, {xRV 5J 35J z: 25}, {xRX 0J YJO ZRO ZRO 80}, {xRX 0st yRO ZRO 150 ZRZ 80} {xlux Lexi 50, 150, 150, 40, 40, 40, 80, 60, 60, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, {xRO, 27th, 90th, 57th, 0th, 0th, 20th century, 20th century, 20th century, and 20th century, respectively.

[]

[{color: [227pence76]], vertex: [0grad1], [2pyrr3]}, {color: [240pj101], vertex: [4pyrone, 5pyrone, 6pyrrine, 4]}, {color: [235235235], vertex: [8miere, 9pr, 10pr, 11pr 8]}, {color: [235235235], vertex: [12pr, 13pr, 14mrr, 15pr, 16pr, 17pr, 1912]]

)

}

K3dmain.addK3DObject (obj4)

Var objBase = new K3D.K3DObject ()

And (objBase)

{

Drawmode = "solid"

Shademode = "lightsource"

Sortmode = "unsorted"

Addphi =-0.5

Approximately =-90

Perslevel = 1000

Inside (

[{xburet 0jinghe Zrem ZRU 80}, {XRX Rue 80J yRV 20je ZRO}, {XRX 0pr 0jre ZRO]

[]

[{color: [227pence76], Vertex: [0pr é gime 2jor1]]}, {Color: [227pr é cor 76pr 38], Vertex: [0meme3re2]

)

}

K3dmain.addK3DObject (objBase)

Var objHtml = new K3D.K3DObject ()

And (objHtml)

{

Drawmode = "solid"

Shademode = "lightsource"

/ / sortmode = "unsorted"

Color = [64pr 64pr 64]

Double-sided = true

Addphi =-0.5

Approximately = 100

Scale = 0.75

Perslevel = 1000

Inside (

[{XRV Lectrum 80], {XRV 70 recorder, {XRV 70], {XRV 70], {XRX 60, y: 30, z0}, {xRV, y: 30, z0}, {xRV, 50, 50, y, 10, zrel 0}, {xRX, 60, 10, 0}, 20 ZRV 0}, {XRV RT 70 lemon, {xRV 70 Magi, 10 Magi ZRO}, {XRV 80, 40, 40, 40, 40, 40, 10, 10, 30, 30, 30, 10, 30, 10, 10, 30, 10, 10, 30, 10, 10, 10, 10, 10, 10, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0. YRU 10L ZRO}, {xRZ 30J yJL 30J ZL 0}, {xRV 40J yrex 30L ZL 0}, {xRO Magi 40 ZRO ZL 0}, {xRO Magi YJ 40J ZRO}, {xRV 20Magne30 Magnum ZRO}, {xvl 30pary: 40jet zJR 0}, {xRX 40pari yJO ZRO 0}, {xRO 40meryJRO ZRO 0}, {xRO 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: [0pyrone, 2dir, 3jor4, 5Power6, 7pyror8, 9pyror10, 10pyror0]}, {vertices: [12, 13, 14, 15, 16, 17, 18, 19, 12]], {vertex: [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 29, 30, 20], {vertex: [32, 34, 35, 36, 37, 32]]

)

}

K3dmain.addK3DObject (objHtml)

/ / add rendering 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 ()

{

/ / clear bg- manually because we need to render something extra

Ctx.clearRect (0century 0canvas.widthdepartment canvas.height)

/ / paint the bg effect before K3D 3D rendering

Ctx.save ()

Ctx.translate (canvas.width / 2 canvas.height / 2)

Ctx.rotate (rotationOffset)

/ / fill for the first time-external light

Var RAYCOUNT = 24

Ctx.fillStyle = "# eee"

Ctx.beginPath ()

For (var I = 0; I)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report