@hytopia.com/server-protocol 1.3.34 → 1.3.36

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hytopia.com/server-protocol",
3
- "version": "1.3.34",
3
+ "version": "1.3.36",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -38,6 +38,7 @@ export enum PacketId {
38
38
  UI = 41,
39
39
  UI_DATAS = 42,
40
40
  SCENE_UIS = 43,
41
+ LIGHTS = 44,
41
42
 
42
43
  // Debug Inbound Packet Types: 128 - 191 range
43
44
  DEBUG_CONFIG = 128,
@@ -0,0 +1,12 @@
1
+ import { definePacket, PacketId } from '../PacketCore';
2
+ import type { IPacket } from '../PacketCore';
3
+ import { lightsSchema } from '../../schemas/Lights';
4
+ import type { LightsSchema } from '../../schemas/Lights';
5
+ import type { WorldTick } from '../PacketCore';
6
+
7
+ export type LightsPacket = IPacket<typeof PacketId.LIGHTS, LightsSchema> & [WorldTick];
8
+
9
+ export const lightsPacketDefinition = definePacket(
10
+ PacketId.LIGHTS,
11
+ lightsSchema,
12
+ );
@@ -5,6 +5,7 @@ export * from './Camera';
5
5
  export * from './ChatMessages';
6
6
  export * from './Chunks';
7
7
  export * from './Entities';
8
+ export * from './Lights';
8
9
  export * from './PhysicsDebugRender';
9
10
  export * from './PhysicsDebugRaycasts';
10
11
  export * from './SceneUIs';
@@ -0,0 +1,38 @@
1
+ import { vectorSchema } from './Vector';
2
+ import { rgbColorSchema } from './RgbColor';
3
+ import type { JSONSchemaType } from 'ajv';
4
+ import type { RgbColorSchema } from './RgbColor';
5
+ import type { VectorSchema } from './Vector';
6
+
7
+ export type LightSchema = {
8
+ i: number; // light id
9
+ a?: number; // if spotlight, angle in radians
10
+ e?: number; // entity attachment, follows entity id
11
+ c?: RgbColorSchema; // light color
12
+ d?: number; // maximum distance of the light
13
+ n?: number; // light intensity
14
+ o?: VectorSchema; // offset
15
+ p?: VectorSchema; // spatial position of the light
16
+ te?: number; // if spotlight, tracked entity id
17
+ tp?: VectorSchema; // if spotlight, tracked position
18
+ t?: string; // light template id
19
+ }
20
+
21
+ export const lightSchema: JSONSchemaType<LightSchema> = {
22
+ type: 'object',
23
+ properties: {
24
+ i: { type: 'number' },
25
+ a: { type: 'number', nullable: true },
26
+ e: { type: 'number', nullable: true },
27
+ c: { ...rgbColorSchema, nullable: true },
28
+ d: { type: 'number', nullable: true },
29
+ n: { type: 'number', nullable: true },
30
+ o: { ...vectorSchema, nullable: true },
31
+ p: { ...vectorSchema, nullable: true },
32
+ te: { type: 'number', nullable: true },
33
+ tp: { ...vectorSchema, nullable: true },
34
+ t: { type: 'string', nullable: true },
35
+ },
36
+ required: ['i'],
37
+ additionalProperties: false,
38
+ }
@@ -0,0 +1,10 @@
1
+ import { lightSchema } from './Light';
2
+ import type { JSONSchemaType } from 'ajv';
3
+ import type { LightSchema } from './Light';
4
+
5
+ export type LightsSchema = LightSchema[];
6
+
7
+ export const lightsSchema: JSONSchemaType<LightsSchema> = {
8
+ type: 'array',
9
+ items: { ...lightSchema },
10
+ }
package/schemas/World.ts CHANGED
@@ -1,17 +1,31 @@
1
+ import { rgbColorSchema } from './RgbColor';
2
+ import { vectorSchema } from './Vector';
1
3
  import type { JSONSchemaType } from 'ajv';
4
+ import type { RgbColorSchema } from './RgbColor';
5
+ import type { VectorSchema } from './Vector';
2
6
 
3
7
  export type WorldSchema = {
4
- i: number; // id
5
- f?: boolean; // focused
6
- n?: string; // name
7
- s?: string; // skyboxUri
8
- t?: number; // timestep (seconds)
8
+ i: number; // id
9
+ ac?: RgbColorSchema; // ambient light color
10
+ ai?: number; // ambient light intensity
11
+ dc?: RgbColorSchema; // directional light color
12
+ di?: number; // directional light intensity
13
+ dp?: VectorSchema; // directional light position
14
+ f?: boolean; // focused
15
+ n?: string; // name
16
+ s?: string; // skyboxUri
17
+ t?: number; // timestep (seconds)
9
18
  };
10
19
 
11
20
  export const worldSchema: JSONSchemaType<WorldSchema> = {
12
21
  type: 'object',
13
22
  properties: {
14
23
  i: { type: 'number' },
24
+ ac: { ...rgbColorSchema, nullable: true },
25
+ ai: { type: 'number', nullable: true },
26
+ dc: { ...rgbColorSchema, nullable: true },
27
+ di: { type: 'number', nullable: true },
28
+ dp: { ...vectorSchema, nullable: true },
15
29
  f: { type: 'boolean', nullable: true },
16
30
  n: { type: 'string', nullable: true },
17
31
  s: { type: 'string', nullable: true },
package/schemas/index.ts CHANGED
@@ -14,6 +14,8 @@ export * from './Entity';
14
14
  export * from './Entities';
15
15
  export * from './HexColor';
16
16
  export * from './Input';
17
+ export * from './Light';
18
+ export * from './Lights';
17
19
  export * from './PhysicsDebugRaycast';
18
20
  export * from './PhysicsDebugRaycasts';
19
21
  export * from './PhysicsDebugRender';