trid3d 0.3.1 → 0.5.0
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/README.md +18 -7
- package/package.json +1 -1
- package/trid/index.d.ts +565 -11
- package/trid/index.js +18 -1
- package/trid/modeling/bevel.js +596 -0
- package/trid/modeling/blobs.js +465 -0
- package/trid/modeling/cleanup.js +471 -0
- package/trid/modeling/curves.js +156 -0
- package/trid/modeling/deform.js +191 -0
- package/trid/modeling/frames.js +97 -0
- package/trid/modeling/loft.js +363 -0
- package/trid/modeling/subdivide.js +215 -0
- package/trid/modeling/sweep.js +169 -0
- package/trid/modeling/vec.js +35 -0
- package/trid/render/canvasRenderer.js +99 -48
- package/trid/render/effects.js +16 -9
- package/trid/render/grid.js +177 -0
- package/trid/render/lights.js +162 -0
- package/trid/render/post.js +325 -0
- package/trid/render/shapes.js +91 -3
- package/trid/render/webglRenderer.js +341 -19
- package/trid/scene.js +48 -6
- package/trid/tools/helpers.js +107 -9
- package/trid/tools/index.js +1 -1
- package/trid/tools/transformGizmo.js +40 -6
package/README.md
CHANGED
|
@@ -16,16 +16,19 @@ Trid gives you a scene, a camera, shapes, model loading and mouse/keyboard tools
|
|
|
16
16
|
|
|
17
17
|
- **Scene** — holds a canvas, a camera and your objects, and runs the frame loop for you.
|
|
18
18
|
- **Groups** — give any object `children` and they move, turn and scale with it (models made of parts, a moon orbiting a planet).
|
|
19
|
-
- **Shapes** — cubes, boxes, spheres, cylinders, cones, tori and planes built in, `lathe` for round shapes and `extrude` for flat ones, or any mesh you define as vertices and edges.
|
|
19
|
+
- **Shapes** — cubes, boxes (sharp or rounded), spheres, cylinders, cones, tori and planes built in, `lathe` for round shapes and `extrude` for flat ones, or any mesh you define as vertices and edges.
|
|
20
|
+
- **Modeling** — smooth curves through a few points (`spline`), shapes swept along a 3D path (`sweep`: tails, horns, pipes, rails), surfaces through cross-sections (`loft`: bodies, bottles, hulls, heads), subdivision surfaces with creases (`subdivideMesh`: box modeling), shapes that melt together (`blobMesh`: creatures, clay; or any distance field with `sdfMesh`), rounded or cut edges on any mesh (`bevelMesh`), taper, twist, bend and bulge deformers, and mesh cleanup and checks (weld, clean, validate, fix winding).
|
|
20
21
|
- **Mesh helpers** — clone, transform, displace, merge and measure meshes; seeded random numbers and smooth noise (`fbm2`, `fbm3`, tileable) for rocks, terrain and procedural textures.
|
|
21
|
-
- **Filled faces** — give an object a `material` to fill and shade its faces, flat or smooth
|
|
22
|
+
- **Filled faces** — give an object a `material` to fill and shade its faces, flat or smooth.
|
|
23
|
+
- **Lights** — ambient, directional and point lights, with colors and intensities, as many as you need (up to 8 at once besides ambient).
|
|
22
24
|
- **Textures** — images, canvases or videos on faces, with texture coordinates from built-in shapes and OBJ files, or made from the shape (planar, box, sphere and cylinder mapping). Repeat, offset and rotate them, or give each face its own material. Or paint one in code: wood, marble, bricks and more, all seamless.
|
|
23
25
|
- **Effects** — stack shader effects like toon, rim and edge glow, gradients and fog on a material, or write your own in GLSL.
|
|
26
|
+
- **Post effects** — bloom, vignette, color grading and film grain over the whole picture, or your own full-screen shaders (several passes if needed).
|
|
24
27
|
- **Two renderers** — the canvas 2D context by default, or `WebGLRenderer` for exact depth and big models, with the same scene code.
|
|
25
28
|
- **OBJ files** — load models from a URL (with their `.mtl` colors and textures), or let users drop their own `.obj` files on the canvas.
|
|
26
29
|
- **Export** — `scene.screenshot()` and `scene.record()` save images and videos of the canvas; `exportOBJ` / `exportModel` write meshes, objects or whole scenes as OBJ files with their MTL materials and textures.
|
|
27
30
|
- **Camera** — position, yaw, pitch and field of view, with near-plane clipping.
|
|
28
|
-
- **Tools** — orbit and fly cameras, object dragging, hover highlight, a move / rotate / scale gizmo, a view axes gizmo, an FPS meter and an OBJ uploader, one line each. Exact picking by triangles. Writing your own is a plain object with a few methods.
|
|
31
|
+
- **Tools** — orbit and fly cameras, object dragging, hover highlight, a move / rotate / scale gizmo (with a pivot of your choice), a view axes gizmo, a floor grid, an FPS meter and an OBJ uploader, one line each. Exact picking by triangles, with the hit point and texture coordinates under the mouse. Writing your own is a plain object with a few methods.
|
|
29
32
|
- **Pure math** — every transform and projection step is exported, plus 4×4 matrices and rotations, so you can use the pipeline piece by piece.
|
|
30
33
|
|
|
31
34
|
## Install
|
|
@@ -83,7 +86,8 @@ Or let users load their own: `scene.use(new ObjUploader())` accepts dropped `.ob
|
|
|
83
86
|
| `trid/scene.js` | The `Scene` class |
|
|
84
87
|
| `trid/sceneGraph.js` | Groups: `children`, world matrices |
|
|
85
88
|
| `trid/math/` | Transforms, camera directions, projection, matrices, rotations, random numbers and noise |
|
|
86
|
-
| `trid/render/` | Renderers (Canvas 2D, WebGL), effects, shapes, mesh helpers, procedural textures, drawing, frame loop |
|
|
89
|
+
| `trid/render/` | Renderers (Canvas 2D, WebGL), lights, effects, post effects, shapes, grids, mesh helpers, procedural textures, drawing, frame loop |
|
|
90
|
+
| `trid/modeling/` | Modeling tools: curves, sweep, loft, subdivision, blobs, bevel, deformers, cleanup |
|
|
87
91
|
| `trid/loaders/` | OBJ, MTL and texture loading |
|
|
88
92
|
| `trid/export/` | Screenshots, video recording, OBJ and MTL export |
|
|
89
93
|
| `trid/tools/` | Camera, object, gizmo and overlay tools |
|
|
@@ -109,10 +113,17 @@ See [`docs/README.md`](https://github.com/ZachR622/Trid/blob/master/docs/README.
|
|
|
109
113
|
npm test
|
|
110
114
|
```
|
|
111
115
|
|
|
112
|
-
Uses Node's built-in test runner (Node 21+), so there's nothing to install. The tests cover shapes, mesh helpers, noise, textures, OBJ / MTL, picking, tools, groups and matrices, and the WebGL renderer's GPU memory on a fake WebGL context.
|
|
116
|
+
Uses Node's built-in test runner (Node 21+), so there's nothing to install. The tests cover shapes, mesh helpers, curves, sweeps, lofts, subdivision, blobs, bevels, deformers, mesh cleanup, noise, textures, OBJ / MTL, picking, tools, groups and matrices, lights, post effects, grids, and the WebGL renderer's GPU memory on a fake WebGL context.
|
|
113
117
|
|
|
114
118
|
## Upgrading
|
|
115
119
|
|
|
120
|
+
### From 0.3 to 0.4
|
|
121
|
+
|
|
122
|
+
- **Lights are a list**: `scene.lights`. A scene still starts with one directional light and an ambient level, and looks the same. `scene.light` and `scene.ambient` are now shortcuts for the first directional light's direction and the first ambient light's intensity.
|
|
123
|
+
- Setting `scene.ambient` after the scene is made no longer dims the directional light (it used to be `1 - ambient` all the time; now that's only how the default lights start). To keep the old look, also set `scene.lights[1].intensity = 1 - ambient`.
|
|
124
|
+
- `scene.light` is `null` for a scene whose `lights` have no directional light.
|
|
125
|
+
- Effects get `s.lightColor`, and `toon` and `gradient` are tinted by colored lights (no change with white lights).
|
|
126
|
+
|
|
116
127
|
### From 0.2 to 0.3
|
|
117
128
|
|
|
118
129
|
- **Canvas textures are read once.** A canvas used as a `texture` is now uploaded once (faster, and sharper with mipmaps). If you draw on it again, call `updateTexture(canvas)` after drawing, or give its material `liveTexture: true` to read it every frame. Videos still play on their own. See [Changing a canvas](https://zachr622.github.io/Trid/textures#changing-a-canvas).
|
|
@@ -125,6 +136,6 @@ Uses Node's built-in test runner (Node 21+), so there's nothing to install. The
|
|
|
125
136
|
Roughly in order:
|
|
126
137
|
|
|
127
138
|
- **More import and export formats** — STL; basic glTF later
|
|
128
|
-
- **More tools** — a selection outline
|
|
129
|
-
- **
|
|
139
|
+
- **More tools** — a selection outline
|
|
140
|
+
- **More post effects** — outlines (from depth), antialiasing (FXAA)
|
|
130
141
|
- **More tests** — the canvas renderer's drawing and the remaining math functions
|
package/package.json
CHANGED