threejs-d-1.0

threejs-d-1.0

d-1.0主要是准备我们开发环境和其他的一些准备,为了我们更好的去进入three的世界

一、搭建three.js本地网站

搭建本地网站的原因,是因为我们访问官网的时候,由于网速限制,导致我们的体验感下降,搭建本地服务器,快很多了。

我们打开官网Three.js点击github就进入了threejs仓库了

我们下载仓库的dev开发包

git clone 和 下载压缩包都可以!

执行命令运行:

npm i //安装依赖
npm start //运行项目

我们现在访问本地项目就快多了,我们想知道任何一个例子也可以查看其具体的文件了。

二、使用parcel搭建threejs开发环境

npm init -y //初始化项目
npm install  parcel-bundler -D //安装parcel

设置入口文件main.js和index.html

配置package.json

//package.json
{
  "name": "threejs",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "parcel ./src/index.html",
    "build": "parcel build ./src/index.html"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "parcel-bundler": "^1.12.5"
  }
}

下载threejs依赖

npm install three --save //安装依赖
//main.js
import * as THREE from 'three'
console.log(THREE)

运行项目,打包项目

npm run dev //运行项目
npm run build //打包项目

运行成功!!!

参考链接:

[Three.js官网]: “https://threejs.org/
[Three.js-github]: “https://github.com/mrdoob/three.js/
[parcel官网]: “https://parceljs.org/"
[parcel中文官网]: “https://www.parceljs.cn/

Donate
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2022-2023 alan_mf
  • Visitors: | Views:

请我喝杯咖啡吧~

支付宝
微信