当前位置: 首页 > news >正文

轻量封装WebGPU渲染系统示例<50>- Json数据描述材质等场景信息

当前示例源码github地址:

https://github.com/vilyLei/voxwebgpu/blob/feature/material/src/voxgpu/sample/DataDrivenScene2.ts

当前示例运行效果:

此示例基于此渲染系统实现,当前示例TypeScript源码如下:

json场景数据:

{"renderer": {"mtplEnabled": true,"camera": {"eye": [1100,1100,500],"up": [0,1,0]}},"scene": {"light": {"pointLights": [{"position": [0,190,0],"color": [5,0,0],"factor1": 0.00001,"factor2": 0.00002}],"directionLights": [{"direction": [-1, -1, 0],"color": [0.5, 0.5, 0.5]}],"spotLights": []},"shadow": {"intensity": 0.4,"radius": 4},"fog": {"color": [0.3,0.7,0.2]}},"entities": [{"plane": {"entity": {"axisType": 1,"extent": [-600,-600,1200,1200],"transform": {"position": [0,0,0]},"materials": [{"type": "default","lighting": true,"shadow": false,"shadowReceived": true,"fogging": true,"arms": [1,0.3,0.2],"albedo": [0.6,0.6,0.5]}]}}},{"sphere": {"entity": {"radius": 80,"transform": {"position": [0,100,200]},"materials": [{"type": "default","lighting": true,"shadow": true,"shadowReceived": true,"fogging": true,"arms": [1,0.3,0.2],"albedo": [0.7,0.6,0.5]}]}}},{"cube": {"entity": {"size": 80,"transform": {"position": [220,130,-10],"scale": [2,1.5,3],"rotation": [-190,0,200]},"materials": [{"type": "default","lighting": true,"shadow": true,"shadowReceived": true,"fogging": true,"arms": [1,0.4,0.2],"albedo": [0.3,0.7,0.8]}]}}},{"torus": {"entity": {"radius": 150,"axisType": 1,"rings": 50,"segments": 30,"transform": {"position": [0,230,0]},"materials": [{"type": "default","lighting": true,"shadow": true,"shadowReceived": true,"fogging": true,"arms": [1,0.2,0.2],"albedo": [0.2,0.5,0.8]}]}}},{"model": {"entity": {"url": "static/assets/draco/monkey.drc","transform": {"position": [0,380,0],"scale": [100,100,100],"rotation": [0,90,0]},"materials": [{"type": "default","lighting": true,"shadow": true,"shadowReceived": true,"fogging": true,"arms": [1,0.5,0.2],"albedo": [0.6,0.3,0.8]}]}}},{"cube": {"entity": {"size": 2050,"normalScale": -1,"materials": [{"type": "default","lighting": true,"fogging": true,"arms": [1,0.3,0.2],"albedo": [0.3,0.3,0.7],"faceCullMode": "front"}]}}},{"gltf": {"entity": {}}},{"usd": {"entity": {}}}]
}

代码:

export class DataDrivenScene2 {private mScene = new DataDrivenRScene();initialize(): void {let url = "static/assets/scene/sceneData02.json";new HttpFileLoader().loadJson(url,(json: object, url: string): void => {console.log("json: ", json);this.initScene(json);});}private initScene(json: object): void {this.mScene.initialize(json);this.initEvent();}private initEvent(): void {const rc = this.mScene;new MouseInteraction().initialize(rc.rscene, 0, false).setAutoRunning(true);}run(): void {this.mScene.run();}
}

http://www.lryc.cn/news/261303.html

相关文章:

  • AtCoder ABC周赛2023 12/10 (Sun) D题题解
  • 基于C/C++的rapidxml加载xml大文件 - 上部分翻译
  • 小程序使用Nodejs作为服务端,Nodejs与与MYSQL数据库相连
  • 深度解读 Cascades 查询优化器
  • Bash 操作审计和安全加固 —— 筑梦之路
  • C/C++常见面试知识总结(三)
  • AR眼镜_AR智能眼镜整机硬件方案定制
  • 2. 皇后的控制力
  • 南京邮电大学数据库实验二
  • 数据库 02-03 补充 SQL的子查询(where,from),子查询作为集合来比较some,exists,all(某一个,存在,所有)
  • 提升英语学习效率,尽在Eudic欧路词典 for Mac
  • 计算机网络英文总结
  • Spring上下文之注解模块ConfigurationMethod
  • 【深度学习】强化学习(三)强化学习的目标函数
  • Python高级算法——人工神经网络(Artificial Neural Network)
  • 深入理解JVM设计的精髓与独特之处
  • fastjson序列化与反序列化的忽略
  • 【TB作品】基于单片机的实验室管理系统,STM32,GM65二维码扫描模块
  • 超过 1450 个 pfSense 服务器因错误链而遭受 RCE 攻击
  • react面试总结2
  • hive 常见存储格式和应用场景
  • PyPDF2库对PDF实现读取的应用
  • C++ stack用法详解
  • QT案例 使用WMI获取win_32类的属性值,包括Win32提供程序类中的属性
  • TCP/UDP 的特点、区别及优缺点
  • 使用 Python 使用贝叶斯神经网络从理论到实践
  • Linux 中的网站服务管理
  • 阿里云cdn设置相同的域名路径访问不同的oss目录
  • 提示(Prompt)工程中提示词的开发优化基础概念学习总结
  • C#基础——语法学习