gfxlite 0.1.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/LICENSE +21 -0
- package/README.md +74 -0
- package/dist/gfxlite.es.js +6081 -0
- package/dist/gfxlite.umd.js +1455 -0
- package/dist/types/core/camera/Camera.d.ts +13 -0
- package/dist/types/core/camera/OrthographicCamera.d.ts +11 -0
- package/dist/types/core/camera/PerspectiveCamera.d.ts +9 -0
- package/dist/types/core/controls/OrbitControls.d.ts +84 -0
- package/dist/types/core/environment/Environment.d.ts +25 -0
- package/dist/types/core/environment/EnvironmentManager.d.ts +44 -0
- package/dist/types/core/geometry/BoxGeometry.d.ts +13 -0
- package/dist/types/core/geometry/CircleGeometry.d.ts +11 -0
- package/dist/types/core/geometry/ConeGeometry.d.ts +17 -0
- package/dist/types/core/geometry/CylinderGeometry.d.ts +19 -0
- package/dist/types/core/geometry/Geometry.d.ts +27 -0
- package/dist/types/core/geometry/PlaneGeometry.d.ts +15 -0
- package/dist/types/core/geometry/SphereGeometry.d.ts +13 -0
- package/dist/types/core/geometry/TorusGeometry.d.ts +15 -0
- package/dist/types/core/light/DirectionalLight.d.ts +19 -0
- package/dist/types/core/light/Light.d.ts +7 -0
- package/dist/types/core/material/BasicMaterial.d.ts +20 -0
- package/dist/types/core/material/LambertMaterial.d.ts +20 -0
- package/dist/types/core/material/Material.d.ts +34 -0
- package/dist/types/core/material/PhongMaterial.d.ts +22 -0
- package/dist/types/core/material/StandardMaterial.d.ts +42 -0
- package/dist/types/core/material/Texture.d.ts +24 -0
- package/dist/types/core/material/TextureManager.d.ts +18 -0
- package/dist/types/core/object/Mesh.d.ts +8 -0
- package/dist/types/core/object/Object3D.d.ts +35 -0
- package/dist/types/core/renderer/BatchManager.d.ts +82 -0
- package/dist/types/core/renderer/CullingComputePhase.d.ts +13 -0
- package/dist/types/core/renderer/DepthPrePhase.d.ts +17 -0
- package/dist/types/core/renderer/LightingManager.d.ts +20 -0
- package/dist/types/core/renderer/MainRenderPhase.d.ts +62 -0
- package/dist/types/core/renderer/Program.d.ts +25 -0
- package/dist/types/core/renderer/RenderPhase.d.ts +10 -0
- package/dist/types/core/renderer/Renderer.d.ts +61 -0
- package/dist/types/core/renderer/ShadowRenderPhase.d.ts +32 -0
- package/dist/types/core/renderer/SkyboxRenderPhase.d.ts +26 -0
- package/dist/types/core/scene/Scene.d.ts +16 -0
- package/dist/types/index.d.ts +28 -0
- package/dist/types/loaders/GLTFInterfaces.d.ts +144 -0
- package/dist/types/loaders/GLTFLoader.d.ts +30 -0
- package/dist/types/math/Box3.d.ts +21 -0
- package/dist/types/math/Euler.d.ts +12 -0
- package/dist/types/math/Matrix3.d.ts +20 -0
- package/dist/types/math/Matrix4.d.ts +31 -0
- package/dist/types/math/Quaternion.d.ts +22 -0
- package/dist/types/math/Utils.d.ts +3 -0
- package/dist/types/math/Vector2.d.ts +16 -0
- package/dist/types/math/Vector3.d.ts +32 -0
- package/dist/types/math/index.d.ts +10 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Pablo Soto
|
|
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
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="docs/public/gfxlite.svg" alt="GFXLite Logo" width="128" height="128">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">GFXLite</h1>
|
|
6
|
+
|
|
7
|
+
`GFXLite` is a lightweight 3D rendering engine built on top of WebGPU. It aims to provide a simple and easy-to-understand API for creating 3D scenes, handling geometry, materials, and cameras.
|
|
8
|
+
|
|
9
|
+
> Currently in development and is not yet ready for production use.
|
|
10
|
+
|
|
11
|
+
## Architecture
|
|
12
|
+
|
|
13
|
+
`GFXLite` implements a modern, GPU-driven rendering pipeline designed for high performance and efficiency.
|
|
14
|
+
|
|
15
|
+
While the API is heavily influenced by **Three.js** for ease of use, the internals are built from the ground up for **WebGPU**. It adopts modern render strategies from high-performance frameworks like **Bevy**, prioritizing GPU-driven techniques over traditional CPU-heavy approaches.
|
|
16
|
+
|
|
17
|
+
### Rendering Pipeline
|
|
18
|
+
|
|
19
|
+
- **Unified Instance Storage**: Uses monolithic Storage Buffers to store instance data (transforms, colors, etc.) for all objects, avoiding the overhead of multiple small uniform buffers.
|
|
20
|
+
- **Automatic Batching**: The `BatchManager` automatically groups compatible meshes (same geometry and material) to maximize instance counts per draw call.
|
|
21
|
+
- **Indirect Drawing**: leverages `drawIndexedIndirect` to heavily reduce CPU-side render loop overhead. The CPU prepares batch data once, and the GPU handles the rest.
|
|
22
|
+
- **GPU Frustum Culling**: A Compute Shader pass pre-calculates visibility for all instances in parallel before rendering. Only visible objects are added to the indirect draw buffer, significantly reducing vertex shading load.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
To install the dependencies, run:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Running Examples
|
|
33
|
+
|
|
34
|
+
To start the development server and see the examples in action:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm run dev
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Open your browser and navigate to the URL provided (usually `http://localhost:5173`).
|
|
41
|
+
|
|
42
|
+
## Basic Usage
|
|
43
|
+
|
|
44
|
+
Here is a simple example of how to create a scene with a box and a camera:
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { Renderer, Scene, PerspectiveCamera, BoxGeometry, Mesh, BasicMaterial, Vector3 } from "gfxlite";
|
|
48
|
+
|
|
49
|
+
// 1. Setup Renderer
|
|
50
|
+
const canvas = document.getElementById("gfx-canvas") as HTMLCanvasElement;
|
|
51
|
+
const renderer = new Renderer(canvas);
|
|
52
|
+
renderer.resize(window.innerWidth, window.innerHeight);
|
|
53
|
+
|
|
54
|
+
// 2. Create Scene
|
|
55
|
+
const scene = new Scene();
|
|
56
|
+
|
|
57
|
+
// 3. Create Camera
|
|
58
|
+
const camera = new PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 100);
|
|
59
|
+
camera.position.set(0, 3, 10);
|
|
60
|
+
camera.lookAt(new Vector3(0, 0, 0));
|
|
61
|
+
|
|
62
|
+
// 4. Add Objects
|
|
63
|
+
const geometry = new BoxGeometry();
|
|
64
|
+
const material = new BasicMaterial({ color: new Vector3(1, 0.5, 0) });
|
|
65
|
+
const mesh = new Mesh(geometry, material);
|
|
66
|
+
scene.add(mesh);
|
|
67
|
+
|
|
68
|
+
// 5. Render Loop
|
|
69
|
+
function animate() {
|
|
70
|
+
requestAnimationFrame(animate);
|
|
71
|
+
renderer.render(scene, camera);
|
|
72
|
+
}
|
|
73
|
+
animate();
|
|
74
|
+
```
|