pixospritz-core 0.10.1 → 1.0.1

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.
Files changed (157) hide show
  1. package/README.md +36 -286
  2. package/dist/bundle.js +13 -3
  3. package/dist/bundle.js.map +1 -1
  4. package/dist/style.css +1 -0
  5. package/package.json +43 -44
  6. package/src/components/WebGLView.jsx +318 -0
  7. package/src/css/pixos.css +372 -0
  8. package/src/engine/actions/animate.js +41 -0
  9. package/src/engine/actions/changezone.js +135 -0
  10. package/src/engine/actions/chat.js +109 -0
  11. package/src/engine/actions/dialogue.js +90 -0
  12. package/src/engine/actions/face.js +22 -0
  13. package/src/engine/actions/greeting.js +28 -0
  14. package/src/engine/actions/interact.js +86 -0
  15. package/src/engine/actions/move.js +67 -0
  16. package/src/engine/actions/patrol.js +109 -0
  17. package/src/engine/actions/prompt.js +185 -0
  18. package/src/engine/actions/script.js +42 -0
  19. package/src/engine/core/audio/AudioSystem.js +543 -0
  20. package/src/engine/core/cutscene/PxcPlayer.js +956 -0
  21. package/src/engine/core/cutscene/manager.js +243 -0
  22. package/src/engine/core/database/index.js +75 -0
  23. package/src/engine/core/debug/index.js +371 -0
  24. package/src/engine/core/hud/index.js +765 -0
  25. package/src/engine/core/index.js +540 -0
  26. package/src/engine/core/input/gamepad/Controller.js +71 -0
  27. package/src/engine/core/input/gamepad/ControllerButtons.js +231 -0
  28. package/src/engine/core/input/gamepad/ControllerStick.js +173 -0
  29. package/src/engine/core/input/gamepad/index.js +592 -0
  30. package/src/engine/core/input/keyboard.js +196 -0
  31. package/src/engine/core/input/manager.js +485 -0
  32. package/src/engine/core/input/mouse.js +203 -0
  33. package/src/engine/core/input/touch.js +175 -0
  34. package/src/engine/core/mode/manager.js +199 -0
  35. package/src/engine/core/net/manager.js +535 -0
  36. package/src/engine/core/queue/action.js +83 -0
  37. package/src/engine/core/queue/event.js +82 -0
  38. package/src/engine/core/queue/index.js +44 -0
  39. package/src/engine/core/queue/loadable.js +33 -0
  40. package/src/engine/core/render/CameraEffects.js +494 -0
  41. package/src/engine/core/render/FrustumCuller.js +417 -0
  42. package/src/engine/core/render/LODManager.js +285 -0
  43. package/src/engine/core/render/ParticleManager.js +529 -0
  44. package/src/engine/core/render/TextureAtlas.js +465 -0
  45. package/src/engine/core/render/camera.js +338 -0
  46. package/src/engine/core/render/light.js +197 -0
  47. package/src/engine/core/render/manager.js +1079 -0
  48. package/src/engine/core/render/shaders.js +110 -0
  49. package/src/engine/core/render/skybox.js +342 -0
  50. package/src/engine/core/resource/manager.js +133 -0
  51. package/src/engine/core/resource/object.js +611 -0
  52. package/src/engine/core/resource/texture.js +103 -0
  53. package/src/engine/core/resource/tileset.js +177 -0
  54. package/src/engine/core/scene/avatar.js +215 -0
  55. package/src/engine/core/scene/speech.js +138 -0
  56. package/src/engine/core/scene/sprite.js +702 -0
  57. package/src/engine/core/scene/spritz.js +189 -0
  58. package/src/engine/core/scene/world.js +681 -0
  59. package/src/engine/core/scene/zone.js +1167 -0
  60. package/src/engine/core/store/index.js +110 -0
  61. package/src/engine/dynamic/animatedSprite.js +64 -0
  62. package/src/engine/dynamic/animatedTile.js +98 -0
  63. package/src/engine/dynamic/avatar.js +110 -0
  64. package/src/engine/dynamic/map.js +174 -0
  65. package/src/engine/dynamic/sprite.js +255 -0
  66. package/src/engine/dynamic/spritz.js +119 -0
  67. package/src/engine/events/EventSystem.js +609 -0
  68. package/src/engine/events/camera.js +142 -0
  69. package/src/engine/events/chat.js +75 -0
  70. package/src/engine/events/menu.js +186 -0
  71. package/src/engine/scripting/CallbackManager.js +514 -0
  72. package/src/engine/scripting/PixoScriptInterpreter.js +81 -0
  73. package/src/engine/scripting/PixoScriptLibrary.js +704 -0
  74. package/src/engine/shaders/effects/index.js +450 -0
  75. package/src/engine/shaders/fs.js +222 -0
  76. package/src/engine/shaders/particles/fs.js +41 -0
  77. package/src/engine/shaders/particles/vs.js +61 -0
  78. package/src/engine/shaders/picker/fs.js +34 -0
  79. package/src/engine/shaders/picker/init.js +62 -0
  80. package/src/engine/shaders/picker/vs.js +42 -0
  81. package/src/engine/shaders/pxsl/README.md +250 -0
  82. package/src/engine/shaders/pxsl/index.js +25 -0
  83. package/src/engine/shaders/pxsl/library.js +608 -0
  84. package/src/engine/shaders/pxsl/manager.js +338 -0
  85. package/src/engine/shaders/pxsl/specification.js +363 -0
  86. package/src/engine/shaders/pxsl/transpiler.js +753 -0
  87. package/src/engine/shaders/skybox/cosmic/fs.js +147 -0
  88. package/src/engine/shaders/skybox/cosmic/vs.js +23 -0
  89. package/src/engine/shaders/skybox/matrix/fs.js +127 -0
  90. package/src/engine/shaders/skybox/matrix/vs.js +23 -0
  91. package/src/engine/shaders/skybox/morning/fs.js +109 -0
  92. package/src/engine/shaders/skybox/morning/vs.js +23 -0
  93. package/src/engine/shaders/skybox/neon/fs.js +119 -0
  94. package/src/engine/shaders/skybox/neon/vs.js +23 -0
  95. package/src/engine/shaders/skybox/sky/fs.js +114 -0
  96. package/src/engine/shaders/skybox/sky/vs.js +23 -0
  97. package/src/engine/shaders/skybox/sunset/fs.js +101 -0
  98. package/src/engine/shaders/skybox/sunset/vs.js +23 -0
  99. package/src/engine/shaders/transition/blur/fs.js +42 -0
  100. package/src/engine/shaders/transition/blur/vs.js +26 -0
  101. package/src/engine/shaders/transition/cross/fs.js +36 -0
  102. package/src/engine/shaders/transition/cross/vs.js +26 -0
  103. package/src/engine/shaders/transition/crossBlur/fs.js +41 -0
  104. package/src/engine/shaders/transition/crossBlur/vs.js +25 -0
  105. package/src/engine/shaders/transition/dissolve/fs.js +78 -0
  106. package/src/engine/shaders/transition/dissolve/vs.js +24 -0
  107. package/src/engine/shaders/transition/fade/fs.js +31 -0
  108. package/src/engine/shaders/transition/fade/vs.js +27 -0
  109. package/src/engine/shaders/transition/iris/fs.js +52 -0
  110. package/src/engine/shaders/transition/iris/vs.js +24 -0
  111. package/src/engine/shaders/transition/pixelate/fs.js +44 -0
  112. package/src/engine/shaders/transition/pixelate/vs.js +24 -0
  113. package/src/engine/shaders/transition/slide/fs.js +53 -0
  114. package/src/engine/shaders/transition/slide/vs.js +24 -0
  115. package/src/engine/shaders/transition/swirl/fs.js +39 -0
  116. package/src/engine/shaders/transition/swirl/vs.js +26 -0
  117. package/src/engine/shaders/transition/wipe/fs.js +50 -0
  118. package/src/engine/shaders/transition/wipe/vs.js +24 -0
  119. package/src/engine/shaders/vs.js +60 -0
  120. package/src/engine/utils/CameraController.js +506 -0
  121. package/src/engine/utils/ObjHelper.js +551 -0
  122. package/src/engine/utils/debug-logger.js +110 -0
  123. package/src/engine/utils/enums.js +305 -0
  124. package/src/engine/utils/generator.js +156 -0
  125. package/src/engine/utils/index.js +21 -0
  126. package/src/engine/utils/loaders/ActionLoader.js +77 -0
  127. package/src/engine/utils/loaders/AudioLoader.js +157 -0
  128. package/src/engine/utils/loaders/EventLoader.js +66 -0
  129. package/src/engine/utils/loaders/ObjectLoader.js +67 -0
  130. package/src/engine/utils/loaders/SpriteLoader.js +77 -0
  131. package/src/engine/utils/loaders/TilesetLoader.js +103 -0
  132. package/src/engine/utils/loaders/index.js +21 -0
  133. package/src/engine/utils/math/matrix4.js +367 -0
  134. package/src/engine/utils/math/vector.js +458 -0
  135. package/src/engine/utils/obj/_old_js/index.js +46 -0
  136. package/src/engine/utils/obj/_old_js/layout.js +308 -0
  137. package/src/engine/utils/obj/_old_js/material.js +711 -0
  138. package/src/engine/utils/obj/_old_js/mesh.js +761 -0
  139. package/src/engine/utils/obj/_old_js/utils.js +647 -0
  140. package/src/engine/utils/obj/index.js +24 -0
  141. package/src/engine/utils/obj/js/index.js +277 -0
  142. package/src/engine/utils/obj/js/loader.js +232 -0
  143. package/src/engine/utils/obj/layout.js +246 -0
  144. package/src/engine/utils/obj/material.js +665 -0
  145. package/src/engine/utils/obj/mesh.js +657 -0
  146. package/src/engine/utils/obj/ts/index.ts +72 -0
  147. package/src/engine/utils/obj/ts/layout.ts +265 -0
  148. package/src/engine/utils/obj/ts/material.ts +760 -0
  149. package/src/engine/utils/obj/ts/mesh.ts +785 -0
  150. package/src/engine/utils/obj/ts/utils.ts +501 -0
  151. package/src/engine/utils/obj/utils.js +428 -0
  152. package/src/engine/utils/resources.js +18 -0
  153. package/src/index.jsx +55 -0
  154. package/src/spritz/player.js +18 -0
  155. package/src/spritz/readme.md +18 -0
  156. package/LICENSE +0 -437
  157. package/dist/bundle.js.LICENSE.txt +0 -31
@@ -0,0 +1,246 @@
1
+ export var TYPES;
2
+ (function (TYPES) {
3
+ TYPES["BYTE"] = "BYTE";
4
+ TYPES["UNSIGNED_BYTE"] = "UNSIGNED_BYTE";
5
+ TYPES["SHORT"] = "SHORT";
6
+ TYPES["UNSIGNED_SHORT"] = "UNSIGNED_SHORT";
7
+ TYPES["FLOAT"] = "FLOAT";
8
+ })(TYPES || (TYPES = {}));
9
+ /**
10
+ * An exception for when two or more of the same attributes are found in the
11
+ * same layout.
12
+ * @private
13
+ */
14
+ export class DuplicateAttributeException extends Error {
15
+ /**
16
+ * Create a DuplicateAttributeException
17
+ * @param {Attribute} attribute - The attribute that was found more than
18
+ * once in the {@link Layout}
19
+ */
20
+ constructor(attribute) {
21
+ super(`found duplicate attribute: ${attribute.key}`);
22
+ }
23
+ }
24
+ /**
25
+ * Represents how a vertex attribute should be packed into an buffer.
26
+ * @private
27
+ */
28
+ export class Attribute {
29
+ /**
30
+ * Create an attribute. Do not call this directly, use the predefined
31
+ * constants.
32
+ * @param {string} key - The name of this attribute as if it were a key in
33
+ * an Object. Use the camel case version of the upper snake case
34
+ * const name.
35
+ * @param {number} size - The number of components per vertex attribute.
36
+ * Must be 1, 2, 3, or 4.
37
+ * @param {string} type - The data type of each component for this
38
+ * attribute. Possible values:<br/>
39
+ * "BYTE": signed 8-bit integer, with values in [-128, 127]<br/>
40
+ * "SHORT": signed 16-bit integer, with values in
41
+ * [-32768, 32767]<br/>
42
+ * "UNSIGNED_BYTE": unsigned 8-bit integer, with values in
43
+ * [0, 255]<br/>
44
+ * "UNSIGNED_SHORT": unsigned 16-bit integer, with values in
45
+ * [0, 65535]<br/>
46
+ * "FLOAT": 32-bit floating point number
47
+ * @param {boolean} normalized - Whether integer data values should be
48
+ * normalized when being casted to a float.<br/>
49
+ * If true, signed integers are normalized to [-1, 1].<br/>
50
+ * If true, unsigned integers are normalized to [0, 1].<br/>
51
+ * For type "FLOAT", this parameter has no effect.
52
+ */
53
+ constructor(key, size, type, normalized = false) {
54
+ this.key = key;
55
+ this.size = size;
56
+ this.type = type;
57
+ this.normalized = normalized;
58
+ switch (type) {
59
+ case "BYTE":
60
+ case "UNSIGNED_BYTE":
61
+ this.sizeOfType = 1;
62
+ break;
63
+ case "SHORT":
64
+ case "UNSIGNED_SHORT":
65
+ this.sizeOfType = 2;
66
+ break;
67
+ case "FLOAT":
68
+ this.sizeOfType = 4;
69
+ break;
70
+ default:
71
+ throw new Error(`Unknown gl type: ${type}`);
72
+ }
73
+ this.sizeInBytes = this.sizeOfType * size;
74
+ }
75
+ }
76
+ /**
77
+ * A class to represent the memory layout for a vertex attribute array. Used by
78
+ * {@link Mesh}'s TBD(...) method to generate a packed array from mesh data.
79
+ * <p>
80
+ * Layout can sort of be thought of as a C-style struct declaration.
81
+ * {@link Mesh}'s TBD(...) method will use the {@link Layout} instance to
82
+ * pack an array in the given attribute order.
83
+ * <p>
84
+ * Layout also is very helpful when calling a WebGL context's
85
+ * <code>vertexAttribPointer</code> method. If you've created a buffer using
86
+ * a Layout instance, then the same Layout instance can be used to determine
87
+ * the size, type, normalized, stride, and offset parameters for
88
+ * <code>vertexAttribPointer</code>.
89
+ * <p>
90
+ * For example:
91
+ * <pre><code>
92
+ *
93
+ * const index = glctx.getAttribLocation(shaderProgram, "pos");
94
+ * glctx.vertexAttribPointer(
95
+ * layout.position.size,
96
+ * glctx[layout.position.type],
97
+ * layout.position.normalized,
98
+ * layout.position.stride,
99
+ * layout.position.offset);
100
+ * </code></pre>
101
+ * @see {@link Mesh}
102
+ */
103
+ export class Layout {
104
+ /**
105
+ * Create a Layout object. This constructor will throw if any duplicate
106
+ * attributes are given.
107
+ * @param {Array} ...attributes - An ordered list of attributes that
108
+ * describe the desired memory layout for each vertex attribute.
109
+ * <p>
110
+ *
111
+ * @see {@link Mesh}
112
+ */
113
+ constructor(...attributes) {
114
+ this.attributes = attributes;
115
+ this.attributeMap = {};
116
+ let offset = 0;
117
+ let maxStrideMultiple = 0;
118
+ for (const attribute of attributes) {
119
+ if (this.attributeMap[attribute.key]) {
120
+ throw new DuplicateAttributeException(attribute);
121
+ }
122
+ // Add padding to satisfy WebGL's requirement that all
123
+ // vertexAttribPointer calls have an offset that is a multiple of
124
+ // the type size.
125
+ if (offset % attribute.sizeOfType !== 0) {
126
+ offset += attribute.sizeOfType - (offset % attribute.sizeOfType);
127
+ console.warn("Layout requires padding before " + attribute.key + " attribute");
128
+ }
129
+ this.attributeMap[attribute.key] = {
130
+ attribute: attribute,
131
+ size: attribute.size,
132
+ type: attribute.type,
133
+ normalized: attribute.normalized,
134
+ offset: offset,
135
+ };
136
+ offset += attribute.sizeInBytes;
137
+ maxStrideMultiple = Math.max(maxStrideMultiple, attribute.sizeOfType);
138
+ }
139
+ // Add padding to the end to satisfy WebGL's requirement that all
140
+ // vertexAttribPointer calls have a stride that is a multiple of the
141
+ // type size. Because we're putting differently sized attributes into
142
+ // the same buffer, it must be padded to a multiple of the largest
143
+ // type size.
144
+ if (offset % maxStrideMultiple !== 0) {
145
+ offset += maxStrideMultiple - (offset % maxStrideMultiple);
146
+ console.warn("Layout requires padding at the back");
147
+ }
148
+ this.stride = offset;
149
+ for (const attribute of attributes) {
150
+ this.attributeMap[attribute.key].stride = this.stride;
151
+ }
152
+ }
153
+ }
154
+ // Geometry attributes
155
+ /**
156
+ * Attribute layout to pack a vertex's x, y, & z as floats
157
+ *
158
+ * @see {@link Layout}
159
+ */
160
+ Layout.POSITION = new Attribute("position", 3, TYPES.FLOAT);
161
+ /**
162
+ * Attribute layout to pack a vertex's normal's x, y, & z as floats
163
+ *
164
+ * @see {@link Layout}
165
+ */
166
+ Layout.NORMAL = new Attribute("normal", 3, TYPES.FLOAT);
167
+ /**
168
+ * Attribute layout to pack a vertex's normal's x, y, & z as floats.
169
+ * <p>
170
+ * This value will be computed on-the-fly based on the texture coordinates.
171
+ * If no texture coordinates are available, the generated value will default to
172
+ * 0, 0, 0.
173
+ *
174
+ * @see {@link Layout}
175
+ */
176
+ Layout.TANGENT = new Attribute("tangent", 3, TYPES.FLOAT);
177
+ /**
178
+ * Attribute layout to pack a vertex's normal's bitangent x, y, & z as floats.
179
+ * <p>
180
+ * This value will be computed on-the-fly based on the texture coordinates.
181
+ * If no texture coordinates are available, the generated value will default to
182
+ * 0, 0, 0.
183
+ * @see {@link Layout}
184
+ */
185
+ Layout.BITANGENT = new Attribute("bitangent", 3, TYPES.FLOAT);
186
+ /**
187
+ * Attribute layout to pack a vertex's texture coordinates' u & v as floats
188
+ *
189
+ * @see {@link Layout}
190
+ */
191
+ Layout.UV = new Attribute("uv", 2, TYPES.FLOAT);
192
+ // Material attributes
193
+ /**
194
+ * Attribute layout to pack an unsigned short to be interpreted as a the index
195
+ * into a {@link Mesh}'s materials list.
196
+ * <p>
197
+ * The intention of this value is to send all of the {@link Mesh}'s materials
198
+ * into multiple shader uniforms and then reference the current one by this
199
+ * vertex attribute.
200
+ * <p>
201
+ * example glsl code:
202
+ *
203
+ * <pre><code>
204
+ * // this is bound using MATERIAL_INDEX
205
+ * attribute int materialIndex;
206
+ *
207
+ * struct Material {
208
+ * vec3 diffuse;
209
+ * vec3 specular;
210
+ * vec3 specularExponent;
211
+ * };
212
+ *
213
+ * uniform Material materials[MAX_MATERIALS];
214
+ *
215
+ * // ...
216
+ *
217
+ * vec3 diffuse = materials[materialIndex];
218
+ *
219
+ * </code></pre>
220
+ * TODO: More description & test to make sure subscripting by attributes even
221
+ * works for webgl
222
+ *
223
+ * @see {@link Layout}
224
+ */
225
+ Layout.MATERIAL_INDEX = new Attribute("materialIndex", 1, TYPES.SHORT);
226
+ Layout.MATERIAL_ENABLED = new Attribute("materialEnabled", 1, TYPES.UNSIGNED_SHORT);
227
+ Layout.AMBIENT = new Attribute("ambient", 3, TYPES.FLOAT);
228
+ Layout.DIFFUSE = new Attribute("diffuse", 3, TYPES.FLOAT);
229
+ Layout.SPECULAR = new Attribute("specular", 3, TYPES.FLOAT);
230
+ Layout.SPECULAR_EXPONENT = new Attribute("specularExponent", 3, TYPES.FLOAT);
231
+ Layout.EMISSIVE = new Attribute("emissive", 3, TYPES.FLOAT);
232
+ Layout.TRANSMISSION_FILTER = new Attribute("transmissionFilter", 3, TYPES.FLOAT);
233
+ Layout.DISSOLVE = new Attribute("dissolve", 1, TYPES.FLOAT);
234
+ Layout.ILLUMINATION = new Attribute("illumination", 1, TYPES.UNSIGNED_SHORT);
235
+ Layout.REFRACTION_INDEX = new Attribute("refractionIndex", 1, TYPES.FLOAT);
236
+ Layout.SHARPNESS = new Attribute("sharpness", 1, TYPES.FLOAT);
237
+ Layout.MAP_DIFFUSE = new Attribute("mapDiffuse", 1, TYPES.SHORT);
238
+ Layout.MAP_AMBIENT = new Attribute("mapAmbient", 1, TYPES.SHORT);
239
+ Layout.MAP_SPECULAR = new Attribute("mapSpecular", 1, TYPES.SHORT);
240
+ Layout.MAP_SPECULAR_EXPONENT = new Attribute("mapSpecularExponent", 1, TYPES.SHORT);
241
+ Layout.MAP_DISSOLVE = new Attribute("mapDissolve", 1, TYPES.SHORT);
242
+ Layout.ANTI_ALIASING = new Attribute("antiAliasing", 1, TYPES.UNSIGNED_SHORT);
243
+ Layout.MAP_BUMP = new Attribute("mapBump", 1, TYPES.SHORT);
244
+ Layout.MAP_DISPLACEMENT = new Attribute("mapDisplacement", 1, TYPES.SHORT);
245
+ Layout.MAP_DECAL = new Attribute("mapDecal", 1, TYPES.SHORT);
246
+ Layout.MAP_EMISSIVE = new Attribute("mapEmissive", 1, TYPES.SHORT);