A non-exhaustive list of WebGL and WebGPU frameworks and libraries. It is mostly for learning purposes as some of the libraries listed are wip/outdated/not maintained anymore.
Name | Stars | Last Commit | Description |
---|---|---|---|
three.js | ![GitHub |
function isTranferable(obj) { | |
try { | |
return ( | |
obj instanceof ArrayBuffer || | |
obj instanceof MessagePort || | |
obj instanceof ImageBitmap || // safari 15+ ios 15+ | |
obj instanceof OffscreenCanvas // safari 16.4+ ios 16.4+ | |
); | |
} catch { | |
return false; |
A non-exhaustive list of WebGL and WebGPU frameworks and libraries. It is mostly for learning purposes as some of the libraries listed are wip/outdated/not maintained anymore.
Name | Stars | Last Commit | Description |
---|---|---|---|
three.js | ![GitHub |
#!/usr/bin/env node | |
var fs = require('fs'); | |
var http = require('http'); | |
var path = require('path'); | |
var rollup = require('rollup'); | |
var rollupConfig = require('../rollup.config'); | |
var CONTENT_TYPES = { | |
'.html': 'text/html', |
/* makes sizing simpler */ | |
*, | |
*::before, | |
*::after { | |
box-sizing: border-box; | |
} | |
/* remove default spacing */ | |
/* force styling of type through styling, rather than elements */ |
import imagemin from 'imagemin'; | |
import imageminWebp from 'imagemin-webp'; | |
import imageminPngquant from 'imagemin-pngquant'; | |
const produceWebP = async () => { | |
const outputFolder = './images/webp'; | |
await imagemin(['images/*.png'], { | |
destination: outputFolder, | |
plugins: [ |
{ | |
"root": true, | |
"env": { | |
"es2022": true, | |
"browser": true, | |
"node": true | |
}, | |
"parserOptions": { | |
"ecmaVersion": 2022, | |
"sourceType": "module" |
/* | |
* Based on example code by Stefan Gustavson (stegu@itn.liu.se). | |
* Optimisations by Peter Eastman (peastman@drizzle.stanford.edu). | |
* Better rank ordering method by Stefan Gustavson in 2012. | |
* | |
* This code was placed in the public domain by its original author, | |
* Stefan Gustavson. You may use it as you see fit, but | |
* attribution is appreciated. | |
*/ |
const isFn = (a) => typeof a === 'function'; | |
export function addObjectPool(objtype, resetFunction, maxSize = Number.MAX_SAFE_INTEGER) { | |
const pool = []; | |
function newObject() { | |
return new objtype(); | |
} | |
if (isFn(resetFunction)) { |
const isRunningInBrowser = typeof window !== 'undefined'; | |
function runWhenBrowserEnvReady(fn) { | |
if (isRunningInBrowser) { | |
const doc = document; | |
doc.readyState[0] === 'l' ? doc.addEventListener('DOMContentLoaded', fn) : fn(); | |
} else { | |
fn(); | |
} | |
} |
const idleOptions = { timeout: 500 }; | |
const request = window.requestIdleCallback || window.requestAnimationFrame; | |
const cancel = window.cancelIdleCallback || window.cancelAnimationFrame; | |
const resolveWhenIdle = { | |
request, | |
cancel, | |
promise: (num) => new Promise((resolve) => request(resolve, Object.assign({}, idleOptions, num))), | |
}; |