zdog+gsap实现三维机械手臂做饭做饼动画效果代码
代码语言:html
所属分类:三维
代码描述:zdog+gsap实现三维机械手臂做饭做饼动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> @import url('https://fonts.googleapis.com/css2?family=Fuzzy+Bubbles:wght@700&display=swap'); .zdog-canvas { background: #f4f1de; cursor: move; display: block; width: 100vw; height:100vh; } body{ margin:0; color:hsl(234deg 20% 20%); font-family:'Fuzzy Bubbles', cursive; } .overTop{ position:fixed; top:0; left:0; padding:30px; font-size:50px; font-weight:700; pointer-events:none; } .overTop.bottom{ bottom:0; top:auto; display:inline-block; font-size:14px; } .overTop.top{ max-width:600px; } </style> </head> <body> <canvas id="cnv" class="zdog-canvas" width="240" height="240"></canvas> <div class="overTop top"> How to animate pancake? </div> <div class="overTop bottom"> Lots of different easings </div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/gsap.3.8.0.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/zdog.dist.js"></script> <script> class PancakeAnim { constructor() { this.isSpinning = true; this.canvas = document.getElementById("cnv"); this.illo = new Zdog.Illustration({ element: ".zdog-canvas", dragRotate: true, translate: { x: 10, y: 50 }, // stop spinning when drag starts onDragStart: () => { this.isSpinning = false; }, onResize: function (width, height) { // scale zoom //let height = window.innerHeight; let min = Math.min(height, width); this.zoom = min / 400; }, resize: true }); this.illo.rotate.x -= 0.2; this.illo.rotate.y -= 1; this.addObjects(); this.animate(); } addObjects() { //Arm this.arm = new Zdog.Shape({ addTo: this.illo, path: [{ line: { x: 120 } }, { line: { x: 20 * 100, y: 120 * 100 } }], color: "#e07a5f", stroke: 50 }); // circle this.pancake = new Zdog.Ellipse({ addTo: this.illo, diameter: 80, translate: { z: 0 }, scale: { x: 1, y: 1, z: 1 }, rotate: { x: Math.PI / 2 }, stroke: 20, color: "#f2cc8f", fill: "#f2cc8f" }); // pan this.pan = new Zdog.Ellipse({ addTo: this.illo, diameter: 120, translate: { z: 0, y: 20 }, scale: { x: 1, y: 1, z: 1 }, rotate: { x: Math.PI / 2 }, stroke: 20, color: "#3d405b", backface: "#3d405b", fill: "#3d405b" }); new Zdog.Shape({ addTo: this.pan, path: [{ line: { z: 10, x: 60 } }, { line: { z: 20, x: 120 } }], translate: { z: 0, y: 0 }, scale: { x: 1, y: 1, z: 1 }, stroke: 20, color: "#3d405b", backface: "#3d405b", fill: "#3d405b&qu.........完整代码请登录后点击上方下载按钮下载查看
网友评论0