当前位置:网站首页>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,多刷新几次就出来了。
边栏推荐
- Is the fund of futures account safe? How to open an account?
- Samba basic usage
- How to change guns for 2D characters
- [source code analysis] NVIDIA hugectr, GPU version parameter server - (1)
- Check log4j problems using stain analysis
- Cloud computing - make learning easier
- NSI packaging script add file details
- 540. Single element in ordered array
- The latest intelligent factory MES management system software solution
- This is the latest opportunity of the London bank trend
猜你喜欢

Search 2D matrix 2

Yolov5 practice: teach object detection by hand

Fresh, 2022 advanced Android interview must know 100 questions (interview questions + answer analysis)

Blue Bridge Cup real topic: the shortest circuit
![[image denoising] matlab code for removing salt and pepper noise based on fast and effective multistage selective convolution filter](/img/bf/f8759195ea67832835e84c851b5e81.jpg)
[image denoising] matlab code for removing salt and pepper noise based on fast and effective multistage selective convolution filter

Happy new year | 202112 monthly summary

Penetration practice vulnhub range Tornado

因子分析怎么计算权重?

Localization through custom services in the shuttle application

Android development interview was badly hit in 3 years, and now the recruitment technical requirements are so high?
随机推荐
Blackwich: the roadmap of decarbonization is the first step to realize the equitable energy transformation in Asia
Check log4j problems using stain analysis
Blue Bridge Cup real question: score statistics
Penetration practice vulnhub range Keyring
Vue uses keep alive to cache page optimization projects
Develop those things: add playback address authentication to easycvr platform
必看,时间序列分析
MES production equipment manufacturing execution system software
PMP daily three questions (February 15, 2022)
SCP -i private key usage
This is the latest opportunity of the London bank trend
APK签名流程介绍[通俗易懂]
PTA year of birth
Easycvr accesses the equipment through the national standard gb28181 protocol. What is the reason for the automatic streaming of the equipment?
Mujoco model learning record
To improve the efficiency of office collaboration, trackup may be the best choice
MySQL + JSON = King fried
证券开户安全么,有没有什么样的危险呢
Detailed explanation of ArrayList expansion
Happy new year | 202112 monthly summary