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

用什么软件做网站原型租空间做网站

用什么软件做网站原型,租空间做网站,做网站好不好,郑州企业网站排名对应的教程文章: https://codelabs.developers.google.com/your-first-webgpu-app?hlzh-cn#5 对应的源码执行效果: 对应的教程源码: 此处源码和教程本身提供的部分代码可能存在一点差异。运行的时候#xff0c;点击画面可以切换效果。 class Color4 {r: number;g: numb…对应的教程文章:  https://codelabs.developers.google.com/your-first-webgpu-app?hlzh-cn#5 对应的源码执行效果: 对应的教程源码:  此处源码和教程本身提供的部分代码可能存在一点差异。运行的时候点击画面可以切换效果。 class Color4 {r: number;g: number;b: number;a: number;constructor(pr 1.0, pg 1.0, pb 1.0, pa 1.0) {this.r pr;this.g pg;this.b pb;this.a pa;} }export class WGPURStorage2 {private mRVertices: Float32Array null;private mRPipeline: any | null null;private mVtxBuffer: any | null null;private mCanvasFormat: any | null null;private mWGPUDevice: any | null null;private mWGPUContext: any | null null;private mUniformBindGroups: any | null null;private mGridSize 32;constructor() {}initialize(): void {const canvas document.createElement(canvas);canvas.width 512;canvas.height 512;document.body.appendChild(canvas);console.log(ready init webgpu ...);this.initWebGPU(canvas).then(() {console.log(webgpu initialization finish ...);this.updateWGPUCanvas();});document.onmousedown (evt):void {this.updateWGPUCanvas( new Color4(0.05, 0.05, 0.1) );}}private mUniformObj: any {uniformArray: null, uniformBuffer: null};private createStorage(device: any): any {// Create an array representing the active state of each cell.const cellStateArray new Uint32Array(this.mGridSize * this.mGridSize);// Create two storage buffers to hold the cell state.const cellStateStorage [device.createBuffer({label: Cell State A,size: cellStateArray.byteLength,usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,}),device.createBuffer({label: Cell State B,size: cellStateArray.byteLength,usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,})];// Mark every third cell of the first grid as active.for (let i 0; i cellStateArray.length; i3) {cellStateArray[i] 1;}device.queue.writeBuffer(cellStateStorage[0], 0, cellStateArray);// Mark every other cell of the second grid as active.for (let i 0; i cellStateArray.length; i) {cellStateArray[i] i % 2;}device.queue.writeBuffer(cellStateStorage[1], 0, cellStateArray);return cellStateStorage;}private createUniform(device: any, pipeline: any): void {// Create a uniform buffer that describes the grid.const uniformArray new Float32Array([this.mGridSize, this.mGridSize]);const uniformBuffer device.createBuffer({label: Grid Uniforms,size: uniformArray.byteLength,usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,});device.queue.writeBuffer(uniformBuffer, 0, uniformArray);const cellStateStorage this.createStorage(device);const bindGroups [device.createBindGroup({label: Cell renderer bind group A,layout: pipeline.getBindGroupLayout(0),entries: [{binding: 0,resource: { buffer: uniformBuffer }}, {binding: 1,resource: { buffer: cellStateStorage[0] }}],}),device.createBindGroup({label: Cell renderer bind group B,layout: pipeline.getBindGroupLayout(0),entries: [{binding: 0,resource: { buffer: uniformBuffer }}, {binding: 1,resource: { buffer: cellStateStorage[1] }}],})];this.mUniformBindGroups bindGroups;const obj this.mUniformObj;obj.uniformArray uniformArray;obj.uniformBuffer uniformBuffer;}private mStep 0;private createRectGeometryData(device: any, pass: any): void {let vertices this.mRVertices;let vertexBuffer this.mVtxBuffer;let cellPipeline this.mRPipeline;if(!cellPipeline) {let hsize 0.8;vertices new Float32Array([// X, Y,-hsize, -hsize, // Triangle 1 (Blue)hsize, -hsize,hsize, hsize,-hsize, -hsize, // Triangle 2 (Red)hsize, hsize,-hsize, hsize,]);vertexBuffer device.createBuffer({label: Cell vertices,size: vertices.byteLength,usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,});device.queue.writeBuffer(vertexBuffer, /*bufferOffset*/0, vertices);const vertexBufferLayout {arrayStride: 8,attributes: [{format: float32x2,offset: 0,shaderLocation: 0, // Position, see vertex shader}],};const shaderCodes struct VertexInput {location(0) pos: vec2f,builtin(instance_index) instance: u32,};struct VertexOutput {builtin(position) pos: vec4f,location(0) cell: vec2f,};group(0) binding(0) varuniform grid: vec2f;group(0) binding(1) varstorage cellState: arrayu32;vertexfn vertexMain(input: VertexInput) - VertexOutput {let i f32(input.instance);let cell vec2f(i % grid.x, floor(i / grid.x));let cellOffset cell / grid * 2;let state f32(cellState[input.instance]);let gridPos (input.pos * state 1) / grid - 1 cellOffset;var output: VertexOutput;output.pos vec4f(gridPos, 0, 1);output.cell cell;return output;}fragmentfn fragmentMain(input: VertexOutput) - location(0) vec4f {// return vec4f(input.cell, 0, 1);let c input.cell/grid;return vec4f(c, 1.0 - c.x, 1);};const cellShaderModule device.createShaderModule({label: Cell shader,code: shaderCodes});cellPipeline device.createRenderPipeline({label: Cell pipeline,layout: auto,vertex: {module: cellShaderModule,entryPoint: vertexMain,buffers: [vertexBufferLayout]},fragment: {module: cellShaderModule,entryPoint: fragmentMain,targets: [{format: this.mCanvasFormat}]},});this.mRVertices vertices;this.mVtxBuffer vertexBuffer;this.mRPipeline cellPipeline;this.createUniform(device, cellPipeline);}pass.setPipeline(cellPipeline);pass.setVertexBuffer(0, vertexBuffer);// pass.setBindGroup(0, this.mUniformBindGroup);pass.setBindGroup(0, this.mUniformBindGroups[this.mStep % 2]);pass.draw(vertices.length / 2, this.mGridSize * this.mGridSize);this.mStep ;}private updateWGPUCanvas(clearColor: Color4 null): void {clearColor clearColor ? clearColor : new Color4(0.05, 0.05, 0.1);const device this.mWGPUDevice;const context this.mWGPUContext;const rpassParam {colorAttachments: [{clearValue: clearColor,// clearValue: [0.3,0.7,0.5,1.0], // yesview: context.getCurrentTexture().createView(),loadOp: clear,storeOp: store}]};const encoder device.createCommandEncoder();const pass encoder.beginRenderPass( rpassParam );this.createRectGeometryData(device, pass);pass.end();device.queue.submit([ encoder.finish() ]);}private async initWebGPU(canvas: HTMLCanvasElement) {const gpu (navigator as any).gpu;if (gpu) {console.log(WebGPU supported on this browser.);const adapter await gpu.requestAdapter();if (adapter) {console.log(Appropriate GPUAdapter found.);const device await adapter.requestDevice();if (device) {this.mWGPUDevice device;console.log(Appropriate GPUDevice found.);const context canvas.getContext(webgpu) as any;const canvasFormat gpu.getPreferredCanvasFormat();this.mWGPUContext context;this.mCanvasFormat canvasFormat;console.log(canvasFormat: , canvasFormat);context.configure({device: device,format: canvasFormat,alphaMode: premultiplied});} else {throw new Error(No appropriate GPUDevice found.);}} else {throw new Error(No appropriate GPUAdapter found.);}} else {throw new Error(WebGPU not supported on this browser.);}}run(): void {} } 切换后的效果:
http://wiki.neutronadmin.com/news/77776/

相关文章:

  • 网站开发开票内容写什么网站设计风格大全
  • 电脑商业网站怎的做简单的品牌创意设计公司
  • 北大荒建设集团有限公司网站网站中文名称注册
  • 网站建设技巧饣金手指排名27威县网站建设
  • 室内设计学校排名榜国内广州做网站seo
  • 网站百度收录是什么意思肥城做网站tahmwlkj
  • 深圳网站建设罗湖国内老牌的广州网站建设
  • 淘宝客高佣金网站建设怎样做外国石雕产品网站
  • 无极门户网站手机网站建设原则
  • 网站突然掉排名了中国前十强集团
  • 三网合一网站报价手机百度云网页版登录
  • 珠海电脑自己建网站免费网站推广群发软件
  • 网站开发国内外研究状况摄影网站备案
  • 免费推广网站2022张家界做旅游网站
  • 建站seo推广手机页面网站开发例子
  • 值得相信的西安网站开发网站代运营合同模板
  • 网站页面高度深圳网站建设哪家公司好
  • 建设企业网站可信度网站开发写好了怎么发布
  • 外贸营销网站制作腾讯云 安装 wordpress
  • 一家专做中式设计的网站中国企业500强营业收入
  • 阿里云网站建设流程网上效果代码网站可以下载吗
  • 哪个网站可以做ppt网站的规划与建设课程设计
  • 网站设计与平面设计区别广州网站设计 信科网络
  • 摄影网站的模板企业局域网组网方案
  • 群晖做网站连接数据库网站建设的实验报告总结
  • 网站收录提交入口网址佛山网站建设运营
  • 昆明网络推广公司排名三明seo培训
  • 高中男女做羞羞视频网站新站seo快速排名 排名
  • 中国网站建设公司河南网站排名优化价格
  • 网络上建个网站买东西多少钱传奇手游官方网站