three实现三维过去现在未来时间线穿梭动画效果代码

代码语言:html

所属分类:动画

代码描述:three实现三维过去现在未来时间线穿梭动画效果代码

代码标签: three 三维 过去 现在 未来 时间线 穿梭 动画

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

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

<head>
  <meta charset="UTF-8">

  
  
<style>
@import url('https://api.fontshare.com/v2/css?f[]=tanker@400&display=swap" rel="stylesheet');
body {
  margin: 0;
  background-color: #060402;
  overflow: hidden;
}

canvas {
  touch-action: initial !important;
}

.container {
  position: absolute;
  top: 0;
  left: 0;
  color: #fcfcfc;
  font-family: tanker;
  height: 100vh;
  width: 100vw;
}
.container .label {
  position: absolute;
  font-size: min(80px, 10vmin);
  overflow: visible;
}
.container .presentLabel {
  left: 0%;
  right: 0%;
  top: 10%;
  text-align: center;
  transform-origin: 50% 200%;
}
.container .pastLabel {
  left: 13%;
  bottom: 52%;
}
.container .futureLabel {
  right: 20%;
  top: 10%;
}
</style>


  
</head>

<body >
  <div class="container">
	 <div class="label presentLabel" style="transform:scale(0)">Present</div>
	 <div class="label futureLabel" style="transform:scale(0)">Future</div>
	 <div class="label pastLabel" style="transform:scale(0)">Past</div>
</div>

<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.89.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/OrbitControls.min.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/jquery-3.2.1.min.js"></script>
      <script >
class ThreeSketch {
  constructor() {
    this.renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
    this.renderer.setSize(window.innerWidth, window.innerHeight);
    document.body.appendChild(this.renderer.domElement);
    this.framerate = 60;
    this.scene = new THREE.Scene();

    this.camera = new THREE.PerspectiveCamera(
    45,
    window.innerWidth / window.innerHeight,
    0.01,
    10000);

    /*
    this.controls = new THREE.OrbitControls(
    	this.camera,
    	this.renderer.domElement
    );
    this.controls.enableDamping=true;
    this.controls.rotateSpeed=0.4;
    */

    //controls.update() must be called after any manual changes to the camera's transform
    this.camera.position.set(2, 2, 10);
    //this.controls.update();
    window.addEventListener("resize", () => {
      this.onResize();
    });
    this.onResize();
  }
  onResize() {
    const width = window.innerWidth;
    const height = window.innerHeight;

    this.camera.aspect = width / height;
    this.camera.updateProjectionMatrix();
    this.renderer.setSize(width, height + 1);
  }
  animate(callback) {
    if (callback) {
      this.animFrameCallBack = callback;
    }
    setTimeout(() => {
      this.animate();
    }, 10.........完整代码请登录后点击上方下载按钮下载查看

网友评论0