PerspectiveTransform实现三维地球自转动画效果代码
代码语言:html
所属分类:三维
代码描述:PerspectiveTransform实现三维地球自转动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Oswald:400'> <style> html, body { position: absolute; width: 100%; height: 100%; margin: 0 0; overflow: hidden; font-family: 'Lato', sans-serif; background-color: #000; color: #fff; } .world { position: absolute; width: 100%; height: 100%; cursor: pointer; cursor: move; cursor: -moz-grab; cursor: -webkit-grab; cursor: grab; } .world-bg { position: absolute; width: 100%; height: 100%; background-position: 50% 50%; background-size: cover; } .world-globe { position: absolute; left: 50%; top: 50%; width: 0; height: 0; } .world-globe-pole { position: absolute; width: 530px; height: 530px; left: -265px; top: -265px; border-radius: 50% 50%; background-color: #fff; } .world-globe-doms-container { position: absolute; left: 50%; top: 50%; width: 0; height: 0; } .world-globe-halo { position: absolute; left: 50%; top: 50%; width: 730px; height: 715px; margin-left: -368px; margin-top: -350px; } .info { position: absolute; left: 0; bottom: 0; width: 100%; padding: 10px 10px; box-sizing: border-box; background-color: rgba(0, 0, 0, 0.8); color: #fff; font-size: 12px; } .info-desc { color: #ddd; font-size: 10px; } a { color: #ff5f5f; } </style> </head> <body > <div class="world"> <div class="world-bg"></div> <div class="world-globe"> <div class="world-globe-pole"></div> <div class="world-globe-doms-container"></div> <div class="world-globe-halo"></div> </div> </div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/dat.gui-min.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/stats-min.js"></script> <script> (function (define) { define(function(){ function PerspectiveTransform(element, width, height, useBackFacing){ this.element = element; this.style = element.style; this.computedStyle = window.getComputedStyle(element); this.width = width; this.height = height; this.useBackFacing = !!useBackFacing; this.topLeft = {x: 0, y: 0}; this.topRight = {x: width, y: 0}; this.bottomLeft = {x: 0, y: height}; this.bottomRight = {x: width, y: height}; this.calcStyle = ''; } PerspectiveTransform.useDPRFix = false; PerspectiveTransform.dpr = 1; PerspectiveTransform.prototype = (function(){ var app = { stylePrefix: '' }; var aM = [[0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0]]; var bM = [0, 0, 0, 0, 0, 0, 0, 0]; function _setTransformStyleName(){ var testStyle = document.createElement('div').style; app.stylePrefix = 'webkitTransform' in testStyle ? 'webkit' : '.........完整代码请登录后点击上方下载按钮下载查看
网友评论0