div+css实现三维场景摄像机拍摄角度动画效果代码

代码语言:html

所属分类:动画

代码描述:div+css实现三维场景摄像机拍摄角度动画效果代码,无js代码,全部在css中实现多个摄像机拍摄角度动画。

代码标签: div css 三维 场景 摄像机 拍摄 角度 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="UTF-8">



    <style>
        @import url("https://fonts.googleapis.com/css2?family=Open+Sans&display=swap");
        *, *::before, *::after {
          padding: 0;
          margin: 0 auto;
          box-sizing: border-box;
        }
        
        :root {
          --perspective: 1000px;
          --camera-truck: 0px;
          --camera-pedestal: 0px;
          --camera-dolly: -1000px;
          --camera-roll: 0deg;
          --camera-pan: 0deg;
          --camera-tilt: 0deg;
        }
        
        body {
          font-family: "Open Sans", sans-serif;
          background-color: #000;
          color: #fff;
          min-height: 100vh;
          display: grid;
          place-items: center;
          perspective: var(--perspective);
        }
        body *:not(:empty) {
          transform-style: preserve-3d;
        }
        
        input[type=radio] {
          display: none;
        }
        input[type=radio]#cam1:checked ~ .labels > [for=cam1], input[type=radio]#cam2:checked ~ .labels > [for=cam2], input[type=radio]#cam3:checked ~ .labels > [for=cam3], input[type=radio]#cam4:checked ~ .labels > [for=cam4] {
          color: dodgerblue;
        }
        input[type=radio]#cam2:checked ~ .scene {
          --camera-dolly: 0px;
          --camera-pedestal: 250px;
          --camera-truck: -1200px;
          --camera-pan: 80deg;
          --camera-roll: -15deg;
        }
        input[type=radio]#cam3:checked ~ .scene {
          --camera-dolly: 100px;
          --camera-pedestal: 1000px;
          --camera-tilt: 0deg;
          --camera-roll: -100deg;
        }
        input[type=radio]#cam4:checked ~ .scene {
          --camera-dolly: -500px;
          --camera-truck: 500px;
          --camera-pan: -45deg;
          --camera-tilt: -10deg;
          --camera-roll: -10deg;
        }
        
        .labels {
          position: fixed;
          top: 1em;
          left: 1em;
          z-index: 2;
        }
        .labels label {
          padding: 0.5em;
          border: 1px solid;
          transition: all 0.3s;
        }
        .labels label:hover {
          color: lightcoral;
          background-color: #fff1;
        }
        
        .scene {
          position: relative;
          transition: transform 1s;
          transform: translateZ(var(--perspective)) rotateX(var(--camera-roll)) rotateY(var(--camera-pan)) rotateZ(var(--camera-tilt)) translateX(calc(var(--camera-truck) * -1)) translateY(var(--camera-pedestal)) translateZ(var(--camera-dolly));
        }
        
        .cube {
          position: relative;
          width: 200px;
          height: 200px;
          -webkit-animation: cubeRotate 30s infinite linear;
             .........完整代码请登录后点击上方下载按钮下载查看

网友评论0