three打造升起的爱心气球效果

代码语言:html

所属分类:表白

代码描述:three打造升起的爱心气球效果

代码标签: 爱心 气球 效果

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

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<style>
body {
  margin: 0;
}
</style>
<script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/three.r118.js"></script>
</head>
<body translate="no">

<script>
let camera,
  renderer,
  scene,
  meshes = [],
  axes = ["x", "y", "z"];

let x = 0,
  y = 0,
  heart = new THREE.Shape();

heart.moveTo(x + 0.5, y + 0.5);
heart.bezierCurveTo(x + 0.5, y + 0.5, x + 0.4, y, x, y);
heart.bezierCurveTo(x - 0.6, y, x - 0.6, y + 0.7, x - 0.6, y + 0.7);
heart.bezierCurveTo(x - 0.6, y + 1.1, x - 0.3, y + 1.54, x + 0.5, y + 1.9);
heart.bezierCurveTo(x + 1.2, y + 1.54, x + 1.6, y + 1.1, x + 1.6, y + 0.7);
heart.bezierCurveTo(x + 1.6, y + 0.7, x + 1.6, y, x + 1, y);
heart.bezierCurveTo(x + 0.7, y, x + 0.5, y + 0.5, x + 0.5, y + 0.5);

function init() {
  scene = new THREE.Scene();
  scene.background = new THREE.Color("aqua");

  createCamera();
  createLights();
  for (let i = 0; i < 30; i++) {
    createMeshes();
  }
  createRenderer();

  renderer.setAnimationLoop(() => {
    update();
    render();
  });
}

function createCamera() {
  let fov = 45,
    aspect = window.innerWidth / window.innerHeight,
    near = 0.1,
    far = 40;

  camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
  ca.........完整代码请登录后点击上方下载按钮下载查看

网友评论0