@umicat/three-sdk 0.8.3 → 0.8.5

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/Input3D.d.ts CHANGED
@@ -55,6 +55,17 @@ export interface Input3DOptions {
55
55
  /** Radians of camera rotation per screen-width dragged. Same number governs
56
56
  * touch drags and desktop right-drags, so there is one knob to turn. */
57
57
  lookSensitivity?: number;
58
+ /**
59
+ * How much of the top of the screen the move and look zones leave alone.
60
+ *
61
+ * A HUD lives at the top — score, hearts, a mute button — and the zones are
62
+ * full-screen and sit ABOVE the game's DOM, so without this every button up
63
+ * there is unreachable on a phone while looking perfectly fine. Nobody
64
+ * drives a thumbstick from the top edge, so the trade is free.
65
+ *
66
+ * A CSS length; the default is `max(64px, 12%)`.
67
+ */
68
+ controlsTopInset?: string;
58
69
  }
59
70
  /**
60
71
  * Movement and jump, from a keyboard or a thumb, behind one interface.
@@ -82,6 +93,7 @@ export declare class Input3D {
82
93
  private actions;
83
94
  private stickMode;
84
95
  private wantLook;
96
+ private topInset;
85
97
  private lookSens;
86
98
  private readonly lookDelta;
87
99
  private enabled;
package/dist/Input3D.js CHANGED
@@ -69,6 +69,7 @@ export class Input3D {
69
69
  this.actions = [];
70
70
  this.stickMode = 'floating';
71
71
  this.wantLook = true;
72
+ this.topInset = 'max(64px, 12%)';
72
73
  this.lookSens = 4.6;
73
74
  this.lookDelta = { x: 0, y: 0 };
74
75
  this.enabled = true;
@@ -88,6 +89,7 @@ export class Input3D {
88
89
  this.actions = opts.actions ?? [];
89
90
  this.stickMode = opts.stick ?? 'floating';
90
91
  this.wantLook = opts.look ?? true;
92
+ this.topInset = opts.controlsTopInset ?? 'max(64px, 12%)';
91
93
  this.lookSens = opts.lookSensitivity ?? 4.6;
92
94
  if (this.wantLook && typeof document !== 'undefined') {
93
95
  this.mountMouseLook(opts.container?.ownerDocument ?? document);
@@ -314,7 +316,7 @@ export class Input3D {
314
316
  // anything. It deliberately stops short of the buttons on the right.
315
317
  const zone = document.createElement('div');
316
318
  Object.assign(zone.style, {
317
- position: 'absolute', left: '0', top: '0', width: '50%', height: '100%',
319
+ position: 'absolute', left: '0', top: this.topInset, width: '50%', bottom: '0',
318
320
  pointerEvents: floating ? 'auto' : 'none',
319
321
  });
320
322
  Object.assign(zone.style, NO_SELECTION);
@@ -323,7 +325,7 @@ export class Input3D {
323
325
  // can be the whole right half rather than an awkward cut-out around them.
324
326
  const lookZone = document.createElement('div');
325
327
  Object.assign(lookZone.style, {
326
- position: 'absolute', right: '0', top: '0', width: '50%', height: '100%',
328
+ position: 'absolute', right: '0', top: this.topInset, width: '50%', bottom: '0',
327
329
  pointerEvents: this.wantLook ? 'auto' : 'none',
328
330
  });
329
331
  Object.assign(lookZone.style, NO_SELECTION);
@@ -132,7 +132,7 @@ export async function loadScene3D(scene3d, manifest, opts = {}) {
132
132
  const mesh = o;
133
133
  if (!mesh.isMesh)
134
134
  return;
135
- mesh.castShadow = true;
135
+ mesh.castShadow = e.castShadow !== false;
136
136
  mesh.receiveShadow = true;
137
137
  // A SkinnedMesh's bounding sphere is computed from the BIND pose and
138
138
  // does not follow the bones. Once the object moves, three.js culls it
@@ -242,7 +242,14 @@ export async function loadScene3D(scene3d, manifest, opts = {}) {
242
242
  // would otherwise be lit from the side of a box centred somewhere else.
243
243
  d.target.position.copy(centre);
244
244
  scene.add(d.target);
245
- d.shadow.mapSize.set(2048, 2048);
245
+ // Sized for the DEVICE, not for the desktop it was written on. A
246
+ // 2048 map is four megapixels of extra render target every frame, and
247
+ // a phone is already drawing at 2x for its screen — that combination
248
+ // took a board from smooth on a laptop to visibly dropping frames on
249
+ // an iPhone while looking identical in a screenshot.
250
+ const dense = typeof window !== 'undefined' && (window.devicePixelRatio ?? 1) > 2;
251
+ const map = dense ? 512 : 1024;
252
+ d.shadow.mapSize.set(map, map);
246
253
  d.shadow.bias = -0.0012;
247
254
  }
248
255
  }
package/dist/scene3d.d.ts CHANGED
@@ -83,6 +83,15 @@ export interface Entity3D {
83
83
  /** Free-form, read by game code. The 2D SDK's `properties` equivalent. */
84
84
  properties?: Record<string, unknown>;
85
85
  visible?: boolean;
86
+ /**
87
+ * Whether this entity casts a shadow. Defaults to true.
88
+ *
89
+ * Set it false for ground: a flat tile casting onto the flat tile beside it
90
+ * produces nothing anyone can see and costs a full extra draw of that mesh
91
+ * every frame. A board made of 144 tiles was drawing 288 times for 144
92
+ * tiles' worth of picture.
93
+ */
94
+ castShadow?: boolean;
86
95
  }
87
96
  /**
88
97
  * Semantic clip name → the clip actually inside the model.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umicat/three-sdk",
3
- "version": "0.8.3",
3
+ "version": "0.8.5",
4
4
  "description": "Three.js runtime for Umicat games: the scene3d design format, its loader with physics, a kinematic character controller, and the Umicat platform via @umicat/platform-sdk.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",