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

发布时间:2023年12月31日

当前示例源码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();
	}
}

文章来源:https://blog.csdn.net/vily_lei/article/details/135319318
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。