@umicat/three-sdk 1.30.0 → 1.32.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/dist/Input3D.js
CHANGED
|
@@ -680,13 +680,27 @@ export class Input3D {
|
|
|
680
680
|
}
|
|
681
681
|
if (jumpBtn) {
|
|
682
682
|
const jb = jumpBtn;
|
|
683
|
+
// Tracked by pointerId for the same reason the stick/look zone are —
|
|
684
|
+
// without it, a SECOND finger landing on (and releasing from) this
|
|
685
|
+
// same button clears `touchJump` unconditionally, even while the
|
|
686
|
+
// FIRST finger is still physically holding it down. The release
|
|
687
|
+
// handlers below used to take no event parameter at all and just
|
|
688
|
+
// zeroed the flag outright; they now only do that for the finger
|
|
689
|
+
// that actually set it.
|
|
690
|
+
let jumpId = null;
|
|
683
691
|
on(jb, 'pointerdown', (e) => {
|
|
692
|
+
if (jumpId !== null)
|
|
693
|
+
return;
|
|
694
|
+
jumpId = e.pointerId;
|
|
684
695
|
jb.setPointerCapture(e.pointerId);
|
|
685
696
|
this.touchJump = true;
|
|
686
697
|
this.beginPress('jump');
|
|
687
698
|
});
|
|
688
699
|
for (const ev of ['pointerup', 'pointercancel', 'lostpointercapture']) {
|
|
689
|
-
on(jb, ev, () => {
|
|
700
|
+
on(jb, ev, (e) => { if (e.pointerId === jumpId) {
|
|
701
|
+
jumpId = null;
|
|
702
|
+
this.touchJump = false;
|
|
703
|
+
} });
|
|
690
704
|
}
|
|
691
705
|
}
|
|
692
706
|
}
|
|
@@ -696,9 +710,17 @@ export class Input3D {
|
|
|
696
710
|
el.addEventListener(ev, h);
|
|
697
711
|
this.cleanups.push(() => el.removeEventListener(ev, h));
|
|
698
712
|
};
|
|
713
|
+
// Same pointerId guard as the jump button above, scoped per-button (one
|
|
714
|
+
// `heldId` per `wireButton` call/element) — `touchHeld` is keyed by
|
|
715
|
+
// ACTION id, not pointer id, so without this a second finger tapping
|
|
716
|
+
// the same action button clears the first finger's still-held press.
|
|
717
|
+
let heldId = null;
|
|
699
718
|
on('pointerdown', (e) => {
|
|
700
719
|
// Cancels the selection gesture as well as the default press behaviour.
|
|
701
720
|
e.preventDefault();
|
|
721
|
+
if (heldId !== null)
|
|
722
|
+
return;
|
|
723
|
+
heldId = e.pointerId;
|
|
702
724
|
el.setPointerCapture(e.pointerId);
|
|
703
725
|
this.touchHeld.add(id);
|
|
704
726
|
this.beginPress(id);
|
|
@@ -706,7 +728,10 @@ export class Input3D {
|
|
|
706
728
|
// pointercancel included: a system gesture steals the pointer with no `up`,
|
|
707
729
|
// and the button would read as held for the rest of the run.
|
|
708
730
|
for (const ev of ['pointerup', 'pointercancel', 'lostpointercapture']) {
|
|
709
|
-
on(ev, () => {
|
|
731
|
+
on(ev, (e) => { if (e.pointerId === heldId) {
|
|
732
|
+
heldId = null;
|
|
733
|
+
this.touchHeld.delete(id);
|
|
734
|
+
} });
|
|
710
735
|
}
|
|
711
736
|
}
|
|
712
737
|
}
|
package/dist/ThreeUmicat.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UmicatCore } from '@umicat/platform-sdk/core/UmicatCore.js';
|
|
2
2
|
import { DialogueModule } from '@umicat/platform-sdk/dialogue/DialogueModule.js';
|
|
3
3
|
import { HudBinding3DNamespace } from './hud3d/HudDynamicBinding3D.js';
|
|
4
|
+
import { setupRecordingListener } from './capture/RecordingManager.js';
|
|
4
5
|
/** Kept in sync with package.json on each publish. */
|
|
5
6
|
const SDK_VERSION = '0.0.1';
|
|
6
7
|
/**
|
|
@@ -25,6 +26,18 @@ export class ThreeUmicat extends UmicatCore {
|
|
|
25
26
|
static async init(options = {}) {
|
|
26
27
|
const game = new ThreeUmicat(await UmicatCore.connect(SDK_VERSION, options));
|
|
27
28
|
announceScaleMode();
|
|
29
|
+
// Recording is a PLATFORM capability, not game logic — the editor's Play
|
|
30
|
+
// tab offers the button to every game regardless of engine, so every game
|
|
31
|
+
// has to be able to answer. Phaser games get this for free because
|
|
32
|
+
// `createUmicatGame` installs it centrally; this package has no such
|
|
33
|
+
// wrapper, so before this the listener was wired by each game's own
|
|
34
|
+
// `main.ts` — the 3D template does it, and every game older than that line
|
|
35
|
+
// (Balaboo, for one) simply could not record, with no error to say why.
|
|
36
|
+
// Installing here covers them all on the next SDK update. Safe to call
|
|
37
|
+
// even though the template ALSO calls it: it is idempotent, and it
|
|
38
|
+
// resolves the canvas at record time, not now — there is no renderer yet
|
|
39
|
+
// at init.
|
|
40
|
+
setupRecordingListener();
|
|
28
41
|
return game;
|
|
29
42
|
}
|
|
30
43
|
}
|
|
@@ -11,9 +11,16 @@ import type * as THREE from 'three';
|
|
|
11
11
|
* Parent sends: 'stopRecording'
|
|
12
12
|
* Game responds: { type: 'recordingComplete', data: string (base64 data URL), mimeType: string }
|
|
13
13
|
*
|
|
14
|
+
* The renderer is OPTIONAL. Without one the canvas is found at record time,
|
|
15
|
+
* which is what makes a single install from `ThreeUmicat.init()` cover every
|
|
16
|
+
* 3D game — three-sdk has no `createUmicatGame`-style wrapper, so before this
|
|
17
|
+
* the listener had to be wired by each game's own `main.ts`, and games older
|
|
18
|
+
* than the template line that does it (Balaboo, for one) simply could not
|
|
19
|
+
* record. Calling it twice is a no-op.
|
|
20
|
+
*
|
|
14
21
|
* `canvas.captureStream()` samples the compositor's output directly, so
|
|
15
22
|
* unlike {@link "./ScreenshotManager.js".takeScreenshot}, it works whether
|
|
16
23
|
* or not the renderer was constructed with `preserveDrawingBuffer` — but the
|
|
17
24
|
* template sets it anyway, for the screenshot path.
|
|
18
25
|
*/
|
|
19
|
-
export declare function setupRecordingListener(renderer
|
|
26
|
+
export declare function setupRecordingListener(renderer?: THREE.WebGLRenderer): void;
|
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
let mediaRecorder = null;
|
|
2
2
|
let recordedChunks = [];
|
|
3
|
+
/** One listener per WINDOW, whoever asks first. `ThreeUmicat.init()` installs
|
|
4
|
+
* it for every game; the 3D template ALSO calls this explicitly and older
|
|
5
|
+
* games may too. Two listeners would mean two MediaRecorders racing the same
|
|
6
|
+
* canvas on one 'startRecording'.
|
|
7
|
+
*
|
|
8
|
+
* Keyed on the window rather than held as a module-level flag, which is both
|
|
9
|
+
* more honest about what "once" means here and the difference between this
|
|
10
|
+
* being testable and not: a module latch makes every call after the first a
|
|
11
|
+
* no-op for the life of the process, so a suite that exercises more than one
|
|
12
|
+
* scenario silently tests nothing after its first case. */
|
|
13
|
+
const installedOn = new WeakSet();
|
|
14
|
+
/** The canvas to record, resolved LAZILY — at record time, not install time.
|
|
15
|
+
* That is what lets `ThreeUmicat.init()` install this: init runs at the top
|
|
16
|
+
* of a game's boot, long before the renderer (and its canvas) exist. An
|
|
17
|
+
* explicit renderer, when given, always wins.
|
|
18
|
+
*
|
|
19
|
+
* Picks the largest canvas when a game has more than one — a minimap or a
|
|
20
|
+
* thumbnail baker is a canvas too, and recording one of those instead of the
|
|
21
|
+
* game would be a silent, confusing failure. */
|
|
22
|
+
function resolveCanvas(renderer) {
|
|
23
|
+
if (renderer?.domElement)
|
|
24
|
+
return renderer.domElement;
|
|
25
|
+
const all = [...document.querySelectorAll('canvas')];
|
|
26
|
+
if (all.length === 0)
|
|
27
|
+
return null;
|
|
28
|
+
return all.reduce((best, c) => (c.width * c.height > best.width * best.height ? c : best), all[0]);
|
|
29
|
+
}
|
|
3
30
|
/**
|
|
4
31
|
* Sets up postMessage listeners for video recording of the renderer's
|
|
5
32
|
* canvas. Same wire protocol as `@umicat/phaser-sdk`'s
|
|
@@ -12,18 +39,30 @@ let recordedChunks = [];
|
|
|
12
39
|
* Parent sends: 'stopRecording'
|
|
13
40
|
* Game responds: { type: 'recordingComplete', data: string (base64 data URL), mimeType: string }
|
|
14
41
|
*
|
|
42
|
+
* The renderer is OPTIONAL. Without one the canvas is found at record time,
|
|
43
|
+
* which is what makes a single install from `ThreeUmicat.init()` cover every
|
|
44
|
+
* 3D game — three-sdk has no `createUmicatGame`-style wrapper, so before this
|
|
45
|
+
* the listener had to be wired by each game's own `main.ts`, and games older
|
|
46
|
+
* than the template line that does it (Balaboo, for one) simply could not
|
|
47
|
+
* record. Calling it twice is a no-op.
|
|
48
|
+
*
|
|
15
49
|
* `canvas.captureStream()` samples the compositor's output directly, so
|
|
16
50
|
* unlike {@link "./ScreenshotManager.js".takeScreenshot}, it works whether
|
|
17
51
|
* or not the renderer was constructed with `preserveDrawingBuffer` — but the
|
|
18
52
|
* template sets it anyway, for the screenshot path.
|
|
19
53
|
*/
|
|
20
54
|
export function setupRecordingListener(renderer) {
|
|
55
|
+
if (installedOn.has(window))
|
|
56
|
+
return;
|
|
57
|
+
installedOn.add(window);
|
|
21
58
|
window.addEventListener('message', (event) => {
|
|
22
59
|
if (event.data === 'startRecording') {
|
|
23
60
|
try {
|
|
24
|
-
const canvas = renderer
|
|
25
|
-
if (!canvas)
|
|
61
|
+
const canvas = resolveCanvas(renderer);
|
|
62
|
+
if (!canvas) {
|
|
63
|
+
window.parent.postMessage({ type: 'recordingError', error: 'no canvas to record' }, '*');
|
|
26
64
|
return;
|
|
65
|
+
}
|
|
27
66
|
recordedChunks = [];
|
|
28
67
|
const stream = canvas.captureStream(30);
|
|
29
68
|
// Pick best available codec.
|
|
@@ -359,6 +359,25 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
|
|
|
359
359
|
selectionBox.visible = false;
|
|
360
360
|
selectionBox.renderOrder = 998;
|
|
361
361
|
selectionBox.material.depthTest = false;
|
|
362
|
+
/**
|
|
363
|
+
* ADR-052 — the outline shown when a CONTEXT MENU opens on a hidden or
|
|
364
|
+
* locked entity.
|
|
365
|
+
*
|
|
366
|
+
* Same look as the selection box on purpose: the question it answers is the
|
|
367
|
+
* same one ("which thing is this menu about?"), and inventing a second
|
|
368
|
+
* visual language for it would only make the answer harder to read. What it
|
|
369
|
+
* deliberately does NOT come with is the gizmo — showing you what you are
|
|
370
|
+
* acting on is not the same as handing back the drag handles that lock
|
|
371
|
+
* exists to take away.
|
|
372
|
+
*
|
|
373
|
+
* Its own helper rather than reusing `selectionBox`, so `applySelection`
|
|
374
|
+
* stays the single owner of that one and the two cannot fight over
|
|
375
|
+
* visibility.
|
|
376
|
+
*/
|
|
377
|
+
const menuTargetBox = new THREE.BoxHelper(new THREE.Object3D(), 0xffd23f);
|
|
378
|
+
menuTargetBox.visible = false;
|
|
379
|
+
menuTargetBox.renderOrder = 998;
|
|
380
|
+
menuTargetBox.material.depthTest = false;
|
|
362
381
|
// ADR-046 — multi-select (box-select + ⌘/Ctrl-click). `multiSelected` is
|
|
363
382
|
// now the ONE authoritative source of truth for "what's selected" — the
|
|
364
383
|
// single-select visuals above (`gizmo.attached`/`selectionBox`) are kept
|
|
@@ -539,6 +558,8 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
|
|
|
539
558
|
// the ground-marquee regression: the claim there is "the ground did NOT
|
|
540
559
|
// move AND both Parts got selected", and neither half is observable from
|
|
541
560
|
// the host protocol alone (a drag that moves nothing posts nothing).
|
|
561
|
+
globalThis.__umicatMenuTargetVisible =
|
|
562
|
+
() => menuTargetBox.visible;
|
|
542
563
|
globalThis.__umicatSelectedIds =
|
|
543
564
|
() => [...multiSelected].map((o) => entityByObject.get(o)).filter((id) => !!id);
|
|
544
565
|
globalThis.__umicatEntityWorldPos =
|
|
@@ -1149,6 +1170,8 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
|
|
|
1149
1170
|
moved = true;
|
|
1150
1171
|
};
|
|
1151
1172
|
const onPointerDown = (e) => {
|
|
1173
|
+
// Any new press ends the previous menu's business, including its outline.
|
|
1174
|
+
menuTargetBox.visible = false;
|
|
1152
1175
|
// Right button — camera look-drag, a separate gesture channel entirely
|
|
1153
1176
|
// from everything below. Hard-returns before touching any select/drag/
|
|
1154
1177
|
// gizmo state, so a right-click can never be misread as the start of a
|
|
@@ -1393,6 +1416,10 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
|
|
|
1393
1416
|
return;
|
|
1394
1417
|
}
|
|
1395
1418
|
if (isInert(hit.entityId)) {
|
|
1419
|
+
// Outline it without selecting it. The menu needs to say what it is
|
|
1420
|
+
// about; the gizmo would undo the lock.
|
|
1421
|
+
menuTargetBox.setFromObject(hit.entityRoot);
|
|
1422
|
+
menuTargetBox.visible = true;
|
|
1396
1423
|
window.parent.postMessage({ type: 'umicat:editor:contextMenu3d', entityId: hit.entityId, inert: true, clientX: e.clientX, clientY: e.clientY }, '*');
|
|
1397
1424
|
return;
|
|
1398
1425
|
}
|
|
@@ -1862,6 +1889,20 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
|
|
|
1862
1889
|
disposeMeshInPlace(object);
|
|
1863
1890
|
object = swapEntityObject(object, fresh, m.entityId);
|
|
1864
1891
|
}
|
|
1892
|
+
if (m.patch?.name !== undefined) {
|
|
1893
|
+
// ADR-052 — display name. Kept live as well as on disk because
|
|
1894
|
+
// `Object3D.name` is what game code and any future debug overlay read;
|
|
1895
|
+
// a rename that only landed on disk would be invisible until a rebuild,
|
|
1896
|
+
// which is indistinguishable from a control that does not work.
|
|
1897
|
+
const authored = sceneData?.entities.find((e) => e.id === m.entityId);
|
|
1898
|
+
if (authored) {
|
|
1899
|
+
if (m.patch.name)
|
|
1900
|
+
authored.name = m.patch.name;
|
|
1901
|
+
else
|
|
1902
|
+
delete authored.name;
|
|
1903
|
+
}
|
|
1904
|
+
object.name = m.patch.name || m.entityId;
|
|
1905
|
+
}
|
|
1865
1906
|
if (m.patch?.editorHidden !== undefined || m.patch?.editorLocked !== undefined) {
|
|
1866
1907
|
const authored = sceneData?.entities.find((e) => e.id === m.entityId);
|
|
1867
1908
|
if (!authored)
|
|
@@ -2611,6 +2652,8 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
|
|
|
2611
2652
|
scene.add(marker);
|
|
2612
2653
|
selectionBox.visible = false;
|
|
2613
2654
|
scene.add(selectionBox);
|
|
2655
|
+
menuTargetBox.visible = false;
|
|
2656
|
+
scene.add(menuTargetBox);
|
|
2614
2657
|
scene.add(gizmo.root);
|
|
2615
2658
|
// ADR-046 Phase 3b — the shared pivot itself has no visible geometry,
|
|
2616
2659
|
// but it still needs to be IN the (fresh) scene graph for
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umicat/three-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.32.0",
|
|
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",
|