@hytopia.com/server-protocol 1.0.71 → 1.1.0
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 +1 -1
- package/packets/PacketCore.ts +12 -11
- package/packets/inbound/index.ts +0 -1
- package/packets/outbound/BlockBatch.ts +12 -0
- package/packets/outbound/BlockTypeBatch.ts +12 -0
- package/packets/outbound/ChunkBatch.ts +12 -0
- package/packets/outbound/EntityBatch.ts +12 -0
- package/packets/outbound/index.ts +5 -3
- package/schemas/Block.ts +1 -3
- package/schemas/BlockBatch.ts +10 -0
- package/schemas/BlockType.ts +1 -7
- package/schemas/BlockTypeBatch.ts +10 -0
- package/schemas/Chunk.ts +1 -3
- package/schemas/ChunkBatch.ts +10 -0
- package/schemas/DebugConfig.ts +1 -1
- package/schemas/Entity.ts +23 -22
- package/schemas/EntityBatch.ts +10 -0
- package/schemas/HexColor.ts +1 -1
- package/schemas/Input.ts +1 -1
- package/schemas/PhysicsDebugRender.ts +2 -4
- package/schemas/StateRequest.ts +1 -1
- package/schemas/VectorBoolean.ts +1 -1
- package/schemas/World.ts +1 -1
- package/schemas/index.ts +5 -6
- package/packets/outbound/BlockTypeRegistry.ts +0 -12
- package/packets/outbound/Simulation.ts +0 -12
- package/schemas/BlockTypeRegistry.ts +0 -21
- package/schemas/Collider.ts +0 -21
- package/schemas/ColliderDesc.ts +0 -47
- package/schemas/RigidBody.ts +0 -74
- package/schemas/Shape.ts +0 -23
- package/schemas/Simulation.ts +0 -20
package/package.json
CHANGED
package/packets/PacketCore.ts
CHANGED
|
@@ -20,24 +20,25 @@ import type { JSONSchemaType, ValidateFunction } from 'ajv';
|
|
|
20
20
|
export enum PacketId {
|
|
21
21
|
// Standard Inbound Packet Types: 0 - 31 range
|
|
22
22
|
SYNC_REQUEST = 0,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
CHAT_MESSAGE_SEND = 4,
|
|
23
|
+
INPUT = 1,
|
|
24
|
+
STATE_REQUEST = 2,
|
|
25
|
+
CHAT_MESSAGE_SEND = 3,
|
|
27
26
|
|
|
28
27
|
// Standard Outbound Packet Types: 32 - 127 range
|
|
29
28
|
SYNC_RESPONSE = 32,
|
|
30
29
|
BLOCK = 33,
|
|
31
|
-
|
|
30
|
+
BLOCK_BATCH = 34,
|
|
32
31
|
BLOCK_TYPE = 35,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
BLOCK_TYPE_BATCH = 36,
|
|
33
|
+
CHUNK = 37,
|
|
34
|
+
CHUNK_BATCH = 38,
|
|
35
|
+
ENTITY = 39,
|
|
36
|
+
ENTITY_BATCH = 40,
|
|
37
|
+
WORLD = 41,
|
|
38
|
+
CHAT_MESSAGE = 42,
|
|
38
39
|
|
|
39
40
|
// Debug Inbound Packet Types: 128 - 191 range
|
|
40
|
-
|
|
41
|
+
DEBUG_CONFIG = 128,
|
|
41
42
|
|
|
42
43
|
// Debug Outbound Packet Types: 192 - 255 range
|
|
43
44
|
PHYSICS_DEBUG_RENDER = 192
|
package/packets/inbound/index.ts
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { definePacket, PacketId } from '../PacketCore';
|
|
2
|
+
import type { IPacket } from '../PacketCore';
|
|
3
|
+
import { blockBatchSchema } from '../../schemas/BlockBatch';
|
|
4
|
+
import type { BlockBatchSchema } from '../../schemas/BlockBatch';
|
|
5
|
+
import type { WorldTick } from '../PacketCore';
|
|
6
|
+
|
|
7
|
+
export type BlockBatchPacket = IPacket<typeof PacketId.BLOCK_BATCH, BlockBatchSchema> & [WorldTick];
|
|
8
|
+
|
|
9
|
+
export const blockBatchPacketDefinition = definePacket(
|
|
10
|
+
PacketId.BLOCK_BATCH,
|
|
11
|
+
blockBatchSchema,
|
|
12
|
+
);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { definePacket, PacketId } from '../PacketCore';
|
|
2
|
+
import type { IPacket } from '../PacketCore';
|
|
3
|
+
import { blockTypeBatchSchema } from '../../schemas/BlockTypeBatch';
|
|
4
|
+
import type { BlockTypeBatchSchema } from '../../schemas/BlockTypeBatch';
|
|
5
|
+
import type { WorldTick } from '../PacketCore';
|
|
6
|
+
|
|
7
|
+
export type BlockTypeBatchPacket = IPacket<typeof PacketId.BLOCK_TYPE_BATCH, BlockTypeBatchSchema> & [WorldTick];
|
|
8
|
+
|
|
9
|
+
export const blockTypeBatchPacketDefinition = definePacket(
|
|
10
|
+
PacketId.BLOCK_TYPE_BATCH,
|
|
11
|
+
blockTypeBatchSchema,
|
|
12
|
+
);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { definePacket, PacketId } from '../PacketCore';
|
|
2
|
+
import type { IPacket } from '../PacketCore';
|
|
3
|
+
import { chunkBatchSchema } from '../../schemas/ChunkBatch';
|
|
4
|
+
import type { ChunkBatchSchema } from '../../schemas/ChunkBatch';
|
|
5
|
+
import type { WorldTick } from '../PacketCore';
|
|
6
|
+
|
|
7
|
+
export type ChunkBatchPacket = IPacket<typeof PacketId.CHUNK_BATCH, ChunkBatchSchema> & [WorldTick];
|
|
8
|
+
|
|
9
|
+
export const chunkBatchPacketDefinition = definePacket(
|
|
10
|
+
PacketId.CHUNK_BATCH,
|
|
11
|
+
chunkBatchSchema,
|
|
12
|
+
);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { definePacket, PacketId } from '../PacketCore';
|
|
2
|
+
import type { IPacket } from '../PacketCore';
|
|
3
|
+
import { entityBatchSchema } from '../../schemas/EntityBatch';
|
|
4
|
+
import type { EntityBatchSchema } from '../../schemas/EntityBatch';
|
|
5
|
+
import type { WorldTick } from '../PacketCore';
|
|
6
|
+
|
|
7
|
+
export type EntityBatchPacket = IPacket<typeof PacketId.ENTITY_BATCH, EntityBatchSchema> & [WorldTick];
|
|
8
|
+
|
|
9
|
+
export const entityBatchPacketDefinition = definePacket(
|
|
10
|
+
PacketId.ENTITY_BATCH,
|
|
11
|
+
entityBatchSchema,
|
|
12
|
+
);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export * from './Block';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './BlockBatch';
|
|
3
3
|
export * from './BlockType';
|
|
4
|
+
export * from './BlockTypeBatch';
|
|
4
5
|
export * from './ChatMessage';
|
|
5
6
|
export * from './Chunk';
|
|
7
|
+
export * from './ChunkBatch';
|
|
6
8
|
export * from './Entity';
|
|
9
|
+
export * from './EntityBatch';
|
|
7
10
|
export * from './PhysicsDebugRender';
|
|
8
|
-
export * from './Simulation';
|
|
9
11
|
export * from './SyncResponse';
|
|
10
|
-
export * from './World';
|
|
12
|
+
export * from './World';
|
package/schemas/Block.ts
CHANGED
|
@@ -3,7 +3,6 @@ import type { JSONSchemaType } from 'ajv';
|
|
|
3
3
|
import type { VectorSchema } from './Vector';
|
|
4
4
|
|
|
5
5
|
export type BlockSchema = {
|
|
6
|
-
wi: number; // world id
|
|
7
6
|
i: number; // block id
|
|
8
7
|
c: VectorSchema; // coordinate
|
|
9
8
|
};
|
|
@@ -11,10 +10,9 @@ export type BlockSchema = {
|
|
|
11
10
|
export const blockSchema: JSONSchemaType<BlockSchema> = {
|
|
12
11
|
type: 'object',
|
|
13
12
|
properties: {
|
|
14
|
-
wi: { type: 'number' },
|
|
15
13
|
i: { type: 'number' },
|
|
16
14
|
c: vectorSchema,
|
|
17
15
|
},
|
|
18
|
-
required: [ '
|
|
16
|
+
required: [ 'i', 'c' ],
|
|
19
17
|
additionalProperties: false,
|
|
20
18
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { blockSchema } from './Block';
|
|
2
|
+
import type { JSONSchemaType } from 'ajv';
|
|
3
|
+
import type { BlockSchema } from './Block';
|
|
4
|
+
|
|
5
|
+
export type BlockBatchSchema = BlockSchema[];
|
|
6
|
+
|
|
7
|
+
export const blockBatchSchema: JSONSchemaType<BlockBatchSchema> = {
|
|
8
|
+
type: 'array',
|
|
9
|
+
items: { ...blockSchema },
|
|
10
|
+
}
|
package/schemas/BlockType.ts
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
import { colliderDescSchema } from './ColliderDesc';
|
|
2
1
|
import type { JSONSchemaType } from 'ajv';
|
|
3
|
-
import type { ColliderDescSchema } from './ColliderDesc';
|
|
4
2
|
|
|
5
3
|
export type BlockTypeSchema = {
|
|
6
|
-
wi: number; // world id
|
|
7
4
|
i: number; // block type id
|
|
8
5
|
t?: string; // textureUri
|
|
9
6
|
n?: string; // name
|
|
10
|
-
c?: ColliderDescSchema; // collider desc
|
|
11
7
|
s?: boolean; // is solid
|
|
12
8
|
}
|
|
13
9
|
|
|
14
10
|
export const blockTypeSchema: JSONSchemaType<BlockTypeSchema> = {
|
|
15
11
|
type: 'object',
|
|
16
12
|
properties: {
|
|
17
|
-
wi: { type: 'number' },
|
|
18
13
|
i: { type: 'number' },
|
|
19
14
|
t: { type: 'string', nullable: true },
|
|
20
15
|
n: { type: 'string', nullable: true },
|
|
21
|
-
c: { ...colliderDescSchema, nullable: true },
|
|
22
16
|
s: { type: 'boolean', nullable: true },
|
|
23
17
|
},
|
|
24
|
-
required: [ '
|
|
18
|
+
required: [ 'i' ],
|
|
25
19
|
additionalProperties: false,
|
|
26
20
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { blockTypeSchema } from './BlockType';
|
|
2
|
+
import type { JSONSchemaType } from 'ajv';
|
|
3
|
+
import type { BlockTypeSchema } from './BlockType';
|
|
4
|
+
|
|
5
|
+
export type BlockTypeBatchSchema = BlockTypeSchema[];
|
|
6
|
+
|
|
7
|
+
export const blockTypeBatchSchema: JSONSchemaType<BlockTypeBatchSchema> = {
|
|
8
|
+
type: 'array',
|
|
9
|
+
items: { ...blockTypeSchema },
|
|
10
|
+
}
|
package/schemas/Chunk.ts
CHANGED
|
@@ -3,7 +3,6 @@ import type { JSONSchemaType } from 'ajv';
|
|
|
3
3
|
import type { VectorSchema } from './Vector';
|
|
4
4
|
|
|
5
5
|
export type ChunkSchema = {
|
|
6
|
-
wi: number; // world id
|
|
7
6
|
c: VectorSchema; // chunk coordinate [ 16n, 16n, 16n ]
|
|
8
7
|
b: Uint8Array | number[]; // block ids in chunk, 16^3 entries, registry block ids 1-255, 0 = none
|
|
9
8
|
};
|
|
@@ -11,7 +10,6 @@ export type ChunkSchema = {
|
|
|
11
10
|
export const chunkSchema: JSONSchemaType<ChunkSchema> = {
|
|
12
11
|
type: 'object',
|
|
13
12
|
properties: {
|
|
14
|
-
wi: { type: 'number' },
|
|
15
13
|
c: vectorSchema,
|
|
16
14
|
b: {
|
|
17
15
|
type: 'array',
|
|
@@ -24,6 +22,6 @@ export const chunkSchema: JSONSchemaType<ChunkSchema> = {
|
|
|
24
22
|
maxItems: 4096
|
|
25
23
|
}
|
|
26
24
|
},
|
|
27
|
-
required: [ '
|
|
25
|
+
required: [ 'c', 'b' ],
|
|
28
26
|
additionalProperties: false,
|
|
29
27
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { chunkSchema } from './Chunk';
|
|
2
|
+
import type { JSONSchemaType } from 'ajv';
|
|
3
|
+
import type { ChunkSchema } from './Chunk';
|
|
4
|
+
|
|
5
|
+
export type ChunkBatchSchema = ChunkSchema[];
|
|
6
|
+
|
|
7
|
+
export const chunkBatchSchema: JSONSchemaType<ChunkBatchSchema> = {
|
|
8
|
+
type: 'array',
|
|
9
|
+
items: { ...chunkSchema },
|
|
10
|
+
}
|
package/schemas/DebugConfig.ts
CHANGED
package/schemas/Entity.ts
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { quaternionSchema } from './Quaternion';
|
|
2
|
+
import { vectorSchema } from './Vector';
|
|
2
3
|
import type { JSONSchemaType } from 'ajv';
|
|
3
|
-
import type {
|
|
4
|
+
import type { QuaternionSchema } from './Quaternion';
|
|
5
|
+
import type { VectorSchema } from './Vector';
|
|
6
|
+
|
|
4
7
|
|
|
5
8
|
export type EntitySchema = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
t?: string; // texture uri
|
|
9
|
+
i: number; // entity id
|
|
10
|
+
f?: boolean; // focused
|
|
11
|
+
m?: string; // model uri
|
|
12
|
+
al?: string[]; // animations looped
|
|
13
|
+
ao?: string[]; // animations one shot
|
|
14
|
+
as?: string[]; // animations stop
|
|
15
|
+
n?: string; // name
|
|
16
|
+
p?: VectorSchema; // position
|
|
17
|
+
r?: QuaternionSchema; // rotation
|
|
18
|
+
rm?: boolean; // removed/remove
|
|
19
|
+
s?: VectorSchema; // scale
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
export const entitySchema: JSONSchemaType<EntitySchema> = {
|
|
21
23
|
type: 'object',
|
|
22
24
|
properties: {
|
|
23
|
-
wi: { type: 'number' },
|
|
24
25
|
i: { type: 'number' },
|
|
25
26
|
f: { type: 'boolean', nullable: true },
|
|
26
|
-
fs: { type: 'boolean', nullable: true },
|
|
27
27
|
m: { type: 'string', nullable: true },
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
al: { type: 'array', items: { type: 'string' }, nullable: true },
|
|
29
|
+
ao: { type: 'array', items: { type: 'string' }, nullable: true },
|
|
30
|
+
as: { type: 'array', items: { type: 'string' }, nullable: true },
|
|
31
31
|
n: { type: 'string', nullable: true },
|
|
32
|
-
|
|
32
|
+
p: { ...vectorSchema, nullable: true },
|
|
33
|
+
r: { ...quaternionSchema, nullable: true },
|
|
33
34
|
rm: { type: 'boolean', nullable: true },
|
|
34
|
-
|
|
35
|
+
s: { ...vectorSchema, nullable: true },
|
|
35
36
|
},
|
|
36
|
-
required: [ '
|
|
37
|
+
required: [ 'i' ],
|
|
37
38
|
additionalProperties: false,
|
|
38
39
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { entitySchema } from './Entity';
|
|
2
|
+
import type { JSONSchemaType } from 'ajv';
|
|
3
|
+
import type { EntitySchema } from './Entity';
|
|
4
|
+
|
|
5
|
+
export type EntityBatchSchema = EntitySchema[];
|
|
6
|
+
|
|
7
|
+
export const entityBatchSchema: JSONSchemaType<EntityBatchSchema> = {
|
|
8
|
+
type: 'array',
|
|
9
|
+
items: { ...entitySchema },
|
|
10
|
+
}
|
package/schemas/HexColor.ts
CHANGED
package/schemas/Input.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { JSONSchemaType } from 'ajv';
|
|
1
|
+
import type { JSONSchemaType } from 'ajv';
|
|
2
2
|
|
|
3
3
|
export type PhysicsDebugRenderSchema = {
|
|
4
|
-
wi: number; // world id
|
|
5
4
|
v: number[]; // rapier debug render vertices
|
|
6
5
|
c: number[]; // rapier debug render colors
|
|
7
6
|
}
|
|
@@ -9,10 +8,9 @@ export type PhysicsDebugRenderSchema = {
|
|
|
9
8
|
export const physicsDebugRenderSchema: JSONSchemaType<PhysicsDebugRenderSchema> = {
|
|
10
9
|
type: 'object',
|
|
11
10
|
properties: {
|
|
12
|
-
wi: { type: 'number' },
|
|
13
11
|
v: { type: 'array', items: { type: 'number' } },
|
|
14
12
|
c: { type: 'array', items: { type: 'number' } },
|
|
15
13
|
},
|
|
16
|
-
required: [ '
|
|
14
|
+
required: [ 'v', 'c' ],
|
|
17
15
|
additionalProperties: false,
|
|
18
16
|
}
|
package/schemas/StateRequest.ts
CHANGED
package/schemas/VectorBoolean.ts
CHANGED
package/schemas/World.ts
CHANGED
package/schemas/index.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
export * from './Block';
|
|
2
|
-
export * from './BlockTypeRegistry';
|
|
3
2
|
export * from './BlockType';
|
|
3
|
+
export * from './BlockTypeBatch';
|
|
4
4
|
export * from './ChatMessage';
|
|
5
5
|
export * from './Chunk';
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
6
|
+
export * from './ChunkBatch';
|
|
7
|
+
export * from './DebugConfig';
|
|
8
8
|
export * from './Entity';
|
|
9
|
+
export * from './EntityBatch';
|
|
10
|
+
export * from './HexColor';
|
|
9
11
|
export * from './Input';
|
|
10
12
|
export * from './PhysicsDebugRender';
|
|
11
13
|
export * from './Quaternion';
|
|
12
|
-
export * from './RigidBody';
|
|
13
|
-
export * from './Shape';
|
|
14
|
-
export * from './Simulation';
|
|
15
14
|
export * from './StateRequest';
|
|
16
15
|
export * from './SyncRequest';
|
|
17
16
|
export * from './SyncResponse';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { definePacket, PacketId } from '../PacketCore';
|
|
2
|
-
import type { IPacket } from '../PacketCore';
|
|
3
|
-
import { blockTypeRegistrySchema } from '../../schemas/BlockTypeRegistry';
|
|
4
|
-
import type { BlockTypeRegistrySchema } from '../../schemas/BlockTypeRegistry';
|
|
5
|
-
import type { WorldTick } from '../PacketCore';
|
|
6
|
-
|
|
7
|
-
export type BlockTypeRegistryPacket = IPacket<typeof PacketId.BLOCK_TYPE_REGISTRY, BlockTypeRegistrySchema> & [WorldTick];
|
|
8
|
-
|
|
9
|
-
export const blockTypeRegistryPacketDefinition = definePacket(
|
|
10
|
-
PacketId.BLOCK_TYPE_REGISTRY,
|
|
11
|
-
blockTypeRegistrySchema,
|
|
12
|
-
);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { definePacket, PacketId } from '../PacketCore';
|
|
2
|
-
import type { IPacket } from '../PacketCore';
|
|
3
|
-
import { simulationSchema } from '../../schemas/Simulation';
|
|
4
|
-
import type { SimulationSchema } from '../../schemas/Simulation';
|
|
5
|
-
import type { WorldTick } from '../PacketCore';
|
|
6
|
-
|
|
7
|
-
export type SimulationPacket = IPacket<typeof PacketId.SIMULATION, SimulationSchema> & [WorldTick];
|
|
8
|
-
|
|
9
|
-
export const simulationPacketDefinition = definePacket(
|
|
10
|
-
PacketId.SIMULATION,
|
|
11
|
-
simulationSchema,
|
|
12
|
-
);
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { blockTypeSchema } from './BlockType';
|
|
2
|
-
import type { JSONSchemaType } from 'ajv';
|
|
3
|
-
import type { BlockTypeSchema } from './BlockType';
|
|
4
|
-
|
|
5
|
-
export type BlockTypeRegistrySchema = {
|
|
6
|
-
wi: number; // world id
|
|
7
|
-
b: BlockTypeSchema[]; // block types
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const blockTypeRegistrySchema: JSONSchemaType<BlockTypeRegistrySchema> = {
|
|
11
|
-
type: 'object',
|
|
12
|
-
properties: {
|
|
13
|
-
wi: { type: 'number' },
|
|
14
|
-
b: {
|
|
15
|
-
type: 'array',
|
|
16
|
-
items: blockTypeSchema,
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
required: [ 'wi', 'b' ],
|
|
20
|
-
additionalProperties: false,
|
|
21
|
-
}
|
package/schemas/Collider.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { colliderDescSchema } from './ColliderDesc';
|
|
2
|
-
import type { JSONSchemaType } from 'ajv';
|
|
3
|
-
import type { ColliderDescSchema } from './ColliderDesc';
|
|
4
|
-
|
|
5
|
-
export type ColliderSchema = {
|
|
6
|
-
i: number; // id
|
|
7
|
-
fs?: boolean; // full state
|
|
8
|
-
rm?: boolean; // removed/remove
|
|
9
|
-
} & ColliderDescSchema;
|
|
10
|
-
|
|
11
|
-
export const colliderSchema: JSONSchemaType<ColliderSchema> = {
|
|
12
|
-
type: 'object',
|
|
13
|
-
properties: {
|
|
14
|
-
i: { type: 'number', nullable: true },
|
|
15
|
-
fs: { type: 'boolean', nullable: true },
|
|
16
|
-
rm: { type: 'boolean', nullable: true },
|
|
17
|
-
...colliderDescSchema.properties
|
|
18
|
-
},
|
|
19
|
-
required: [ 'i' ],
|
|
20
|
-
additionalProperties: false,
|
|
21
|
-
}
|
package/schemas/ColliderDesc.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { shapeSchema } from './Shape';
|
|
2
|
-
import { quaternionSchema } from './Quaternion';
|
|
3
|
-
import { vectorSchema } from './Vector';
|
|
4
|
-
import type { JSONSchemaType } from 'ajv';
|
|
5
|
-
import type { ShapeSchema } from './Shape';
|
|
6
|
-
import type { QuaternionSchema } from './Quaternion';
|
|
7
|
-
import type { VectorSchema } from './Vector';
|
|
8
|
-
|
|
9
|
-
export type ColliderDescSchema = {
|
|
10
|
-
at?: number; // active collision types
|
|
11
|
-
cg?: number; // collision groups
|
|
12
|
-
cs?: number; // contact skin
|
|
13
|
-
d?: number; // density
|
|
14
|
-
f?: number; // friction
|
|
15
|
-
fr?: number; // friction combine rule
|
|
16
|
-
en?: boolean; // enabled
|
|
17
|
-
m?: number; // mass
|
|
18
|
-
re?: number; // restitution
|
|
19
|
-
rer?: number; // restitution combine rule
|
|
20
|
-
r?: QuaternionSchema; // rotation
|
|
21
|
-
s?: ShapeSchema; // shape
|
|
22
|
-
sg?: number; // solver groups
|
|
23
|
-
sn?: boolean; // sensor
|
|
24
|
-
t?: VectorSchema; // translation
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const colliderDescSchema: JSONSchemaType<ColliderDescSchema> = {
|
|
28
|
-
type: 'object',
|
|
29
|
-
properties: {
|
|
30
|
-
at: { type: 'number', nullable: true },
|
|
31
|
-
cg: { type: 'number', nullable: true },
|
|
32
|
-
cs: { type: 'number', nullable: true },
|
|
33
|
-
d: { type: 'number', nullable: true },
|
|
34
|
-
f: { type: 'number', nullable: true },
|
|
35
|
-
fr: { type: 'number', nullable: true },
|
|
36
|
-
en: { type: 'boolean', nullable: true },
|
|
37
|
-
m: { type: 'number', nullable: true },
|
|
38
|
-
re: { type: 'number', nullable: true },
|
|
39
|
-
rer: { type: 'number', nullable: true },
|
|
40
|
-
r: { ...quaternionSchema, nullable: true },
|
|
41
|
-
s: { ...shapeSchema, nullable: true },
|
|
42
|
-
sg: { type: 'number', nullable: true },
|
|
43
|
-
sn: { type: 'boolean', nullable: true },
|
|
44
|
-
t: { ...vectorSchema, nullable: true },
|
|
45
|
-
},
|
|
46
|
-
additionalProperties: false,
|
|
47
|
-
}
|
package/schemas/RigidBody.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { colliderSchema } from './Collider';
|
|
2
|
-
import { quaternionSchema } from './Quaternion';
|
|
3
|
-
import { vectorSchema } from './Vector';
|
|
4
|
-
import { vectorBooleanSchema } from './VectorBoolean'
|
|
5
|
-
import type { JSONSchemaType } from 'ajv';
|
|
6
|
-
import type { ColliderSchema } from './Collider';
|
|
7
|
-
import type { VectorSchema } from './Vector';
|
|
8
|
-
import type { VectorBooleanSchema } from './VectorBoolean';
|
|
9
|
-
import type { QuaternionSchema } from './Quaternion';
|
|
10
|
-
|
|
11
|
-
export type RigidBodySchema = {
|
|
12
|
-
ad?: number; // angular dampening
|
|
13
|
-
ap?: { // additional mass properties
|
|
14
|
-
am: number; // additional mass
|
|
15
|
-
cm: VectorSchema; // center of mass
|
|
16
|
-
pf: QuaternionSchema; // principal angular inertia local frame
|
|
17
|
-
pi: VectorSchema; // principal angular inertia
|
|
18
|
-
},
|
|
19
|
-
as?: number; // additional solver iterations
|
|
20
|
-
av?: VectorSchema; // angular velocity
|
|
21
|
-
b?: number; // body type
|
|
22
|
-
c?: ColliderSchema[]; // collider desc
|
|
23
|
-
d?: number; // dominance group
|
|
24
|
-
ce?: boolean; // ccd enabled
|
|
25
|
-
en?: boolean; // enabled
|
|
26
|
-
er?: VectorBooleanSchema; // enabled rotations
|
|
27
|
-
et?: VectorBooleanSchema; // enabled translations
|
|
28
|
-
fs?: boolean; // full state
|
|
29
|
-
g?: number; // gravity scaling
|
|
30
|
-
ld?: number; // linear damping
|
|
31
|
-
lv?: VectorSchema; // linear velocity
|
|
32
|
-
r?: QuaternionSchema; // rotation
|
|
33
|
-
rm?: boolean; // removed
|
|
34
|
-
sl?: boolean; // sleeping
|
|
35
|
-
scp?: number; // soft ccd prediction
|
|
36
|
-
t?: VectorSchema; // translation
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export const rigidBodySchema: JSONSchemaType<RigidBodySchema> = {
|
|
40
|
-
type: 'object',
|
|
41
|
-
properties: {
|
|
42
|
-
ad: { type: 'number', nullable: true },
|
|
43
|
-
ap: {
|
|
44
|
-
type: 'object',
|
|
45
|
-
properties: {
|
|
46
|
-
am: { type: 'number' },
|
|
47
|
-
cm: { ...vectorSchema },
|
|
48
|
-
pf: { ...quaternionSchema },
|
|
49
|
-
pi: { ...vectorSchema },
|
|
50
|
-
},
|
|
51
|
-
required: ['am', 'cm', 'pf', 'pi'],
|
|
52
|
-
nullable: true,
|
|
53
|
-
},
|
|
54
|
-
as: { type: 'number', nullable: true },
|
|
55
|
-
av: { ...vectorSchema, nullable: true },
|
|
56
|
-
b: { type: 'number', nullable: true },
|
|
57
|
-
c: { type: 'array', items: colliderSchema, nullable: true },
|
|
58
|
-
d: { type: 'number', nullable: true },
|
|
59
|
-
ce: { type: 'boolean', nullable: true },
|
|
60
|
-
en: { type: 'boolean', nullable: true },
|
|
61
|
-
er: { ...vectorBooleanSchema, nullable: true },
|
|
62
|
-
et: { ...vectorBooleanSchema, nullable: true },
|
|
63
|
-
fs: { type: 'boolean', nullable: true },
|
|
64
|
-
g: { type: 'number', nullable: true },
|
|
65
|
-
ld: { type: 'number', nullable: true },
|
|
66
|
-
lv: { ...vectorSchema, nullable: true },
|
|
67
|
-
r: { ...quaternionSchema, nullable: true },
|
|
68
|
-
rm: { type: 'boolean', nullable: true },
|
|
69
|
-
sl: { type: 'boolean', nullable: true },
|
|
70
|
-
scp: { type: 'number', nullable: true },
|
|
71
|
-
t: { ...vectorSchema, nullable: true },
|
|
72
|
-
},
|
|
73
|
-
additionalProperties: false,
|
|
74
|
-
}
|
package/schemas/Shape.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { JSONSchemaType } from 'ajv';
|
|
2
|
-
import { vectorSchema } from './Vector';
|
|
3
|
-
import type { VectorSchema } from './Vector';
|
|
4
|
-
|
|
5
|
-
export type ShapeSchema = {
|
|
6
|
-
t?: number; // type
|
|
7
|
-
b?: number; // border radius
|
|
8
|
-
r?: number; // radius
|
|
9
|
-
hx?: VectorSchema; // half extends
|
|
10
|
-
hh?: number; // half height
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const shapeSchema: JSONSchemaType<ShapeSchema> = {
|
|
14
|
-
type: 'object',
|
|
15
|
-
properties: {
|
|
16
|
-
t: { type: 'number', nullable: true },
|
|
17
|
-
b: { type: 'number', nullable: true },
|
|
18
|
-
r: { type: 'number', nullable: true },
|
|
19
|
-
hx: { ...vectorSchema, nullable: true },
|
|
20
|
-
hh: { type: 'number', nullable: true },
|
|
21
|
-
},
|
|
22
|
-
additionalProperties: false,
|
|
23
|
-
}
|
package/schemas/Simulation.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { JSONSchemaType } from 'ajv';
|
|
2
|
-
import { vectorSchema } from './Vector';
|
|
3
|
-
import type { VectorSchema } from './Vector';
|
|
4
|
-
|
|
5
|
-
export type SimulationSchema = {
|
|
6
|
-
wi: number; // world id
|
|
7
|
-
t?: number; // timestep (seconds)
|
|
8
|
-
g?: VectorSchema; // gravity
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const simulationSchema: JSONSchemaType<SimulationSchema> = {
|
|
12
|
-
type: 'object',
|
|
13
|
-
properties: {
|
|
14
|
-
wi: { type: 'number' },
|
|
15
|
-
t: { type: 'number', nullable: true },
|
|
16
|
-
g: { ...vectorSchema, nullable: true },
|
|
17
|
-
},
|
|
18
|
-
required: [ 'wi' ],
|
|
19
|
-
additionalProperties: false,
|
|
20
|
-
}
|