From 501949828db6414bf712ba31d1b66b0e24512c2b Mon Sep 17 00:00:00 2001 From: Szymon Nowakowski Date: Thu, 6 Nov 2025 16:32:41 +0100 Subject: [PATCH] Modernize project --- .editorconfig | 5 ++++- AUTHORS | 2 +- README.md | 6 +++--- bun.lock | 22 ++++++++++++++++++++++ bun.lockb | Bin 11076 -> 0 bytes example/index.html | 4 ++-- example/script.ts | 6 +++--- example/types.d.ts | 4 ++++ package.json | 16 ++++++---------- src/_BinaryWriter.ts | 4 ++-- src/gltf.ts | 4 ++-- src/resources/IndexBuffer.ts | 2 +- src/resources/VertexBuffer.ts | 10 +++++----- 13 files changed, 55 insertions(+), 30 deletions(-) create mode 100644 bun.lock delete mode 100644 bun.lockb create mode 100644 example/types.d.ts diff --git a/.editorconfig b/.editorconfig index d9ac3e2..f2709cb 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,8 +6,11 @@ end_of_line = lf indent_size = 4 indent_style = tab insert_final_newline = true -tab_width = 4 trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false + +[bun.lock] +indent_size = 2 +indent_style = space diff --git a/AUTHORS b/AUTHORS index 8023d98..3a300b5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1 +1 @@ -Szymon Nowakowski (https://renati.me) +Szymon Nowakowski (https://renati.me) diff --git a/README.md b/README.md index 3b9db94..c641b29 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ -This project ships with [bun.lockb](https://bun.sh/docs/install/lockfile) +This project ships with [bun.lock](https://bun.sh/docs/install/lockfile) lockfile for the [Bun](https://bun.sh/) JavaScript runtime. You should be able to install the dependencies with any JavaScript package manager, though. -To run the example, run `start:example` script with your JavaScript package -manager and visit [localhost:8000](http://localhost:8000). +To run the example, run `bun run start:example`. The example relies on the Bun +JavaScript runtime to bundle and serve the example. diff --git a/bun.lock b/bun.lock new file mode 100644 index 0000000..80fdc6e --- /dev/null +++ b/bun.lock @@ -0,0 +1,22 @@ +{ + "lockfileVersion": 1, + "workspaces": { + "": { + "name": "oktaeder", + "dependencies": { + "tslib": "^2.6.2", + }, + "devDependencies": { + "@webgpu/types": "^0.1.66", + "typescript": "^5.9.3", + }, + }, + }, + "packages": { + "@webgpu/types": ["@webgpu/types@0.1.66", "", {}, "sha512-YA2hLrwLpDsRueNDXIMqN9NTzD6bCDkuXbOSe0heS+f8YE8usA6Gbv1prj81pzVHrbaAma7zObnIC+I6/sXJgA=="], + + "tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="], + + "typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="], + } +} diff --git a/bun.lockb b/bun.lockb deleted file mode 100644 index db6a8868ad2a70ef43440b60f104b91ca3b30f4f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11076 zcmeHNdt8iL_n*l`rMs?*CP}(YS5pzip+fFSIg+WSn$%2Yri)9A;}(i8$~BHki8weV z<#Ld&Dp7JPI(2eM2Ztksde@$rJu{s5^`rUc_r4$N^O@GO_uA{b*Is+?XRrONj0~-! zIBcr`2Gfepj3x&}F%{rv8O{n^8q5f%TL!b(5j3u4w6%f^fk4=1ox7-xTFPZ7MLZ3{Ked$Nn=b~x#W)VOICm_Z{TeE}oLea3mhvITBHU@hg+=s|QgmlMti0I3rE z6bJ+!of8nn2oEA`g>KcM91DC1@F3tCz~>6-PdjxSNFXDB!3+ny@?_IMR0nj@lUk*95L2l)nRek-P&q!fybM^nszV@UqQh z>lQ?8`O)n_%aKg&vu_U=^DN9a&;wMB#{UpA=v5Kbv*z@{l!6ss6cJmBY zWzSE&)RBC6h_?Hi)Nx%#VTpU<<4O6U{%T`mA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ImDc}~%<%)6D)m@q8qbxV5hHne56`1oD-H)(j%d(K8w+{*IUo&#)hOz`oOW4~RSfTkJc1_rP}#eD}b2 z5Bwh69zuHxzQQgv4rC9q3)zSC z5e~vbxCkHhgZe}LqW;m{1lfb^LiQm$k-f-nWIq}Q8V?#58Xp=b8t-GFJvn4304X^C zXiN2ras;PSMLx6n%<0e$@Oe0ICr4atO|hZaTZ9Y^^D_e0#tS9?n^UWDLa~ z1O%L|#aT@m;$mA06-gSP9~c`C=LtzfKtf=I4v@g;c{r0Omb?QA_=kscjbaJTvf^x{ zSc3DgIA1B2;7l#fXo@8`my2_rVhPUn;;g7xg7d*RZz`7Hj4{rviX}LwjB~GI3C=p> z?5tRV^U^qfE0*BQHO}ygB{;W@bHHK=&VJ)8u~>rh<2a8jmf#FJ&NPc9ILD52(P9bC z!sBeUSc3EPmBM_sSb{V8IO8pr;9Nh>iHjvK$go6!tPKVH(>D)?9uZAvQ>Mgn>1-w~ zd>)t0V1`T}+lV)Vqi8d5Ie~nLi|;iKv3DeCpnrTobt?C>oSzL_R>I|Q=xjjqYap+k z8$A8(RA>!*lDFP*Obszsxp#@sf_yV<3EFoy|8d*7#?S*oBBQLh%OmL={+~cLBa$1+ zdctdwjQ3gA*A24*-sxlXdK8+LBf?>0C5C$tqSPo%wkkCyL49e9{WM zXJ`AF{{(fP3{Fr5@LyN}BJ)IzVJ(QBC04`NV;~zuAgItU6#nWE!SGAph$HeFpopHo z5kq1=07atojX2_|1{iVS8&L#{4JH&oM9=-g;4e)P3cu7Z9O1$jAqmUiqBpRM9mB1s;Nk>;K>1e*tdQj}QO= diff --git a/example/index.html b/example/index.html index b0b7d08..94ff3c6 100644 --- a/example/index.html +++ b/example/index.html @@ -4,8 +4,8 @@ oktaeder example - - + + diff --git a/example/script.ts b/example/script.ts index 5a26ca0..82fcb2a 100644 --- a/example/script.ts +++ b/example/script.ts @@ -1,10 +1,10 @@ /// +/// import { Color, Mesh, Node, PerspectiveCamera, PointLight, Quaternion, Scene, Submesh, Vector3 } from "../src/data/index"; import { Renderer, degToRad } from "../src/oktaeder"; import "./style.css"; - -new EventSource("/esbuild").addEventListener("change", () => location.reload()); +import uvmapUrl from "./uvmap.png"; const canvas = document.createElement("canvas"); window.addEventListener("resize", onResize); @@ -66,7 +66,7 @@ const submesh: Submesh = { start: 0, length: 24 }; const mesh = new Mesh({ vertexBuffer, indexBuffer, submeshes: [submesh] }); -const imageBitmap = await loadImageBitmap("/uvmap.png"); +const imageBitmap = await loadImageBitmap(uvmapUrl); const texture = renderer.createTexture({ format: "srgb", diff --git a/example/types.d.ts b/example/types.d.ts new file mode 100644 index 0000000..1884019 --- /dev/null +++ b/example/types.d.ts @@ -0,0 +1,4 @@ +declare module "*.png" { + const url: string; + export default url; +} diff --git a/package.json b/package.json index 9555b64..dbfa466 100644 --- a/package.json +++ b/package.json @@ -7,27 +7,23 @@ "gltf", "wegbpu" ], - "homepage": "https://github.com/iszn11/oktaeder", - "bugs": { - "url": "https://github.com/iszn11/oktaeder/issues" - }, + "homepage": "https://gitea.renati.me/renati/oktaeder", "license": "MPL-2.0", "browser": "./dist/oktaeder.js", "repository": { "type": "git", - "url": "https://github.com/iszn11/oktaeder.git" + "url": "https://gitea.renati.me/renati/oktaeder.git" }, "scripts": { - "start:example": "esbuild example/script.ts --bundle --outfile=example/bundle.js --watch --servedir=example --format=esm --sourcemap", + "start:example": "bun run example/index.html", "build": "tsc --build" }, "dependencies": { - "tslib": "^2.6.2" + "tslib": "^2.8.1" }, "devDependencies": { - "@webgpu/types": "^0.1.40", - "esbuild": "^0.20.2", - "typescript": "^5.4.2" + "@webgpu/types": "^0.1.66", + "typescript": "^5.9.3" }, "exports": { ".": { diff --git a/src/_BinaryWriter.ts b/src/_BinaryWriter.ts index e4c9adb..496c6c5 100644 --- a/src/_BinaryWriter.ts +++ b/src/_BinaryWriter.ts @@ -12,10 +12,10 @@ export class _BinaryWriter { _buffer: ArrayBuffer; _dataView: DataView; - _typedArray: Uint8Array; + _typedArray: Uint8Array; _length: number; - get subarray(): Uint8Array { return new Uint8Array(this._buffer, 0, this._length); } + get subarray(): Uint8Array { return new Uint8Array(this._buffer, 0, this._length); } constructor(capacity = _BinaryWriter.DEFAULT_CAPACITY) { capacity = Math.max(capacity, 1); diff --git a/src/gltf.ts b/src/gltf.ts index 39cd0a1..e20947a 100644 --- a/src/gltf.ts +++ b/src/gltf.ts @@ -69,7 +69,7 @@ import * as resources from "./resources"; * - issues error * - BLEND: partial support * - decoded, but not implemented - * - doubleSided: prtial support + * - doubleSided: partial support * - decoded, but not implemented * * Extensions: @@ -240,7 +240,7 @@ export async function parse(gltf: ArrayBufferView, { } if (version !== 2) { - const message = `Unsupported binary glTF container format. The bytes 4-8 define the binary glTF conatiner format version when read as little endian unsigned integer. Only version 2 is supported, but in the provided buffer they have the value of ${version}`; + const message = `Unsupported binary glTF container format. The bytes 4-8 define the binary glTF container format version when read as little endian unsigned integer. Only version 2 is supported, but in the provided buffer they have the value of ${version}`; const error = new ParseError({ message, severity: "error" }); if (throwOnError) { throw error; diff --git a/src/resources/IndexBuffer.ts b/src/resources/IndexBuffer.ts index fd3ed5f..562c212 100644 --- a/src/resources/IndexBuffer.ts +++ b/src/resources/IndexBuffer.ts @@ -64,7 +64,7 @@ export class IndexBuffer { return this.writeTypedArray(offset, array); } - writeTypedArray(offset: number, indices: Uint16Array | Uint32Array): IndexBuffer { + writeTypedArray(offset: number, indices: Uint16Array | Uint32Array): IndexBuffer { if ( this._indexFormat === "uint16" && !(indices instanceof Uint16Array) || this._indexFormat === "uint32" && !(indices instanceof Uint32Array) diff --git a/src/resources/VertexBuffer.ts b/src/resources/VertexBuffer.ts index dfaea2e..11943b2 100644 --- a/src/resources/VertexBuffer.ts +++ b/src/resources/VertexBuffer.ts @@ -42,11 +42,11 @@ export interface VertexBufferWriteArrayProps { } export interface VertexBufferWriteTypedArrayProps { - readonly position?: Float32Array; - readonly texCoord?: Float32Array; - readonly lightTexCoord?: Float32Array; - readonly normal?: Float32Array; - readonly tangent?: Float32Array; + readonly position?: Float32Array; + readonly texCoord?: Float32Array; + readonly lightTexCoord?: Float32Array; + readonly normal?: Float32Array; + readonly tangent?: Float32Array; } export class VertexBuffer {