three实现多彩的五角星旋转动画效果代码

代码语言:html

所属分类:动画

代码描述:three实现多彩的五角星旋转动画效果代码

代码标签: three 多彩 五角星 旋转 动画

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

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

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

  
<style>
body {
  margin: 0;
}
</style>


  <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.123.js"></script>
  
  
</head>

<body >

      <script >

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

const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
const stars = [];

for (let i = 0; i < 30; i++) {
  const geometry = new THREE.BufferGeometry();

  // Define vertices for a 5-point star
  const vertices = [];
  const numPoints = 5;
  const outerRadius = 1;
  const innerRadius = 0.4;
  const starColor = 0xffff00;

  for (let i = 0; i < numPoints * 2; i++) {
    const radius = i % 2 === 0 ? outerRadius : innerRadius;
    const angle = 3 * (i / numPoints) * Math.PI;
    const x = Math.cos(angle) * radius;
    const y = Math.sin(angle) * radius;
    vertices.push(x, y,.........完整代码请登录后点击上方下载按钮下载查看

网友评论0