@umicat/three-sdk 1.15.0 → 1.17.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.
@@ -1,3 +1,4 @@
1
+ import { installFoldVariables, placeCanvasInPanel } from '@umicat/platform-sdk/fold/foldVariables.js';
1
2
  // Laying a 3D game across a folded device, NDS-style: the world above the
2
3
  // crease, the controls below it.
3
4
  //
@@ -62,13 +63,17 @@ export function viewportSize(umicat) {
62
63
  */
63
64
  export function installDualScreen(umicat, targets = {}) {
64
65
  let current = null;
66
+ // The CSS custom properties are published by the platform SDK, not here: the
67
+ // variable names are a contract with a game's stylesheet, and the Phaser side
68
+ // needs the same ones. Two definitions of a contract drift.
69
+ const offVars = installFoldVariables(umicat.fold);
65
70
  const applyCanvas = () => {
66
71
  if (!current)
67
72
  return;
68
73
  if (!targets.renderer) {
69
74
  // Box only — the game sizes its own buffer.
70
75
  if (targets.canvas)
71
- placeCanvas(current, targets.canvas);
76
+ placeCanvasInPanel(targets.canvas, current);
72
77
  return;
73
78
  }
74
79
  const size = current.dualScreen && current.top
@@ -79,13 +84,12 @@ export function installDualScreen(umicat, targets = {}) {
79
84
  targets.camera.aspect = size.width / size.height;
80
85
  targets.camera.updateProjectionMatrix();
81
86
  }
82
- placeCanvas(current, targets.renderer.domElement);
87
+ placeCanvasInPanel(targets.renderer.domElement, current);
83
88
  };
84
89
  const onResize = () => { applyCanvas(); requestAnimationFrame(applyCanvas); };
85
90
  window.addEventListener('resize', onResize);
86
91
  const off = umicat.fold.subscribe((layout) => {
87
92
  current = layout;
88
- publishVariables(layout);
89
93
  placeControls(layout);
90
94
  applyCanvas();
91
95
  // A game that drives its own canvas still needs to hear about it. Folding
@@ -95,66 +99,7 @@ export function installDualScreen(umicat, targets = {}) {
95
99
  if (!targets.renderer)
96
100
  window.dispatchEvent(new Event('resize'));
97
101
  });
98
- return () => { window.removeEventListener('resize', onResize); off(); };
99
- }
100
- function publishVariables(layout) {
101
- const root = document.documentElement;
102
- const px = (n) => `${Math.round(n ?? 0)}px`;
103
- const on = layout.dualScreen;
104
- root.style.setProperty('--umicat-top-height', px(on ? layout.top?.height : 0));
105
- root.style.setProperty('--umicat-bottom-top', px(on ? layout.bottom?.y : 0));
106
- root.style.setProperty('--umicat-bottom-height', px(on ? layout.bottom?.height : 0));
107
- root.style.setProperty('--umicat-fold-top', px(on ? layout.division?.y : 0));
108
- root.style.setProperty('--umicat-fold-height', px(on ? layout.division?.height : 0));
109
- // A stylesheet cannot ask the SDK a question, so the state is an attribute.
110
- if (on)
111
- root.dataset.umicatDualScreen = '';
112
- else
113
- delete root.dataset.umicatDualScreen;
114
- }
115
- /**
116
- * Moves the SDK's touch layer into the lower panel.
117
- *
118
- * It is `position:fixed; inset:0` normally — the full window, with the stick
119
- * and buttons pinned near the bottom corners, which is where thumbs are on a
120
- * flat phone. Folded, thumbs are on the lower half and the upper half is
121
- * propped away from them, so "near the bottom of the window" is the wrong place
122
- * twice over: too far to reach, and sitting on top of the world.
123
- *
124
- * Done by moving the LAYER rather than each control, so every control the SDK
125
- * places — and any it grows later — follows for free.
126
- */
127
- /**
128
- * Constrains the canvas's CSS box to the upper panel.
129
- *
130
- * `viewportSize` alone is not enough, and the reason is a three.js argument
131
- * nobody thinks about: `setSize(w, h, false)` — which every template uses —
132
- * sizes the DRAWING BUFFER and deliberately leaves the CSS box alone, because
133
- * normally the canvas is stretched to the window by a stylesheet. Shrink only
134
- * the buffer and the result is the same full-screen picture at a lower
135
- * resolution, which looks like nothing happened at all.
136
- *
137
- * Found by doing exactly that: the fold arrived, the buffer shrank, and the
138
- * screenshot was unchanged.
139
- *
140
- * Defaults to the document's only canvas. A game with several passes its own.
141
- */
142
- function placeCanvas(layout, explicit) {
143
- const canvas = explicit ?? document.querySelector('canvas');
144
- if (!canvas)
145
- return;
146
- if (layout.dualScreen && layout.top) {
147
- Object.assign(canvas.style, {
148
- position: 'fixed',
149
- left: `${layout.top.x}px`,
150
- top: `${layout.top.y}px`,
151
- width: `${layout.top.width}px`,
152
- height: `${layout.top.height}px`,
153
- });
154
- }
155
- else {
156
- Object.assign(canvas.style, { position: '', left: '', top: '', width: '', height: '' });
157
- }
102
+ return () => { window.removeEventListener('resize', onResize); off(); offVars(); };
158
103
  }
159
104
  function placeControls(layout) {
160
105
  const root = document.querySelector(TOUCH_ROOT);
@@ -182,6 +182,25 @@ function materialRepeatFor(kind, size, tileUnit) {
182
182
  }
183
183
  return new THREE.Vector2(u(size.x), u(size.z));
184
184
  }
185
+ /**
186
+ * ADR-047 — rebuilds a `THREE.BufferGeometry` from a baked CSG result's
187
+ * flat position/index arrays (`Entity3D.primitive.mesh`). `normals` is
188
+ * optional — when the CSG op didn't carry any over, `computeVertexNormals`
189
+ * derives smooth per-vertex ones, same fallback `triangleListGeometry`
190
+ * already uses for wedge/corner-wedge.
191
+ */
192
+ function bakedMeshGeometry(mesh) {
193
+ const geom = new THREE.BufferGeometry();
194
+ geom.setAttribute('position', new THREE.Float32BufferAttribute(mesh.positions, 3));
195
+ geom.setIndex(mesh.indices);
196
+ if (mesh.normals && mesh.normals.length === mesh.positions.length) {
197
+ geom.setAttribute('normal', new THREE.Float32BufferAttribute(mesh.normals, 3));
198
+ }
199
+ else {
200
+ geom.computeVertexNormals();
201
+ }
202
+ return geom;
203
+ }
185
204
  export function makePrimitive(e) {
186
205
  const p = e.primitive;
187
206
  const s = p.size ?? { x: 1, y: 1, z: 1 };
@@ -190,15 +209,16 @@ export function makePrimitive(e) {
190
209
  : p.kind === 'cylinder' ? new THREE.CylinderGeometry(s.x / 2, s.x / 2, s.y, 24)
191
210
  : p.kind === 'wedge' ? wedgeGeometry(s)
192
211
  : p.kind === 'corner-wedge' ? cornerWedgeGeometry(s)
193
- // Lay the plane down by rotating the GEOMETRY, not the object. Rotating the
194
- // object is the obvious move and it is wrong: applyTransform sets the
195
- // object's quaternion from the entity's authored rotation straight
196
- // afterwards, silently discarding it — which left every "ground" standing
197
- // upright like a wall. It renders convincingly until the camera crosses to
198
- // the far side, at which point the scene becomes a flat fill and every
199
- // measurement still says the character is dead centre, because it is —
200
- // behind a 40x40 wall.
201
- : new THREE.PlaneGeometry(s.x, s.z).rotateX(-Math.PI / 2);
212
+ : p.kind === 'mesh' ? bakedMeshGeometry(p.mesh ?? { positions: [], indices: [] })
213
+ // Lay the plane down by rotating the GEOMETRY, not the object. Rotating the
214
+ // object is the obvious move and it is wrong: applyTransform sets the
215
+ // object's quaternion from the entity's authored rotation straight
216
+ // afterwards, silently discarding it — which left every "ground" standing
217
+ // upright like a wall. It renders convincingly until the camera crosses to
218
+ // the far side, at which point the scene becomes a flat fill and every
219
+ // measurement still says the character is dead centre, because it is —
220
+ // behind a 40x40 wall.
221
+ : new THREE.PlaneGeometry(s.x, s.z).rotateX(-Math.PI / 2);
202
222
  const material = new THREE.MeshStandardMaterial({
203
223
  color: new THREE.Color(p.color ?? '#c8c8c8'), roughness: 0.85,
204
224
  // The wedge/corner-wedge faces' winding was verified by hand (no
@@ -206,7 +226,9 @@ export function makePrimitive(e) {
206
226
  // DoubleSide is a pragmatic safety net against a winding mistake
207
227
  // making a face invisible from its intended viewing side; it costs a
208
228
  // little backface-culling perf on two low-poly shapes, not correctness.
209
- side: (p.kind === 'wedge' || p.kind === 'corner-wedge') ? THREE.DoubleSide : THREE.FrontSide,
229
+ // `mesh` joins the same safety net for the same reason — a CSG seam
230
+ // is exactly where a winding inconsistency is most likely to turn up.
231
+ side: (p.kind === 'wedge' || p.kind === 'corner-wedge' || p.kind === 'mesh') ? THREE.DoubleSide : THREE.FrontSide,
210
232
  });
211
233
  const mesh = new THREE.Mesh(geom, material);
212
234
  mesh.castShadow = p.kind !== 'plane';
@@ -0,0 +1,41 @@
1
+ import * as THREE from 'three';
2
+ /**
3
+ * ADR-047 — Boolean operations (Union/Intersect/Negate), copied from Roblox
4
+ * exactly: Negate is a pure marker on a Part (no geometry change by itself);
5
+ * Union computes the union of every NON-negated selected Part, then
6
+ * subtracts the union of every NEGATED one from it; Intersect computes the
7
+ * intersection of every selected Part regardless of any Negate marks.
8
+ *
9
+ * Pure three.js math, no scene/editor dependency (same posture
10
+ * `gizmoMath.ts` already has) — `EditorDesignPlayer3D.ts` is the only
11
+ * caller, and it owns turning a `CsgResult` into a new `Entity3D`.
12
+ */
13
+ export interface CsgOperand {
14
+ object: THREE.Object3D;
15
+ negated?: boolean;
16
+ }
17
+ export interface CsgResultMesh {
18
+ positions: number[];
19
+ indices: number[];
20
+ normals?: number[];
21
+ }
22
+ export interface CsgResult {
23
+ mesh: CsgResultMesh;
24
+ /** The new entity's LOCAL transform — equal to the first operand's (in
25
+ * fold order) WORLD transform, per three-bvh-csg's own documented
26
+ * behavior (`Evaluator.evaluate` always re-stamps the result with
27
+ * operand A's transform) — correct as a scene-root, parentless entity's
28
+ * local transform with no further conversion needed. */
29
+ position: THREE.Vector3;
30
+ quaternion: THREE.Quaternion;
31
+ scale: THREE.Vector3;
32
+ }
33
+ /**
34
+ * Roblox's Union: union of the non-negated Parts, minus the union of the
35
+ * negated ones. If EVERY selected Part is negated (nothing to cut from),
36
+ * negate marks are meaningless here — falls back to a plain union of
37
+ * everything, same as Intersect ignoring them entirely.
38
+ */
39
+ export declare function unionOperands(operands: CsgOperand[]): CsgResult;
40
+ /** Intersection of every selected Part, in selection order. Ignores Negate marks entirely. */
41
+ export declare function intersectOperands(operands: CsgOperand[]): CsgResult;
@@ -0,0 +1,72 @@
1
+ import * as THREE from 'three';
2
+ import { Evaluator, Brush, ADDITION, SUBTRACTION, INTERSECTION } from 'three-bvh-csg';
3
+ /**
4
+ * Wraps a live scene object's geometry + CURRENT WORLD transform into a
5
+ * `Brush` three-bvh-csg can operate on. Clones the geometry rather than
6
+ * handing over the live mesh's own — `Brush.prepareGeometry()` permanently
7
+ * attaches CSG-internal bookkeeping (`boundsTree`/`halfEdges`/
8
+ * `groupIndices`) to whatever geometry it's given, which must not leak onto
9
+ * an object still live in the scene.
10
+ */
11
+ function toBrush(object) {
12
+ const mesh = object;
13
+ const geometry = mesh.geometry.clone();
14
+ const brush = new Brush(geometry, new THREE.MeshStandardMaterial());
15
+ object.updateWorldMatrix(true, false);
16
+ object.matrixWorld.decompose(brush.position, brush.quaternion, brush.scale);
17
+ brush.updateMatrix();
18
+ brush.matrixWorld.copy(object.matrixWorld);
19
+ return brush;
20
+ }
21
+ function extractResult(brush) {
22
+ const geometry = brush.geometry;
23
+ const posAttr = geometry.attributes.position;
24
+ const positions = Array.from(posAttr.array);
25
+ const indexAttr = geometry.index;
26
+ const indices = indexAttr
27
+ ? Array.from(indexAttr.array)
28
+ : Array.from({ length: posAttr.count }, (_, i) => i);
29
+ const normalAttr = geometry.attributes.normal;
30
+ const normals = normalAttr ? Array.from(normalAttr.array) : undefined;
31
+ return {
32
+ mesh: { positions, indices, normals },
33
+ position: brush.position.clone(),
34
+ quaternion: brush.quaternion.clone(),
35
+ scale: brush.scale.clone(),
36
+ };
37
+ }
38
+ function foldAddition(evaluator, objects) {
39
+ let acc = toBrush(objects[0]);
40
+ for (let i = 1; i < objects.length; i++)
41
+ acc = evaluator.evaluate(acc, toBrush(objects[i]), ADDITION);
42
+ return acc;
43
+ }
44
+ /**
45
+ * Roblox's Union: union of the non-negated Parts, minus the union of the
46
+ * negated ones. If EVERY selected Part is negated (nothing to cut from),
47
+ * negate marks are meaningless here — falls back to a plain union of
48
+ * everything, same as Intersect ignoring them entirely.
49
+ */
50
+ export function unionOperands(operands) {
51
+ if (operands.length < 2)
52
+ throw new Error('union needs at least 2 operands');
53
+ const evaluator = new Evaluator();
54
+ const nonNegated = operands.filter((o) => !o.negated).map((o) => o.object);
55
+ const negated = operands.filter((o) => o.negated).map((o) => o.object);
56
+ if (nonNegated.length === 0)
57
+ return extractResult(foldAddition(evaluator, operands.map((o) => o.object)));
58
+ let acc = foldAddition(evaluator, nonNegated);
59
+ if (negated.length > 0)
60
+ acc = evaluator.evaluate(acc, foldAddition(evaluator, negated), SUBTRACTION);
61
+ return extractResult(acc);
62
+ }
63
+ /** Intersection of every selected Part, in selection order. Ignores Negate marks entirely. */
64
+ export function intersectOperands(operands) {
65
+ if (operands.length < 2)
66
+ throw new Error('intersect needs at least 2 operands');
67
+ const evaluator = new Evaluator();
68
+ let acc = toBrush(operands[0].object);
69
+ for (let i = 1; i < operands.length; i++)
70
+ acc = evaluator.evaluate(acc, toBrush(operands[i].object), INTERSECTION);
71
+ return extractResult(acc);
72
+ }
@@ -6,6 +6,7 @@ import { applyAttachments } from '../Attachments.js';
6
6
  import { singleModelManifest, defaultColliderForPrimitive, groundRestOffset } from '../scene3d.js';
7
7
  import { TransformGizmo3D } from './TransformGizmo3D.js';
8
8
  import { closestPointOnLineToRay, raycastPlane, angleAroundAxis } from './gizmoMath.js';
9
+ import { unionOperands, intersectOperands } from './CSG3D.js';
9
10
  import { loadHud3DScene } from '../hud3d/HudRuntime3D.js';
10
11
  /**
11
12
  * The 3D counterpart of `@umicat/phaser-sdk`'s `EditorDesignScene` (ADR-021)
@@ -249,6 +250,96 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
249
250
  // per press.
250
251
  const movementKeysDown = new Set();
251
252
  let shiftHeld = false;
253
+ // ── ADR-051: grid snap ──────────────────────────────────────────────
254
+ //
255
+ // ON by default, step 1. The reference here is Roblox Studio, not Unity:
256
+ // Studio ships Snap to Grid ENABLED at 1 stud, and that is the right
257
+ // default for this audience because the public library's modular kits are
258
+ // built on exactly that module. Measured rather than assumed — Kenney
259
+ // Nature Kit's `cliff_block*` and `ground_*` are 1x1x1 with the origin
260
+ // centred horizontally and the base at y=0, so an INTEGER world position
261
+ // tiles them edge-to-edge with no gap and stacks them with no overlap.
262
+ // Unity's opposite default (off; hold Ctrl to snap) was rejected for the
263
+ // reason the desktop-controls work established the hard way: a capability
264
+ // nobody can find is the same as not having one.
265
+ //
266
+ // The step is ABSOLUTE — the resulting world POSITION is rounded, not the
267
+ // movement. That is what lets a piece already sitting at 0.37 get
268
+ // CORRECTED to 0 the next time it is dragged; delta-snapping would
269
+ // preserve the 0.37 forever, and the visible seam with it.
270
+ let snapEnabled = true;
271
+ let snapStep = 1;
272
+ let snapRotateRad = Math.PI / 2;
273
+ const snap1 = (v) => Math.round(v / snapStep) * snapStep;
274
+ /**
275
+ * Round a WORLD-space position onto the grid. Always called BEFORE the
276
+ * caller converts to parent-local space, so a parented entity lands on the
277
+ * world grid (the one its neighbours tile against) rather than on a grid
278
+ * skewed by its parent's transform.
279
+ *
280
+ * `axes` names ONLY the components this gesture actually varies, and
281
+ * nothing else is touched. That is load-bearing, not tidiness: an X-handle
282
+ * drag that also rounded Y and Z would silently move an entity on two axes
283
+ * the user did not grab, breaking the one contract the axis gizmo exists to
284
+ * provide (`gizmo-3d.test.mjs` asserts exactly that, and passed only
285
+ * because its fixture happened to sit on integers). Unity and Blender both
286
+ * constrain snapping to the dragged axis for the same reason.
287
+ *
288
+ * `bypass` is Alt held during the drag. It is the only modifier left:
289
+ * meta/ctrl at pointerdown means multi-select (ADR-046) and Shift is the
290
+ * fly-speed multiplier. Reading `altKey` off a pointer event is safe on
291
+ * macOS — the "Option is a dead key" trap from the pixel-art work is about
292
+ * Alt+LETTER shortcuts emitting special characters, which this is not.
293
+ */
294
+ const snapWorldPos = (p, bypass, axes) => {
295
+ if (!snapEnabled || bypass)
296
+ return;
297
+ if (axes.includes('x'))
298
+ p.x = snap1(p.x);
299
+ if (axes.includes('y'))
300
+ p.y = snap1(p.y);
301
+ if (axes.includes('z'))
302
+ p.z = snap1(p.z);
303
+ };
304
+ /**
305
+ * The visible grid. A single horizontal XZ plane, deliberately not a
306
+ * volumetric three-axis grid (unreadable in perspective, and no tool draws
307
+ * one) and deliberately only at y=0: with snap on, vertical stacking is
308
+ * self-aligning against the piece BELOW, so the grid's job is to
309
+ * communicate the module size and give horizontal reference — which is
310
+ * also why Roblox gets away with its grid being a texture on the ground
311
+ * baseplate rather than a viewport overlay.
312
+ *
313
+ * Cell count is held constant (not the extent) so a fine step costs the
314
+ * same number of lines as a coarse one — step 0.25 draws a dense 25-unit
315
+ * grid for close work, step 4 a 400-unit one for blocking out.
316
+ */
317
+ let snapGrid = null;
318
+ const SNAP_GRID_CELLS = 100;
319
+ const rebuildSnapGrid = () => {
320
+ if (snapGrid) {
321
+ snapGrid.parent?.remove(snapGrid);
322
+ snapGrid.geometry.dispose();
323
+ snapGrid.material.dispose();
324
+ snapGrid = null;
325
+ }
326
+ if (!scene || !snapEnabled)
327
+ return;
328
+ const grid = new THREE.GridHelper(snapStep * SNAP_GRID_CELLS, SNAP_GRID_CELLS, 0x5a6472, 0x39404a);
329
+ grid.name = '__umicatSnapGrid';
330
+ // Ground in a real scene is routinely a FLAT tile whose top face is
331
+ // exactly y=0 (`ground_grass.glb` measures 1 x 0 x 1), so a grid at
332
+ // y=0 would be coplanar with it and z-fight across the whole floor.
333
+ // Lift it a hair and never write depth, so it reads as a drawn-on
334
+ // overlay instead of geometry competing for the same pixels.
335
+ grid.position.y = 0.002;
336
+ const mat = grid.material;
337
+ mat.transparent = true;
338
+ mat.opacity = 0.5;
339
+ mat.depthWrite = false;
340
+ scene.add(grid);
341
+ snapGrid = grid;
342
+ };
252
343
  // A single persistent marker, repositioned per click — the exact world
253
344
  // point clicked (what "put a torch at the spot I clicked" needs), distinct
254
345
  // from the box below (which entity was hit, not just where).
@@ -278,6 +369,38 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
278
369
  // single click never grows a second, redundant box.
279
370
  let multiSelected = new Set();
280
371
  const multiBoxes = new Map();
372
+ // ADR-047 — a persistent magenta outline on any Part marked `negated`
373
+ // (Roblox's own convention for a to-be-subtracted Union operand),
374
+ // independent of selection — a Part stays visibly marked while
375
+ // deselected, since Negate is STATE, not a transient selection
376
+ // highlight. Resynced every frame (below, alongside `gizmo.update`)
377
+ // rather than only at the moments this file already knows a transform
378
+ // changed, specifically because a negated Part can be moved via the
379
+ // ORDINARY single-entity gizmo/free-drag paths — neither of which
380
+ // otherwise has any reason to know this map exists. Deliberately NOT a
381
+ // material-color tint — the shared-material clone trap `Tint.ts`'s own
382
+ // doc comment already warns about elsewhere in this codebase.
383
+ const negatedBoxes = new Map();
384
+ function setNegatedVisual(object, negated) {
385
+ if (negated) {
386
+ if (negatedBoxes.has(object))
387
+ return;
388
+ const box = new THREE.BoxHelper(object, 0xff33cc);
389
+ box.renderOrder = 997;
390
+ box.material.depthTest = false;
391
+ scene?.add(box);
392
+ negatedBoxes.set(object, box);
393
+ }
394
+ else {
395
+ const box = negatedBoxes.get(object);
396
+ if (!box)
397
+ return;
398
+ scene?.remove(box);
399
+ box.geometry.dispose();
400
+ box.material.dispose();
401
+ negatedBoxes.delete(object);
402
+ }
403
+ }
281
404
  // The Move/Rotate/Scale transform gizmo — shows (and is only hit-testable)
282
405
  // on the current mode's handles once something is selected. `gizmo.root`
283
406
  // is added to the scene once, at scene-load time, right alongside the
@@ -399,6 +522,20 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
399
522
  // dropped model's `importScale` means that's almost never true).
400
523
  globalThis.__umicatGizmoAttachedScale =
401
524
  () => gizmo.attached ? { x: gizmo.attached.scale.x, y: gizmo.attached.scale.y, z: gizmo.attached.scale.z } : null;
525
+ // ADR-051 — test-only readback, same posture as the hooks above (never
526
+ // read by umicat-home-ui). `cameraDistance` is here because the grid can
527
+ // break the zoom-to-fit INVISIBLY: folded into the fit box, a 100-unit
528
+ // grid frames 100 units around a 20-unit scene, which reads as "the
529
+ // editor opens zoomed out" rather than as a bug, and no assertion about
530
+ // snapping itself would ever catch it.
531
+ globalThis.__umicatSnapState =
532
+ () => ({
533
+ enabled: snapEnabled,
534
+ step: snapStep,
535
+ rotateDeg: (snapRotateRad * 180) / Math.PI,
536
+ gridPresent: !!(scene && scene.getObjectByName('__umicatSnapGrid')),
537
+ cameraDistance: camera.position.length(),
538
+ });
402
539
  // ADR-046 Phase 3b — test-only: distinguishes "gizmo attached to a REAL
403
540
  // single entity" from "gizmo attached to the shared group pivot" — both
404
541
  // report non-null from `__umicatGizmoAttachedScale` above, so a test
@@ -830,6 +967,13 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
830
967
  if (!grab)
831
968
  return;
832
969
  const newWorldPos = grab.clone().sub(gizmoDrag.grabOffset);
970
+ // ADR-051 — snap in WORLD space, before the parent-local conversion
971
+ // and before the group delta below, and ONLY on the axis being
972
+ // dragged. Snapping the PIVOT and letting members follow by that same
973
+ // delta is what keeps a multi-selection rigid: snapping each member
974
+ // independently would collapse any fractional offsets between them
975
+ // (Unity snaps the active object for the same reason).
976
+ snapWorldPos(newWorldPos, e.altKey, gizmoDrag.axis);
833
977
  if (obj.parent)
834
978
  obj.parent.worldToLocal(newWorldPos);
835
979
  obj.position.copy(newWorldPos);
@@ -912,7 +1056,17 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
912
1056
  if (!hitPoint)
913
1057
  return;
914
1058
  const currentAngle = angleAroundAxis(gizmoDrag.planePoint, gizmoDrag.planeNormal, hitPoint);
915
- const delta = currentAngle - gizmoDrag.startAngle;
1059
+ // ADR-051 — rotation snaps the DELTA, not an absolute orientation,
1060
+ // which is what Unity and Blender both do: "the object's angle about
1061
+ // this world axis" is not well defined for an arbitrary quaternion
1062
+ // without a swing/twist decomposition. Exact for the case that
1063
+ // matters — a freshly placed entity starts at identity, so stepped
1064
+ // deltas land it exactly on multiples. Known limit: an entity already
1065
+ // sitting at an odd angle keeps that offset forever.
1066
+ const rawDelta = currentAngle - gizmoDrag.startAngle;
1067
+ const delta = snapEnabled && !e.altKey
1068
+ ? Math.round(rawDelta / snapRotateRad) * snapRotateRad
1069
+ : rawDelta;
916
1070
  const deltaQuat = new THREE.Quaternion().setFromAxisAngle(gizmoDrag.planeNormal, delta);
917
1071
  const newWorldQuat = deltaQuat.multiply(gizmoDrag.startWorldQuaternion.clone());
918
1072
  obj.quaternion.copy(gizmoDrag.parentWorldQuatInverse.clone().multiply(newWorldQuat));
@@ -1106,6 +1260,11 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
1106
1260
  if (!raycaster.ray.intersectPlane(dragPlane, planePoint))
1107
1261
  return; // looking parallel to the plane
1108
1262
  const newWorldPos = planePoint.sub(dragGrabOffset);
1263
+ // ADR-051 — same grid as the gizmo path. `dragPlane` is horizontal at
1264
+ // the entity's own height, so this gesture varies x and z only; y must
1265
+ // not be rounded here or a piece deliberately parked at y=0.5 would
1266
+ // drop to the floor the first time it was slid sideways.
1267
+ snapWorldPos(newWorldPos, e.altKey, 'xz');
1109
1268
  if (dragEntity.parent)
1110
1269
  dragEntity.parent.worldToLocal(newWorldPos);
1111
1270
  dragEntity.position.copy(newWorldPos);
@@ -1359,6 +1518,27 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
1359
1518
  return onCreateEntity3d(data);
1360
1519
  if (data.type === 'umicat:editor:deleteEntity3d')
1361
1520
  return onDeleteEntity3d(data);
1521
+ if (data.type === 'umicat:editor:csgUnion3d')
1522
+ return onCsgUnion3d(data);
1523
+ if (data.type === 'umicat:editor:csgIntersect3d')
1524
+ return onCsgIntersect3d(data);
1525
+ // ADR-051 — grid snap settings. Host owns the control and the
1526
+ // persistence; this just applies them. Every field is optional so the
1527
+ // host can push a partial update, and the grid is rebuilt on any change
1528
+ // because its cell size IS the step (the grid is the snap grid, not a
1529
+ // separate decoration).
1530
+ if (data.type === 'umicat:editor:setSnap3d') {
1531
+ const d = data;
1532
+ if (typeof d.enabled === 'boolean')
1533
+ snapEnabled = d.enabled;
1534
+ if (typeof d.step === 'number' && Number.isFinite(d.step) && d.step > 0)
1535
+ snapStep = d.step;
1536
+ if (typeof d.rotateDeg === 'number' && Number.isFinite(d.rotateDeg) && d.rotateDeg > 0) {
1537
+ snapRotateRad = (d.rotateDeg * Math.PI) / 180;
1538
+ }
1539
+ rebuildSnapGrid();
1540
+ return;
1541
+ }
1362
1542
  if (data.type === 'umicat:editor:setGizmoMode3d') {
1363
1543
  const mode = data.mode;
1364
1544
  if (mode === 'move' || mode === 'rotate' || mode === 'scale') {
@@ -1460,6 +1640,17 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
1460
1640
  // explicit refresh here, same as a live drag already does.
1461
1641
  selectionBox.setFromObject(object);
1462
1642
  }
1643
+ if (m.patch?.negated !== undefined) {
1644
+ // ADR-047 — pure marker, no geometry/transform change at all.
1645
+ setNegatedVisual(object, m.patch.negated);
1646
+ const authored = sceneData?.entities.find((e) => e.id === m.entityId);
1647
+ if (authored) {
1648
+ if (m.patch.negated)
1649
+ authored.negated = true;
1650
+ else
1651
+ delete authored.negated;
1652
+ }
1653
+ }
1463
1654
  if (m.patch?.parent !== undefined) {
1464
1655
  // ADR-045 Phase 2 — reparent. `Object3D.attach` (standard three.js
1465
1656
  // API) moves `object` under the new parent AND recomputes its local
@@ -1580,6 +1771,14 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
1580
1771
  box.setFromObject(fresh);
1581
1772
  }
1582
1773
  }
1774
+ {
1775
+ const box = negatedBoxes.get(object);
1776
+ if (box) {
1777
+ negatedBoxes.delete(object);
1778
+ negatedBoxes.set(fresh, box);
1779
+ box.setFromObject(fresh);
1780
+ }
1781
+ }
1583
1782
  object = fresh;
1584
1783
  }
1585
1784
  done();
@@ -1704,28 +1903,33 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
1704
1903
  * block the entity from existing at all, unlike a direct user-initiated
1705
1904
  * patch where failing loudly is correct).
1706
1905
  */
1707
- async function onCreateEntity3d(m) {
1708
- const e = m.entity;
1709
- const done = (error) => {
1710
- if (error)
1711
- console.warn('[umicat/editor] 3D entity create failed:', e.id, error);
1712
- window.parent.postMessage({ type: 'umicat:editor:entityCreated3d', entityId: e.id, ok: !error, error }, '*');
1713
- };
1906
+ /**
1907
+ * The actual spawn work behind `onCreateEntity3d`'s message handler,
1908
+ * pulled out with no `postMessage` of its own — same split this file's
1909
+ * `deleteEntityLive`/`onDeleteEntity3d` pair already established —
1910
+ * SPECIFICALLY so ADR-047's CSG handler (below) can create its merged
1911
+ * result entity through the exact same path Paste/Duplicate already use
1912
+ * (parent-honoring, skin/attachment re-apply, registration into every
1913
+ * map) without also emitting an unrelated `entityCreated3d` ack the CSG
1914
+ * flow has no use for — it posts its own `csgResult3d` instead. Returns
1915
+ * an error string on failure, undefined on success.
1916
+ */
1917
+ async function createEntityLive(e) {
1714
1918
  if (!scene)
1715
- return done('no scene loaded yet');
1919
+ return 'no scene loaded yet';
1716
1920
  if (objectByEntity.has(e.id))
1717
- return done(`entity '${e.id}' already exists in this scene`);
1921
+ return `entity '${e.id}' already exists in this scene`;
1718
1922
  let object;
1719
1923
  if (e.modelAssetId) {
1720
1924
  const asset = manifest?.models?.find((x) => x.id === e.modelAssetId);
1721
1925
  if (!asset)
1722
- return done(`entity references model '${e.modelAssetId}', which the manifest does not define`);
1926
+ return `entity references model '${e.modelAssetId}', which the manifest does not define`;
1723
1927
  try {
1724
1928
  const loaded = await loadModelAsset(singleModelManifest(asset), e.modelAssetId, { assetBase: '' });
1725
1929
  object = loaded.object;
1726
1930
  }
1727
1931
  catch (err) {
1728
- return done(err instanceof Error ? err.message : String(err));
1932
+ return err instanceof Error ? err.message : String(err);
1729
1933
  }
1730
1934
  object.traverse((n) => { n.castShadow = e.castShadow !== false; n.receiveShadow = true; });
1731
1935
  if (e.skin) {
@@ -1771,14 +1975,22 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
1771
1975
  if (e.parent) {
1772
1976
  const resolved = objectByEntity.get(e.parent);
1773
1977
  if (!resolved)
1774
- return done(`entity references parent '${e.parent}', which does not exist in this scene`);
1978
+ return `entity references parent '${e.parent}', which does not exist in this scene`;
1775
1979
  parentObject = resolved;
1776
1980
  }
1777
1981
  parentObject.add(object);
1778
1982
  entityByObject.set(object, e.id);
1779
1983
  objectByEntity.set(e.id, object);
1780
1984
  sceneData?.entities.push(e);
1781
- done();
1985
+ if (e.negated)
1986
+ setNegatedVisual(object, true);
1987
+ return undefined;
1988
+ }
1989
+ async function onCreateEntity3d(m) {
1990
+ const error = await createEntityLive(m.entity);
1991
+ if (error)
1992
+ console.warn('[umicat/editor] 3D entity create failed:', m.entity.id, error);
1993
+ window.parent.postMessage({ type: 'umicat:editor:entityCreated3d', entityId: m.entity.id, ok: !error, error }, '*');
1782
1994
  }
1783
1995
  /**
1784
1996
  * Frees a subtree's GPU resources the same way the whole-scene `dispose()`
@@ -1852,6 +2064,7 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
1852
2064
  entityByObject.delete(object);
1853
2065
  objectByEntity.delete(entityId);
1854
2066
  worn.delete(entityId);
2067
+ setNegatedVisual(object, false);
1855
2068
  if (sceneData) {
1856
2069
  const idx = sceneData.entities.findIndex((e) => e.id === entityId);
1857
2070
  if (idx >= 0)
@@ -1865,6 +2078,115 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
1865
2078
  console.warn('[umicat/editor] 3D entity delete failed:', m.entityId, error);
1866
2079
  window.parent.postMessage({ type: 'umicat:editor:entityDeleted3d', entityId: m.entityId, ok: !error, error }, '*');
1867
2080
  }
2081
+ /**
2082
+ * ADR-047 — Roblox's Union/Intersect, copied exactly (confirmed against
2083
+ * a real screenshot of Roblox Studio's own right-click menu): both ops
2084
+ * need 2+ selected Parts; a `plane` or model/group entity (no solid
2085
+ * geometry of its own, or geometry this SDK can't guarantee is
2086
+ * manifold) can't be an operand. Returns an error string naming the
2087
+ * first disqualifying entity, or the resolved `{object, authored}` pair
2088
+ * list on success.
2089
+ */
2090
+ function resolveCsgOperands(entityIds) {
2091
+ const resolved = [];
2092
+ for (const id of entityIds) {
2093
+ const object = objectByEntity.get(id);
2094
+ if (!object)
2095
+ return `no entity '${id}' in the scene being shown`;
2096
+ const authored = sceneData?.entities.find((e) => e.id === id);
2097
+ if (!authored?.primitive || authored.primitive.kind === 'plane') {
2098
+ return `entity '${id}' is not a solid Part — Union/Intersect only work on box/sphere/cylinder/` +
2099
+ `wedge/corner-wedge/mesh Parts`;
2100
+ }
2101
+ resolved.push({ object, authored });
2102
+ }
2103
+ return resolved;
2104
+ }
2105
+ /**
2106
+ * Shared by Union and Intersect — both delete every operand and spawn
2107
+ * ONE new `primitive.kind:'mesh'` entity in their place, reusing
2108
+ * `createEntityLive` (the exact same spawn path Paste/Duplicate use) so
2109
+ * the result is immediately selected, pickable and draggable with zero
2110
+ * new registration code. `compute` is the one thing that differs
2111
+ * between the two ops; everything else (validation, operand deletion,
2112
+ * entity assembly, selection, the ack) is identical.
2113
+ */
2114
+ async function doCsgOp(m, op, compute) {
2115
+ const done = (error, entity) => {
2116
+ if (error)
2117
+ console.warn(`[umicat/editor] 3D CSG ${op} failed:`, error);
2118
+ window.parent.postMessage({
2119
+ // `newEntityId` always echoes back, success or failure — the
2120
+ // host has no other stable key to match this ack to the
2121
+ // request that caused it (unlike `entityCreated3d`'s
2122
+ // `entityId`, which IS always present; `entity` here is only
2123
+ // present on success).
2124
+ type: 'umicat:editor:csgResult3d', op, ok: !error, error, entity, newEntityId: m.newEntityId,
2125
+ removedEntityIds: error ? undefined : m.entityIds,
2126
+ }, '*');
2127
+ };
2128
+ if (!scene)
2129
+ return done('no scene loaded yet');
2130
+ if (m.entityIds.length < 2)
2131
+ return done(`${op} needs at least 2 selected Parts`);
2132
+ if (objectByEntity.has(m.newEntityId))
2133
+ return done(`entity '${m.newEntityId}' already exists in this scene`);
2134
+ const resolved = resolveCsgOperands(m.entityIds);
2135
+ if (typeof resolved === 'string')
2136
+ return done(resolved);
2137
+ let result;
2138
+ try {
2139
+ result = compute(resolved.map((r) => ({ object: r.object, negated: r.authored.negated })));
2140
+ }
2141
+ catch (err) {
2142
+ return done(err instanceof Error ? err.message : String(err));
2143
+ }
2144
+ // Appearance inherits from the SAME operand three-bvh-csg itself used
2145
+ // for the result's TRANSFORM (see `CSG3D.ts`'s own doc comment) — the
2146
+ // first non-negated selected Part for Union (or the first selected
2147
+ // Part at all, if every one was negated), the first selected Part at
2148
+ // all for Intersect. Not re-derived independently of that choice.
2149
+ const appearanceSource = op === 'union' ? (resolved.find((r) => !r.authored.negated) ?? resolved[0]) : resolved[0];
2150
+ const newPrimitive = {
2151
+ kind: 'mesh',
2152
+ mesh: result.mesh,
2153
+ color: appearanceSource.authored.primitive?.color,
2154
+ material: appearanceSource.authored.primitive?.material,
2155
+ };
2156
+ const newEntity = {
2157
+ id: m.newEntityId,
2158
+ primitive: newPrimitive,
2159
+ // Explicit, same convention `onDropPrimitive3d` already established
2160
+ // — the SDK chose this default, so it's echoed back into the
2161
+ // authored entity rather than left for `loadScene3D`'s fallback to
2162
+ // re-derive later (that fallback exists for scenes authored before
2163
+ // a collider field existed at all, not as the normal path here).
2164
+ collider: defaultColliderForPrimitive(newPrimitive),
2165
+ transform: {
2166
+ position: { x: result.position.x, y: result.position.y, z: result.position.z },
2167
+ rotation: [result.quaternion.x, result.quaternion.y, result.quaternion.z, result.quaternion.w],
2168
+ scale: { x: result.scale.x, y: result.scale.y, z: result.scale.z },
2169
+ },
2170
+ };
2171
+ for (const id of m.entityIds) {
2172
+ const err = deleteEntityLive(id);
2173
+ if (err)
2174
+ console.warn('[umicat/editor] CSG: failed to remove operand', id, err);
2175
+ }
2176
+ const createError = await createEntityLive(newEntity);
2177
+ if (createError)
2178
+ return done(createError);
2179
+ const newObject = objectByEntity.get(newEntity.id);
2180
+ if (newObject)
2181
+ applySelection([newObject]);
2182
+ done(undefined, newEntity);
2183
+ }
2184
+ async function onCsgUnion3d(m) {
2185
+ return doCsgOp(m, 'union', unionOperands);
2186
+ }
2187
+ async function onCsgIntersect3d(m) {
2188
+ return doCsgOp(m, 'intersect', intersectOperands);
2189
+ }
1868
2190
  window.addEventListener('message', (e) => { void onHostMessage(e); });
1869
2191
  /**
1870
2192
  * In-iframe keyboard shortcuts — Delete/Backspace and Ctrl/Cmd+Z only work
@@ -1996,6 +2318,8 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
1996
2318
  if (!scene)
1997
2319
  return;
1998
2320
  gizmo.update(camera);
2321
+ for (const [obj, box] of negatedBoxes)
2322
+ box.setFromObject(obj);
1999
2323
  renderer.setScissorTest(false);
2000
2324
  renderer.render(scene, camera);
2001
2325
  // Second pass: the orientation gizmo, into a small scissored corner
@@ -2070,9 +2394,36 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
2070
2394
  multiSelected = new Set();
2071
2395
  multiBoxes.clear();
2072
2396
  groupDrag = null;
2397
+ // ADR-047 — same reasoning as `multiBoxes.clear()` just above: a prior
2398
+ // scene's boxes were added to that scene, not this one. Re-seed from
2399
+ // the freshly loaded authored data, not carried over.
2400
+ // ADR-051 — a (re)load builds a brand new scene graph, so the previous
2401
+ // grid went with the old one. Same reasoning as the selection
2402
+ // bookkeeping above.
2403
+ snapGrid = null;
2404
+ rebuildSnapGrid();
2405
+ negatedBoxes.clear();
2406
+ for (const e of sceneData.entities) {
2407
+ if (e.negated) {
2408
+ const obj = objectByEntity.get(e.id);
2409
+ if (obj)
2410
+ setNegatedVisual(obj, true);
2411
+ }
2412
+ }
2073
2413
  // Frame the whole scene — auto-fit, since a small template scene and a
2074
2414
  // real level's dozens of entities need wildly different orbit distances.
2075
- const box = new THREE.Box3().setFromObject(scene);
2415
+ // Frame the authored ENTITIES, not `scene` as a whole. ADR-051 adds a
2416
+ // grid helper whose extent is a display choice (step x 100 units) and
2417
+ // has nothing to do with how big the level is — `setFromObject(scene)`
2418
+ // would fold it in and shove the camera back far enough to frame a
2419
+ // 100-unit grid around a 6-unit template. Falls back to the whole scene
2420
+ // when there are no entities at all, which is what the empty-scene case
2421
+ // used to rely on.
2422
+ const box = new THREE.Box3();
2423
+ for (const obj of objectByEntity.values())
2424
+ box.expandByObject(obj, true);
2425
+ if (box.isEmpty())
2426
+ box.setFromObject(scene);
2076
2427
  const size = box.getSize(new THREE.Vector3());
2077
2428
  const center = box.getCenter(new THREE.Vector3());
2078
2429
  const radius = Math.max(size.length() * 0.5, 0.5);
package/dist/scene3d.d.ts CHANGED
@@ -111,7 +111,12 @@ export interface Entity3D {
111
111
  * built from.
112
112
  */
113
113
  primitive?: {
114
- kind: 'box' | 'sphere' | 'plane' | 'cylinder' | 'wedge' | 'corner-wedge';
114
+ /**
115
+ * ADR-047 — `mesh` is a BAKED CSG Union/Intersect result (the
116
+ * editor's Boolean operations), not an authorable shape — it carries
117
+ * no `size`, only a fixed `mesh` geometry buffer, below.
118
+ */
119
+ kind: 'box' | 'sphere' | 'plane' | 'cylinder' | 'wedge' | 'corner-wedge' | 'mesh';
115
120
  size?: Vec3;
116
121
  color?: string;
117
122
  /**
@@ -125,8 +130,38 @@ export interface Entity3D {
125
130
  * already does when both `color` and `map` are present).
126
131
  */
127
132
  material?: string;
133
+ /**
134
+ * ADR-047 — only present for `kind: 'mesh'`. Flat `[x,y,z, x,y,z,
135
+ * ...]` vertex positions and `[i,i,i, ...]` triangle indices, in the
136
+ * entity's OWN local space (the same space `Transform3D.position`
137
+ * places the entity's origin at) — written once, at Union/Intersect
138
+ * time, by `CSG3D.ts`'s operation result; never hand-authored and
139
+ * never edited in place (the shape is fixed; move/rotate/scale/
140
+ * re-color/re-material still work normally via the entity's own
141
+ * `transform`/`color`/`material`, same as any other Part). `normals`
142
+ * is optional — omitted, the renderer computes smooth-per-face
143
+ * normals the same way `triangleListGeometry` already does for
144
+ * wedge/corner-wedge.
145
+ */
146
+ mesh?: {
147
+ positions: number[];
148
+ indices: number[];
149
+ normals?: number[];
150
+ };
128
151
  };
129
152
  collider?: Collider3D;
153
+ /**
154
+ * ADR-047 — marks this Part for SUBTRACTION the next time it (or a
155
+ * selection including it) is Union'd — Roblox's own Negate/Union
156
+ * two-step: Negate alone changes nothing geometrically, it is purely
157
+ * the marker `Union` reads at compute time to decide which selected
158
+ * Parts to ADD versus which to CUT AWAY from the rest. Meaningless
159
+ * (and never set) on anything but a `primitive` entity, and always
160
+ * dropped from whatever NEW entity a Union/Intersect produces — the
161
+ * flag describes "how to combine this Part," not a property the
162
+ * resulting merged shape inherits.
163
+ */
164
+ negated?: boolean;
130
165
  /** Which clip to play on spawn, by SEMANTIC name — see `AnimationMap`. */
131
166
  animation?: {
132
167
  play?: string;
package/dist/scene3d.js CHANGED
@@ -97,6 +97,21 @@ export function groundRestOffset(primitive) {
97
97
  */
98
98
  export function defaultColliderForPrimitive(primitive) {
99
99
  const s = primitive.size ?? { x: 1, y: 1, z: 1 };
100
+ // ADR-047 — a `mesh` Part (a baked CSG result) has no `size` at all; its
101
+ // collider is a convex hull of its OWN baked vertices, same "irregular
102
+ // solid → convexHull" fallback wedge/corner-wedge already use below —
103
+ // an approximation for anything non-convex (e.g. a Subtract that
104
+ // carved a hole clean through), but still the right DEFAULT: Rapier has
105
+ // no "exact concave shape" primitive for a DYNAMIC body, and a hull is
106
+ // always at least as permissive (never blocks something it shouldn't),
107
+ // same tradeoff this function already accepts for wedge/corner-wedge.
108
+ if (primitive.kind === 'mesh') {
109
+ const positions = primitive.mesh?.positions ?? [];
110
+ const points = [];
111
+ for (let i = 0; i + 2 < positions.length; i += 3)
112
+ points.push({ x: positions[i], y: positions[i + 1], z: positions[i + 2] });
113
+ return { shape: { kind: 'convexHull', points }, body: 'fixed' };
114
+ }
100
115
  const shape = primitive.kind === 'box' ? { kind: 'box', halfExtents: { x: s.x / 2, y: s.y / 2, z: s.z / 2 } }
101
116
  : primitive.kind === 'sphere' ? { kind: 'sphere', radius: s.x / 2 }
102
117
  : primitive.kind === 'cylinder' ? { kind: 'cylinder', halfHeight: s.y / 2, radius: s.x / 2 }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umicat/three-sdk",
3
- "version": "1.15.0",
3
+ "version": "1.17.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",
@@ -13,13 +13,16 @@
13
13
  },
14
14
  "scripts": {
15
15
  "build": "tsc",
16
- "test": "npm run build && npm run build:example && node --test scripts/*.test.mjs",
17
- "build:example": "../umicat-template/node_modules/esbuild/bin/esbuild example/src/main.js --bundle --format=esm --outfile=example/public/game.js --alias:@umicat/three-sdk=./dist/index.js --log-level=warning"
16
+ "test": "npm run build && npm run build:example && npm run build:editor-fixture && node --test scripts/*.test.mjs",
17
+ "build:example": "../umicat-template/node_modules/esbuild/bin/esbuild example/src/main.js --bundle --format=esm --outfile=example/public/game.js --alias:@umicat/three-sdk=./dist/index.js --log-level=warning",
18
+ "build:editor-fixture": "../umicat-template/node_modules/esbuild/bin/esbuild scripts/harness/editor-entry.js --bundle --format=esm --outfile=scripts/harness/editor-fixture/editor-bundle.js --alias:@umicat/three-sdk=./dist/index.js --log-level=warning"
18
19
  },
19
20
  "dependencies": {
20
21
  "@dimforge/rapier3d-compat": "^0.14.0",
22
+ "@umicat/platform-sdk": "^0.4.0",
21
23
  "three": "0.186.0",
22
- "@umicat/platform-sdk": "^0.3.0"
24
+ "three-bvh-csg": "^0.0.18",
25
+ "three-mesh-bvh": "^0.9.16"
23
26
  },
24
27
  "devDependencies": {
25
28
  "@types/three": "^0.185.4",