spoint 0.1.0 → 0.1.10

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 (204) hide show
  1. package/README.md +134 -209
  2. package/SKILL.md +95 -0
  3. package/apps/environment/index.js +200 -1
  4. package/apps/environment/models/decorative/.gitkeep +0 -0
  5. package/apps/environment/models/hazards/.gitkeep +0 -0
  6. package/apps/environment/models/interactive/.gitkeep +0 -0
  7. package/apps/environment/models/structures/.gitkeep +0 -0
  8. package/apps/environment/smartObjects.js +114 -0
  9. package/apps/interactable/index.js +155 -0
  10. package/apps/physics-crate/index.js +15 -9
  11. package/apps/power-crate/index.js +18 -12
  12. package/apps/tps-game/$GDUPI.vrm +0 -0
  13. package/apps/tps-game/Cleetus.vrm +0 -0
  14. package/apps/tps-game/index.js +185 -27
  15. package/apps/world/index.js +68 -22
  16. package/bin/create-app.js +337 -0
  17. package/client/ARControls.js +301 -0
  18. package/client/LoadingManager.js +117 -0
  19. package/client/MobileControls.js +1122 -0
  20. package/client/anim-lib.glb +0 -0
  21. package/client/animation.js +306 -0
  22. package/client/app.js +1341 -65
  23. package/client/camera.js +191 -33
  24. package/client/createLoadingScreen.js +69 -0
  25. package/client/editor/bridge.js +113 -0
  26. package/client/editor/css/main.css +794 -0
  27. package/client/editor/images/rotate.svg +4 -0
  28. package/client/editor/images/scale.svg +4 -0
  29. package/client/editor/images/translate.svg +4 -0
  30. package/client/editor/index.html +103 -0
  31. package/client/editor/js/Command.js +41 -0
  32. package/client/editor/js/Config.js +81 -0
  33. package/client/editor/js/Editor.js +785 -0
  34. package/client/editor/js/EditorControls.js +438 -0
  35. package/client/editor/js/History.js +321 -0
  36. package/client/editor/js/Loader.js +987 -0
  37. package/client/editor/js/LoaderUtils.js +90 -0
  38. package/client/editor/js/Menubar.Add.js +510 -0
  39. package/client/editor/js/Menubar.Edit.js +145 -0
  40. package/client/editor/js/Menubar.File.js +466 -0
  41. package/client/editor/js/Menubar.Help.js +73 -0
  42. package/client/editor/js/Menubar.Status.js +51 -0
  43. package/client/editor/js/Menubar.View.js +183 -0
  44. package/client/editor/js/Menubar.js +27 -0
  45. package/client/editor/js/Player.js +53 -0
  46. package/client/editor/js/Resizer.js +58 -0
  47. package/client/editor/js/Script.js +503 -0
  48. package/client/editor/js/Selector.js +102 -0
  49. package/client/editor/js/Sidebar.Geometry.BoxGeometry.js +121 -0
  50. package/client/editor/js/Sidebar.Geometry.BufferGeometry.js +115 -0
  51. package/client/editor/js/Sidebar.Geometry.CapsuleGeometry.js +97 -0
  52. package/client/editor/js/Sidebar.Geometry.CircleGeometry.js +97 -0
  53. package/client/editor/js/Sidebar.Geometry.CylinderGeometry.js +121 -0
  54. package/client/editor/js/Sidebar.Geometry.DodecahedronGeometry.js +73 -0
  55. package/client/editor/js/Sidebar.Geometry.ExtrudeGeometry.js +196 -0
  56. package/client/editor/js/Sidebar.Geometry.IcosahedronGeometry.js +73 -0
  57. package/client/editor/js/Sidebar.Geometry.LatheGeometry.js +98 -0
  58. package/client/editor/js/Sidebar.Geometry.Modifiers.js +73 -0
  59. package/client/editor/js/Sidebar.Geometry.OctahedronGeometry.js +74 -0
  60. package/client/editor/js/Sidebar.Geometry.PlaneGeometry.js +97 -0
  61. package/client/editor/js/Sidebar.Geometry.RingGeometry.js +121 -0
  62. package/client/editor/js/Sidebar.Geometry.ShapeGeometry.js +76 -0
  63. package/client/editor/js/Sidebar.Geometry.SphereGeometry.js +133 -0
  64. package/client/editor/js/Sidebar.Geometry.TetrahedronGeometry.js +74 -0
  65. package/client/editor/js/Sidebar.Geometry.TorusGeometry.js +109 -0
  66. package/client/editor/js/Sidebar.Geometry.TorusKnotGeometry.js +121 -0
  67. package/client/editor/js/Sidebar.Geometry.TubeGeometry.js +135 -0
  68. package/client/editor/js/Sidebar.Geometry.js +332 -0
  69. package/client/editor/js/Sidebar.Material.BooleanProperty.js +60 -0
  70. package/client/editor/js/Sidebar.Material.ColorProperty.js +87 -0
  71. package/client/editor/js/Sidebar.Material.ConstantProperty.js +62 -0
  72. package/client/editor/js/Sidebar.Material.MapProperty.js +249 -0
  73. package/client/editor/js/Sidebar.Material.NumberProperty.js +60 -0
  74. package/client/editor/js/Sidebar.Material.Program.js +73 -0
  75. package/client/editor/js/Sidebar.Material.RangeValueProperty.js +63 -0
  76. package/client/editor/js/Sidebar.Material.js +751 -0
  77. package/client/editor/js/Sidebar.Object.Animation.js +102 -0
  78. package/client/editor/js/Sidebar.Object.js +898 -0
  79. package/client/editor/js/Sidebar.Project.App.js +165 -0
  80. package/client/editor/js/Sidebar.Project.Image.js +225 -0
  81. package/client/editor/js/Sidebar.Project.Materials.js +82 -0
  82. package/client/editor/js/Sidebar.Project.Renderer.js +144 -0
  83. package/client/editor/js/Sidebar.Project.Video.js +242 -0
  84. package/client/editor/js/Sidebar.Project.js +31 -0
  85. package/client/editor/js/Sidebar.Properties.js +73 -0
  86. package/client/editor/js/Sidebar.Scene.js +585 -0
  87. package/client/editor/js/Sidebar.Script.js +129 -0
  88. package/client/editor/js/Sidebar.Settings.History.js +146 -0
  89. package/client/editor/js/Sidebar.Settings.Shortcuts.js +175 -0
  90. package/client/editor/js/Sidebar.Settings.js +60 -0
  91. package/client/editor/js/Sidebar.js +41 -0
  92. package/client/editor/js/Storage.js +98 -0
  93. package/client/editor/js/Strings.js +2028 -0
  94. package/client/editor/js/Toolbar.js +84 -0
  95. package/client/editor/js/Viewport.Controls.js +92 -0
  96. package/client/editor/js/Viewport.Info.js +136 -0
  97. package/client/editor/js/Viewport.Pathtracer.js +91 -0
  98. package/client/editor/js/Viewport.ViewHelper.js +39 -0
  99. package/client/editor/js/Viewport.XR.js +222 -0
  100. package/client/editor/js/Viewport.js +900 -0
  101. package/client/editor/js/commands/AddObjectCommand.js +68 -0
  102. package/client/editor/js/commands/AddScriptCommand.js +75 -0
  103. package/client/editor/js/commands/Commands.js +23 -0
  104. package/client/editor/js/commands/MoveObjectCommand.js +111 -0
  105. package/client/editor/js/commands/MultiCmdsCommand.js +85 -0
  106. package/client/editor/js/commands/RemoveObjectCommand.js +88 -0
  107. package/client/editor/js/commands/RemoveScriptCommand.js +81 -0
  108. package/client/editor/js/commands/SetColorCommand.js +73 -0
  109. package/client/editor/js/commands/SetGeometryCommand.js +87 -0
  110. package/client/editor/js/commands/SetGeometryValueCommand.js +70 -0
  111. package/client/editor/js/commands/SetMaterialColorCommand.js +86 -0
  112. package/client/editor/js/commands/SetMaterialCommand.js +79 -0
  113. package/client/editor/js/commands/SetMaterialMapCommand.js +143 -0
  114. package/client/editor/js/commands/SetMaterialRangeCommand.js +91 -0
  115. package/client/editor/js/commands/SetMaterialValueCommand.js +90 -0
  116. package/client/editor/js/commands/SetMaterialVectorCommand.js +79 -0
  117. package/client/editor/js/commands/SetPositionCommand.js +84 -0
  118. package/client/editor/js/commands/SetRotationCommand.js +84 -0
  119. package/client/editor/js/commands/SetScaleCommand.js +84 -0
  120. package/client/editor/js/commands/SetSceneCommand.js +103 -0
  121. package/client/editor/js/commands/SetScriptValueCommand.js +80 -0
  122. package/client/editor/js/commands/SetShadowValueCommand.js +73 -0
  123. package/client/editor/js/commands/SetUuidCommand.js +70 -0
  124. package/client/editor/js/commands/SetValueCommand.js +75 -0
  125. package/client/editor/js/libs/acorn/acorn.js +3236 -0
  126. package/client/editor/js/libs/acorn/acorn_loose.js +1299 -0
  127. package/client/editor/js/libs/acorn/walk.js +344 -0
  128. package/client/editor/js/libs/app/index.html +57 -0
  129. package/client/editor/js/libs/app.js +251 -0
  130. package/client/editor/js/libs/codemirror/addon/dialog.css +32 -0
  131. package/client/editor/js/libs/codemirror/addon/dialog.js +163 -0
  132. package/client/editor/js/libs/codemirror/addon/show-hint.css +36 -0
  133. package/client/editor/js/libs/codemirror/addon/show-hint.js +529 -0
  134. package/client/editor/js/libs/codemirror/addon/tern.css +87 -0
  135. package/client/editor/js/libs/codemirror/addon/tern.js +750 -0
  136. package/client/editor/js/libs/codemirror/codemirror.css +344 -0
  137. package/client/editor/js/libs/codemirror/codemirror.js +9849 -0
  138. package/client/editor/js/libs/codemirror/mode/glsl.js +233 -0
  139. package/client/editor/js/libs/codemirror/mode/javascript.js +959 -0
  140. package/client/editor/js/libs/codemirror/theme/monokai.css +41 -0
  141. package/client/editor/js/libs/esprima.js +6401 -0
  142. package/client/editor/js/libs/jsonlint.js +453 -0
  143. package/client/editor/js/libs/signals.min.js +14 -0
  144. package/client/editor/js/libs/tern-threejs/threejs.js +5031 -0
  145. package/client/editor/js/libs/ternjs/comment.js +87 -0
  146. package/client/editor/js/libs/ternjs/def.js +588 -0
  147. package/client/editor/js/libs/ternjs/doc_comment.js +401 -0
  148. package/client/editor/js/libs/ternjs/infer.js +1635 -0
  149. package/client/editor/js/libs/ternjs/polyfill.js +80 -0
  150. package/client/editor/js/libs/ternjs/signal.js +26 -0
  151. package/client/editor/js/libs/ternjs/tern.js +993 -0
  152. package/client/editor/js/libs/ui.js +1346 -0
  153. package/client/editor/js/libs/ui.three.js +855 -0
  154. package/client/facial-animation.js +455 -0
  155. package/client/index.html +7 -4
  156. package/client/loading.css +147 -0
  157. package/client/loading.html +25 -0
  158. package/client/style.css +251 -0
  159. package/package.json +7 -3
  160. package/server.js +9 -1
  161. package/src/apps/AppContext.js +1 -1
  162. package/src/apps/AppLoader.js +50 -37
  163. package/src/apps/AppRuntime.js +32 -8
  164. package/src/client/InputHandler.js +233 -0
  165. package/src/client/JitterBuffer.js +207 -0
  166. package/src/client/KalmanFilter.js +125 -0
  167. package/src/client/MessageHandler.js +101 -0
  168. package/src/client/PhysicsNetworkClient.js +141 -68
  169. package/src/client/ReconnectManager.js +62 -0
  170. package/src/client/SmoothInterpolation.js +127 -0
  171. package/src/client/SnapshotProcessor.js +144 -0
  172. package/src/connection/ConnectionManager.js +21 -3
  173. package/src/connection/SessionStore.js +13 -3
  174. package/src/index.client.js +4 -6
  175. package/src/netcode/EventLog.js +29 -15
  176. package/src/netcode/LagCompensator.js +25 -26
  177. package/src/netcode/NetworkState.js +4 -1
  178. package/src/netcode/PhysicsIntegration.js +20 -6
  179. package/src/netcode/PlayerManager.js +10 -2
  180. package/src/netcode/SnapshotEncoder.js +66 -19
  181. package/src/netcode/TickSystem.js +13 -4
  182. package/src/physics/World.js +66 -13
  183. package/src/protocol/msgpack.js +90 -63
  184. package/src/sdk/ReloadHandlers.js +12 -2
  185. package/src/sdk/ReloadManager.js +5 -0
  186. package/src/sdk/ServerHandlers.js +50 -11
  187. package/src/sdk/StaticHandler.js +22 -6
  188. package/src/sdk/TickHandler.js +101 -34
  189. package/src/sdk/scaffold.js +28 -0
  190. package/src/sdk/server.js +59 -33
  191. package/src/shared/movement.js +2 -1
  192. package/src/spatial/Octree.js +5 -0
  193. package/apps/interactive-door/index.js +0 -33
  194. package/apps/patrol-npc/index.js +0 -37
  195. package/src/connection/QualityMonitor.js +0 -46
  196. package/src/debug/StateInspector.js +0 -42
  197. package/src/index.js +0 -1
  198. package/src/index.server.js +0 -27
  199. package/src/protocol/Codec.js +0 -60
  200. package/src/protocol/SequenceTracker.js +0 -71
  201. package/src/sdk/ClientMessageHandler.js +0 -80
  202. package/src/sdk/client.js +0 -122
  203. package/world/kaira.glb +0 -0
  204. package/world/schwust.glb +0 -0
@@ -0,0 +1,321 @@
1
+ import * as Commands from './commands/Commands.js';
2
+
3
+ class History {
4
+
5
+ constructor( editor ) {
6
+
7
+ this.editor = editor;
8
+ this.undos = [];
9
+ this.redos = [];
10
+ this.lastCmdTime = Date.now();
11
+ this.idCounter = 0;
12
+
13
+ this.historyDisabled = false;
14
+ this.config = editor.config;
15
+
16
+ // signals
17
+
18
+ const scope = this;
19
+
20
+ this.editor.signals.startPlayer.add( function () {
21
+
22
+ scope.historyDisabled = true;
23
+
24
+ } );
25
+
26
+ this.editor.signals.stopPlayer.add( function () {
27
+
28
+ scope.historyDisabled = false;
29
+
30
+ } );
31
+
32
+ }
33
+
34
+ execute( cmd, optionalName ) {
35
+
36
+ const lastCmd = this.undos[ this.undos.length - 1 ];
37
+ const timeDifference = Date.now() - this.lastCmdTime;
38
+
39
+ const isUpdatableCmd = lastCmd &&
40
+ lastCmd.updatable &&
41
+ cmd.updatable &&
42
+ lastCmd.object === cmd.object &&
43
+ lastCmd.type === cmd.type &&
44
+ lastCmd.script === cmd.script &&
45
+ lastCmd.attributeName === cmd.attributeName;
46
+
47
+ if ( isUpdatableCmd && cmd.type === 'SetScriptValueCommand' ) {
48
+
49
+ // When the cmd.type is "SetScriptValueCommand" the timeDifference is ignored
50
+
51
+ lastCmd.update( cmd );
52
+ cmd = lastCmd;
53
+
54
+ } else if ( isUpdatableCmd && timeDifference < 500 ) {
55
+
56
+ lastCmd.update( cmd );
57
+ cmd = lastCmd;
58
+
59
+ } else {
60
+
61
+ // the command is not updatable and is added as a new part of the history
62
+
63
+ this.undos.push( cmd );
64
+ cmd.id = ++ this.idCounter;
65
+
66
+ }
67
+
68
+ cmd.name = ( optionalName !== undefined ) ? optionalName : cmd.name;
69
+ cmd.execute();
70
+ cmd.inMemory = true;
71
+
72
+ if ( this.config.getKey( 'settings/history' ) ) {
73
+
74
+ cmd.json = cmd.toJSON(); // serialize the cmd immediately after execution and append the json to the cmd
75
+
76
+ }
77
+
78
+ this.lastCmdTime = Date.now();
79
+
80
+ // clearing all the redo-commands
81
+
82
+ this.redos = [];
83
+ this.editor.signals.historyChanged.dispatch( cmd );
84
+
85
+ }
86
+
87
+ undo() {
88
+
89
+ if ( this.historyDisabled ) {
90
+
91
+ alert( this.editor.strings.getKey( 'prompt/history/forbid' ) );
92
+ return;
93
+
94
+ }
95
+
96
+ let cmd = undefined;
97
+
98
+ if ( this.undos.length > 0 ) {
99
+
100
+ cmd = this.undos.pop();
101
+
102
+ if ( cmd.inMemory === false ) {
103
+
104
+ cmd.fromJSON( cmd.json );
105
+
106
+ }
107
+
108
+ }
109
+
110
+ if ( cmd !== undefined ) {
111
+
112
+ cmd.undo();
113
+ this.redos.push( cmd );
114
+ this.editor.signals.historyChanged.dispatch( cmd );
115
+
116
+ }
117
+
118
+ return cmd;
119
+
120
+ }
121
+
122
+ redo() {
123
+
124
+ if ( this.historyDisabled ) {
125
+
126
+ alert( this.editor.strings.getKey( 'prompt/history/forbid' ) );
127
+ return;
128
+
129
+ }
130
+
131
+ let cmd = undefined;
132
+
133
+ if ( this.redos.length > 0 ) {
134
+
135
+ cmd = this.redos.pop();
136
+
137
+ if ( cmd.inMemory === false ) {
138
+
139
+ cmd.fromJSON( cmd.json );
140
+
141
+ }
142
+
143
+ }
144
+
145
+ if ( cmd !== undefined ) {
146
+
147
+ cmd.execute();
148
+ this.undos.push( cmd );
149
+ this.editor.signals.historyChanged.dispatch( cmd );
150
+
151
+ }
152
+
153
+ return cmd;
154
+
155
+ }
156
+
157
+ toJSON() {
158
+
159
+ const history = {};
160
+ history.undos = [];
161
+ history.redos = [];
162
+
163
+ if ( ! this.config.getKey( 'settings/history' ) ) {
164
+
165
+ return history;
166
+
167
+ }
168
+
169
+ // Append Undos to History
170
+
171
+ for ( let i = 0; i < this.undos.length; i ++ ) {
172
+
173
+ if ( this.undos[ i ].hasOwnProperty( 'json' ) ) {
174
+
175
+ history.undos.push( this.undos[ i ].json );
176
+
177
+ }
178
+
179
+ }
180
+
181
+ // Append Redos to History
182
+
183
+ for ( let i = 0; i < this.redos.length; i ++ ) {
184
+
185
+ if ( this.redos[ i ].hasOwnProperty( 'json' ) ) {
186
+
187
+ history.redos.push( this.redos[ i ].json );
188
+
189
+ }
190
+
191
+ }
192
+
193
+ return history;
194
+
195
+ }
196
+
197
+ fromJSON( json ) {
198
+
199
+ if ( json === undefined ) return;
200
+
201
+ for ( let i = 0; i < json.undos.length; i ++ ) {
202
+
203
+ const cmdJSON = json.undos[ i ];
204
+ const cmd = new Commands[ cmdJSON.type ]( this.editor ); // creates a new object of type "json.type"
205
+ cmd.json = cmdJSON;
206
+ cmd.id = cmdJSON.id;
207
+ cmd.name = cmdJSON.name;
208
+ this.undos.push( cmd );
209
+ this.idCounter = ( cmdJSON.id > this.idCounter ) ? cmdJSON.id : this.idCounter; // set last used idCounter
210
+
211
+ }
212
+
213
+ for ( let i = 0; i < json.redos.length; i ++ ) {
214
+
215
+ const cmdJSON = json.redos[ i ];
216
+ const cmd = new Commands[ cmdJSON.type ]( this.editor ); // creates a new object of type "json.type"
217
+ cmd.json = cmdJSON;
218
+ cmd.id = cmdJSON.id;
219
+ cmd.name = cmdJSON.name;
220
+ this.redos.push( cmd );
221
+ this.idCounter = ( cmdJSON.id > this.idCounter ) ? cmdJSON.id : this.idCounter; // set last used idCounter
222
+
223
+ }
224
+
225
+ // Select the last executed undo-command
226
+ this.editor.signals.historyChanged.dispatch( this.undos[ this.undos.length - 1 ] );
227
+
228
+ }
229
+
230
+ clear() {
231
+
232
+ this.undos = [];
233
+ this.redos = [];
234
+ this.idCounter = 0;
235
+
236
+ this.editor.signals.historyChanged.dispatch();
237
+
238
+ }
239
+
240
+ goToState( id ) {
241
+
242
+ if ( this.historyDisabled ) {
243
+
244
+ alert( this.editor.strings.getKey( 'prompt/history/forbid' ) );
245
+ return;
246
+
247
+ }
248
+
249
+ this.editor.signals.sceneGraphChanged.active = false;
250
+ this.editor.signals.historyChanged.active = false;
251
+
252
+ let cmd = this.undos.length > 0 ? this.undos[ this.undos.length - 1 ] : undefined; // next cmd to pop
253
+
254
+ if ( cmd === undefined || id > cmd.id ) {
255
+
256
+ cmd = this.redo();
257
+ while ( cmd !== undefined && id > cmd.id ) {
258
+
259
+ cmd = this.redo();
260
+
261
+ }
262
+
263
+ } else {
264
+
265
+ while ( true ) {
266
+
267
+ cmd = this.undos[ this.undos.length - 1 ]; // next cmd to pop
268
+
269
+ if ( cmd === undefined || id === cmd.id ) break;
270
+
271
+ this.undo();
272
+
273
+ }
274
+
275
+ }
276
+
277
+ this.editor.signals.sceneGraphChanged.active = true;
278
+ this.editor.signals.historyChanged.active = true;
279
+
280
+ this.editor.signals.sceneGraphChanged.dispatch();
281
+ this.editor.signals.historyChanged.dispatch( cmd );
282
+
283
+ }
284
+
285
+ enableSerialization( id ) {
286
+
287
+ /**
288
+ * because there might be commands in this.undos and this.redos
289
+ * which have not been serialized with .toJSON() we go back
290
+ * to the oldest command and redo one command after the other
291
+ * while also calling .toJSON() on them.
292
+ */
293
+
294
+ this.goToState( - 1 );
295
+
296
+ this.editor.signals.sceneGraphChanged.active = false;
297
+ this.editor.signals.historyChanged.active = false;
298
+
299
+ let cmd = this.redo();
300
+ while ( cmd !== undefined ) {
301
+
302
+ if ( ! cmd.hasOwnProperty( 'json' ) ) {
303
+
304
+ cmd.json = cmd.toJSON();
305
+
306
+ }
307
+
308
+ cmd = this.redo();
309
+
310
+ }
311
+
312
+ this.editor.signals.sceneGraphChanged.active = true;
313
+ this.editor.signals.historyChanged.active = true;
314
+
315
+ this.goToState( id );
316
+
317
+ }
318
+
319
+ }
320
+
321
+ export { History };