three实现三维螺旋动画效果代码

代码语言:html

所属分类:动画

代码描述:three实现三维螺旋动画效果代码

代码标签: three 三维 螺旋 动画

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

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

<head>

  <meta charset="UTF-8">

  
  
<style>
@import url("https://fonts.googleapis.com/css2?family=Spectral:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;0,800;1,200;1,300;1,400;1,500;1,600;1,700;1,800&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html,
body {
  overscroll-behavior-x: none;
  overscroll-behavior-y: none;
}
body {
  background: mediumaquamarine;
  color: #fff;
  position: relative;
  font-family: "Spectral", serif;
  font-size: 20px;
  overflow: hidden;
}

#canvas {
  width: 100vw;
  height: 100vh;
}
canvas {
  z-index: 0;
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
</style>

</head>

<body  >
  <!-- using three.js -->
<canvas id="canvas"></canvas>


<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.145.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/OrbitControls.145.js"></script>
      <script >
window.onload = function () {
  "use strict";

  //////// three.js
  const canvas = document.getElementById("canvas");
  let camera, scene, renderer, controls;
  let geometry, material, mesh;
  let ww, hh;
  let timeoutID = 0;
  const size = 3;
  const color = new THREE.Color("#FF7F50");

  init();
  animate();

  function init() {
    ww = window.innerWidth;
    hh = window.innerHeight;
    //ww = document.body.clientWidth / 2 / window.devicePixelRatio;
    //hh = window.innerHeight;
    //hh = document.body.cliantHeight/window.devicePixelRatio;

    scene = new THREE.Scene();
    renderer = new THREE.WebGLRenderer({
      canvas: canvas,
      antialias: true,
      alpha: true
    });
    renderer.setPixelRatio(window.devicePixelRatio);
    //renderer.setSize(ww, hh);
    renderer.setSize(ww, hh, false);
    renderer.outputEncoding = THREE.sRGBEncoding;
    //
    camera = new THREE.PerspectiveCamera(40, ww / hh, 0.01, size * 30);
    //camera.position.set(0, size, size * 6);
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0