Skip to content

Commit 79f049b

Browse files
committed
Update readme
1 parent 233d8e0 commit 79f049b

File tree

2 files changed

+49
-21
lines changed

2 files changed

+49
-21
lines changed

README.md

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,15 @@ This is a part of [Node3D](https://github.com/node-3d) project.
1010
npm i -s 3d-core-raub
1111
```
1212

13-
Run **WebGL** code on **Node.js**.
13+
> This package uses pre-compiled Node.js addons. **There is no compilation** during the `npm install`.
14+
The addons are compiled for: Win64, Linux64, Linux ARM64, MacOS ARM64.
1415

1516
![Example](examples/screenshot.png)
1617

17-
> Note: Since version 4.0.0, [three.js](https://github.com/mrdoob/three.js) is a peer dependency.
18-
Please install your version of choise and call `addThreeHelpers` before drawing frames.
19-
20-
* Multiple windows are supported, using [GLFW](http://www.glfw.org/) for window management.
21-
* WebGL implementation is not 100% accurate, but good enough to run three.js examples.
22-
* The C++ bindings use [GLEW](http://glew.sourceforge.net/) to access all the OpenGL functions.
23-
* Image loading uses [FreeImage](http://freeimage.sourceforge.net/) encoder/decoder.
24-
* Window icons are supported and both JS- and Image-friendly.
25-
26-
> Note: this package uses a bunch of **N-API addons**, which are ABI-compatible across
27-
different Node.js versions. Addon binaries are precompiled and **there is no compilation**
28-
step during the `npm i` command.
29-
18+
* WebGL/OpenGL on **Node.js** with support for web libs, such as **three.js**.
19+
* Multi-window apps, low-level window control with [glfw-raub](https://github.com/node-3d/glfw-raub).
20+
* Modern OpenGL functions also available, see [webgl-raub](https://github.com/node-3d/webgl-raub).
21+
* Image loading/saving in popular formats with [image-raub](https://github.com/node-3d/image-raub).
3022

3123
This module exports 2 methods:
3224
1. `export const init: (opts?: TInitOpts) => TCore3D;`
@@ -40,9 +32,11 @@ This module exports 2 methods:
4032
`three.Texture.fromId` static method to create THREE textures from known GL resource IDs.
4133

4234

43-
See [TypeScript defenitions](/index.d.ts) for more details.
35+
See [TS declarations](/index.d.ts) for more details.
4436

45-
Example (as in [crate-lean.mjs](/examples/crate-lean.mjs)):
37+
## Example
38+
39+
(As in [crate-lean.mjs](/examples/crate-lean.mjs)):
4640

4741
```javascript
4842
import * as THREE from 'three';
@@ -78,5 +72,32 @@ Example Notes:
7872
window modes.
7973
1. `Screen` helps with **three.js**-oriented resource management, but is not required.
8074
1. **three.js** uses VAO, so if not using `Screen`, handling the window mode changes
81-
(creates a separate OpenGL context) is up to you. Basically, `doc.on('mode', () => {...})` -
75+
(which creates a separate OpenGL context) is up to you.
76+
Basically, `doc.on('mode', () => {...})` -
8277
here you should [re-create THREE.WebGLRenderer](/js/objects/screen.js#L127).
78+
79+
80+
## OpenGL Features
81+
82+
1. This is real native OpenGL, and you have direct access to GL resource IDs. This may be
83+
useful for resource sharing and compute interop (such as
84+
[CUDA-GL interop](https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__OPENGL.html)).
85+
1. The flag `isGles3` let's you use a GL ES 3 preset, which is closest to "real" WebGL.
86+
If set to `false`, WebGL stuff (such as three.js) will still work, but now with some hacks.
87+
However, if you are planning to use non-WebGL features (e.g. OpenGL 4.5 features),
88+
you might want it off, and then select a specific context version manually.
89+
1. The flag `isWebGL2` impacts how web libraries recognize the WebGL version.
90+
But it doesn't really change the capabilities of the engine.
91+
1. Offscreen rendering is possible on Windows and Linux, as demonstrated by the tests
92+
running in GitHub Actions. There are test cases that generate and compare screenshots,
93+
and they do work in headless mode.
94+
1. OpenGL context sharing is enabled. You can obtain `HDC, HWND, CTX` for Windows and whatever
95+
those are called on Linux and MacOS. See [glfw-raub](https://github.com/node-3d/glfw-raub).
96+
97+
98+
## License
99+
100+
You get this for free. Have fun!
101+
102+
Some of the components have their separate licenses, but all of them may be used
103+
commercially, without royalty.

index.d.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,19 @@ declare module "3d-core-raub" {
207207
window: Document,
208208

209209
/**
210-
* The default frame-loop helper, calls `requestAnimationFrame` automatically.
211-
*/
212-
loop: (cb: () => void) => void,
210+
* Optimized loop method that will continuously generate frames with given `cb`.
211+
*
212+
* The returned function may be called to break the loop.
213+
* @alias doc.loop
214+
*/
215+
loop(cb: (dateNow: number) => void): (() => void);
213216

214217
/**
215-
* Swaps GL buffers and calls the `cb` callback on next frame.
218+
* Similar to `requestAnimationFrame` on web. It uses `setImmediate`, and can
219+
* therefore be cancelled (with `doc.cancelAnimationFrame`).
220+
*
221+
* On immediate, it will process events (input), then call `cb`, then swap buffers.
222+
* Swap buffers is blocking when VSYNC is on - that's how FPS is sync'd.
216223
* @alias doc.requestAnimationFrame
217224
*/
218225
requestAnimationFrame: (cb: (dateNow: number) => void) => number,

0 commit comments

Comments
 (0)