轻量封装WebGPU渲染系统示例<55>- 顶点数据更新

当前示例源码github地址:

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

当前示例运行效果:

​​​​​​​

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

export class VertexUpdateTest {
	private mRscene = new RendererScene();
	initialize(): void {
		this.mRscene.initialize({
			canvasWith: 512,
			canvasHeight: 512,
			rpassparam:
			{
				multisampled: true
			}
		});
		this.initScene();
		this.initEvent();
	}
	private mPlane: PlaneEntity;
	private initScene(): void {

		let rc = this.mRscene;

		let plane = new PlaneEntity({
			axisType: 1,
			geometryDynamic: true,
			extent: [-600, -600, 1200, 1200]
		});
		this.mPlane = plane;
		rc.addEntity(plane);
	}
	
	private initEvent(): void {
		const rc = this.mRscene;
		rc.addEventListener(MouseEvent.MOUSE_DOWN, this.mouseDown);
		new MouseInteraction().initialize(rc, 0, false).setAutoRunning(true);
	}
	private mouseDown = (evt: MouseEvent): void => {
		
		let geom = this.mPlane.geometry;
		let attrib = geom.getAttribDataWithTypeName('position');
		
		let vs = attrib.data as Float32Array;
		vs[0] -= 100;
		attrib.update();
	};
	run(): void {
		this.mRscene.run();
	}
}

最近更新

  1. TCP协议是安全的吗?

    2024-01-01 17:52:03       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-01 17:52:03       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-01 17:52:03       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-01 17:52:03       18 阅读

热门阅读

  1. Mybatis之增删改查

    2024-01-01 17:52:03       29 阅读
  2. Channel底层简记

    2024-01-01 17:52:03       25 阅读
  3. SOLID之依赖倒置原则

    2024-01-01 17:52:03       49 阅读
  4. chrome.tabs.executeScrip To chrome.scripting.executeScript

    2024-01-01 17:52:03       35 阅读
  5. Python面试之装饰器

    2024-01-01 17:52:03       34 阅读
  6. 网络通讯基础(9):connect ()函数

    2024-01-01 17:52:03       38 阅读
  7. 2024年1月1日答案

    2024-01-01 17:52:03       32 阅读