当前位置:网站首页>GAMES202作业0-环境搭建过程&解决遇到的问题
GAMES202作业0-环境搭建过程&解决遇到的问题
2022-07-01 18:33:00 【flashinggg】
目录
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead
1 下载Visual Studio Code
直接点进链接下载并安装:
Download Visual Studio Code - Mac, Linux, Windows
2 安装插件 Live Server
打开VS Code -> Extensions -> 搜索Live Server ->点击 install安装即可

题外话:VS Code安装的插件都可以在C盘 -> Users -> 用户名 -> .vscode文件夹里找到。

3 Node.js
点击链接下载并安装Node.js:
Download | Node.js (nodejs.org)
(1)Win+R调出运行栏并输入cmd:

或者搜索框直接搜cmd都可以:

(2)输入如下命令:
npm install http-server -g

出现上述界面就代表install成功了,如果报错出现了WARN,后面部分有说解决办法,可以直接去看看。
4 打开作业框架查看模型
(1)在VS Code选择Open new fold并选择作业0的文件夹,打开后如下:

(2)右键index.html文件并选择Open with Live Server:


就能成功打开作业框架的内容,其中包含:一个人物模型和一个围绕模型运动的光源。
如果打开出现黑屏或仅有光源没有模型的问题,后面的问题解决有展示解决办法。
解决问题
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead
这个问题会在输入npm install http-server -g 的时候出现,如果出现如下错误提示:
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

首先,保证npm更新到了最新版本。之后,找到我们安装Noder.js的文件夹,我是安装到了D盘,按照你的保存路径找就行,
并分别打开npm和npm.cmd这两个文件。

文件可以直接拖拽进刚刚安装的VS Code里就可以打开了。
ctrl+H分别搜索定位到
prefix -gnpm如下:

npm.cmd如下:

关键的一步来了,分别把prefix -g 替换成如下代码:(注意这里替换最好自己手动输入!)
prefix --location=global替换后npm和npm.cmd依次如下:


ctrl+s分别保存后关掉文件,再进行cmd输入npm install http-server -g,会发现刚刚的WARN就消失了。
作业0模型不显示
作业0只有光源/作业0模型不显示/作业0黑屏...等等问题都可以尝试接下来的解决思路:
我最开始出现的是黑屏的问题,光源和模型什么都没有,只有右上角的操作栏

这里可以在展示的浏览器中,按F12就能弹出浏览器后台的Console界面:

看到提示了:
Uncaught ReferenceError: mat4 is not defined
我们再回到VS Code打开的框架,观察index.html文件可以发现,针对mat4的是这句话:

我认为这个链接就是加载mat4的部分:https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix-min.js
我发现,我是打不开里面的这个链接的,即使挂了梯也打不了开... 于是想到比较粗暴的解决办法就是,直接下载gl-matrix-min.js文件加在框架里,应该就能解决了。
经搜索发现了有人把这个文件上传了github:gl-matrix-min.js · GitHub
点进去直接下载,并将文件中的对应文件拖入VS Code里就行,我是放在了src下:


到这里还没有完成,还需要把刚刚的原始的代码:
<script src="https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix-min.js"
integrity="sha512-zhHQR0/H5SEBL3Wn6yYSaTTZej12z0hVZKOv3TwCUXT1z5qeqGcXJLLrbERYRScEDDpYIJhPC1fk31gqR783iQ=="
crossorigin="anonymous" defer> </script>
替换成:
<script src="src/gl-matrix-min.js" defer> </script>做完上述操作后,ctrl+s保存,刷新结果页面,可以发现模型就展示出来了,且报错也消除了。

如果模型展示不全,只出现了一个202,多刷新几次就出来了。
边栏推荐
- Common design parameters of solid rocket motor
- JS how to convert a string with a delimiter into an n-dimensional array
- Sum of three numbers
- Record 3 - the state machine realizes key control and measures the number of external pulses
- Subnet division and summary
- Nielseniq found that 60% of the re launched products had poor returns
- EasyCVR通过国标GB28181协议接入设备,出现设备自动拉流是什么原因?
- C operator overloads the query table
- Penetration practice vulnhub range Tornado
- Computer network interview assault
猜你喜欢

How to manage 1000 anchors by one person?

Set the style of QT property sheet control

Calculation of intersection of two line segments

Fix the black screen caused by iPhone system failure

Distributed task queue: Celery usage record

Localization through custom services in the shuttle application

信度系数低怎么办?信度系数具体怎么算?

Classpath classpath

. Net cloud native architect training camp (permission system code implements actionaccess) -- learning notes

Basic concepts of binary tree
随机推荐
Depth first search - DFS (burst search)
[acnoi2022] color ball
A database editing gadget that can edit SQLite database. SQLite database replaces fields. SQL replaces all values of a field in the database
When the fixed frequency artifact falls in love with multithreading | ros2 fixed frequency topic release demo
Extract the compressed package file and retrieve the password
MySQL connection tools
A wonderful time to buy and sell stocks
C operator overloads the query table
The latest software scheme of the intelligent information management system of the armed police force
Yolov5 practice: teach object detection by hand
Flex layout
Search 2D matrix 2
To improve the efficiency of office collaboration, trackup may be the best choice
golang中的select详解
Static timing analysis (STA) in ic/fpga design
Length of learning and changing
Fix the problem that easycvr device video cannot be played
Fix the black screen caused by iPhone system failure
目前炒期货在哪里开户最正规安全?怎么期货开户?
主成分计算权重