@kubeverse/sdk 0.1.3 → 0.1.4
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/dist/context.d.ts +108 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/objects/Model.d.ts +13 -0
- package/dist/objects/Model.d.ts.map +1 -0
- package/dist/objects/Model.js +41 -0
- package/dist/objects/Model.js.map +1 -0
- package/dist/objects/NPC.d.ts +24 -0
- package/dist/objects/NPC.d.ts.map +1 -0
- package/dist/objects/NPC.js +72 -0
- package/dist/objects/NPC.js.map +1 -0
- package/dist/objects/Primitive.d.ts +33 -0
- package/dist/objects/Primitive.d.ts.map +1 -0
- package/dist/objects/Primitive.js +89 -0
- package/dist/objects/Primitive.js.map +1 -0
- package/dist/objects/Prop.d.ts +23 -0
- package/dist/objects/Prop.d.ts.map +1 -0
- package/dist/objects/Prop.js +35 -0
- package/dist/objects/Prop.js.map +1 -0
- package/dist/objects/Terrain.d.ts +21 -0
- package/dist/objects/Terrain.d.ts.map +1 -0
- package/dist/objects/Terrain.js +61 -0
- package/dist/objects/Terrain.js.map +1 -0
- package/dist/objects/TriggerZone.d.ts +19 -0
- package/dist/objects/TriggerZone.d.ts.map +1 -0
- package/dist/objects/TriggerZone.js +35 -0
- package/dist/objects/TriggerZone.js.map +1 -0
- package/dist/objects/Vehicle.d.ts +21 -0
- package/dist/objects/Vehicle.d.ts.map +1 -0
- package/dist/objects/Vehicle.js +47 -0
- package/dist/objects/Vehicle.js.map +1 -0
- package/dist/objects/VoxelBlock.d.ts +19 -0
- package/dist/objects/VoxelBlock.d.ts.map +1 -0
- package/dist/objects/VoxelBlock.js +53 -0
- package/dist/objects/VoxelBlock.js.map +1 -0
- package/dist/objects/index.d.ts +9 -0
- package/dist/objects/index.d.ts.map +1 -0
- package/dist/objects/index.js +25 -0
- package/dist/objects/index.js.map +1 -0
- package/package.json +1 -1
package/dist/context.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type TriggerZoneEnterCallback<TPlayer extends IPlayer = IPlayer> = (playe
|
|
|
7
7
|
export type TriggerZoneLeaveCallback<TPlayer extends IPlayer = IPlayer> = (player: TPlayer) => void | Promise<void>;
|
|
8
8
|
export type ChatMessageHandler<TPlayer extends IPlayer = IPlayer> = (player: TPlayer, text: string) => boolean | void | Promise<boolean | void>;
|
|
9
9
|
export type PrimitiveOptions = {
|
|
10
|
-
type: "cube" | "sphere" | "cylinder" | "ramp" | "halfcube";
|
|
10
|
+
type: "cube" | "sphere" | "cylinder" | "ramp" | "halfcube" | "plane" | "cone" | "torus" | "capsule";
|
|
11
11
|
position: Vector3;
|
|
12
12
|
rotation?: Quaternion;
|
|
13
13
|
scale?: {
|
|
@@ -17,6 +17,11 @@ export type PrimitiveOptions = {
|
|
|
17
17
|
};
|
|
18
18
|
color?: number;
|
|
19
19
|
materialType?: "standard" | "basic";
|
|
20
|
+
texture?: string;
|
|
21
|
+
textureRepeat?: {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
};
|
|
20
25
|
opacity?: number;
|
|
21
26
|
colliderType?: "fixed" | "dynamic" | "kinematic" | "none";
|
|
22
27
|
renderMode?: "voxel" | "default";
|
|
@@ -31,6 +36,11 @@ export type PrimitiveUpdateOptions = {
|
|
|
31
36
|
};
|
|
32
37
|
color?: number;
|
|
33
38
|
materialType?: "standard" | "basic";
|
|
39
|
+
texture?: string;
|
|
40
|
+
textureRepeat?: {
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
};
|
|
34
44
|
opacity?: number;
|
|
35
45
|
colliderType?: "fixed" | "dynamic" | "kinematic" | "none";
|
|
36
46
|
};
|
|
@@ -57,6 +67,11 @@ export type RuntimePrimitive = {
|
|
|
57
67
|
primitiveData: {
|
|
58
68
|
color?: number;
|
|
59
69
|
materialType?: "standard" | "basic";
|
|
70
|
+
texture?: string;
|
|
71
|
+
textureRepeat?: {
|
|
72
|
+
x: number;
|
|
73
|
+
y: number;
|
|
74
|
+
};
|
|
60
75
|
opacity?: number;
|
|
61
76
|
};
|
|
62
77
|
colliderType: "fixed" | "dynamic" | "kinematic" | "none";
|
|
@@ -73,9 +88,43 @@ export type RuntimeProp = {
|
|
|
73
88
|
z: number;
|
|
74
89
|
};
|
|
75
90
|
};
|
|
91
|
+
export type ModelOptions = {
|
|
92
|
+
modelKey: string;
|
|
93
|
+
position: Vector3;
|
|
94
|
+
rotation?: Quaternion;
|
|
95
|
+
scale?: {
|
|
96
|
+
x: number;
|
|
97
|
+
y: number;
|
|
98
|
+
z: number;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
export type ModelUpdateOptions = {
|
|
102
|
+
position?: Vector3;
|
|
103
|
+
rotation?: Quaternion;
|
|
104
|
+
scale?: {
|
|
105
|
+
x: number;
|
|
106
|
+
y: number;
|
|
107
|
+
z: number;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
export type RuntimeModel = {
|
|
111
|
+
id: string;
|
|
112
|
+
modelKey: string;
|
|
113
|
+
position: Vector3;
|
|
114
|
+
quaternion: Quaternion;
|
|
115
|
+
scale: {
|
|
116
|
+
x: number;
|
|
117
|
+
y: number;
|
|
118
|
+
z: number;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
76
121
|
export type SpawnVehicleOptions = {
|
|
77
122
|
type: "car" | "plane";
|
|
78
123
|
model?: string;
|
|
124
|
+
/** How long (ms) before the vehicle auto-despawns when unoccupied. Use Infinity to never despawn. Default: 10 000 ms. */
|
|
125
|
+
despawnDelay?: number;
|
|
126
|
+
/** When true, the handbrake is automatically engaged when unoccupied and released when a driver enters. Default: true. */
|
|
127
|
+
parkingBrake?: boolean;
|
|
79
128
|
};
|
|
80
129
|
export type RaycastHit = {
|
|
81
130
|
position: Vector3;
|
|
@@ -84,6 +133,54 @@ export type RaycastHit = {
|
|
|
84
133
|
entityId?: string;
|
|
85
134
|
entityType?: "player" | "npc" | "primitive" | "world";
|
|
86
135
|
};
|
|
136
|
+
export type TerrainPreset = "grass" | "desert" | "snow" | "rock" | "dirt";
|
|
137
|
+
export type TerrainColorStop = {
|
|
138
|
+
height: number;
|
|
139
|
+
color: number;
|
|
140
|
+
};
|
|
141
|
+
export type TerrainMaterialOptions = {
|
|
142
|
+
colorStops?: TerrainColorStop[];
|
|
143
|
+
cliffColor?: number;
|
|
144
|
+
steepnessThreshold?: number;
|
|
145
|
+
noiseScale?: number;
|
|
146
|
+
texture?: string;
|
|
147
|
+
textureRepeat?: {
|
|
148
|
+
x: number;
|
|
149
|
+
y: number;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
export type TerrainMaterial = TerrainPreset | TerrainMaterialOptions;
|
|
153
|
+
export type TerrainOptions = {
|
|
154
|
+
position: Vector3;
|
|
155
|
+
rotation?: Quaternion;
|
|
156
|
+
heights: number[];
|
|
157
|
+
nrows: number;
|
|
158
|
+
ncols: number;
|
|
159
|
+
scale: {
|
|
160
|
+
x: number;
|
|
161
|
+
y: number;
|
|
162
|
+
z: number;
|
|
163
|
+
};
|
|
164
|
+
material?: TerrainMaterial;
|
|
165
|
+
};
|
|
166
|
+
export type TerrainUpdateOptions = {
|
|
167
|
+
heights?: number[];
|
|
168
|
+
material?: TerrainMaterial;
|
|
169
|
+
};
|
|
170
|
+
export type RuntimeTerrain = {
|
|
171
|
+
id: string;
|
|
172
|
+
position: Vector3;
|
|
173
|
+
quaternion: Quaternion;
|
|
174
|
+
heights: number[];
|
|
175
|
+
nrows: number;
|
|
176
|
+
ncols: number;
|
|
177
|
+
scale: {
|
|
178
|
+
x: number;
|
|
179
|
+
y: number;
|
|
180
|
+
z: number;
|
|
181
|
+
};
|
|
182
|
+
material: TerrainMaterial;
|
|
183
|
+
};
|
|
87
184
|
export type WorldSettingsLike = object;
|
|
88
185
|
export type TimerHandle = ReturnType<typeof globalThis.setTimeout>;
|
|
89
186
|
export interface IWorldContext<TPlayer extends IPlayer = IPlayer, TNPC extends INPC = INPC> {
|
|
@@ -94,8 +191,10 @@ export interface IWorldContext<TPlayer extends IPlayer = IPlayer, TNPC extends I
|
|
|
94
191
|
y: number;
|
|
95
192
|
z: number;
|
|
96
193
|
}): string;
|
|
194
|
+
spawnModel(options: ModelOptions): string;
|
|
97
195
|
spawnPrimitive(options: PrimitiveOptions): string;
|
|
98
196
|
spawnPrimitives(options: PrimitiveOptions[]): string[];
|
|
197
|
+
spawnTerrain(options: TerrainOptions): string;
|
|
99
198
|
setVoxelBlock(x: number, y: number, z: number, options: VoxelBlockOptions): void;
|
|
100
199
|
setVoxelBlocks(blocks: VoxelBlockDef[]): void;
|
|
101
200
|
removeVoxelBlock(x: number, y: number, z: number): void;
|
|
@@ -106,19 +205,27 @@ export interface IWorldContext<TPlayer extends IPlayer = IPlayer, TNPC extends I
|
|
|
106
205
|
removeTriggerZone(id: string): void;
|
|
107
206
|
removeNPC(npc: TNPC, delay?: number): void;
|
|
108
207
|
removeProp(id: string): void;
|
|
208
|
+
removeModel(id: string): void;
|
|
109
209
|
removePrimitive(id: string): void;
|
|
210
|
+
removeTerrain(id: string): void;
|
|
211
|
+
updateModel(id: string, updates: ModelUpdateOptions): boolean;
|
|
110
212
|
updatePrimitive(id: string, updates: PrimitiveUpdateOptions): boolean;
|
|
213
|
+
updateTerrain(id: string, updates: TerrainUpdateOptions): boolean;
|
|
111
214
|
getPlayers(): Map<string, TPlayer>;
|
|
112
215
|
getPlayerById(id: string): TPlayer | null;
|
|
113
216
|
getPlayerByUserId(userId: string): TPlayer | null;
|
|
114
217
|
getNPCs(): TNPC[];
|
|
115
218
|
getWorldSettings(): WorldSettingsLike;
|
|
116
219
|
getPrimitives(): RuntimePrimitive[];
|
|
220
|
+
getTerrains(): RuntimeTerrain[];
|
|
221
|
+
getTerrainHeightAt(x: number, z: number, terrainId?: string): number | null;
|
|
117
222
|
getProps(): RuntimeProp[];
|
|
223
|
+
getModels(): RuntimeModel[];
|
|
118
224
|
getSpawnPoints(): Vector3[];
|
|
119
225
|
randomSpawnPoint(): Vector3;
|
|
120
226
|
broadcast(event: string, data: any): void;
|
|
121
227
|
sendChatMessage(text: string): void;
|
|
228
|
+
giveLoadout(player: TPlayer, ...weapons: (string | null)[]): void;
|
|
122
229
|
onChatMessage(handler: ChatMessageHandler<TPlayer>): void;
|
|
123
230
|
playSoundAll(audioKey: string, volume?: number, detune?: number): void;
|
|
124
231
|
loadUITemplate(moduleDir: string): void;
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAE7C,MAAM,MAAM,mBAAmB,CAAC,OAAO,SAAS,OAAO,GAAG,OAAO,IAAI,CACnE,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,OAAO,KACZ,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B,MAAM,MAAM,mBAAmB,CAAC,OAAO,SAAS,OAAO,GAAG,OAAO,IAAI,CACnE,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,GAAG,KACN,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,OAAO,GAAG,OAAO,IAAI,CACjE,MAAM,EAAE,OAAO,EACf,WAAW,EAAE,MAAM,KAChB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B,MAAM,MAAM,wBAAwB,CAAC,OAAO,SAAS,OAAO,GAAG,OAAO,IAAI,CACxE,MAAM,EAAE,OAAO,KACZ,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CA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,EAAE;QAAE,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,UAAU,GAAG,IAAI,CAAC;IAC5H,UAAU,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW,CAAC;IACpD,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IACxC,WAAW,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW,CAAC;IACrD,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;CAC1C"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -19,4 +19,5 @@ __exportStar(require("./entities"), exports);
|
|
|
19
19
|
__exportStar(require("./context"), exports);
|
|
20
20
|
__exportStar(require("./worldModule"), exports);
|
|
21
21
|
__exportStar(require("./types"), exports);
|
|
22
|
+
__exportStar(require("./objects"), exports);
|
|
22
23
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,6CAA2B;AAC3B,4CAA0B;AAC1B,gDAA8B;AAC9B,0CAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,6CAA2B;AAC3B,4CAA0B;AAC1B,gDAA8B;AAC9B,0CAAwB;AACxB,4CAA0B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IWorldContext, ModelOptions, ModelUpdateOptions } from "../context";
|
|
2
|
+
export declare class Model {
|
|
3
|
+
private _id;
|
|
4
|
+
private _ctx;
|
|
5
|
+
private readonly options;
|
|
6
|
+
constructor(options: ModelOptions);
|
|
7
|
+
get id(): string;
|
|
8
|
+
get isSpawned(): boolean;
|
|
9
|
+
spawn(ctx: IWorldContext): this;
|
|
10
|
+
update(updates: ModelUpdateOptions): boolean;
|
|
11
|
+
remove(): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=Model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Model.d.ts","sourceRoot":"","sources":["../../src/objects/Model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE7E,qBAAa,KAAK;IAChB,OAAO,CAAC,GAAG,CAAuB;IAClC,OAAO,CAAC,IAAI,CAA8B;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;gBAE3B,OAAO,EAAE,YAAY;IAIjC,IAAI,EAAE,IAAI,MAAM,CAGf;IAED,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI;IAO/B,MAAM,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO;IAO5C,MAAM,IAAI,IAAI;CAQf"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Model = void 0;
|
|
4
|
+
class Model {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this._id = null;
|
|
7
|
+
this._ctx = null;
|
|
8
|
+
this.options = options;
|
|
9
|
+
}
|
|
10
|
+
get id() {
|
|
11
|
+
if (!this._id)
|
|
12
|
+
throw new Error("Model not spawned. Call .spawn(ctx) first.");
|
|
13
|
+
return this._id;
|
|
14
|
+
}
|
|
15
|
+
get isSpawned() {
|
|
16
|
+
return this._id !== null;
|
|
17
|
+
}
|
|
18
|
+
spawn(ctx) {
|
|
19
|
+
if (this._id)
|
|
20
|
+
throw new Error("Model already spawned.");
|
|
21
|
+
this._ctx = ctx;
|
|
22
|
+
this._id = ctx.spawnModel(this.options);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
update(updates) {
|
|
26
|
+
if (!this._ctx || !this._id) {
|
|
27
|
+
throw new Error("Model not spawned. Call .spawn(ctx) first.");
|
|
28
|
+
}
|
|
29
|
+
return this._ctx.updateModel(this._id, updates);
|
|
30
|
+
}
|
|
31
|
+
remove() {
|
|
32
|
+
if (!this._ctx || !this._id) {
|
|
33
|
+
throw new Error("Model not spawned. Call .spawn(ctx) first.");
|
|
34
|
+
}
|
|
35
|
+
this._ctx.removeModel(this._id);
|
|
36
|
+
this._id = null;
|
|
37
|
+
this._ctx = null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.Model = Model;
|
|
41
|
+
//# sourceMappingURL=Model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Model.js","sourceRoot":"","sources":["../../src/objects/Model.ts"],"names":[],"mappings":";;;AAEA,MAAa,KAAK;IAKhB,YAAY,OAAqB;QAJzB,QAAG,GAAkB,IAAI,CAAC;QAC1B,SAAI,GAAyB,IAAI,CAAC;QAIxC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,IAAI,EAAE;QACJ,IAAI,CAAC,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAC7E,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,GAAkB;QACtB,IAAI,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QACxD,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,OAA2B;QAChC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAChE,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAxCD,sBAwCC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IWorldContext } from "../context";
|
|
2
|
+
import { INPC, IPlayer } from "../entities";
|
|
3
|
+
import { Vector3 } from "../math";
|
|
4
|
+
export declare class NPC {
|
|
5
|
+
private _ctx;
|
|
6
|
+
private _npc;
|
|
7
|
+
private readonly spawnPosition;
|
|
8
|
+
constructor(position: Vector3);
|
|
9
|
+
get isSpawned(): boolean;
|
|
10
|
+
spawn(ctx: IWorldContext): this;
|
|
11
|
+
static fromExisting(npc: INPC, ctx: IWorldContext): NPC;
|
|
12
|
+
private requireSpawned;
|
|
13
|
+
get raw(): INPC;
|
|
14
|
+
get id(): string;
|
|
15
|
+
get position(): Vector3;
|
|
16
|
+
get health(): number;
|
|
17
|
+
get isDead(): boolean;
|
|
18
|
+
teleportTo(position: Vector3): this;
|
|
19
|
+
damage(amount: number, attackerId?: string): this;
|
|
20
|
+
heal(amount: number): this;
|
|
21
|
+
setTarget(target: IPlayer | INPC | NPC | null): this;
|
|
22
|
+
remove(delay?: number): void;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=NPC.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NPC.d.ts","sourceRoot":"","sources":["../../src/objects/NPC.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,qBAAa,GAAG;IACd,OAAO,CAAC,IAAI,CAA8B;IAC1C,OAAO,CAAC,IAAI,CAAqB;IACjC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAU;gBAE5B,QAAQ,EAAE,OAAO;IAI7B,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI;IAO/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,aAAa,GAAG,GAAG;IAOvD,OAAO,CAAC,cAAc;IAOtB,IAAI,GAAG,IAAI,IAAI,CAEd;IAED,IAAI,EAAE,IAAI,MAAM,CAEf;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,UAAU,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAKnC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAKjD,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAK1B,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI;IAMpD,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;CAM7B"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NPC = void 0;
|
|
4
|
+
class NPC {
|
|
5
|
+
constructor(position) {
|
|
6
|
+
this._ctx = null;
|
|
7
|
+
this._npc = null;
|
|
8
|
+
this.spawnPosition = position;
|
|
9
|
+
}
|
|
10
|
+
get isSpawned() {
|
|
11
|
+
return this._npc !== null;
|
|
12
|
+
}
|
|
13
|
+
spawn(ctx) {
|
|
14
|
+
if (this._npc)
|
|
15
|
+
throw new Error("NPC already spawned.");
|
|
16
|
+
this._ctx = ctx;
|
|
17
|
+
this._npc = ctx.spawnNPC(this.spawnPosition);
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
static fromExisting(npc, ctx) {
|
|
21
|
+
const instance = new NPC(npc.position);
|
|
22
|
+
instance._ctx = ctx;
|
|
23
|
+
instance._npc = npc;
|
|
24
|
+
return instance;
|
|
25
|
+
}
|
|
26
|
+
requireSpawned() {
|
|
27
|
+
if (!this._ctx || !this._npc) {
|
|
28
|
+
throw new Error("NPC not spawned. Call .spawn(ctx) first.");
|
|
29
|
+
}
|
|
30
|
+
return { ctx: this._ctx, npc: this._npc };
|
|
31
|
+
}
|
|
32
|
+
get raw() {
|
|
33
|
+
return this.requireSpawned().npc;
|
|
34
|
+
}
|
|
35
|
+
get id() {
|
|
36
|
+
return this.requireSpawned().npc.id;
|
|
37
|
+
}
|
|
38
|
+
get position() {
|
|
39
|
+
return this.requireSpawned().npc.position;
|
|
40
|
+
}
|
|
41
|
+
get health() {
|
|
42
|
+
return this.requireSpawned().npc.health;
|
|
43
|
+
}
|
|
44
|
+
get isDead() {
|
|
45
|
+
return this.requireSpawned().npc.isDead;
|
|
46
|
+
}
|
|
47
|
+
teleportTo(position) {
|
|
48
|
+
this.requireSpawned().npc.teleportTo(position);
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
damage(amount, attackerId) {
|
|
52
|
+
this.requireSpawned().npc.damage(amount, attackerId);
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
heal(amount) {
|
|
56
|
+
this.requireSpawned().npc.heal(amount);
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
setTarget(target) {
|
|
60
|
+
const { npc } = this.requireSpawned();
|
|
61
|
+
npc.setTarget(target instanceof NPC ? target.raw : target);
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
remove(delay) {
|
|
65
|
+
const { ctx, npc } = this.requireSpawned();
|
|
66
|
+
ctx.removeNPC(npc, delay);
|
|
67
|
+
this._npc = null;
|
|
68
|
+
this._ctx = null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.NPC = NPC;
|
|
72
|
+
//# sourceMappingURL=NPC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NPC.js","sourceRoot":"","sources":["../../src/objects/NPC.ts"],"names":[],"mappings":";;;AAIA,MAAa,GAAG;IAKd,YAAY,QAAiB;QAJrB,SAAI,GAAyB,IAAI,CAAC;QAClC,SAAI,GAAgB,IAAI,CAAC;QAI/B,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC;IAChC,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI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,cAAc,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC;IAC1C,CAAC;IAED,UAAU,CAAC,QAAiB;QAC1B,IAAI,CAAC,cAAc,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,MAAc,EAAE,UAAmB;QACxC,IAAI,CAAC,cAAc,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC,MAAc;QACjB,IAAI,CAAC,cAAc,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,SAAS,CAAC,MAAmC;QAC3C,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QACtC,GAAG,CAAC,SAAS,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,KAAc;QACnB,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QAC3C,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAjFD,kBAiFC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CollisionCallback, IWorldContext, PrimitiveOptions, PrimitiveUpdateOptions } from "../context";
|
|
2
|
+
import { Vector3, Quaternion } from "../math";
|
|
3
|
+
export declare class Primitive {
|
|
4
|
+
private _id;
|
|
5
|
+
private _ctx;
|
|
6
|
+
private readonly options;
|
|
7
|
+
constructor(options: PrimitiveOptions);
|
|
8
|
+
get id(): string;
|
|
9
|
+
get isSpawned(): boolean;
|
|
10
|
+
spawn(ctx: IWorldContext): this;
|
|
11
|
+
private requireSpawned;
|
|
12
|
+
static batch(options: PrimitiveOptions[], ctx: IWorldContext): Primitive[];
|
|
13
|
+
update(updates: PrimitiveUpdateOptions): this;
|
|
14
|
+
setPosition(position: Vector3): this;
|
|
15
|
+
setRotation(rotation: Quaternion): this;
|
|
16
|
+
setScale(scale: {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
z: number;
|
|
20
|
+
}): this;
|
|
21
|
+
setColor(color: number): this;
|
|
22
|
+
setMaterialType(materialType: "standard" | "basic"): this;
|
|
23
|
+
setTexture(texture: string, textureRepeat?: {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
}): this;
|
|
27
|
+
setOpacity(opacity: number): this;
|
|
28
|
+
setColliderType(colliderType: "fixed" | "dynamic" | "kinematic" | "none"): this;
|
|
29
|
+
onPlayerEnter(callback: CollisionCallback): this;
|
|
30
|
+
onPlayerLeave(callback: CollisionCallback): this;
|
|
31
|
+
remove(): void;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=Primitive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Primitive.d.ts","sourceRoot":"","sources":["../../src/objects/Primitive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE9C,qBAAa,SAAS;IACpB,OAAO,CAAC,GAAG,CAAuB;IAClC,OAAO,CAAC,IAAI,CAA8B;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;gBAE/B,OAAO,EAAE,gBAAgB;IAIrC,IAAI,EAAE,IAAI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ctx = null;
|
|
8
|
+
this.options = options;
|
|
9
|
+
}
|
|
10
|
+
get id() {
|
|
11
|
+
if (!this._id)
|
|
12
|
+
throw new Error("Primitive not spawned. Call .spawn(ctx) first.");
|
|
13
|
+
return this._id;
|
|
14
|
+
}
|
|
15
|
+
get isSpawned() {
|
|
16
|
+
return this._id !== null;
|
|
17
|
+
}
|
|
18
|
+
spawn(ctx) {
|
|
19
|
+
if (this._id)
|
|
20
|
+
throw new Error("Primitive already spawned.");
|
|
21
|
+
this._ctx = ctx;
|
|
22
|
+
this._id = ctx.spawnPrimitive(this.options);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
requireSpawned() {
|
|
26
|
+
if (!this._ctx || !this._id) {
|
|
27
|
+
throw new Error("Primitive not spawned. Call .spawn(ctx) first.");
|
|
28
|
+
}
|
|
29
|
+
return this._ctx;
|
|
30
|
+
}
|
|
31
|
+
static batch(options, ctx) {
|
|
32
|
+
if (!Array.isArray(options) || options.length === 0)
|
|
33
|
+
return [];
|
|
34
|
+
const ids = ctx.spawnPrimitives(options);
|
|
35
|
+
return ids.map((id, index) => {
|
|
36
|
+
const p = new Primitive(options[index]);
|
|
37
|
+
p._ctx = ctx;
|
|
38
|
+
p._id = id;
|
|
39
|
+
return p;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
update(updates) {
|
|
43
|
+
const ctx = this.requireSpawned();
|
|
44
|
+
ctx.updatePrimitive(this._id, updates);
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
setPosition(position) {
|
|
48
|
+
return this.update({ position });
|
|
49
|
+
}
|
|
50
|
+
setRotation(rotation) {
|
|
51
|
+
return this.update({ rotation });
|
|
52
|
+
}
|
|
53
|
+
setScale(scale) {
|
|
54
|
+
return this.update({ scale });
|
|
55
|
+
}
|
|
56
|
+
setColor(color) {
|
|
57
|
+
return this.update({ color });
|
|
58
|
+
}
|
|
59
|
+
setMaterialType(materialType) {
|
|
60
|
+
return this.update({ materialType });
|
|
61
|
+
}
|
|
62
|
+
setTexture(texture, textureRepeat) {
|
|
63
|
+
return this.update({ texture, textureRepeat });
|
|
64
|
+
}
|
|
65
|
+
setOpacity(opacity) {
|
|
66
|
+
return this.update({ opacity });
|
|
67
|
+
}
|
|
68
|
+
setColliderType(colliderType) {
|
|
69
|
+
return this.update({ colliderType });
|
|
70
|
+
}
|
|
71
|
+
onPlayerEnter(callback) {
|
|
72
|
+
const ctx = this.requireSpawned();
|
|
73
|
+
ctx.onPlayerEnterPrimitive(this._id, callback);
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
onPlayerLeave(callback) {
|
|
77
|
+
const ctx = this.requireSpawned();
|
|
78
|
+
ctx.onPlayerLeavePrimitive(this._id, callback);
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
remove() {
|
|
82
|
+
const ctx = this.requireSpawned();
|
|
83
|
+
ctx.removePrimitive(this._id);
|
|
84
|
+
this._id = null;
|
|
85
|
+
this._ctx = null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.Primitive = Primitive;
|
|
89
|
+
//# sourceMappingURL=Primitive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Primitive.js","sourceRoot":"","sources":["../../src/objects/Primitive.ts"],"names":[],"mappings":";;;AAQA,MAAa,SAAS;IAKpB,YAAY,OAAyB;QAJ7B,QAAG,GAAkB,IAAI,CAAC;QAC1B,SAAI,GAAyB,IAAI,CAAC;QAIxC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,IAAI,EAAE;QACJ,IAAI,CAAC,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;QACjF,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,GAAkB;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Ae,CAAC,IAAI,CAAC,GAAI,CAAC,CAAC;QAC/B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAnGD,8BAmGC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IWorldContext } from "../context";
|
|
2
|
+
import { Quaternion, Vector3 } from "../math";
|
|
3
|
+
export type PropOptions = {
|
|
4
|
+
type: string;
|
|
5
|
+
position: Vector3;
|
|
6
|
+
rotation?: Quaternion;
|
|
7
|
+
scale?: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
z: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare class Prop {
|
|
14
|
+
private _id;
|
|
15
|
+
private _ctx;
|
|
16
|
+
private readonly options;
|
|
17
|
+
constructor(options: PropOptions);
|
|
18
|
+
get id(): string;
|
|
19
|
+
get isSpawned(): boolean;
|
|
20
|
+
spawn(ctx: IWorldContext): this;
|
|
21
|
+
remove(): void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=Prop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Prop.d.ts","sourceRoot":"","sources":["../../src/objects/Prop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,KAAK,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7C,CAAC;AAEF,qBAAa,IAAI;IACf,OAAO,CAAC,GAAG,CAAuB;IAClC,OAAO,CAAC,IAAI,CAA8B;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAc;gBAE1B,OAAO,EAAE,WAAW;IAIhC,IAAI,EAAE,IAAI,MAAM,CAGf;IAED,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI;IAY/B,MAAM,IAAI,IAAI;CAQf"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Prop = void 0;
|
|
4
|
+
class Prop {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this._id = null;
|
|
7
|
+
this._ctx = null;
|
|
8
|
+
this.options = options;
|
|
9
|
+
}
|
|
10
|
+
get id() {
|
|
11
|
+
if (!this._id)
|
|
12
|
+
throw new Error("Prop not spawned. Call .spawn(ctx) first.");
|
|
13
|
+
return this._id;
|
|
14
|
+
}
|
|
15
|
+
get isSpawned() {
|
|
16
|
+
return this._id !== null;
|
|
17
|
+
}
|
|
18
|
+
spawn(ctx) {
|
|
19
|
+
if (this._id)
|
|
20
|
+
throw new Error("Prop already spawned.");
|
|
21
|
+
this._ctx = ctx;
|
|
22
|
+
this._id = ctx.spawnProp(this.options.type, this.options.position, this.options.rotation, this.options.scale);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
remove() {
|
|
26
|
+
if (!this._ctx || !this._id) {
|
|
27
|
+
throw new Error("Prop not spawned. Call .spawn(ctx) first.");
|
|
28
|
+
}
|
|
29
|
+
this._ctx.removeProp(this._id);
|
|
30
|
+
this._id = null;
|
|
31
|
+
this._ctx = null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.Prop = Prop;
|
|
35
|
+
//# sourceMappingURL=Prop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Prop.js","sourceRoot":"","sources":["../../src/objects/Pr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";
|
|
2
|
+
export declare class Terrain {
|
|
3
|
+
private _id;
|
|
4
|
+
private _ctx;
|
|
5
|
+
private readonly options;
|
|
6
|
+
constructor(options: TerrainOptions);
|
|
7
|
+
get id(): string;
|
|
8
|
+
get isSpawned(): boolean;
|
|
9
|
+
spawn(ctx: IWorldContext): this;
|
|
10
|
+
private requireSpawned;
|
|
11
|
+
update(updates: TerrainUpdateOptions): this;
|
|
12
|
+
setHeights(heights: number[]): this;
|
|
13
|
+
setMaterial(material: TerrainMaterial): this;
|
|
14
|
+
setTexture(texture: string, textureRepeat?: {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
}): this;
|
|
18
|
+
getHeightAt(x: number, z: number): number | null;
|
|
19
|
+
remove(): void;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=Terrain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Terrain.d.ts","sourceRoot":"","sources":["../../src/objects/Terrain.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,eAAe,EAEf,cAAc,EACd,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAEpB,qBAAa,OAAO;IAClB,OAAO,CAAC,GAAG,CAAuB;IAClC,OAAO,CAAC,IAAI,CAA8B;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;gBAE7B,OAAO,EAAE,cAAc;IAInC,IAAI,EAAE,IAAI,MAAM,CAGf;IAED,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI;IAO/B,OAAO,CAAC,cAAc;IAOtB,MAAM,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI;IAM3C,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAInC,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAI5C,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAQ3E,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAKhD,MAAM,IAAI,IAAI;CAMf"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Terrain = void 0;
|
|
4
|
+
class Terrain {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this._id = null;
|
|
7
|
+
this._ctx = null;
|
|
8
|
+
this.options = options;
|
|
9
|
+
}
|
|
10
|
+
get id() {
|
|
11
|
+
if (!this._id)
|
|
12
|
+
throw new Error("Terrain not spawned. Call .spawn(ctx) first.");
|
|
13
|
+
return this._id;
|
|
14
|
+
}
|
|
15
|
+
get isSpawned() {
|
|
16
|
+
return this._id !== null;
|
|
17
|
+
}
|
|
18
|
+
spawn(ctx) {
|
|
19
|
+
if (this._id)
|
|
20
|
+
throw new Error("Terrain already spawned.");
|
|
21
|
+
this._ctx = ctx;
|
|
22
|
+
this._id = ctx.spawnTerrain(this.options);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
requireSpawned() {
|
|
26
|
+
if (!this._ctx || !this._id) {
|
|
27
|
+
throw new Error("Terrain not spawned. Call .spawn(ctx) first.");
|
|
28
|
+
}
|
|
29
|
+
return this._ctx;
|
|
30
|
+
}
|
|
31
|
+
update(updates) {
|
|
32
|
+
const ctx = this.requireSpawned();
|
|
33
|
+
ctx.updateTerrain(this._id, updates);
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
setHeights(heights) {
|
|
37
|
+
return this.update({ heights });
|
|
38
|
+
}
|
|
39
|
+
setMaterial(material) {
|
|
40
|
+
return this.update({ material });
|
|
41
|
+
}
|
|
42
|
+
setTexture(texture, textureRepeat) {
|
|
43
|
+
const material = {
|
|
44
|
+
texture,
|
|
45
|
+
textureRepeat,
|
|
46
|
+
};
|
|
47
|
+
return this.update({ material });
|
|
48
|
+
}
|
|
49
|
+
getHeightAt(x, z) {
|
|
50
|
+
const ctx = this.requireSpawned();
|
|
51
|
+
return ctx.getTerrainHeightAt(x, z, this._id);
|
|
52
|
+
}
|
|
53
|
+
remove() {
|
|
54
|
+
const ctx = this.requireSpawned();
|
|
55
|
+
ctx.removeTerrain(this._id);
|
|
56
|
+
this._id = null;
|
|
57
|
+
this._ctx = null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.Terrain = Terrain;
|
|
61
|
+
//# sourceMappingURL=Terrain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Terrain.js","sourceRoot":"","sources":["../../src/objects/Terrain.ts"],"names":[],"mappings":";;;AAQA,MAAa,OAAO;IAKlB,YAAY,OAAuB;QAJ3B,QAAG,GAAkB,IAAI,CAAC;QAC1B,SAAI,GAAyB,IAAI,CAAC;QAIxC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,IAAI,EAAE;QACJ,IAAI,CAAC,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAC/E,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,GAAkB;QACtB,IAAI,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,cAAc;QACpB,IAAI,CAAC,IAAI,CAAC,IAAI,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neLeaveCallback } from "../context";
|
|
2
|
+
import { Vector3 } from "../math";
|
|
3
|
+
export type TriggerZoneOptions = {
|
|
4
|
+
position: Vector3;
|
|
5
|
+
size: Vector3;
|
|
6
|
+
onEnter: TriggerZoneEnterCallback;
|
|
7
|
+
onLeave?: TriggerZoneLeaveCallback;
|
|
8
|
+
};
|
|
9
|
+
export declare class TriggerZone {
|
|
10
|
+
private _id;
|
|
11
|
+
private _ctx;
|
|
12
|
+
private readonly options;
|
|
13
|
+
constructor(options: TriggerZoneOptions);
|
|
14
|
+
get id(): string;
|
|
15
|
+
get isSpawned(): boolean;
|
|
16
|
+
spawn(ctx: IWorldContext): this;
|
|
17
|
+
remove(): void;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=TriggerZone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TriggerZone.d.ts","sourceRoot":"","sources":["../../src/objects/TriggerZone.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,wBAAwB,CAAC;IAClC,OAAO,CAAC,EAAE,wBAAwB,CAAC;CACpC,CAAC;AAEF,qBAAa,WAAW;IACtB,OAAO,CAAC,GAAG,CAAuB;IAClC,OAAO,CAAC,IAAI,CAA8B;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;gBAEjC,OAAO,EAAE,kBAAkB;IAIvC,IAAI,EAAE,IAAI,MAAM,CAGf;IAED,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI;IAY/B,MAAM,IAAI,IAAI;CAQf"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TriggerZone = void 0;
|
|
4
|
+
class TriggerZone {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this._id = null;
|
|
7
|
+
this._ctx = null;
|
|
8
|
+
this.options = options;
|
|
9
|
+
}
|
|
10
|
+
get id() {
|
|
11
|
+
if (!this._id)
|
|
12
|
+
throw new Error("TriggerZone not spawned. Call .spawn(ctx) first.");
|
|
13
|
+
return this._id;
|
|
14
|
+
}
|
|
15
|
+
get isSpawned() {
|
|
16
|
+
return this._id !== null;
|
|
17
|
+
}
|
|
18
|
+
spawn(ctx) {
|
|
19
|
+
if (this._id)
|
|
20
|
+
throw new Error("TriggerZone already spawned.");
|
|
21
|
+
this._ctx = ctx;
|
|
22
|
+
this._id = ctx.createTriggerZone(this.options.position, this.options.size, this.options.onEnter, this.options.onLeave);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
remove() {
|
|
26
|
+
if (!this._ctx || !this._id) {
|
|
27
|
+
throw new Error("TriggerZone not spawned. Call .spawn(ctx) first.");
|
|
28
|
+
}
|
|
29
|
+
this._ctx.removeTriggerZone(this._id);
|
|
30
|
+
this._id = null;
|
|
31
|
+
this._ctx = null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.TriggerZone = TriggerZone;
|
|
35
|
+
//# sourceMappingURL=TriggerZone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TriggerZone.js","sourceRoot":"","sources":["../../src/objects/TriggerZone.ts"],"names":[],"mappings":";;;AAcA,MAAa,WAAW;IAKtB,YAAY,OAA2B;QAJ/B,QAAG,GAAkB,IAAI,CAAC;QAC1B,SAAI,GAAyB,IAAI,CAAC;QAIxC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,IAAI,EAAE;QACJ,IAAI,CAAC,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACnF,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,GAAkB;QACtB,IAAI,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAC9D,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,iBAAiB,CAC9B,IAAI,CAAC,OAAO,CAAC,QAAQ,EACrB,IAAI,CAAC,OAAO,CAAC,IAAI,EACjB,IAAI,CAAC,OAAO,CAAC,OAAO,EACpB,IAAI,CAAC,OAAO,CAAC,OAAO,CACrB,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACtE,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAtCD,kCAsCC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IWorldContext, SpawnVehicleOptions } from "../context";
|
|
2
|
+
import { IVehicle } from "../entities";
|
|
3
|
+
import { Vector3 } from "../math";
|
|
4
|
+
export type VehicleSpawnOptions = {
|
|
5
|
+
position: Vector3;
|
|
6
|
+
options: SpawnVehicleOptions;
|
|
7
|
+
};
|
|
8
|
+
export declare class Vehicle {
|
|
9
|
+
private _vehicle;
|
|
10
|
+
private readonly config;
|
|
11
|
+
constructor(config: VehicleSpawnOptions);
|
|
12
|
+
get isSpawned(): boolean;
|
|
13
|
+
spawn(ctx: IWorldContext): this;
|
|
14
|
+
static fromExisting(vehicle: IVehicle): Vehicle;
|
|
15
|
+
private requireSpawned;
|
|
16
|
+
get raw(): IVehicle;
|
|
17
|
+
get id(): string;
|
|
18
|
+
get position(): Vector3;
|
|
19
|
+
despawn(): void;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=Vehicle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Vehicle.d.ts","sourceRoot":"","sources":["../../src/objects/Vehicle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,mBAAmB,CAAC;CAC9B,CAAC;AAEF,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAyB;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;gBAEjC,MAAM,EAAE,mBAAmB;IAIvC,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI;IAM/B,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IAS/C,OAAO,CAAC,cAAc;IAOtB,IAAI,GAAG,IAAI,QAAQ,CAElB;IAED,IAAI,EAAE,IAAI,MAAM,CAEf;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,OAAO,IAAI,IAAI;CAIhB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Vehicle = void 0;
|
|
4
|
+
class Vehicle {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this._vehicle = null;
|
|
7
|
+
this.config = config;
|
|
8
|
+
}
|
|
9
|
+
get isSpawned() {
|
|
10
|
+
return this._vehicle !== null;
|
|
11
|
+
}
|
|
12
|
+
spawn(ctx) {
|
|
13
|
+
if (this._vehicle)
|
|
14
|
+
throw new Error("Vehicle already spawned.");
|
|
15
|
+
this._vehicle = ctx.spawnVehicle(this.config.position, this.config.options);
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
static fromExisting(vehicle) {
|
|
19
|
+
const instance = new Vehicle({
|
|
20
|
+
position: vehicle.position,
|
|
21
|
+
options: { type: "car" },
|
|
22
|
+
});
|
|
23
|
+
instance._vehicle = vehicle;
|
|
24
|
+
return instance;
|
|
25
|
+
}
|
|
26
|
+
requireSpawned() {
|
|
27
|
+
if (!this._vehicle) {
|
|
28
|
+
throw new Error("Vehicle not spawned. Call .spawn(ctx) first.");
|
|
29
|
+
}
|
|
30
|
+
return this._vehicle;
|
|
31
|
+
}
|
|
32
|
+
get raw() {
|
|
33
|
+
return this.requireSpawned();
|
|
34
|
+
}
|
|
35
|
+
get id() {
|
|
36
|
+
return this.requireSpawned().id;
|
|
37
|
+
}
|
|
38
|
+
get position() {
|
|
39
|
+
return this.requireSpawned().position;
|
|
40
|
+
}
|
|
41
|
+
despawn() {
|
|
42
|
+
this.requireSpawned().despawn();
|
|
43
|
+
this._vehicle = null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.Vehicle = Vehicle;
|
|
47
|
+
//# sourceMappingURL=Vehicle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Vehicle.js","sourceRoot":"","sources":["../../src/objects/Vehicle.ts"],"names":[],"mappings":";;;AASA,MAAa,OAAO;IAIlB,YAAY,MAA2B;QAH/B,aAAQ,GAAoB,IAAI,CAAC;QAIvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,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VoxelBlockOptions } from "../context";
|
|
2
|
+
export declare class VoxelBlock {
|
|
3
|
+
readonly x: number;
|
|
4
|
+
readonly y: number;
|
|
5
|
+
readonly z: number;
|
|
6
|
+
private _ctx;
|
|
7
|
+
private readonly options;
|
|
8
|
+
constructor(x: number, y: number, z: number, options: VoxelBlockOptions);
|
|
9
|
+
get isSpawned(): boolean;
|
|
10
|
+
spawn(ctx: IWorldContext): this;
|
|
11
|
+
private requireSpawned;
|
|
12
|
+
set(options: VoxelBlockOptions): this;
|
|
13
|
+
get(): VoxelBlockOptions | null;
|
|
14
|
+
remove(): void;
|
|
15
|
+
static setMany(blocks: VoxelBlockDef[], ctx: IWorldContext): void;
|
|
16
|
+
static get(x: number, y: number, z: number, ctx: IWorldContext): VoxelBlockOptions | null;
|
|
17
|
+
static remove(x: number, y: number, z: number, ctx: IWorldContext): void;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=VoxelBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VoxelBlock.d.ts","sourceRoot":"","sources":["../../src/objects/VoxelBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,aAAa,EACb,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,qBAAa,UAAU;IACrB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,IAAI,CAA8B;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;gBAEhC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB;IAOvE,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI;IAO/B,OAAO,CAAC,cAAc;IAOtB,GAAG,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAMrC,GAAG,IAAI,iBAAiB,GAAG,IAAI;IAK/B,MAAM,IAAI,IAAI;IAMd,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,GAAG,EAAE,aAAa,GAAG,IAAI;IAIjE,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,GAAG,iBAAiB,GAAG,IAAI;IAIzF,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,GAAG,IAAI;CAGzE"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VoxelBlock = void 0;
|
|
4
|
+
class VoxelBlock {
|
|
5
|
+
constructor(x, y, z, options) {
|
|
6
|
+
this._ctx = null;
|
|
7
|
+
this.x = Math.round(x);
|
|
8
|
+
this.y = Math.round(y);
|
|
9
|
+
this.z = Math.round(z);
|
|
10
|
+
this.options = options;
|
|
11
|
+
}
|
|
12
|
+
get isSpawned() {
|
|
13
|
+
return this._ctx !== null;
|
|
14
|
+
}
|
|
15
|
+
spawn(ctx) {
|
|
16
|
+
if (this._ctx)
|
|
17
|
+
throw new Error("VoxelBlock already spawned.");
|
|
18
|
+
this._ctx = ctx;
|
|
19
|
+
ctx.setVoxelBlock(this.x, this.y, this.z, this.options);
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
requireSpawned() {
|
|
23
|
+
if (!this._ctx) {
|
|
24
|
+
throw new Error("VoxelBlock not spawned. Call .spawn(ctx) first.");
|
|
25
|
+
}
|
|
26
|
+
return this._ctx;
|
|
27
|
+
}
|
|
28
|
+
set(options) {
|
|
29
|
+
const ctx = this.requireSpawned();
|
|
30
|
+
ctx.setVoxelBlock(this.x, this.y, this.z, options);
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
get() {
|
|
34
|
+
const ctx = this.requireSpawned();
|
|
35
|
+
return ctx.getVoxelBlock(this.x, this.y, this.z);
|
|
36
|
+
}
|
|
37
|
+
remove() {
|
|
38
|
+
const ctx = this.requireSpawned();
|
|
39
|
+
ctx.removeVoxelBlock(this.x, this.y, this.z);
|
|
40
|
+
this._ctx = null;
|
|
41
|
+
}
|
|
42
|
+
static setMany(blocks, ctx) {
|
|
43
|
+
ctx.setVoxelBlocks(blocks);
|
|
44
|
+
}
|
|
45
|
+
static get(x, y, z, ctx) {
|
|
46
|
+
return ctx.getVoxelBlock(x, y, z);
|
|
47
|
+
}
|
|
48
|
+
static remove(x, y, z, ctx) {
|
|
49
|
+
ctx.removeVoxelBlock(x, y, z);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.VoxelBlock = VoxelBlock;
|
|
53
|
+
//# sourceMappingURL=VoxelBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VoxelBlock.js","sourceRoot":"","sources":["../../src/objects/VoxelBlock.ts"],"names":[],"mappings":";;;AAMA,MAAa,UAAU;IAOrB,YAAY,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,OAA0B;QAH/D,SAAI,GAAyB,IAAI,CAAC;QAIxC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACvB,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACvB,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC;IAC5B,CAAC;IAED,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IAC7B,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,GAAkB;QAC5D,OAAO,GAAG,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,GAAkB;QAC/D,GAAG,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAChC,CAAC;CACF;AA5DD,gCA4DC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./Primitive";
|
|
2
|
+
export * from "./Terrain";
|
|
3
|
+
export * from "./TriggerZone";
|
|
4
|
+
export * from "./Prop";
|
|
5
|
+
export * from "./Model";
|
|
6
|
+
export * from "./VoxelBlock";
|
|
7
|
+
export * from "./NPC";
|
|
8
|
+
export * from "./Vehicle";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/objects/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Primitive"), exports);
|
|
18
|
+
__exportStar(require("./Terrain"), exports);
|
|
19
|
+
__exportStar(require("./TriggerZone"), exports);
|
|
20
|
+
__exportStar(require("./Prop"), exports);
|
|
21
|
+
__exportStar(require("./Model"), exports);
|
|
22
|
+
__exportStar(require("./VoxelBlock"), exports);
|
|
23
|
+
__exportStar(require("./NPC"), exports);
|
|
24
|
+
__exportStar(require("./Vehicle"), exports);
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/objects/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,4CAA0B;AAC1B,gDAA8B;AAC9B,yCAAuB;AACvB,0CAAwB;AACxB,+CAA6B;AAC7B,wCAAsB;AACtB,4CAA0B"}
|