()
| 146 | } |
| 147 | |
| 148 | async init() { |
| 149 | const shaderModule = await this.loadShader("hello_camera"); |
| 150 | |
| 151 | this.vertexBuffer = this.createBuffer({ |
| 152 | label: "Vertex Buffer", |
| 153 | data: this.vertices, |
| 154 | usage: GPUBufferUsage.VERTEX, |
| 155 | }); |
| 156 | |
| 157 | this.indexBuffer = this.createBuffer({ |
| 158 | label: "Index Buffer", |
| 159 | data: this.indices, |
| 160 | usage: GPUBufferUsage.INDEX, |
| 161 | }); |
| 162 | |
| 163 | this.cameraBuffer = this.createBuffer({ |
| 164 | label: "Camera Buffer", |
| 165 | data: this.cameraUniform, |
| 166 | usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST, |
| 167 | }); |
| 168 | |
| 169 | this.texture = this.device.createTexture({ |
| 170 | label: "Tree Texture", |
| 171 | size: { |
| 172 | width: this.textureImage.width, |
| 173 | height: this.textureImage.height, |
| 174 | depthOrArrayLayers: 1, |
| 175 | }, |
| 176 | mipLevelCount: 1, |
| 177 | sampleCount: 1, |
| 178 | dimension: "2d", |
| 179 | format: "rgba8unorm-srgb", |
| 180 | usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST, |
| 181 | }); |
| 182 | |
| 183 | this.device.queue.writeTexture({ |
| 184 | texture: this.texture, |
| 185 | }, this.textureImage.image, { |
| 186 | offset: 0, |
| 187 | bytesPerRow: this.textureImage.width * 4, |
| 188 | rowsPerImage: this.textureImage.height, |
| 189 | }, { |
| 190 | width: this.textureImage.width, |
| 191 | height: this.textureImage.height, |
| 192 | depthOrArrayLayers: 1, |
| 193 | }); |
| 194 | |
| 195 | this.textureView = this.texture.createView(); |
| 196 | this.textureSampler = this.device.createSampler({ |
| 197 | label: "Tree Texture Sampler", |
| 198 | addressModeU: "clamp-to-edge", |
| 199 | addressModeV: "clamp-to-edge", |
| 200 | addressModeW: "clamp-to-edge", |
| 201 | magFilter: "linear", |
| 202 | minFilter: "nearest", |
| 203 | mipmapFilter: "nearest", |
| 204 | }); |
| 205 |
nothing calls this directly
no test coverage detected