trid3d 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ZachR622
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,105 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/ZachR622/Trid/master/docs/public/logo.svg" width="96" alt="Trid logo">
3
+ </p>
2
4
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
5
+ <h1 align="center">Trid</h1>
6
+
7
+ <p align="center">A small 3D library for the HTML canvas. No dependencies, no build step.</p>
8
+
9
+ ---
10
+
11
+ Trid gives you a scene, a camera, shapes, model loading and mouse/keyboard tools, all in plain ES modules you can drop next to your page.
12
+
13
+ > **Status:** early. Objects can be wireframes or filled and shaded; textures and shaders are on the way.
14
+
15
+ ## Features
16
+
17
+ - **Scene** — holds a canvas, a camera and your objects, and runs the frame loop for you.
18
+ - **Shapes** — cubes, boxes and spheres built in, or any mesh you define as vertices and edges.
19
+ - **Filled faces** — give an object a `material` to fill and shade its faces, flat or smooth, with one directional light.
20
+ - **Textures** — images, canvases or videos on faces, with texture coordinates from built-in shapes and OBJ files.
21
+ - **Effects** — stack shader effects like toon, rim and edge glow, gradients and fog on a material, or write your own in GLSL.
22
+ - **Two renderers** — the canvas 2D context by default, or `WebGLRenderer` for exact depth and big models, with the same scene code.
23
+ - **OBJ files** — load models from a URL, or let users drop their own `.obj` files on the canvas.
24
+ - **Camera** — position, yaw, pitch and field of view, with near-plane clipping.
25
+ - **Tools** — orbit and fly cameras, object dragging, hover highlight, an FPS meter and an OBJ uploader, one line each. Writing your own is a plain object with a few methods.
26
+ - **Pure math** — every transform and projection step is exported, so you can use the pipeline piece by piece.
27
+
28
+ ## Install
29
+
30
+ ```sh
31
+ npm install trid3d
32
+ ```
33
+
34
+ No bundler? Use the CDN with an import map, or copy the `trid/` folder next to your page and import `./trid/index.js`:
35
+
36
+ ```html
37
+ <script type="importmap">
38
+ { "imports": { "trid3d": "https://cdn.jsdelivr.net/npm/trid3d@0.1/trid/index.js" } }
39
+ </script>
40
+ ```
41
+
42
+ ## Quick start
43
+
44
+ ```html
45
+ <canvas id="canvas"></canvas>
46
+ <script type="module" src="main.js"></script>
47
+ ```
48
+
49
+ ```js
50
+ // main.js
51
+ import { Scene, makeShape, OrbitCamera } from "trid3d";
52
+
53
+ const scene = new Scene(document.getElementById("canvas"), { width: 800, height: 400 });
54
+ const cube = scene.add({ mesh: makeShape("cube"), color: "#E9806E" }); // wireframe
55
+ const ball = scene.add({ mesh: makeShape("sphere"), material: { fill: "#8ab4f8" } }); // filled and shaded
56
+ ball.pos.x = 0.8;
57
+
58
+ scene.use(new OrbitCamera()); // drag to orbit, scroll to zoom
59
+ scene.start((dt) => (cube.rot.y += dt));
60
+ ```
61
+
62
+ Without a bundler, serve the folder (`python3 -m http.server`) instead of opening the file directly: browsers block module imports from `file://` pages.
63
+
64
+ ### Loading a model
65
+
66
+ ```js
67
+ import { loadOBJ } from "trid3d";
68
+
69
+ const mesh = await loadOBJ("models/teapot.obj", { fit: 1 }); // centered, 1 unit wide
70
+ scene.add({ mesh });
71
+ ```
72
+
73
+ Or let users load their own: `scene.use(new ObjUploader())` accepts dropped `.obj` files, and `uploader.open()` shows a file dialog.
74
+
75
+ ## Project layout
76
+
77
+ | Folder | Content |
78
+ | --- | --- |
79
+ | `trid/index.js` | Entry file: exports everything (`"trid3d"`) |
80
+ | `trid/scene.js` | The `Scene` class |
81
+ | `trid/math/` | Transforms, camera directions, projection |
82
+ | `trid/render/` | Renderers (Canvas 2D, WebGL), effects, shapes, drawing, frame loop |
83
+ | `trid/loaders/` | OBJ and texture loading |
84
+ | `trid/tools/` | Camera, object and overlay tools |
85
+ | `docs/` | Documentation site with live demos |
86
+
87
+ ## Documentation
88
+
89
+ **[zachr622.github.io/Trid](https://zachr622.github.io/Trid/)**: every class, option and function, with live demos.
90
+
91
+ To run the docs locally (Node 18+):
92
+
93
+ ```sh
94
+ npm install
95
+ npm run docs:dev
96
+ ```
97
+
98
+ See [`docs/README.md`](https://github.com/ZachR622/Trid/blob/master/docs/README.md) for building and editing the docs.
99
+
100
+ ## Roadmap
101
+
102
+ - **More shapes** — cylinder, cone, torus, plane/grid
103
+ - **More tools** — rotate/scale objects with the mouse, selection outline
104
+ - **Parent/child transforms** — e.g. a moon orbiting a planet
105
+ - **Tests** for the math functions
package/package.json CHANGED
@@ -1,6 +1,47 @@
1
1
  {
2
2
  "name": "trid3d",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "A small 3D library for the HTML canvas: wireframes, filled and smooth faces, textures and shader effects, drawn with Canvas 2D or WebGL. No dependencies.",
5
+ "keywords": [
6
+ "3d",
7
+ "canvas",
8
+ "webgl",
9
+ "wireframe",
10
+ "renderer",
11
+ "obj",
12
+ "shader"
13
+ ],
14
+ "license": "MIT",
15
+ "author": "ZachR622",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/ZachR622/Trid.git"
19
+ },
20
+ "homepage": "https://zachr622.github.io/Trid/",
21
+ "bugs": {
22
+ "url": "https://github.com/ZachR622/Trid/issues"
23
+ },
24
+ "type": "module",
25
+ "main": "./trid/index.js",
26
+ "module": "./trid/index.js",
27
+ "types": "./trid/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./trid/index.d.ts",
31
+ "default": "./trid/index.js"
32
+ },
33
+ "./*": "./trid/*"
34
+ },
35
+ "files": [
36
+ "trid"
37
+ ],
38
+ "sideEffects": false,
39
+ "scripts": {
40
+ "docs:dev": "vitepress dev docs",
41
+ "docs:build": "vitepress build docs",
42
+ "docs:preview": "vitepress preview docs"
43
+ },
44
+ "devDependencies": {
45
+ "vitepress": "^1.6.4"
46
+ }
47
+ }