pigl-js 1.0.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 +135 -0
- package/dist/pigl.mjs +3212 -0
- package/dist/pigl.umd.js +1085 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# PiGL.js
|
|
2
|
+
|
|
3
|
+
A custom WebGL rendering engine and editor built from scratch using vanilla JavaScript and GLSL. This project demonstrates a component-based architecture with a focus on multipass rendering and post-processing effects.
|
|
4
|
+
|
|
5
|
+
## Demo
|
|
6
|
+
|
|
7
|
+
[View Live Demo](https://itstanpi.github.io/PiGL.js/)
|
|
8
|
+
|
|
9
|
+
## Description
|
|
10
|
+
|
|
11
|
+
PiGL.js is a lightweight 3D engine that implements a custom rendering pipeline. It supports standard 3D features like model loading and lighting, but its core strength lies in its flexible render pass system, allowing for complex visual effects like pixel art stylization, outlines, and water rendering. The project includes a built-in visual editor for inspecting the scene and profiling performance.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
### Engine
|
|
16
|
+
- **Custom WebGL Renderer**: Built on raw WebGL API without external 3D libraries.
|
|
17
|
+
- **Render Pass System**: Modular pipeline for chaining render effects.
|
|
18
|
+
- Lighting Pass
|
|
19
|
+
- Skybox Rendering
|
|
20
|
+
- Outline Effect (Post-processing)
|
|
21
|
+
- Pixel Art / Dithering Effect
|
|
22
|
+
- Water Rendering
|
|
23
|
+
- **Component System**: GameObject and Transform hierarchy.
|
|
24
|
+
- **Asset Management**: OBJ model loader and Texture handling.
|
|
25
|
+
- **Shadow Mapping**: Real-time shadow casting.
|
|
26
|
+
- **Camera System**: First-person camera controller.
|
|
27
|
+
|
|
28
|
+
### Editor
|
|
29
|
+
- **In-Browser Editor UI**: Windows system for managing tools.
|
|
30
|
+
- **Hierarchy Window**: View and select objects in the scene.
|
|
31
|
+
- **Inspector Window**: Modify object properties and transforms.
|
|
32
|
+
- **Material Editor**: Adjust shader uniforms and material properties in real-time.
|
|
33
|
+
- **Profiler**: Real-time monitoring of CPU/GPU frame times and draw calls.
|
|
34
|
+
- **Render Pass Debugger**: Toggle and inspect individual render passes.
|
|
35
|
+
|
|
36
|
+
## Documentation
|
|
37
|
+
|
|
38
|
+
### Architecture
|
|
39
|
+
|
|
40
|
+
The engine is split into two main parts: the Core Engine and the Editor.
|
|
41
|
+
|
|
42
|
+
**Core Engine**
|
|
43
|
+
- `GameObject`: The base entity class containing a Mesh, Material, and Transform.
|
|
44
|
+
- `Renderer`: Handles the WebGL context and executing the render queue.
|
|
45
|
+
- `RenderPass`: Base class for creating custom rendering steps.
|
|
46
|
+
|
|
47
|
+
### Render Pipeline
|
|
48
|
+
|
|
49
|
+
The rendering process is defined by a stack of passes. To add a new effect:
|
|
50
|
+
1. Create a class extending `RenderPass`.
|
|
51
|
+
2. Implement the `render()` method.
|
|
52
|
+
3. Add the pass to the `Renderer`.
|
|
53
|
+
|
|
54
|
+
### Shader System
|
|
55
|
+
|
|
56
|
+
Shaders are loaded as raw strings (via Vite) and compiled at runtime. The engine supports standard shader features including:
|
|
57
|
+
- Vertex/Fragment shaders
|
|
58
|
+
- Uniform management
|
|
59
|
+
- Texture samplers
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## Development
|
|
63
|
+
- **Acknowledgment**: System architecture and engineering designed by Me(TanPi), with coding assistance from AI under proper reviewing and supervision.
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
To run this project locally:
|
|
68
|
+
|
|
69
|
+
1. Clone the repository
|
|
70
|
+
2. Install dependencies:
|
|
71
|
+
```bash
|
|
72
|
+
npm install
|
|
73
|
+
```
|
|
74
|
+
3. Start the development server:
|
|
75
|
+
```bash
|
|
76
|
+
npm run dev
|
|
77
|
+
```
|
|
78
|
+
4. Build for production:
|
|
79
|
+
```bash
|
|
80
|
+
npm run build
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Usage as a Library
|
|
84
|
+
|
|
85
|
+
You can use PiGL.js as a standalone app or as a library in your own projects.
|
|
86
|
+
|
|
87
|
+
### As a Library
|
|
88
|
+
|
|
89
|
+
To build the library:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npm run build:lib
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
This will generate `dist/pigl.umd.js` and `dist/pigl.es.js`.
|
|
96
|
+
|
|
97
|
+
#### Importing
|
|
98
|
+
|
|
99
|
+
- For ES Modules:
|
|
100
|
+
```js
|
|
101
|
+
import { Renderer, Editor, LightingPass } from 'pigl';
|
|
102
|
+
```
|
|
103
|
+
- For UMD (browser):
|
|
104
|
+
```html
|
|
105
|
+
<script src="dist/pigl.umd.js"></script>
|
|
106
|
+
<script>
|
|
107
|
+
const { Renderer, Editor, LightingPass } = window.PiGL;
|
|
108
|
+
</script>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
All engine, editor, passes, and utility modules are exported from the library entry point.
|
|
112
|
+
|
|
113
|
+
### As an App
|
|
114
|
+
|
|
115
|
+
You can continue to use the project as a standalone app with:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
npm run dev
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
or build for deployment with:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
npm run build
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Controls
|
|
128
|
+
|
|
129
|
+
- **WASD**: Move Camera
|
|
130
|
+
- **Mouse**: Look around
|
|
131
|
+
- **Editor UI**: Interacting with windows to change scene settings.
|
|
132
|
+
|
|
133
|
+
## Credits
|
|
134
|
+
|
|
135
|
+
- **3D Model**: [Lowpoly Island](https://sketchfab.com/3d-models/lowpoly-island-0a514854b7164178a6c7a69961235197) by the respective artist on Sketchfab.
|