@thestatic-tv/dcl-sdk 2.10.0 → 2.10.1

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/README.md CHANGED
@@ -134,7 +134,9 @@ who is already inside, and KICK ALL works. Each visitor's copy of the scene read
134
134
  at load, on entering the scene, once a minute while inside, and at once when a kick names its wallet.
135
135
 
136
136
  - **Banned:** the SDK raises a wall over each of your parcels (any shape of scene, an L included), moves the visitor
137
- to just above the walls if they are inside one, and shows them only a notice. No guide, chat, admin panel or SDK
137
+ to your scene's front entry (the 1 m strip outside the walls beside your default spawn point in `scene.json`, at
138
+ its height; with no spawn point, the edge nearest them, on the ground) from anywhere else on your parcels, at any
139
+ height, and shows them only a notice. No guide, chat, admin panel or SDK
138
140
  video while it lasts. The walls start 1 m in from your scene's outer edges, so someone walking in from outside sees
139
141
  the notice before they reach a wall.
140
142
  - **KICK ALL:** every visitor who cannot moderate the scene gets the same for two minutes. Moderators stay.
package/dist/index.d.mts CHANGED
@@ -1065,6 +1065,7 @@ declare class ModerationModule {
1065
1065
  private readWaiters;
1066
1066
  private rects;
1067
1067
  private boxes;
1068
+ private spawn;
1068
1069
  private wallEntities;
1069
1070
  private lastBlocked;
1070
1071
  private lastStanding;
@@ -1117,7 +1118,7 @@ declare class ModerationModule {
1117
1118
  private lowerWalls;
1118
1119
  /** The walls this copy has up (one per parcel while blocked) */
1119
1120
  get wallCount(): number;
1120
- /** Every CHECK_EVERY_S: a lapsed kick, the re-reads, and a blocked visitor inside a wall moved above it */
1121
+ /** Every CHECK_EVERY_S: a lapsed kick, the re-reads, and a blocked visitor out of place moved to the front entry */
1121
1122
  system: (dt: number) => void;
1122
1123
  }
1123
1124
 
package/dist/index.d.ts CHANGED
@@ -1065,6 +1065,7 @@ declare class ModerationModule {
1065
1065
  private readWaiters;
1066
1066
  private rects;
1067
1067
  private boxes;
1068
+ private spawn;
1068
1069
  private wallEntities;
1069
1070
  private lastBlocked;
1070
1071
  private lastStanding;
@@ -1117,7 +1118,7 @@ declare class ModerationModule {
1117
1118
  private lowerWalls;
1118
1119
  /** The walls this copy has up (one per parcel while blocked) */
1119
1120
  get wallCount(): number;
1120
- /** Every CHECK_EVERY_S: a lapsed kick, the re-reads, and a blocked visitor inside a wall moved above it */
1121
+ /** Every CHECK_EVERY_S: a lapsed kick, the re-reads, and a blocked visitor out of place moved to the front entry */
1121
1122
  system: (dt: number) => void;
1122
1123
  }
1123
1124
 
package/dist/index.js CHANGED
@@ -265,6 +265,7 @@ var import_Runtime = require("~system/Runtime");
265
265
  var PARCEL_SIZE = 16;
266
266
  var EDGE_STRIP = 1;
267
267
  var WALL_TOP_MAX = 32;
268
+ var GROUND_REACH = 3;
268
269
  function heightLimit(parcels) {
269
270
  return Math.log2(parcels + 1) * 20;
270
271
  }
@@ -311,13 +312,25 @@ function wallBoxes(rects, strip = EDGE_STRIP, top = wallTop(rects.length)) {
311
312
  function inParcels(p, rects) {
312
313
  return rects.some((r) => p.x >= r.minX && p.x <= r.maxX && p.z >= r.minZ && p.z <= r.maxZ);
313
314
  }
314
- function insideWalls(p, boxes) {
315
- return boxes.some((b) => p.x >= b.minX && p.x <= b.maxX && p.z >= b.minZ && p.z <= b.maxZ && p.y < b.top);
315
+ function spawnPointOf(metadata) {
316
+ const points = metadata?.spawnPoints;
317
+ if (!Array.isArray(points) || points.length === 0) return null;
318
+ const chosen = points.find((s) => s && s.default === true) || points[0];
319
+ const position = chosen?.position;
320
+ const coordinate = (v) => {
321
+ const values = (Array.isArray(v) ? v : [v]).filter((n) => typeof n === "number" && Number.isFinite(n));
322
+ return values.length === 0 ? null : (Math.min(...values) + Math.max(...values)) / 2;
323
+ };
324
+ const x = coordinate(position?.x);
325
+ const y = coordinate(position?.y);
326
+ const z = coordinate(position?.z);
327
+ return x === null || y === null || z === null ? null : { x, y, z };
316
328
  }
317
329
  var clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
318
- function ejectPoint(boxes, rects, from) {
330
+ function entryPoint(boxes, rects, spawn, from) {
319
331
  const IN = 0.5;
320
- const p = from || { x: 0, y: 0, z: 0 };
332
+ const target = spawn || from || { x: 0, y: 0, z: 0 };
333
+ const y = spawn ? Math.max(0, spawn.y) : 0;
321
334
  let best = null;
322
335
  let bestDistance = Infinity;
323
336
  rects.forEach((rect, i) => {
@@ -325,20 +338,26 @@ function ejectPoint(boxes, rects, from) {
325
338
  if (!b) return;
326
339
  const along = (lo, hi, v) => clamp(v, lo + IN, hi - IN);
327
340
  for (const side of outerSides(rect, rects)) {
328
- const point = side === "west" ? { x: b.minX + IN, z: along(b.minZ, b.maxZ, p.z) } : side === "east" ? { x: b.maxX - IN, z: along(b.minZ, b.maxZ, p.z) } : side === "south" ? { x: along(b.minX, b.maxX, p.x), z: b.minZ + IN } : { x: along(b.minX, b.maxX, p.x), z: b.maxZ - IN };
329
- const distance = Math.hypot(point.x - p.x, point.z - p.z);
341
+ const point = side === "west" ? { x: (rect.minX + b.minX) / 2, z: along(b.minZ, b.maxZ, target.z) } : side === "east" ? { x: (rect.maxX + b.maxX) / 2, z: along(b.minZ, b.maxZ, target.z) } : side === "south" ? { x: along(b.minX, b.maxX, target.x), z: (rect.minZ + b.minZ) / 2 } : { x: along(b.minX, b.maxX, target.x), z: (rect.maxZ + b.maxZ) / 2 };
342
+ const distance = Math.hypot(point.x - target.x, point.z - target.z);
330
343
  if (distance < bestDistance) {
331
344
  bestDistance = distance;
332
- best = { x: point.x, y: b.top + 1, z: point.z };
345
+ best = { x: point.x, y, z: point.z };
333
346
  }
334
347
  }
335
348
  });
336
349
  return best;
337
350
  }
351
+ function mustMoveToEntry(p, boxes, rects, entryY) {
352
+ if (!inParcels(p, rects)) return false;
353
+ const overWall = boxes.some((b) => p.x >= b.minX && p.x <= b.maxX && p.z >= b.minZ && p.z <= b.maxZ);
354
+ return overWall || p.y > entryY + GROUND_REACH;
355
+ }
338
356
 
339
357
  // src/utils/bounds.ts
340
358
  var cachedBounds = null;
341
359
  var cachedParcelRects = [];
360
+ var cachedSpawn = null;
342
361
  var boundsInitialized = false;
343
362
  var boundsError = false;
344
363
  function parseParcel(parcel) {
@@ -364,6 +383,7 @@ async function getSceneBounds() {
364
383
  const metadata = JSON.parse(sceneInfo.metadataJson);
365
384
  parcels = metadata?.scene?.parcels || [];
366
385
  baseParcel = metadata?.scene?.base;
386
+ cachedSpawn = spawnPointOf(metadata);
367
387
  }
368
388
  if (parcels.length === 0) {
369
389
  boundsError = true;
@@ -418,6 +438,9 @@ function isPlayerInBounds(_bounds) {
418
438
  function getParcelRects() {
419
439
  return cachedParcelRects.map((r) => ({ ...r }));
420
440
  }
441
+ function getSpawnPoint() {
442
+ return cachedSpawn ? { ...cachedSpawn } : null;
443
+ }
421
444
  function getPlayerPosition() {
422
445
  try {
423
446
  const transform = import_ecs2.Transform.getOrNull(import_ecs2.engine.PlayerEntity);
@@ -3279,6 +3302,7 @@ var ModerationModule = class {
3279
3302
  this.readWaiters = [];
3280
3303
  this.rects = [];
3281
3304
  this.boxes = [];
3305
+ this.spawn = null;
3282
3306
  this.wallEntities = [];
3283
3307
  this.lastBlocked = false;
3284
3308
  this.lastStanding = "clear";
@@ -3288,7 +3312,7 @@ var ModerationModule = class {
3288
3312
  this.wasInScene = null;
3289
3313
  this.sinceCheck = 0;
3290
3314
  this.started = false;
3291
- /** Every CHECK_EVERY_S: a lapsed kick, the re-reads, and a blocked visitor inside a wall moved above it */
3315
+ /** Every CHECK_EVERY_S: a lapsed kick, the re-reads, and a blocked visitor out of place moved to the front entry */
3292
3316
  this.system = (dt) => {
3293
3317
  if (this.hintDueAt !== null && this.now() >= this.hintDueAt) {
3294
3318
  this.hintDueAt = null;
@@ -3316,10 +3340,10 @@ var ModerationModule = class {
3316
3340
  if (inScene && now - this.lastReadAt >= REREAD_MS) this.readPending = true;
3317
3341
  this.wasInScene = inScene;
3318
3342
  this.tryRead();
3319
- if (me && this.blocked && insideWalls(me, this.boxes)) {
3320
- const to = ejectPoint(this.boxes, this.rects, me);
3321
- if (to) {
3322
- this.log("Blocked and inside the walls - moving above them", to);
3343
+ if (me && this.blocked) {
3344
+ const to = entryPoint(this.boxes, this.rects, this.spawn, me);
3345
+ if (to && mustMoveToEntry(me, this.boxes, this.rects, to.y)) {
3346
+ this.log("Blocked and inside the scene - moving to the front entry", to);
3323
3347
  Promise.resolve((0, import_RestrictedActions5.movePlayerTo)({ newRelativePosition: import_math6.Vector3.create(to.x, to.y, to.z) })).catch(() => {
3324
3348
  });
3325
3349
  }
@@ -3342,6 +3366,7 @@ var ModerationModule = class {
3342
3366
  await getSceneBounds();
3343
3367
  this.rects = getParcelRects();
3344
3368
  this.boxes = wallBoxes(this.rects);
3369
+ this.spawn = getSpawnPoint();
3345
3370
  } catch {
3346
3371
  }
3347
3372
  this.sync();
package/dist/index.mjs CHANGED
@@ -214,6 +214,7 @@ import { getSceneInformation } from "~system/Runtime";
214
214
  var PARCEL_SIZE = 16;
215
215
  var EDGE_STRIP = 1;
216
216
  var WALL_TOP_MAX = 32;
217
+ var GROUND_REACH = 3;
217
218
  function heightLimit(parcels) {
218
219
  return Math.log2(parcels + 1) * 20;
219
220
  }
@@ -260,13 +261,25 @@ function wallBoxes(rects, strip = EDGE_STRIP, top = wallTop(rects.length)) {
260
261
  function inParcels(p, rects) {
261
262
  return rects.some((r) => p.x >= r.minX && p.x <= r.maxX && p.z >= r.minZ && p.z <= r.maxZ);
262
263
  }
263
- function insideWalls(p, boxes) {
264
- return boxes.some((b) => p.x >= b.minX && p.x <= b.maxX && p.z >= b.minZ && p.z <= b.maxZ && p.y < b.top);
264
+ function spawnPointOf(metadata) {
265
+ const points = metadata?.spawnPoints;
266
+ if (!Array.isArray(points) || points.length === 0) return null;
267
+ const chosen = points.find((s) => s && s.default === true) || points[0];
268
+ const position = chosen?.position;
269
+ const coordinate = (v) => {
270
+ const values = (Array.isArray(v) ? v : [v]).filter((n) => typeof n === "number" && Number.isFinite(n));
271
+ return values.length === 0 ? null : (Math.min(...values) + Math.max(...values)) / 2;
272
+ };
273
+ const x = coordinate(position?.x);
274
+ const y = coordinate(position?.y);
275
+ const z = coordinate(position?.z);
276
+ return x === null || y === null || z === null ? null : { x, y, z };
265
277
  }
266
278
  var clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
267
- function ejectPoint(boxes, rects, from) {
279
+ function entryPoint(boxes, rects, spawn, from) {
268
280
  const IN = 0.5;
269
- const p = from || { x: 0, y: 0, z: 0 };
281
+ const target = spawn || from || { x: 0, y: 0, z: 0 };
282
+ const y = spawn ? Math.max(0, spawn.y) : 0;
270
283
  let best = null;
271
284
  let bestDistance = Infinity;
272
285
  rects.forEach((rect, i) => {
@@ -274,20 +287,26 @@ function ejectPoint(boxes, rects, from) {
274
287
  if (!b) return;
275
288
  const along = (lo, hi, v) => clamp(v, lo + IN, hi - IN);
276
289
  for (const side of outerSides(rect, rects)) {
277
- const point = side === "west" ? { x: b.minX + IN, z: along(b.minZ, b.maxZ, p.z) } : side === "east" ? { x: b.maxX - IN, z: along(b.minZ, b.maxZ, p.z) } : side === "south" ? { x: along(b.minX, b.maxX, p.x), z: b.minZ + IN } : { x: along(b.minX, b.maxX, p.x), z: b.maxZ - IN };
278
- const distance = Math.hypot(point.x - p.x, point.z - p.z);
290
+ const point = side === "west" ? { x: (rect.minX + b.minX) / 2, z: along(b.minZ, b.maxZ, target.z) } : side === "east" ? { x: (rect.maxX + b.maxX) / 2, z: along(b.minZ, b.maxZ, target.z) } : side === "south" ? { x: along(b.minX, b.maxX, target.x), z: (rect.minZ + b.minZ) / 2 } : { x: along(b.minX, b.maxX, target.x), z: (rect.maxZ + b.maxZ) / 2 };
291
+ const distance = Math.hypot(point.x - target.x, point.z - target.z);
279
292
  if (distance < bestDistance) {
280
293
  bestDistance = distance;
281
- best = { x: point.x, y: b.top + 1, z: point.z };
294
+ best = { x: point.x, y, z: point.z };
282
295
  }
283
296
  }
284
297
  });
285
298
  return best;
286
299
  }
300
+ function mustMoveToEntry(p, boxes, rects, entryY) {
301
+ if (!inParcels(p, rects)) return false;
302
+ const overWall = boxes.some((b) => p.x >= b.minX && p.x <= b.maxX && p.z >= b.minZ && p.z <= b.maxZ);
303
+ return overWall || p.y > entryY + GROUND_REACH;
304
+ }
287
305
 
288
306
  // src/utils/bounds.ts
289
307
  var cachedBounds = null;
290
308
  var cachedParcelRects = [];
309
+ var cachedSpawn = null;
291
310
  var boundsInitialized = false;
292
311
  var boundsError = false;
293
312
  function parseParcel(parcel) {
@@ -313,6 +332,7 @@ async function getSceneBounds() {
313
332
  const metadata = JSON.parse(sceneInfo.metadataJson);
314
333
  parcels = metadata?.scene?.parcels || [];
315
334
  baseParcel = metadata?.scene?.base;
335
+ cachedSpawn = spawnPointOf(metadata);
316
336
  }
317
337
  if (parcels.length === 0) {
318
338
  boundsError = true;
@@ -367,6 +387,9 @@ function isPlayerInBounds(_bounds) {
367
387
  function getParcelRects() {
368
388
  return cachedParcelRects.map((r) => ({ ...r }));
369
389
  }
390
+ function getSpawnPoint() {
391
+ return cachedSpawn ? { ...cachedSpawn } : null;
392
+ }
370
393
  function getPlayerPosition() {
371
394
  try {
372
395
  const transform = Transform.getOrNull(engine2.PlayerEntity);
@@ -3228,6 +3251,7 @@ var ModerationModule = class {
3228
3251
  this.readWaiters = [];
3229
3252
  this.rects = [];
3230
3253
  this.boxes = [];
3254
+ this.spawn = null;
3231
3255
  this.wallEntities = [];
3232
3256
  this.lastBlocked = false;
3233
3257
  this.lastStanding = "clear";
@@ -3237,7 +3261,7 @@ var ModerationModule = class {
3237
3261
  this.wasInScene = null;
3238
3262
  this.sinceCheck = 0;
3239
3263
  this.started = false;
3240
- /** Every CHECK_EVERY_S: a lapsed kick, the re-reads, and a blocked visitor inside a wall moved above it */
3264
+ /** Every CHECK_EVERY_S: a lapsed kick, the re-reads, and a blocked visitor out of place moved to the front entry */
3241
3265
  this.system = (dt) => {
3242
3266
  if (this.hintDueAt !== null && this.now() >= this.hintDueAt) {
3243
3267
  this.hintDueAt = null;
@@ -3265,10 +3289,10 @@ var ModerationModule = class {
3265
3289
  if (inScene && now - this.lastReadAt >= REREAD_MS) this.readPending = true;
3266
3290
  this.wasInScene = inScene;
3267
3291
  this.tryRead();
3268
- if (me && this.blocked && insideWalls(me, this.boxes)) {
3269
- const to = ejectPoint(this.boxes, this.rects, me);
3270
- if (to) {
3271
- this.log("Blocked and inside the walls - moving above them", to);
3292
+ if (me && this.blocked) {
3293
+ const to = entryPoint(this.boxes, this.rects, this.spawn, me);
3294
+ if (to && mustMoveToEntry(me, this.boxes, this.rects, to.y)) {
3295
+ this.log("Blocked and inside the scene - moving to the front entry", to);
3272
3296
  Promise.resolve(movePlayerTo({ newRelativePosition: Vector3.create(to.x, to.y, to.z) })).catch(() => {
3273
3297
  });
3274
3298
  }
@@ -3291,6 +3315,7 @@ var ModerationModule = class {
3291
3315
  await getSceneBounds();
3292
3316
  this.rects = getParcelRects();
3293
3317
  this.boxes = wallBoxes(this.rects);
3318
+ this.spawn = getSpawnPoint();
3294
3319
  } catch {
3295
3320
  }
3296
3321
  this.sync();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thestatic-tv/dcl-sdk",
3
- "version": "2.10.0",
3
+ "version": "2.10.1",
4
4
  "description": "Connect your Decentraland scene to thestatic.tv - full channel lineup, metrics tracking, and interactions",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",