hytopia 0.5.4 → 0.5.5

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.
@@ -0,0 +1,65 @@
1
+ import {
2
+ startServer,
3
+ Entity,
4
+ PlayerEvent,
5
+ ModelRegistry,
6
+ } from 'hytopia';
7
+
8
+ import worldMap from './assets/map.json';
9
+
10
+ startServer(world => {
11
+ world.loadMap(worldMap);
12
+
13
+ const animatedEntity = new Entity({
14
+ name: 'Entity',
15
+ modelUri: 'models/players/player.gltf', // Change the model here for testing different models
16
+ modelScale: 0.5, // Change the scale here relative to your neeeds.
17
+ })
18
+
19
+ animatedEntity.spawn(world, { x: 0, y: 10, z: 0 });
20
+
21
+
22
+ world.on(PlayerEvent.JOINED_WORLD, ({ player }) => {
23
+ // focus the camera on the animated entity.
24
+ player.camera.setAttachedToEntity(animatedEntity);
25
+
26
+ world.chatManager.sendPlayerMessage(player, 'Commands:');
27
+ world.chatManager.sendPlayerMessage(player, '/list - Show animations');
28
+ world.chatManager.sendPlayerMessage(player, '/loop <name> - Start looped animation');
29
+ world.chatManager.sendPlayerMessage(player, '/oneshot <name> - Start one-shot animation');
30
+ world.chatManager.sendPlayerMessage(player, '/stop <name> - Stop animation');
31
+ world.chatManager.sendPlayerMessage(player, '/stopall - Stop all animations');
32
+ });
33
+
34
+ world.on(PlayerEvent.LEFT_WORLD, ({ player }) => {
35
+ // Nothing to do, since we aren't spawning any player specific entities, etc.
36
+ });
37
+
38
+ world.chatManager.registerCommand('/list', player => {
39
+ const animationNames = ModelRegistry.instance.getAnimationNames(animatedEntity.modelUri!).join(', ');
40
+
41
+ world.chatManager.sendPlayerMessage(player, `Available animations: ${animationNames}`);
42
+ });
43
+
44
+ world.chatManager.registerCommand('/loop', (player, args) => {
45
+ world.chatManager.sendBroadcastMessage(`Looping ${args.join(' ')}`, '00FF00');
46
+ animatedEntity.startModelLoopedAnimations(args);
47
+ });
48
+
49
+ world.chatManager.registerCommand('/oneshot', (player, args) => {
50
+ world.chatManager.sendBroadcastMessage(`Oneshotting ${args.join(' ')}`, '00FF00');
51
+ animatedEntity.startModelOneshotAnimations(args);
52
+ });
53
+
54
+ world.chatManager.registerCommand('/stop', (player, args) => {
55
+ world.chatManager.sendBroadcastMessage(`Stopped ${args.join(' ')}`, '00FF00');
56
+ animatedEntity.stopModelAnimations(args);
57
+ });
58
+
59
+ world.chatManager.registerCommand('/stopall', player => {
60
+ world.chatManager.sendBroadcastMessage(`Stopped all animations`, '00FF00');
61
+ const animationNames = ModelRegistry.instance.getAnimationNames(animatedEntity.modelUri!)
62
+
63
+ animatedEntity.stopModelAnimations(animationNames);
64
+ });
65
+ });
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "entity-animations",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "dependencies": {
13
+ "@hytopia.com/assets": "latest",
14
+ "hytopia": "latest"
15
+ },
16
+ "trustedDependencies": [
17
+ "mediasoup",
18
+ "sharp"
19
+ ]
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hytopia",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.",
5
5
  "main": "server.js",
6
6
  "bin": {
package/server.api.json CHANGED
@@ -25288,6 +25288,54 @@
25288
25288
  "name": "ModelRegistry",
25289
25289
  "preserveMemberOrder": false,
25290
25290
  "members": [
25291
+ {
25292
+ "kind": "Method",
25293
+ "canonicalReference": "server!ModelRegistry#getAnimationNames:member(1)",
25294
+ "docComment": "/**\n * Retrieves an array of all known animation names for a model.\n *\n * @param modelUri - The URI of the model to retrieve the animation names for.\n *\n * @returns An array of all known animation names for the model.\n */\n",
25295
+ "excerptTokens": [
25296
+ {
25297
+ "kind": "Content",
25298
+ "text": "getAnimationNames(modelUri: "
25299
+ },
25300
+ {
25301
+ "kind": "Content",
25302
+ "text": "string"
25303
+ },
25304
+ {
25305
+ "kind": "Content",
25306
+ "text": "): "
25307
+ },
25308
+ {
25309
+ "kind": "Content",
25310
+ "text": "string[]"
25311
+ },
25312
+ {
25313
+ "kind": "Content",
25314
+ "text": ";"
25315
+ }
25316
+ ],
25317
+ "isStatic": false,
25318
+ "returnTypeTokenRange": {
25319
+ "startIndex": 3,
25320
+ "endIndex": 4
25321
+ },
25322
+ "releaseTag": "Public",
25323
+ "isProtected": false,
25324
+ "overloadIndex": 1,
25325
+ "parameters": [
25326
+ {
25327
+ "parameterName": "modelUri",
25328
+ "parameterTypeTokenRange": {
25329
+ "startIndex": 1,
25330
+ "endIndex": 2
25331
+ },
25332
+ "isOptional": false
25333
+ }
25334
+ ],
25335
+ "isOptional": false,
25336
+ "isAbstract": false,
25337
+ "name": "getAnimationNames"
25338
+ },
25291
25339
  {
25292
25340
  "kind": "Method",
25293
25341
  "canonicalReference": "server!ModelRegistry#getBoundingBox:member(1)",
package/server.d.ts CHANGED
@@ -3203,6 +3203,13 @@ export declare class ModelRegistry {
3203
3203
 
3204
3204
 
3205
3205
 
3206
+ /**
3207
+ * Retrieves an array of all known animation names for a model.
3208
+ *
3209
+ * @param modelUri - The URI of the model to retrieve the animation names for.
3210
+ * @returns An array of all known animation names for the model.
3211
+ */
3212
+ getAnimationNames(modelUri: string): string[];
3206
3213
  /**
3207
3214
  * Retrieves the bounding box of a model.
3208
3215
  *