hytopia 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -12,6 +12,8 @@ HYTOPIA allows you to create your own highly-sharable, immersive, massively mult
12
12
 
13
13
  ## What is this SDK?
14
14
 
15
+ *Note: This SDK is currently in alpha development. Expect breaking changes with new version releases.*
16
+
15
17
  The HYTOPIA SDK makes it easy for developers to create multiplayer games on the HYTOPIA platform using JavaScript or TypeScript.
16
18
 
17
19
  Available as a simple NPM package, this SDK provides everything you need to get started:
@@ -29,17 +31,27 @@ With these resources, you can quickly build and share immersive, voxel-style mul
29
31
 
30
32
  1. Install a compatible JavaScript runtime. We recommend [Bun (recommended)](https://bun.sh/), but [Node.js](https://nodejs.org/) and [Deno](https://deno.com/) are also supported. All examples will be given using Bun.
31
33
 
32
- 2. Install the SDK in a new or existing project.
34
+ 2. If you're starting a new project, initialize it.
35
+ ```bash
36
+ bun init
37
+ ```
38
+
39
+ 3. Install the SDK in a new or existing project.
40
+ ```bash
41
+ bun add hytopia
42
+ ```
43
+
44
+ 4. Initialize boilerplate. Copies assets and an index.ts game script into your project.
33
45
  ```bash
34
- npm install hytopia
46
+ bunx hytopia init
35
47
  ```
36
48
 
37
- 2. Run a local HYTOPIA server using an example game included in the SDK. The following command will start the Zombie Arena example game on port 8080.
49
+ 5. Start the server, use --watch for hot reloads as you make changes.
38
50
  ```bash
39
- bun hytopia examples/zombie-arena
51
+ bun --watch index.ts
40
52
  ```
41
53
 
42
- 3. Visit https://play.hytopia.com - when prompted, enter the local server your game is running on, which is `http://localhost:8080`.
54
+ 4. Visit https://play.hytopia.com - when prompted, enter `localhost:8080` - this is the default port of the local server you started in the previous step.
43
55
 
44
56
  Once you're up and running, here's some other resources to go further:
45
57
  - [Game Examples](./examples)
package/bin/scripts.js ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const command = process.argv[2];
6
+
7
+ if (command === 'init') {
8
+ const srcDir = path.join(__dirname, '..', 'boilerplate');
9
+ const destDir = process.cwd();
10
+
11
+ fs.cpSync(srcDir, destDir, { recursive: true });
12
+
13
+ console.log('🚀 Hytopia project initialized successfully!');
14
+ console.log('💡 Start your development server with `bun --watch index.ts`!');
15
+ return;
16
+ }
17
+
18
+ console.log('Unknown command: ' + command);
@@ -41,6 +41,17 @@ import worldMap from './assets/map.json';
41
41
  */
42
42
 
43
43
  startServer(world => {
44
+ /**
45
+ * Enable debugging of the physics simulation.
46
+ * This will overlay lines in-game representing colliders,
47
+ * rigid bodies, and raycasts. This is useful for debugging
48
+ * physics-related issues and is very frequently used.
49
+ * For larger worlds, enabling this can cause performance
50
+ * issues, which will be noticed as dropped frame rates
51
+ * and higher RTT times.
52
+ */
53
+ world.simulation.enableDebug(true);
54
+
44
55
  /**
45
56
  * Load our map.
46
57
  * You can build your own map using https://build.hytopia.com
@@ -0,0 +1,53 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [HYTOPIA](./server.hytopia.md) &gt; [Simulation](./server.hytopia.simulation.md) &gt; [enableDebug](./server.hytopia.simulation.enabledebug.md)
4
+
5
+ ## HYTOPIA.Simulation.enableDebug() method
6
+
7
+ Enables or disables debug rendering for the simulation. When enabled, all colliders and rigid bodies will be rendered in the world. Do not enable this in production. In large worlds this can cause noticable lag and RTT spikes.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ enableDebug(enabled: boolean): void;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ <table><thead><tr><th>
18
+
19
+ Parameter
20
+
21
+
22
+ </th><th>
23
+
24
+ Type
25
+
26
+
27
+ </th><th>
28
+
29
+ Description
30
+
31
+
32
+ </th></tr></thead>
33
+ <tbody><tr><td>
34
+
35
+ enabled
36
+
37
+
38
+ </td><td>
39
+
40
+ boolean
41
+
42
+
43
+ </td><td>
44
+
45
+ Whether to enable debug rendering.
46
+
47
+
48
+ </td></tr>
49
+ </tbody></table>
50
+ **Returns:**
51
+
52
+ void
53
+
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [HYTOPIA](./server.hytopia.md) &gt; [Simulation](./server.hytopia.simulation.md) &gt; [isDebugEnabled](./server.hytopia.simulation.isdebugenabled.md)
4
+
5
+ ## HYTOPIA.Simulation.isDebugEnabled property
6
+
7
+ Whether the simulation has debug rendering enabled.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ get isDebugEnabled(): boolean;
13
+ ```
@@ -61,6 +61,27 @@ RAPIER.Vector3
61
61
  The gravity vector for the simulation.
62
62
 
63
63
 
64
+ </td></tr>
65
+ <tr><td>
66
+
67
+ [isDebugEnabled](./server.hytopia.simulation.isdebugenabled.md)
68
+
69
+
70
+ </td><td>
71
+
72
+ `readonly`
73
+
74
+
75
+ </td><td>
76
+
77
+ boolean
78
+
79
+
80
+ </td><td>
81
+
82
+ Whether the simulation has debug rendering enabled.
83
+
84
+
64
85
  </td></tr>
65
86
  <tr><td>
66
87
 
@@ -137,5 +158,19 @@ Description
137
158
  Casts a ray through the simulation.
138
159
 
139
160
 
161
+ </td></tr>
162
+ <tr><td>
163
+
164
+ [enableDebug(enabled)](./server.hytopia.simulation.enabledebug.md)
165
+
166
+
167
+ </td><td>
168
+
169
+
170
+ </td><td>
171
+
172
+ Enables or disables debug rendering for the simulation. When enabled, all colliders and rigid bodies will be rendered in the world. Do not enable this in production. In large worlds this can cause noticable lag and RTT spikes.
173
+
174
+
140
175
  </td></tr>
141
176
  </tbody></table>
@@ -0,0 +1,53 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [Simulation](./server.simulation.md) &gt; [enableDebug](./server.simulation.enabledebug.md)
4
+
5
+ ## Simulation.enableDebug() method
6
+
7
+ Enables or disables debug rendering for the simulation. When enabled, all colliders and rigid bodies will be rendered in the world. Do not enable this in production. In large worlds this can cause noticable lag and RTT spikes.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ enableDebug(enabled: boolean): void;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ <table><thead><tr><th>
18
+
19
+ Parameter
20
+
21
+
22
+ </th><th>
23
+
24
+ Type
25
+
26
+
27
+ </th><th>
28
+
29
+ Description
30
+
31
+
32
+ </th></tr></thead>
33
+ <tbody><tr><td>
34
+
35
+ enabled
36
+
37
+
38
+ </td><td>
39
+
40
+ boolean
41
+
42
+
43
+ </td><td>
44
+
45
+ Whether to enable debug rendering.
46
+
47
+
48
+ </td></tr>
49
+ </tbody></table>
50
+ **Returns:**
51
+
52
+ void
53
+
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [Simulation](./server.simulation.md) &gt; [isDebugEnabled](./server.simulation.isdebugenabled.md)
4
+
5
+ ## Simulation.isDebugEnabled property
6
+
7
+ Whether the simulation has debug rendering enabled.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ get isDebugEnabled(): boolean;
13
+ ```
@@ -61,6 +61,27 @@ RAPIER.Vector3
61
61
  The gravity vector for the simulation.
62
62
 
63
63
 
64
+ </td></tr>
65
+ <tr><td>
66
+
67
+ [isDebugEnabled](./server.simulation.isdebugenabled.md)
68
+
69
+
70
+ </td><td>
71
+
72
+ `readonly`
73
+
74
+
75
+ </td><td>
76
+
77
+ boolean
78
+
79
+
80
+ </td><td>
81
+
82
+ Whether the simulation has debug rendering enabled.
83
+
84
+
64
85
  </td></tr>
65
86
  <tr><td>
66
87
 
@@ -137,5 +158,19 @@ Description
137
158
  Casts a ray through the simulation.
138
159
 
139
160
 
161
+ </td></tr>
162
+ <tr><td>
163
+
164
+ [enableDebug(enabled)](./server.simulation.enabledebug.md)
165
+
166
+
167
+ </td><td>
168
+
169
+
170
+ </td><td>
171
+
172
+ Enables or disables debug rendering for the simulation. When enabled, all colliders and rigid bodies will be rendered in the world. Do not enable this in production. In large worlds this can cause noticable lag and RTT spikes.
173
+
174
+
140
175
  </td></tr>
141
176
  </tbody></table>
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "hytopia",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "The HYTOPIA SDK makes it easy for developers to create multiplayer games on the HYTOPIA platform using JavaScript or TypeScript.",
5
5
  "main": "server.js",
6
+ "bin": {
7
+ "hytopia": "bin/scripts.js"
8
+ },
6
9
  "directories": {
7
10
  "doc": "docs",
8
11
  "example": "examples"
9
12
  },
10
- "scripts": {
11
- "init": "cp -r boilerplate/* ."
12
- },
13
13
  "repository": {
14
14
  "type": "git",
15
15
  "url": "git+https://github.com/hytopiagg/sdk.git"
package/server.api.json CHANGED
@@ -28114,6 +28114,54 @@
28114
28114
  "isAbstract": false,
28115
28115
  "name": "castRay"
28116
28116
  },
28117
+ {
28118
+ "kind": "Method",
28119
+ "canonicalReference": "server!HYTOPIA.Simulation#enableDebug:member(1)",
28120
+ "docComment": "/**\n * Enables or disables debug rendering for the simulation. When enabled, all colliders and rigid bodies will be rendered in the world. Do not enable this in production. In large worlds this can cause noticable lag and RTT spikes.\n *\n * @param enabled - Whether to enable debug rendering.\n */\n",
28121
+ "excerptTokens": [
28122
+ {
28123
+ "kind": "Content",
28124
+ "text": "enableDebug(enabled: "
28125
+ },
28126
+ {
28127
+ "kind": "Content",
28128
+ "text": "boolean"
28129
+ },
28130
+ {
28131
+ "kind": "Content",
28132
+ "text": "): "
28133
+ },
28134
+ {
28135
+ "kind": "Content",
28136
+ "text": "void"
28137
+ },
28138
+ {
28139
+ "kind": "Content",
28140
+ "text": ";"
28141
+ }
28142
+ ],
28143
+ "isStatic": false,
28144
+ "returnTypeTokenRange": {
28145
+ "startIndex": 3,
28146
+ "endIndex": 4
28147
+ },
28148
+ "releaseTag": "Public",
28149
+ "isProtected": false,
28150
+ "overloadIndex": 1,
28151
+ "parameters": [
28152
+ {
28153
+ "parameterName": "enabled",
28154
+ "parameterTypeTokenRange": {
28155
+ "startIndex": 1,
28156
+ "endIndex": 2
28157
+ },
28158
+ "isOptional": false
28159
+ }
28160
+ ],
28161
+ "isOptional": false,
28162
+ "isAbstract": false,
28163
+ "name": "enableDebug"
28164
+ },
28117
28165
  {
28118
28166
  "kind": "Property",
28119
28167
  "canonicalReference": "server!HYTOPIA.Simulation#gravity:member",
@@ -28145,6 +28193,36 @@
28145
28193
  "isProtected": false,
28146
28194
  "isAbstract": false
28147
28195
  },
28196
+ {
28197
+ "kind": "Property",
28198
+ "canonicalReference": "server!HYTOPIA.Simulation#isDebugEnabled:member",
28199
+ "docComment": "/**\n * Whether the simulation has debug rendering enabled.\n */\n",
28200
+ "excerptTokens": [
28201
+ {
28202
+ "kind": "Content",
28203
+ "text": "get isDebugEnabled(): "
28204
+ },
28205
+ {
28206
+ "kind": "Content",
28207
+ "text": "boolean"
28208
+ },
28209
+ {
28210
+ "kind": "Content",
28211
+ "text": ";"
28212
+ }
28213
+ ],
28214
+ "isReadonly": true,
28215
+ "isOptional": false,
28216
+ "releaseTag": "Public",
28217
+ "name": "isDebugEnabled",
28218
+ "propertyTypeTokenRange": {
28219
+ "startIndex": 1,
28220
+ "endIndex": 2
28221
+ },
28222
+ "isStatic": false,
28223
+ "isProtected": false,
28224
+ "isAbstract": false
28225
+ },
28148
28226
  {
28149
28227
  "kind": "Property",
28150
28228
  "canonicalReference": "server!HYTOPIA.Simulation#timestepS:member",
@@ -34773,6 +34851,54 @@
34773
34851
  "isAbstract": false,
34774
34852
  "name": "castRay"
34775
34853
  },
34854
+ {
34855
+ "kind": "Method",
34856
+ "canonicalReference": "server!Simulation#enableDebug:member(1)",
34857
+ "docComment": "/**\n * Enables or disables debug rendering for the simulation. When enabled, all colliders and rigid bodies will be rendered in the world. Do not enable this in production. In large worlds this can cause noticable lag and RTT spikes.\n *\n * @param enabled - Whether to enable debug rendering.\n */\n",
34858
+ "excerptTokens": [
34859
+ {
34860
+ "kind": "Content",
34861
+ "text": "enableDebug(enabled: "
34862
+ },
34863
+ {
34864
+ "kind": "Content",
34865
+ "text": "boolean"
34866
+ },
34867
+ {
34868
+ "kind": "Content",
34869
+ "text": "): "
34870
+ },
34871
+ {
34872
+ "kind": "Content",
34873
+ "text": "void"
34874
+ },
34875
+ {
34876
+ "kind": "Content",
34877
+ "text": ";"
34878
+ }
34879
+ ],
34880
+ "isStatic": false,
34881
+ "returnTypeTokenRange": {
34882
+ "startIndex": 3,
34883
+ "endIndex": 4
34884
+ },
34885
+ "releaseTag": "Public",
34886
+ "isProtected": false,
34887
+ "overloadIndex": 1,
34888
+ "parameters": [
34889
+ {
34890
+ "parameterName": "enabled",
34891
+ "parameterTypeTokenRange": {
34892
+ "startIndex": 1,
34893
+ "endIndex": 2
34894
+ },
34895
+ "isOptional": false
34896
+ }
34897
+ ],
34898
+ "isOptional": false,
34899
+ "isAbstract": false,
34900
+ "name": "enableDebug"
34901
+ },
34776
34902
  {
34777
34903
  "kind": "Property",
34778
34904
  "canonicalReference": "server!Simulation#gravity:member",
@@ -34804,6 +34930,36 @@
34804
34930
  "isProtected": false,
34805
34931
  "isAbstract": false
34806
34932
  },
34933
+ {
34934
+ "kind": "Property",
34935
+ "canonicalReference": "server!Simulation#isDebugEnabled:member",
34936
+ "docComment": "/**\n * Whether the simulation has debug rendering enabled.\n */\n",
34937
+ "excerptTokens": [
34938
+ {
34939
+ "kind": "Content",
34940
+ "text": "get isDebugEnabled(): "
34941
+ },
34942
+ {
34943
+ "kind": "Content",
34944
+ "text": "boolean"
34945
+ },
34946
+ {
34947
+ "kind": "Content",
34948
+ "text": ";"
34949
+ }
34950
+ ],
34951
+ "isReadonly": true,
34952
+ "isOptional": false,
34953
+ "releaseTag": "Public",
34954
+ "name": "isDebugEnabled",
34955
+ "propertyTypeTokenRange": {
34956
+ "startIndex": 1,
34957
+ "endIndex": 2
34958
+ },
34959
+ "isStatic": false,
34960
+ "isProtected": false,
34961
+ "isAbstract": false
34962
+ },
34807
34963
  {
34808
34964
  "kind": "Property",
34809
34965
  "canonicalReference": "server!Simulation#timestepS:member",
package/server.d.ts CHANGED
@@ -2297,6 +2297,9 @@ export declare class Simulation {
2297
2297
 
2298
2298
 
2299
2299
 
2300
+
2301
+ /** Whether the simulation has debug rendering enabled. */
2302
+ get isDebugEnabled(): boolean;
2300
2303
  /** The gravity vector for the simulation. */
2301
2304
  get gravity(): RAPIER.Vector3;
2302
2305
  /** The fixed timestep for the simulation. */
@@ -2314,6 +2317,14 @@ export declare class Simulation {
2314
2317
  castRay(origin: RAPIER.Vector3, direction: RAPIER.Vector3, length: number, options?: RayCastOptions): Block | Entity | null;
2315
2318
 
2316
2319
 
2320
+ /**
2321
+ * Enables or disables debug rendering for the simulation.
2322
+ * When enabled, all colliders and rigid bodies will be rendered
2323
+ * in the world. Do not enable this in production. In large
2324
+ * worlds this can cause noticable lag and RTT spikes.
2325
+ * @param enabled - Whether to enable debug rendering.
2326
+ */
2327
+ enableDebug(enabled: boolean): void;
2317
2328
 
2318
2329
 
2319
2330