@nodaro/shared 3.31.0 → 3.33.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 +17 -0
- package/dist/chunk-23FJQTEA.js +1604 -0
- package/dist/chunk-23FJQTEA.js.map +1 -0
- package/dist/chunk-2NIQO2J3.cjs +54 -0
- package/dist/chunk-2NIQO2J3.cjs.map +1 -0
- package/dist/chunk-2NQLSLSN.cjs +19 -0
- package/dist/chunk-2NQLSLSN.cjs.map +1 -0
- package/dist/chunk-2OJIVO7R.cjs +32 -0
- package/dist/chunk-2OJIVO7R.cjs.map +1 -0
- package/dist/chunk-2RF4Z7KG.cjs +803 -0
- package/dist/chunk-2RF4Z7KG.cjs.map +1 -0
- package/dist/chunk-3RYKIUAE.js +86 -0
- package/dist/chunk-3RYKIUAE.js.map +1 -0
- package/dist/chunk-44I73CQS.cjs +194 -0
- package/dist/chunk-44I73CQS.cjs.map +1 -0
- package/dist/chunk-5PC6JBGJ.cjs +1419 -0
- package/dist/chunk-5PC6JBGJ.cjs.map +1 -0
- package/dist/chunk-5RU2HCW2.js +30 -0
- package/dist/chunk-5RU2HCW2.js.map +1 -0
- package/dist/chunk-5RYLK3MQ.js +267 -0
- package/dist/chunk-5RYLK3MQ.js.map +1 -0
- package/dist/chunk-5THUHJ3E.js +46 -0
- package/dist/chunk-5THUHJ3E.js.map +1 -0
- package/dist/chunk-6DAWSVX2.cjs +103 -0
- package/dist/chunk-6DAWSVX2.cjs.map +1 -0
- package/dist/chunk-6WZ2VN7V.js +920 -0
- package/dist/chunk-6WZ2VN7V.js.map +1 -0
- package/dist/chunk-7G7G42KS.js +86 -0
- package/dist/chunk-7G7G42KS.js.map +1 -0
- package/dist/chunk-7Z5LUTGU.js +1567 -0
- package/dist/chunk-7Z5LUTGU.js.map +1 -0
- package/dist/chunk-AINCI23X.js +2171 -0
- package/dist/chunk-AINCI23X.js.map +1 -0
- package/dist/chunk-BG5D5CZ6.js +1922 -0
- package/dist/chunk-BG5D5CZ6.js.map +1 -0
- package/dist/chunk-CK3GK34R.js +1381 -0
- package/dist/chunk-CK3GK34R.js.map +1 -0
- package/dist/chunk-CUH22J4D.js +17 -0
- package/dist/chunk-CUH22J4D.js.map +1 -0
- package/dist/chunk-D26ENTN2.cjs +1770 -0
- package/dist/chunk-D26ENTN2.cjs.map +1 -0
- package/dist/chunk-D6GNRSCV.cjs +2017 -0
- package/dist/chunk-D6GNRSCV.cjs.map +1 -0
- package/dist/chunk-FBV5DF6D.js +95 -0
- package/dist/chunk-FBV5DF6D.js.map +1 -0
- package/dist/chunk-FG4E7MTG.cjs +4 -0
- package/dist/chunk-FG4E7MTG.cjs.map +1 -0
- package/dist/chunk-FT5CF6IA.js +42 -0
- package/dist/chunk-FT5CF6IA.js.map +1 -0
- package/dist/chunk-G6IIVKMO.js +26 -0
- package/dist/chunk-G6IIVKMO.js.map +1 -0
- package/dist/chunk-HC7VKIV5.cjs +430 -0
- package/dist/chunk-HC7VKIV5.cjs.map +1 -0
- package/dist/chunk-HGC5JNVA.cjs +1503 -0
- package/dist/chunk-HGC5JNVA.cjs.map +1 -0
- package/dist/chunk-HKFMXNVQ.cjs +1273 -0
- package/dist/chunk-HKFMXNVQ.cjs.map +1 -0
- package/dist/chunk-HRXEZ3SX.cjs +526 -0
- package/dist/chunk-HRXEZ3SX.cjs.map +1 -0
- package/dist/chunk-HSHCCBIV.js +255 -0
- package/dist/chunk-HSHCCBIV.js.map +1 -0
- package/dist/chunk-HUR6ZJ7S.cjs +159 -0
- package/dist/chunk-HUR6ZJ7S.cjs.map +1 -0
- package/dist/chunk-J7BMO73N.cjs +114 -0
- package/dist/chunk-J7BMO73N.cjs.map +1 -0
- package/dist/chunk-JFS3NWZ5.cjs +1714 -0
- package/dist/chunk-JFS3NWZ5.cjs.map +1 -0
- package/dist/chunk-JL4C5VJ7.cjs +488 -0
- package/dist/chunk-JL4C5VJ7.cjs.map +1 -0
- package/dist/chunk-JSGIEF6Z.cjs +1087 -0
- package/dist/chunk-JSGIEF6Z.cjs.map +1 -0
- package/dist/chunk-JWA5SGCS.js +203 -0
- package/dist/chunk-JWA5SGCS.js.map +1 -0
- package/dist/chunk-K3LLGRK7.cjs +3545 -0
- package/dist/chunk-K3LLGRK7.cjs.map +1 -0
- package/dist/chunk-KU6S7IYV.cjs +210 -0
- package/dist/chunk-KU6S7IYV.cjs.map +1 -0
- package/dist/chunk-M36G6SRP.js +447 -0
- package/dist/chunk-M36G6SRP.js.map +1 -0
- package/dist/chunk-M7GQBRZU.cjs +1963 -0
- package/dist/chunk-M7GQBRZU.cjs.map +1 -0
- package/dist/chunk-MRXGWL42.cjs +4 -0
- package/dist/chunk-MRXGWL42.cjs.map +1 -0
- package/dist/chunk-NEJ2PV4C.cjs +211 -0
- package/dist/chunk-NEJ2PV4C.cjs.map +1 -0
- package/dist/chunk-OTATNBMD.js +141 -0
- package/dist/chunk-OTATNBMD.js.map +1 -0
- package/dist/chunk-OZSACQ2V.js +471 -0
- package/dist/chunk-OZSACQ2V.js.map +1 -0
- package/dist/chunk-PHZ23DP3.js +1782 -0
- package/dist/chunk-PHZ23DP3.js.map +1 -0
- package/dist/chunk-PQHS255G.js +1369 -0
- package/dist/chunk-PQHS255G.js.map +1 -0
- package/dist/chunk-PRYE7AZQ.cjs +1227 -0
- package/dist/chunk-PRYE7AZQ.cjs.map +1 -0
- package/dist/chunk-PVJBAPYJ.js +404 -0
- package/dist/chunk-PVJBAPYJ.js.map +1 -0
- package/dist/chunk-PXFQVLBX.js +776 -0
- package/dist/chunk-PXFQVLBX.js.map +1 -0
- package/dist/chunk-QA3MVQ32.js +21 -0
- package/dist/chunk-QA3MVQ32.js.map +1 -0
- package/dist/chunk-QJRP44ZO.js +769 -0
- package/dist/chunk-QJRP44ZO.js.map +1 -0
- package/dist/chunk-SAW5OK36.cjs +54 -0
- package/dist/chunk-SAW5OK36.cjs.map +1 -0
- package/dist/chunk-SES6GDBQ.cjs +624 -0
- package/dist/chunk-SES6GDBQ.cjs.map +1 -0
- package/dist/chunk-SFW3UB2P.js +31 -0
- package/dist/chunk-SFW3UB2P.js.map +1 -0
- package/dist/chunk-TNPDV7I4.cjs +2346 -0
- package/dist/chunk-TNPDV7I4.cjs.map +1 -0
- package/dist/chunk-TU33KYKW.cjs +25 -0
- package/dist/chunk-TU33KYKW.cjs.map +1 -0
- package/dist/chunk-TZBIY5C3.js +187 -0
- package/dist/chunk-TZBIY5C3.js.map +1 -0
- package/dist/chunk-TZE673G6.js +3 -0
- package/dist/chunk-TZE673G6.js.map +1 -0
- package/dist/chunk-UCFWI6D4.js +29 -0
- package/dist/chunk-UCFWI6D4.js.map +1 -0
- package/dist/chunk-UTQSSKSG.js +1164 -0
- package/dist/chunk-UTQSSKSG.js.map +1 -0
- package/dist/chunk-VA42637J.cjs +287 -0
- package/dist/chunk-VA42637J.cjs.map +1 -0
- package/dist/chunk-VNQRI2RO.cjs +1047 -0
- package/dist/chunk-VNQRI2RO.cjs.map +1 -0
- package/dist/chunk-VXPLKQWY.cjs +821 -0
- package/dist/chunk-VXPLKQWY.cjs.map +1 -0
- package/dist/chunk-WD6HJRBG.cjs +197 -0
- package/dist/chunk-WD6HJRBG.cjs.map +1 -0
- package/dist/chunk-WDIBOWAA.js +1054 -0
- package/dist/chunk-WDIBOWAA.js.map +1 -0
- package/dist/chunk-WKOIGLQX.cjs +38 -0
- package/dist/chunk-WKOIGLQX.cjs.map +1 -0
- package/dist/chunk-WNVQ3SMB.cjs +96 -0
- package/dist/chunk-WNVQ3SMB.cjs.map +1 -0
- package/dist/chunk-WRSWH7US.cjs +285 -0
- package/dist/chunk-WRSWH7US.cjs.map +1 -0
- package/dist/chunk-XGFTL5XY.js +181 -0
- package/dist/chunk-XGFTL5XY.js.map +1 -0
- package/dist/chunk-XNISPHTZ.js +1039 -0
- package/dist/chunk-XNISPHTZ.js.map +1 -0
- package/dist/chunk-Y2PM3FFL.js +3 -0
- package/dist/chunk-Y2PM3FFL.js.map +1 -0
- package/dist/chunk-YBPBK5KI.js +1030 -0
- package/dist/chunk-YBPBK5KI.js.map +1 -0
- package/dist/chunk-YWNYGYI7.cjs +31 -0
- package/dist/chunk-YWNYGYI7.cjs.map +1 -0
- package/dist/chunk-YYV35XOS.js +122 -0
- package/dist/chunk-YYV35XOS.js.map +1 -0
- package/dist/chunk-Z2OL5AJD.cjs +133 -0
- package/dist/chunk-Z2OL5AJD.cjs.map +1 -0
- package/dist/chunk-ZDFHA2EC.js +572 -0
- package/dist/chunk-ZDFHA2EC.js.map +1 -0
- package/dist/chunk-ZL7UM6PU.cjs +34 -0
- package/dist/chunk-ZL7UM6PU.cjs.map +1 -0
- package/dist/chunk-ZNZDQAXN.js +175 -0
- package/dist/chunk-ZNZDQAXN.js.map +1 -0
- package/dist/chunk-ZO5PBBFX.js +3497 -0
- package/dist/chunk-ZO5PBBFX.js.map +1 -0
- package/dist/chunk-ZRL2UFTH.cjs +1073 -0
- package/dist/chunk-ZRL2UFTH.cjs.map +1 -0
- package/dist/entries/apps.cjs +155 -0
- package/dist/entries/apps.cjs.map +1 -0
- package/dist/entries/apps.d.cts +292 -0
- package/dist/entries/apps.d.ts +292 -0
- package/dist/entries/apps.js +10 -0
- package/dist/entries/apps.js.map +1 -0
- package/dist/entries/captions.cjs +124 -0
- package/dist/entries/captions.cjs.map +1 -0
- package/dist/entries/captions.d.cts +354 -0
- package/dist/entries/captions.d.ts +354 -0
- package/dist/entries/captions.js +3 -0
- package/dist/entries/captions.js.map +1 -0
- package/dist/entries/catalogs.cjs +165 -0
- package/dist/entries/catalogs.cjs.map +1 -0
- package/dist/entries/catalogs.d.cts +385 -0
- package/dist/entries/catalogs.d.ts +385 -0
- package/dist/entries/catalogs.js +4 -0
- package/dist/entries/catalogs.js.map +1 -0
- package/dist/entries/credits.cjs +596 -0
- package/dist/entries/credits.cjs.map +1 -0
- package/dist/entries/credits.d.cts +1460 -0
- package/dist/entries/credits.d.ts +1460 -0
- package/dist/entries/credits.js +11 -0
- package/dist/entries/credits.js.map +1 -0
- package/dist/entries/edl.cjs +409 -0
- package/dist/entries/edl.cjs.map +1 -0
- package/dist/entries/edl.d.cts +1199 -0
- package/dist/entries/edl.d.ts +1199 -0
- package/dist/entries/edl.js +4 -0
- package/dist/entries/edl.js.map +1 -0
- package/dist/entries/entities.cjs +530 -0
- package/dist/entries/entities.cjs.map +1 -0
- package/dist/entries/entities.d.cts +1371 -0
- package/dist/entries/entities.d.ts +1371 -0
- package/dist/entries/entities.js +5 -0
- package/dist/entries/entities.js.map +1 -0
- package/dist/entries/i18n.cjs +48 -0
- package/dist/entries/i18n.cjs.map +1 -0
- package/dist/entries/i18n.d.cts +69 -0
- package/dist/entries/i18n.d.ts +69 -0
- package/dist/entries/i18n.js +3 -0
- package/dist/entries/i18n.js.map +1 -0
- package/dist/entries/llm-models.cjs +177 -0
- package/dist/entries/llm-models.cjs.map +1 -0
- package/dist/entries/llm-models.d.cts +435 -0
- package/dist/entries/llm-models.d.ts +435 -0
- package/dist/entries/llm-models.js +4 -0
- package/dist/entries/llm-models.js.map +1 -0
- package/dist/entries/media.cjs +335 -0
- package/dist/entries/media.cjs.map +1 -0
- package/dist/entries/media.d.cts +518 -0
- package/dist/entries/media.d.ts +518 -0
- package/dist/entries/media.js +6 -0
- package/dist/entries/media.js.map +1 -0
- package/dist/entries/model-catalog.cjs +259 -0
- package/dist/entries/model-catalog.cjs.map +1 -0
- package/dist/entries/model-catalog.d.cts +202 -0
- package/dist/entries/model-catalog.d.ts +202 -0
- package/dist/entries/model-catalog.js +6 -0
- package/dist/entries/model-catalog.js.map +1 -0
- package/dist/entries/models.cjs +833 -0
- package/dist/entries/models.cjs.map +1 -0
- package/dist/entries/models.d.cts +287 -0
- package/dist/entries/models.d.ts +287 -0
- package/dist/entries/models.js +8 -0
- package/dist/entries/models.js.map +1 -0
- package/dist/entries/nodes.cjs +789 -0
- package/dist/entries/nodes.cjs.map +1 -0
- package/dist/entries/nodes.d.cts +1600 -0
- package/dist/entries/nodes.d.ts +1600 -0
- package/dist/entries/nodes.js +16 -0
- package/dist/entries/nodes.js.map +1 -0
- package/dist/entries/organizations.cjs +80 -0
- package/dist/entries/organizations.cjs.map +1 -0
- package/dist/entries/organizations.d.cts +466 -0
- package/dist/entries/organizations.d.ts +466 -0
- package/dist/entries/organizations.js +3 -0
- package/dist/entries/organizations.js.map +1 -0
- package/dist/entries/pipeline.cjs +594 -0
- package/dist/entries/pipeline.cjs.map +1 -0
- package/dist/entries/pipeline.d.cts +2617 -0
- package/dist/entries/pipeline.d.ts +2617 -0
- package/dist/entries/pipeline.js +5 -0
- package/dist/entries/pipeline.js.map +1 -0
- package/dist/entries/scene3d.cjs +704 -0
- package/dist/entries/scene3d.cjs.map +1 -0
- package/dist/entries/scene3d.d.cts +4284 -0
- package/dist/entries/scene3d.d.ts +4284 -0
- package/dist/entries/scene3d.js +3 -0
- package/dist/entries/scene3d.js.map +1 -0
- package/dist/entries/social.cjs +714 -0
- package/dist/entries/social.cjs.map +1 -0
- package/dist/entries/social.d.cts +1366 -0
- package/dist/entries/social.d.ts +1366 -0
- package/dist/entries/social.js +5 -0
- package/dist/entries/social.js.map +1 -0
- package/dist/entries/types.cjs +13 -0
- package/dist/entries/types.cjs.map +1 -0
- package/dist/entries/types.d.cts +162 -0
- package/dist/entries/types.d.ts +162 -0
- package/dist/entries/types.js +4 -0
- package/dist/entries/types.js.map +1 -0
- package/dist/entries/ugc.cjs +279 -0
- package/dist/entries/ugc.cjs.map +1 -0
- package/dist/entries/ugc.d.cts +575 -0
- package/dist/entries/ugc.d.ts +575 -0
- package/dist/entries/ugc.js +6 -0
- package/dist/entries/ugc.js.map +1 -0
- package/dist/entries/video.cjs +549 -0
- package/dist/entries/video.cjs.map +1 -0
- package/dist/entries/video.d.cts +1791 -0
- package/dist/entries/video.d.ts +1791 -0
- package/dist/entries/video.js +8 -0
- package/dist/entries/video.js.map +1 -0
- package/dist/entries/workflow.cjs +574 -0
- package/dist/entries/workflow.cjs.map +1 -0
- package/dist/entries/workflow.d.cts +1743 -0
- package/dist/entries/workflow.d.ts +1743 -0
- package/dist/entries/workflow.js +5 -0
- package/dist/entries/workflow.js.map +1 -0
- package/dist/fan-out-meta-Bu6VyXcZ.d.cts +19 -0
- package/dist/fan-out-meta-Bu6VyXcZ.d.ts +19 -0
- package/dist/gemini-omni-voices-zeRXxSbZ.d.cts +174 -0
- package/dist/gemini-omni-voices-zeRXxSbZ.d.ts +174 -0
- package/dist/image-overlay-layers-CyBfRhxJ.d.cts +208 -0
- package/dist/image-overlay-layers-CyBfRhxJ.d.ts +208 -0
- package/dist/index.cjs +7747 -27084
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -24198
- package/dist/index.d.ts +32 -24198
- package/dist/index.js +40 -25220
- package/dist/index.js.map +1 -1
- package/dist/model-catalog-V-ZNzRSd.d.cts +651 -0
- package/dist/model-catalog-V-ZNzRSd.d.ts +651 -0
- package/dist/presentation-types-0ENOCjoj.d.cts +61 -0
- package/dist/presentation-types-0ENOCjoj.d.ts +61 -0
- package/dist/presentation-utils-D0kxsWf9.d.cts +92 -0
- package/dist/presentation-utils-pZwlEAzo.d.ts +92 -0
- package/dist/scene-node-types-C3kl_zyK.d.cts +1949 -0
- package/dist/scene-node-types-C3kl_zyK.d.ts +1949 -0
- package/dist/supported-fonts-CRoF1gOy.d.cts +16 -0
- package/dist/supported-fonts-CRoF1gOy.d.ts +16 -0
- package/dist/types-BRlFPEru.d.cts +511 -0
- package/dist/types-BRlFPEru.d.ts +511 -0
- package/dist/types-DffyGSy5.d.cts +67 -0
- package/dist/types-DffyGSy5.d.ts +67 -0
- package/package.json +102 -1
- package/src/__tests__/add-captions-plan.test.ts +6 -2
- package/src/__tests__/caption-edge-dash.test.ts +23 -0
- package/src/__tests__/fixtures/root-exports.baseline.json +4625 -0
- package/src/__tests__/input-field-extra-keys.test.ts +1 -0
- package/src/__tests__/model-makers.test.ts +76 -0
- package/src/__tests__/no-internal-imports.test.ts +1 -1
- package/src/__tests__/node-aspect-ratio.test.ts +25 -0
- package/src/__tests__/node-runtime-keys.test.ts +9 -0
- package/src/__tests__/package-entries.test.ts +50 -0
- package/src/__tests__/pitch-tempo-pricing.test.ts +21 -0
- package/src/__tests__/presentation-utils.test.ts +15 -0
- package/src/__tests__/preview-gate-use-case.test.ts +151 -0
- package/src/__tests__/private-host.test.ts +53 -0
- package/src/__tests__/run-continuation.test.ts +7 -1
- package/src/__tests__/site-capture-node.test.ts +58 -0
- package/src/__tests__/ugc-lane-wires.test.ts +228 -0
- package/src/__tests__/ugc-node-wires.test.ts +9 -3
- package/src/__tests__/ugc-run-state.test.ts +5 -4
- package/src/__tests__/video-analysis-catalog-sync.test.ts +1 -1
- package/src/__tests__/video-analysis-pricing.test.ts +6 -6
- package/src/__tests__/voice-changer-pro-quote.test.ts +79 -0
- package/src/add-captions-plan.ts +9 -3
- package/src/caption-edge-dash.ts +33 -0
- package/src/component-types.ts +9 -0
- package/src/credit-estimators/index.ts +22 -1
- package/src/credit-estimators/pitch-tempo.ts +15 -1
- package/src/credit-estimators/speech.ts +72 -4
- package/src/credit-estimators/unit-quote.ts +52 -0
- package/src/credit-estimators/video-sfx.ts +15 -0
- package/src/credit-estimators/voice-changer-pro-quote.ts +138 -0
- package/src/credit-identifiers.ts +62 -17
- package/src/entity-image-handle.ts +2 -0
- package/src/entries/apps.ts +63 -0
- package/src/entries/captions.ts +34 -0
- package/src/entries/catalogs.ts +65 -0
- package/src/entries/credits.ts +105 -0
- package/src/entries/edl.ts +42 -0
- package/src/entries/entities.ts +144 -0
- package/src/entries/i18n.ts +31 -0
- package/src/entries/llm-models.ts +63 -0
- package/src/entries/media.ts +36 -0
- package/src/entries/model-catalog.ts +95 -0
- package/src/entries/models.ts +266 -0
- package/src/entries/nodes.ts +245 -0
- package/src/entries/organizations.ts +9 -0
- package/src/entries/pipeline.ts +43 -0
- package/src/entries/scene3d.ts +27 -0
- package/src/entries/social.ts +297 -0
- package/src/entries/types.ts +26 -0
- package/src/entries/ugc.ts +14 -0
- package/src/entries/video.ts +59 -0
- package/src/entries/workflow.ts +172 -0
- package/src/fan-out-rows.ts +2 -0
- package/src/index.ts +25 -1845
- package/src/json-kinds.ts +4 -0
- package/src/model-catalog.ts +243 -34
- package/src/node-mappable-fields.ts +1 -0
- package/src/node-run-routes.ts +2 -0
- package/src/node-runtime-keys.ts +8 -0
- package/src/normalize-node-params.ts +30 -0
- package/src/presentation-utils.ts +12 -0
- package/src/preview-gate.ts +92 -14
- package/src/private-host.ts +89 -59
- package/src/producer-types.ts +16 -2
- package/src/run-continuation.ts +21 -0
- package/src/site-capture-node.ts +82 -0
- package/src/ugc-lane-wires.ts +246 -0
- package/src/ugc-node-wires.ts +37 -7
- package/src/ugc-run-state.ts +5 -3
- package/src/video-analysis-pricing.ts +31 -29
|
@@ -0,0 +1,2171 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// src/scene3d.ts
|
|
4
|
+
var SCENE3D_PLAN_TYPE = "3d-scene";
|
|
5
|
+
var SCENE3D_SCHEMA_VERSION = 1;
|
|
6
|
+
var SCENE3D_DEFAULT_FPS = 24;
|
|
7
|
+
var SCENE3D_DEFAULT_DURATION_SECONDS = 4;
|
|
8
|
+
var SCENE3D_LIMITS = {
|
|
9
|
+
minDimensionPx: 100,
|
|
10
|
+
/** Applies to BOTH axes, so the worst admissible frame is SQUARE, not merely
|
|
11
|
+
* wider — 2560x2560 is 3.2x the pixels of 1920x1080, and that is the frame
|
|
12
|
+
* this bound was measured at. Raised from 1920 once that cost was measured
|
|
13
|
+
* rather than assumed: on the software GL path a container actually uses,
|
|
14
|
+
* an animated 2560x2560 frame costs ~154 ms/frame against ~65 ms at
|
|
15
|
+
* 1920x1080, so even `maxDurationInFrames` (3600) lands near 9 min against
|
|
16
|
+
* the render worker's 25-minute budget. Peak memory is the real price —
|
|
17
|
+
* ~3.1 GB across the browser process tree versus ~1.6 GB — and is the number
|
|
18
|
+
* to re-measure before widening this again. */
|
|
19
|
+
maxDimensionPx: 2560,
|
|
20
|
+
minFps: 15,
|
|
21
|
+
maxFps: 60,
|
|
22
|
+
minDurationInFrames: 1,
|
|
23
|
+
maxDurationInFrames: 3600,
|
|
24
|
+
/** Shortest scene an authoring request may ask for, in seconds. One second
|
|
25
|
+
* is the frozen v1 floor the SDK/MCP surface and the public docs state; the
|
|
26
|
+
* route Zod and the canvas path both quote it from here so they cannot
|
|
27
|
+
* drift below it. */
|
|
28
|
+
minDurationSeconds: 1,
|
|
29
|
+
/** Hard ceiling on wall-clock length, checked against fps × frames. */
|
|
30
|
+
maxDurationSeconds: 60,
|
|
31
|
+
minObjects: 1,
|
|
32
|
+
maxObjects: 100,
|
|
33
|
+
/** Per-object and per-camera track length. */
|
|
34
|
+
maxKeyframes: 240,
|
|
35
|
+
maxReferences: 8,
|
|
36
|
+
maxOperations: 100,
|
|
37
|
+
/** |x|, |y|, |z| ceiling for positions and camera/target coordinates. */
|
|
38
|
+
maxCoordinate: 1e3,
|
|
39
|
+
minSize: 1e-3,
|
|
40
|
+
maxSize: 1e3,
|
|
41
|
+
minScale: 1e-3,
|
|
42
|
+
maxScale: 1e3,
|
|
43
|
+
minFocalLengthMm: 10,
|
|
44
|
+
maxFocalLengthMm: 200,
|
|
45
|
+
defaultSensorWidthMm: 36,
|
|
46
|
+
minSensorWidthMm: 1,
|
|
47
|
+
maxSensorWidthMm: 200,
|
|
48
|
+
maxIntensity: 100,
|
|
49
|
+
/** How deep a parent chain may nest. Bounds the renderer's transform walk. */
|
|
50
|
+
maxHierarchyDepth: 8,
|
|
51
|
+
maxIdLength: 64,
|
|
52
|
+
maxNameLength: 120,
|
|
53
|
+
maxUrlLength: 2048,
|
|
54
|
+
maxChangeSummaryLength: 2e3
|
|
55
|
+
};
|
|
56
|
+
var SCENE3D_PRIMITIVES = [
|
|
57
|
+
"box",
|
|
58
|
+
"sphere",
|
|
59
|
+
"cylinder",
|
|
60
|
+
"cone",
|
|
61
|
+
"plane",
|
|
62
|
+
"capsule",
|
|
63
|
+
"group"
|
|
64
|
+
];
|
|
65
|
+
function boundedVec3(max, label) {
|
|
66
|
+
return z.tuple([
|
|
67
|
+
z.number().min(-max).max(max),
|
|
68
|
+
z.number().min(-max).max(max),
|
|
69
|
+
z.number().min(-max).max(max)
|
|
70
|
+
]).describe(label);
|
|
71
|
+
}
|
|
72
|
+
var vec3Schema = boundedVec3(SCENE3D_LIMITS.maxCoordinate, "position triple (meters)");
|
|
73
|
+
var sizeVec3Schema = z.tuple([
|
|
74
|
+
z.number().min(SCENE3D_LIMITS.minSize).max(SCENE3D_LIMITS.maxSize),
|
|
75
|
+
z.number().min(SCENE3D_LIMITS.minSize).max(SCENE3D_LIMITS.maxSize),
|
|
76
|
+
z.number().min(SCENE3D_LIMITS.minSize).max(SCENE3D_LIMITS.maxSize)
|
|
77
|
+
]);
|
|
78
|
+
var scaleVec3Schema = z.tuple([
|
|
79
|
+
z.number().min(SCENE3D_LIMITS.minScale).max(SCENE3D_LIMITS.maxScale),
|
|
80
|
+
z.number().min(SCENE3D_LIMITS.minScale).max(SCENE3D_LIMITS.maxScale),
|
|
81
|
+
z.number().min(SCENE3D_LIMITS.minScale).max(SCENE3D_LIMITS.maxScale)
|
|
82
|
+
]);
|
|
83
|
+
var rotationVec3Schema = boundedVec3(1e3, "euler XYZ (radians)");
|
|
84
|
+
var HEX_COLOR = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
|
|
85
|
+
var scene3DColorSchema = z.string().regex(HEX_COLOR, "color must be an opaque hex string such as #4f8ef7 (3 or 6 digits; alpha is not supported)");
|
|
86
|
+
var SCENE3D_ID = /^[A-Za-z0-9][A-Za-z0-9_.-]*$/;
|
|
87
|
+
var scene3DIdSchema = z.string().min(1).max(SCENE3D_LIMITS.maxIdLength).regex(SCENE3D_ID, "id must start alphanumeric and contain only letters, digits, '_', '-' or '.'");
|
|
88
|
+
function isScene3DHttpUrl(value) {
|
|
89
|
+
try {
|
|
90
|
+
const parsed = new URL(value);
|
|
91
|
+
return parsed.protocol === "http:" || parsed.protocol === "https:";
|
|
92
|
+
} catch {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
var scene3DUrlSchema = z.string().min(1).max(SCENE3D_LIMITS.maxUrlLength).refine(isScene3DHttpUrl, "url must be an http(s) URL");
|
|
97
|
+
var scene3DEasingSchema = z.enum(["linear", "easeInOut"]);
|
|
98
|
+
var scene3DPrimitiveSchema = z.enum([
|
|
99
|
+
"box",
|
|
100
|
+
"sphere",
|
|
101
|
+
"cylinder",
|
|
102
|
+
"cone",
|
|
103
|
+
"plane",
|
|
104
|
+
"capsule",
|
|
105
|
+
"group"
|
|
106
|
+
]);
|
|
107
|
+
var frameSchema = z.number().int().min(0).max(SCENE3D_LIMITS.maxDurationInFrames);
|
|
108
|
+
var scene3DObjectKeyframeSchema = z.object({
|
|
109
|
+
frame: frameSchema,
|
|
110
|
+
position: vec3Schema.optional(),
|
|
111
|
+
rotation: rotationVec3Schema.optional(),
|
|
112
|
+
scale: scaleVec3Schema.optional(),
|
|
113
|
+
easing: scene3DEasingSchema.optional()
|
|
114
|
+
}).strict();
|
|
115
|
+
var scene3DCameraKeyframeSchema = z.object({
|
|
116
|
+
frame: frameSchema,
|
|
117
|
+
position: vec3Schema.optional(),
|
|
118
|
+
target: vec3Schema.optional(),
|
|
119
|
+
focalLengthMm: z.number().min(SCENE3D_LIMITS.minFocalLengthMm).max(SCENE3D_LIMITS.maxFocalLengthMm).optional(),
|
|
120
|
+
easing: scene3DEasingSchema.optional()
|
|
121
|
+
}).strict();
|
|
122
|
+
var scene3DObjectSchema = z.object({
|
|
123
|
+
id: scene3DIdSchema,
|
|
124
|
+
name: z.string().min(1).max(SCENE3D_LIMITS.maxNameLength),
|
|
125
|
+
primitive: scene3DPrimitiveSchema,
|
|
126
|
+
parentId: scene3DIdSchema.optional(),
|
|
127
|
+
dimensions: sizeVec3Schema,
|
|
128
|
+
position: vec3Schema,
|
|
129
|
+
rotation: rotationVec3Schema,
|
|
130
|
+
scale: scaleVec3Schema,
|
|
131
|
+
color: scene3DColorSchema,
|
|
132
|
+
keyframes: z.array(scene3DObjectKeyframeSchema).max(SCENE3D_LIMITS.maxKeyframes).optional()
|
|
133
|
+
}).strict();
|
|
134
|
+
var scene3DCameraSchema = z.object({
|
|
135
|
+
position: vec3Schema,
|
|
136
|
+
target: vec3Schema,
|
|
137
|
+
focalLengthMm: z.number().min(SCENE3D_LIMITS.minFocalLengthMm).max(SCENE3D_LIMITS.maxFocalLengthMm),
|
|
138
|
+
sensorWidthMm: z.number().min(SCENE3D_LIMITS.minSensorWidthMm).max(SCENE3D_LIMITS.maxSensorWidthMm).default(SCENE3D_LIMITS.defaultSensorWidthMm),
|
|
139
|
+
keyframes: z.array(scene3DCameraKeyframeSchema).max(SCENE3D_LIMITS.maxKeyframes).optional()
|
|
140
|
+
}).strict();
|
|
141
|
+
var scene3DLightingSchema = z.object({
|
|
142
|
+
ambientIntensity: z.number().min(0).max(SCENE3D_LIMITS.maxIntensity),
|
|
143
|
+
keyIntensity: z.number().min(0).max(SCENE3D_LIMITS.maxIntensity),
|
|
144
|
+
keyPosition: vec3Schema
|
|
145
|
+
}).strict();
|
|
146
|
+
var scene3DReferenceSchema = z.object({
|
|
147
|
+
id: scene3DIdSchema,
|
|
148
|
+
url: scene3DUrlSchema,
|
|
149
|
+
kind: z.enum(["image", "video"]),
|
|
150
|
+
role: z.enum(["appearance", "layout", "motion"]),
|
|
151
|
+
objectId: scene3DIdSchema.optional(),
|
|
152
|
+
startSeconds: z.number().min(0).max(86400).optional(),
|
|
153
|
+
endSeconds: z.number().min(0).max(86400).optional()
|
|
154
|
+
}).strict();
|
|
155
|
+
function checkKeyframeTrack(frames, durationInFrames, path, issues) {
|
|
156
|
+
let previous = -1;
|
|
157
|
+
frames.forEach((kf, index) => {
|
|
158
|
+
if (kf.frame > durationInFrames - 1) {
|
|
159
|
+
issues.push({
|
|
160
|
+
path: [...path, index, "frame"],
|
|
161
|
+
message: `frame ${kf.frame} is past the scene's last frame (${durationInFrames - 1})`
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
if (kf.frame === previous) {
|
|
165
|
+
issues.push({ path: [...path, index, "frame"], message: `duplicate keyframe at frame ${kf.frame}` });
|
|
166
|
+
} else if (kf.frame < previous) {
|
|
167
|
+
issues.push({
|
|
168
|
+
path: [...path, index, "frame"],
|
|
169
|
+
message: `keyframes must be sorted by frame (${kf.frame} follows ${previous})`
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
previous = kf.frame;
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function scene3DPlanV1Issues(plan) {
|
|
176
|
+
const issues = [];
|
|
177
|
+
const seconds = plan.durationInFrames / plan.fps;
|
|
178
|
+
if (seconds > SCENE3D_LIMITS.maxDurationSeconds) {
|
|
179
|
+
issues.push({
|
|
180
|
+
path: ["durationInFrames"],
|
|
181
|
+
message: `scene is ${seconds.toFixed(2)}s; the limit is ${SCENE3D_LIMITS.maxDurationSeconds}s`
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
const byId = /* @__PURE__ */ new Map();
|
|
185
|
+
plan.objects.forEach((object, index) => {
|
|
186
|
+
if (byId.has(object.id)) {
|
|
187
|
+
issues.push({ path: ["objects", index, "id"], message: `duplicate object id "${object.id}"` });
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
byId.set(object.id, object);
|
|
191
|
+
});
|
|
192
|
+
plan.objects.forEach((object, index) => {
|
|
193
|
+
if (object.parentId === void 0) return;
|
|
194
|
+
if (object.parentId === object.id) {
|
|
195
|
+
issues.push({ path: ["objects", index, "parentId"], message: `object "${object.id}" cannot parent itself` });
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
if (!byId.has(object.parentId)) {
|
|
199
|
+
issues.push({
|
|
200
|
+
path: ["objects", index, "parentId"],
|
|
201
|
+
message: `object "${object.id}" references unknown parent "${object.parentId}"`
|
|
202
|
+
});
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const seen = /* @__PURE__ */ new Set([object.id]);
|
|
206
|
+
let cursor = byId.get(object.parentId);
|
|
207
|
+
let depth = 1;
|
|
208
|
+
while (cursor) {
|
|
209
|
+
if (seen.has(cursor.id)) {
|
|
210
|
+
issues.push({
|
|
211
|
+
path: ["objects", index, "parentId"],
|
|
212
|
+
message: `parent cycle through object "${cursor.id}"`
|
|
213
|
+
});
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
seen.add(cursor.id);
|
|
217
|
+
depth += 1;
|
|
218
|
+
if (depth > SCENE3D_LIMITS.maxHierarchyDepth) {
|
|
219
|
+
issues.push({
|
|
220
|
+
path: ["objects", index, "parentId"],
|
|
221
|
+
message: `hierarchy deeper than ${SCENE3D_LIMITS.maxHierarchyDepth} levels`
|
|
222
|
+
});
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
cursor = cursor.parentId === void 0 ? void 0 : byId.get(cursor.parentId);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
plan.objects.forEach((object, index) => {
|
|
229
|
+
if (object.keyframes && object.keyframes.length > 0) {
|
|
230
|
+
checkKeyframeTrack(object.keyframes, plan.durationInFrames, ["objects", index, "keyframes"], issues);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
if (plan.camera.keyframes && plan.camera.keyframes.length > 0) {
|
|
234
|
+
checkKeyframeTrack(plan.camera.keyframes, plan.durationInFrames, ["camera", "keyframes"], issues);
|
|
235
|
+
}
|
|
236
|
+
const referenceIds = /* @__PURE__ */ new Set();
|
|
237
|
+
(plan.references ?? []).forEach((reference, index) => {
|
|
238
|
+
if (referenceIds.has(reference.id)) {
|
|
239
|
+
issues.push({ path: ["references", index, "id"], message: `duplicate reference id "${reference.id}"` });
|
|
240
|
+
}
|
|
241
|
+
referenceIds.add(reference.id);
|
|
242
|
+
if (reference.objectId !== void 0 && !byId.has(reference.objectId)) {
|
|
243
|
+
issues.push({
|
|
244
|
+
path: ["references", index, "objectId"],
|
|
245
|
+
message: `reference "${reference.id}" points at unknown object "${reference.objectId}"`
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
if (reference.startSeconds !== void 0 && reference.endSeconds !== void 0 && reference.endSeconds <= reference.startSeconds) {
|
|
249
|
+
issues.push({
|
|
250
|
+
path: ["references", index, "endSeconds"],
|
|
251
|
+
message: `reference "${reference.id}" ends at or before it starts`
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
if (reference.kind === "image" && (reference.startSeconds !== void 0 || reference.endSeconds !== void 0)) {
|
|
255
|
+
issues.push({
|
|
256
|
+
path: ["references", index, "startSeconds"],
|
|
257
|
+
message: `reference "${reference.id}" is an image; a time window applies to video only`
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
return issues;
|
|
262
|
+
}
|
|
263
|
+
var scene3DPlanV1ObjectSchema = z.object({
|
|
264
|
+
planType: z.literal(SCENE3D_PLAN_TYPE),
|
|
265
|
+
schemaVersion: z.literal(SCENE3D_SCHEMA_VERSION),
|
|
266
|
+
revisionId: z.uuid(),
|
|
267
|
+
parentRevisionId: z.uuid().optional(),
|
|
268
|
+
width: z.number().int().min(SCENE3D_LIMITS.minDimensionPx).max(SCENE3D_LIMITS.maxDimensionPx),
|
|
269
|
+
height: z.number().int().min(SCENE3D_LIMITS.minDimensionPx).max(SCENE3D_LIMITS.maxDimensionPx),
|
|
270
|
+
fps: z.number().int().min(SCENE3D_LIMITS.minFps).max(SCENE3D_LIMITS.maxFps),
|
|
271
|
+
durationInFrames: z.number().int().min(SCENE3D_LIMITS.minDurationInFrames).max(SCENE3D_LIMITS.maxDurationInFrames),
|
|
272
|
+
backgroundColor: scene3DColorSchema,
|
|
273
|
+
camera: scene3DCameraSchema,
|
|
274
|
+
objects: z.array(scene3DObjectSchema).min(SCENE3D_LIMITS.minObjects).max(SCENE3D_LIMITS.maxObjects),
|
|
275
|
+
lighting: scene3DLightingSchema,
|
|
276
|
+
references: z.array(scene3DReferenceSchema).max(SCENE3D_LIMITS.maxReferences).optional()
|
|
277
|
+
}).strict();
|
|
278
|
+
var scene3DPlanV1Schema = scene3DPlanV1ObjectSchema.superRefine((plan, ctx) => {
|
|
279
|
+
for (const issue of scene3DPlanV1Issues(plan)) {
|
|
280
|
+
ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
var scene3DPlanSchema = scene3DPlanV1Schema;
|
|
284
|
+
var scene3DPlanIssues = scene3DPlanV1Issues;
|
|
285
|
+
function scene3DDeepEqual(a, b) {
|
|
286
|
+
if (a === b) return true;
|
|
287
|
+
if (typeof a !== typeof b) return false;
|
|
288
|
+
if (a === null || b === null || typeof a !== "object") return false;
|
|
289
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
290
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
291
|
+
if (a.length !== b.length) return false;
|
|
292
|
+
return a.every((item, i) => scene3DDeepEqual(item, b[i]));
|
|
293
|
+
}
|
|
294
|
+
const aObj = a;
|
|
295
|
+
const bObj = b;
|
|
296
|
+
const aKeys = Object.keys(aObj);
|
|
297
|
+
const bKeys = Object.keys(bObj);
|
|
298
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
299
|
+
return aKeys.every((key) => key in bObj && scene3DDeepEqual(aObj[key], bObj[key]));
|
|
300
|
+
}
|
|
301
|
+
function newScene3DRevisionId() {
|
|
302
|
+
const webCrypto = globalThis.crypto;
|
|
303
|
+
if (webCrypto && typeof webCrypto.randomUUID === "function") return webCrypto.randomUUID();
|
|
304
|
+
const bytes = new Uint8Array(16);
|
|
305
|
+
if (webCrypto && typeof webCrypto.getRandomValues === "function") {
|
|
306
|
+
webCrypto.getRandomValues(bytes);
|
|
307
|
+
} else {
|
|
308
|
+
for (let i = 0; i < bytes.length; i++) bytes[i] = Math.floor(Math.random() * 256);
|
|
309
|
+
}
|
|
310
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
311
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
312
|
+
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
313
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
314
|
+
}
|
|
315
|
+
function isScene3DPlanV1(value) {
|
|
316
|
+
return scene3DPlanV1Schema.safeParse(value).success;
|
|
317
|
+
}
|
|
318
|
+
var SCENE3D_PLAN_FIELD = "scenePlan";
|
|
319
|
+
var SCENE3D_GENERATE_NODE_TYPE = "generate-3d-scene";
|
|
320
|
+
var SCENE3D_EDIT_NODE_TYPE = "edit-3d-scene";
|
|
321
|
+
var scene3DObjectChangesSchema = z.object({
|
|
322
|
+
name: z.string().min(1).max(SCENE3D_LIMITS.maxNameLength).optional(),
|
|
323
|
+
primitive: scene3DPrimitiveSchema.optional(),
|
|
324
|
+
/** `null` detaches from the parent; omitted leaves it as-is. */
|
|
325
|
+
parentId: scene3DIdSchema.nullable().optional(),
|
|
326
|
+
dimensions: sizeVec3Schema.optional(),
|
|
327
|
+
position: vec3Schema.optional(),
|
|
328
|
+
rotation: rotationVec3Schema.optional(),
|
|
329
|
+
scale: scaleVec3Schema.optional(),
|
|
330
|
+
color: scene3DColorSchema.optional(),
|
|
331
|
+
keyframes: z.array(scene3DObjectKeyframeSchema).max(SCENE3D_LIMITS.maxKeyframes).optional()
|
|
332
|
+
}).strict();
|
|
333
|
+
var scene3DCameraChangesSchema = z.object({
|
|
334
|
+
position: vec3Schema.optional(),
|
|
335
|
+
target: vec3Schema.optional(),
|
|
336
|
+
focalLengthMm: z.number().min(SCENE3D_LIMITS.minFocalLengthMm).max(SCENE3D_LIMITS.maxFocalLengthMm).optional(),
|
|
337
|
+
sensorWidthMm: z.number().min(SCENE3D_LIMITS.minSensorWidthMm).max(SCENE3D_LIMITS.maxSensorWidthMm).optional(),
|
|
338
|
+
keyframes: z.array(scene3DCameraKeyframeSchema).max(SCENE3D_LIMITS.maxKeyframes).optional()
|
|
339
|
+
}).strict();
|
|
340
|
+
var scene3DLightingChangesSchema = z.object({
|
|
341
|
+
ambientIntensity: z.number().min(0).max(SCENE3D_LIMITS.maxIntensity).optional(),
|
|
342
|
+
keyIntensity: z.number().min(0).max(SCENE3D_LIMITS.maxIntensity).optional(),
|
|
343
|
+
keyPosition: vec3Schema.optional()
|
|
344
|
+
}).strict();
|
|
345
|
+
var scene3DEditOperationSchema = z.discriminatedUnion("op", [
|
|
346
|
+
z.object({ op: z.literal("set-object"), objectId: scene3DIdSchema, changes: scene3DObjectChangesSchema }).strict(),
|
|
347
|
+
z.object({ op: z.literal("add-object"), object: scene3DObjectSchema }).strict(),
|
|
348
|
+
z.object({ op: z.literal("remove-object"), objectId: scene3DIdSchema }).strict(),
|
|
349
|
+
z.object({ op: z.literal("set-camera"), changes: scene3DCameraChangesSchema }).strict(),
|
|
350
|
+
z.object({ op: z.literal("set-lighting"), changes: scene3DLightingChangesSchema }).strict(),
|
|
351
|
+
z.object({ op: z.literal("set-background"), color: scene3DColorSchema }).strict()
|
|
352
|
+
]);
|
|
353
|
+
var scene3DEditOperationsSchema = z.array(scene3DEditOperationSchema).min(1).max(SCENE3D_LIMITS.maxOperations);
|
|
354
|
+
function clonePlan(plan) {
|
|
355
|
+
return JSON.parse(JSON.stringify(plan));
|
|
356
|
+
}
|
|
357
|
+
function summarizeScene3DOperations(operations) {
|
|
358
|
+
const lines = operations.map((operation) => {
|
|
359
|
+
switch (operation.op) {
|
|
360
|
+
case "set-object": {
|
|
361
|
+
const fields = Object.keys(operation.changes);
|
|
362
|
+
return `Updated ${fields.length > 0 ? fields.join(", ") : "nothing"} on "${operation.objectId}"`;
|
|
363
|
+
}
|
|
364
|
+
case "add-object":
|
|
365
|
+
return `Added ${operation.object.primitive} "${operation.object.name}" (${operation.object.id})`;
|
|
366
|
+
case "remove-object":
|
|
367
|
+
return `Removed "${operation.objectId}"`;
|
|
368
|
+
case "set-camera":
|
|
369
|
+
return `Updated camera ${Object.keys(operation.changes).join(", ") || "nothing"}`;
|
|
370
|
+
case "set-lighting":
|
|
371
|
+
return `Updated lighting ${Object.keys(operation.changes).join(", ") || "nothing"}`;
|
|
372
|
+
case "set-background":
|
|
373
|
+
return `Set background to ${operation.color}`;
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
return lines.join("; ").slice(0, SCENE3D_LIMITS.maxChangeSummaryLength);
|
|
377
|
+
}
|
|
378
|
+
function firstIssueMessage(error) {
|
|
379
|
+
const issue = error.issues[0];
|
|
380
|
+
if (!issue) return "invalid";
|
|
381
|
+
const path = issue.path.join(".");
|
|
382
|
+
return path ? `${path}: ${issue.message}` : issue.message;
|
|
383
|
+
}
|
|
384
|
+
function applyScene3DEditOperations(plan, operations, options = {}) {
|
|
385
|
+
const parsedPlan = scene3DPlanV1Schema.safeParse(plan);
|
|
386
|
+
if (!parsedPlan.success) {
|
|
387
|
+
return { ok: false, code: "invalid_plan", message: `scenePlan is invalid \u2014 ${firstIssueMessage(parsedPlan.error)}` };
|
|
388
|
+
}
|
|
389
|
+
const source = parsedPlan.data;
|
|
390
|
+
if (options.expectedRevisionId !== void 0 && options.expectedRevisionId !== source.revisionId) {
|
|
391
|
+
return {
|
|
392
|
+
ok: false,
|
|
393
|
+
code: "stale_revision",
|
|
394
|
+
message: `This scene has moved on \u2014 expected revision ${options.expectedRevisionId}, the plan is at ${source.revisionId}.`
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
const parsedOps = scene3DEditOperationsSchema.safeParse(operations);
|
|
398
|
+
if (!parsedOps.success) {
|
|
399
|
+
const issue = parsedOps.error.issues[0];
|
|
400
|
+
const index = typeof issue?.path[0] === "number" ? issue.path[0] : void 0;
|
|
401
|
+
return {
|
|
402
|
+
ok: false,
|
|
403
|
+
code: "invalid_operations",
|
|
404
|
+
message: `operations are invalid \u2014 ${firstIssueMessage(parsedOps.error)}`,
|
|
405
|
+
...index === void 0 ? {} : { operationIndex: index }
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
const ops = parsedOps.data;
|
|
409
|
+
const next = clonePlan(source);
|
|
410
|
+
const changed = /* @__PURE__ */ new Set();
|
|
411
|
+
for (let index = 0; index < ops.length; index++) {
|
|
412
|
+
const operation = ops[index];
|
|
413
|
+
switch (operation.op) {
|
|
414
|
+
case "set-object": {
|
|
415
|
+
const target = next.objects.findIndex((o) => o.id === operation.objectId);
|
|
416
|
+
if (target === -1) {
|
|
417
|
+
return {
|
|
418
|
+
ok: false,
|
|
419
|
+
code: "unknown_object",
|
|
420
|
+
message: `no object "${operation.objectId}" in this scene`,
|
|
421
|
+
operationIndex: index
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
const { parentId, ...rest } = operation.changes;
|
|
425
|
+
const updated = { ...next.objects[target], ...rest };
|
|
426
|
+
if (parentId !== void 0) {
|
|
427
|
+
if (parentId === null) delete updated.parentId;
|
|
428
|
+
else updated.parentId = parentId;
|
|
429
|
+
}
|
|
430
|
+
next.objects = next.objects.map((o, i) => i === target ? updated : o);
|
|
431
|
+
changed.add(operation.objectId);
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
case "add-object": {
|
|
435
|
+
if (next.objects.some((o) => o.id === operation.object.id)) {
|
|
436
|
+
return {
|
|
437
|
+
ok: false,
|
|
438
|
+
code: "duplicate_object",
|
|
439
|
+
message: `an object with id "${operation.object.id}" already exists`,
|
|
440
|
+
operationIndex: index
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
next.objects = [...next.objects, operation.object];
|
|
444
|
+
changed.add(operation.object.id);
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
case "remove-object": {
|
|
448
|
+
if (!next.objects.some((o) => o.id === operation.objectId)) {
|
|
449
|
+
return {
|
|
450
|
+
ok: false,
|
|
451
|
+
code: "unknown_object",
|
|
452
|
+
message: `no object "${operation.objectId}" in this scene`,
|
|
453
|
+
operationIndex: index
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
next.objects = next.objects.filter((o) => o.id !== operation.objectId);
|
|
457
|
+
changed.add(operation.objectId);
|
|
458
|
+
break;
|
|
459
|
+
}
|
|
460
|
+
case "set-camera":
|
|
461
|
+
next.camera = { ...next.camera, ...operation.changes };
|
|
462
|
+
break;
|
|
463
|
+
case "set-lighting":
|
|
464
|
+
next.lighting = { ...next.lighting, ...operation.changes };
|
|
465
|
+
break;
|
|
466
|
+
case "set-background":
|
|
467
|
+
next.backgroundColor = operation.color;
|
|
468
|
+
break;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
for (const lockedId of options.lockedObjectIds ?? []) {
|
|
472
|
+
const before = source.objects.find((o) => o.id === lockedId);
|
|
473
|
+
const after = next.objects.find((o) => o.id === lockedId);
|
|
474
|
+
if (before === void 0) continue;
|
|
475
|
+
if (after === void 0) {
|
|
476
|
+
return { ok: false, code: "locked_object", message: `object "${lockedId}" is locked and cannot be removed` };
|
|
477
|
+
}
|
|
478
|
+
if (!scene3DDeepEqual(before, after)) {
|
|
479
|
+
return { ok: false, code: "locked_object", message: `object "${lockedId}" is locked and cannot be modified` };
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
next.parentRevisionId = source.revisionId;
|
|
483
|
+
next.revisionId = options.revisionId ?? newScene3DRevisionId();
|
|
484
|
+
const validated = scene3DPlanV1Schema.safeParse(next);
|
|
485
|
+
if (!validated.success) {
|
|
486
|
+
return {
|
|
487
|
+
ok: false,
|
|
488
|
+
code: "invalid_plan",
|
|
489
|
+
message: `the edit would leave the scene invalid \u2014 ${firstIssueMessage(validated.error)}`
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
return {
|
|
493
|
+
ok: true,
|
|
494
|
+
plan: validated.data,
|
|
495
|
+
changedObjectIds: [...changed],
|
|
496
|
+
changeSummary: summarizeScene3DOperations(ops)
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
var SCENE3D_SCHEMA_VERSION_V2 = 2;
|
|
500
|
+
var SCENE3D_SUPPORTED_SCHEMA_VERSIONS = [1, 2];
|
|
501
|
+
var SCENE3D_V2_ENGINES = ["blender-cloud", "blender-local"];
|
|
502
|
+
var SCENE3D_V2_LIMITS = {
|
|
503
|
+
/** Both the seconds and the frame ceiling apply; neither waives the other. */
|
|
504
|
+
maxDurationSeconds: 60,
|
|
505
|
+
minDurationInFrames: 1,
|
|
506
|
+
maxDurationInFrames: 3600,
|
|
507
|
+
minFps: 15,
|
|
508
|
+
maxFps: 60,
|
|
509
|
+
defaultFps: 24,
|
|
510
|
+
/** Even integers only — an odd axis breaks H.264 chroma subsampling. */
|
|
511
|
+
minDimensionPx: 100,
|
|
512
|
+
/** Deliberately kept equal to v1's `SCENE3D_LIMITS.maxDimensionPx`: one
|
|
513
|
+
* renderer draws both versions, so one measured ceiling bounds both. */
|
|
514
|
+
maxDimensionPx: SCENE3D_LIMITS.maxDimensionPx,
|
|
515
|
+
minEntities: 1,
|
|
516
|
+
/** SEMANTIC entities, not exported mesh nodes. */
|
|
517
|
+
maxEntities: 100,
|
|
518
|
+
/** Enforced during asset normalization, after decode — see
|
|
519
|
+
* `scene3DV2NormalizationIssues` in `scene3d-v2-resources.ts`. */
|
|
520
|
+
maxMeshNodes: 2e3,
|
|
521
|
+
maxTriangles: 2e5,
|
|
522
|
+
maxHierarchyDepth: 16,
|
|
523
|
+
/** Decoded manifest JSON. Measured on the bytes, before `JSON.parse`. */
|
|
524
|
+
maxManifestBytes: 512 * 1024,
|
|
525
|
+
/** Decoded camera-track JSON. */
|
|
526
|
+
maxCameraTrackBytes: 8 * 1024 * 1024,
|
|
527
|
+
/** Total DECLARED bytes of the assets the renderer downloads. Compression
|
|
528
|
+
* does not waive the decoded geometry limits above. */
|
|
529
|
+
maxRendererAssetBytes: 64 * 1024 * 1024,
|
|
530
|
+
/** A `blend-source` is a separately authorized download, never handed to the
|
|
531
|
+
* browser renderer, and therefore not part of the renderer budget. */
|
|
532
|
+
maxBlendSourceBytes: 512 * 1024 * 1024,
|
|
533
|
+
maxAssets: 64,
|
|
534
|
+
maxShots: 32,
|
|
535
|
+
maxShotEntityIds: 16,
|
|
536
|
+
/** v1's reference limit, unchanged until deliberately expanded. */
|
|
537
|
+
maxReferences: SCENE3D_LIMITS.maxReferences,
|
|
538
|
+
maxAnchorsPerEntity: 32,
|
|
539
|
+
maxMaterialBindingsPerEntity: 16,
|
|
540
|
+
maxOverrides: 200,
|
|
541
|
+
minPosterDimensionPx: 16,
|
|
542
|
+
maxPosterDimensionPx: 4096,
|
|
543
|
+
maxIdLength: SCENE3D_LIMITS.maxIdLength,
|
|
544
|
+
maxAssetIdLength: 128,
|
|
545
|
+
maxNodeIdLength: 128,
|
|
546
|
+
maxNodeNameLength: 256,
|
|
547
|
+
maxNameLength: SCENE3D_LIMITS.maxNameLength,
|
|
548
|
+
maxLabelLength: SCENE3D_LIMITS.maxNameLength,
|
|
549
|
+
maxMaterialNameLength: 120,
|
|
550
|
+
maxVersionLength: 64,
|
|
551
|
+
maxCoordinate: SCENE3D_LIMITS.maxCoordinate,
|
|
552
|
+
minSize: SCENE3D_LIMITS.minSize,
|
|
553
|
+
maxSize: SCENE3D_LIMITS.maxSize,
|
|
554
|
+
maxIntensity: SCENE3D_LIMITS.maxIntensity
|
|
555
|
+
};
|
|
556
|
+
var SCENE3D_V2_OVERRIDE_OPERATION_VERSION = 1;
|
|
557
|
+
var SCENE3D_GLB_EXTRAS_ENTITY_ID = "nodaroEntityId";
|
|
558
|
+
var SCENE3D_GLB_EXTRAS_SUBPART_ID = "nodaroSubpartId";
|
|
559
|
+
var SCENE3D_GLB_EXTRAS_MATERIAL_ROLE = "nodaroMaterialRole";
|
|
560
|
+
var SCENE3D_GLB_EXTRAS_ALLOWLIST = [
|
|
561
|
+
SCENE3D_GLB_EXTRAS_ENTITY_ID,
|
|
562
|
+
SCENE3D_GLB_EXTRAS_SUBPART_ID,
|
|
563
|
+
SCENE3D_GLB_EXTRAS_MATERIAL_ROLE
|
|
564
|
+
];
|
|
565
|
+
var SCENE3D_ENTITY_ROLES = [
|
|
566
|
+
"person",
|
|
567
|
+
"vehicle",
|
|
568
|
+
"prop",
|
|
569
|
+
"environment",
|
|
570
|
+
"other"
|
|
571
|
+
];
|
|
572
|
+
var SCENE3D_V2_PRIMITIVES = [
|
|
573
|
+
"box",
|
|
574
|
+
"sphere",
|
|
575
|
+
"cylinder",
|
|
576
|
+
"cone",
|
|
577
|
+
"plane",
|
|
578
|
+
"capsule"
|
|
579
|
+
];
|
|
580
|
+
var SCENE3D_ENTITY_CAPABILITIES = [
|
|
581
|
+
"transform",
|
|
582
|
+
"color",
|
|
583
|
+
"visibility"
|
|
584
|
+
];
|
|
585
|
+
var SCENE3D_DEFAULT_ENTITY_CAPABILITIES = SCENE3D_ENTITY_CAPABILITIES;
|
|
586
|
+
var SCENE3D_ASSET_KINDS = [
|
|
587
|
+
"glb",
|
|
588
|
+
"camera-track-json",
|
|
589
|
+
"poster",
|
|
590
|
+
"validation-report",
|
|
591
|
+
"blend-source"
|
|
592
|
+
];
|
|
593
|
+
var SCENE3D_ASSET_ROLES = [
|
|
594
|
+
"scene-geometry",
|
|
595
|
+
"entity-geometry",
|
|
596
|
+
"camera-track",
|
|
597
|
+
"poster",
|
|
598
|
+
"validation-report",
|
|
599
|
+
"source"
|
|
600
|
+
];
|
|
601
|
+
var SCENE3D_ASSET_ROLE_KINDS = {
|
|
602
|
+
"scene-geometry": "glb",
|
|
603
|
+
"entity-geometry": "glb",
|
|
604
|
+
"camera-track": "camera-track-json",
|
|
605
|
+
poster: "poster",
|
|
606
|
+
"validation-report": "validation-report",
|
|
607
|
+
source: "blend-source"
|
|
608
|
+
};
|
|
609
|
+
var SCENE3D_RENDERER_ASSET_KINDS = [
|
|
610
|
+
"glb",
|
|
611
|
+
"camera-track-json",
|
|
612
|
+
"poster"
|
|
613
|
+
];
|
|
614
|
+
var SCENE3D_PRIMITIVE_MATERIAL_ROLE = "identity";
|
|
615
|
+
var SCENE3D_CLAY_LIGHTING_PRESETS = ["clay-studio-v1", "clay-studio-v2"];
|
|
616
|
+
var scene3DAssetIdSchema = z.string().min(1).max(SCENE3D_V2_LIMITS.maxAssetIdLength).regex(/^[A-Za-z0-9][A-Za-z0-9_.:-]*$/, "assetId must be an opaque id (letters, digits, '_', '-', '.', ':')").refine((value) => !value.includes(".."), "assetId must not contain '..'");
|
|
617
|
+
var scene3DNodeIdSchema = z.string().min(1).max(SCENE3D_V2_LIMITS.maxNodeIdLength).regex(/^[A-Za-z0-9][A-Za-z0-9_.:-]*$/, "node id must be an exporter-generated stable id");
|
|
618
|
+
var scene3DNodeNameSchema = z.string().min(1).max(SCENE3D_V2_LIMITS.maxNodeNameLength).regex(/^[^\u0000-\u001f\u007f]+$/, "node name must not contain control characters");
|
|
619
|
+
var scene3DSha256Schema = z.string().regex(/^[0-9a-f]{64}$/, "sha256 must be 64 lowercase hex characters");
|
|
620
|
+
var scene3DVersionTokenSchema = z.string().min(1).max(SCENE3D_V2_LIMITS.maxVersionLength).regex(
|
|
621
|
+
/^[A-Za-z0-9][A-Za-z0-9_.+-]*$/,
|
|
622
|
+
"version must be a bounded token (letters, digits, '_', '-', '.', '+') \u2014 never a path or prose"
|
|
623
|
+
);
|
|
624
|
+
var scene3DEngineIdSchema = z.string().min(1).max(SCENE3D_V2_LIMITS.maxVersionLength).regex(/^[a-z0-9][a-z0-9-]*$/, "engine must be a lowercase slug such as blender-cloud");
|
|
625
|
+
var scene3DAnchorNameSchema = scene3DIdSchema;
|
|
626
|
+
var scene3DMaterialRoleSchema = scene3DIdSchema;
|
|
627
|
+
var scene3DMaterialNameSchema = z.string().min(1).max(SCENE3D_V2_LIMITS.maxMaterialNameLength).regex(/^[^\u0000-\u001f\u007f]+$/, "material name must not contain control characters");
|
|
628
|
+
var v2FrameSchema = z.number().int().min(0).max(SCENE3D_V2_LIMITS.maxDurationInFrames);
|
|
629
|
+
var scene3DEntityCapabilitySchema = z.enum(["transform", "color", "visibility"]);
|
|
630
|
+
var scene3DAnchorSchema = z.object({
|
|
631
|
+
name: scene3DAnchorNameSchema,
|
|
632
|
+
position: vec3Schema,
|
|
633
|
+
nodeName: scene3DNodeNameSchema.optional(),
|
|
634
|
+
rotation: rotationVec3Schema.optional()
|
|
635
|
+
}).strict();
|
|
636
|
+
var scene3DMaterialBindingSchema = z.object({
|
|
637
|
+
role: scene3DMaterialRoleSchema,
|
|
638
|
+
materialName: scene3DMaterialNameSchema,
|
|
639
|
+
color: scene3DColorSchema.optional(),
|
|
640
|
+
roughness: z.number().min(0).max(1).optional()
|
|
641
|
+
}).strict();
|
|
642
|
+
var scene3DAssetAnimationSchema = z.object({
|
|
643
|
+
clipName: z.string().min(1).max(SCENE3D_V2_LIMITS.maxNameLength),
|
|
644
|
+
startFrame: v2FrameSchema,
|
|
645
|
+
endFrameExclusive: z.number().int().min(1).max(SCENE3D_V2_LIMITS.maxDurationInFrames),
|
|
646
|
+
loop: z.boolean().optional()
|
|
647
|
+
}).strict();
|
|
648
|
+
var scene3DEntityVisualSchema = z.discriminatedUnion("kind", [
|
|
649
|
+
z.object({ kind: z.literal("group") }).strict(),
|
|
650
|
+
z.object({
|
|
651
|
+
kind: z.literal("primitive"),
|
|
652
|
+
primitive: z.enum(["box", "sphere", "cylinder", "cone", "plane", "capsule"]),
|
|
653
|
+
dimensions: sizeVec3Schema,
|
|
654
|
+
color: scene3DColorSchema
|
|
655
|
+
}).strict(),
|
|
656
|
+
z.object({
|
|
657
|
+
kind: z.literal("asset"),
|
|
658
|
+
assetId: scene3DAssetIdSchema,
|
|
659
|
+
rootNodeId: scene3DNodeIdSchema,
|
|
660
|
+
animation: scene3DAssetAnimationSchema.optional()
|
|
661
|
+
}).strict()
|
|
662
|
+
]);
|
|
663
|
+
var scene3DEntityV2Schema = z.object({
|
|
664
|
+
id: scene3DIdSchema,
|
|
665
|
+
name: z.string().min(1).max(SCENE3D_V2_LIMITS.maxNameLength),
|
|
666
|
+
parentId: scene3DIdSchema.optional(),
|
|
667
|
+
role: z.enum(["person", "vehicle", "prop", "environment", "other"]).optional(),
|
|
668
|
+
position: vec3Schema.optional(),
|
|
669
|
+
rotation: rotationVec3Schema.optional(),
|
|
670
|
+
scale: scaleVec3Schema.optional(),
|
|
671
|
+
visible: z.boolean().optional(),
|
|
672
|
+
identityColor: scene3DColorSchema.optional(),
|
|
673
|
+
anchors: z.array(scene3DAnchorSchema).max(SCENE3D_V2_LIMITS.maxAnchorsPerEntity).optional(),
|
|
674
|
+
capabilities: z.array(scene3DEntityCapabilitySchema).max(SCENE3D_ENTITY_CAPABILITIES.length).optional(),
|
|
675
|
+
locks: z.array(scene3DEntityCapabilitySchema).max(SCENE3D_ENTITY_CAPABILITIES.length).optional(),
|
|
676
|
+
materialBindings: z.array(scene3DMaterialBindingSchema).max(SCENE3D_V2_LIMITS.maxMaterialBindingsPerEntity).optional(),
|
|
677
|
+
visual: scene3DEntityVisualSchema
|
|
678
|
+
}).strict();
|
|
679
|
+
var scene3DAssetRefSchema = z.object({
|
|
680
|
+
assetId: scene3DAssetIdSchema,
|
|
681
|
+
kind: z.enum(["glb", "camera-track-json", "poster", "validation-report", "blend-source"]),
|
|
682
|
+
role: z.enum(["scene-geometry", "entity-geometry", "camera-track", "poster", "validation-report", "source"]),
|
|
683
|
+
byteLength: z.number().int().min(1).max(SCENE3D_V2_LIMITS.maxBlendSourceBytes),
|
|
684
|
+
sha256: scene3DSha256Schema,
|
|
685
|
+
originRevisionId: z.uuid().optional()
|
|
686
|
+
}).strict();
|
|
687
|
+
var scene3DShotSchema = z.object({
|
|
688
|
+
id: scene3DIdSchema,
|
|
689
|
+
startFrame: v2FrameSchema,
|
|
690
|
+
endFrameExclusive: z.number().int().min(1).max(SCENE3D_V2_LIMITS.maxDurationInFrames),
|
|
691
|
+
label: z.string().min(1).max(SCENE3D_V2_LIMITS.maxLabelLength).optional(),
|
|
692
|
+
subjectEntityIds: z.array(scene3DIdSchema).max(SCENE3D_V2_LIMITS.maxShotEntityIds).optional(),
|
|
693
|
+
foregroundEntityIds: z.array(scene3DIdSchema).max(SCENE3D_V2_LIMITS.maxShotEntityIds).optional()
|
|
694
|
+
}).strict();
|
|
695
|
+
var scene3DClayLightingSchema = z.object({
|
|
696
|
+
preset: z.enum(SCENE3D_CLAY_LIGHTING_PRESETS),
|
|
697
|
+
ambientIntensity: z.number().min(0).max(SCENE3D_V2_LIMITS.maxIntensity),
|
|
698
|
+
keyIntensity: z.number().min(0).max(SCENE3D_V2_LIMITS.maxIntensity),
|
|
699
|
+
keyPosition: vec3Schema
|
|
700
|
+
}).strict();
|
|
701
|
+
var overrideProvenanceShape = {
|
|
702
|
+
id: scene3DIdSchema,
|
|
703
|
+
sourceRevisionId: z.uuid(),
|
|
704
|
+
sourceContentHash: scene3DSha256Schema,
|
|
705
|
+
operationVersion: z.number().int().min(1).max(255)
|
|
706
|
+
};
|
|
707
|
+
var scene3DOverrideSchema = z.discriminatedUnion("kind", [
|
|
708
|
+
z.object({
|
|
709
|
+
...overrideProvenanceShape,
|
|
710
|
+
kind: z.literal("entity-transform"),
|
|
711
|
+
entityId: scene3DIdSchema,
|
|
712
|
+
space: z.enum(["local", "world"]),
|
|
713
|
+
position: vec3Schema.optional(),
|
|
714
|
+
rotation: rotationVec3Schema.optional(),
|
|
715
|
+
scale: scaleVec3Schema.optional()
|
|
716
|
+
}).strict(),
|
|
717
|
+
z.object({
|
|
718
|
+
...overrideProvenanceShape,
|
|
719
|
+
kind: z.literal("entity-color"),
|
|
720
|
+
entityId: scene3DIdSchema,
|
|
721
|
+
materialRole: scene3DMaterialRoleSchema,
|
|
722
|
+
color: scene3DColorSchema
|
|
723
|
+
}).strict(),
|
|
724
|
+
z.object({
|
|
725
|
+
...overrideProvenanceShape,
|
|
726
|
+
kind: z.literal("entity-visibility"),
|
|
727
|
+
entityId: scene3DIdSchema,
|
|
728
|
+
visible: z.boolean()
|
|
729
|
+
}).strict(),
|
|
730
|
+
z.object({
|
|
731
|
+
...overrideProvenanceShape,
|
|
732
|
+
kind: z.literal("camera-shot-offset"),
|
|
733
|
+
shotId: scene3DIdSchema,
|
|
734
|
+
positionOffset: vec3Schema.optional(),
|
|
735
|
+
targetOffset: vec3Schema.optional()
|
|
736
|
+
}).strict()
|
|
737
|
+
]);
|
|
738
|
+
var scene3DProvenanceSchema = z.object({
|
|
739
|
+
engine: scene3DEngineIdSchema,
|
|
740
|
+
engineVersion: scene3DVersionTokenSchema,
|
|
741
|
+
recipeVersion: scene3DVersionTokenSchema,
|
|
742
|
+
compilerVersion: scene3DVersionTokenSchema,
|
|
743
|
+
exporterVersion: scene3DVersionTokenSchema,
|
|
744
|
+
rendererVersion: scene3DVersionTokenSchema,
|
|
745
|
+
sourceRevisionId: z.uuid().optional(),
|
|
746
|
+
sourceArtifactId: scene3DAssetIdSchema.optional(),
|
|
747
|
+
contentHash: scene3DSha256Schema
|
|
748
|
+
}).strict();
|
|
749
|
+
function scene3DJsonByteLength(text) {
|
|
750
|
+
return new TextEncoder().encode(text).length;
|
|
751
|
+
}
|
|
752
|
+
function scene3DZodIssues(error) {
|
|
753
|
+
return error.issues.map((issue) => ({ path: [...issue.path], message: issue.message }));
|
|
754
|
+
}
|
|
755
|
+
function entityCapabilities(entity) {
|
|
756
|
+
return entity.capabilities ?? SCENE3D_DEFAULT_ENTITY_CAPABILITIES;
|
|
757
|
+
}
|
|
758
|
+
function scene3DEntityAcceptsOverlay(entity, capability2) {
|
|
759
|
+
return entityCapabilities(entity).includes(capability2) && !(entity.locks ?? []).includes(capability2);
|
|
760
|
+
}
|
|
761
|
+
function checkEntities(plan, byId, issues) {
|
|
762
|
+
const rootNodeOwners = /* @__PURE__ */ new Map();
|
|
763
|
+
plan.objects.forEach((entity, index) => {
|
|
764
|
+
const at = (...rest) => ["objects", index, ...rest];
|
|
765
|
+
if (entity.visual.kind !== "asset") {
|
|
766
|
+
for (const field of ["position", "rotation", "scale"]) {
|
|
767
|
+
if (entity[field] === void 0) {
|
|
768
|
+
issues.push({
|
|
769
|
+
path: at(field),
|
|
770
|
+
message: `entity "${entity.id}" is a ${entity.visual.kind} and must declare ${field}`
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
if (entity.visual.kind === "asset") {
|
|
776
|
+
const owner = rootNodeOwners.get(entity.visual.rootNodeId);
|
|
777
|
+
if (owner !== void 0) {
|
|
778
|
+
issues.push({
|
|
779
|
+
path: at("visual", "rootNodeId"),
|
|
780
|
+
message: `root node "${entity.visual.rootNodeId}" is already the root of entity "${owner}"`
|
|
781
|
+
});
|
|
782
|
+
} else {
|
|
783
|
+
rootNodeOwners.set(entity.visual.rootNodeId, entity.id);
|
|
784
|
+
}
|
|
785
|
+
const animation = entity.visual.animation;
|
|
786
|
+
if (animation) {
|
|
787
|
+
if (animation.endFrameExclusive <= animation.startFrame) {
|
|
788
|
+
issues.push({
|
|
789
|
+
path: at("visual", "animation", "endFrameExclusive"),
|
|
790
|
+
message: `entity "${entity.id}" animation ends at or before it starts`
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
if (animation.endFrameExclusive > plan.durationInFrames) {
|
|
794
|
+
issues.push({
|
|
795
|
+
path: at("visual", "animation", "endFrameExclusive"),
|
|
796
|
+
message: `entity "${entity.id}" animation runs past the scene (${plan.durationInFrames} frames)`
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
} else if (entity.materialBindings && entity.materialBindings.length > 0) {
|
|
801
|
+
issues.push({
|
|
802
|
+
path: at("materialBindings"),
|
|
803
|
+
message: `entity "${entity.id}" is a ${entity.visual.kind}; material bindings name materials in an asset root`
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
const roles = /* @__PURE__ */ new Set();
|
|
807
|
+
(entity.materialBindings ?? []).forEach((binding, bindingIndex) => {
|
|
808
|
+
if (roles.has(binding.role)) {
|
|
809
|
+
issues.push({
|
|
810
|
+
path: at("materialBindings", bindingIndex, "role"),
|
|
811
|
+
message: `entity "${entity.id}" binds material role "${binding.role}" twice`
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
roles.add(binding.role);
|
|
815
|
+
});
|
|
816
|
+
const anchorNames = /* @__PURE__ */ new Set();
|
|
817
|
+
(entity.anchors ?? []).forEach((anchor, anchorIndex) => {
|
|
818
|
+
if (anchor.nodeName !== void 0 && entity.visual.kind !== "asset") {
|
|
819
|
+
issues.push({
|
|
820
|
+
path: at("anchors", anchorIndex, "nodeName"),
|
|
821
|
+
message: `entity "${entity.id}" can bind anchor nodes only with an asset visual`
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
if (anchorNames.has(anchor.name)) {
|
|
825
|
+
issues.push({
|
|
826
|
+
path: at("anchors", anchorIndex, "name"),
|
|
827
|
+
message: `entity "${entity.id}" declares anchor "${anchor.name}" twice`
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
anchorNames.add(anchor.name);
|
|
831
|
+
});
|
|
832
|
+
});
|
|
833
|
+
plan.objects.forEach((entity, index) => {
|
|
834
|
+
if (entity.parentId === void 0) return;
|
|
835
|
+
if (entity.parentId === entity.id) {
|
|
836
|
+
issues.push({ path: ["objects", index, "parentId"], message: `entity "${entity.id}" cannot parent itself` });
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
if (!byId.has(entity.parentId)) {
|
|
840
|
+
issues.push({
|
|
841
|
+
path: ["objects", index, "parentId"],
|
|
842
|
+
message: `entity "${entity.id}" references unknown parent "${entity.parentId}"`
|
|
843
|
+
});
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
const seen = /* @__PURE__ */ new Set([entity.id]);
|
|
847
|
+
let cursor = byId.get(entity.parentId);
|
|
848
|
+
let depth = 1;
|
|
849
|
+
while (cursor) {
|
|
850
|
+
if (seen.has(cursor.id)) {
|
|
851
|
+
issues.push({ path: ["objects", index, "parentId"], message: `parent cycle through entity "${cursor.id}"` });
|
|
852
|
+
break;
|
|
853
|
+
}
|
|
854
|
+
seen.add(cursor.id);
|
|
855
|
+
depth += 1;
|
|
856
|
+
if (depth > SCENE3D_V2_LIMITS.maxHierarchyDepth) {
|
|
857
|
+
issues.push({
|
|
858
|
+
path: ["objects", index, "parentId"],
|
|
859
|
+
message: `hierarchy deeper than ${SCENE3D_V2_LIMITS.maxHierarchyDepth} levels`
|
|
860
|
+
});
|
|
861
|
+
break;
|
|
862
|
+
}
|
|
863
|
+
cursor = cursor.parentId === void 0 ? void 0 : byId.get(cursor.parentId);
|
|
864
|
+
}
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
function checkAssets(plan, assetsById, issues) {
|
|
868
|
+
let rendererBytes = 0;
|
|
869
|
+
let sourceCount = 0;
|
|
870
|
+
plan.assets.forEach((asset, index) => {
|
|
871
|
+
const at = (...rest) => ["assets", index, ...rest];
|
|
872
|
+
const expectedKind = SCENE3D_ASSET_ROLE_KINDS[asset.role];
|
|
873
|
+
if (asset.kind !== expectedKind) {
|
|
874
|
+
issues.push({
|
|
875
|
+
path: at("kind"),
|
|
876
|
+
message: `asset "${asset.assetId}" has role "${asset.role}", which requires kind "${expectedKind}" (got "${asset.kind}")`
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
if (asset.kind === "camera-track-json" && asset.byteLength > SCENE3D_V2_LIMITS.maxCameraTrackBytes) {
|
|
880
|
+
issues.push({
|
|
881
|
+
path: at("byteLength"),
|
|
882
|
+
message: `camera track "${asset.assetId}" is ${asset.byteLength} bytes; the limit is ${SCENE3D_V2_LIMITS.maxCameraTrackBytes}`
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
if (SCENE3D_RENDERER_ASSET_KINDS.includes(asset.kind)) {
|
|
886
|
+
rendererBytes += asset.byteLength;
|
|
887
|
+
if (asset.byteLength > SCENE3D_V2_LIMITS.maxRendererAssetBytes) {
|
|
888
|
+
issues.push({
|
|
889
|
+
path: at("byteLength"),
|
|
890
|
+
message: `asset "${asset.assetId}" is ${asset.byteLength} bytes; a downloaded scene asset may not exceed ${SCENE3D_V2_LIMITS.maxRendererAssetBytes}`
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
if (asset.kind === "blend-source") {
|
|
895
|
+
sourceCount += 1;
|
|
896
|
+
if (sourceCount > 1) {
|
|
897
|
+
issues.push({ path: at("kind"), message: "a revision may retain at most one blend-source asset" });
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
});
|
|
901
|
+
if (rendererBytes > SCENE3D_V2_LIMITS.maxRendererAssetBytes) {
|
|
902
|
+
issues.push({
|
|
903
|
+
path: ["assets"],
|
|
904
|
+
message: `downloaded scene assets total ${rendererBytes} bytes; the limit is ${SCENE3D_V2_LIMITS.maxRendererAssetBytes}`
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
const track = assetsById.get(plan.cameraTrackAssetId);
|
|
908
|
+
if (!track) {
|
|
909
|
+
issues.push({
|
|
910
|
+
path: ["cameraTrackAssetId"],
|
|
911
|
+
message: `cameraTrackAssetId "${plan.cameraTrackAssetId}" is not in assets`
|
|
912
|
+
});
|
|
913
|
+
} else if (track.kind !== "camera-track-json") {
|
|
914
|
+
issues.push({
|
|
915
|
+
path: ["cameraTrackAssetId"],
|
|
916
|
+
message: `cameraTrackAssetId "${plan.cameraTrackAssetId}" is kind "${track.kind}"; a camera track must be camera-track-json`
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
const referencedGlbs = /* @__PURE__ */ new Set();
|
|
920
|
+
for (const entity of plan.objects) {
|
|
921
|
+
if (entity.visual.kind === "asset") referencedGlbs.add(entity.visual.assetId);
|
|
922
|
+
}
|
|
923
|
+
plan.assets.forEach((asset, index) => {
|
|
924
|
+
if (asset.kind === "glb" && !referencedGlbs.has(asset.assetId)) {
|
|
925
|
+
issues.push({
|
|
926
|
+
path: ["assets", index, "assetId"],
|
|
927
|
+
message: `glb asset "${asset.assetId}" is not referenced by any entity`
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
plan.objects.forEach((entity, index) => {
|
|
932
|
+
if (entity.visual.kind !== "asset") return;
|
|
933
|
+
const asset = assetsById.get(entity.visual.assetId);
|
|
934
|
+
if (!asset) {
|
|
935
|
+
issues.push({
|
|
936
|
+
path: ["objects", index, "visual", "assetId"],
|
|
937
|
+
message: `entity "${entity.id}" references unknown asset "${entity.visual.assetId}"`
|
|
938
|
+
});
|
|
939
|
+
} else if (asset.kind !== "glb") {
|
|
940
|
+
issues.push({
|
|
941
|
+
path: ["objects", index, "visual", "assetId"],
|
|
942
|
+
message: `entity "${entity.id}" references asset "${asset.assetId}" of kind "${asset.kind}"; geometry must be glb`
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
if (plan.provenance.sourceArtifactId !== void 0) {
|
|
947
|
+
const source = assetsById.get(plan.provenance.sourceArtifactId);
|
|
948
|
+
if (!source) {
|
|
949
|
+
issues.push({
|
|
950
|
+
path: ["provenance", "sourceArtifactId"],
|
|
951
|
+
message: `sourceArtifactId "${plan.provenance.sourceArtifactId}" is not in assets`
|
|
952
|
+
});
|
|
953
|
+
} else if (source.kind !== "blend-source") {
|
|
954
|
+
issues.push({
|
|
955
|
+
path: ["provenance", "sourceArtifactId"],
|
|
956
|
+
message: `sourceArtifactId "${source.assetId}" is kind "${source.kind}"; a retained source must be blend-source`
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
function checkShots(plan, byId, issues) {
|
|
962
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
963
|
+
let expectedStart = 0;
|
|
964
|
+
plan.shots.forEach((shot, index) => {
|
|
965
|
+
const at = (...rest) => ["shots", index, ...rest];
|
|
966
|
+
if (seenIds.has(shot.id)) {
|
|
967
|
+
issues.push({ path: at("id"), message: `duplicate shot id "${shot.id}"` });
|
|
968
|
+
}
|
|
969
|
+
seenIds.add(shot.id);
|
|
970
|
+
if (shot.endFrameExclusive <= shot.startFrame) {
|
|
971
|
+
issues.push({
|
|
972
|
+
path: at("endFrameExclusive"),
|
|
973
|
+
message: `shot "${shot.id}" ends at or before it starts (${shot.startFrame}..${shot.endFrameExclusive})`
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
if (shot.startFrame !== expectedStart) {
|
|
977
|
+
issues.push({
|
|
978
|
+
path: at("startFrame"),
|
|
979
|
+
message: index === 0 ? `shots must start at frame 0 (got ${shot.startFrame})` : `shot "${shot.id}" starts at ${shot.startFrame}; the previous shot ends at ${expectedStart} \u2014 every frame belongs to exactly one shot`
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
expectedStart = Math.max(expectedStart, shot.endFrameExclusive);
|
|
983
|
+
for (const field of ["subjectEntityIds", "foregroundEntityIds"]) {
|
|
984
|
+
(shot[field] ?? []).forEach((entityId, entityIndex) => {
|
|
985
|
+
if (!byId.has(entityId)) {
|
|
986
|
+
issues.push({
|
|
987
|
+
path: at(field, entityIndex),
|
|
988
|
+
message: `shot "${shot.id}" references unknown entity "${entityId}"`
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
});
|
|
994
|
+
const last = plan.shots[plan.shots.length - 1];
|
|
995
|
+
if (last && last.endFrameExclusive !== plan.durationInFrames) {
|
|
996
|
+
issues.push({
|
|
997
|
+
path: ["shots", plan.shots.length - 1, "endFrameExclusive"],
|
|
998
|
+
message: `shots end at frame ${last.endFrameExclusive}; the scene is ${plan.durationInFrames} frames and must be covered completely`
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
function checkOverrides(plan, byId, shotIds, issues) {
|
|
1003
|
+
const overrideIds = /* @__PURE__ */ new Set();
|
|
1004
|
+
const transformTargets = /* @__PURE__ */ new Set();
|
|
1005
|
+
const visibilityTargets = /* @__PURE__ */ new Set();
|
|
1006
|
+
const colorTargets = /* @__PURE__ */ new Set();
|
|
1007
|
+
const offsetTargets = /* @__PURE__ */ new Set();
|
|
1008
|
+
(plan.overrides ?? []).forEach((override, index) => {
|
|
1009
|
+
const at = (...rest) => ["overrides", index, ...rest];
|
|
1010
|
+
if (overrideIds.has(override.id)) {
|
|
1011
|
+
issues.push({ path: at("id"), message: `duplicate override id "${override.id}"` });
|
|
1012
|
+
}
|
|
1013
|
+
overrideIds.add(override.id);
|
|
1014
|
+
if (override.operationVersion > SCENE3D_V2_OVERRIDE_OPERATION_VERSION) {
|
|
1015
|
+
issues.push({
|
|
1016
|
+
path: at("operationVersion"),
|
|
1017
|
+
message: `override "${override.id}" uses operation version ${override.operationVersion}; this reader understands up to ${SCENE3D_V2_OVERRIDE_OPERATION_VERSION}`
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
if (override.kind === "camera-shot-offset") {
|
|
1021
|
+
if (!shotIds.has(override.shotId)) {
|
|
1022
|
+
issues.push({ path: at("shotId"), message: `override "${override.id}" targets unknown shot "${override.shotId}"` });
|
|
1023
|
+
} else if (offsetTargets.has(override.shotId)) {
|
|
1024
|
+
issues.push({
|
|
1025
|
+
path: at("shotId"),
|
|
1026
|
+
message: `shot "${override.shotId}" already has a camera offset; one owner per channel`
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
offsetTargets.add(override.shotId);
|
|
1030
|
+
if (override.positionOffset === void 0 && override.targetOffset === void 0) {
|
|
1031
|
+
issues.push({ path: at(), message: `override "${override.id}" offsets nothing` });
|
|
1032
|
+
}
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
const entity = byId.get(override.entityId);
|
|
1036
|
+
if (!entity) {
|
|
1037
|
+
issues.push({ path: at("entityId"), message: `override "${override.id}" targets unknown entity "${override.entityId}"` });
|
|
1038
|
+
return;
|
|
1039
|
+
}
|
|
1040
|
+
if (override.kind === "entity-transform") {
|
|
1041
|
+
if (transformTargets.has(override.entityId)) {
|
|
1042
|
+
issues.push({
|
|
1043
|
+
path: at("entityId"),
|
|
1044
|
+
message: `entity "${override.entityId}" already has a transform override; one owner per channel`
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
transformTargets.add(override.entityId);
|
|
1048
|
+
if (!scene3DEntityAcceptsOverlay(entity, "transform")) {
|
|
1049
|
+
issues.push({
|
|
1050
|
+
path: at("entityId"),
|
|
1051
|
+
message: `entity "${override.entityId}" does not accept a transform overlay (locked or not advertised)`
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
if (override.position === void 0 && override.rotation === void 0 && override.scale === void 0) {
|
|
1055
|
+
issues.push({ path: at(), message: `override "${override.id}" changes nothing` });
|
|
1056
|
+
}
|
|
1057
|
+
return;
|
|
1058
|
+
}
|
|
1059
|
+
if (override.kind === "entity-visibility") {
|
|
1060
|
+
if (visibilityTargets.has(override.entityId)) {
|
|
1061
|
+
issues.push({
|
|
1062
|
+
path: at("entityId"),
|
|
1063
|
+
message: `entity "${override.entityId}" already has a visibility override; one owner per channel`
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
visibilityTargets.add(override.entityId);
|
|
1067
|
+
if (!scene3DEntityAcceptsOverlay(entity, "visibility")) {
|
|
1068
|
+
issues.push({
|
|
1069
|
+
path: at("entityId"),
|
|
1070
|
+
message: `entity "${override.entityId}" does not accept a visibility overlay (locked or not advertised)`
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
return;
|
|
1074
|
+
}
|
|
1075
|
+
const key = `${override.entityId}\0${override.materialRole}`;
|
|
1076
|
+
if (colorTargets.has(key)) {
|
|
1077
|
+
issues.push({
|
|
1078
|
+
path: at("materialRole"),
|
|
1079
|
+
message: `entity "${override.entityId}" already recolours material role "${override.materialRole}"`
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
colorTargets.add(key);
|
|
1083
|
+
if (!scene3DEntityAcceptsOverlay(entity, "color")) {
|
|
1084
|
+
issues.push({
|
|
1085
|
+
path: at("entityId"),
|
|
1086
|
+
message: `entity "${override.entityId}" does not accept a colour overlay (locked or not advertised)`
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
if (entity.visual.kind === "group") {
|
|
1090
|
+
issues.push({
|
|
1091
|
+
path: at("materialRole"),
|
|
1092
|
+
message: `entity "${override.entityId}" is a group and has no geometry to recolour`
|
|
1093
|
+
});
|
|
1094
|
+
} else if (entity.visual.kind === "primitive") {
|
|
1095
|
+
if (override.materialRole !== SCENE3D_PRIMITIVE_MATERIAL_ROLE) {
|
|
1096
|
+
issues.push({
|
|
1097
|
+
path: at("materialRole"),
|
|
1098
|
+
message: `entity "${override.entityId}" is a primitive; its only material role is "${SCENE3D_PRIMITIVE_MATERIAL_ROLE}"`
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
1101
|
+
} else if (!(entity.materialBindings ?? []).some((binding) => binding.role === override.materialRole)) {
|
|
1102
|
+
issues.push({
|
|
1103
|
+
path: at("materialRole"),
|
|
1104
|
+
message: `entity "${override.entityId}" declares no material role "${override.materialRole}"; a binding may only name materials in that entity's asset root`
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
function scene3DPlanV2Issues(plan) {
|
|
1110
|
+
const issues = [];
|
|
1111
|
+
const seconds = plan.durationInFrames / plan.fps;
|
|
1112
|
+
if (seconds > SCENE3D_V2_LIMITS.maxDurationSeconds) {
|
|
1113
|
+
issues.push({
|
|
1114
|
+
path: ["durationInFrames"],
|
|
1115
|
+
message: `scene is ${seconds.toFixed(2)}s; the limit is ${SCENE3D_V2_LIMITS.maxDurationSeconds}s`
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
for (const axis of ["width", "height"]) {
|
|
1119
|
+
if (plan[axis] % 2 !== 0) {
|
|
1120
|
+
issues.push({ path: [axis], message: `${axis} must be an even number of pixels (got ${plan[axis]})` });
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
const byId = /* @__PURE__ */ new Map();
|
|
1124
|
+
plan.objects.forEach((entity, index) => {
|
|
1125
|
+
if (byId.has(entity.id)) {
|
|
1126
|
+
issues.push({ path: ["objects", index, "id"], message: `duplicate entity id "${entity.id}"` });
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
byId.set(entity.id, entity);
|
|
1130
|
+
});
|
|
1131
|
+
const assetsById = /* @__PURE__ */ new Map();
|
|
1132
|
+
plan.assets.forEach((asset, index) => {
|
|
1133
|
+
if (assetsById.has(asset.assetId)) {
|
|
1134
|
+
issues.push({ path: ["assets", index, "assetId"], message: `duplicate asset id "${asset.assetId}"` });
|
|
1135
|
+
return;
|
|
1136
|
+
}
|
|
1137
|
+
assetsById.set(asset.assetId, asset);
|
|
1138
|
+
});
|
|
1139
|
+
checkEntities(plan, byId, issues);
|
|
1140
|
+
checkAssets(plan, assetsById, issues);
|
|
1141
|
+
checkShots(plan, byId, issues);
|
|
1142
|
+
checkOverrides(plan, byId, new Set(plan.shots.map((shot) => shot.id)), issues);
|
|
1143
|
+
const referenceIds = /* @__PURE__ */ new Set();
|
|
1144
|
+
(plan.references ?? []).forEach((reference, index) => {
|
|
1145
|
+
if (referenceIds.has(reference.id)) {
|
|
1146
|
+
issues.push({ path: ["references", index, "id"], message: `duplicate reference id "${reference.id}"` });
|
|
1147
|
+
}
|
|
1148
|
+
referenceIds.add(reference.id);
|
|
1149
|
+
if (reference.objectId !== void 0 && !byId.has(reference.objectId)) {
|
|
1150
|
+
issues.push({
|
|
1151
|
+
path: ["references", index, "objectId"],
|
|
1152
|
+
message: `reference "${reference.id}" points at unknown entity "${reference.objectId}"`
|
|
1153
|
+
});
|
|
1154
|
+
}
|
|
1155
|
+
if (reference.startSeconds !== void 0 && reference.endSeconds !== void 0 && reference.endSeconds <= reference.startSeconds) {
|
|
1156
|
+
issues.push({
|
|
1157
|
+
path: ["references", index, "endSeconds"],
|
|
1158
|
+
message: `reference "${reference.id}" ends at or before it starts`
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1161
|
+
if (reference.kind === "image" && (reference.startSeconds !== void 0 || reference.endSeconds !== void 0)) {
|
|
1162
|
+
issues.push({
|
|
1163
|
+
path: ["references", index, "startSeconds"],
|
|
1164
|
+
message: `reference "${reference.id}" is an image; a time window applies to video only`
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
});
|
|
1168
|
+
return issues;
|
|
1169
|
+
}
|
|
1170
|
+
var scene3DPlanV2ObjectSchema = z.object({
|
|
1171
|
+
planType: z.literal(SCENE3D_PLAN_TYPE),
|
|
1172
|
+
schemaVersion: z.literal(SCENE3D_SCHEMA_VERSION_V2),
|
|
1173
|
+
revisionId: z.uuid(),
|
|
1174
|
+
parentRevisionId: z.uuid().optional(),
|
|
1175
|
+
width: z.number().int().min(SCENE3D_V2_LIMITS.minDimensionPx).max(SCENE3D_V2_LIMITS.maxDimensionPx),
|
|
1176
|
+
height: z.number().int().min(SCENE3D_V2_LIMITS.minDimensionPx).max(SCENE3D_V2_LIMITS.maxDimensionPx),
|
|
1177
|
+
fps: z.number().int().min(SCENE3D_V2_LIMITS.minFps).max(SCENE3D_V2_LIMITS.maxFps),
|
|
1178
|
+
durationInFrames: z.number().int().min(SCENE3D_V2_LIMITS.minDurationInFrames).max(SCENE3D_V2_LIMITS.maxDurationInFrames),
|
|
1179
|
+
units: z.literal("meters"),
|
|
1180
|
+
upAxis: z.literal("Y"),
|
|
1181
|
+
handedness: z.literal("right"),
|
|
1182
|
+
objects: z.array(scene3DEntityV2Schema).min(SCENE3D_V2_LIMITS.minEntities).max(SCENE3D_V2_LIMITS.maxEntities),
|
|
1183
|
+
assets: z.array(scene3DAssetRefSchema).min(1).max(SCENE3D_V2_LIMITS.maxAssets),
|
|
1184
|
+
cameraTrackAssetId: scene3DAssetIdSchema,
|
|
1185
|
+
shots: z.array(scene3DShotSchema).min(1).max(SCENE3D_V2_LIMITS.maxShots),
|
|
1186
|
+
lighting: scene3DClayLightingSchema,
|
|
1187
|
+
backgroundColor: scene3DColorSchema,
|
|
1188
|
+
references: z.array(scene3DReferenceSchema).max(SCENE3D_V2_LIMITS.maxReferences).optional(),
|
|
1189
|
+
overrides: z.array(scene3DOverrideSchema).max(SCENE3D_V2_LIMITS.maxOverrides).optional(),
|
|
1190
|
+
provenance: scene3DProvenanceSchema
|
|
1191
|
+
}).strict();
|
|
1192
|
+
var scene3DPlanV2Schema = scene3DPlanV2ObjectSchema.superRefine((plan, ctx) => {
|
|
1193
|
+
for (const issue of scene3DPlanV2Issues(plan)) {
|
|
1194
|
+
ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
|
|
1195
|
+
}
|
|
1196
|
+
});
|
|
1197
|
+
var scene3DAnyPlanSchema = z.discriminatedUnion("schemaVersion", [scene3DPlanV1ObjectSchema, scene3DPlanV2ObjectSchema]).superRefine((plan, ctx) => {
|
|
1198
|
+
const issues = plan.schemaVersion === SCENE3D_SCHEMA_VERSION_V2 ? scene3DPlanV2Issues(plan) : scene3DPlanV1Issues(plan);
|
|
1199
|
+
for (const issue of issues) {
|
|
1200
|
+
ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
|
|
1201
|
+
}
|
|
1202
|
+
});
|
|
1203
|
+
var scene3DAcceptedSchemaVersionsSchema = z.array(z.union([z.literal(1), z.literal(2)])).min(1).max(SCENE3D_SUPPORTED_SCHEMA_VERSIONS.length);
|
|
1204
|
+
function isScene3DPlanV2(value) {
|
|
1205
|
+
return scene3DPlanV2Schema.safeParse(value).success;
|
|
1206
|
+
}
|
|
1207
|
+
function isScene3DPlan(value) {
|
|
1208
|
+
return scene3DAnyPlanSchema.safeParse(value).success;
|
|
1209
|
+
}
|
|
1210
|
+
function scene3DPlanSchemaVersion(value) {
|
|
1211
|
+
if (typeof value !== "object" || value === null) return null;
|
|
1212
|
+
const record = value;
|
|
1213
|
+
if (record.planType !== SCENE3D_PLAN_TYPE) return null;
|
|
1214
|
+
if (typeof record.schemaVersion !== "number" || !Number.isInteger(record.schemaVersion)) return null;
|
|
1215
|
+
return record.schemaVersion;
|
|
1216
|
+
}
|
|
1217
|
+
function isScene3DSchemaVersionSupported(version) {
|
|
1218
|
+
return SCENE3D_SUPPORTED_SCHEMA_VERSIONS.includes(version);
|
|
1219
|
+
}
|
|
1220
|
+
function isKnownScene3DEngine(engine) {
|
|
1221
|
+
return SCENE3D_V2_ENGINES.includes(engine);
|
|
1222
|
+
}
|
|
1223
|
+
function scene3DShotIndexForFrame(shots, frame) {
|
|
1224
|
+
for (let index = 0; index < shots.length; index++) {
|
|
1225
|
+
const shot = shots[index];
|
|
1226
|
+
if (frame >= shot.startFrame && frame < shot.endFrameExclusive) return index;
|
|
1227
|
+
}
|
|
1228
|
+
return -1;
|
|
1229
|
+
}
|
|
1230
|
+
function scene3DShotForFrame(shots, frame) {
|
|
1231
|
+
const index = scene3DShotIndexForFrame(shots, frame);
|
|
1232
|
+
return index === -1 ? void 0 : shots[index];
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
// src/scene3d-v2-resources.ts
|
|
1236
|
+
function scene3DV2HierarchyDepth(entities) {
|
|
1237
|
+
const byId = new Map(entities.map((entity) => [entity.id, entity]));
|
|
1238
|
+
let deepest = 0;
|
|
1239
|
+
for (const entity of entities) {
|
|
1240
|
+
let depth = 1;
|
|
1241
|
+
let cursor = entity;
|
|
1242
|
+
const seen = /* @__PURE__ */ new Set([entity.id]);
|
|
1243
|
+
while (cursor.parentId !== void 0) {
|
|
1244
|
+
const parent = byId.get(cursor.parentId);
|
|
1245
|
+
if (!parent || seen.has(parent.id)) break;
|
|
1246
|
+
seen.add(parent.id);
|
|
1247
|
+
cursor = parent;
|
|
1248
|
+
depth += 1;
|
|
1249
|
+
}
|
|
1250
|
+
if (depth > deepest) deepest = depth;
|
|
1251
|
+
}
|
|
1252
|
+
return deepest;
|
|
1253
|
+
}
|
|
1254
|
+
function scene3DV2ResourceUsage(plan) {
|
|
1255
|
+
let rendererAssetBytes = 0;
|
|
1256
|
+
let cameraTrackBytes = 0;
|
|
1257
|
+
let blendSourceBytes = 0;
|
|
1258
|
+
for (const asset of plan.assets) {
|
|
1259
|
+
if (SCENE3D_RENDERER_ASSET_KINDS.includes(asset.kind)) rendererAssetBytes += asset.byteLength;
|
|
1260
|
+
if (asset.kind === "camera-track-json") cameraTrackBytes += asset.byteLength;
|
|
1261
|
+
if (asset.kind === "blend-source") blendSourceBytes += asset.byteLength;
|
|
1262
|
+
}
|
|
1263
|
+
return {
|
|
1264
|
+
entities: plan.objects.length,
|
|
1265
|
+
assets: plan.assets.length,
|
|
1266
|
+
shots: plan.shots.length,
|
|
1267
|
+
overrides: plan.overrides?.length ?? 0,
|
|
1268
|
+
references: plan.references?.length ?? 0,
|
|
1269
|
+
frames: plan.durationInFrames,
|
|
1270
|
+
durationSeconds: plan.durationInFrames / plan.fps,
|
|
1271
|
+
hierarchyDepth: scene3DV2HierarchyDepth(plan.objects),
|
|
1272
|
+
rendererAssetBytes,
|
|
1273
|
+
cameraTrackBytes,
|
|
1274
|
+
blendSourceBytes
|
|
1275
|
+
};
|
|
1276
|
+
}
|
|
1277
|
+
function scene3DV2AdmissionIssues(plan, manifestBytes) {
|
|
1278
|
+
const issues = [];
|
|
1279
|
+
const usage = scene3DV2ResourceUsage(plan);
|
|
1280
|
+
const limits = SCENE3D_V2_LIMITS;
|
|
1281
|
+
if (manifestBytes !== void 0 && manifestBytes > limits.maxManifestBytes) {
|
|
1282
|
+
issues.push({
|
|
1283
|
+
path: [],
|
|
1284
|
+
message: `manifest is ${manifestBytes} bytes; the limit is ${limits.maxManifestBytes}`
|
|
1285
|
+
});
|
|
1286
|
+
}
|
|
1287
|
+
if (usage.frames > limits.maxDurationInFrames) {
|
|
1288
|
+
issues.push({
|
|
1289
|
+
path: ["durationInFrames"],
|
|
1290
|
+
message: `scene is ${usage.frames} frames; the limit is ${limits.maxDurationInFrames}`
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
if (usage.durationSeconds > limits.maxDurationSeconds) {
|
|
1294
|
+
issues.push({
|
|
1295
|
+
path: ["durationInFrames"],
|
|
1296
|
+
message: `scene is ${usage.durationSeconds.toFixed(2)}s; the limit is ${limits.maxDurationSeconds}s`
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
if (usage.entities > limits.maxEntities) {
|
|
1300
|
+
issues.push({ path: ["objects"], message: `${usage.entities} entities; the limit is ${limits.maxEntities}` });
|
|
1301
|
+
}
|
|
1302
|
+
if (usage.shots > limits.maxShots) {
|
|
1303
|
+
issues.push({ path: ["shots"], message: `${usage.shots} shots; the limit is ${limits.maxShots}` });
|
|
1304
|
+
}
|
|
1305
|
+
if (usage.hierarchyDepth > limits.maxHierarchyDepth) {
|
|
1306
|
+
issues.push({
|
|
1307
|
+
path: ["objects"],
|
|
1308
|
+
message: `hierarchy is ${usage.hierarchyDepth} deep; the limit is ${limits.maxHierarchyDepth}`
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
if (usage.rendererAssetBytes > limits.maxRendererAssetBytes) {
|
|
1312
|
+
issues.push({
|
|
1313
|
+
path: ["assets"],
|
|
1314
|
+
message: `downloaded scene assets total ${usage.rendererAssetBytes} bytes; the limit is ${limits.maxRendererAssetBytes}`
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
if (usage.cameraTrackBytes > limits.maxCameraTrackBytes) {
|
|
1318
|
+
issues.push({
|
|
1319
|
+
path: ["assets"],
|
|
1320
|
+
message: `camera track data totals ${usage.cameraTrackBytes} bytes; the limit is ${limits.maxCameraTrackBytes}`
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1323
|
+
return issues;
|
|
1324
|
+
}
|
|
1325
|
+
function scene3DV2NormalizationIssues(plan, stats) {
|
|
1326
|
+
const issues = [];
|
|
1327
|
+
const limits = SCENE3D_V2_LIMITS;
|
|
1328
|
+
const declared = new Map(plan.assets.map((asset) => [asset.assetId, asset]));
|
|
1329
|
+
let meshNodes = 0;
|
|
1330
|
+
let triangles = 0;
|
|
1331
|
+
let rendererBytes = 0;
|
|
1332
|
+
stats.forEach((stat, index) => {
|
|
1333
|
+
const at = (...rest) => [index, ...rest];
|
|
1334
|
+
const asset = declared.get(stat.assetId);
|
|
1335
|
+
if (!asset) {
|
|
1336
|
+
issues.push({ path: at("assetId"), message: `asset "${stat.assetId}" is not declared in the manifest` });
|
|
1337
|
+
return;
|
|
1338
|
+
}
|
|
1339
|
+
if (stat.kind !== asset.kind) {
|
|
1340
|
+
issues.push({
|
|
1341
|
+
path: at("kind"),
|
|
1342
|
+
message: `asset "${stat.assetId}" decoded as "${stat.kind}" but the manifest declares "${asset.kind}"`
|
|
1343
|
+
});
|
|
1344
|
+
}
|
|
1345
|
+
if (stat.byteLength !== asset.byteLength) {
|
|
1346
|
+
issues.push({
|
|
1347
|
+
path: at("byteLength"),
|
|
1348
|
+
message: `asset "${stat.assetId}" is ${stat.byteLength} bytes; the manifest declares ${asset.byteLength}`
|
|
1349
|
+
});
|
|
1350
|
+
}
|
|
1351
|
+
if (stat.sha256 !== void 0 && stat.sha256 !== asset.sha256) {
|
|
1352
|
+
issues.push({
|
|
1353
|
+
path: at("sha256"),
|
|
1354
|
+
message: `asset "${stat.assetId}" digest does not match the manifest`
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1357
|
+
if (SCENE3D_RENDERER_ASSET_KINDS.includes(stat.kind)) rendererBytes += stat.byteLength;
|
|
1358
|
+
if (stat.kind === "camera-track-json" && stat.byteLength > limits.maxCameraTrackBytes) {
|
|
1359
|
+
issues.push({
|
|
1360
|
+
path: at("byteLength"),
|
|
1361
|
+
message: `camera track "${stat.assetId}" decoded to ${stat.byteLength} bytes; the limit is ${limits.maxCameraTrackBytes}`
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
meshNodes += stat.meshNodes ?? 0;
|
|
1365
|
+
triangles += stat.triangles ?? 0;
|
|
1366
|
+
if (stat.maxNodeDepth !== void 0 && stat.maxNodeDepth > limits.maxHierarchyDepth) {
|
|
1367
|
+
issues.push({
|
|
1368
|
+
path: at("maxNodeDepth"),
|
|
1369
|
+
message: `asset "${stat.assetId}" nests ${stat.maxNodeDepth} levels; the limit is ${limits.maxHierarchyDepth}`
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
for (const [field, value] of [
|
|
1373
|
+
["imageWidth", stat.imageWidth],
|
|
1374
|
+
["imageHeight", stat.imageHeight]
|
|
1375
|
+
]) {
|
|
1376
|
+
if (value === void 0) continue;
|
|
1377
|
+
if (!Number.isInteger(value) || value < limits.minPosterDimensionPx || value > limits.maxPosterDimensionPx) {
|
|
1378
|
+
issues.push({
|
|
1379
|
+
path: at(field),
|
|
1380
|
+
message: `asset "${stat.assetId}" ${field} is ${value}; it must be an integer between ${limits.minPosterDimensionPx} and ${limits.maxPosterDimensionPx}`
|
|
1381
|
+
});
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
});
|
|
1385
|
+
if (meshNodes > limits.maxMeshNodes) {
|
|
1386
|
+
issues.push({ path: [], message: `resolved assets contain ${meshNodes} mesh nodes; the limit is ${limits.maxMeshNodes}` });
|
|
1387
|
+
}
|
|
1388
|
+
if (triangles > limits.maxTriangles) {
|
|
1389
|
+
issues.push({ path: [], message: `resolved assets contain ${triangles} triangles; the limit is ${limits.maxTriangles}` });
|
|
1390
|
+
}
|
|
1391
|
+
if (rendererBytes > limits.maxRendererAssetBytes) {
|
|
1392
|
+
issues.push({
|
|
1393
|
+
path: [],
|
|
1394
|
+
message: `downloaded scene assets decoded to ${rendererBytes} bytes; the limit is ${limits.maxRendererAssetBytes}`
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
return issues;
|
|
1398
|
+
}
|
|
1399
|
+
function parseScene3DPlanV2Json(text) {
|
|
1400
|
+
const bytes = scene3DJsonByteLength(text);
|
|
1401
|
+
if (bytes > SCENE3D_V2_LIMITS.maxManifestBytes) {
|
|
1402
|
+
return {
|
|
1403
|
+
ok: false,
|
|
1404
|
+
issues: [{ path: [], message: `manifest is ${bytes} bytes; the limit is ${SCENE3D_V2_LIMITS.maxManifestBytes}` }]
|
|
1405
|
+
};
|
|
1406
|
+
}
|
|
1407
|
+
let decoded;
|
|
1408
|
+
try {
|
|
1409
|
+
decoded = JSON.parse(text);
|
|
1410
|
+
} catch {
|
|
1411
|
+
return { ok: false, issues: [{ path: [], message: "manifest is not valid JSON" }] };
|
|
1412
|
+
}
|
|
1413
|
+
const parsed = scene3DPlanV2Schema.safeParse(decoded);
|
|
1414
|
+
if (!parsed.success) return { ok: false, issues: scene3DZodIssues(parsed.error) };
|
|
1415
|
+
return { ok: true, value: parsed.data };
|
|
1416
|
+
}
|
|
1417
|
+
var SCENE3D_V2_CONTENT_HASH_EXCLUDED = ["revisionId", "parentRevisionId"];
|
|
1418
|
+
function canonicalize(value) {
|
|
1419
|
+
if (value === null) return "null";
|
|
1420
|
+
if (typeof value === "number") {
|
|
1421
|
+
if (!Number.isFinite(value)) throw new Error("cannot canonicalize a non-finite number");
|
|
1422
|
+
return JSON.stringify(value === 0 ? 0 : value);
|
|
1423
|
+
}
|
|
1424
|
+
if (typeof value === "string" || typeof value === "boolean") return JSON.stringify(value);
|
|
1425
|
+
if (Array.isArray(value)) return `[${value.map((item) => canonicalize(item)).join(",")}]`;
|
|
1426
|
+
if (typeof value === "object") {
|
|
1427
|
+
const record = value;
|
|
1428
|
+
const parts = [];
|
|
1429
|
+
for (const key of Object.keys(record).sort()) {
|
|
1430
|
+
const entry = record[key];
|
|
1431
|
+
if (entry === void 0) continue;
|
|
1432
|
+
parts.push(`${JSON.stringify(key)}:${canonicalize(entry)}`);
|
|
1433
|
+
}
|
|
1434
|
+
return `{${parts.join(",")}}`;
|
|
1435
|
+
}
|
|
1436
|
+
throw new Error(`cannot canonicalize ${typeof value}`);
|
|
1437
|
+
}
|
|
1438
|
+
function canonicalScene3DPlanV2Json(plan) {
|
|
1439
|
+
const { revisionId: _revisionId, parentRevisionId: _parentRevisionId, provenance, ...rest } = plan;
|
|
1440
|
+
const { contentHash: _contentHash, ...provenanceRest } = provenance;
|
|
1441
|
+
return canonicalize({ ...rest, provenance: provenanceRest });
|
|
1442
|
+
}
|
|
1443
|
+
function toHex(buffer) {
|
|
1444
|
+
return Array.from(new Uint8Array(buffer), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
1445
|
+
}
|
|
1446
|
+
async function computeScene3DPlanV2ContentHash(plan) {
|
|
1447
|
+
const subtle = globalThis.crypto?.subtle;
|
|
1448
|
+
if (!subtle) throw new Error("WebCrypto SubtleCrypto is required to hash a Scene3D revision");
|
|
1449
|
+
const bytes = new TextEncoder().encode(canonicalScene3DPlanV2Json(plan));
|
|
1450
|
+
return toHex(await subtle.digest("SHA-256", bytes));
|
|
1451
|
+
}
|
|
1452
|
+
async function verifyScene3DPlanV2ContentHash(plan) {
|
|
1453
|
+
return await computeScene3DPlanV2ContentHash(plan) === plan.provenance.contentHash;
|
|
1454
|
+
}
|
|
1455
|
+
var SCENE3D_CAMERA_TRACK_FORMAT = "scene3d-camera-track";
|
|
1456
|
+
var SCENE3D_CAMERA_TRACK_VERSION = 1;
|
|
1457
|
+
var SCENE3D_CAMERA_TRACK_LIMITS = {
|
|
1458
|
+
maxJsonBytes: SCENE3D_V2_LIMITS.maxCameraTrackBytes,
|
|
1459
|
+
maxFrameCount: SCENE3D_V2_LIMITS.maxDurationInFrames,
|
|
1460
|
+
minFps: SCENE3D_V2_LIMITS.minFps,
|
|
1461
|
+
maxFps: SCENE3D_V2_LIMITS.maxFps,
|
|
1462
|
+
/** A unit quaternion off by more than this is a bug, not float noise. */
|
|
1463
|
+
quaternionTolerance: 1e-4,
|
|
1464
|
+
/** Absolute tolerance on the projection entries that must be exactly zero
|
|
1465
|
+
* (or exactly ∓1) in a perspective matrix. */
|
|
1466
|
+
projectionEpsilon: 1e-6,
|
|
1467
|
+
/** Relative tolerance when comparing declared near/far against the values the
|
|
1468
|
+
* projection matrix implies. */
|
|
1469
|
+
nearFarRelativeTolerance: 1e-3,
|
|
1470
|
+
/** Relative tolerance on `m[0]/m[5]` vs the manifest's `height/width`. */
|
|
1471
|
+
aspectRelativeTolerance: 1e-3,
|
|
1472
|
+
minNear: 1e-4,
|
|
1473
|
+
maxFar: 1e7
|
|
1474
|
+
};
|
|
1475
|
+
var coordinate = z.number().min(-SCENE3D_LIMITS.maxCoordinate).max(SCENE3D_LIMITS.maxCoordinate);
|
|
1476
|
+
var positionSchema = z.tuple([coordinate, coordinate, coordinate]);
|
|
1477
|
+
var scene3DCameraSampleSchema = z.object({
|
|
1478
|
+
position: positionSchema,
|
|
1479
|
+
quaternion: z.tuple([z.number(), z.number(), z.number(), z.number()]),
|
|
1480
|
+
projectionMatrix: z.array(z.number()).length(16),
|
|
1481
|
+
near: z.number().min(SCENE3D_CAMERA_TRACK_LIMITS.minNear).max(SCENE3D_CAMERA_TRACK_LIMITS.maxFar),
|
|
1482
|
+
far: z.number().min(SCENE3D_CAMERA_TRACK_LIMITS.minNear).max(SCENE3D_CAMERA_TRACK_LIMITS.maxFar),
|
|
1483
|
+
target: positionSchema.optional(),
|
|
1484
|
+
focalLengthMm: z.number().min(SCENE3D_LIMITS.minFocalLengthMm).max(SCENE3D_LIMITS.maxFocalLengthMm).optional()
|
|
1485
|
+
}).strict();
|
|
1486
|
+
var scene3DCameraTrackObjectSchema = z.object({
|
|
1487
|
+
format: z.literal(SCENE3D_CAMERA_TRACK_FORMAT),
|
|
1488
|
+
version: z.literal(SCENE3D_CAMERA_TRACK_VERSION),
|
|
1489
|
+
frameStart: z.literal(0),
|
|
1490
|
+
frameCount: z.number().int().min(1).max(SCENE3D_CAMERA_TRACK_LIMITS.maxFrameCount),
|
|
1491
|
+
fps: z.number().int().min(SCENE3D_CAMERA_TRACK_LIMITS.minFps).max(SCENE3D_CAMERA_TRACK_LIMITS.maxFps),
|
|
1492
|
+
samples: z.array(scene3DCameraSampleSchema).min(1).max(SCENE3D_CAMERA_TRACK_LIMITS.maxFrameCount)
|
|
1493
|
+
}).strict();
|
|
1494
|
+
function scene3DProjectionIssues(matrix, near, far, path) {
|
|
1495
|
+
const issues = [];
|
|
1496
|
+
const eps = SCENE3D_CAMERA_TRACK_LIMITS.projectionEpsilon;
|
|
1497
|
+
if (matrix.length !== 16) {
|
|
1498
|
+
issues.push({ path, message: `projection matrix must have exactly 16 entries (got ${matrix.length})` });
|
|
1499
|
+
return issues;
|
|
1500
|
+
}
|
|
1501
|
+
if (matrix.some((value) => !Number.isFinite(value))) {
|
|
1502
|
+
issues.push({ path, message: "projection matrix contains a non-finite entry" });
|
|
1503
|
+
return issues;
|
|
1504
|
+
}
|
|
1505
|
+
if (Math.abs(matrix[11]) < eps && Math.abs(matrix[15] - 1) < eps) {
|
|
1506
|
+
issues.push({
|
|
1507
|
+
path,
|
|
1508
|
+
message: "projection matrix is orthographic; only perspective cameras are supported by this schema version"
|
|
1509
|
+
});
|
|
1510
|
+
return issues;
|
|
1511
|
+
}
|
|
1512
|
+
for (const index of [1, 2, 3, 4, 6, 7, 12, 13, 15]) {
|
|
1513
|
+
if (Math.abs(matrix[index]) > eps) {
|
|
1514
|
+
issues.push({ path: [...path, index], message: `projection matrix entry ${index} must be 0 (got ${matrix[index]})` });
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
if (Math.abs(matrix[11] + 1) > eps) {
|
|
1518
|
+
issues.push({ path: [...path, 11], message: `projection matrix entry 11 must be -1 for a perspective camera (got ${matrix[11]})` });
|
|
1519
|
+
}
|
|
1520
|
+
if (!(matrix[0] > 0)) {
|
|
1521
|
+
issues.push({ path: [...path, 0], message: `projection matrix entry 0 must be positive (got ${matrix[0]})` });
|
|
1522
|
+
}
|
|
1523
|
+
if (!(matrix[5] > 0)) {
|
|
1524
|
+
issues.push({ path: [...path, 5], message: `projection matrix entry 5 must be positive (got ${matrix[5]})` });
|
|
1525
|
+
}
|
|
1526
|
+
if (!(matrix[10] < 0)) {
|
|
1527
|
+
issues.push({ path: [...path, 10], message: `projection matrix entry 10 must be negative (got ${matrix[10]})` });
|
|
1528
|
+
}
|
|
1529
|
+
if (!(matrix[14] < 0)) {
|
|
1530
|
+
issues.push({ path: [...path, 14], message: `projection matrix entry 14 must be negative (got ${matrix[14]})` });
|
|
1531
|
+
}
|
|
1532
|
+
if (issues.length > 0) return issues;
|
|
1533
|
+
if (!(near > 0) || !(far > near)) {
|
|
1534
|
+
issues.push({ path, message: `near/far must satisfy 0 < near < far (got near ${near}, far ${far})` });
|
|
1535
|
+
return issues;
|
|
1536
|
+
}
|
|
1537
|
+
const tolerance = SCENE3D_CAMERA_TRACK_LIMITS.nearFarRelativeTolerance;
|
|
1538
|
+
const impliedNear = matrix[14] / (matrix[10] - 1);
|
|
1539
|
+
if (Math.abs(impliedNear - near) > Math.abs(near) * tolerance) {
|
|
1540
|
+
issues.push({
|
|
1541
|
+
path,
|
|
1542
|
+
message: `projection matrix implies near ${impliedNear.toPrecision(6)}, but the sample declares ${near}`
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
const farDenominator = matrix[10] + 1;
|
|
1546
|
+
if (Math.abs(farDenominator) < eps) {
|
|
1547
|
+
issues.push({
|
|
1548
|
+
path,
|
|
1549
|
+
message: `projection matrix implies an infinite far plane, but the sample declares ${far}`
|
|
1550
|
+
});
|
|
1551
|
+
} else {
|
|
1552
|
+
const impliedFar = matrix[14] / farDenominator;
|
|
1553
|
+
if (Math.abs(impliedFar - far) > Math.abs(far) * tolerance) {
|
|
1554
|
+
issues.push({
|
|
1555
|
+
path,
|
|
1556
|
+
message: `projection matrix implies far ${impliedFar.toPrecision(6)}, but the sample declares ${far}`
|
|
1557
|
+
});
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
return issues;
|
|
1561
|
+
}
|
|
1562
|
+
function scene3DCameraTrackIssues(track) {
|
|
1563
|
+
const issues = [];
|
|
1564
|
+
if (track.samples.length !== track.frameCount) {
|
|
1565
|
+
issues.push({
|
|
1566
|
+
path: ["samples"],
|
|
1567
|
+
message: `track declares ${track.frameCount} frames but carries ${track.samples.length} samples; exactly one sample per frame is required`
|
|
1568
|
+
});
|
|
1569
|
+
}
|
|
1570
|
+
const quaternionTolerance = SCENE3D_CAMERA_TRACK_LIMITS.quaternionTolerance;
|
|
1571
|
+
track.samples.forEach((sample, index) => {
|
|
1572
|
+
const [x, y, z9, w] = sample.quaternion;
|
|
1573
|
+
const norm = Math.sqrt(x * x + y * y + z9 * z9 + w * w);
|
|
1574
|
+
if (Math.abs(norm - 1) > quaternionTolerance) {
|
|
1575
|
+
issues.push({
|
|
1576
|
+
path: ["samples", index, "quaternion"],
|
|
1577
|
+
message: `quaternion at frame ${index} has length ${norm.toPrecision(6)}; it must be normalized`
|
|
1578
|
+
});
|
|
1579
|
+
}
|
|
1580
|
+
if (!(sample.far > sample.near)) {
|
|
1581
|
+
issues.push({
|
|
1582
|
+
path: ["samples", index, "far"],
|
|
1583
|
+
message: `frame ${index}: far (${sample.far}) must be greater than near (${sample.near})`
|
|
1584
|
+
});
|
|
1585
|
+
}
|
|
1586
|
+
for (const issue of scene3DProjectionIssues(
|
|
1587
|
+
sample.projectionMatrix,
|
|
1588
|
+
sample.near,
|
|
1589
|
+
sample.far,
|
|
1590
|
+
["samples", index, "projectionMatrix"]
|
|
1591
|
+
)) {
|
|
1592
|
+
issues.push(issue);
|
|
1593
|
+
}
|
|
1594
|
+
});
|
|
1595
|
+
return issues;
|
|
1596
|
+
}
|
|
1597
|
+
var scene3DCameraTrackSchema = scene3DCameraTrackObjectSchema.superRefine((track, ctx) => {
|
|
1598
|
+
for (const issue of scene3DCameraTrackIssues(track)) {
|
|
1599
|
+
ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
|
|
1600
|
+
}
|
|
1601
|
+
});
|
|
1602
|
+
function isScene3DCameraTrack(value) {
|
|
1603
|
+
return scene3DCameraTrackSchema.safeParse(value).success;
|
|
1604
|
+
}
|
|
1605
|
+
function scene3DCameraTrackPlanIssues(track, plan) {
|
|
1606
|
+
const issues = [];
|
|
1607
|
+
if (track.fps !== plan.fps) {
|
|
1608
|
+
issues.push({
|
|
1609
|
+
path: ["fps"],
|
|
1610
|
+
message: `camera track is ${track.fps} fps but the scene is ${plan.fps} fps; changing fps requires an explicit resample and a new revision`
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
1613
|
+
if (track.frameCount !== plan.durationInFrames) {
|
|
1614
|
+
issues.push({
|
|
1615
|
+
path: ["frameCount"],
|
|
1616
|
+
message: `camera track covers ${track.frameCount} frames but the scene is ${plan.durationInFrames} frames`
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1619
|
+
const expected = plan.height / plan.width;
|
|
1620
|
+
const tolerance = SCENE3D_CAMERA_TRACK_LIMITS.aspectRelativeTolerance;
|
|
1621
|
+
track.samples.forEach((sample, index) => {
|
|
1622
|
+
const m0 = sample.projectionMatrix[0];
|
|
1623
|
+
const m5 = sample.projectionMatrix[5];
|
|
1624
|
+
if (!Number.isFinite(m0) || !Number.isFinite(m5) || m5 === 0) return;
|
|
1625
|
+
const actual = m0 / m5;
|
|
1626
|
+
if (Math.abs(actual - expected) > expected * tolerance) {
|
|
1627
|
+
issues.push({
|
|
1628
|
+
path: ["samples", index, "projectionMatrix"],
|
|
1629
|
+
message: `frame ${index}: projection is baked for aspect ${(1 / actual).toPrecision(6)} but the scene renders ${plan.width}\xD7${plan.height}; reprojection requires a new revision`
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1632
|
+
});
|
|
1633
|
+
return issues;
|
|
1634
|
+
}
|
|
1635
|
+
function scene3DSampleForFrame(track, frame) {
|
|
1636
|
+
if (!Number.isInteger(frame) || frame < 0 || frame >= track.frameCount) return void 0;
|
|
1637
|
+
return track.samples[frame];
|
|
1638
|
+
}
|
|
1639
|
+
function parseScene3DCameraTrackJson(text) {
|
|
1640
|
+
const bytes = scene3DJsonByteLength(text);
|
|
1641
|
+
if (bytes > SCENE3D_CAMERA_TRACK_LIMITS.maxJsonBytes) {
|
|
1642
|
+
return {
|
|
1643
|
+
ok: false,
|
|
1644
|
+
issues: [
|
|
1645
|
+
{
|
|
1646
|
+
path: [],
|
|
1647
|
+
message: `camera track is ${bytes} bytes; the limit is ${SCENE3D_CAMERA_TRACK_LIMITS.maxJsonBytes}`
|
|
1648
|
+
}
|
|
1649
|
+
]
|
|
1650
|
+
};
|
|
1651
|
+
}
|
|
1652
|
+
let decoded;
|
|
1653
|
+
try {
|
|
1654
|
+
decoded = JSON.parse(text);
|
|
1655
|
+
} catch {
|
|
1656
|
+
return { ok: false, issues: [{ path: [], message: "camera track is not valid JSON" }] };
|
|
1657
|
+
}
|
|
1658
|
+
const parsed = scene3DCameraTrackSchema.safeParse(decoded);
|
|
1659
|
+
if (!parsed.success) {
|
|
1660
|
+
return { ok: false, issues: scene3DZodIssues(parsed.error) };
|
|
1661
|
+
}
|
|
1662
|
+
return { ok: true, value: parsed.data };
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
// src/scene3d-delivery-notes.ts
|
|
1666
|
+
var SCENE3D_AUTHORING_ASSUMPTION_CODE = "SCENE_AUTHORING_ASSUMPTION";
|
|
1667
|
+
var SCENE3D_REVIEW_REFUSED_CODE = "SCENE_REVIEW_REFUSED";
|
|
1668
|
+
var SCENE3D_REVIEW_UNAVAILABLE_CODE = "SCENE_REVIEW_UNAVAILABLE";
|
|
1669
|
+
var SCENE3D_REMEDY_AUTO_APPLIED_CODE = "REMEDY_AUTO_APPLIED";
|
|
1670
|
+
var SCENE3D_ASSERTION_RESTORED_CODE = "ASSERTION_RESTORED";
|
|
1671
|
+
var SCENE3D_REVIEW_UNAVAILABLE_REASONS = ["provider", "unusable"];
|
|
1672
|
+
function isScene3DReviewUnavailableReason(value) {
|
|
1673
|
+
return SCENE3D_REVIEW_UNAVAILABLE_REASONS.includes(value);
|
|
1674
|
+
}
|
|
1675
|
+
function scene3DReviewVerdictOf(output) {
|
|
1676
|
+
const review = output?.metadata?.review;
|
|
1677
|
+
if (typeof review !== "object" || review === null) return void 0;
|
|
1678
|
+
const candidate = review;
|
|
1679
|
+
if (candidate.verdict !== "refused" && candidate.verdict !== "unavailable") return void 0;
|
|
1680
|
+
const objections = (Array.isArray(candidate.objections) ? candidate.objections : []).flatMap((entry) => {
|
|
1681
|
+
if (typeof entry !== "object" || entry === null) return [];
|
|
1682
|
+
const objection = entry;
|
|
1683
|
+
if (typeof objection.what !== "string" || !objection.what) return [];
|
|
1684
|
+
const frames = (Array.isArray(objection.frames) ? objection.frames : []).filter((frame) => Number.isSafeInteger(frame) && frame >= 0);
|
|
1685
|
+
return [{
|
|
1686
|
+
category: typeof objection.category === "string" && objection.category ? objection.category : "unsupported",
|
|
1687
|
+
what: objection.what,
|
|
1688
|
+
...typeof objection.correction === "string" && objection.correction ? { correction: objection.correction } : {},
|
|
1689
|
+
frames
|
|
1690
|
+
}];
|
|
1691
|
+
});
|
|
1692
|
+
const findings = {
|
|
1693
|
+
objections,
|
|
1694
|
+
...typeof candidate.observed === "string" && candidate.observed ? { observed: candidate.observed } : {}
|
|
1695
|
+
};
|
|
1696
|
+
if (candidate.verdict === "refused") return { verdict: "refused", ...findings };
|
|
1697
|
+
const attempts = typeof candidate.attempts === "number" && Number.isSafeInteger(candidate.attempts) && candidate.attempts > 0 ? candidate.attempts : 1;
|
|
1698
|
+
const reason = isScene3DReviewUnavailableReason(candidate.reason) ? candidate.reason : "provider";
|
|
1699
|
+
return { verdict: "unavailable", reason, attempts, ...findings };
|
|
1700
|
+
}
|
|
1701
|
+
function scene3DReviewNote(verdict) {
|
|
1702
|
+
if (verdict.verdict === "unavailable") {
|
|
1703
|
+
const asked = verdict.attempts === 1 ? "one attempt" : `${verdict.attempts} attempts`;
|
|
1704
|
+
const partial = verdict.objections.length ? ` Part of the review did answer first, and its ${verdict.objections.length === 1 ? "one finding is" : `${verdict.objections.length} findings are`} listed \u2014 but they are not the whole verdict.` : "";
|
|
1705
|
+
const missing = verdict.reason === "unusable" ? `returned no usable verdict in ${asked}` : `did not reach its provider in ${asked}`;
|
|
1706
|
+
return `The scene built and every mandatory assertion passed, but the visual review ${missing}; it was delivered unreviewed.${partial}`;
|
|
1707
|
+
}
|
|
1708
|
+
const count = verdict.objections.length;
|
|
1709
|
+
if (!count) {
|
|
1710
|
+
return "The visual review refused this scene without naming anything to change; it was delivered anyway because every mandatory assertion passed.";
|
|
1711
|
+
}
|
|
1712
|
+
return `The visual review refused this scene on ${count === 1 ? "one finding" : `${count} findings`}; it was delivered anyway because every mandatory assertion passed.`;
|
|
1713
|
+
}
|
|
1714
|
+
var scene3DInputAssetSchema = z.object({
|
|
1715
|
+
id: z.string().regex(/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,63}$/),
|
|
1716
|
+
revisionId: z.uuid(),
|
|
1717
|
+
assetId: z.uuid(),
|
|
1718
|
+
label: z.string().min(1).max(64).regex(/^[^\u0000-\u001f]+$/).optional()
|
|
1719
|
+
}).strict();
|
|
1720
|
+
var scene3DInputAssetsSchema = z.array(scene3DInputAssetSchema).max(8).superRefine((values, ctx) => {
|
|
1721
|
+
if (new Set(values.map((value) => value.id)).size !== values.length || new Set(values.map((value) => value.assetId)).size !== values.length) {
|
|
1722
|
+
ctx.addIssue({ code: "custom", message: "Scene input assets must have unique identities" });
|
|
1723
|
+
}
|
|
1724
|
+
});
|
|
1725
|
+
function scene3DInputAssetsForEngine(value, engine) {
|
|
1726
|
+
const assets = scene3DInputAssetsSchema.parse(value ?? []);
|
|
1727
|
+
if (assets.length && engine !== "blender-cloud" && engine !== "blender-local") {
|
|
1728
|
+
throw new Error("Imported 3D assets require an advanced scene engine");
|
|
1729
|
+
}
|
|
1730
|
+
return assets;
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
// src/pro-3d-render.ts
|
|
1734
|
+
var PRO3D_RENDER_NODE_TYPE = "pro-3d-render";
|
|
1735
|
+
var PRO3D_RENDER_LABEL = "3D Render Pro";
|
|
1736
|
+
var PRO3D_RENDER_CREDIT_ID = "pro-3d-render";
|
|
1737
|
+
var PRO3D_RENDER_ENGINES = ["blender-cloud", "blender-local"];
|
|
1738
|
+
var PRO3D_RENDER_DEFAULT_ENGINE = "blender-cloud";
|
|
1739
|
+
var PRO3D_RENDER_QUALITY_PROFILES = ["standard"];
|
|
1740
|
+
var PRO3D_RENDER_DEFAULT_QUALITY = "standard";
|
|
1741
|
+
var PRO3D_RENDER_STYLES = ["clay"];
|
|
1742
|
+
var PRO3D_RENDER_DEFAULT_STYLE = "clay";
|
|
1743
|
+
var PRO3D_RENDER_MIN_REPAIR_PASSES = 0;
|
|
1744
|
+
var PRO3D_RENDER_MAX_REPAIR_PASSES = 2;
|
|
1745
|
+
var PRO3D_RENDER_DEFAULT_REPAIR_PASSES = 2;
|
|
1746
|
+
var PRO3D_RENDER_ASPECT_RATIOS = ["16:9", "9:16", "1:1", "4:5", "21:9"];
|
|
1747
|
+
var PRO3D_RENDER_PROMPT_MAX = 8e3;
|
|
1748
|
+
var PRO3D_RENDER_LIMITS = {
|
|
1749
|
+
promptMax: PRO3D_RENDER_PROMPT_MAX,
|
|
1750
|
+
editPromptMax: PRO3D_RENDER_PROMPT_MAX,
|
|
1751
|
+
minDurationSeconds: SCENE3D_LIMITS.minDurationSeconds,
|
|
1752
|
+
maxDurationSeconds: SCENE3D_LIMITS.maxDurationSeconds,
|
|
1753
|
+
minFps: SCENE3D_LIMITS.minFps,
|
|
1754
|
+
maxFps: SCENE3D_LIMITS.maxFps,
|
|
1755
|
+
maxReferences: SCENE3D_LIMITS.maxReferences,
|
|
1756
|
+
/** Opaque ids the caller echoes back (quote, export, connection). */
|
|
1757
|
+
maxIdLength: 200,
|
|
1758
|
+
/** `Idempotency-Key` bounds — the platform's floor, with a ceiling so an
|
|
1759
|
+
* unbounded header can never reach a lookup or a database column. */
|
|
1760
|
+
minIdempotencyKeyLength: 8,
|
|
1761
|
+
maxIdempotencyKeyLength: 255
|
|
1762
|
+
};
|
|
1763
|
+
var PRO3D_RENDER_SOURCE_KINDS = ["prompt", "scene", "local-export"];
|
|
1764
|
+
function isPro3DRenderRenderOnly(source) {
|
|
1765
|
+
return source.kind === "scene" && source.editPrompt === void 0;
|
|
1766
|
+
}
|
|
1767
|
+
function pro3DRenderProducedSchemaVersion(source) {
|
|
1768
|
+
return source.kind === "scene" ? null : 2;
|
|
1769
|
+
}
|
|
1770
|
+
var pro3DRenderQuoteSchema = z.object({
|
|
1771
|
+
quoteId: z.string().min(1),
|
|
1772
|
+
expiresAt: z.string().min(1),
|
|
1773
|
+
maxCredits: z.number(),
|
|
1774
|
+
breakdown: z.array(
|
|
1775
|
+
z.object({ code: z.string(), label: z.string(), credits: z.number() }).passthrough()
|
|
1776
|
+
),
|
|
1777
|
+
pricingVersion: z.string(),
|
|
1778
|
+
capabilitiesVersion: z.string(),
|
|
1779
|
+
normalizedInputHash: z.string().min(1)
|
|
1780
|
+
}).passthrough();
|
|
1781
|
+
function isPro3DRenderQuote(value) {
|
|
1782
|
+
return pro3DRenderQuoteSchema.safeParse(value).success;
|
|
1783
|
+
}
|
|
1784
|
+
var pro3DRenderReviewFindingsShape = {
|
|
1785
|
+
objections: z.array(
|
|
1786
|
+
z.object({
|
|
1787
|
+
category: z.string(),
|
|
1788
|
+
what: z.string(),
|
|
1789
|
+
correction: z.string().optional(),
|
|
1790
|
+
frames: z.array(z.number().int().min(0)).default([])
|
|
1791
|
+
}).passthrough()
|
|
1792
|
+
),
|
|
1793
|
+
observed: z.string().optional()
|
|
1794
|
+
};
|
|
1795
|
+
var pro3DRenderReviewVerdictSchema = z.union([
|
|
1796
|
+
z.object({ verdict: z.literal("refused"), ...pro3DRenderReviewFindingsShape }).passthrough(),
|
|
1797
|
+
z.object({
|
|
1798
|
+
verdict: z.literal("unavailable"),
|
|
1799
|
+
reason: z.enum(SCENE3D_REVIEW_UNAVAILABLE_REASONS).catch("provider"),
|
|
1800
|
+
attempts: z.number().int().min(1).catch(1),
|
|
1801
|
+
...pro3DRenderReviewFindingsShape
|
|
1802
|
+
}).passthrough()
|
|
1803
|
+
]);
|
|
1804
|
+
var pro3DRenderShotStillSchema = z.object({
|
|
1805
|
+
shotIndex: z.number().int().min(0),
|
|
1806
|
+
frame: z.number().int().min(0),
|
|
1807
|
+
assetId: z.string().min(1),
|
|
1808
|
+
url: z.string().min(1)
|
|
1809
|
+
}).passthrough();
|
|
1810
|
+
var pro3DRenderJobOutputSchema = z.object({
|
|
1811
|
+
videoUrl: z.string().min(1),
|
|
1812
|
+
scenePlan: scene3DAnyPlanSchema,
|
|
1813
|
+
sceneRevisionId: z.string().min(1),
|
|
1814
|
+
posterAssetId: z.string().min(1),
|
|
1815
|
+
shotStills: z.array(pro3DRenderShotStillSchema).optional(),
|
|
1816
|
+
sourceArtifactId: z.string().min(1).optional(),
|
|
1817
|
+
validation: z.object({
|
|
1818
|
+
status: z.literal("passed"),
|
|
1819
|
+
reportAssetId: z.string().min(1),
|
|
1820
|
+
warnings: z.array(
|
|
1821
|
+
z.object({
|
|
1822
|
+
code: z.string(),
|
|
1823
|
+
message: z.string(),
|
|
1824
|
+
shotId: z.string().optional()
|
|
1825
|
+
}).passthrough()
|
|
1826
|
+
)
|
|
1827
|
+
}).passthrough(),
|
|
1828
|
+
renderer: z.string().min(1),
|
|
1829
|
+
metadata: z.object({
|
|
1830
|
+
width: z.number().int().positive(),
|
|
1831
|
+
height: z.number().int().positive(),
|
|
1832
|
+
fps: z.number().positive(),
|
|
1833
|
+
frames: z.number().int().positive(),
|
|
1834
|
+
duration: z.number().positive(),
|
|
1835
|
+
summary: z.string().optional(),
|
|
1836
|
+
/**
|
|
1837
|
+
* Degrades to absent rather than refusing the RESULT, which is the whole lesson of the
|
|
1838
|
+
* verdict this round added. A narrow `verdict` here did not merely mis-read an unreviewed
|
|
1839
|
+
* delivery — it failed `isPro3DRenderJobOutput` for the entire job, blanking a real,
|
|
1840
|
+
* paid, playable MP4 over an advisory field. A verdict a future engine invents must cost
|
|
1841
|
+
* at most itself; the `SCENE_REVIEW_*` entry in `validation.warnings[]` still arrives
|
|
1842
|
+
* either way, because that array has no code enum.
|
|
1843
|
+
*/
|
|
1844
|
+
review: pro3DRenderReviewVerdictSchema.optional().catch(void 0)
|
|
1845
|
+
}).passthrough(),
|
|
1846
|
+
repairPasses: z.number().int().min(0).optional(),
|
|
1847
|
+
admissionRetries: z.number().int().min(0).optional(),
|
|
1848
|
+
mechanicalPasses: z.number().int().min(0).optional(),
|
|
1849
|
+
// Tolerant like the review verdict above, and for the same reason: this rides a result that
|
|
1850
|
+
// already has a real MP4, so a malformed entry must never blank a video the platform rendered
|
|
1851
|
+
// and charged for. The identity fields are required because an entry without them names
|
|
1852
|
+
// nothing; `value` is unknown because a restored assertion holds whatever it holds.
|
|
1853
|
+
restoredAssertions: z.array(
|
|
1854
|
+
z.object({
|
|
1855
|
+
op: z.string(),
|
|
1856
|
+
path: z.string(),
|
|
1857
|
+
value: z.unknown().optional(),
|
|
1858
|
+
assertionId: z.string(),
|
|
1859
|
+
reason: z.string()
|
|
1860
|
+
}).passthrough()
|
|
1861
|
+
).optional(),
|
|
1862
|
+
changeSummary: z.string().optional()
|
|
1863
|
+
}).passthrough();
|
|
1864
|
+
function isPro3DRenderJobOutput(value) {
|
|
1865
|
+
return pro3DRenderJobOutputSchema.safeParse(value).success;
|
|
1866
|
+
}
|
|
1867
|
+
function pro3DRenderShotStills(output) {
|
|
1868
|
+
const list = output?.shotStills;
|
|
1869
|
+
if (!Array.isArray(list)) return [];
|
|
1870
|
+
const parsed = list.flatMap((entry) => {
|
|
1871
|
+
const result = pro3DRenderShotStillSchema.safeParse(entry);
|
|
1872
|
+
return result.success ? [{
|
|
1873
|
+
shotIndex: result.data.shotIndex,
|
|
1874
|
+
frame: result.data.frame,
|
|
1875
|
+
assetId: result.data.assetId,
|
|
1876
|
+
url: result.data.url
|
|
1877
|
+
}] : [];
|
|
1878
|
+
});
|
|
1879
|
+
return parsed.sort((a, b) => a.shotIndex - b.shotIndex);
|
|
1880
|
+
}
|
|
1881
|
+
var pro3DRenderCoreOutputSchema = z.object({
|
|
1882
|
+
videoUrl: z.string().min(1),
|
|
1883
|
+
scenePlan: scene3DAnyPlanSchema
|
|
1884
|
+
}).passthrough();
|
|
1885
|
+
function buildPro3DRenderSource(input) {
|
|
1886
|
+
if (input.sourceMode === "scene") {
|
|
1887
|
+
const revisionId = input.revisionId?.trim();
|
|
1888
|
+
const sourceJobId = input.sourceJobId?.trim();
|
|
1889
|
+
if (!revisionId) {
|
|
1890
|
+
return { ok: false, message: "no scene to render \u2014 wire a 3D scene in, or run this node once." };
|
|
1891
|
+
}
|
|
1892
|
+
const editPrompt = input.editPrompt?.trim();
|
|
1893
|
+
return {
|
|
1894
|
+
ok: true,
|
|
1895
|
+
source: { kind: "scene", revisionId, ...sourceJobId ? { sourceJobId } : {}, ...editPrompt ? { editPrompt } : {} }
|
|
1896
|
+
};
|
|
1897
|
+
}
|
|
1898
|
+
const prompt = input.prompt?.trim();
|
|
1899
|
+
if (!prompt) {
|
|
1900
|
+
return { ok: false, message: "no brief \u2014 describe the scene, or wire a prompt in." };
|
|
1901
|
+
}
|
|
1902
|
+
const references = input.references ?? [];
|
|
1903
|
+
const parsedAssets = scene3DInputAssetsSchema.safeParse(input.inputAssets ?? []);
|
|
1904
|
+
if (!parsedAssets.success) return { ok: false, message: "invalid scene input assets" };
|
|
1905
|
+
return {
|
|
1906
|
+
ok: true,
|
|
1907
|
+
source: {
|
|
1908
|
+
kind: "prompt",
|
|
1909
|
+
prompt,
|
|
1910
|
+
...references.length > 0 ? { references } : {},
|
|
1911
|
+
...parsedAssets.data.length ? { inputAssets: parsedAssets.data } : {}
|
|
1912
|
+
}
|
|
1913
|
+
};
|
|
1914
|
+
}
|
|
1915
|
+
function pro3DRenderTimingOverrides(input) {
|
|
1916
|
+
if (input.source.kind === "scene" && !input.overrideSourceTiming) return {};
|
|
1917
|
+
const out = {};
|
|
1918
|
+
if (typeof input.durationSeconds === "number") out.durationSeconds = input.durationSeconds;
|
|
1919
|
+
if (typeof input.fps === "number") out.fps = input.fps;
|
|
1920
|
+
if (typeof input.aspectRatio === "string") out.aspectRatio = input.aspectRatio;
|
|
1921
|
+
return out;
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
// src/scene3d-render-pricing.ts
|
|
1925
|
+
var SCENE3D_RENDER_TIERS = ["base", "large", "xlarge"];
|
|
1926
|
+
var SCENE3D_RENDER_BASE_MAX_PX = 1920;
|
|
1927
|
+
var SCENE3D_RENDER_XLARGE_MIN_AREA_PX = 512e4;
|
|
1928
|
+
var SCENE3D_RENDER_TIER_MULTIPLIERS = {
|
|
1929
|
+
base: 1,
|
|
1930
|
+
large: 1.5,
|
|
1931
|
+
xlarge: 2.5
|
|
1932
|
+
};
|
|
1933
|
+
function scene3DRenderTier(width, height) {
|
|
1934
|
+
const w = typeof width === "number" && Number.isFinite(width) && width > 0 ? width : 0;
|
|
1935
|
+
const h = typeof height === "number" && Number.isFinite(height) && height > 0 ? height : 0;
|
|
1936
|
+
if (w === 0 || h === 0) return "base";
|
|
1937
|
+
if (Math.max(w, h) <= SCENE3D_RENDER_BASE_MAX_PX) return "base";
|
|
1938
|
+
return w * h > SCENE3D_RENDER_XLARGE_MIN_AREA_PX ? "xlarge" : "large";
|
|
1939
|
+
}
|
|
1940
|
+
function scene3DRenderTierCredits(baseCredits, tier) {
|
|
1941
|
+
return Math.ceil(baseCredits * SCENE3D_RENDER_TIER_MULTIPLIERS[tier]);
|
|
1942
|
+
}
|
|
1943
|
+
var RENDER_VIDEO_CREDIT_ID = "render-video";
|
|
1944
|
+
function renderVideoCreditId(input) {
|
|
1945
|
+
if (!input || typeof input !== "object") return RENDER_VIDEO_CREDIT_ID;
|
|
1946
|
+
const body = input;
|
|
1947
|
+
if (body.planType !== SCENE3D_PLAN_TYPE) return RENDER_VIDEO_CREDIT_ID;
|
|
1948
|
+
if (!body.plan || typeof body.plan !== "object") return RENDER_VIDEO_CREDIT_ID;
|
|
1949
|
+
const plan = body.plan;
|
|
1950
|
+
const tier = scene3DRenderTier(plan.width, plan.height);
|
|
1951
|
+
return tier === "base" ? RENDER_VIDEO_CREDIT_ID : `${RENDER_VIDEO_CREDIT_ID}:3d-${tier}`;
|
|
1952
|
+
}
|
|
1953
|
+
function pro3DRenderFrameUnit(quality, tier = "base") {
|
|
1954
|
+
const unit = `${PRO3D_RENDER_CREDIT_ID}:render-frame:${quality}`;
|
|
1955
|
+
return tier === "base" ? unit : `${unit}:${tier}`;
|
|
1956
|
+
}
|
|
1957
|
+
var scene3DV2OverrideInputSchema = z.discriminatedUnion("kind", [
|
|
1958
|
+
z.object({
|
|
1959
|
+
kind: z.literal("entity-transform"),
|
|
1960
|
+
entityId: scene3DIdSchema,
|
|
1961
|
+
space: z.enum(["local", "world"]),
|
|
1962
|
+
position: vec3Schema.optional(),
|
|
1963
|
+
rotation: rotationVec3Schema.optional(),
|
|
1964
|
+
scale: scaleVec3Schema.optional()
|
|
1965
|
+
}).strict(),
|
|
1966
|
+
z.object({
|
|
1967
|
+
kind: z.literal("entity-color"),
|
|
1968
|
+
entityId: scene3DIdSchema,
|
|
1969
|
+
materialRole: scene3DMaterialRoleSchema,
|
|
1970
|
+
color: scene3DColorSchema
|
|
1971
|
+
}).strict(),
|
|
1972
|
+
z.object({ kind: z.literal("entity-visibility"), entityId: scene3DIdSchema, visible: z.boolean() }).strict(),
|
|
1973
|
+
z.object({
|
|
1974
|
+
kind: z.literal("camera-shot-offset"),
|
|
1975
|
+
shotId: scene3DIdSchema,
|
|
1976
|
+
positionOffset: vec3Schema.optional(),
|
|
1977
|
+
targetOffset: vec3Schema.optional()
|
|
1978
|
+
}).strict()
|
|
1979
|
+
]);
|
|
1980
|
+
var scene3DV2EditOperationSchema = z.discriminatedUnion("op", [
|
|
1981
|
+
z.object({ op: z.literal("set-override"), override: scene3DV2OverrideInputSchema }).strict(),
|
|
1982
|
+
z.object({ op: z.literal("remove-override"), overrideId: scene3DIdSchema }).strict()
|
|
1983
|
+
]);
|
|
1984
|
+
var scene3DV2EditOperationsSchema = z.array(scene3DV2EditOperationSchema).min(1).max(100);
|
|
1985
|
+
function channel(override) {
|
|
1986
|
+
switch (override.kind) {
|
|
1987
|
+
case "entity-transform":
|
|
1988
|
+
return `transform:${override.entityId}`;
|
|
1989
|
+
case "entity-color":
|
|
1990
|
+
return `color:${override.entityId}:${override.materialRole}`;
|
|
1991
|
+
case "entity-visibility":
|
|
1992
|
+
return `visibility:${override.entityId}`;
|
|
1993
|
+
case "camera-shot-offset":
|
|
1994
|
+
return `camera:${override.shotId}`;
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
function capability(override) {
|
|
1998
|
+
switch (override.kind) {
|
|
1999
|
+
case "entity-transform":
|
|
2000
|
+
return "transform";
|
|
2001
|
+
case "entity-color":
|
|
2002
|
+
return "color";
|
|
2003
|
+
case "entity-visibility":
|
|
2004
|
+
return "visibility";
|
|
2005
|
+
case "camera-shot-offset":
|
|
2006
|
+
return null;
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
function lockIssue(plan, override, externalLocks) {
|
|
2010
|
+
if (override.kind === "camera-shot-offset") return null;
|
|
2011
|
+
const target = plan.objects.find((o) => o.id === override.entityId);
|
|
2012
|
+
if (!target) return `Unknown entity: ${override.entityId}`;
|
|
2013
|
+
const cap = capability(override);
|
|
2014
|
+
if (target.capabilities && !target.capabilities.includes(cap)) return `Entity ${target.id} does not allow ${cap} edits`;
|
|
2015
|
+
if (externalLocks.has(target.id) || target.locks?.includes(cap)) return `Entity ${target.id} is locked for ${cap}`;
|
|
2016
|
+
if (cap !== "transform" && cap !== "visibility") return null;
|
|
2017
|
+
const byId = new Map(plan.objects.map((entity) => [entity.id, entity]));
|
|
2018
|
+
for (const entity of plan.objects) {
|
|
2019
|
+
if (!externalLocks.has(entity.id) && !entity.locks?.includes(cap)) continue;
|
|
2020
|
+
let parent = entity.parentId;
|
|
2021
|
+
while (parent) {
|
|
2022
|
+
if (parent === target.id) return `Changing ${target.id} would change locked descendant ${entity.id}`;
|
|
2023
|
+
parent = byId.get(parent)?.parentId;
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
return null;
|
|
2027
|
+
}
|
|
2028
|
+
async function applyScene3DV2EditOperations(input, operations, options) {
|
|
2029
|
+
const parsed = scene3DPlanV2Schema.safeParse(input);
|
|
2030
|
+
if (!parsed.success) return { ok: false, code: "invalid_plan", message: parsed.error.issues[0]?.message ?? "Invalid scene" };
|
|
2031
|
+
const base = parsed.data;
|
|
2032
|
+
if (base.revisionId !== options.expectedRevisionId || options.expectedContentHash !== void 0 && base.provenance.contentHash !== options.expectedContentHash) {
|
|
2033
|
+
return { ok: false, code: "stale_revision", message: "The scene changed since this edit was prepared" };
|
|
2034
|
+
}
|
|
2035
|
+
if (!await verifyScene3DPlanV2ContentHash(base)) {
|
|
2036
|
+
return { ok: false, code: "invalid_plan", message: "The scene content does not match its digest" };
|
|
2037
|
+
}
|
|
2038
|
+
const ops = scene3DV2EditOperationsSchema.safeParse(operations);
|
|
2039
|
+
if (!ops.success) return { ok: false, code: "invalid_operations", message: ops.error.issues[0]?.message ?? "Invalid edit" };
|
|
2040
|
+
const revisionId = options.newRevisionId ?? newScene3DRevisionId();
|
|
2041
|
+
if (revisionId === base.revisionId) return { ok: false, code: "invalid_operations", message: "An edit requires a new revision identity" };
|
|
2042
|
+
const externalLocks = new Set(options.lockedObjectIds ?? []);
|
|
2043
|
+
for (const id of externalLocks) {
|
|
2044
|
+
if (!base.objects.some((entity) => entity.id === id)) return { ok: false, code: "invalid_operations", message: `Unknown locked entity: ${id}` };
|
|
2045
|
+
}
|
|
2046
|
+
let overrides = [...base.overrides ?? []];
|
|
2047
|
+
for (const [index, operation] of ops.data.entries()) {
|
|
2048
|
+
if (operation.op === "remove-override") {
|
|
2049
|
+
const existing = overrides.find((override) => override.id === operation.overrideId);
|
|
2050
|
+
if (!existing) return { ok: false, code: "invalid_operations", message: `Unknown override: ${operation.overrideId}` };
|
|
2051
|
+
const issue2 = lockIssue(base, existing, externalLocks);
|
|
2052
|
+
if (issue2) return { ok: false, code: "locked", message: issue2 };
|
|
2053
|
+
overrides = overrides.filter((override) => override.id !== existing.id);
|
|
2054
|
+
continue;
|
|
2055
|
+
}
|
|
2056
|
+
const issue = lockIssue(base, operation.override, externalLocks);
|
|
2057
|
+
if (issue) return { ok: false, code: "locked", message: issue };
|
|
2058
|
+
const previous = overrides.find((override) => channel(override) === channel(operation.override));
|
|
2059
|
+
const compatible = previous && (previous.kind !== "entity-transform" || operation.override.kind === "entity-transform" && previous.space === operation.override.space);
|
|
2060
|
+
const next2 = {
|
|
2061
|
+
...compatible ? previous : {},
|
|
2062
|
+
...operation.override,
|
|
2063
|
+
id: `edit-${revisionId}-${index}`,
|
|
2064
|
+
sourceRevisionId: base.revisionId,
|
|
2065
|
+
sourceContentHash: base.provenance.contentHash,
|
|
2066
|
+
operationVersion: SCENE3D_V2_OVERRIDE_OPERATION_VERSION
|
|
2067
|
+
};
|
|
2068
|
+
const key = channel(next2);
|
|
2069
|
+
overrides = [...overrides.filter((override) => channel(override) !== key), next2];
|
|
2070
|
+
}
|
|
2071
|
+
const { sourceArtifactId: _sourceArtifactId, ...provenance } = base.provenance;
|
|
2072
|
+
const next = {
|
|
2073
|
+
...base,
|
|
2074
|
+
revisionId,
|
|
2075
|
+
parentRevisionId: base.revisionId,
|
|
2076
|
+
// Geometry and cameras are reused; derived images, validation and native
|
|
2077
|
+
// exports describe the old revision until regenerated for these overlays.
|
|
2078
|
+
assets: base.assets.filter((asset) => asset.kind === "glb" || asset.kind === "camera-track-json").map((asset) => ({
|
|
2079
|
+
...asset,
|
|
2080
|
+
originRevisionId: asset.originRevisionId ?? base.revisionId
|
|
2081
|
+
})),
|
|
2082
|
+
overrides,
|
|
2083
|
+
provenance: { ...provenance, sourceRevisionId: base.revisionId }
|
|
2084
|
+
};
|
|
2085
|
+
const validated = scene3DPlanV2Schema.safeParse(next);
|
|
2086
|
+
if (!validated.success) return { ok: false, code: "invalid_operations", message: validated.error.issues[0]?.message ?? "Invalid edited scene" };
|
|
2087
|
+
const plan = validated.data;
|
|
2088
|
+
const contentHash = await computeScene3DPlanV2ContentHash(plan);
|
|
2089
|
+
return { ok: true, plan: { ...plan, provenance: { ...plan.provenance, contentHash } }, changeSummary: `Applied ${ops.data.length} scene edit${ops.data.length === 1 ? "" : "s"}` };
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
// src/scene3d-authoring-engine.ts
|
|
2093
|
+
var SCENE3D_BASIC_ENGINE = "basic";
|
|
2094
|
+
var SCENE3D_AUTHORING_ENGINES = [SCENE3D_BASIC_ENGINE, ...SCENE3D_V2_ENGINES];
|
|
2095
|
+
var SCENE3D_DEFAULT_ADVANCED_ENGINE = "blender-cloud";
|
|
2096
|
+
function isScene3DAuthoringEngine(value) {
|
|
2097
|
+
return typeof value === "string" && SCENE3D_AUTHORING_ENGINES.includes(value);
|
|
2098
|
+
}
|
|
2099
|
+
function advancedFields(engine) {
|
|
2100
|
+
return { engine, acceptedSceneSchemaVersions: [...SCENE3D_SUPPORTED_SCHEMA_VERSIONS] };
|
|
2101
|
+
}
|
|
2102
|
+
function serves(available, engine) {
|
|
2103
|
+
return available === void 0 || available.includes(engine);
|
|
2104
|
+
}
|
|
2105
|
+
function planAuthoringEngine(plan) {
|
|
2106
|
+
const provenance = plan?.provenance;
|
|
2107
|
+
const engine = provenance?.engine;
|
|
2108
|
+
return typeof engine === "string" && isKnownScene3DEngine(engine) ? engine : void 0;
|
|
2109
|
+
}
|
|
2110
|
+
function resolveScene3DAuthoringEngine(input) {
|
|
2111
|
+
const requested = typeof input.requested === "string" && input.requested.trim() !== "" ? input.requested.trim() : void 0;
|
|
2112
|
+
if (requested !== void 0 && !isScene3DAuthoringEngine(requested)) {
|
|
2113
|
+
return {
|
|
2114
|
+
ok: false,
|
|
2115
|
+
code: "unknown_engine",
|
|
2116
|
+
message: `"${requested}" is not a 3D authoring engine \u2014 choose Basic, or an advanced engine this install offers.`
|
|
2117
|
+
};
|
|
2118
|
+
}
|
|
2119
|
+
const version = input.plan === void 0 ? void 0 : scene3DPlanSchemaVersion(input.plan);
|
|
2120
|
+
if (version !== void 0 && version !== null && !SCENE3D_SUPPORTED_SCHEMA_VERSIONS.includes(version)) {
|
|
2121
|
+
return {
|
|
2122
|
+
ok: false,
|
|
2123
|
+
code: "unsupported_schema_version",
|
|
2124
|
+
message: `This scene uses schema version ${version}, which this version of Nodaro cannot edit.`
|
|
2125
|
+
};
|
|
2126
|
+
}
|
|
2127
|
+
const isV2 = version === SCENE3D_SCHEMA_VERSION_V2;
|
|
2128
|
+
if (isV2) {
|
|
2129
|
+
if (requested === SCENE3D_BASIC_ENGINE) {
|
|
2130
|
+
return {
|
|
2131
|
+
ok: false,
|
|
2132
|
+
code: "schema_requires_advanced",
|
|
2133
|
+
message: "This scene was authored by an advanced engine (schema v2) and cannot be edited on the Basic engine \u2014 switch this node's engine to the advanced one."
|
|
2134
|
+
};
|
|
2135
|
+
}
|
|
2136
|
+
if (requested !== void 0) {
|
|
2137
|
+
return serves(input.availableEngines, requested) ? { ok: true, lane: "advanced", engine: requested, fields: advancedFields(requested) } : unavailable(requested);
|
|
2138
|
+
}
|
|
2139
|
+
const preferred = [];
|
|
2140
|
+
const authored = planAuthoringEngine(input.plan);
|
|
2141
|
+
if (authored) preferred.push(authored);
|
|
2142
|
+
if (!preferred.includes(SCENE3D_DEFAULT_ADVANCED_ENGINE)) preferred.push(SCENE3D_DEFAULT_ADVANCED_ENGINE);
|
|
2143
|
+
const engine2 = preferred.find((candidate) => serves(input.availableEngines, candidate));
|
|
2144
|
+
if (!engine2) {
|
|
2145
|
+
return {
|
|
2146
|
+
ok: false,
|
|
2147
|
+
code: "advanced_unavailable",
|
|
2148
|
+
message: "This scene needs an advanced 3D engine to edit, and this install does not have one available."
|
|
2149
|
+
};
|
|
2150
|
+
}
|
|
2151
|
+
return { ok: true, lane: "advanced", engine: engine2, fields: advancedFields(engine2) };
|
|
2152
|
+
}
|
|
2153
|
+
if (requested === void 0 || requested === SCENE3D_BASIC_ENGINE) {
|
|
2154
|
+
return { ok: true, lane: "basic", engine: void 0, fields: {} };
|
|
2155
|
+
}
|
|
2156
|
+
const engine = requested;
|
|
2157
|
+
if (!serves(input.availableEngines, engine)) return unavailable(engine);
|
|
2158
|
+
return { ok: true, lane: "advanced", engine, fields: advancedFields(engine) };
|
|
2159
|
+
}
|
|
2160
|
+
function unavailable(engine) {
|
|
2161
|
+
return {
|
|
2162
|
+
ok: false,
|
|
2163
|
+
code: "engine_unavailable",
|
|
2164
|
+
message: `The "${engine}" 3D authoring engine is not available on this install.`
|
|
2165
|
+
};
|
|
2166
|
+
}
|
|
2167
|
+
var SCENE3D_BASIC_SCHEMA_VERSION = SCENE3D_SCHEMA_VERSION;
|
|
2168
|
+
|
|
2169
|
+
export { PRO3D_RENDER_ASPECT_RATIOS, PRO3D_RENDER_CREDIT_ID, PRO3D_RENDER_DEFAULT_ENGINE, PRO3D_RENDER_DEFAULT_QUALITY, PRO3D_RENDER_DEFAULT_REPAIR_PASSES, PRO3D_RENDER_DEFAULT_STYLE, PRO3D_RENDER_ENGINES, PRO3D_RENDER_LABEL, PRO3D_RENDER_LIMITS, PRO3D_RENDER_MAX_REPAIR_PASSES, PRO3D_RENDER_MIN_REPAIR_PASSES, PRO3D_RENDER_NODE_TYPE, PRO3D_RENDER_PROMPT_MAX, PRO3D_RENDER_QUALITY_PROFILES, PRO3D_RENDER_SOURCE_KINDS, PRO3D_RENDER_STYLES, RENDER_VIDEO_CREDIT_ID, SCENE3D_ASSERTION_RESTORED_CODE, SCENE3D_ASSET_KINDS, SCENE3D_ASSET_ROLES, SCENE3D_ASSET_ROLE_KINDS, SCENE3D_AUTHORING_ASSUMPTION_CODE, SCENE3D_AUTHORING_ENGINES, SCENE3D_BASIC_ENGINE, SCENE3D_BASIC_SCHEMA_VERSION, SCENE3D_CAMERA_TRACK_FORMAT, SCENE3D_CAMERA_TRACK_LIMITS, SCENE3D_CAMERA_TRACK_VERSION, SCENE3D_CLAY_LIGHTING_PRESETS, SCENE3D_DEFAULT_ADVANCED_ENGINE, SCENE3D_DEFAULT_DURATION_SECONDS, SCENE3D_DEFAULT_ENTITY_CAPABILITIES, SCENE3D_DEFAULT_FPS, SCENE3D_EDIT_NODE_TYPE, SCENE3D_ENTITY_CAPABILITIES, SCENE3D_ENTITY_ROLES, SCENE3D_GENERATE_NODE_TYPE, SCENE3D_GLB_EXTRAS_ALLOWLIST, SCENE3D_GLB_EXTRAS_ENTITY_ID, SCENE3D_GLB_EXTRAS_MATERIAL_ROLE, SCENE3D_GLB_EXTRAS_SUBPART_ID, SCENE3D_LIMITS, SCENE3D_PLAN_FIELD, SCENE3D_PLAN_TYPE, SCENE3D_PRIMITIVES, SCENE3D_PRIMITIVE_MATERIAL_ROLE, SCENE3D_REMEDY_AUTO_APPLIED_CODE, SCENE3D_RENDERER_ASSET_KINDS, SCENE3D_RENDER_BASE_MAX_PX, SCENE3D_RENDER_TIERS, SCENE3D_RENDER_TIER_MULTIPLIERS, SCENE3D_RENDER_XLARGE_MIN_AREA_PX, SCENE3D_REVIEW_REFUSED_CODE, SCENE3D_REVIEW_UNAVAILABLE_CODE, SCENE3D_REVIEW_UNAVAILABLE_REASONS, SCENE3D_SCHEMA_VERSION, SCENE3D_SCHEMA_VERSION_V2, SCENE3D_SUPPORTED_SCHEMA_VERSIONS, SCENE3D_V2_CONTENT_HASH_EXCLUDED, SCENE3D_V2_ENGINES, SCENE3D_V2_LIMITS, SCENE3D_V2_OVERRIDE_OPERATION_VERSION, SCENE3D_V2_PRIMITIVES, applyScene3DEditOperations, applyScene3DV2EditOperations, buildPro3DRenderSource, canonicalScene3DPlanV2Json, computeScene3DPlanV2ContentHash, isKnownScene3DEngine, isPro3DRenderJobOutput, isPro3DRenderQuote, isPro3DRenderRenderOnly, isScene3DAuthoringEngine, isScene3DCameraTrack, isScene3DHttpUrl, isScene3DPlan, isScene3DPlanV1, isScene3DPlanV2, isScene3DReviewUnavailableReason, isScene3DSchemaVersionSupported, newScene3DRevisionId, parseScene3DCameraTrackJson, parseScene3DPlanV2Json, pro3DRenderCoreOutputSchema, pro3DRenderFrameUnit, pro3DRenderJobOutputSchema, pro3DRenderProducedSchemaVersion, pro3DRenderQuoteSchema, pro3DRenderReviewVerdictSchema, pro3DRenderShotStillSchema, pro3DRenderShotStills, pro3DRenderTimingOverrides, renderVideoCreditId, resolveScene3DAuthoringEngine, rotationVec3Schema, scaleVec3Schema, scene3DAcceptedSchemaVersionsSchema, scene3DAnchorNameSchema, scene3DAnchorSchema, scene3DAnyPlanSchema, scene3DAssetAnimationSchema, scene3DAssetIdSchema, scene3DAssetRefSchema, scene3DCameraChangesSchema, scene3DCameraKeyframeSchema, scene3DCameraSampleSchema, scene3DCameraSchema, scene3DCameraTrackIssues, scene3DCameraTrackObjectSchema, scene3DCameraTrackPlanIssues, scene3DCameraTrackSchema, scene3DClayLightingSchema, scene3DColorSchema, scene3DDeepEqual, scene3DEasingSchema, scene3DEditOperationSchema, scene3DEditOperationsSchema, scene3DEngineIdSchema, scene3DEntityAcceptsOverlay, scene3DEntityCapabilitySchema, scene3DEntityV2Schema, scene3DEntityVisualSchema, scene3DIdSchema, scene3DInputAssetSchema, scene3DInputAssetsForEngine, scene3DInputAssetsSchema, scene3DJsonByteLength, scene3DLightingChangesSchema, scene3DLightingSchema, scene3DMaterialBindingSchema, scene3DMaterialNameSchema, scene3DMaterialRoleSchema, scene3DNodeIdSchema, scene3DNodeNameSchema, scene3DObjectChangesSchema, scene3DObjectKeyframeSchema, scene3DObjectSchema, scene3DOverrideSchema, scene3DPlanIssues, scene3DPlanSchema, scene3DPlanSchemaVersion, scene3DPlanV1Issues, scene3DPlanV1ObjectSchema, scene3DPlanV1Schema, scene3DPlanV2Issues, scene3DPlanV2ObjectSchema, scene3DPlanV2Schema, scene3DPrimitiveSchema, scene3DProjectionIssues, scene3DProvenanceSchema, scene3DReferenceSchema, scene3DRenderTier, scene3DRenderTierCredits, scene3DReviewNote, scene3DReviewVerdictOf, scene3DSampleForFrame, scene3DSha256Schema, scene3DShotForFrame, scene3DShotIndexForFrame, scene3DShotSchema, scene3DUrlSchema, scene3DV2AdmissionIssues, scene3DV2EditOperationSchema, scene3DV2EditOperationsSchema, scene3DV2HierarchyDepth, scene3DV2NormalizationIssues, scene3DV2OverrideInputSchema, scene3DV2ResourceUsage, scene3DVersionTokenSchema, scene3DZodIssues, sizeVec3Schema, summarizeScene3DOperations, vec3Schema, verifyScene3DPlanV2ContentHash };
|
|
2170
|
+
//# sourceMappingURL=chunk-AINCI23X.js.map
|
|
2171
|
+
//# sourceMappingURL=chunk-AINCI23X.js.map
|