@volter/editor 0.5.57 → 0.5.58
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/BUNDLED_NOTICES +6 -6
- package/dist/.vite/manifest.json +228 -228
- package/dist/assets/{AudioViewer-DILwc7Pt.js → AudioViewer-CEfg6soG.js} +1 -1
- package/dist/assets/{EntityModelDocument-DVlDQ_IJ.js → EntityModelDocument-rBweka7M.js} +1 -1
- package/dist/assets/{EnvironmentAssetDocument-BVGDJjW4.js → EnvironmentAssetDocument-VgR_on1P.js} +1 -1
- package/dist/assets/{GameplaySessionTimeline-X_nMT8Sa.js → GameplaySessionTimeline-B9v8LIxV.js} +1 -1
- package/dist/assets/{ImageViewer-D-aZoyr1.js → ImageViewer-CvnifCXj.js} +1 -1
- package/dist/assets/{InspectorObjectPreview-CpHEw6QH.js → InspectorObjectPreview-gbDaFcDe.js} +1 -1
- package/dist/assets/{JsonAssetDocument-CLVN1V9Z.js → JsonAssetDocument-B-ze7id8.js} +1 -1
- package/dist/assets/{ModelAssetDocument-C60lQ11c.js → ModelAssetDocument-NDTeB7b_.js} +1 -1
- package/dist/assets/{NonThreeAuthoringBootstrap-D8oHDftw.js → NonThreeAuthoringBootstrap-D1oTrvVk.js} +2 -2
- package/dist/assets/{Object3DPreview-CSmLPKkk.js → Object3DPreview-DvXwCq08.js} +2 -2
- package/dist/assets/{OnlineAssetDetail-D8wVVoay.js → OnlineAssetDetail-GdHcOske.js} +2 -2
- package/dist/assets/{SourceAssetViewer-BcOCJ2ye.js → SourceAssetViewer-C0qk5wJl.js} +2 -2
- package/dist/assets/{StageHost-B_YrFNiC.js → StageHost-BU-t7Wwj.js} +4 -4
- package/dist/assets/{ToolObject3DPreview-Crowr7IN.js → ToolObject3DPreview-CP6YmA70.js} +1 -1
- package/dist/assets/{TransientHint-GNwuzA4c.js → TransientHint-Rw3wxMUO.js} +1 -1
- package/dist/assets/{VideoViewer-CjQ4P9AJ.js → VideoViewer-D8aW7n4N.js} +1 -1
- package/dist/assets/{asset-editor-persistence-D3Yy77wZ.js → asset-editor-persistence-COlYs9e4.js} +1 -1
- package/dist/assets/blender-emscripten-engine-BkrPLmPf.js +2 -0
- package/dist/assets/{blender-node-editor.document-BfvoBocD.js → blender-node-editor.document-DtaO2jAu.js} +1 -1
- package/dist/assets/{blender-outliner-model-B8b00oxr.js → blender-outliner-model-CfXIMSXz.js} +1 -1
- package/dist/assets/{blender-properties-tab-0M780SHF.js → blender-properties-tab-DYiaVS6T.js} +3 -3
- package/dist/assets/blender-runtime-host-DGe1KLVZ.js +4 -0
- package/dist/assets/{blender-runtime-skin-DcwXD-m8.js → blender-runtime-skin-CBll8ovN.js} +3 -3
- package/dist/assets/blender-runtime.document-CStrnPJb.js +8 -0
- package/dist/assets/{blender-timeline.document-RtHIpbT1.js → blender-timeline.document-WjHuKO96.js} +1 -1
- package/dist/assets/{blender-uv-editor.document-ChwaS3BG.js → blender-uv-editor.document-CsjAI-Lc.js} +1 -1
- package/dist/assets/{blender-version.status-Bnhf8h1I.js → blender-version.status-BcaIEqih.js} +1 -1
- package/dist/assets/{blender-wali-engine-C7bet0ss.js → blender-wali-engine-Dtwixi7B.js} +1 -1
- package/dist/assets/{blender.command-BCCEp0kb.js → blender.command-B9Qf17Yr.js} +1 -1
- package/dist/assets/{browserAll-Do0ehj3Q.js → browserAll-DAbE1efB.js} +1 -1
- package/dist/assets/{edit-mode-authoring-BX4IRQq9.js → edit-mode-authoring-BBWCwYeE.js} +1 -1
- package/dist/assets/{hosted-asset-materialization-BK7DHisS.js → hosted-asset-materialization-CvAt4P7_.js} +1 -1
- package/dist/assets/{index-5av5LJja.js → index-CY4oDLhJ.js} +348 -348
- package/dist/assets/{models.finder-Bm1YfG95.js → models.finder-CZNTvr_w.js} +1 -1
- package/dist/assets/{product-Ywxte8eQ.js → product-Dr7coa2h.js} +1 -1
- package/dist/assets/{properties-bone-constraints.inspector-Ck0Hzlvr.js → properties-bone-constraints.inspector-DBAuXqr4.js} +1 -1
- package/dist/assets/{properties-bone.inspector-B8M42o0V.js → properties-bone.inspector-C_F8SxhT.js} +1 -1
- package/dist/assets/{properties-collection.inspector-D-RSO5zy.js → properties-collection.inspector-C1DLm9eT.js} +1 -1
- package/dist/assets/{properties-constraints.inspector-DbJa57oa.js → properties-constraints.inspector-BySUEgAb.js} +1 -1
- package/dist/assets/{properties-data.inspector-DLgjbRW6.js → properties-data.inspector-BOvrvedq.js} +1 -1
- package/dist/assets/{properties-material.inspector-B11LZYDW.js → properties-material.inspector-CGJmh_QM.js} +1 -1
- package/dist/assets/{properties-modifiers.inspector-BCWwuA26.js → properties-modifiers.inspector-xnsQ1ddN.js} +1 -1
- package/dist/assets/{properties-object.inspector-UZVJG49S.js → properties-object.inspector-BOEEbStu.js} +1 -1
- package/dist/assets/{properties-output.inspector-XOwcBits.js → properties-output.inspector-NXZnMx4l.js} +1 -1
- package/dist/assets/{properties-particles.inspector-By04vT7R.js → properties-particles.inspector-D6D1g8l3.js} +1 -1
- package/dist/assets/{properties-physics.inspector-D3T7FLdg.js → properties-physics.inspector-DoPfj0an.js} +1 -1
- package/dist/assets/{properties-render.inspector-Y0Rjr9gZ.js → properties-render.inspector-Cvnkkapn.js} +1 -1
- package/dist/assets/{properties-scene.inspector-CfyDWB4W.js → properties-scene.inspector-C2mQ8GLM.js} +1 -1
- package/dist/assets/{properties-texture.inspector-AFRsJx6-.js → properties-texture.inspector-DvASuzXS.js} +1 -1
- package/dist/assets/{properties-view-layer.inspector-Co07LAmQ.js → properties-view-layer.inspector-FIxWmUI0.js} +1 -1
- package/dist/assets/{properties-world.inspector-C7T4JocI.js → properties-world.inspector-BfopwUSa.js} +1 -1
- package/dist/assets/{react-story-board-vrmj74Ng.js → react-story-board-DBO76grK.js} +1 -1
- package/dist/assets/{react-three-rapier.esm-D874pLFD.js → react-three-rapier.esm-Cj4NtDam.js} +1 -1
- package/dist/assets/{session-1bPxsLdy.js → session-Dv4dTRLk.js} +180 -22
- package/dist/assets/{spark.module-D1CUMLYS.js → spark.module-BOFvGTtp.js} +1 -1
- package/dist/assets/{stage-keyboard-Cx90EYIT.js → stage-keyboard-BsKOZggP.js} +1 -1
- package/dist/assets/{stage-overlay-set-duu3P0mZ.js → stage-overlay-set-bQwh25SV.js} +1 -1
- package/dist/assets/{stage-presence-markers-DKH3p_ao.js → stage-presence-markers-CALnBqqb.js} +1 -1
- package/dist/assets/{story-capture-Dqurwlhr.js → story-capture-BLVE1Bck.js} +1 -1
- package/dist/assets/{story-pixi-preview-c78Aygdi.js → story-pixi-preview-B1LxWTHx.js} +1 -1
- package/dist/assets/{story-three-preview-CbZo5B3D.js → story-three-preview-CsjJKTcf.js} +2 -2
- package/dist/assets/{webworkerAll-iMzrvNir.js → webworkerAll-dq7Pw9V8.js} +1 -1
- package/dist/assets/worker-29OHwCKe.js +2 -0
- package/dist/assets/{world-documents-CGbrcsYk.js → world-documents-PX5fRvVn.js} +1 -1
- package/dist-node/cli.js +9 -9
- package/package.json +9 -9
- package/dist/assets/blender-emscripten-engine-C_uFxIuO.js +0 -2
- package/dist/assets/blender-runtime-host-D8NHsAfD.js +0 -4
- package/dist/assets/blender-runtime.document-BixTvrw8.js +0 -7
- package/dist/assets/worker-DTgfRRas.js +0 -1
|
@@ -194,6 +194,7 @@ def _load_post(_arg):
|
|
|
194
194
|
# in wasm (35 s at 1280x720, 48 samples) and \`_photograph\` never ran. The
|
|
195
195
|
# engine ids are taken again on every load.
|
|
196
196
|
ENGINES[:], UNAVAILABLE_ENGINES[:] = _register_engine()
|
|
197
|
+
HISTORY.reset()
|
|
197
198
|
|
|
198
199
|
|
|
199
200
|
# ---------------------------------------------------------------- warnings
|
|
@@ -352,12 +353,11 @@ def _describe_background(background, camera_ray):
|
|
|
352
353
|
"inputs": [{"kind": "math", "operation": "ADD", "clamp": False,
|
|
353
354
|
"inputs": products[:2]}, products[2]]}
|
|
354
355
|
if kind == "ShaderNodeMapping" and socket == "Vector":
|
|
355
|
-
if node.vector_type != "POINT":
|
|
356
|
-
raise NotImplementedError("World Mapping vector type %s" % node.vector_type)
|
|
357
356
|
for name in ("Location", "Rotation", "Scale"):
|
|
358
357
|
if node.inputs[name].links:
|
|
359
358
|
raise NotImplementedError("Linked World Mapping " + name)
|
|
360
|
-
return {"kind": "mapping", "
|
|
359
|
+
return {"kind": "mapping", "vector_type": node.vector_type,
|
|
360
|
+
"vector": value(node.inputs["Vector"]),
|
|
361
361
|
"location": [float(c) for c in node.inputs["Location"].default_value],
|
|
362
362
|
"rotation": [float(c) for c in node.inputs["Rotation"].default_value],
|
|
363
363
|
"scale": [float(c) for c in node.inputs["Scale"].default_value]}
|
|
@@ -402,9 +402,17 @@ def _describe_background(background, camera_ray):
|
|
|
402
402
|
finally:
|
|
403
403
|
visiting.remove(key)
|
|
404
404
|
|
|
405
|
+
color = value(background.inputs["Color"])
|
|
406
|
+
strength = value(background.inputs["Strength"])
|
|
407
|
+
# The field evaluator already implements an unclamped color mix. Mixing
|
|
408
|
+
# black with radiance at factor strength is exact multiplication, including
|
|
409
|
+
# spatially varying strength, with no second shader implementation.
|
|
410
|
+
if not isinstance(strength, (int, float)):
|
|
411
|
+
color = {"kind": "mix_color", "factor": strength, "a": [0.0, 0.0, 0.0],
|
|
412
|
+
"b": color, "clamp_factor": False, "clamp_result": False}
|
|
413
|
+
strength = 1.0
|
|
405
414
|
return {"color": [float(c) for c in list(background.inputs["Color"].default_value)[:3]],
|
|
406
|
-
"strength": float(
|
|
407
|
-
"shader": value(background.inputs["Color"])}
|
|
415
|
+
"strength": float(strength), "shader": color}
|
|
408
416
|
|
|
409
417
|
|
|
410
418
|
def _describe_world(world):
|
|
@@ -417,18 +425,17 @@ def _describe_world(world):
|
|
|
417
425
|
if outputs[0].inputs["Volume"].links:
|
|
418
426
|
raise NotImplementedError("World volume rendering is not implemented")
|
|
419
427
|
background, lighting = _surface_backgrounds(surface[0].from_node)
|
|
420
|
-
for node in (background, lighting):
|
|
421
|
-
if node is not None and node.inputs["Strength"].links:
|
|
422
|
-
raise NotImplementedError("Linked World Background strength is not implemented")
|
|
423
428
|
described = _describe_background(background, camera_ray=True)
|
|
424
429
|
lighting_data = _describe_background(lighting or background, camera_ray=False)
|
|
425
430
|
if lighting_data != described:
|
|
426
431
|
described["lighting"] = lighting_data
|
|
427
|
-
#
|
|
428
|
-
|
|
432
|
+
# Only a wholly constant background can drop the expression: linked
|
|
433
|
+
# Strength may carry spatial radiance even when Color itself is constant.
|
|
434
|
+
if not any(background.inputs[name].is_linked for name in ("Color", "Strength")):
|
|
429
435
|
described.pop("shader", None)
|
|
430
|
-
|
|
431
|
-
|
|
436
|
+
if "lighting" in described and not any(
|
|
437
|
+
(lighting or background).inputs[name].is_linked for name in ("Color", "Strength")):
|
|
438
|
+
described["lighting"].pop("shader", None)
|
|
432
439
|
return described
|
|
433
440
|
|
|
434
441
|
|
|
@@ -780,9 +787,8 @@ class Session:
|
|
|
780
787
|
# How many COLUMN BYTES this frame actually shipped: a move ships
|
|
781
788
|
# zero, a vertex edit one mesh's worth.
|
|
782
789
|
"bytes": int(_blender_web.buffer_size()),
|
|
783
|
-
# Blender's \`is_dirty
|
|
784
|
-
#
|
|
785
|
-
# why \`save_document\` does not read it. See the note there.
|
|
790
|
+
# Blender's \`is_dirty\` is instrumentation, not our save predicate:
|
|
791
|
+
# its value also depends on native undo initialization/checkpoints.
|
|
786
792
|
"dirty": bool(bpy.data.is_dirty),
|
|
787
793
|
}
|
|
788
794
|
# A PRESENT IS WHAT LEAVES THE DOCUMENT STALE, and the predicate is the
|
|
@@ -1060,13 +1066,10 @@ class Session:
|
|
|
1060
1066
|
if self.document is None:
|
|
1061
1067
|
return {"saved": False, "reason": "no-document"}
|
|
1062
1068
|
# \`bpy.data.is_dirty\` IS NOT A PREDICATE HERE, and this is the measurement
|
|
1063
|
-
# rather than a preference.
|
|
1064
|
-
#
|
|
1065
|
-
#
|
|
1066
|
-
#
|
|
1067
|
-
# False. It is False before a save, False after one, and False across a
|
|
1068
|
-
# script that models an entire scene; the only state it ever named here
|
|
1069
|
-
# was "saved".
|
|
1069
|
+
# rather than a preference. Before native undo initialization it stayed
|
|
1070
|
+
# False even after a script built fourteen objects; with explicit undo
|
|
1071
|
+
# checkpoints it can stay True across read-only operations. It is not
|
|
1072
|
+
# a reliable change detector for this request-driven background session.
|
|
1070
1073
|
#
|
|
1071
1074
|
# It was briefly used to skip a redundant write, and it froze the
|
|
1072
1075
|
# document after its first save -- a reopened session could model all
|
|
@@ -1419,6 +1422,109 @@ def _register_engine():
|
|
|
1419
1422
|
return made, unavailable
|
|
1420
1423
|
|
|
1421
1424
|
|
|
1425
|
+
# ---------------------------------------------------------------- native document history
|
|
1426
|
+
|
|
1427
|
+
class NativeHistory:
|
|
1428
|
+
"""Blender owns the snapshots. These ids only address its steps from Code-OSS.
|
|
1429
|
+
|
|
1430
|
+
Background mode supports explicit undo_push (ed_undo_push_exec). Initialize
|
|
1431
|
+
after opening the document, then checkpoint at the request boundary, including
|
|
1432
|
+
scripts that mutate and subsequently fail. Never replay a script to redo it.
|
|
1433
|
+
"""
|
|
1434
|
+
def __init__(self):
|
|
1435
|
+
self.epoch = 0
|
|
1436
|
+
self.serial = 0
|
|
1437
|
+
self.steps = []
|
|
1438
|
+
self.cursor = 0
|
|
1439
|
+
self.events = []
|
|
1440
|
+
self.initialized = False
|
|
1441
|
+
self.group_depth = 0
|
|
1442
|
+
self.group_label = None
|
|
1443
|
+
self.mutation_serial = 0
|
|
1444
|
+
self.moving = False
|
|
1445
|
+
|
|
1446
|
+
def changed(self):
|
|
1447
|
+
self.mutation_serial += 1
|
|
1448
|
+
|
|
1449
|
+
def native_moved(self):
|
|
1450
|
+
# A script can invoke Blender's undo directly. It must not leave our
|
|
1451
|
+
# tokens addressing a different native cursor. Host-owned moves retain
|
|
1452
|
+
# their ledger; external moves invalidate it and start a fresh baseline.
|
|
1453
|
+
if not self.moving:
|
|
1454
|
+
self.reset()
|
|
1455
|
+
|
|
1456
|
+
def reset(self):
|
|
1457
|
+
self.epoch += 1
|
|
1458
|
+
self.steps = []
|
|
1459
|
+
self.cursor = 0
|
|
1460
|
+
self.initialized = False
|
|
1461
|
+
self.group_depth = 0
|
|
1462
|
+
self.group_label = None
|
|
1463
|
+
self.events = [{"reset": True}]
|
|
1464
|
+
|
|
1465
|
+
def begin(self):
|
|
1466
|
+
if self.initialized:
|
|
1467
|
+
return
|
|
1468
|
+
preferences = bpy.context.preferences.edit
|
|
1469
|
+
preferences.use_global_undo = True
|
|
1470
|
+
# Native eviction may exhaust history before our address ledger. poll()
|
|
1471
|
+
# below then refuses instead of claiming a restoration. Bound memory in
|
|
1472
|
+
# the browser worker; retaining hundreds of full scenes can exhaust wasm.
|
|
1473
|
+
preferences.undo_steps = 32
|
|
1474
|
+
preferences.undo_memory_limit = 256
|
|
1475
|
+
if "FINISHED" not in bpy.ops.ed.undo_push(message="Open document"):
|
|
1476
|
+
raise RuntimeError("Blender could not initialize native undo; the edit was not started")
|
|
1477
|
+
self.initialized = True
|
|
1478
|
+
|
|
1479
|
+
def commit(self, label):
|
|
1480
|
+
self.begin()
|
|
1481
|
+
if self.group_depth:
|
|
1482
|
+
self.group_label = self.group_label or label
|
|
1483
|
+
return
|
|
1484
|
+
bpy.context.view_layer.update()
|
|
1485
|
+
if "FINISHED" not in bpy.ops.ed.undo_push(message=label[:63]):
|
|
1486
|
+
raise RuntimeError("Blender could not checkpoint this edit in native undo")
|
|
1487
|
+
self.serial += 1
|
|
1488
|
+
token = "%s:%s:%s" % (SESSION.session, self.epoch, self.serial)
|
|
1489
|
+
self.steps[self.cursor:] = [token]
|
|
1490
|
+
# Blender keeps at most undo_steps native states, including the baseline.
|
|
1491
|
+
if len(self.steps) > 31:
|
|
1492
|
+
del self.steps[:-31]
|
|
1493
|
+
self.cursor = len(self.steps)
|
|
1494
|
+
self.events.append({"id": token, "label": label,
|
|
1495
|
+
"resource": SESSION.document_relative})
|
|
1496
|
+
|
|
1497
|
+
def move(self, token, direction):
|
|
1498
|
+
if self.group_depth:
|
|
1499
|
+
raise RuntimeError("Finish the current Blender gesture before undo or redo")
|
|
1500
|
+
index = self.cursor - 1 if direction == "undo" else self.cursor
|
|
1501
|
+
if index < 0 or index >= len(self.steps) or self.steps[index] != token:
|
|
1502
|
+
raise RuntimeError("Blender history expired or changed outside this edit; no other step was restored")
|
|
1503
|
+
operator = bpy.ops.ed.undo if direction == "undo" else bpy.ops.ed.redo
|
|
1504
|
+
if not operator.poll():
|
|
1505
|
+
raise RuntimeError("Blender cannot %s this native step in the current context" % direction)
|
|
1506
|
+
self.moving = True
|
|
1507
|
+
try:
|
|
1508
|
+
if "FINISHED" not in operator():
|
|
1509
|
+
raise RuntimeError("Blender did not finish %s" % direction)
|
|
1510
|
+
finally:
|
|
1511
|
+
self.moving = False
|
|
1512
|
+
self.cursor += -1 if direction == "undo" else 1
|
|
1513
|
+
# Native undo replaces datablocks. Both revision caches must forget their
|
|
1514
|
+
# old pointers before the restored scene is exported to the presenter.
|
|
1515
|
+
_blender_web.session_reset()
|
|
1516
|
+
SESSION.forget()
|
|
1517
|
+
SESSION.present()
|
|
1518
|
+
return {"moved": True}
|
|
1519
|
+
|
|
1520
|
+
|
|
1521
|
+
HISTORY = NativeHistory()
|
|
1522
|
+
|
|
1523
|
+
|
|
1524
|
+
@bpy.app.handlers.persistent
|
|
1525
|
+
def _history_post(_arg):
|
|
1526
|
+
HISTORY.native_moved()
|
|
1527
|
+
|
|
1422
1528
|
# ---------------------------------------------------------------- the MCP tools
|
|
1423
1529
|
|
|
1424
1530
|
def get_scene_info():
|
|
@@ -2049,6 +2155,7 @@ def rna_set(path, identifier, value, index=None):
|
|
|
2049
2155
|
setattr(target, identifier, value)
|
|
2050
2156
|
else:
|
|
2051
2157
|
getattr(target, identifier)[index] = value
|
|
2158
|
+
HISTORY.changed()
|
|
2052
2159
|
return {"path": path, "property": identifier, "value": _rna_value(target, prop)}
|
|
2053
2160
|
|
|
2054
2161
|
|
|
@@ -3925,28 +4032,35 @@ def outliner_set(path, column, value):
|
|
|
3925
4032
|
if isinstance(target, bpy.types.Object):
|
|
3926
4033
|
if column == "hide":
|
|
3927
4034
|
target.hide_set(value, view_layer=bpy.context.view_layer)
|
|
4035
|
+
HISTORY.changed()
|
|
3928
4036
|
return {"path": path, "column": column, "value": bool(target.hide_get())}
|
|
3929
4037
|
if column == "render":
|
|
3930
4038
|
target.hide_render = value
|
|
4039
|
+
HISTORY.changed()
|
|
3931
4040
|
return {"path": path, "column": column, "value": bool(target.hide_render)}
|
|
3932
4041
|
if column == "viewport":
|
|
3933
4042
|
target.hide_viewport = value
|
|
4043
|
+
HISTORY.changed()
|
|
3934
4044
|
return {"path": path, "column": column, "value": bool(target.hide_viewport)}
|
|
3935
4045
|
if isinstance(target, bpy.types.LayerCollection):
|
|
3936
4046
|
if column in ("exclude", "hide"):
|
|
3937
4047
|
member = "exclude" if column == "exclude" else "hide_viewport"
|
|
3938
4048
|
setattr(target, member, value)
|
|
4049
|
+
HISTORY.changed()
|
|
3939
4050
|
return {"path": path, "column": column, "value": bool(getattr(target, member))}
|
|
3940
4051
|
if column == "render":
|
|
3941
4052
|
target.collection.hide_render = value
|
|
4053
|
+
HISTORY.changed()
|
|
3942
4054
|
return {"path": path, "column": column, "value": bool(target.collection.hide_render)}
|
|
3943
4055
|
if isinstance(target, bpy.types.Modifier):
|
|
3944
4056
|
member = {"render": "show_render", "viewport": "show_viewport"}.get(column)
|
|
3945
4057
|
if member is not None:
|
|
3946
4058
|
setattr(target, member, not value)
|
|
4059
|
+
HISTORY.changed()
|
|
3947
4060
|
return {"path": path, "column": column, "value": not getattr(target, member)}
|
|
3948
4061
|
if isinstance(target, bpy.types.Constraint) and column == "hide":
|
|
3949
4062
|
target.enabled = not value
|
|
4063
|
+
HISTORY.changed()
|
|
3950
4064
|
return {"path": path, "column": column, "value": not target.enabled}
|
|
3951
4065
|
raise ValueError(
|
|
3952
4066
|
"Blender's Outliner draws no %r column on a %s, so nothing was written -- the columns "
|
|
@@ -3955,6 +4069,45 @@ def outliner_set(path, column, value):
|
|
|
3955
4069
|
|
|
3956
4070
|
|
|
3957
4071
|
def dispatch(request):
|
|
4072
|
+
op = request.get("op")
|
|
4073
|
+
if op == "history-begin":
|
|
4074
|
+
HISTORY.begin()
|
|
4075
|
+
HISTORY.group_depth += 1
|
|
4076
|
+
return None
|
|
4077
|
+
if op == "history-end":
|
|
4078
|
+
if HISTORY.group_depth == 0:
|
|
4079
|
+
raise RuntimeError("No Blender gesture is open")
|
|
4080
|
+
HISTORY.group_depth -= 1
|
|
4081
|
+
if HISTORY.group_depth == 0 and HISTORY.group_label:
|
|
4082
|
+
label, HISTORY.group_label = HISTORY.group_label, None
|
|
4083
|
+
HISTORY.commit(label)
|
|
4084
|
+
return None
|
|
4085
|
+
if op == "history-events":
|
|
4086
|
+
events, HISTORY.events = HISTORY.events, []
|
|
4087
|
+
return events
|
|
4088
|
+
if op == "history-step":
|
|
4089
|
+
if request["direction"] not in ("undo", "redo"):
|
|
4090
|
+
raise ValueError("Unknown history direction")
|
|
4091
|
+
return HISTORY.move(request["token"], request["direction"])
|
|
4092
|
+
mutation = op in ("execute", "rna-set", "outliner-set") and request.get("history", True)
|
|
4093
|
+
if not mutation:
|
|
4094
|
+
return _dispatch(request)
|
|
4095
|
+
HISTORY.begin()
|
|
4096
|
+
before = HISTORY.mutation_serial
|
|
4097
|
+
epoch = HISTORY.epoch
|
|
4098
|
+
try:
|
|
4099
|
+
return _dispatch(request)
|
|
4100
|
+
finally:
|
|
4101
|
+
# Loading a file resets Blender's native stack. Its final state cannot
|
|
4102
|
+
# serve as both the before and after of an invented undo checkpoint.
|
|
4103
|
+
if HISTORY.epoch == epoch and HISTORY.mutation_serial != before:
|
|
4104
|
+
HISTORY.commit(request.get("label") or {
|
|
4105
|
+
"execute": "Blender Python", "rna-set": "Set " + request.get("property", "property"),
|
|
4106
|
+
"outliner-set": "Set " + request.get("column", "visibility"),
|
|
4107
|
+
}[op])
|
|
4108
|
+
|
|
4109
|
+
|
|
4110
|
+
def _dispatch(request):
|
|
3958
4111
|
op = request.get("op")
|
|
3959
4112
|
if op == "execute":
|
|
3960
4113
|
engine = bpy.context.scene.render.engine
|
|
@@ -3967,6 +4120,9 @@ def dispatch(request):
|
|
|
3967
4120
|
absent = _absent_capability(request["code"])
|
|
3968
4121
|
if absent is not None:
|
|
3969
4122
|
return {"executed": False, "result": "", "error": absent}
|
|
4123
|
+
# Arbitrary Python can partially mutate before throwing. Once execution
|
|
4124
|
+
# starts it needs a checkpoint; capability refusals above do not.
|
|
4125
|
+
HISTORY.changed()
|
|
3970
4126
|
answer = execute(request["code"])
|
|
3971
4127
|
# Every mutation is presented, the rule: the Model
|
|
3972
4128
|
# document is what the agent is looking at.
|
|
@@ -4076,6 +4232,8 @@ def dispatch(request):
|
|
|
4076
4232
|
|
|
4077
4233
|
_prepare_directories()
|
|
4078
4234
|
bpy.app.handlers.load_post.append(_load_post)
|
|
4235
|
+
bpy.app.handlers.undo_post.append(_history_post)
|
|
4236
|
+
bpy.app.handlers.redo_post.append(_history_post)
|
|
4079
4237
|
ENGINES, UNAVAILABLE_ENGINES = _register_engine()
|
|
4080
4238
|
_say("@@VGAI-READY " + json.dumps({"blender": bpy.app.version_string, "engines": ENGINES,
|
|
4081
4239
|
"unavailableEngines": UNAVAILABLE_ENGINES}))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a0 as QQ,g as cB,Z as JC,ad as kB,a as OA,V as F,ae as RB,W as BQ,i as CQ,j as nI,v as sI,af as Hg,Q as Z,x as FA,K as lI,ag as BA,u as v,k as vQ,$ as Ww,ah as UC,p as jw,L as gC,ai as nC,aj as eC,ak as zQ,al as HC,am as EQ,an as LC,ab as iQ,ao as FB,h as og,d as YA,c as gI,ap as dg,aq as RQ,ar as pA,as as Lg,at as YC,au as QC,av as Yg,z as vw,I as zw,aw as _w,F as $w,ax as As,ay as Is,az as gs,l as Qs,aA as FQ,aa as Bs,a1 as Cs,y as Es}from"./three.module-BynznMJN.js";import{I as SB}from"./index-
|
|
1
|
+
import{a0 as QQ,g as cB,Z as JC,ad as kB,a as OA,V as F,ae as RB,W as BQ,i as CQ,j as nI,v as sI,af as Hg,Q as Z,x as FA,K as lI,ag as BA,u as v,k as vQ,$ as Ww,ah as UC,p as jw,L as gC,ai as nC,aj as eC,ak as zQ,al as HC,am as EQ,an as LC,ab as iQ,ao as FB,h as og,d as YA,c as gI,ap as dg,aq as RQ,ar as pA,as as Lg,at as YC,au as QC,av as Yg,z as vw,I as zw,aw as _w,F as $w,ax as As,ay as Is,az as gs,l as Qs,aA as FQ,aa as Bs,a1 as Cs,y as Es}from"./three.module-BynznMJN.js";import{I as SB}from"./index-CY4oDLhJ.js";import"./index-DaQZGF7d.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./jsx-runtime-DPjLkJKQ.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-D2LwEE0L.js";import"./client-DNXj_opT.js";class _Q extends LC{constructor(A,I){super(),this.ordering=A,this.setAttribute("position",new iQ(is,3)),this.setIndex(new iQ(Ds,1)),this._maxInstanceCount=A.length,this.instanceCount=I,this.attribute=new Is(A,1,!1,1),this.attribute.setUsage(gs),this.setAttribute("splatIndex",this.attribute)}update(A,I){this.ordering=A,this.attribute.array=A,this.instanceCount=I,this.attribute.addUpdateRange(0,I),this.attribute.needsUpdate=!0}}const is=new Float32Array([-1,-1,0,1,-1,0,1,1,0,-1,1,0]),Ds=new Uint16Array([0,1,2,0,2,3]),rC=`(function() {
|
|
2
2
|
"use strict";
|
|
3
3
|
class CsplatArray {
|
|
4
4
|
static __wrap(ptr) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o}from"./index-DaQZGF7d.js";import{J as t}from"./index-
|
|
1
|
+
import{r as o}from"./index-DaQZGF7d.js";import{J as t}from"./index-CY4oDLhJ.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./jsx-runtime-DPjLkJKQ.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-D2LwEE0L.js";import"./client-DNXj_opT.js";import"./three.module-BynznMJN.js";function v({stage:r}){return o.useEffect(()=>t(r.store,r.viewport,r.canvas),[r.store,r.viewport,r.canvas]),null}export{v as StageKeyboardBinding};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./jsx-runtime-DPjLkJKQ.js";import{r}from"./index-DaQZGF7d.js";import{b5 as C,T as d,b6 as I,b7 as E,b8 as z,b9 as O,ba as y,t as k,bb as $,bc as f,bd as j,a4 as w,be as N,bf as U,bg as G,bh as W,B as m,bi as V,bj as F,bk as P,bl as B,bm as L,bn as M,bo as K,bp as _,bq as q,br as Z,bs as J,bt as Q,bu as X,bv as Y,bw as ee,bx as te,by as se,bz as re}from"./index-
|
|
1
|
+
import{a as e}from"./jsx-runtime-DPjLkJKQ.js";import{r}from"./index-DaQZGF7d.js";import{b5 as C,T as d,b6 as I,b7 as E,b8 as z,b9 as O,ba as y,t as k,bb as $,bc as f,bd as j,a4 as w,be as N,bf as U,bg as G,bh as W,B as m,bi as V,bj as F,bk as P,bl as B,bm as L,bn as M,bo as K,bp as _,bq as q,br as Z,bs as J,bt as Q,bu as X,bv as Y,bw as ee,bx as te,by as se,bz as re}from"./index-CY4oDLhJ.js";import"./index-CtzuWnCS.js";import"./index-D2LwEE0L.js";import{s as A,o as b}from"./StageHost-BU-t7Wwj.js";import{T as ne}from"./TransientHint-Rw3wxMUO.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./client-DNXj_opT.js";import"./index-CinJrH5C.js";import"./three.module-BynznMJN.js";import"./clip-planes-CnAI6DZn.js";import"./OrbitControls-BHxt84w6.js";import"./LineSegments2-vfeDUBfs.js";import"./viewport-pick-context-DkawXbEi.js";import"./editor-presentation-activity-C7SNSmTd.js";function H(){const t=z("viewport.frameSelection");return`Orbit: right-drag (or Alt+drag) · Pan: middle-drag · Zoom: wheel${t?` · ${t}: frame selection`:""}`}function R(){const t=z("viewport.toggleSnap");return`Trackpad: two-finger pan · pinch zoom · Alt+drag orbit${t?` · Snap: ${t}`:""}`}function D(){r.useSyncExternalStore(I,E,E)}function oe(){const t=r.useSyncExternalStore(A,b,b);return D(),t?null:e.jsxs(C,{variant:"overlay",border:!0,className:"vgai-viewport-controls-hint vgai-chrome-island vgai-glass-island","data-island-scale":"compact",style:{pointerEvents:"none"},children:[e.jsx(d,{variant:"code","data-testid":"viewport-controls-hint",children:H()}),e.jsx(d,{variant:"code",children:R()})]})}function g(t){return t.toFixed(2)}function ie(){const t=O(),[n,s]=r.useState({x:0,y:0,z:0}),[o,a]=r.useState({x:0,y:0,z:0}),i=r.useRef(0),c=r.useSyncExternalStore(A,b,b);return D(),r.useEffect(()=>{function p(){const u=t.cameraPosition,h=t.cameraTarget;s(l=>l.x!==u.x||l.y!==u.y||l.z!==u.z?{x:u.x,y:u.y,z:u.z}:l),a(l=>l.x!==h.x||l.y!==h.y||l.z!==h.z?{x:h.x,y:h.y,z:h.z}:l),i.current=requestAnimationFrame(p)}return i.current=requestAnimationFrame(p),()=>cancelAnimationFrame(i.current)},[t]),e.jsxs(C,{variant:"overlay",border:!0,className:"vgai-camera-info vgai-chrome-island vgai-glass-island","data-island-scale":"compact",children:[e.jsxs(y,{gap:8,align:"center",style:{whiteSpace:"nowrap"},children:[e.jsxs(d,{variant:"code",children:["Pos ",g(n.x)," ",g(n.y)," ",g(n.z)]}),e.jsxs(d,{variant:"code",children:["Target ",g(o.x)," ",g(o.y)," ",g(o.z)]})]}),!c&&e.jsxs(e.Fragment,{children:[e.jsx(d,{variant:"code","data-testid":"viewport-controls-hint",style:{whiteSpace:"nowrap"},children:H()}),e.jsx(d,{variant:"code",style:{whiteSpace:"nowrap"},children:R()})]})]})}function ae(){const t=O(),[,n]=r.useState(0),s=$();return r.useEffect(()=>{const o=setInterval(()=>n(a=>a+1),200);return()=>clearInterval(o)},[]),e.jsxs("div",{className:"vgai-hud-overlay vgai-chrome-island vgai-glass-island","data-island-scale":"compact","data-hud-border":"strong",style:{position:"absolute",top:"var(--vgai-viewport-overlay-hud-top, 48px)",right:8,padding:"6px 10px",pointerEvents:"auto",fontSize:"var(--vgai-font-base)",color:k.content.primary,fontFamily:k.typography.mono,lineHeight:"16px"},children:[e.jsxs("div",{children:["FPS: ",t.fps.toFixed(0)]}),e.jsxs("div",{children:["Draw: ",t.drawCalls]}),e.jsxs("div",{children:["Tris: ",t.triangles.toLocaleString()]}),e.jsxs("div",{children:["Frame: ",t.frameTime.toFixed(1),"ms"]}),s!==null&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["Heap: ",s.heapUsedMB===null?"n/a":`${s.heapUsedMB.toFixed(0)}MB`,s.heapLimitMB===null?"":` / ${s.heapLimitMB.toFixed(0)}MB`]}),e.jsxs("div",{children:["Mount epochs: ",s.mountEpochs]}),e.jsxs("div",{children:["Canvas: ",s.canvasMB.toFixed(1),"MB ×",s.canvases]}),s.textures!==void 0&&e.jsxs("div",{children:["GPU: ",s.textures," tex, ",s.geometries??0," geo",s.programs===void 0?"":`, ${s.programs} prog`]})]})]})}let x={projection:"perspective"};const S=new Set;function T(){return x}function ce(t){return S.add(t),()=>S.delete(t)}function v(t){if(x.projection!==t){x={...x,projection:t};for(const n of S)n()}}function le({store:t}){const n=r.useSyncExternalStore(ce,T,T),[s,o]=r.useState(!1),a=r.useRef(null);r.useEffect(()=>{if(!s)return;const c=p=>{a.current?.contains(p.target)||o(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]);const i=c=>{v("orthographic"),t.setViewPreset(c)};return e.jsxs("div",{ref:a,className:"vgai-viewport-popover-anchor",children:[e.jsx(f,{text:n.projection==="perspective"?"Perspective":"Orthographic",children:e.jsx(j,{"aria-label":"Viewport views","aria-expanded":s,size:"comfortable",onClick:()=>o(c=>!c),children:e.jsx(w,{icon:s?N:U,size:"md"})})}),s?e.jsx(G,{style:{minWidth:230},children:e.jsxs(W,{gap:3,children:[e.jsx(d,{variant:"caption",tone:"muted",children:"Projection"}),e.jsxs(y,{gap:1,children:[e.jsx(m,{size:"compact",variant:n.projection==="perspective"?"primary":"ghost",onClick:()=>v("perspective"),children:"Perspective"}),e.jsx(m,{size:"compact",variant:n.projection==="orthographic"?"primary":"ghost",onClick:()=>v("orthographic"),children:"Orthographic"})]}),e.jsx(d,{variant:"caption",tone:"muted",children:"Axis View"}),e.jsxs(y,{gap:1,children:[e.jsx(m,{size:"compact",variant:"ghost",onClick:()=>i("top"),children:"Top"}),e.jsx(m,{size:"compact",variant:"ghost",onClick:()=>i("front"),children:"Front"}),e.jsx(m,{size:"compact",variant:"ghost",onClick:()=>i("right"),children:"Right"})]})]})}):null]})}function de({store:t,documentId:n}){r.useSyncExternalStore(t.subscribe,t.getSnapshot),r.useSyncExternalStore(V,F),r.useSyncExternalStore(P,B),r.useSyncExternalStore(L,M);const{adapter:s}=K(t),o=_(n);r.useSyncExternalStore(o?.subscribe??pe,o?.getSnapshot??ue);const a=o?o.presentation().grid:t.showGrid;return e.jsxs(q,{label:"Viewport display",className:"vgai-viewport-toolbar vgai-viewport-toolbar-right",children:[e.jsx(f,{text:`Grid: ${a?"On":"Off"}`,children:e.jsx(j,{"aria-label":"Toggle grid","aria-pressed":a,size:"comfortable",onClick:()=>o?o.setGrid(!a):t.toggleGrid(),children:e.jsx(w,{icon:Z,size:"md"})})}),e.jsx(ge,{store:t}),e.jsx(J,{mode:t.shadingMode,onChange:i=>t.setShadingMode(i)}),e.jsx(le,{store:t}),e.jsx(he,{adapter:s,store:t})]})}const pe=()=>()=>{},ue=()=>0,he=r.memo(function({adapter:n,store:s}){const[,o]=r.useReducer(i=>i+1,0);r.useEffect(()=>n.subscribe?.(o),[n]);const a=r.useMemo(()=>X(n),[n,s.contentVersion]);return a===0?null:e.jsx(f,{text:`Open Light Explorer · ${a} ${a===1?"light":"lights"}`,children:e.jsx(j,{"aria-label":"Open Light Explorer",size:"comfortable",onClick:()=>ee(te.lightExplorer.id),children:e.jsx(w,{icon:Y,size:"md"})})})});function ge({store:t}){const n=[{key:"bounds",label:"Bounds"},{key:"lights",label:"Lights"},{key:"cameras",label:"Cameras"},{key:"colliders",label:"Colliders"},{key:"joints",label:"Joints"},{key:"particles",label:"Particle Emitters"},{key:"lod",label:"LOD"},{key:"audio",label:"Audio"},{key:"splines",label:"Splines"},{key:"navmesh",label:"NavMesh"},{key:"constraints",label:"Constraints"},{key:"reflectionProbes",label:"Reflection Probes"},{key:"triggerVolumes",label:"Trigger Volumes"},{key:"skeletons",label:"Skeletons"},{key:"weights",label:"Weights"}];return e.jsx(Q,{label:"Helpers",master:{enabled:t.showHelpers,onToggle:()=>t.toggleHelpers()},choices:n.map(s=>({id:s.key,label:s.label,enabled:t.helperVisibility[s.key],onToggle:()=>t.toggleHelperType(s.key)}))})}function Pe({store:t,documentId:n,stage:s,active:o,chrome:a}){const i=s?.store??t;r.useSyncExternalStore(t.subscribe,t.getShellSnapshot??t.getSnapshot),r.useSyncExternalStore(i.subscribe,i.getShellSnapshot??i.getSnapshot),r.useSyncExternalStore(P,B),r.useSyncExternalStore(L,M),r.useSyncExternalStore(V,F);const c=se(t,n,a),p=re(c);return e.jsxs(e.Fragment,{children:[p?e.jsxs(e.Fragment,{children:[e.jsx(de,{store:i,documentId:n}),e.jsx(ie,{})]}):null,!p&&c.surface==="three"?e.jsx(oe,{}):null,c.surface==="three"&&i.showStats&&e.jsx(ae,{}),o?e.jsx(ne,{}):null]})}export{Pe as StageOverlaySet};
|
package/dist/assets/{stage-presence-markers-DKH3p_ao.js → stage-presence-markers-CALnBqqb.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./jsx-runtime-DPjLkJKQ.js";import"./index-DaQZGF7d.js";import"./index-CtzuWnCS.js";import{ab as H,ac as B,Y as W,ad as N,ae as k,af as J,ag as U}from"./index-
|
|
1
|
+
import"./jsx-runtime-DPjLkJKQ.js";import"./index-DaQZGF7d.js";import"./index-CtzuWnCS.js";import{ab as H,ac as B,Y as W,ad as N,ae as k,af as J,ag as U}from"./index-CY4oDLhJ.js";import"./index-D2LwEE0L.js";import{au as K,a as ee,k as te,bb as ne,d as P,e as oe,i as re,bc as ie,bd as ae,Q as se,V as I,av as ce,be as le,aC as de,aa as pe,aD as ue,b7 as fe}from"./three.module-BynznMJN.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./index-CinJrH5C.js";import"./client-DNXj_opT.js";let v={document:null,file:null,oid:null,selection:[],camera:null,gesture:null},w="",R=!1,S=!1;const ge=100;function j(){R||S||(R=!0,globalThis.setTimeout(()=>{R=!1;const e=JSON.stringify(v);e!==w&&(w=e,S=!0,H(v).catch(()=>{w=""}).finally(()=>{S=!1,JSON.stringify(v)!==w&&j()}))},ge))}function C(e){v={...v,...e},j()}function me(){const e=document.querySelector(`.${J}`);return(e?getComputedStyle(e).getPropertyValue("--vgai-content-on-accent").trim():"")||U.color.content.onAccent}function Q(e,r){const n=e.image,o=n.getContext("2d");if(!o)return;o.clearRect(0,0,n.width,n.height),o.fillStyle=r.color,o.beginPath(),o.roundRect(2,2,n.width-4,n.height-4,16),o.fill(),o.fillStyle=me(),o.font="600 22px system-ui, sans-serif",o.textAlign="center",o.textBaseline="middle";const c=r.kind==="agent"?" · AI":"";o.fillText(`${r.displayName}${c}`,n.width/2,n.height/2,238),e.needsUpdate=!0}function ye(e){const r=new te(50,1,.2,1.4),n=new ne(r),o=new P(e.color);n.setColors(o,o,o,o,o),n.name=`Collaboration camera: ${e.displayName}`,n.userData.editorOnly=!0;const c=document.createElement("canvas");c.width=256,c.height=64;const p=new oe(c);p.colorSpace=re;const d=new ie(new ae({map:p,depthTest:!1,transparent:!0}));return d.name=`Collaboration label: ${e.displayName}`,d.userData.editorOnly=!0,d.scale.set(1.8,.45,1),d.renderOrder=1e4,Q(p,e),{camera:r,helper:n,label:d,texture:p,signature:"",targetPosition:new I,targetQuaternion:new se,targetFov:50,initialized:!1}}function he(e,r){const n=r.presence.camera;if(!n)return;e.targetPosition.set(n.x,n.y,n.z);const o=new ce;o.position.copy(e.targetPosition),o.lookAt(n.targetX,n.targetY,n.targetZ),e.targetQuaternion.copy(o.quaternion),e.targetFov=n.fov,e.initialized||(e.initialized=!0,e.camera.position.copy(e.targetPosition),e.camera.quaternion.copy(e.targetQuaternion),e.camera.fov=e.targetFov);const c=`${r.displayName}|${r.kind}|${r.color}|${r.status}`;c!==e.signature&&(e.signature=c,Q(e.texture,r))}function ve(e,r){const n=1-Math.exp(-12*Math.max(0,r));e.camera.position.lerp(e.targetPosition,n),e.camera.quaternion.slerp(e.targetQuaternion,n),e.camera.fov+=(e.targetFov-e.camera.fov)*n,e.camera.updateProjectionMatrix(),e.camera.updateMatrixWorld(!0),e.helper.update(),e.label.position.copy(e.camera.position),e.label.position.y+=.55}function Z(e){e.helper.removeFromParent(),e.label.removeFromParent(),e.helper.dispose(),e.texture.dispose(),e.label.material.dispose()}function be(e,r){const n=B(e),o=new le(n,new P(r));return o.name=`Collaboration selection: ${e.name||e.uuid}`,o.userData.editorOnly=!0,o.renderOrder=9999,o.material.depthTest=!1,{object:e,box:n,helper:o}}function M(e){e.helper.removeFromParent(),e.helper.geometry.dispose(),e.helper.material.dispose()}function we(e){if(!e||e.type!=="pointer-ray"||!["originX","originY","originZ","directionX","directionY","directionZ","length"].every(p=>typeof e[p]=="number"&&Number.isFinite(e[p])))return null;const n=new I(e.originX,e.originY,e.originZ),o=new I(e.directionX,e.directionY,e.directionZ),c=Math.min(1e3,Math.max(.1,e.length));return o.lengthSq()<1e-6?null:{origin:n,end:n.clone().add(o.normalize().multiplyScalar(c))}}function Oe(e){const{scene:r,store:n,documentId:o,container:c,canvas:p,viewport:d,readVisibleCameraPose:E}=e,y=()=>W()===o,b=()=>{if(!y())return;const i=E();C({camera:{x:i.position.x,y:i.position.y,z:i.position.z,targetX:i.target.x,targetY:i.target.y,targetZ:i.target.z,fov:i.fov}})};d.orbitControls.addEventListener("change",b);let x=!1;const z=i=>{const s=i.value===!0;x=s,y()&&C({gesture:s?{type:"transform",selection:[...n.selectedEntityIds]}:null})};d.transformControls.addEventListener("dragging-changed",z);const T=new K,L=new ee,F=i=>{if(x||i.buttons!==0||!y())return;const s=p.getBoundingClientRect();if(s.width<=0||s.height<=0)return;L.set((i.clientX-s.left)/s.width*2-1,-((i.clientY-s.top)/s.height)*2+1),T.setFromCamera(L,d.renderCamera);const l=T.ray,m=E();C({gesture:{type:"pointer-ray",originX:l.origin.x,originY:l.origin.y,originZ:l.origin.z,directionX:l.direction.x,directionY:l.direction.y,directionZ:l.direction.z,length:Math.max(2,m.position.distanceTo(m.target))}})},O=()=>{!x&&y()&&C({gesture:null})};c.addEventListener("pointermove",F),c.addEventListener("pointerleave",O),b();const f=new Map,u=new Map,g=new Map;let Y=-1;const V=()=>{const i=N();if(!i||i.sequence===Y)return;Y=i.sequence;const s=i.participants.filter(t=>t.participantId!==k&&t.presence.document===o),l=s.filter(t=>t.presence.camera),m=new Set(l.map(t=>t.participantId));for(const[t,a]of f)m.has(t)||(Z(a),f.delete(t));for(const t of l){let a=f.get(t.participantId);a||(a=ye(t),f.set(t.participantId,a),r.add(a.helper,a.label)),he(a,t)}const D=s.flatMap(t=>t.presence.selection.slice(0,20).map(a=>({key:`${t.participantId}:${a}`,objectId:a,color:t.color}))),_=new Set(D.map(t=>t.key));for(const[t,a]of u)_.has(t)||(M(a),u.delete(t));for(const t of D){const a=n.objectMap.get(t.objectId),h=u.get(t.key);if(!a){h&&(M(h),u.delete(t.key));continue}if(h?.object===a)continue;h&&M(h);const $=be(a,t.color);u.set(t.key,$),r.add($.helper)}const X=s.flatMap(t=>{const a=we(t.presence.gesture);return a?[{participantId:t.participantId,color:t.color,ray:a}]:[]}),G=new Set(X.map(t=>t.participantId));for(const[t,a]of g)G.has(t)||(q(a),g.delete(t));for(const t of X){let a=g.get(t.participantId);a||(a=Ce(t.color),g.set(t.participantId,a),r.add(a.line)),Me(a,t.ray)}},A=i=>{if(!y())return;const s=i.detail?.participantId;if(typeof s!="string")return;const l=N()?.participants.find(m=>m.participantId===s)?.presence.camera;l&&n.setCameraPose({x:l.x,y:l.y,z:l.z},{x:l.targetX,y:l.targetY,z:l.targetZ},l.fov)};return window.addEventListener("editor:collaboration-join",A),{reportCamera:b,syncMarkers:i=>{V();for(const s of f.values())ve(s,i);for(const s of u.values())B(s.object,s.box)},dispose:()=>{d.orbitControls.removeEventListener("change",b),d.transformControls.removeEventListener("dragging-changed",z),c.removeEventListener("pointermove",F),c.removeEventListener("pointerleave",O),window.removeEventListener("editor:collaboration-join",A);for(const i of f.values())Z(i);f.clear();for(const i of u.values())M(i);u.clear();for(const i of g.values())q(i);g.clear()}}}function Ce(e){const r=new de(new Float32Array(6),3),n=new pe;n.setAttribute("position",r);const o=new ue({color:new P(e),depthTest:!1,transparent:!0,opacity:.9}),c=new fe(n,o);return c.name="Collaboration pointer ray",c.userData.editorOnly=!0,c.renderOrder=10001,{line:c,positions:r}}function Me(e,r){e.positions.setXYZ(0,r.origin.x,r.origin.y,r.origin.z),e.positions.setXYZ(1,r.end.x,r.end.y,r.end.z),e.positions.needsUpdate=!0,e.line.geometry.computeBoundingSphere()}function q(e){e.line.removeFromParent(),e.line.geometry.dispose(),e.line.material.dispose()}export{Oe as bindStagePresenceMarkers};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as E}from"./react-story-board-vrmj74Ng.js";import{aS as I,a9 as M,t as $,aT as R,az as T,aU as D,aV as k,aW as L,aX as O,aY as N,aZ as U,a_ as W,a$ as A,b0 as B,aO as j,b1 as F,aa as H,b2 as G,b3 as V}from"./index-5av5LJja.js";import{a as b}from"./jsx-runtime-DPjLkJKQ.js";import{r as _}from"./index-DaQZGF7d.js";import"./index-CtzuWnCS.js";import"./index-D2LwEE0L.js";import{awaitPixiStoryFrame as z}from"./story-pixi-preview-c78Aygdi.js";import{supportsThreeStoryCapture as q,captureStoryComponentThumbnail as K,isStoryThreeClassificationRefusal as Y}from"./story-three-preview-CbZo5B3D.js";import"./client-DNXj_opT.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./index-CinJrH5C.js";import"./three.module-BynznMJN.js";import"./story-mount-turn-2IYGgHob.js";import"./events-156d8d12.esm-Dy_KXdhT.js";class Q extends _.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,o){console.error(`[stories] ${this.props.modulePath} — story "${this.props.storyName}" crashed while rendering:`,t,o.componentStack)}render(){return this.state.error?b.jsxs("div",{style:{padding:12,fontSize:12,color:$.semantic.danger,maxWidth:640},children:[b.jsxs("div",{style:{fontWeight:600,marginBottom:4},children:["Story crashed: ",b.jsx("code",{children:this.props.modulePath})," — export"," ",b.jsx("code",{children:this.props.storyName})]}),b.jsx("div",{style:{whiteSpace:"pre-wrap"},children:String(this.state.error)})]}):this.props.children}}const x=new WeakMap;async function X(e,t,o,l,i){const n=x.get(e),a=(n?.generation??0)+1;x.set(e,{root:n?.root,generation:a}),I(e);const m=T();m&&await R(m.rootPath),await l.load();const{createRoot:p,flushSync:h}=await M(),f=x.get(e);if(!f||f.generation!==a)return null;const c=n?.root??p(e);return x.set(e,{root:c,generation:a}),h(()=>{c.render(b.jsx(Q,{modulePath:t,storyName:o,children:b.jsx(l,{})}))}),{root:c,unmount:()=>{queueMicrotask(()=>{const s=x.get(e);!s||s.generation!==a||!s.root||(x.delete(e),s.root.unmount())})}}}var Z={mobile1:{name:"Small mobile",styles:{height:"568px",width:"320px"},type:"mobile"},mobile2:{name:"Large mobile",styles:{height:"896px",width:"414px"},type:"mobile"},tablet:{name:"Tablet",styles:{height:"1112px",width:"834px"},type:"tablet"},desktop:{name:"Desktop",styles:{height:"1024px",width:"1280px"},type:"desktop"}};const J=640,tt=400;function et(e,t){return`portable-${e}:${t.map(o=>encodeURIComponent(o)).join("/")}`}function ot(e){const t=new Map,o=[],l=new Map,i=new Map;for(const n of e){const a=D({modulePath:n.modulePath,...n.title?{title:n.title}:{}}),m=[...a.segments,a.leaf];let p=null;for(let c=0;c<m.length;c++){const s=m.slice(0,c+1),g=c===m.length-1,u=et(g?"component":"folder",s);t.has(u)||(t.set(u,{id:u,label:s.at(-1),role:g?"component":"folder",kind:g?"component":"group",typeLabel:g?"Component":c===0?"Category":"Folder",parentId:p,childIds:[],...g?{secondaryLabel:n.modulePath}:{}}),p?t.get(p)?.childIds.push(u):o.push(u)),p=u}const h=p;t.get(h)?.childIds.push(n.id),l.set(n.id,h);const f=i.get(h);f?f.storyIds.push(n.id):i.set(h,{id:h,label:k(a),storyIds:[n.id]})}return{sections:[...i.values()],nodes:[...t.values()],rootIds:o,storyParentIds:l}}function S(e){return e&&typeof e=="object"?e:null}function P(e){if(typeof e!="string")return null;const t=Number.parseFloat(e);return Number.isFinite(t)&&t>0?t:null}function rt(e){const t=S(S(e.viewport)?.options),o={...Z};if(!t)return o;for(const[l,i]of Object.entries(t)){const n=S(i),a=S(n?.styles);!n||!a||typeof n.name!="string"||typeof a.width!="string"||typeof a.height!="string"||(o[l]={name:n.name,styles:{width:a.width,height:a.height},...typeof n.type=="string"?{type:n.type}:{}})}return o}function nt(e){const t=e.viewport;if(typeof t=="string")return{value:t||null,isRotated:!1};const o=S(t);return{value:typeof o?.value=="string"&&o.value?o.value:null,isRotated:o?.isRotated===!0}}function at(e,t,o,l){const i=e.parameters??{},n=e.globals??{},a=i.layout,m=a==="centered"||a==="fullscreen"||a==="padded"?a:"padded",p=rt(i),h=Object.entries(p).flatMap(([d,y])=>{const w=P(y.styles.width),v=P(y.styles.height);return w&&v?[{id:d,label:y.name,width:w,height:v}]:[]}),f=nt(n),c=o===void 0?f.value:o,s=h.find(d=>d.id===c),g=s?.width??t?.width??J,u=s?.height??t?.height??tt,r=l??f.isRotated;return{layout:m,choices:h,selectedViewportId:s?.id??null,locked:e.viewportLocked===!0,rotated:r,width:r?u:g,height:r?g:u}}function st(e,t=ot(e)){return{index:t,resolve:at}}async function Et(e,t){await L();const o=V(),l=O().filter(r=>N({modulePath:r.modulePath,regions:o}).medium==="dom"),i=document.createElement("canvas");i.width=e,i.height=t;const n=i.getContext("2d");if(!n)throw new Error("UI Canvas preview could not create a 2D output context.");if(l.length===0)return i.toDataURL("image/png");const a=st(l),m=T()?.config.resolution,p={width:m?.width??640,height:m?.height??400},h=new Map,f=new Map;for(const r of l){const d=a.resolve(r,p),[y]=await C(r.modulePath,[r],{width:d.width,height:d.height,capture:j,cropToContent:d.layout!=="fullscreen",layout:d.layout,transparent:!0});if(!y)throw new Error(`No preview rendered for ${r.id}.`);const w=new Image;w.src=`data:${y.mimeType};base64,${y.base64}`,await w.decode(),h.set(r.id,w),f.set(r.id,{width:w.naturalWidth,height:w.naturalHeight})}const c=E(l,a.index,r=>f.get(r.id)),s=Math.min(e/c.width,t/c.height),g=(e-c.width*s)/2,u=(t-c.height*s)/2;for(const[r,d]of c.layouts)n.drawImage(h.get(r),g+d.x*s,u+d.y*s,d.width*s,d.height*s);return i.toDataURL("image/png")}const it="#ffffff",ct="#14171c";async function It(e,t){const{modulePath:o,width:l,height:i}=t;if(!e)throw new Error(`No project is open, so '${o}' cannot be loaded. Open the project first.`);const n=await U(e),a=n.find(u=>u.modulePath===o);if(!a)throw new Error(`'${o}' is not a story file of this project. `+(n.length===0?"This project has no *.stories.tsx / *.stories.ts under src/.":`This project's story files are: ${n.map(u=>u.modulePath).join(", ")}.`));await W(await A(e));let m;try{m=await a.load()}catch(u){throw new Error(`'${o}' failed to import — ${u instanceof Error?u.message:String(u)}`)}const p=await B(o,m);if(!p.ok)throw new Error(p.error);const h=lt(o,p.stories,t.story),f=t.capture??j,c=t.captureThree??(q()?(u,r)=>K(u,{...r,...t.camera===void 0?{}:{camera:t.camera},...t.pose===void 0?{}:{pose:t.pose}}):void 0);if((t.camera||t.pose)&&!c)throw new Error(`'${o}': camera/clip parameters need the three capture leg, which this environment cannot provide (no WebGL).`);const s=await C(o,h,{width:l,height:i,capture:f,...c?{captureThree:c}:{},requireThree:!!(t.camera||t.pose)}),g=await ht(s,l,i);return{modulePath:o,width:l,height:i,variants:s,contactSheet:g}}function lt(e,t,o){if(o===void 0)return t;const l=t.find(i=>i.name===o);if(!l)throw new Error(`'${e}' exports no story named '${o}'. It exports: ${t.map(i=>i.name).join(", ")}.`);return[l]}async function C(e,t,o){const{width:l,height:i,capture:n,captureThree:a,requireThree:m,cropToContent:p=!0}=o,h=document.createElement("div");h.setAttribute("style",`position:fixed;left:-20000px;top:0;width:${l}px;height:${i}px;overflow:hidden;contain:strict;pointer-events:none;background:${o.transparent?"transparent":it};`),document.body.appendChild(h);const f=[];try{for(const c of t){if(a){const r=await a(c.Component,{width:l,height:i}).catch(d=>(Y(d)||console.warn(`[story-capture] three mount for '${c.name}' failed — falling back to the DOM leg:`,d instanceof Error?d.stack??d.message:String(d)),null));if(r===null&&m)throw new Error(`story '${c.name}' did not render on the three leg — --azimuth/--elevation/--distance/--clip/--time apply to three (R3F) stories only, and falling back to the DOM leg would silently ignore them. Narrow to a three story with --story <export>, or drop the camera/clip flags.`);if(r!==null){const d=r.indexOf(",");f.push({name:c.name,label:c.label,base64:d>=0?r.slice(d+1):r,mimeType:"image/png"});continue}}const s=document.createElement("div");s.setAttribute("style",`position:relative;width:${l}px;height:${i}px;overflow:hidden;`),o.layout==="padded"&&(s.style.padding="16px"),o.layout==="centered"&&(s.style.display="flex",s.style.alignItems="center",s.style.justifyContent="center"),s.style.boxSizing="border-box",h.replaceChildren(s);let g=[];const u=await H(async r=>{g=r;const d=await X(s,e,c.name,c.Component);return await dt(s),await z(r),d});try{const r=await n(h,{canvasFrame:G(g),cropToContent:p,...o.transparent?{allowTransparent:!0}:{}});f.push({name:c.name,label:c.label,base64:r.base64,mimeType:"image/png"})}finally{u?.unmount(),await new Promise(r=>setTimeout(r,0)),s.remove()}}}finally{h.remove()}return f}async function dt(e,t=10){for(let i=0;i<t&&!(e.childNodes.length>0);i++)await new Promise(n=>setTimeout(n,0));if(e.childNodes.length===0)return;const o=200,l=5e3;await new Promise(i=>{let n=null,a=!1;const m=new MutationObserver(()=>{n!==null&&clearTimeout(n),n=setTimeout(h,o)}),p=setTimeout(h,l);function h(){a||(a=!0,m.disconnect(),n!==null&&clearTimeout(n),clearTimeout(p),i())}m.observe(e,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),n=setTimeout(h,o)})}async function ht(e,t,o,l={}){const i=Math.min(Math.max(1,e.length),Math.max(1,Math.floor(l.columns??2))),n=Math.max(1,Math.ceil(e.length/i)),a=[];for(const r of e){const d=new Image;d.src=`data:${r.mimeType};base64,${r.base64}`,await d.decode(),a.push(d)}const m=Math.max(1,...a.map(r=>r.naturalWidth),a.length?0:t),p=Math.max(1,...a.map(r=>r.naturalHeight),a.length?0:o),h=m*i,f=p*n,c=document.createElement("canvas");c.width=h,c.height=f;const s=c.getContext("2d");if(!s)throw new Error("Unable to create the story variant sheet.");s.fillStyle=ct,s.fillRect(0,0,h,f);for(const[r,d]of e.entries()){const y=r%i*m,w=Math.floor(r/i)*p,v=a[r];s.drawImage(v,y+Math.floor((m-v.naturalWidth)/2),w+Math.floor((p-v.naturalHeight)/2)),l.labels!==!1&&F(s,d.name.toUpperCase(),y,w,m,p)}const g=c.toDataURL("image/png"),u=g.indexOf(",");return{width:h,height:f,base64:u>=0?g.slice(u+1):g,mimeType:"image/png"}}export{Et as captureDomStoryBoardPreview,It as captureProjectStoryVariants,ht as composeVariantSheet,C as renderStoryVariants};
|
|
1
|
+
import{r as E}from"./react-story-board-DBO76grK.js";import{aS as I,a9 as M,t as $,aT as R,az as T,aU as D,aV as k,aW as L,aX as O,aY as N,aZ as U,a_ as W,a$ as A,b0 as B,aO as j,b1 as F,aa as H,b2 as G,b3 as V}from"./index-CY4oDLhJ.js";import{a as b}from"./jsx-runtime-DPjLkJKQ.js";import{r as _}from"./index-DaQZGF7d.js";import"./index-CtzuWnCS.js";import"./index-D2LwEE0L.js";import{awaitPixiStoryFrame as z}from"./story-pixi-preview-B1LxWTHx.js";import{supportsThreeStoryCapture as q,captureStoryComponentThumbnail as K,isStoryThreeClassificationRefusal as Y}from"./story-three-preview-CsjJKTcf.js";import"./client-DNXj_opT.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./index-CinJrH5C.js";import"./three.module-BynznMJN.js";import"./story-mount-turn-2IYGgHob.js";import"./events-156d8d12.esm-Dy_KXdhT.js";class Q extends _.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,o){console.error(`[stories] ${this.props.modulePath} — story "${this.props.storyName}" crashed while rendering:`,t,o.componentStack)}render(){return this.state.error?b.jsxs("div",{style:{padding:12,fontSize:12,color:$.semantic.danger,maxWidth:640},children:[b.jsxs("div",{style:{fontWeight:600,marginBottom:4},children:["Story crashed: ",b.jsx("code",{children:this.props.modulePath})," — export"," ",b.jsx("code",{children:this.props.storyName})]}),b.jsx("div",{style:{whiteSpace:"pre-wrap"},children:String(this.state.error)})]}):this.props.children}}const x=new WeakMap;async function X(e,t,o,l,i){const n=x.get(e),a=(n?.generation??0)+1;x.set(e,{root:n?.root,generation:a}),I(e);const m=T();m&&await R(m.rootPath),await l.load();const{createRoot:p,flushSync:h}=await M(),f=x.get(e);if(!f||f.generation!==a)return null;const c=n?.root??p(e);return x.set(e,{root:c,generation:a}),h(()=>{c.render(b.jsx(Q,{modulePath:t,storyName:o,children:b.jsx(l,{})}))}),{root:c,unmount:()=>{queueMicrotask(()=>{const s=x.get(e);!s||s.generation!==a||!s.root||(x.delete(e),s.root.unmount())})}}}var Z={mobile1:{name:"Small mobile",styles:{height:"568px",width:"320px"},type:"mobile"},mobile2:{name:"Large mobile",styles:{height:"896px",width:"414px"},type:"mobile"},tablet:{name:"Tablet",styles:{height:"1112px",width:"834px"},type:"tablet"},desktop:{name:"Desktop",styles:{height:"1024px",width:"1280px"},type:"desktop"}};const J=640,tt=400;function et(e,t){return`portable-${e}:${t.map(o=>encodeURIComponent(o)).join("/")}`}function ot(e){const t=new Map,o=[],l=new Map,i=new Map;for(const n of e){const a=D({modulePath:n.modulePath,...n.title?{title:n.title}:{}}),m=[...a.segments,a.leaf];let p=null;for(let c=0;c<m.length;c++){const s=m.slice(0,c+1),g=c===m.length-1,u=et(g?"component":"folder",s);t.has(u)||(t.set(u,{id:u,label:s.at(-1),role:g?"component":"folder",kind:g?"component":"group",typeLabel:g?"Component":c===0?"Category":"Folder",parentId:p,childIds:[],...g?{secondaryLabel:n.modulePath}:{}}),p?t.get(p)?.childIds.push(u):o.push(u)),p=u}const h=p;t.get(h)?.childIds.push(n.id),l.set(n.id,h);const f=i.get(h);f?f.storyIds.push(n.id):i.set(h,{id:h,label:k(a),storyIds:[n.id]})}return{sections:[...i.values()],nodes:[...t.values()],rootIds:o,storyParentIds:l}}function S(e){return e&&typeof e=="object"?e:null}function P(e){if(typeof e!="string")return null;const t=Number.parseFloat(e);return Number.isFinite(t)&&t>0?t:null}function rt(e){const t=S(S(e.viewport)?.options),o={...Z};if(!t)return o;for(const[l,i]of Object.entries(t)){const n=S(i),a=S(n?.styles);!n||!a||typeof n.name!="string"||typeof a.width!="string"||typeof a.height!="string"||(o[l]={name:n.name,styles:{width:a.width,height:a.height},...typeof n.type=="string"?{type:n.type}:{}})}return o}function nt(e){const t=e.viewport;if(typeof t=="string")return{value:t||null,isRotated:!1};const o=S(t);return{value:typeof o?.value=="string"&&o.value?o.value:null,isRotated:o?.isRotated===!0}}function at(e,t,o,l){const i=e.parameters??{},n=e.globals??{},a=i.layout,m=a==="centered"||a==="fullscreen"||a==="padded"?a:"padded",p=rt(i),h=Object.entries(p).flatMap(([d,y])=>{const w=P(y.styles.width),v=P(y.styles.height);return w&&v?[{id:d,label:y.name,width:w,height:v}]:[]}),f=nt(n),c=o===void 0?f.value:o,s=h.find(d=>d.id===c),g=s?.width??t?.width??J,u=s?.height??t?.height??tt,r=l??f.isRotated;return{layout:m,choices:h,selectedViewportId:s?.id??null,locked:e.viewportLocked===!0,rotated:r,width:r?u:g,height:r?g:u}}function st(e,t=ot(e)){return{index:t,resolve:at}}async function Et(e,t){await L();const o=V(),l=O().filter(r=>N({modulePath:r.modulePath,regions:o}).medium==="dom"),i=document.createElement("canvas");i.width=e,i.height=t;const n=i.getContext("2d");if(!n)throw new Error("UI Canvas preview could not create a 2D output context.");if(l.length===0)return i.toDataURL("image/png");const a=st(l),m=T()?.config.resolution,p={width:m?.width??640,height:m?.height??400},h=new Map,f=new Map;for(const r of l){const d=a.resolve(r,p),[y]=await C(r.modulePath,[r],{width:d.width,height:d.height,capture:j,cropToContent:d.layout!=="fullscreen",layout:d.layout,transparent:!0});if(!y)throw new Error(`No preview rendered for ${r.id}.`);const w=new Image;w.src=`data:${y.mimeType};base64,${y.base64}`,await w.decode(),h.set(r.id,w),f.set(r.id,{width:w.naturalWidth,height:w.naturalHeight})}const c=E(l,a.index,r=>f.get(r.id)),s=Math.min(e/c.width,t/c.height),g=(e-c.width*s)/2,u=(t-c.height*s)/2;for(const[r,d]of c.layouts)n.drawImage(h.get(r),g+d.x*s,u+d.y*s,d.width*s,d.height*s);return i.toDataURL("image/png")}const it="#ffffff",ct="#14171c";async function It(e,t){const{modulePath:o,width:l,height:i}=t;if(!e)throw new Error(`No project is open, so '${o}' cannot be loaded. Open the project first.`);const n=await U(e),a=n.find(u=>u.modulePath===o);if(!a)throw new Error(`'${o}' is not a story file of this project. `+(n.length===0?"This project has no *.stories.tsx / *.stories.ts under src/.":`This project's story files are: ${n.map(u=>u.modulePath).join(", ")}.`));await W(await A(e));let m;try{m=await a.load()}catch(u){throw new Error(`'${o}' failed to import — ${u instanceof Error?u.message:String(u)}`)}const p=await B(o,m);if(!p.ok)throw new Error(p.error);const h=lt(o,p.stories,t.story),f=t.capture??j,c=t.captureThree??(q()?(u,r)=>K(u,{...r,...t.camera===void 0?{}:{camera:t.camera},...t.pose===void 0?{}:{pose:t.pose}}):void 0);if((t.camera||t.pose)&&!c)throw new Error(`'${o}': camera/clip parameters need the three capture leg, which this environment cannot provide (no WebGL).`);const s=await C(o,h,{width:l,height:i,capture:f,...c?{captureThree:c}:{},requireThree:!!(t.camera||t.pose)}),g=await ht(s,l,i);return{modulePath:o,width:l,height:i,variants:s,contactSheet:g}}function lt(e,t,o){if(o===void 0)return t;const l=t.find(i=>i.name===o);if(!l)throw new Error(`'${e}' exports no story named '${o}'. It exports: ${t.map(i=>i.name).join(", ")}.`);return[l]}async function C(e,t,o){const{width:l,height:i,capture:n,captureThree:a,requireThree:m,cropToContent:p=!0}=o,h=document.createElement("div");h.setAttribute("style",`position:fixed;left:-20000px;top:0;width:${l}px;height:${i}px;overflow:hidden;contain:strict;pointer-events:none;background:${o.transparent?"transparent":it};`),document.body.appendChild(h);const f=[];try{for(const c of t){if(a){const r=await a(c.Component,{width:l,height:i}).catch(d=>(Y(d)||console.warn(`[story-capture] three mount for '${c.name}' failed — falling back to the DOM leg:`,d instanceof Error?d.stack??d.message:String(d)),null));if(r===null&&m)throw new Error(`story '${c.name}' did not render on the three leg — --azimuth/--elevation/--distance/--clip/--time apply to three (R3F) stories only, and falling back to the DOM leg would silently ignore them. Narrow to a three story with --story <export>, or drop the camera/clip flags.`);if(r!==null){const d=r.indexOf(",");f.push({name:c.name,label:c.label,base64:d>=0?r.slice(d+1):r,mimeType:"image/png"});continue}}const s=document.createElement("div");s.setAttribute("style",`position:relative;width:${l}px;height:${i}px;overflow:hidden;`),o.layout==="padded"&&(s.style.padding="16px"),o.layout==="centered"&&(s.style.display="flex",s.style.alignItems="center",s.style.justifyContent="center"),s.style.boxSizing="border-box",h.replaceChildren(s);let g=[];const u=await H(async r=>{g=r;const d=await X(s,e,c.name,c.Component);return await dt(s),await z(r),d});try{const r=await n(h,{canvasFrame:G(g),cropToContent:p,...o.transparent?{allowTransparent:!0}:{}});f.push({name:c.name,label:c.label,base64:r.base64,mimeType:"image/png"})}finally{u?.unmount(),await new Promise(r=>setTimeout(r,0)),s.remove()}}}finally{h.remove()}return f}async function dt(e,t=10){for(let i=0;i<t&&!(e.childNodes.length>0);i++)await new Promise(n=>setTimeout(n,0));if(e.childNodes.length===0)return;const o=200,l=5e3;await new Promise(i=>{let n=null,a=!1;const m=new MutationObserver(()=>{n!==null&&clearTimeout(n),n=setTimeout(h,o)}),p=setTimeout(h,l);function h(){a||(a=!0,m.disconnect(),n!==null&&clearTimeout(n),clearTimeout(p),i())}m.observe(e,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),n=setTimeout(h,o)})}async function ht(e,t,o,l={}){const i=Math.min(Math.max(1,e.length),Math.max(1,Math.floor(l.columns??2))),n=Math.max(1,Math.ceil(e.length/i)),a=[];for(const r of e){const d=new Image;d.src=`data:${r.mimeType};base64,${r.base64}`,await d.decode(),a.push(d)}const m=Math.max(1,...a.map(r=>r.naturalWidth),a.length?0:t),p=Math.max(1,...a.map(r=>r.naturalHeight),a.length?0:o),h=m*i,f=p*n,c=document.createElement("canvas");c.width=h,c.height=f;const s=c.getContext("2d");if(!s)throw new Error("Unable to create the story variant sheet.");s.fillStyle=ct,s.fillRect(0,0,h,f);for(const[r,d]of e.entries()){const y=r%i*m,w=Math.floor(r/i)*p,v=a[r];s.drawImage(v,y+Math.floor((m-v.naturalWidth)/2),w+Math.floor((p-v.naturalHeight)/2)),l.labels!==!1&&F(s,d.name.toUpperCase(),y,w,m,p)}const g=c.toDataURL("image/png"),u=g.indexOf(",");return{width:h,height:f,base64:u>=0?g.slice(u+1):g,mimeType:"image/png"}}export{Et as captureDomStoryBoardPreview,It as captureProjectStoryVariants,ht as composeVariantSheet,C as renderStoryVariants};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as v}from"./index-DaQZGF7d.js";import{a9 as E,aa as M}from"./index-
|
|
1
|
+
import{r as v}from"./index-DaQZGF7d.js";import{a9 as E,aa as M}from"./index-CY4oDLhJ.js";import{r as T,C as P}from"./story-mount-turn-2IYGgHob.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./jsx-runtime-DPjLkJKQ.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-D2LwEE0L.js";import"./client-DNXj_opT.js";import"./three.module-BynznMJN.js";function S(t){if(t.children.length===0)return!1;const o=t.getBounds();return o.width>1&&o.height>1}const m=1e4,k=12,I="position:fixed;left:-20000px;top:0;width:512px;height:512px;overflow:hidden;contain:strict;pointer-events:none;visibility:hidden;";function C(t){return T(()=>t(D))}function R(t,o={}){return C(n=>n(t,o))}function _(t){return T(async()=>t.dispose())}async function X(t,o={}){const n=await R(t,o.props??{});try{const i=o.width??128,r=o.height??96;n.app.renderer.render({container:n.stage});const s=n.stage.getBounds(),c=o.layout==="fullscreen",d=8,e=n.app.screen.clone();c||(e.x=s.x-d,e.y=s.y-d,e.width=Math.max(1,s.width+d*2),e.height=Math.max(1,s.height+d*2));const a=i/r;if(!c&&e.width/e.height<a){const l=e.height*a;e.x-=(l-e.width)/2,e.width=l}else if(!c&&e.width/e.height>a){const l=e.width/a;e.y-=(l-e.height)/2,e.height=l}const u=n.app.renderer.background,h=await n.app.renderer.extract.canvas({target:n.stage,frame:e,...c&&u.alpha>0?{clearColor:u.colorRgba}:{}}),w=document.createElement("canvas");w.width=i,w.height=r;const g=w.getContext("2d");if(!g)throw new Error("Canvas story preview could not create a 2D readback context.");const p=Math.min(i/h.width,r/h.height),y=h.width*p,x=h.height*p;return g.drawImage(h,(i-y)/2,(r-x)/2,y,x),w.toDataURL("image/png")}finally{await _(n)}}const f=()=>new Promise(t=>setTimeout(t,0));async function D(t,o={}){typeof t.load=="function"&&await t.load();const n=await E(),i=document.createElement("div");i.setAttribute("style",I),document.body.appendChild(i);let r=null;const s=()=>{r?.unmount(),r=null,i.remove()};try{return await M(async c=>{let d=null;r=n.createRoot(i),r.render(v.createElement(P,{onCaught:h=>{d??=h}},v.createElement(t,o)));for(let h=0;h<k&&!(d||i.querySelector("canvas"));h++)await f();if(d)throw b(d);if(!i.querySelector("canvas"))throw new Error("The story rendered no canvas — it does not mount Pixi content.");const e=Date.now()+m;let a;for(;Date.now()<e;){if(d)throw b(d);if(a??=c[0],a&&S(a.stage))break;await f()}if(!a)throw new Error(`The story rendered a canvas but never initialized a Pixi Application within ${m/1e3}s — it is not a canvas story, or its renderer could not be created here.`);a.stop(),a.ticker.lastTime=0;let u=!1;return{host:i,stage:a.stage,ticker:a.ticker,app:a,dispose(){u||(u=!0,s())}}})}catch(c){throw s(),c}}const O=m;async function Y(t,o=Date.now){if(t.length===0)return;const n=new Set,i=t.map(r=>{const s={postrender:()=>{n.add(r)}};return r.renderer?.runners.postrender.add(s),{app:r,observer:s}});try{const r=o()+O;for(;o()<r;){if(t.every(c=>c.stage!==void 0&&S(c.stage)&&n.has(c)))return;await f()}}finally{for(const{app:r,observer:s}of i)r.renderer?.runners.postrender.remove(s)}}function b(t){return new Error(`mountStoryPixi: the story threw while rendering — it does not mount Pixi content, or its component crashed. Original error: ${t instanceof Error?t.message:String(t)}`,{cause:t})}export{Y as awaitPixiStoryFrame,X as capturePixiStoryThumbnail,_ as disposeStoryPixi,R as mountStoryPixi,C as withPixiStoryMountTurn};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-three-rapier.esm-
|
|
2
|
-
import{aJ as B,aK as U,aL as W,aM as z,_ as G}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-three-rapier.esm-Cj4NtDam.js","assets/index-CY4oDLhJ.js","assets/index-DaQZGF7d.js","assets/_commonjsHelpers-D6-XlEtG.js","assets/index-D_NuPfjr.js","assets/jsx-runtime-DPjLkJKQ.js","assets/index-CtzuWnCS.js","assets/index-CinJrH5C.js","assets/index-D2LwEE0L.js","assets/client-DNXj_opT.js","assets/three.module-BynznMJN.js","assets/index-D2fNXpHa.css","assets/events-156d8d12.esm-Dy_KXdhT.js","assets/BufferGeometryUtils-oP8-Ve4I.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{aJ as B,aK as U,aL as W,aM as z,_ as G}from"./index-CY4oDLhJ.js";import{r as j}from"./index-DaQZGF7d.js";import{r as H,C as $}from"./story-mount-turn-2IYGgHob.js";import{s as q,aW as Q,i as V,br as J}from"./three.module-BynznMJN.js";import{e as K,c as X}from"./events-156d8d12.esm-Dy_KXdhT.js";import"./jsx-runtime-DPjLkJKQ.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-D_NuPfjr.js";import"./index-D2LwEE0L.js";import"./client-DNXj_opT.js";const Y=1/60,Z=6,ee=15,_=1e-4,te=2,ne=10,re=250,oe=4e3;function S(e){e.updateMatrixWorld(!0);const t=[];return e.traverse(n=>{const r=n.matrixWorld.elements;t.push(r[12],r[13],r[14])}),t}function N(e){let t=0;return e.traverse(()=>{t++}),t}function D(e,t){if(e.length!==t.length)return Number.NaN;let n=0;for(let r=0;r<t.length;r+=3){const o=t[r]-e[r],a=t[r+1]-e[r+1],i=t[r+2]-e[r+2],s=Math.sqrt(o*o+a*a+i*i);if(!Number.isFinite(s))return Number.NaN;s>n&&(n=s)}return n}const ie=()=>new Promise(e=>setTimeout(e,0));async function se(e,t,n){const r=n();let o=N(e),a=r,i=!1;for(;n()-r<oe;){if(n()-a>=re){i=!0;break}await t();const s=N(e);s!==o&&(o=s,a=n())}return{buildWaitMs:n()-r,buildSettled:i}}function x(e){return{outcome:e,steps:0,lastMotion:0,buildWaitMs:0,buildSettled:!0}}function ae(e){return e.hasPhysicsSubscriber!==!1}async function ce(e,t={}){const n=t.yieldTurn??ie,r=t.now??(()=>Date.now()),o=e.update?.bind(e);if(!o)return x("unsupported");if(!ae(e))return x("still");const{buildWaitMs:a,buildSettled:i}=await se(e.scene,n,r);let s=S(e.scene),l=0,u=0,h=!1,E=0,y="still";for(let d=0;d<ee;d++){for(let w=0;w<Z;w++)o(Y),l++;await n();const m=S(e.scene),f=D(s,m);if(s=m,!Number.isFinite(f)){u=0;continue}if(E=f,f>_){h=!0,u=0,y="budget";continue}if(u++,h&&u>=te){y="rest";break}}for(let d=0;d<ne;d++){await n();const m=S(e.scene),f=D(s,m);if(s=m,Number.isFinite(f)&&f<=_)break}return{outcome:y,steps:l,lastMotion:E,buildWaitMs:a,buildSettled:i}}const ue={packaged:!1,createElement:j.createElement,createR3FRoot:X,extendThree:K,three:q};let g=null;async function le(){const e=await import(U);for(const t of["createElement","createR3FRoot","extendThree"])if(typeof e[t]!="function")throw new Error(`The packaged R3F preview runtime did not export ${t} as a function — see vite-plugin-module-doorways.ts.`);if(typeof e.projectThree!="object"||e.projectThree===null)throw new Error("The packaged R3F preview runtime did not export projectThree — see vite-plugin-module-doorways.ts.");return{packaged:!0,createElement:e.createElement,createR3FRoot:e.createR3FRoot,extendThree:e.extendThree,three:e.projectThree}}async function de(){return await B()?(g||(g=le()),g):ue}const R="vgai:story-preview-root",me=1e4;function v(e){if(typeof e=="function"){const t=e;return t.displayName||t.name||""}if(e&&typeof e=="object"){const t=e;return typeof t.displayName=="string"&&t.displayName.length>0?t.displayName:typeof t.name=="string"&&t.name.length>0?t.name:v(t.type??t.render)}return""}function fe(e){const t=e,n=t._reactInternals??t._reactInternalFiber;return n&&typeof n=="object"?n:void 0}function pe(e){const t=[v(e.type),v(e.elementType)];if(!(t.includes("RigidBody")||t.includes("InstancedRigidBodies")))return{provider:t.includes("Physics"),body:!1,movingBody:!1};const r=e.memoizedProps&&typeof e.memoizedProps=="object"?e.memoizedProps:{};return{provider:t.includes("Physics"),body:!0,movingBody:r.type!=="fixed"}}function he(e){const t=e?[e]:[],n=new Set;let r=!1,o=!1,a=!1;for(;t.length>0;){const i=t.pop();if(n.has(i))continue;n.add(i);const s=pe(i);r||=s.provider,o||=s.body,a||=s.movingBody,i.child&&t.push(i.child),i.sibling&&t.push(i.sibling)}return r?!o||a:!1}class ye extends j.Component{componentDidMount(){this.props.onReport(he(fe(this)))}render(){return this.props.children??null}}function we(e){return e instanceof Error&&e.message.includes("is not part of the THREE namespace")}function F(e){return we(e)?!0:e instanceof Error?e.message.includes("Hooks can only be used within the Canvas component")||e.message.includes("useGame: no Game in context"):!1}function ke(e){return F(e)}function L(e){return e instanceof Error&&e.message.includes("useRapier must be used within <Physics")}async function Ee(e){try{return(e.packaged?await import("/@id/@react-three/rapier"):await G(()=>import("./react-three-rapier.esm-Cj4NtDam.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))).Physics}catch{return null}}function Te(e,t,n){const r=globalThis,o=r.reportError,a=typeof o=="function"?o.bind(globalThis):i=>{console.error(i)};r.reportError=i=>{F(i)||t&&L(i)||a(i)};try{return n(e)}finally{r.reportError=o}}function be(e){return{domElement:e,xr:{enabled:!1,addEventListener(){},removeEventListener(){},setAnimationLoop(){},getSession(){return null}},shadowMap:{enabled:!1,type:J},outputColorSpace:V,toneMapping:Q,setPixelRatio(){},setSize(){},setClearColor(){},setClearAlpha(){},setViewport(){},setScissor(){},setScissorTest(){},setAnimationLoop(){},clear(){},render(){},compile(){},dispose(){},getPixelRatio(){return 1},getContext(){return null}}}let C=null;function I(e){return H(()=>e(ve))}function Se(e){C!==e.extendThree&&(C=e.extendThree,e.extendThree(e.three))}async function ge(e,t={}){return I(n=>n(e,t))}function Re(e){return I(async()=>e.dispose())}async function ve(e,t={}){const n=z(),r=n?Date.now():0,o=await de(),a=n?Date.now()-r:0,i=n?Date.now():0;typeof e.load=="function"&&await e.load();const s=n?Date.now()-i:0;try{return await O(o,e,t,void 0,{timed:n,runtimeMs:a,loadMs:s})}catch(l){if(!L(l))throw l;const u=await Ee(o);if(!u)throw l;return await O(o,e,t,h=>o.createElement(u,{paused:!1},h),{timed:n,runtimeMs:a,loadMs:s})}}async function O(e,t,n,r,o){Se(e);const a=document.createElement("canvas"),i=Te(a,r===void 0,e.createR3FRoot);let s;const l=new Promise(c=>{s=c});await i.configure({gl:(()=>be(a)),frameloop:"never",size:{width:128,height:96,top:0,left:0},onCreated:c=>s(c)});let u=null,h;const E=new Promise((c,b)=>{h=b}),y=c=>{u??=new Error("mountStoryObject3D: the story threw while reconciling into an R3F root — it does not render `three` content (a DOM/React story), or its component crashed. Original error: "+String(c instanceof Error?c.message:c),{cause:c}),h(u)},d=e.createElement(t,n);let m=!1;const f=c=>{m=c};i.render(e.createElement("group",{name:R},e.createElement($,{onCaught:y},e.createElement(ye,{onReport:f},r?r(d):d))));const w=o?.timed?Date.now():0;let P;const p=await Promise.race([l,E,new Promise((c,b)=>{P=setTimeout(()=>b(new Error("mountStoryObject3D: onCreated did not fire within 10s — the story never reached its first R3F commit and never threw. Either it is still SUSPENDED on a slow load (a suspending loader with no <Suspense> boundary holds the first commit until its content is ready), or its render is hung.")),me)})]).catch(c=>{throw o?.timed&&(o.runtimeMs,o.loadMs,Date.now()-w),i.unmount(),c}).finally(()=>clearTimeout(P));if(u)throw i.unmount(),u;p.clock.autoStart=!1,p.clock.stop();const T=p.scene.getObjectByName(R);if(!T)throw i.unmount(),new Error(`mountStoryObject3D: the story's wrapper group ("${R}") is not in the scene after its first commit — the story rendered nothing mountable.`);const k=o?.timed?Date.now()-w:0,A=o?.timed?Date.now():0;await ce({scene:T,update:c=>{p.advance(p.clock.elapsedTime+Math.min(c,.1),!1)},hasPhysicsSubscriber:m}),o?.timed&&(o.runtimeMs,o.loadMs,Date.now()-A);let M=p.clock.elapsedTime;return{root:T,scene:p.scene,advance(c){!(c>0)||!Number.isFinite(c)||(M+=Math.min(c,.1),p.advance(M,!1))},dispose(){i.unmount()}}}async function Ae(e,t={}){const n=await ge(e,t.props??{});try{const r=W(n.root,{width:t.width??128,height:t.height??96,...t.camera===void 0?{}:{camera:t.camera},...t.pose===void 0?{}:{pose:t.pose}}),o=r.views.find(a=>a.view==="perspective")??r.views[0];if(!o)throw new Error("Story preview capture returned no views.");return`data:${o.mimeType};base64,${o.base64}`}finally{await Re(n)}}function Be(){return typeof WebGLRenderingContext<"u"&&typeof navigator<"u"&&!navigator.userAgent.toLowerCase().includes("jsdom")}export{R as PREVIEW_ROOT_NAME,Ae as captureStoryComponentThumbnail,Re as disposeStoryObject3D,ke as isStoryThreeClassificationRefusal,ge as mountStoryObject3D,Be as supportsThreeStoryCapture,I as withStoryMountTurn};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{eD as v,eE as C,b_ as Z,eF as z,eG as R,eH as T,eI as te,eJ as Ce,eK as ce,eL as F,bZ as P,eM as E,b$ as Se,c0 as he}from"./index-
|
|
1
|
+
import{eD as v,eE as C,b_ as Z,eF as z,eG as R,eH as T,eI as te,eJ as Ce,eK as ce,eL as F,bZ as P,eM as E,b$ as Se,c0 as he}from"./index-CY4oDLhJ.js";import"./index-DaQZGF7d.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./jsx-runtime-DPjLkJKQ.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-D2LwEE0L.js";import"./client-DNXj_opT.js";import"./three.module-BynznMJN.js";const B=Object.create(null),re=Object.create(null);function Q(s,e){let t=re[s];return t===void 0&&(B[e]===void 0&&(B[e]=1),re[s]=t=B[e]++),t}let k;function Pe(){return(!k||k?.isContextLost())&&(k=v.get().createCanvas().getContext("webgl",{})),k}let G;function Ie(){if(!G){G="mediump";const s=Pe();s&&s.getShaderPrecisionFormat&&(G=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision?"highp":"mediump")}return G}function Ae(s,e,t){return e?s:t?(s=s.replace("out vec4 finalColor;",""),`
|
|
2
2
|
|
|
3
3
|
#ifdef GL_ES // This checks if it is WebGL1
|
|
4
4
|
#define in varying
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const d="/work/.vgai-session",oe=`${d}/session.py`,ae=[`${d}/in`,`${d}/reply`],_="/__editor/blender-wasm";function L(e){return new URL(`${_}/${e}`,import.meta.url).href}async function M(){const e=await fetch(L("status"));return e.ok?await e.json():{available:!1,skew:null,dir:null,sizes:{},encoded:{},missing:[`${_}/status answered ${e.status}`]}}async function D(e){const r=await M();if(!r.available)throw new Error(`The headless Blender WebAssembly build is not served by this editor: ${r.missing.join("; ")}`);if(r.skew==="wali"){const{startWaliBlenderEngine:t}=await import("./blender-wali-engine-Dtwixi7B.js");return t(e,r)}const{startEmscriptenBlenderEngine:n}=await import("./blender-emscripten-engine-BkrPLmPf.js");return n(e,r)}function U(e){return e<200?1:e<5e3?5:25}const C=e=>new Promise(r=>setTimeout(r,e)),T=new TextDecoder;function se(e,r,n){let t=0,a=0;const o=new Set;async function s(u){for(const l of o)u.has(`${l}.done`)||(await e.unlink(`${d}/reply/${l}.json`),await e.unlink(`${d}/reply/${l}.done`),o.delete(l))}async function i(){let u;try{u=await e.readdir(`${d}/ask`)}catch{return}const l=new Set(u.filter(h=>h.endsWith(".done")));await s(l);for(const h of l){const y=h.slice(0,-5);if(Number(y)<=a)continue;a=Number(y);const m=JSON.parse(T.decode(await e.readFile(`${d}/ask/${y}.json`)));let j;try{j=await r.ask(m)}catch(v){j={error:v instanceof Error?v.message:String(v)}}await e.writeFile(`${d}/reply/${y}.json`,JSON.stringify(j??null)),await e.writeFile(`${d}/reply/${y}.done`,"1"),o.add(y)}}async function c(u){const l=String(++t);await e.writeFile(`${d}/in/${l}.json`,JSON.stringify(u)),await e.writeFile(`${d}/in/${l}.done`,"1");const h=performance.now();for(;;){if(await i(),await e.stat(`${d}/out/${l}.done`)){const m=JSON.parse(T.decode(await e.readFile(`${d}/out/${l}.json`)));if(await e.unlink(`${d}/in/${l}.json`),await e.unlink(`${d}/in/${l}.done`),m.error)throw new Error(m.error);return m.result}const y=n?.();if(y)throw new Error(`Blender is gone, so this call will never be answered: ${y}. The session keeps its directory and its cached banner, so every later call would wait on the same missing answer; start a new program with \`blender-start {fresh: true}\` (\`VGAI_BLENDER_FRESH_SESSION=1\` for the battery harness).`);await C(U(performance.now()-h))}}return{request:c}}const N=e=>typeof e=="object"&&e!==null&&typeof e.offset=="number"&&typeof e.length=="number"&&typeof e.dtype=="string"&&typeof e.count=="number"&&typeof e.stride=="number",J={f32:e=>new Float32Array(e.buffer,e.byteOffset,e.byteLength>>2),f64:e=>new Float64Array(e.buffer,e.byteOffset,e.byteLength>>3),u32:e=>new Uint32Array(e.buffer,e.byteOffset,e.byteLength>>2),i32:e=>new Int32Array(e.buffer,e.byteOffset,e.byteLength>>2),u16:e=>new Uint16Array(e.buffer,e.byteOffset,e.byteLength>>1),i16:e=>new Int16Array(e.buffer,e.byteOffset,e.byteLength>>1),u8:e=>e,i8:e=>new Int8Array(e.buffer,e.byteOffset,e.byteLength)};function V(e,r,n){const t=J[n.dtype];if(!t)throw new Error(`Blender frame column ${r}: unknown dtype ${n.dtype}`);const{offset:a,length:o}=n;if(a<0||o<0||a+o>e.byteLength)throw new Error(`Blender frame column ${r}: bytes ${a}..${a+o} lie outside the ${e.byteLength}-byte export arena`);const s=e.subarray(a,a+o).slice(),i=t(s),c=n.count*n.stride;if(i.length!==c)throw new Error(`Blender frame column ${r}: ${i.length} values, ${c} declared (${n.count} x ${n.stride})`);return i}function W(e,r){const n=(t,a)=>{if(N(t)){const o=V(e,a,t);return a==="co"?Float64Array.from(o):o}if(Array.isArray(t))return t.map(o=>n(o,a));if(typeof t=="object"&&t!==null){const o={};for(const[s,i]of Object.entries(t))o[s]=n(i,s);return o}return t};return n(r,"")}async function z(e,r){const n=async(t,a)=>{if(N(t)){const{offset:o,length:s,dtype:i}=t;if(o<0||s<0||o+s>e.byteLength)throw new Error(`Blender frame column ${a}: bytes ${o}..${o+s} lie outside the ${e.byteLength}-byte export arena`);const c=e.subarray(o,o+s).slice(),u=await crypto.subtle.digest("SHA-256",c),l=[...new Uint8Array(u)].map(h=>h.toString(16).padStart(2,"0")).join("");return{dtype:i,length:s,sha256:l}}if(Array.isArray(t))return Promise.all(t.map(o=>n(o,a)));if(typeof t=="object"&&t!==null){const o={};for(const[s,i]of Object.entries(t))o[s]=await n(i,s);return o}return t};return n(r,"")}const $=e=>self.postMessage(e),p=(e,r)=>$({op:"log",level:e,text:r});let b=null,O=null,G=0;const A=new Map;function H(e,r,n){const t=++G,a=[],o=e;for(const s of[o?.meshes??{},o?.images??{}])for(const i of Object.values(s))for(const c of Object.values(i))ArrayBuffer.isView(c)&&c.buffer instanceof ArrayBuffer&&!a.includes(c.buffer)&&a.push(c.buffer);return new Promise((s,i)=>{A.set(t,{resolve:s,reject:i}),self.postMessage({op:"present",id:t,frame:e,description:r,...n?{capture:n}:{}},a)})}let f=null,E=null,S=null,k=0;const K=1e3;function F(){E!==null&&(S!==null&&clearTimeout(S),S=setTimeout(()=>{S=null,Q()},K))}async function Q(){if(!f||E===null)return;if(k>0){F();return}const e=E;let r;try{r=await f.request({op:"save-document"})}catch(t){p("error",`@@VGAI-ERROR the Blender document ${e} could not be saved: ${g(t)}`);return}if(!r?.saved||typeof r.path!="string")return;let n;try{n=await f.files.readFile(r.path)}catch(t){p("error",`@@VGAI-ERROR the Blender document ${e} was saved but could not be read back out of the engine: ${g(t)}`);return}w.delete(r.path);try{const t=await fetch(`/__editor/blender-document?path=${encodeURIComponent(e)}`,{method:"POST",headers:{"content-type":"application/octet-stream"},body:new Blob([n])});if(!t.ok){const a=await t.text().catch(()=>"");p("error",`@@VGAI-ERROR the Blender document ${e} was not written to the project: HTTP ${t.status} ${a}`);return}}catch(t){p("error",`@@VGAI-ERROR the Blender document ${e} was not written to the project: ${g(t)}`);return}p("log",`@@VGAI-DOCUMENT ${JSON.stringify({path:e,bytes:n.length})}`)}async function X(e,r){const n={engine:null},t=await D({project:e,log:p,ask:async({frame:o,capture:s,saveDue:i})=>{if(!n.engine)throw new Error("The Blender session presented before it started");i&&F();const c=await n.engine.readArena(),u=await z(c,o),l=await H(W(c,o),u,s);return{...typeof l.capture=="object"&&l.capture!==null?l.capture:{},..."held"in l?{held:l.held}:{}}}});n.engine=t,f=t,r&&await P(t.files,e);const a=await t.request({op:"start",project:e,...r?{document:r}:{}});return r&&(E=r),b={start:async()=>a,execute:async o=>{const s=await t.request({op:"execute",code:o});return s.error?`Error executing code: ${s.error}`:`Code executed successfully: ${s.result}`},sceneInfo:async()=>JSON.stringify(await t.request({op:"scene-info"}),null,2),objectInfo:async o=>JSON.stringify(await t.request({op:"object-info",name:o}),null,2),screenshotView:async o=>(await t.request({op:"present",capture:{size:o}}),JSON.stringify({view:{size:o}}))},{...a,engine:"blender-wasm",skew:t.skew,bootMs:Math.round(t.bootMs),releasedPayloadMB:t.releasedPayloadBytes===null?null:Math.round(t.releasedPayloadBytes/1048576)}}async function Y(){try{const e=await fetch("/__editor/blender-wasm/status");return e.ok?await e.json():{available:!1,missing:[`status answered ${e.status}`]}}catch(e){return{available:!1,missing:[String(e)]}}}async function Z(e,r){if(b)throw new Error("The Blender session is already started");if(!e.startsWith("/"))throw new Error("The Blender session needs the project's absolute path");if(r!==void 0&&!q(r))throw new Error(`The Blender document must be a project-relative .blend path with no traversal (models/model.blend); got ${JSON.stringify(r)}`);const n=await Y();if(!n.available)throw new Error(`Headless Blender is not served by this editor, so there is no modeling engine: ${n.missing.join("; ")}. The engine is Blender compiled to WebAssembly (packages/blender-engine/wasm, or the directory VGAI_BLENDER_WASM_DIR names); nothing stands in for it.`);return O=e,X(e,r)}function q(e){return!e.endsWith(".blend")||e.startsWith("/")||e.includes("\\")?!1:e.split("/").every(n=>n!==""&&n!=="."&&n!=="..")}const I=new Set;function B(e){I.has(e)||(I.add(e),p("error",e))}async function ee(e){const r=s=>(B(`The project's files are not readable from Python: ${s}`),null);let n;try{n=await fetch("/__editor/blender-project-index")}catch(s){return r(String(s))}if(!n.ok)return r(`/__editor/blender-project-index answered ${n.status}`);let t;try{if(t=await n.json(),typeof t?.root!="string"||!Array.isArray(t.files))return r("invalid project index")}catch(s){return r(String(s))}const{root:a,files:o}=t;return a!==e&&B(`The editor serving this tab has ${a} open, not ${e}; its files are mounted at ${e}, which is where Python is looking.`),o}const w=new Map;async function te(e,r){const n=await e.stat(r);return n?`${n.size}:${n.mtimeMs}`:""}async function P(e,r){const n=await ee(r);if(!n)return;const t=new Set(n.map(a=>`${r}/${a.path}`));for(const a of[...w.keys()])if(!t.has(a)){try{await e.unlink(a)}catch{}w.delete(a)}for(const a of n){const o=`${r}/${a.path}`,s=`${a.size}:${a.mtime}`;if(w.get(o)?.host===s||!w.has(o)&&await e.stat(o)!==null)continue;const i=await fetch(`/__editor/blender-project-file?path=${encodeURIComponent(a.path)}`);if(!i.ok){B(`${a.path}: HTTP ${i.status}`);continue}const c=o.slice(0,o.lastIndexOf("/"));c&&await e.mkdirTree(c),await e.writeFile(o,new Uint8Array(await i.arrayBuffer())),w.set(o,{host:s,engine:await te(e,o)})}}async function ne(e,r){const n=[],t=async a=>{let o;try{o=await e.readdir(a)}catch{return}for(const s of o){if(s==="."||s==="..")continue;const i=`${a.replace(/\/$/,"")}/${s}`,c=await e.stat(i);if(c){if((c.mode&61440)===16384){await t(i);continue}w.get(i)?.engine!==`${c.size}:${c.mtimeMs}`&&n.push({path:i,size:c.size,mtime:c.mtimeMs})}}};return await t(r),n}async function R(e){switch(e.op){case"start":return Z(e.project,e.document);case"present-result":{const t=A.get(e.id);A.delete(e.id),t&&(e.error?t.reject(new Error(e.error)):t.resolve({...e.capture===void 0?{}:{capture:e.capture},..."held"in e?{held:e.held}:{}}));return}}if(!b||!O||!f)throw new Error("The Blender session has not started");const r=f.files,n=f.request.bind(f);switch(e.op){case"history-begin":case"history-end":return n({op:e.op});case"history-step":return n({op:"history-step",token:e.token,direction:e.direction});case"execute":await P(r,O);{const t=await n({op:"execute",code:e.code,history:e.history??!0,label:e.label??"Blender Python"});return t.error?`Error executing code: ${t.error}`:`Code executed successfully: ${t.result}`}case"present":return n({op:"present"});case"scene-info":return b.sceneInfo();case"object-info":return b.objectInfo(e.name);case"rna":return n({op:"rna",path:e.path,...e.names===void 0?{}:{names:e.names}});case"rna-context":return n({op:"rna-context",...e.object===void 0?{}:{object:e.object},...e.collection===void 0?{}:{collection:e.collection}});case"rna-set":return n({op:"rna-set",history:e.history!==!1,path:e.path,property:e.property,value:e.value,...e.index===void 0?{}:{index:e.index}});case"outliner":return n({op:"outliner",...e.selected===void 0?{}:{selected:[...e.selected]}});case"node-tree":return n({op:"node-tree",...e.path===void 0?{}:{path:e.path},...e.material===void 0?{}:{material:e.material}});case"uv-layout":return n({op:"uv-layout",...e.object===void 0?{}:{object:e.object},...e.uvLayer===void 0?{}:{uvLayer:e.uvLayer}});case"rig":return n({op:"rig",...e.object===void 0?{}:{object:e.object}});case"action-clip":return n({op:"action-clip",...e.object===void 0?{}:{object:e.object},...e.bake===void 0?{}:{bake:e.bake}});case"outliner-set":return n({op:"outliner-set",path:e.path,column:e.column,value:e.value});case"screenshot-view":return JSON.parse(await b.screenshotView(e.maxSize));case"read-file":return r.readFile(e.path);case"write-file":{const t=e.path.slice(0,e.path.lastIndexOf("/"));t&&await r.mkdirTree(t),await r.writeFile(e.path,e.bytes),w.delete(e.path);return}case"list-files":return ne(r,e.path)}throw new Error(`Unknown Blender worker request ${e.op}`)}function g(e){if(e instanceof Error)return e.stack??`${e.name}: ${e.message}`;if(typeof e=="object"&&e!==null){const r=e;if(typeof r.message=="string")return typeof r.name=="string"?`${r.name}: ${r.message}`:r.message;try{return JSON.stringify(e)??Object.prototype.toString.call(e)}catch{return Object.prototype.toString.call(e)}}return String(e)}function re(){if(!f)return;const e=f.memoryBytes();e!==null&&$({op:"memory",bytes:e})}self.onmessage=async e=>{const r=e.data;if(r.op==="present-result"){await R(r);return}k+=1;try{const n=await R(r);await x(),$({id:r.id,result:n})}catch(n){let t=g(n);try{await x()}catch(a){t+=`
|
|
2
|
+
Unable to deliver Blender history: ${g(a)}`}$({id:r.id,error:t})}finally{k-=1}re()};async function x(){if(!f||!b)return;const e=await f.request({op:"history-events"});e.length&&$({op:"history",entries:e})}export{_ as A,ae as P,d as S,oe as a,L as b,se as o,C as s};
|