[97编程世界冠军4K组]代码被转为ts脚本github代码如何在WIN10运行和调试

源代码地址:iGitHub - SuperSodaSea/Omniscent: Analysis and Replication of Omniscent, the 1st in the Mekka & Symposium 1997 PC 4K Intro Competition.

1、软件安装nodejs和webstorm都要安装
node-v20.12.2-x64.msi
WebStorm-2024.1.1.exe

代码:
Omniscent-main.zip

我修改了些代码,gitee地址:

r77683962/Omniscent

2、nodejs安装完成后通过npm安装pnpm、tsc、rollup,有兴趣可以搜索下这些命令的功能,进入cmd执行以下命令,(建议使用管理员模式进入cmd,不然有些安装会报没有权限):
npm config set registry https://registry.npmmirror.com/
npm i -g pnpm
pnpm i tsc
pnpm i rollup

3、在webstorm设置node.js和pnpm工具地址

File菜单->settings->Languages&Frameworks->node.js,然后使用自已安装的路径替换
node路径(这个根据自已的安装路径设置):
C:\Program Files\nodejs\node.exe

pnpm路径(这个根据自已的安装路径设置):
C:\Users\PC\AppData\Roaming\npm\pnpm.cmd


4、Omniscent-main.zip代码解压,然后使用webstorm打开解压目录(要注意被打开的目录里有src、types这些目录才对)

5、编译代码根目录package.json第25行

"build": "rollup -c"

这行前边会有一个绿色的三角形,点击这个三角形,选择Run 'build',编译日志如下

C:\Users\Administrator\AppData\Roaming\npm\pnpm.cmd run build

> omniscent@ build D:\projects\Omniscent_git
> rollup -c


src/index.ts → lib/cjs, lib/esm...
Browserslist: caniuse-lite is outdated. Please run:
  npx update-browserslist-db@latest
  Why you should do it regularly: https://github.com/browserslist/update-db#readme
created lib/cjs, lib/esm in 2.1s

demo/src/index.ts → dist...
created dist in 7s

Process finished with exit code 0
编译完成在根目录下会生成dist、lib、node_modules目录

6、打开根目录dist目录的index.html文件点击右上角的Chrome图标,点击Play,就可以看到运行的3D界面了

7、可以通过命令行添加日志,便于理解代码,运行时打开浏览器的检查查看运行时的日志:

比如:代码里在根目录下Omniscent.ts文件中constructor()方法里添加了console.log("Omniscent constructor");

执行第5步编译,然后执行第6步,打开index.html文件,打开检查开关,刷新页面,可以看到运行的日志:

这里要注意的是,实际运行的代码是由ts编译的mjs文件,所以如果修改了ts代码,需要重新编译,编译完成后,刷新原来打开的index.html页面后,再点击Play就可以看到新修改的代码生效。

这个代码主要用到:three.js(3D库)

three.js在线帮助手册: https://threejs.org/docs/index.html#manual/en/introduction/Creating-a-scene

参考来源:
https://blog.csdn.net/xueli_2017/article/details/91492971

这个链接也有些有意思的例子:GitHub - gkjohnson/three-mesh-bvh: A BVH implementation to speed up raycasting and enable spatial queries against three.js meshes.o

  • 15
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值