轻量封装WebGPU渲染系统示例<52>- Json数据描述材质、纹理等3D渲染场景信息

当前示例源码github地址:

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

当前示例运行效果:

​​​​​​​

Json数据:

{"renderer": {"mtplEnabled": true,"camera": {"eye": [1100,1100,500],"up": [0,1,0]}},"resource": {"textures": [{"name": "plastic","list": [{"albedo": {"url": "static/assets/pbr/plastic/albedo.jpg"}},{"normal": {"url": "static/assets/pbr/plastic/normal.jpg"}},{"ao": {"url": "static/assets/pbr/plastic/ao.jpg"}},{"roughness": {"url": "static/assets/pbr/plastic/roughness.jpg"}},{"metallic": {"url": "static/assets/pbr/plastic/metallic.jpg"}},{"specularEnv": {}}]},{"name": "rusted_iron","list": [{"albedo": {"url": "static/assets/pbr/rusted_iron/albedo.jpg"}},{"normal": {"url": "static/assets/pbr/rusted_iron/normal.jpg"}},{"ao": {"url": "static/assets/pbr/rusted_iron/ao.jpg"}},{"roughness": {"url": "static/assets/pbr/rusted_iron/roughness.jpg"}},{"metallic": {"url": "static/assets/pbr/rusted_iron/metallic.jpg"}},{"specularEnv": {}}]},{"name": "wall","list": [{"albedo": {"url": "static/assets/pbr/wall/albedo.jpg"}},{"normal": {"url": "static/assets/pbr/wall/normal.jpg"}},{"ao": {"url": "static/assets/pbr/wall/ao.jpg"}},{"roughness": {"url": "static/assets/pbr/wall/roughness.jpg"}},{"metallic": {"url": "static/assets/pbr/wall/metallic.jpg"}},{"specularEnv": {}}]}]},"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": [{"position": [-200,600,100],"direction": [2,-1,-0.5],"color": [5,10,0],"degree": 50,"factor1": 0.00001,"factor2": 0.00002}]},"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.8,0.2],"albedo": [0.7,0.6,0.5],"uvParam": [3,3,0,0],"textures": 2}]}}},{"sphere": {"entity": {"radius": 80,"transform": {"position": [0,100,200]},"materials": [{"type": "default","lighting": true,"shadow": true,"shadowReceived": true,"fogging": true,"arms": [1,0.9,0.2],"albedo": [0.7,0.8,0.5],"emissive": [0.5,0.5,0.5],"textures": 0}]}}},{"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],"uvParam": [2,2,0,0],"textures": 1}]}}},{"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.6,0.2],"albedo": [1.3,0.9,1.3],"uvParam": [8,2,0,0],"textures": 2}]}}},{"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": [1.6,0.9,1.8],"textures": 1}]}}},{"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": {}}}]
}

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


export class DataDrivenScene3 {private mScene = new DataDrivenRScene();initialize(): void {console.log("DataDrivenScene3::initialize() ...");let url = "static/assets/scene/sceneData03.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.mzph.cn/news/229799.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

16、vue3(十六):数据大屏(一):尺寸适配,水球图,柱形图,饼状图、图例

目录 一、尺寸适配解决方案 1.vw和vh 2.scale 二、数据大屏顶部搭建 1.思路分析

lightdb mysql模式下的datediff

文章目录 背景MySQL行为LightDB MySQL兼容模式行为DATEDIFF 背景 在信创适配中,有从MySQL迁移过来的程序,其中程序涉及日期加减数字的场景和使用datediff函数的场景。因此在LightDB-X 23.4版本中,MySQL兼容模式下对日期加减数字做了支持&…

[原创][R语言]股票分析实战[2]:周级别涨幅趋势的相关性

[简介] 常用网名: 猪头三 出生日期: 1981.XX.XX QQ联系: 643439947 个人网站: 80x86汇编小站 https://www.x86asm.org 编程生涯: 2001年~至今[共22年] 职业生涯: 20年 开发语言: C/C、80x86ASM、PHP、Perl、Objective-C、Object Pascal、C#、Python 开发工具: Visual Studio、D…

频谱论文:面向频谱地图构建的频谱态势生成技术研究

#频谱# [1]李竟铭.面向频谱地图构建的频谱态势生成技术研究.2019.南京航空航天大学,MA thesis.doi:10.27239/d.cnki.gnhhu.2019.000556. (南京航空航天大学) 频谱地图是对无线电环境的抽象表达,它可以直观、多维度地展现频谱态势信息&…

RabbitMq交换机详解

目录 1.交换机类型2.Fanout交换机2.1.声明队列和交换机2.2.消息发送2.3.消息接收2.4.总结 3.Direct交换机3.1.声明队列和交换机3.2.消息接收3.3.消息发送3.4.总结 4.Topic交换机4.1.说明4.2.消息发送4.3.消息接收4.4.总结 5.Headers交换机5.1.说明5.2.消息发送5.3.消息接收5.4.…

React 实现列表页和列表详情页功能

1.简介 本篇文章将会基于react 实现列表页和列表详情的功能,后续会完善更多的功能细节。 2.实现 a.app.js 入口类,实现路由功能 import ./App.css; import {BrowserRouter, Route, Routes} from react-router-dom; import {UserList} from "./p…

python渗透测试入门——流量嗅探器

1.代码及代码讲解。 代码编写工具:VsCode (1)socket嗅探器 首先第一个脚本是最简单的原始socket嗅探器,它只会读一个数据包,然后直接退出: import socket import os#host to listen on HOST #这里输入…

Redis Cluster集群搭建 三主三从

Redis包下载 Linux: http://download.redis.io/releases/ Mac or Windows: https://redis.io/download/ 2.下载后解压进入文件夹(本次我的Redis版本是6.2.14版本) /redis/redis-6.2.14 开始安装 make instarll修改配置文件复制redis.conf 6…

Mysql适用Sql语句对数据库表的字段进行增加、删除和修改等一系列操作

对表字段进行增加:需要指定操作的表名,新增字段的字段名以及字段数据类型。 alter table TableName add column FieldName FieldType 对表字段进行删除:需要指定操作的表名,想要删除的字段名。 alter table TableName drop FieldN…

STM32F103RCT6开发板M3单片机教程04--按键检测

原画图讲解 本教程使用是(光明谷SUN_STM32mini开发板) 首先了硬件连接原理,STM32F103RCT6开发板是mini最小系统板,板子在没并有按键。需要自行用面包板搭建。 硬件连接: PC10 -> KEY1 (MCU内部上拉…

【PostgreSQL】从零开始:(十一)PostgreSQL-Dropdb命令删除数据库

dropdb命令删除数据库 命令 [postgrespostgre-sql bin]$ dropdb --help dropdb removes a PostgreSQL database.Usage:dropdb [OPTION]... DBNAMEOptions:-e, --echo show the commands being sent to the server-f, --force try to terminate …

mysql原理--InnoDB的表空间

1.概述 通过前边儿的内容大家知道, 表空间 是一个抽象的概念。 对于系统表空间来说,对应着文件系统中一个或多个实际文件;对于每个独立表空间来说,对应着文件系统中一个名为 表名.ibd 的实际文件。可以把表空间想象成被切分为许许…

C#基础知识 - 操作数与运算符篇2

C#基础知识 - 操作数与运算符篇 4.2 运算符4.2.1 按操作数个数分类4.2.2 按运算类型分类4.2.3 对运算符 、-- 的使用4.2.4 关系运算符&#xff1a;>、 < 、> 、<、 ! 、4.2.5 逻辑运算符&#xff1a;&& || ! ^ & |4.2.6 位运算符&#xff1a;~ 、^、 &…

neuq-acm预备队训练week 10周报

neuq-acm预备队训练week 10 P1525 [NOIP2010 提高组] 关押罪犯-CSDN博客 neuq-acm预备队训练week 10 P3386 【模板】二分图最大匹配-CSDN博客 neuq-acm预备队训练week 10 P1129 [ZJOI2007] 矩阵游戏-CSDN博客

2020-XNUCA babyv8

做的第一道存在指针压缩机制的V8题&#xff0c;通过小越界写修改length构造大越界读写&#xff0c;然后利用arraybuffer的backing store构造任意地址写&#xff0c;利用wasm rwx段地址的特点以及堆空间的分布&#xff0c;搜索到rwx段的具体地址&#xff0c;然后利用任意地址写将…

掌握分片上传:优化大文件传输的关键策略 【C++】【WinHttp】【curl】

目录 引言 第一部分&#xff1a;分片上传的基本概念 1. 分片上传以及它的工作原理 2. 为什么选择分片上传 第二部分&#xff1a;实现分片上传的关键步骤 1. 文件分片的方法&#xff0c;如何选择合适的分片大小 文件分片的基本步骤&#xff1a; 如何选择合适的分片大小&a…

Leetcode 2966. Divide Array Into Arrays With Max Difference

Leetcode 2966. Divide Array Into Arrays With Max Difference 1. 解题思路2. 代码实现 题目链接&#xff1a;2966. Divide Array Into Arrays With Max Difference 1. 解题思路 这一题思路上来说其实很简单&#xff0c;想清楚这个问题必然是有序排列之后三个三个组成一组即…

当OneNote不同步时,你需要做些什么让其恢复在线

OneNote笔记本无法同步的原因有很多。由于OneNote使用OneDrive将笔记本存储在云中,因此可能会出现互联网连接问题,与多人联机处理笔记本时会出现延迟,以及从不同设备处理同一笔记本时会发生延迟。以下是OneNote不同步时的操作。 注意:本文中的说明适用于OneNote for Windo…

急速上手搭建单节点 k8s集群实战

Minikube搭建 是一种轻量化的Kubernetes集群&#xff0c;是k8s社区为了帮助开发者和学习者能够更好学习和体验k8s功能而推出的&#xff0c;使用个人PC的虚拟化环境就快速构建启动单节点k8s机器准备&#xff1a;阿里云 CentOS 7.x &#xff0c;2核4g 安装 安装Docker # 1.先…

flask简单应用-1

目标&#xff1a; 做一个搜索网页&#xff0c;搜索当前路径下是否含有指定关键字的文件&#xff0c;如果有就列出来&#xff0c;没有返回消息 第一步&#xff1a;我们需要先显示一个搜索页面&#xff0c;页面上需要有一个可以输入的对话框&#xff0c;一个按钮执行搜索 建立ht…