螺旋动画效果
代码语言:html
所属分类:动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> body { background: #111; } </style> </head> <body translate="no"> <div id="wrapper"></div> <script> (function () { 'use strict'; let wrapper,canvas,ctx,width,height, Tau = Math.PI * 2,PI180 = Math.PI / 180, systems = []; /* PlanetarySystem */ let PlanetarySystem = function (id = 'pSys') { Object.defineProperty(this, 'id', { value: id, writable: true }); Object.defineProperty(this, 'x', { value: 0, writable: true }); Object.defineProperty(this, 'y', { value: 0, writable: true }); Object.defineProperty(this, 'allBodies', { value: [], writable: true }); Object.defineProperty(this, 'allBodiesLookup', { value: {}, writable: true }); // fast id lookup for children Object.defineProperty(this, 'numBodies', { value: 0, writable: true }); }; PlanetarySystem.prototype.addBody = function (vo) { vo.parentSystem = this; vo.parentBody = vo.parentBody === null ? this : this.allBodiesLookup[vo.parentBody]; let body = new PlanetaryBody(vo); body.update(); this.allBodies.push(body); this.allBodiesLookup[vo.id] = body; this.numBodies += 1; }; PlanetarySystem.prototype.setSpeedFactor = function (value) { let body; for (let i = 0; i < this.numBodies; i++) { body = this.allBodies[i]; body.setSpeedFactor(value); } }; PlanetarySystem.prototype.update = function () { let body; for (let i = 0; i < this.numBodies; i++) { body = this.allBodies[i]; body.update(); } }; /* PlanetaryBody */ let PlanetaryBody = function (vo) { Object.defineProperty(this, 'id', { value: vo.id, writable: true }); Object.defineProperty(this, 'diameter', { value: vo.diameter, writable: true }); Object.defineProperty(this, 'co.........完整代码请登录后点击上方下载按钮下载查看
网友评论0