three实现文字三维探照灯走光交互效果代码

代码语言:html

所属分类:三维

代码描述:three实现文字三维探照灯走光交互效果代码

代码标签: three 文字 三维 探照灯 走光 交互

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

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

<head>
    <meta charset="UTF-8">
<style>
    * {
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
}

body {
  height: 100vh;
  background-color: hotpink;
  margin: 0;
  padding: 0;
  overflow: hidden;
}
</style>

</head>

<body>

    <div class="canvas" id="canvas-wrapper" aria-label="neumorphism"></div>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.108.js"></script>
    <script >

const colorBg = 'hotpink'; // #ff69b4
const colorTypo = '#ff49a4'; // dark pink

const nearDist = 0.1;
const farDist = 10000;

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerHeight,
nearDist,
farDist);

camera.position.z = Math.round(farDist / 20);

const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setClearColor(colorBg);
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
document.querySelector("#canvas-wrapper").appendChild(renderer.domElement);

const light = new THREE.DirectionalLight(0xffdffd, 1);
light.position.set(-15, 0, 70);
scene.add(light);

// CREATE TYPOGRAPHY
const group = new THREE.Group();
const typoLoader = new THREE.FontLoader();
const createTypo = font => {
  const word = `neu
morph
ism`;
  const typoSize = 120;
  const typoHeight = Math.round(typoSize / 4);
  const typoProperties = {
    font: font,
    size: typoSize,
    height: 0,
    curveSegments: 20,
    bevelEnabled: false,
    bevelThickness: 0.1,
    bevelSize: 0.5,
    bevelOffset: 0,
    bevelSegments: 1.........完整代码请登录后点击上方下载按钮下载查看

网友评论0