three.js 在 WebGL 绘制旋转的几何体

实现 three.js 内置几何体的创建,并加入几何体旋转动画。包含几何体有:球形网格、二十面体、八面体、四面体、长方形平面、立方体、圆形平面等,这些都是学习 three.js 的基础

为了方便,我将使用 vite 搭建一个原生 js 项目。

1.创建项目

npm create vite@latest three-demo
选:Vanilla
选:JavaScript

2.初始化项目
 cd three-demo
 cnpm install

3.安装 three.js
 cnpm install three@0.160.0 --save

或者 cd three-demo
curl -O https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.min.js

4.编写示例 three_demo_10.html  如下

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>learn10 (内置几何体)</title>
    <script src="three.min.js"></script>
    <style>
        body {
            margin: 0;
        }

        canvas {
            width: 100%;
            height: 100%;
            display: block;
        }
    </style>
</head>
<body onload='draw()'>
<script>
    var renderer;
    var initRenderer = () => {
      renderer = new THREE.WebGLRender
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值