oda-engine 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +151 -2
- package/bin/nowhere.mjs +352 -0
- package/lib/account.mjs +57 -0
- package/lib/agentModules.mjs +57 -0
- package/lib/devServer.mjs +351 -0
- package/lib/headless.mjs +231 -0
- package/lib/headlessPreview.mjs +212 -0
- package/lib/keys.mjs +517 -0
- package/lib/make.mjs +855 -0
- package/lib/mcp.mjs +537 -0
- package/lib/open.mjs +22 -0
- package/lib/preview.mjs +87 -0
- package/lib/previewRpc.mjs +134 -0
- package/lib/project.mjs +359 -0
- package/lib/publishFlow.mjs +90 -0
- package/lib/resources.mjs +50 -0
- package/lib/rules.mjs +60 -0
- package/lib/scaffold.mjs +42 -0
- package/lib/setup.mjs +59 -0
- package/lib/tools.mjs +668 -0
- package/package.json +51 -4
- package/template/game.config.json +9 -0
- package/template/scene.json +4 -0
- package/template/src/main.ts +11 -0
- package/vendor/DOCS.md +447 -0
- package/vendor/agent/appRun.mjs +520 -0
- package/vendor/agent/assets/brief.mjs +242 -0
- package/vendor/agent/assets/collider.mjs +531 -0
- package/vendor/agent/assets/environments/index.mjs +12 -0
- package/vendor/agent/assets/environments/worldlabs.mjs +161 -0
- package/vendor/agent/assets/fetch.mjs +168 -0
- package/vendor/agent/assets/footprint.mjs +13 -0
- package/vendor/agent/assets/gltf.mjs +547 -0
- package/vendor/agent/assets/hdr.mjs +269 -0
- package/vendor/agent/assets/imageOps.mjs +171 -0
- package/vendor/agent/assets/images/codex.mjs +307 -0
- package/vendor/agent/assets/images/fal.mjs +75 -0
- package/vendor/agent/assets/images/gemini.mjs +84 -0
- package/vendor/agent/assets/images/index.mjs +25 -0
- package/vendor/agent/assets/images/openai.mjs +75 -0
- package/vendor/agent/assets/images/stability.mjs +71 -0
- package/vendor/agent/assets/images/views.mjs +31 -0
- package/vendor/agent/assets/import.mjs +1352 -0
- package/vendor/agent/assets/inspect.mjs +465 -0
- package/vendor/agent/assets/jobs.mjs +196 -0
- package/vendor/agent/assets/ktx2.mjs +290 -0
- package/vendor/agent/assets/ledger.mjs +466 -0
- package/vendor/agent/assets/net.mjs +254 -0
- package/vendor/agent/assets/prices.json +39 -0
- package/vendor/agent/assets/providers/fal.mjs +115 -0
- package/vendor/agent/assets/providers/index.mjs +22 -0
- package/vendor/agent/assets/providers/meshy.mjs +119 -0
- package/vendor/agent/assets/providers/tripo.mjs +188 -0
- package/vendor/agent/assets/sources/ambientcg.mjs +129 -0
- package/vendor/agent/assets/sources/index.mjs +23 -0
- package/vendor/agent/assets/sources/polyhaven.mjs +237 -0
- package/vendor/agent/assets/sources/polypizza.mjs +121 -0
- package/vendor/agent/assets/splat.mjs +631 -0
- package/vendor/agent/assets/targets.mjs +122 -0
- package/vendor/agent/assets/tile.mjs +261 -0
- package/vendor/agent/assets/unzip.mjs +180 -0
- package/vendor/agent/blender/cleanup.py +360 -0
- package/vendor/agent/blender/convert.py +167 -0
- package/vendor/agent/blender/find.mjs +192 -0
- package/vendor/agent/blender/nw_export.py +104 -0
- package/vendor/agent/blender/nw_rubric.py +426 -0
- package/vendor/agent/blender/run.mjs +193 -0
- package/vendor/agent/blender/runner.py +252 -0
- package/vendor/agent/blender/sheet.py +743 -0
- package/vendor/agent/depth.mjs +134 -0
- package/vendor/agent/director/board.mjs +451 -0
- package/vendor/agent/director/contracts.mjs +663 -0
- package/vendor/agent/director/director.mjs +2365 -0
- package/vendor/agent/director/estimate.mjs +200 -0
- package/vendor/agent/director/gate.mjs +802 -0
- package/vendor/agent/director/limits.json +16 -0
- package/vendor/agent/director/methods.mjs +457 -0
- package/vendor/agent/director/policy.json +33 -0
- package/vendor/agent/director/prompts.mjs +244 -0
- package/vendor/agent/director/reading.mjs +341 -0
- package/vendor/agent/director/router.mjs +184 -0
- package/vendor/agent/director/seams.mjs +243 -0
- package/vendor/agent/director/session.mjs +643 -0
- package/vendor/agent/director/store.mjs +119 -0
- package/vendor/agent/director/taskGate.mjs +110 -0
- package/vendor/agent/director/teamLedger.mjs +118 -0
- package/vendor/agent/director/triage.mjs +63 -0
- package/vendor/agent/downloads.cjs +363 -0
- package/vendor/agent/flow.mjs +78 -0
- package/vendor/agent/guard.mjs +613 -0
- package/vendor/agent/host.mjs +1736 -0
- package/vendor/agent/language.mjs +58 -0
- package/vendor/agent/ledger.mjs +360 -0
- package/vendor/agent/locale.cjs +186 -0
- package/vendor/agent/loop/capacity.mjs +74 -0
- package/vendor/agent/loop/compose.mjs +127 -0
- package/vendor/agent/loop/gate.mjs +205 -0
- package/vendor/agent/loop/judge.mjs +189 -0
- package/vendor/agent/loop/levels.mjs +273 -0
- package/vendor/agent/loop/state.mjs +358 -0
- package/vendor/agent/notes.cjs +278 -0
- package/vendor/agent/pace.mjs +258 -0
- package/vendor/agent/panels.mjs +431 -0
- package/vendor/agent/prompt.mjs +342 -0
- package/vendor/agent/reference/board.mjs +410 -0
- package/vendor/agent/reference/compose.mjs +364 -0
- package/vendor/agent/reference/decode.mjs +56 -0
- package/vendor/agent/reference/facts.mjs +1874 -0
- package/vendor/agent/reference/png.mjs +107 -0
- package/vendor/agent/reference/records.mjs +63 -0
- package/vendor/agent/reference/web.mjs +252 -0
- package/vendor/agent/roles/artist.mjs +69 -0
- package/vendor/agent/roles/builder.mjs +79 -0
- package/vendor/agent/roles/checks.mjs +223 -0
- package/vendor/agent/roles/common.mjs +188 -0
- package/vendor/agent/roles/critic.mjs +171 -0
- package/vendor/agent/roles/index.mjs +39 -0
- package/vendor/agent/roles/modeller.mjs +142 -0
- package/vendor/agent/roles/qa.mjs +58 -0
- package/vendor/agent/roles/rubrics.mjs +79 -0
- package/vendor/agent/roles/sound.mjs +69 -0
- package/vendor/agent/rounds.cjs +333 -0
- package/vendor/agent/shared.mjs +284 -0
- package/vendor/agent/stopGate.mjs +574 -0
- package/vendor/agent/subagents.mjs +129 -0
- package/vendor/agent/tools/assets.mjs +499 -0
- package/vendor/agent/tools/blender.mjs +754 -0
- package/vendor/agent/tools/cards.mjs +479 -0
- package/vendor/agent/tools/choices.mjs +479 -0
- package/vendor/agent/tools/compose.mjs +74 -0
- package/vendor/agent/tools/environment.mjs +488 -0
- package/vendor/agent/tools/eyes.mjs +733 -0
- package/vendor/agent/tools/generate.mjs +338 -0
- package/vendor/agent/tools/guide.mjs +46 -0
- package/vendor/agent/tools/harness.mjs +193 -0
- package/vendor/agent/tools/image.mjs +643 -0
- package/vendor/agent/tools/index.mjs +162 -0
- package/vendor/agent/tools/look.mjs +578 -0
- package/vendor/agent/tools/loop.mjs +858 -0
- package/vendor/agent/tools/others.mjs +123 -0
- package/vendor/agent/tools/pictures.mjs +535 -0
- package/vendor/agent/tools/reference.mjs +366 -0
- package/vendor/agent/transcripts.mjs +118 -0
- package/vendor/agent-loop.mjs +602 -0
- package/vendor/agent-plugin/.claude-plugin/plugin.json +5 -0
- package/vendor/agent-plugin/skills/art-direction/SKILL.md +82 -0
- package/vendor/agent-plugin/skills/asset-legality/SKILL.md +101 -0
- package/vendor/agent-plugin/skills/asset-sources/SKILL.md +111 -0
- package/vendor/agent-plugin/skills/blender-modeling/SKILL.md +97 -0
- package/vendor/agent-plugin/skills/look-dev/SKILL.md +104 -0
- package/vendor/agent-plugin/skills/playtesting/SKILL.md +74 -0
- package/vendor/agent-plugin/skills/reference-loop/SKILL.md +102 -0
- package/vendor/agent-plugin/skills/sound-design/SKILL.md +60 -0
- package/vendor/agent-plugin/skills/style/SKILL.md +35 -0
- package/vendor/agent-plugin/skills/tsl-r185/SKILL.md +107 -0
- package/vendor/auth.cjs +570 -0
- package/vendor/build.cjs +953 -0
- package/vendor/catalog.json +455 -0
- package/vendor/connectors.cjs +688 -0
- package/vendor/eyes.mjs +733 -0
- package/vendor/gameExports.json +1390 -0
- package/vendor/git.cjs +222 -0
- package/vendor/models.json +57 -0
- package/vendor/publish.cjs +1018 -0
- package/vendor/refBoard.cjs +301 -0
- package/vendor/schema/dist/assets.d.ts +335 -0
- package/vendor/schema/dist/assets.js +439 -0
- package/vendor/schema/dist/brief.d.ts +357 -0
- package/vendor/schema/dist/brief.js +302 -0
- package/vendor/schema/dist/common.d.ts +9 -0
- package/vendor/schema/dist/common.js +13 -0
- package/vendor/schema/dist/config.d.ts +406 -0
- package/vendor/schema/dist/config.js +355 -0
- package/vendor/schema/dist/contract.d.ts +599 -0
- package/vendor/schema/dist/contract.js +1146 -0
- package/vendor/schema/dist/index.d.ts +14 -0
- package/vendor/schema/dist/index.js +21 -0
- package/vendor/schema/dist/look.d.ts +463 -0
- package/vendor/schema/dist/look.js +681 -0
- package/vendor/schema/dist/lookStats.d.ts +230 -0
- package/vendor/schema/dist/lookStats.js +768 -0
- package/vendor/schema/dist/pilot.d.ts +32 -0
- package/vendor/schema/dist/pilot.js +44 -0
- package/vendor/schema/dist/publish.d.ts +214 -0
- package/vendor/schema/dist/publish.js +291 -0
- package/vendor/schema/dist/scene.d.ts +75 -0
- package/vendor/schema/dist/scene.js +120 -0
- package/vendor/schema/dist/skyLight.d.ts +141 -0
- package/vendor/schema/dist/skyLight.js +436 -0
- package/vendor/schema/dist/style.d.ts +131 -0
- package/vendor/schema/dist/style.js +155 -0
- package/vendor/schema/package.json +1 -0
- package/vendor/selectionPrompt.mjs +51 -0
- package/vendor/useTools.mjs +195 -0
- package/vendor/userMessage.mjs +26 -0
- package/web-dist/assets/GaussianSplatUtils-CB77cP9U.js +1 -0
- package/web-dist/assets/KTX2Loader-6OIWUF7s.js +2 -0
- package/web-dist/assets/SPZLoader-zYj0Alfv.js +1 -0
- package/web-dist/assets/gaussianSplat-CJTI1sEh.js +1 -0
- package/web-dist/assets/index-CcjyyQco.css +1 -0
- package/web-dist/assets/index-DMyJcoZJ.js +693 -0
- package/web-dist/assets/meshopt_decoder.module-BvwdjiD3.js +1 -0
- package/web-dist/assets/zstddec.module-CfFeQW7d.js +1 -0
- package/web-dist/index.html +34 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# The export run of nw_blender: empties the factory scene, runs the agent's
|
|
2
|
+
# bpy script, lists what glTF will not carry, and exports the result as one
|
|
3
|
+
# GLB. run.mjs starts it as
|
|
4
|
+
# Blender -b --factory-startup --disable-autoexec --offline-mode
|
|
5
|
+
# --python-exit-code 3 --python runner.py -- <args.json>
|
|
6
|
+
# with args { project, script, out_tmp, collection, blend, result }. The
|
|
7
|
+
# answer goes to args.result as JSON; stdout belongs to the agent's prints.
|
|
8
|
+
# Written for Blender 4.2 to 5.1: anything newer than 4.2 is tried and
|
|
9
|
+
# dropped with a warning when the running Blender refuses it.
|
|
10
|
+
#
|
|
11
|
+
# The script is the agent's own bpy: nothing is put on its path but the
|
|
12
|
+
# folder it sits in. After it ran, the answer also says what it read from the
|
|
13
|
+
# project (`inputs`: the images and linked libraries under it, for the
|
|
14
|
+
# licence ledger), leaving out the files the run wrote itself (its bakes).
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
import os
|
|
18
|
+
import sys
|
|
19
|
+
import time
|
|
20
|
+
import traceback
|
|
21
|
+
|
|
22
|
+
import bpy
|
|
23
|
+
|
|
24
|
+
# Compiled copies of the modules beside this file would land inside the
|
|
25
|
+
# app; nothing is gained, since every run starts a fresh Blender.
|
|
26
|
+
sys.dont_write_bytecode = True
|
|
27
|
+
HERE = os.path.dirname(os.path.realpath(__file__))
|
|
28
|
+
if HERE not in sys.path:
|
|
29
|
+
sys.path.append(HERE)
|
|
30
|
+
|
|
31
|
+
from nw_export import dropped_nodes, export # noqa: E402
|
|
32
|
+
|
|
33
|
+
ARGS = json.load(open(sys.argv[sys.argv.index('--') + 1], encoding='utf-8'))
|
|
34
|
+
STARTED = time.time()
|
|
35
|
+
WARNINGS = []
|
|
36
|
+
|
|
37
|
+
# What "every visible mesh, curve, text and empty" means in Blender's types.
|
|
38
|
+
# Armatures go along so a rigged model keeps its skeleton and animations.
|
|
39
|
+
EXPORT_TYPES = {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'EMPTY', 'ARMATURE'}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def write_result(doc):
|
|
43
|
+
doc['seconds'] = round(time.time() - STARTED, 2)
|
|
44
|
+
doc['warnings'] = WARNINGS
|
|
45
|
+
with open(ARGS['result'], 'w', encoding='utf-8') as f:
|
|
46
|
+
json.dump(doc, f)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def empty_scene():
|
|
50
|
+
# The factory scene's cube, camera and light would otherwise be exported
|
|
51
|
+
# along with the model; its world stays, for scripts that set a sky.
|
|
52
|
+
for obj in list(bpy.data.objects):
|
|
53
|
+
bpy.data.objects.remove(obj, do_unlink=True)
|
|
54
|
+
scene = bpy.context.scene
|
|
55
|
+
for coll in list(scene.collection.children):
|
|
56
|
+
bpy.data.collections.remove(coll)
|
|
57
|
+
try:
|
|
58
|
+
bpy.data.orphans_purge(do_recursive=True)
|
|
59
|
+
except Exception:
|
|
60
|
+
pass
|
|
61
|
+
scene.unit_settings.system = 'METRIC'
|
|
62
|
+
scene.unit_settings.scale_length = 1.0
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def script_frame(error, script):
|
|
66
|
+
"""The deepest traceback line inside the agent's own script."""
|
|
67
|
+
if isinstance(error, SyntaxError) and error.filename and os.path.realpath(error.filename) == script:
|
|
68
|
+
return {'line': error.lineno, 'text': (error.text or '').strip()}
|
|
69
|
+
found = None
|
|
70
|
+
for frame in traceback.extract_tb(error.__traceback__):
|
|
71
|
+
if os.path.realpath(frame.filename) == script:
|
|
72
|
+
found = {'line': frame.lineno, 'text': (frame.line or '').strip()}
|
|
73
|
+
return found
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def script_traceback(error, script):
|
|
77
|
+
"""The traceback from the agent's script down, without this runner's frames."""
|
|
78
|
+
tb = error.__traceback__
|
|
79
|
+
while tb is not None and os.path.realpath(tb.tb_frame.f_code.co_filename) != script:
|
|
80
|
+
tb = tb.tb_next
|
|
81
|
+
if tb is None:
|
|
82
|
+
return ''.join(traceback.format_exception_only(type(error), error))
|
|
83
|
+
return ''.join(traceback.format_exception(type(error), error, tb))
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def run_script(script):
|
|
87
|
+
project = ARGS['project']
|
|
88
|
+
os.chdir(project)
|
|
89
|
+
# A script may keep helpers beside it (blender/lib.py) and import them;
|
|
90
|
+
# this runner's own folder is taken off the path, so the script sees
|
|
91
|
+
# only bpy, its own folder and Python's.
|
|
92
|
+
sys.path.insert(0, os.path.dirname(script))
|
|
93
|
+
if HERE in sys.path:
|
|
94
|
+
sys.path.remove(HERE)
|
|
95
|
+
# Old habits read the output path from sys.argv and export or reset the
|
|
96
|
+
# scene themselves; nw_blender does both, so the script gets no arguments.
|
|
97
|
+
sys.argv = [script]
|
|
98
|
+
with open(script, encoding='utf-8') as f:
|
|
99
|
+
source = f.read()
|
|
100
|
+
code = compile(source, script, 'exec')
|
|
101
|
+
scope = {'__name__': '__main__', '__file__': script, 'NW_PROJECT': project}
|
|
102
|
+
try:
|
|
103
|
+
exec(code, scope)
|
|
104
|
+
except SystemExit as e:
|
|
105
|
+
if e.code not in (None, 0):
|
|
106
|
+
raise RuntimeError(f'the script called sys.exit({e.code!r})') from None
|
|
107
|
+
WARNINGS.append('the script called sys.exit(); nw_blender carried on and exported (leave it out)')
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def export_objects(scene, collection):
|
|
111
|
+
view_layer = bpy.context.view_layer
|
|
112
|
+
if collection:
|
|
113
|
+
coll = bpy.data.collections.get(collection)
|
|
114
|
+
if coll is None:
|
|
115
|
+
return None, [c.name for c in bpy.data.collections]
|
|
116
|
+
# A collection kept out of the default export (a lighter copy the
|
|
117
|
+
# script excluded from the view layer) is what this call asked for,
|
|
118
|
+
# so it is shown for the export.
|
|
119
|
+
show_collection(view_layer.layer_collection, coll)
|
|
120
|
+
pool = coll.all_objects
|
|
121
|
+
else:
|
|
122
|
+
pool = scene.objects
|
|
123
|
+
# Visibility and selectability live on the view layer's bases, which
|
|
124
|
+
# Blender refreshes only when the scene is evaluated; objects the script
|
|
125
|
+
# just made can read as hidden and refuse selection until then.
|
|
126
|
+
view_layer.update()
|
|
127
|
+
picked = []
|
|
128
|
+
for obj in pool:
|
|
129
|
+
if obj.type not in EXPORT_TYPES:
|
|
130
|
+
continue
|
|
131
|
+
try:
|
|
132
|
+
if not obj.visible_get(view_layer=view_layer):
|
|
133
|
+
continue
|
|
134
|
+
except Exception:
|
|
135
|
+
continue
|
|
136
|
+
picked.append(obj)
|
|
137
|
+
return picked, None
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def show_collection(layer, coll):
|
|
141
|
+
"""Includes coll (and the layer collections above it) in the view layer and unhides it."""
|
|
142
|
+
if layer.collection == coll:
|
|
143
|
+
layer.exclude = False
|
|
144
|
+
layer.hide_viewport = False
|
|
145
|
+
coll.hide_viewport = False
|
|
146
|
+
return True
|
|
147
|
+
for child in layer.children:
|
|
148
|
+
if show_collection(child, coll):
|
|
149
|
+
layer.exclude = False
|
|
150
|
+
layer.hide_viewport = False
|
|
151
|
+
return True
|
|
152
|
+
return False
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def project_relative(path, project):
|
|
156
|
+
"""The project-relative path of a file inside the project, else None."""
|
|
157
|
+
if not path:
|
|
158
|
+
return None
|
|
159
|
+
try:
|
|
160
|
+
full = os.path.realpath(bpy.path.abspath(path))
|
|
161
|
+
except Exception:
|
|
162
|
+
return None
|
|
163
|
+
root = os.path.realpath(project)
|
|
164
|
+
if not full.startswith(root + os.sep) or not os.path.isfile(full):
|
|
165
|
+
return None
|
|
166
|
+
return os.path.relpath(full, root).replace(os.sep, '/')
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def written_this_run(full):
|
|
170
|
+
"""Whether a file was written after this run started (a bake the script
|
|
171
|
+
saved), so it is the run's own output and not something it read."""
|
|
172
|
+
try:
|
|
173
|
+
return os.path.getmtime(full) >= STARTED - 0.05
|
|
174
|
+
except OSError:
|
|
175
|
+
return False
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def read_inputs(project):
|
|
179
|
+
"""The project's files the script read: images and linked libraries, not
|
|
180
|
+
the files the run wrote itself (its bakes)."""
|
|
181
|
+
found = []
|
|
182
|
+
for block in list(bpy.data.images) + list(bpy.data.libraries):
|
|
183
|
+
if getattr(block, 'source', 'FILE') not in ('FILE', 'SEQUENCE', 'TILED', 'MOVIE'):
|
|
184
|
+
continue
|
|
185
|
+
path = getattr(block, 'filepath', '')
|
|
186
|
+
rel = project_relative(path, project)
|
|
187
|
+
if not rel or rel in found:
|
|
188
|
+
continue
|
|
189
|
+
if written_this_run(os.path.join(os.path.realpath(project), rel)):
|
|
190
|
+
continue
|
|
191
|
+
found.append(rel)
|
|
192
|
+
return sorted(found)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def main():
|
|
196
|
+
script = os.path.realpath(ARGS['script'])
|
|
197
|
+
empty_scene()
|
|
198
|
+
try:
|
|
199
|
+
run_script(script)
|
|
200
|
+
except BaseException as e:
|
|
201
|
+
trace = script_traceback(e, script)
|
|
202
|
+
write_result({
|
|
203
|
+
'ok': False,
|
|
204
|
+
'stage': 'script',
|
|
205
|
+
'error': f'{type(e).__name__}: {e}',
|
|
206
|
+
'traceback': trace,
|
|
207
|
+
'at': script_frame(e, script),
|
|
208
|
+
})
|
|
209
|
+
sys.stderr.write(trace)
|
|
210
|
+
sys.exit(3)
|
|
211
|
+
|
|
212
|
+
# A script that ends in edit mode has edits the mesh data does not have yet.
|
|
213
|
+
try:
|
|
214
|
+
if bpy.context.object is not None and bpy.context.object.mode != 'OBJECT':
|
|
215
|
+
bpy.ops.object.mode_set(mode='OBJECT')
|
|
216
|
+
except Exception:
|
|
217
|
+
pass
|
|
218
|
+
|
|
219
|
+
scene = bpy.context.scene
|
|
220
|
+
selected, collections = export_objects(scene, ARGS.get('collection'))
|
|
221
|
+
if selected is None:
|
|
222
|
+
write_result({'ok': False, 'stage': 'collection', 'collection': ARGS.get('collection'), 'collections': collections})
|
|
223
|
+
sys.exit(3)
|
|
224
|
+
if not selected:
|
|
225
|
+
write_result({'ok': False, 'stage': 'empty', 'collection': ARGS.get('collection')})
|
|
226
|
+
sys.exit(3)
|
|
227
|
+
|
|
228
|
+
meshes = sum(1 for o in selected if o.type == 'MESH')
|
|
229
|
+
dropped = dropped_nodes(selected)
|
|
230
|
+
try:
|
|
231
|
+
export(ARGS['out_tmp'], selected, WARNINGS)
|
|
232
|
+
except BaseException as e:
|
|
233
|
+
write_result({'ok': False, 'stage': 'export', 'error': f'{type(e).__name__}: {e}', 'traceback': traceback.format_exc()})
|
|
234
|
+
raise
|
|
235
|
+
if not os.path.isfile(ARGS['out_tmp']) or os.path.getsize(ARGS['out_tmp']) == 0:
|
|
236
|
+
write_result({'ok': False, 'stage': 'export', 'error': 'the glTF exporter wrote no file', 'traceback': ''})
|
|
237
|
+
sys.exit(3)
|
|
238
|
+
|
|
239
|
+
if ARGS.get('blend'):
|
|
240
|
+
try:
|
|
241
|
+
os.makedirs(os.path.dirname(ARGS['blend']), exist_ok=True)
|
|
242
|
+
bpy.ops.wm.save_as_mainfile(filepath=ARGS['blend'], compress=True)
|
|
243
|
+
except Exception as e:
|
|
244
|
+
WARNINGS.append(f'the .blend was not saved: {e}')
|
|
245
|
+
|
|
246
|
+
write_result({
|
|
247
|
+
'ok': True, 'objects': len(selected), 'meshes': meshes, 'dropped': dropped, 'exported': ARGS['out_tmp'],
|
|
248
|
+
'inputs': read_inputs(ARGS['project']),
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
main()
|