Skip to content

Commit be29af7

Browse files
committed
update wiki for v0.1
1 parent 4926be5 commit be29af7

File tree

2 files changed

+49
-13
lines changed

2 files changed

+49
-13
lines changed

docs/components/index.md

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ public interface Component<T> {
2828
## Fragments
2929
!!! abstract "See [Fragment Javadoc](https://javadoc.ngengine.org/org/ngengine/components/fragments/Fragment.html)"
3030

31-
Fragments are interfaces that extend a component’s functionality. By implementing one or more fragment interfaces (e.g., `MainViewPortFragment`, `LogicFragment`), a component signals which engine systems it needs. The manager detects these fragments and handles their lifecycle in a predefined order:
31+
Fragments are interfaces that extend a component’s functionality. By implementing one or more fragment interfaces (e.g., `AssetLoadingFragment`, `LogicFragment`), a component signals which engine systems it needs. The manager detects these fragments and handles their lifecycle in a predefined order:
3232

33-
1. **Initialization** (`receiveXXX` methods)
34-
2. **Loading** (`loadXXX` methods)
35-
3. **Enable** (via the component’s `onEnable`)
36-
4. **Update** (`updateXXX` methods called on each update tick)
37-
5. **Disable** (via the component’s `onDisable`)
33+
1. **Load** (`loadXXX` methods)
34+
2. **Enable** (via the component’s `onEnable`)
35+
3. **Update** (`updateXXX` methods called on each update tick)
36+
4. **Disable** (via the component’s `onDisable`)
3837

3938
This composition-based design avoids deep inheritance hierarchies. Each fragment represents hooks into specific engine subsystems, allowing the component to participate in various aspects of the game/application lifecycle without being tightly coupled to the engine.
4039

@@ -81,4 +80,37 @@ from there you should proceed to implement as many fragments as needed, until yo
8180
```
8281

8382

84-
A list of available fragments can be found in the [Javadoc](https://javadoc.ngengine.org/org/ngengine/components/fragments/package-summary.html).
83+
A list of available fragments can be found in the [Javadoc](https://javadoc.ngengine.org/org/ngengine/components/fragments/package-summary.html).
84+
85+
86+
87+
88+
## Accessing Engine Objects
89+
90+
Components sometimes need to interact with core engine objects such as input, rendering, or asset management.
91+
A common but discouraged approach is to inject these dependencies manually (e.g., via constructors or setters). This makes components harder to reuse and more tightly bound to a specific initialization context.
92+
93+
Instead, you should retrieve global engine objects through [`ComponentManager.getGlobalInstance(Class)`](https://javadoc.ngengine.org/org/ngengine/components/ComponentManager.html#getGlobalInstance%28java.lang.Class%29).
94+
From any point where you have access to a `ComponentManager`, you can request the object class you need.
95+
96+
### Commonly Available Objects
97+
98+
| Class | Description |
99+
| -------------------------------------- | ------------------------------------------------------------------ |
100+
| `com.jme3.input.InputManager` | Manages input devices, used for advanced input handling |
101+
| `com.jme3.renderer.RenderManager` | Controls low-level rendering features |
102+
| `org.ngengine.store.DataStoreProvider` | Provides access to the persistent data store |
103+
| | |
104+
| | |
105+
| `com.jme3.asset.AssetManager` | Loads assets synchronously |
106+
| `org.ngengine.AsyncAssetManager` | Loads assets synchronously or asynchronously |
107+
| | |
108+
| | |
109+
| `com.jme3.renderer.ViewPort` | Represents the main scene ViewPort |
110+
| `com.jme3.renderer.Camera` | Camera associated with the main ViewPort |
111+
| `org.ngengine.ViewPortManager` | Provides access to all ViewPorts, including main and GUI ViewPorts |
112+
| | |
113+
| | |
114+
| `com.jme3.app.Application` | Legacy: current jME3 Application instance (avoid if possible) |
115+
| `com.jme3.app.state.AppStateManager` | Legacy: manages AppStates (avoid if possible) |
116+

docs/lights.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ You control the color and intensity of each light source. Typically you set the
1818
You can choose to use lights in other colors than white, or darker colors. This influences the scene’s atmosphere and will make the scene appear colder (e.g. `ColorRGBA.Cyan`) or warmer (`ColorRGBA.Yellow`), brighter (higher values) or darker (lower values).
1919

2020

21-
Lights attached to a spatial will illuminate only the spatial itself and its children. If you want to illuminate the entire scene, you should attach lights to the root node.
21+
Lights attached to a spatial will illuminate only the spatial itself and its children. If you want to illuminate the entire scene, you should initialize them as **global** lights by passing `true` as `global` parameter to the light constructor.
2222

23-
You can get a list of all lights added to a Spatial by `calling getWorldLightList()` (includes inherited lights) or `getLocalLightList()` (only directly added lights), and iterating over the result.
23+
```java
24+
PointLight globalLight = new PointLight(true);
25+
```
26+
27+
You can get a list of all lights added to a Spatial by `calling getWorldLightList()` (includes inherited lights and global lights) or `getLocalLightList()` (only directly added lights), and iterating over the result.
2428

2529

2630
## PointLight
@@ -33,7 +37,7 @@ A PointLight has a location and shines from there in all directions as far as it
3337
!!! example "Example: Lamp, lightbulb, torch, candle"
3438

3539
```java
36-
PointLight lamp_light = new PointLight();
40+
PointLight lamp_light = new PointLight(true); // global light
3741
lamp_light.setColor(ColorRGBA.Yellow);
3842
lamp_light.setRadius(4f);
3943
lamp_light.setPosition(new Vector3f(lamp_geo.getLocalTranslation()));
@@ -51,7 +55,7 @@ A DirectionalLight has no position, only a direction. It sends out parallel beam
5155
!!! example "Example: Sun light"
5256

5357
```java
54-
DirectionalLight sun = new DirectionalLight();
58+
DirectionalLight sun = new DirectionalLight(true); // global light
5559
sun.setColor(ColorRGBA.White);
5660
sun.setDirection(new Vector3f(-.5f,-.5f,-.5f).normalizeLocal());
5761
rootNode.addLight(sun);
@@ -67,7 +71,7 @@ A SpotLight sends out a distinct beam or cone of light. A SpotLight has a direct
6771
!!! example "Example: Flashlight"
6872

6973
```java
70-
SpotLight spot = new SpotLight();
74+
SpotLight spot = new SpotLight(true); // global light
7175
spot.setSpotRange(100f); // distance
7276
spot.setSpotInnerAngle(15f * FastMath.DEG_TO_RAD); // inner light cone (central beam)
7377
spot.setSpotOuterAngle(35f * FastMath.DEG_TO_RAD); // outer light cone (edge of the light)
@@ -86,7 +90,7 @@ An AmbientLight simply influences the brightness and color of the scene globally
8690
!!! example "Example: Regulate overall brightness, tinge the whole scene in a warm or cold color"
8791

8892
```java
89-
AmbientLight al = new AmbientLight();
93+
AmbientLight al = new AmbientLight(); // local light
9094
al.setColor(ColorRGBA.White.mult(1.3f));
9195
rootNode.addLight(al);
9296
```

0 commit comments

Comments
 (0)