@rooms.sh/sdk 0.0.1 → 0.0.3

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.
Files changed (2) hide show
  1. package/dist/index.js +82 -20
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -159,13 +159,17 @@ function validateRoomDefinition(room, overrides = {}) {
159
159
  }
160
160
  const itemEntries = Object.entries(room.items);
161
161
  if (itemEntries.length > options.maxItems) {
162
- throw new Error(`Room has too many item definitions (${itemEntries.length})`);
162
+ throw new Error(
163
+ `Room has too many item definitions (${itemEntries.length})`
164
+ );
163
165
  }
164
166
  if (room.instances.length > options.maxInstances) {
165
167
  throw new Error(`Room has too many instances (${room.instances.length})`);
166
168
  }
167
169
  if ((room.lights?.length ?? 0) > options.maxLights) {
168
- throw new Error(`Room has too many room lights (${room.lights?.length ?? 0})`);
170
+ throw new Error(
171
+ `Room has too many room lights (${room.lights?.length ?? 0})`
172
+ );
169
173
  }
170
174
  if (!room.cameras[room.defaultCamera]) {
171
175
  throw new Error(`Default camera "${room.defaultCamera}" does not exist`);
@@ -177,44 +181,78 @@ function validateRoomDefinition(room, overrides = {}) {
177
181
  for (const [index, node] of item2.nodes.entries()) {
178
182
  assertTransform(node, `room.items.${itemId}.nodes[${index}]`);
179
183
  if (node.kind === "mesh") {
180
- validateGeometry(node.geometry, `room.items.${itemId}.nodes[${index}].geometry`);
184
+ validateGeometry(
185
+ node.geometry,
186
+ `room.items.${itemId}.nodes[${index}].geometry`
187
+ );
181
188
  }
182
189
  if (node.kind === "item" && !room.items[node.itemId]) {
183
- throw new Error(`Item "${itemId}" references missing child item "${node.itemId}"`);
190
+ throw new Error(
191
+ `Item "${itemId}" references missing child item "${node.itemId}"`
192
+ );
184
193
  }
185
194
  }
186
195
  }
187
196
  for (const instance of room.instances) {
188
197
  if (!room.items[instance.itemId]) {
189
- throw new Error(`Instance "${instance.id}" references missing item "${instance.itemId}"`);
198
+ throw new Error(
199
+ `Instance "${instance.id}" references missing item "${instance.itemId}"`
200
+ );
190
201
  }
191
202
  if (instance.placement.mode === "free") {
192
- assertVec3(instance.placement.position, `room.instances.${instance.id}.placement.position`);
193
- assertEuler(instance.placement.rotation, `room.instances.${instance.id}.placement.rotation`);
194
- assertVec3(instance.placement.scale, `room.instances.${instance.id}.placement.scale`);
203
+ assertVec3(
204
+ instance.placement.position,
205
+ `room.instances.${instance.id}.placement.position`
206
+ );
207
+ assertEuler(
208
+ instance.placement.rotation,
209
+ `room.instances.${instance.id}.placement.rotation`
210
+ );
211
+ assertVec3(
212
+ instance.placement.scale,
213
+ `room.instances.${instance.id}.placement.scale`
214
+ );
195
215
  continue;
196
216
  }
197
217
  if (instance.placement.mode === "floor") {
198
- assertFiniteNumber(instance.placement.x, `room.instances.${instance.id}.placement.x`);
199
- assertFiniteNumber(instance.placement.z, `room.instances.${instance.id}.placement.z`);
218
+ assertFiniteNumber(
219
+ instance.placement.x,
220
+ `room.instances.${instance.id}.placement.x`
221
+ );
222
+ assertFiniteNumber(
223
+ instance.placement.z,
224
+ `room.instances.${instance.id}.placement.z`
225
+ );
200
226
  if (instance.placement.rotationY !== void 0) {
201
227
  assertFiniteNumber(
202
228
  instance.placement.rotationY,
203
229
  `room.instances.${instance.id}.placement.rotationY`
204
230
  );
205
231
  }
206
- assertVec3(instance.placement.scale, `room.instances.${instance.id}.placement.scale`);
232
+ assertVec3(
233
+ instance.placement.scale,
234
+ `room.instances.${instance.id}.placement.scale`
235
+ );
207
236
  continue;
208
237
  }
209
- assertFiniteNumber(instance.placement.offset, `room.instances.${instance.id}.placement.offset`);
210
- assertFiniteNumber(instance.placement.bottom, `room.instances.${instance.id}.placement.bottom`);
238
+ assertFiniteNumber(
239
+ instance.placement.offset,
240
+ `room.instances.${instance.id}.placement.offset`
241
+ );
242
+ assertFiniteNumber(
243
+ instance.placement.bottom,
244
+ `room.instances.${instance.id}.placement.bottom`
245
+ );
211
246
  if (instance.placement.rotationY !== void 0) {
212
247
  assertFiniteNumber(
213
248
  instance.placement.rotationY,
214
249
  `room.instances.${instance.id}.placement.rotationY`
215
250
  );
216
251
  }
217
- assertVec3(instance.placement.scale, `room.instances.${instance.id}.placement.scale`);
252
+ assertVec3(
253
+ instance.placement.scale,
254
+ `room.instances.${instance.id}.placement.scale`
255
+ );
218
256
  }
219
257
  for (const camera of Object.values(room.cameras)) {
220
258
  assertVec3(camera.position, "room.cameras.position");
@@ -310,10 +348,26 @@ var geometry = {
310
348
  p,
311
349
  q
312
350
  }),
313
- tetrahedron: (radius = 1, detail = 0) => ({ type: "tetrahedron", radius, detail }),
314
- octahedron: (radius = 1, detail = 0) => ({ type: "octahedron", radius, detail }),
315
- icosahedron: (radius = 1, detail = 0) => ({ type: "icosahedron", radius, detail }),
316
- dodecahedron: (radius = 1, detail = 0) => ({ type: "dodecahedron", radius, detail }),
351
+ tetrahedron: (radius = 1, detail = 0) => ({
352
+ type: "tetrahedron",
353
+ radius,
354
+ detail
355
+ }),
356
+ octahedron: (radius = 1, detail = 0) => ({
357
+ type: "octahedron",
358
+ radius,
359
+ detail
360
+ }),
361
+ icosahedron: (radius = 1, detail = 0) => ({
362
+ type: "icosahedron",
363
+ radius,
364
+ detail
365
+ }),
366
+ dodecahedron: (radius = 1, detail = 0) => ({
367
+ type: "dodecahedron",
368
+ radius,
369
+ detail
370
+ }),
317
371
  polyhedron: (vertices, indices, radius = 1, detail = 0) => ({
318
372
  type: "polyhedron",
319
373
  vertices,
@@ -321,14 +375,22 @@ var geometry = {
321
375
  radius,
322
376
  detail
323
377
  }),
324
- shape: (path, depth = 0) => ({ type: "shape", path, depth }),
378
+ shape: (path, depth = 0) => ({
379
+ type: "shape",
380
+ path,
381
+ depth
382
+ }),
325
383
  extrude: (path, depth, bevelEnabled = false) => ({
326
384
  type: "extrude",
327
385
  path,
328
386
  depth,
329
387
  bevelEnabled
330
388
  }),
331
- lathe: (points, segments = 12) => ({ type: "lathe", points, segments }),
389
+ lathe: (points, segments = 12) => ({
390
+ type: "lathe",
391
+ points,
392
+ segments
393
+ }),
332
394
  tube: (points, tubularSegments = 32, radius = 0.02, radialSegments = 8, closed = false) => ({
333
395
  type: "tube",
334
396
  points,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rooms.sh/sdk",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",