hytopia 0.1.4 → 0.1.8

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 CHANGED
@@ -2,17 +2,45 @@
2
2
 
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
- const command = process.argv[2];
5
+ const mkcert = require('mkcert');
6
6
 
7
- if (command === 'init') {
8
- const srcDir = path.join(__dirname, '..', 'boilerplate');
9
- const destDir = process.cwd();
7
+ (async () => {
8
+ const command = process.argv[2];
10
9
 
11
- fs.cpSync(srcDir, destDir, { recursive: true });
10
+ if (command === 'init') {
11
+ const srcDir = path.join(__dirname, '..', 'boilerplate');
12
+ const destDir = process.cwd();
13
+
14
+ // Copy boilerplate
15
+ console.log(`Copying boilerplate to ${destDir}`);
16
+ fs.cpSync(srcDir, destDir, { recursive: true });
17
+
18
+ // Generate SSL cert and allow mkcert to auto handle CA/Cert setup
19
+ console.log(`Generating SSL cert for local development...`);
20
+ const validity = 3650; // 10 years
21
+ const ca = await mkcert.createCA({
22
+ organization: 'HYTOPIA',
23
+ countryCode: 'US',
24
+ state: 'Washington',
25
+ locality: 'Seattle',
26
+ validity,
27
+ });
12
28
 
13
- console.log('🚀 Hytopia project initialized successfully!');
14
- console.log('💡 Start your development server with `bun --watch index.ts`!');
15
- return;
16
- }
29
+ const cert = await mkcert.createCert({
30
+ ca: { key: ca.key, cert: ca.cert },
31
+ domains: ['localhost', '127.0.0.1'],
32
+ validity,
33
+ });
34
+
35
+ fs.writeFileSync(path.join(destDir, 'assets', 'certs', 'localhost.crt'), cert.cert);
36
+ fs.writeFileSync(path.join(destDir, 'assets', 'certs', 'localhost.key'), cert.key);
37
+
38
+ // Done, lfg!
39
+ console.log('🚀 Hytopia project initialized successfully!');
40
+ console.log('💡 Start your development server with `bun --watch index.ts`!');
41
+ return;
42
+ }
43
+
44
+ console.log('Unknown command: ' + command);
45
+ })();
17
46
 
18
- console.log('Unknown command: ' + command);
@@ -0,0 +1,6 @@
1
+ For local development, mkcert generated certs will be stored here.
2
+ We do this to allow https://localhost & wss://localhost support.
3
+ Without this, play.hytopia.com requires a bunch of funky browser
4
+ flag workarounds in order to connect to our local server.
5
+ This is only used for local development and will be ignored
6
+ when your game is deployed to HYTOPIA servers.
@@ -41,6 +41,17 @@ import worldMap from './assets/map.json';
41
41
  */
42
42
 
43
43
  startServer(world => {
44
+ /**
45
+ * Enable debug rendering 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 in a development environment.
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.enableDebugRendering(true);
54
+
44
55
  /**
45
56
  * Load our map.
46
57
  * You can build your own map using https://build.hytopia.com
@@ -73,7 +84,7 @@ startServer(world => {
73
84
  world.chatManager.sendPlayerMessage(player, 'Use WASD to move around.');
74
85
  world.chatManager.sendPlayerMessage(player, 'Press space to jump.');
75
86
  world.chatManager.sendPlayerMessage(player, 'Hold shift to sprint.');
76
- world.chatManager.sendPlayerMessage(player, 'Type /rocket for a little surprise!');
87
+ world.chatManager.sendPlayerMessage(player, 'Press \\ to enter or exit debug view.');
77
88
  };
78
89
 
79
90
  /**
package/bun.lockb ADDED
Binary file
@@ -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; [enableDebugRendering](./server.hytopia.simulation.enabledebugrendering.md)
4
+
5
+ ## HYTOPIA.Simulation.enableDebugRendering() method
6
+
7
+ Enables or disables debug rendering for the simulation. When enabled, all colliders, rigid body and raycast outlines will be rendered in the world. Do not enable this in production. In large worlds enabling this can cause noticable lag and RTT spikes.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ enableDebugRendering(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; [isDebugRenderingEnabled](./server.hytopia.simulation.isdebugrenderingenabled.md)
4
+
5
+ ## HYTOPIA.Simulation.isDebugRenderingEnabled property
6
+
7
+ Whether the simulation has debug rendering enabled.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ get isDebugRenderingEnabled(): 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
+ [isDebugRenderingEnabled](./server.hytopia.simulation.isdebugrenderingenabled.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
+ [enableDebugRendering(enabled)](./server.hytopia.simulation.enabledebugrendering.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, rigid body and raycast outlines will be rendered in the world. Do not enable this in production. In large worlds enabling 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; [enableDebugRendering](./server.simulation.enabledebugrendering.md)
4
+
5
+ ## Simulation.enableDebugRendering() method
6
+
7
+ Enables or disables debug rendering for the simulation. When enabled, all colliders, rigid body and raycast outlines will be rendered in the world. Do not enable this in production. In large worlds enabling this can cause noticable lag and RTT spikes.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ enableDebugRendering(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; [isDebugRenderingEnabled](./server.simulation.isdebugrenderingenabled.md)
4
+
5
+ ## Simulation.isDebugRenderingEnabled property
6
+
7
+ Whether the simulation has debug rendering enabled.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ get isDebugRenderingEnabled(): 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
+ [isDebugRenderingEnabled](./server.simulation.isdebugrenderingenabled.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
+ [enableDebugRendering(enabled)](./server.simulation.enabledebugrendering.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, rigid body and raycast outlines will be rendered in the world. Do not enable this in production. In large worlds enabling this can cause noticable lag and RTT spikes.
173
+
174
+
140
175
  </td></tr>
141
176
  </tbody></table>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hytopia",
3
- "version": "0.1.4",
3
+ "version": "0.1.8",
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
6
  "bin": {
@@ -46,5 +46,8 @@
46
46
  "bugs": {
47
47
  "url": "https://github.com/hytopiagg/sdk/issues"
48
48
  },
49
- "homepage": "https://github.com/hytopiagg/sdk#readme"
49
+ "homepage": "https://github.com/hytopiagg/sdk#readme",
50
+ "devDependencies": {
51
+ "mkcert": "^3.2.0"
52
+ }
50
53
  }
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#enableDebugRendering:member(1)",
28120
+ "docComment": "/**\n * Enables or disables debug rendering for the simulation. When enabled, all colliders, rigid body and raycast outlines will be rendered in the world. Do not enable this in production. In large worlds enabling 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": "enableDebugRendering(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": "enableDebugRendering"
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#isDebugRenderingEnabled:member",
28199
+ "docComment": "/**\n * Whether the simulation has debug rendering enabled.\n */\n",
28200
+ "excerptTokens": [
28201
+ {
28202
+ "kind": "Content",
28203
+ "text": "get isDebugRenderingEnabled(): "
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": "isDebugRenderingEnabled",
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#enableDebugRendering:member(1)",
34857
+ "docComment": "/**\n * Enables or disables debug rendering for the simulation. When enabled, all colliders, rigid body and raycast outlines will be rendered in the world. Do not enable this in production. In large worlds enabling 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": "enableDebugRendering(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": "enableDebugRendering"
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#isDebugRenderingEnabled:member",
34936
+ "docComment": "/**\n * Whether the simulation has debug rendering enabled.\n */\n",
34937
+ "excerptTokens": [
34938
+ {
34939
+ "kind": "Content",
34940
+ "text": "get isDebugRenderingEnabled(): "
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": "isDebugRenderingEnabled",
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 isDebugRenderingEnabled(): 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, rigid body and raycast outlines
2323
+ * will be rendered in the world. Do not enable this in production.
2324
+ * In large worlds enabling this can cause noticable lag and RTT spikes.
2325
+ * @param enabled - Whether to enable debug rendering.
2326
+ */
2327
+ enableDebugRendering(enabled: boolean): void;
2317
2328
 
2318
2329
 
2319
2330