Skip to content

Instantly share code, notes, and snippets.

View ccincotti3's full-sized avatar

Carmen Cincotti ccincotti3

View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Carmen's Fun WebGPU Triangle</title>
</head>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Carmen's Fun WebGPU Triangle</title>
</head>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Carmen's Fun WebGPU Triangle</title>
</head>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Carmen's Fun WebGPU Triangle</title>
</head>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Carmen's Fun WebGPU Triangle</title>
</head>
@ccincotti3
ccincotti3 / webgpu-triangle-series-part-1.html
Created December 5, 2022 14:21
This is the code that we worked on in part one of the WebGPU YouTube Series.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Carmen's Fun WebGPU Triangle</title>
</head>
<body>
<canvas id="canvas-container"></canvas>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Carmen Cincotti - WebGPU Triangle</title>
<style>
canvas {
import { vecDistSquared } from "./math";
/**
* Hash table for self collisions of the Cloth object
*
* https://github.com/matthias-research/pages/blob/master/tenMinutePhysics/11-hashing.pdf
* https://www.carmencincotti.com
*/
export class Hash {
private spacing: number;
/**
* Query for items in hash table
* After execution, check results in:
* - queryIds - particle ids found in query
* - querySize - number of particles found
*
* Theory:
* https://www.carmencincotti.com/2022-11-07/spatial-hash-maps-part-two/
*/
query(pos: Float32Array, nr: number, maxDist: number) {
/**
* Create the spatial hash table data structure - based off of
* https://github.com/matthias-research/pages/blob/master/tenMinutePhysics/11-hashing.pdf
*
* Theory:
* https://www.carmencincotti.com/2022-10-31/spatial-hash-maps-part-one/
*
* Scroll down to Creating the Data Structure Slide
*/
create(pos: Float32Array) {