You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/components/index.md
+39-7Lines changed: 39 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,13 +28,12 @@ public interface Component<T> {
28
28
## Fragments
29
29
!!! abstract "See [Fragment Javadoc](https://javadoc.ngengine.org/org/ngengine/components/fragments/Fragment.html)"
30
30
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:
32
32
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`)
38
37
39
38
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.
40
39
@@ -81,4 +80,37 @@ from there you should proceed to implement as many fragments as needed, until yo
81
80
```
82
81
83
82
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.
Copy file name to clipboardExpand all lines: docs/lights.md
+10-6Lines changed: 10 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,9 +18,13 @@ You control the color and intensity of each light source. Typically you set the
18
18
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).
19
19
20
20
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.
22
22
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 =newPointLight(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.
24
28
25
29
26
30
## PointLight
@@ -33,7 +37,7 @@ A PointLight has a location and shines from there in all directions as far as it
33
37
!!! example "Example: Lamp, lightbulb, torch, candle"
34
38
35
39
```java
36
-
PointLight lamp_light =newPointLight();
40
+
PointLight lamp_light =newPointLight(true); // global light
0 commit comments