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,211 @@
|
|
|
1
|
+
// actionengine/display/graphics/lighting/actionlight.js
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Base class for all light types in the ActionEngine
|
|
5
|
+
* This serves as an abstract class that defines the interface for different light types
|
|
6
|
+
*/
|
|
7
|
+
class ActionLight {
|
|
8
|
+
/**
|
|
9
|
+
* Constructor for the base light class
|
|
10
|
+
* @param {WebGLRenderingContext} gl - The WebGL rendering context
|
|
11
|
+
* @param {boolean} isWebGL2 - Flag indicating if WebGL2 is available
|
|
12
|
+
*/
|
|
13
|
+
constructor(gl, isWebGL2) {
|
|
14
|
+
this.gl = gl;
|
|
15
|
+
this.isWebGL2 = isWebGL2;
|
|
16
|
+
|
|
17
|
+
// Reference to global lighting constants
|
|
18
|
+
this.constants = lightingConstants;
|
|
19
|
+
|
|
20
|
+
// Basic light properties
|
|
21
|
+
this.position = new Vector3(0, 0, 0);
|
|
22
|
+
this.color = new Vector3(1, 1, 1); // White light by default
|
|
23
|
+
this.intensity = 1.0;
|
|
24
|
+
|
|
25
|
+
// Shadow capability flag
|
|
26
|
+
this.castsShadows = false;
|
|
27
|
+
|
|
28
|
+
// For tracking changes between frames
|
|
29
|
+
this._lastPosition = undefined;
|
|
30
|
+
this._lastIntensity = undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Set the light position
|
|
35
|
+
* @param {Vector3} position - The new position
|
|
36
|
+
*/
|
|
37
|
+
setPosition(position) {
|
|
38
|
+
// Use copy if it exists, otherwise fall back to direct assignment
|
|
39
|
+
if (typeof this.position.copy === 'function') {
|
|
40
|
+
this.position.copy(position);
|
|
41
|
+
} else {
|
|
42
|
+
this.position.x = position.x;
|
|
43
|
+
this.position.y = position.y;
|
|
44
|
+
this.position.z = position.z;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get the light position
|
|
50
|
+
* @returns {Vector3} - The current position
|
|
51
|
+
*/
|
|
52
|
+
getPosition() {
|
|
53
|
+
return this.position;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Get the shadow texture for this light (if it exists)
|
|
58
|
+
* @returns {WebGLTexture|null} - The shadow texture or null if there isn't one
|
|
59
|
+
*/
|
|
60
|
+
getShadowsEnabled() {
|
|
61
|
+
return this.castsShadows;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Set the light color
|
|
66
|
+
* @param {Vector3} color - RGB color vector (values 0-1)
|
|
67
|
+
*/
|
|
68
|
+
setColor(color) {
|
|
69
|
+
// Use copy if it exists, otherwise fall back to direct assignment
|
|
70
|
+
if (typeof this.color.copy === 'function') {
|
|
71
|
+
this.color.copy(color);
|
|
72
|
+
} else {
|
|
73
|
+
this.color.x = color.x;
|
|
74
|
+
this.color.y = color.y;
|
|
75
|
+
this.color.z = color.z;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Get the light color
|
|
81
|
+
* @returns {Vector3} - The current color
|
|
82
|
+
*/
|
|
83
|
+
getColor() {
|
|
84
|
+
return this.color;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Set the light intensity
|
|
89
|
+
* @param {number} intensity - The new intensity value
|
|
90
|
+
*/
|
|
91
|
+
setIntensity(intensity) {
|
|
92
|
+
this.intensity = intensity;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Get the light intensity
|
|
97
|
+
* @returns {number} - The current intensity
|
|
98
|
+
*/
|
|
99
|
+
getIntensity() {
|
|
100
|
+
return this.intensity;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Enable or disable shadow casting for this light
|
|
105
|
+
* @param {boolean} enabled - Whether shadows should be cast
|
|
106
|
+
*/
|
|
107
|
+
setShadowsEnabled(enabled) {
|
|
108
|
+
this.castsShadows = enabled;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Update the light's internal state
|
|
113
|
+
* This should be called once per frame
|
|
114
|
+
* @returns {boolean} - Whether any properties changed this frame
|
|
115
|
+
*/
|
|
116
|
+
update() {
|
|
117
|
+
let changed = false;
|
|
118
|
+
|
|
119
|
+
// Check if light position has changed
|
|
120
|
+
if (this._lastPosition === undefined ||
|
|
121
|
+
this._lastPosition.x !== this.position.x ||
|
|
122
|
+
this._lastPosition.y !== this.position.y ||
|
|
123
|
+
this._lastPosition.z !== this.position.z) {
|
|
124
|
+
|
|
125
|
+
// Cache current position to detect changes
|
|
126
|
+
this._lastPosition = {
|
|
127
|
+
x: this.position.x,
|
|
128
|
+
y: this.position.y,
|
|
129
|
+
z: this.position.z
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
changed = true;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Track intensity changes
|
|
136
|
+
if (this._lastIntensity === undefined ||
|
|
137
|
+
Math.abs(this._lastIntensity - this.intensity) > 0.0001) {
|
|
138
|
+
|
|
139
|
+
this._lastIntensity = this.intensity;
|
|
140
|
+
changed = true;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return changed;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Sync light properties with global constants
|
|
148
|
+
* This should be implemented by subclasses
|
|
149
|
+
*/
|
|
150
|
+
syncWithConstants() {
|
|
151
|
+
// Base implementation does nothing
|
|
152
|
+
// Subclasses should override this
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Setup shadow mapping resources
|
|
157
|
+
* This should be implemented by subclasses
|
|
158
|
+
*/
|
|
159
|
+
setupShadowMap() {
|
|
160
|
+
// Base implementation does nothing
|
|
161
|
+
// Subclasses should override this
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Begin shadow rendering pass for this light
|
|
166
|
+
* This should be implemented by subclasses
|
|
167
|
+
*/
|
|
168
|
+
beginShadowPass() {
|
|
169
|
+
// Base implementation does nothing
|
|
170
|
+
// Subclasses should override this
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* End shadow rendering pass for this light
|
|
175
|
+
* This should be implemented by subclasses
|
|
176
|
+
*/
|
|
177
|
+
endShadowPass() {
|
|
178
|
+
// Base implementation does nothing
|
|
179
|
+
// Subclasses should override this
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Render a single object to this light's shadow map
|
|
184
|
+
* This should be implemented by subclasses
|
|
185
|
+
* @param {object} object - The object to render to the shadow map
|
|
186
|
+
*/
|
|
187
|
+
renderObjectToShadowMap(object) {
|
|
188
|
+
// Base implementation does nothing
|
|
189
|
+
// Subclasses should override this
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Apply this light's uniforms to a shader program
|
|
194
|
+
* This should be implemented by subclasses
|
|
195
|
+
* @param {WebGLProgram} program - The shader program
|
|
196
|
+
* @param {number} index - Index of this light in an array of lights
|
|
197
|
+
*/
|
|
198
|
+
applyToShader(program, index) {
|
|
199
|
+
// Base implementation does nothing
|
|
200
|
+
// Subclasses should override this
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Cleanup resources used by this light
|
|
205
|
+
* This should be called when the light is no longer needed
|
|
206
|
+
*/
|
|
207
|
+
dispose() {
|
|
208
|
+
// Base implementation does nothing
|
|
209
|
+
// Subclasses should override to free GL resources
|
|
210
|
+
}
|
|
211
|
+
}
|