action-engine-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/LICENSE +45 -0
- package/README.md +348 -0
- package/actionengine/3rdparty/goblin/goblin.js +9609 -0
- package/actionengine/3rdparty/goblin/goblin.min.js +5 -0
- package/actionengine/camera/actioncamera.js +90 -0
- package/actionengine/camera/cameracollisionhandler.js +69 -0
- package/actionengine/character/actioncharacter.js +360 -0
- package/actionengine/character/actioncharacter3D.js +61 -0
- package/actionengine/core/app.js +430 -0
- package/actionengine/debug/basedebugpanel.js +858 -0
- package/actionengine/display/canvasmanager.js +75 -0
- package/actionengine/display/gl/programmanager.js +570 -0
- package/actionengine/display/gl/shaders/lineshader.js +118 -0
- package/actionengine/display/gl/shaders/objectshader.js +1756 -0
- package/actionengine/display/gl/shaders/particleshader.js +43 -0
- package/actionengine/display/gl/shaders/shadowshader.js +319 -0
- package/actionengine/display/gl/shaders/spriteshader.js +100 -0
- package/actionengine/display/gl/shaders/watershader.js +67 -0
- package/actionengine/display/graphics/actionmodel3D.js +191 -0
- package/actionengine/display/graphics/actionsprite3D.js +230 -0
- package/actionengine/display/graphics/lighting/actiondirectionalshadowlight.js +864 -0
- package/actionengine/display/graphics/lighting/actionlight.js +211 -0
- package/actionengine/display/graphics/lighting/actionomnidirectionalshadowlight.js +862 -0
- package/actionengine/display/graphics/lighting/lightingconstants.js +263 -0
- package/actionengine/display/graphics/lighting/lightmanager.js +789 -0
- package/actionengine/display/graphics/renderableobject.js +44 -0
- package/actionengine/display/graphics/renderers/actionrenderer2D.js +341 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/actionrenderer3D.js +655 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/canvasmanager3D.js +82 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/debugrenderer3D.js +493 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/objectrenderer3D.js +790 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/spriteRenderer3D.js +266 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/sunrenderer3D.js +140 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/waterrenderer3D.js +173 -0
- package/actionengine/display/graphics/renderers/actionrenderer3D/weatherrenderer3D.js +87 -0
- package/actionengine/display/graphics/texture/proceduraltexture.js +192 -0
- package/actionengine/display/graphics/texture/texturemanager.js +242 -0
- package/actionengine/display/graphics/texture/textureregistry.js +177 -0
- package/actionengine/input/actionscrollablearea.js +1405 -0
- package/actionengine/input/inputhandler.js +1647 -0
- package/actionengine/math/geometry/geometrybuilder.js +161 -0
- package/actionengine/math/geometry/glbexporter.js +364 -0
- package/actionengine/math/geometry/glbloader.js +722 -0
- package/actionengine/math/geometry/modelcodegenerator.js +97 -0
- package/actionengine/math/geometry/triangle.js +33 -0
- package/actionengine/math/geometry/triangleutils.js +34 -0
- package/actionengine/math/mathutils.js +25 -0
- package/actionengine/math/matrix4.js +785 -0
- package/actionengine/math/physics/actionphysics.js +108 -0
- package/actionengine/math/physics/actionphysicsobject3D.js +164 -0
- package/actionengine/math/physics/actionphysicsworld3D.js +238 -0
- package/actionengine/math/physics/actionraycast.js +129 -0
- package/actionengine/math/physics/shapes/actionphysicsbox3D.js +158 -0
- package/actionengine/math/physics/shapes/actionphysicscapsule3D.js +200 -0
- package/actionengine/math/physics/shapes/actionphysicscompoundshape3D.js +147 -0
- package/actionengine/math/physics/shapes/actionphysicscone3D.js +126 -0
- package/actionengine/math/physics/shapes/actionphysicsconvexshape3D.js +72 -0
- package/actionengine/math/physics/shapes/actionphysicscylinder3D.js +117 -0
- package/actionengine/math/physics/shapes/actionphysicsmesh3D.js +74 -0
- package/actionengine/math/physics/shapes/actionphysicsplane3D.js +100 -0
- package/actionengine/math/physics/shapes/actionphysicssphere3D.js +95 -0
- package/actionengine/math/quaternion.js +61 -0
- package/actionengine/math/vector2.js +277 -0
- package/actionengine/math/vector3.js +318 -0
- package/actionengine/math/viewfrustum.js +136 -0
- package/actionengine/network/ACTIONNETREADME.md +810 -0
- package/actionengine/network/client/ActionNetManager.js +802 -0
- package/actionengine/network/client/ActionNetManagerGUI.js +1709 -0
- package/actionengine/network/client/ActionNetManagerP2P.js +1537 -0
- package/actionengine/network/client/SyncSystem.js +422 -0
- package/actionengine/network/p2p/ActionNetPeer.js +142 -0
- package/actionengine/network/p2p/ActionNetTrackerClient.js +623 -0
- package/actionengine/network/p2p/DataConnection.js +282 -0
- package/actionengine/network/p2p/README.md +510 -0
- package/actionengine/network/p2p/example.html +502 -0
- package/actionengine/network/server/ActionNetServer.js +577 -0
- package/actionengine/network/server/ActionNetServerSSL.js +579 -0
- package/actionengine/network/server/ActionNetServerUtils.js +458 -0
- package/actionengine/network/server/SERVERREADME.md +314 -0
- package/actionengine/network/server/package-lock.json +35 -0
- package/actionengine/network/server/package.json +13 -0
- package/actionengine/network/server/start.bat +27 -0
- package/actionengine/network/server/start.sh +25 -0
- package/actionengine/network/server/startwss.bat +27 -0
- package/actionengine/sound/audiomanager.js +1589 -0
- package/actionengine/sound/soundfont/ACTIONSOUNDFONT_README.md +205 -0
- package/actionengine/sound/soundfont/actionparser.js +718 -0
- package/actionengine/sound/soundfont/actionreverb.js +252 -0
- package/actionengine/sound/soundfont/actionsoundfont.js +543 -0
- package/actionengine/sound/soundfont/sf2playerlicence.txt +29 -0
- package/actionengine/sound/soundfont/soundfont.js +2 -0
- package/dist/action-engine.min.js +328 -0
- package/package.json +35 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
// actionengine/display/graphics/lighting/lightingconstants.js
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* LightingConstants provides centralized configuration for lighting and shadow settings.
|
|
5
|
+
* These values can be modified at runtime through the debug panel.
|
|
6
|
+
*/
|
|
7
|
+
class LightingConstants {
|
|
8
|
+
constructor() {
|
|
9
|
+
// Light position and direction
|
|
10
|
+
this.LIGHT_POSITION = {
|
|
11
|
+
x: 0,
|
|
12
|
+
y: 5000.0,
|
|
13
|
+
z: 0,
|
|
14
|
+
max: 50000, // Maximum height/position
|
|
15
|
+
min: -50000 // Minimum height/position
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
this.LIGHT_DIRECTION = {
|
|
19
|
+
x: 0.0,
|
|
20
|
+
y: -1.0,
|
|
21
|
+
z: -0.0,
|
|
22
|
+
min: -1.0, // Direction component minimum
|
|
23
|
+
max: 1.0, // Direction component maximum
|
|
24
|
+
step: 0.1
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// Light properties
|
|
28
|
+
this.LIGHT_INTENSITY = {
|
|
29
|
+
value: 7500.0,
|
|
30
|
+
min: 0,
|
|
31
|
+
max: 100000
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Default shader intensity factor - controls how intensity affects non-PBR shaders
|
|
35
|
+
this.OBJECT_SHADER_DEFAULT_VARIANT_INTENSITY_FACTOR = {
|
|
36
|
+
value: 0.0001, // Scale factor for default shader (increased for more visible lighting)
|
|
37
|
+
min: 0.000000000000001,
|
|
38
|
+
max: 1.0,
|
|
39
|
+
step: 0.00000000000001
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// Material properties
|
|
43
|
+
this.MATERIAL = {
|
|
44
|
+
ROUGHNESS: {
|
|
45
|
+
value: 1.0,
|
|
46
|
+
min: 0.0,
|
|
47
|
+
max: 1.0
|
|
48
|
+
},
|
|
49
|
+
METALLIC: {
|
|
50
|
+
value: 0.0,
|
|
51
|
+
min: 0.0,
|
|
52
|
+
max: 1.0
|
|
53
|
+
},
|
|
54
|
+
BASE_REFLECTIVITY: {
|
|
55
|
+
value: 0.0,
|
|
56
|
+
min: 0.0,
|
|
57
|
+
max: 1.0
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// Shadow map settings
|
|
62
|
+
this.SHADOW_MAP = {
|
|
63
|
+
SIZE: {
|
|
64
|
+
value: 16384, // Power of 2 for best performance
|
|
65
|
+
options: [512, 1024, 2048, 4096, 8192, 16384],
|
|
66
|
+
label: "Shadow Resolution"
|
|
67
|
+
},
|
|
68
|
+
BIAS: {
|
|
69
|
+
value: 0.0732, // Bias to prevent shadow acne - fine-tuned for testing
|
|
70
|
+
min: -0.001, // Narrower range focused on useful values
|
|
71
|
+
max: 0.1, // Maximum bias value for testing
|
|
72
|
+
step: 0.0001 // Very small step for fine-grained control
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// Shadow map settings
|
|
77
|
+
this.POINT_LIGHT_SHADOW_MAP = {
|
|
78
|
+
SIZE: {
|
|
79
|
+
value: 2048, // Power of 2 for best performance
|
|
80
|
+
options: [512, 1024, 2048, 4096, 8192, 16384],
|
|
81
|
+
label: "Shadow Resolution"
|
|
82
|
+
},
|
|
83
|
+
BIAS: {
|
|
84
|
+
value: 0.0732, // Bias to prevent shadow acne - fine-tuned for testing
|
|
85
|
+
min: -0.001, // Narrower range focused on useful values
|
|
86
|
+
max: 0.1, // Maximum bias value for testing
|
|
87
|
+
step: 0.0001 // Very small step for fine-grained control
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// Shadow projection settings - orthographic frustum for directional light
|
|
92
|
+
this.SHADOW_PROJECTION = {
|
|
93
|
+
LEFT: {
|
|
94
|
+
value: -4096,
|
|
95
|
+
min: -20000,
|
|
96
|
+
max: 0,
|
|
97
|
+
step: 10
|
|
98
|
+
},
|
|
99
|
+
RIGHT: {
|
|
100
|
+
value: 4096,
|
|
101
|
+
min: 0,
|
|
102
|
+
max: 20000,
|
|
103
|
+
step: 10
|
|
104
|
+
},
|
|
105
|
+
BOTTOM: {
|
|
106
|
+
value: -4096,
|
|
107
|
+
min: -20000,
|
|
108
|
+
max: 0,
|
|
109
|
+
step: 10
|
|
110
|
+
},
|
|
111
|
+
TOP: {
|
|
112
|
+
value: 4096,
|
|
113
|
+
min: 0,
|
|
114
|
+
max: 20000,
|
|
115
|
+
step: 10
|
|
116
|
+
},
|
|
117
|
+
NEAR: {
|
|
118
|
+
value: 4300,
|
|
119
|
+
min: 0.01,
|
|
120
|
+
max: 50000,
|
|
121
|
+
step: 1
|
|
122
|
+
},
|
|
123
|
+
FAR: {
|
|
124
|
+
value: 5001,
|
|
125
|
+
min: 0.1,
|
|
126
|
+
max: 50000,
|
|
127
|
+
step: 100
|
|
128
|
+
},
|
|
129
|
+
AUTO_FIT: false, // Automatically fit shadow frustum to visible scene
|
|
130
|
+
DISTANCE_MULTIPLIER: {
|
|
131
|
+
value: 100, // Multiplier for light target distance
|
|
132
|
+
min: 10,
|
|
133
|
+
max: 10000,
|
|
134
|
+
step: 10
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// Shadow filtering settings
|
|
139
|
+
this.SHADOW_FILTERING = {
|
|
140
|
+
ENABLED: false,
|
|
141
|
+
PCF: { // Percentage Closer Filtering
|
|
142
|
+
ENABLED: true,
|
|
143
|
+
SIZE: {
|
|
144
|
+
value: 9, // Size of PCF kernel (3 = 3x3 sampling)
|
|
145
|
+
options: [1, 3, 5, 7, 9],
|
|
146
|
+
label: "PCF Kernel Size"
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
SOFTNESS: {
|
|
150
|
+
value: -0.7, // Shadow softness (0 = hard, 1 = very soft)
|
|
151
|
+
min: -60.0,
|
|
152
|
+
max: 0.0,
|
|
153
|
+
step: 0.01
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// Shadow quality presets
|
|
158
|
+
this.SHADOW_QUALITY_PRESETS = [
|
|
159
|
+
{
|
|
160
|
+
name: "Low",
|
|
161
|
+
mapSize: 1024,
|
|
162
|
+
bias: 0.005,
|
|
163
|
+
pcfSize: 3
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: "Medium",
|
|
167
|
+
mapSize: 2048,
|
|
168
|
+
bias: 0.003,
|
|
169
|
+
pcfSize: 5
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: "High",
|
|
173
|
+
mapSize: 4096,
|
|
174
|
+
bias: 0.0015,
|
|
175
|
+
pcfSize: 7
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: "Ultra",
|
|
179
|
+
mapSize: 8192,
|
|
180
|
+
bias: 0.001,
|
|
181
|
+
pcfSize: 9
|
|
182
|
+
}
|
|
183
|
+
];
|
|
184
|
+
|
|
185
|
+
// Debug settings
|
|
186
|
+
this.DEBUG = {
|
|
187
|
+
VISUALIZE_SHADOW_MAP: false, // Display shadow map in corner
|
|
188
|
+
VISUALIZE_FRUSTUM: true, // Visualize shadow frustum
|
|
189
|
+
FORCE_SHADOW_MAP_TEST: false, // Should never be used - was an unfinished AI concept
|
|
190
|
+
LIGHT_VISUALIZATION_SIZE: {
|
|
191
|
+
value: 20,
|
|
192
|
+
min: 5,
|
|
193
|
+
max: 100,
|
|
194
|
+
step: 5
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Helper methods to apply quality presets
|
|
200
|
+
applyShadowQualityPreset(presetIndex) {
|
|
201
|
+
if (presetIndex < 0 || presetIndex >= this.SHADOW_QUALITY_PRESETS.length) {
|
|
202
|
+
console.warn(`Invalid shadow quality preset index: ${presetIndex}`);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const preset = this.SHADOW_QUALITY_PRESETS[presetIndex];
|
|
207
|
+
this.SHADOW_MAP.SIZE.value = preset.mapSize;
|
|
208
|
+
this.SHADOW_MAP.BIAS.value = preset.bias;
|
|
209
|
+
this.SHADOW_FILTERING.PCF.SIZE.value = preset.pcfSize;
|
|
210
|
+
|
|
211
|
+
console.log(`Applied shadow quality preset: ${preset.name}`);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Allow exporting full config for debugging/saving
|
|
215
|
+
exportConfig() {
|
|
216
|
+
return {
|
|
217
|
+
lightPosition: { ...this.LIGHT_POSITION },
|
|
218
|
+
lightDirection: { ...this.LIGHT_DIRECTION },
|
|
219
|
+
lightIntensity: { ...this.LIGHT_INTENSITY },
|
|
220
|
+
objectShaderDefaultVariantIntensityFactor: { ...this.OBJECT_SHADER_DEFAULT_VARIANT_INTENSITY_FACTOR },
|
|
221
|
+
material: { ...this.MATERIAL },
|
|
222
|
+
shadowMap: { ...this.SHADOW_MAP },
|
|
223
|
+
shadowProjection: { ...this.SHADOW_PROJECTION },
|
|
224
|
+
shadowFiltering: { ...this.SHADOW_FILTERING },
|
|
225
|
+
shadowQualityPresets: [...this.SHADOW_QUALITY_PRESETS],
|
|
226
|
+
debug: { ...this.DEBUG }
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Import config (for loading saved settings)
|
|
231
|
+
importConfig(config) {
|
|
232
|
+
if (!config) return;
|
|
233
|
+
|
|
234
|
+
// Helper function to safely copy properties
|
|
235
|
+
const copyProps = (target, source) => {
|
|
236
|
+
if (!source) return;
|
|
237
|
+
Object.keys(target).forEach(key => {
|
|
238
|
+
if (source[key] !== undefined) {
|
|
239
|
+
if (typeof target[key] === 'object' && !Array.isArray(target[key])) {
|
|
240
|
+
copyProps(target[key], source[key]);
|
|
241
|
+
} else {
|
|
242
|
+
target[key] = source[key];
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
copyProps(this.LIGHT_POSITION, config.lightPosition);
|
|
249
|
+
copyProps(this.LIGHT_DIRECTION, config.lightDirection);
|
|
250
|
+
copyProps(this.LIGHT_INTENSITY, config.lightIntensity);
|
|
251
|
+
copyProps(this.OBJECT_SHADER_DEFAULT_VARIANT_INTENSITY_FACTOR, config.objectShaderDefaultVariantIntensityFactor);
|
|
252
|
+
copyProps(this.MATERIAL, config.material);
|
|
253
|
+
copyProps(this.SHADOW_MAP, config.shadowMap);
|
|
254
|
+
copyProps(this.SHADOW_PROJECTION, config.shadowProjection);
|
|
255
|
+
copyProps(this.SHADOW_FILTERING, config.shadowFiltering);
|
|
256
|
+
copyProps(this.DEBUG, config.debug);
|
|
257
|
+
|
|
258
|
+
console.log('Imported lighting configuration');
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Create a global instance
|
|
263
|
+
const lightingConstants = new LightingConstants();
|