当前位置:网站首页>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,多刷新几次就出来了。
边栏推荐
- Introduction to easyclick database
- Length of learning and changing
- Classpath classpath
- To improve the efficiency of office collaboration, trackup may be the best choice
- Software construction scheme of smart factory collaborative management and control application system
- Cloud computing - make learning easier
- Apk signature process introduction [easy to understand]
- What is web application security testing technology?
- Fix the problem that easycvr device video cannot be played
- [today in history] February 15: Pascal's father was born; YouTube was founded; Kotlin language comes out
猜你喜欢

What impact will multinational encryption regulation bring to the market in 2022

Bug of QQ browser article comment: the commentator is wrong

Blue Bridge Cup real topic: the shortest circuit

Penetration practice vulnhub range Keyring

C# SelfHost WebAPI (2)

Using OpenSSL encryption to rebound shell traffic

Operation of cmake under win

Relational database management system of easyclick

The method of real-time tracking the current price of London Silver

Localization through custom services in the shuttle application
随机推荐
Work and leisure suggestions of old programmers
[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush
Redis master-slave realizes 10 second check and recovery
Penetration practice vulnhub range Nemesis
Highly reliable program storage and startup control system based on anti fuse FPGA and QSPI flash
Zabbix报警执行远程命令
What is web application security testing technology?
Growing up in the competition -- (Guangyou's most handsome cub) Pikachu walking
Session layer of csframework, server and client (1)
Apache iceberg source code analysis: schema evolution
Three dimensional anti-terrorism Simulation Drill deduction training system software
A database editing gadget that can edit SQLite database. SQLite database replaces fields. SQL replaces all values of a field in the database
js如何将带有分割符的字符串转化成一个n维数组
Yuancosmos game farmersworld farmers world - core content of the second conference in China!
Single element of an ordered array
Android development interview was badly hit in 3 years, and now the recruitment technical requirements are so high?
Win10+vs2019 Community Edition compiling OpenSSL
Cassette helicopter and alternating electric field magnetic manometer DPC
主成分之综合竞争力案例分析
. Net cloud native architect training camp (permission system code implements actionaccess) -- learning notes