Repository navigation
[feat] web: import self-contained 3D models into the stage #329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
8528e1c
11e8b2a
b87df1b
2e4f5e2
f1d1db4
282d4fd
879b45a
b8ba4bf
0eff527
9300d9b
5d35292
1fcf15e
4c5eb6d
94b454b
b8299f4
d616107
c124800
92dbe1e
3e7188d
bc1f5a5
e0ef6a2
d4fde9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,10 +7,12 @@ | |
| from .assets import Asset, AssetRef | ||
| from .base import Contract, NonNegative, ObjectVersion, Point, ProjectEntity, Revision, unique | ||
| from .canvas import CanvasItem, EditorBinding, GenerationBinding, MaterialBinding, MediaCanvasItem | ||
| from .editors import EditorDocument, MediaEditDocument, LayerDocument, StackDocument, SubjectDocument, TimelineDocument | ||
| from .editors import DirectorDocument, EditorDocument, MediaEditDocument, LayerDocument, StackDocument, SubjectDocument, TimelineDocument | ||
| from .generation import FollowingReference, GenerationSpec, Job, PromptReference, Reference, ResultVersion | ||
| from ..rule_facts import TIMELINE_DURATION_EPSILON | ||
|
|
||
| STAGE_MODEL_MIME = {'glb': 'model/gltf-binary', 'gltf': 'model/gltf+json'} | ||
|
|
||
|
|
||
| class Project(Contract): | ||
| id: UUID = Field(description='Stable object ID.') | ||
|
|
@@ -81,7 +83,7 @@ def project_relations(self): | |
| for ref in asset_references(objects): | ||
| asset = assets.get(ref.assetId) | ||
| if asset is None or ref.revision > asset.revision or ref.fingerprint != asset.fingerprint or ref.kind != asset.kind: | ||
| raise ValueError('Missing or inconsistent pinned asset reference') | ||
| raise ValueError('Missing or inconsistent pinned asset reference. 缺失或不一致的固定素材引用。') | ||
| parents = {} | ||
| for item in self.canvasItems: | ||
| if item.parentId: | ||
|
|
@@ -208,6 +210,17 @@ def project_relations(self): | |
| duration = asset.metadata.durationSeconds | ||
| if asset.kind != 'image' and duration is not None and clip.outPoint > duration + TIMELINE_DURATION_EPSILON: | ||
| raise ValueError('时间线片段超过素材的实际时长。') | ||
| if isinstance(doc, DirectorDocument): | ||
| for obj in doc.data.objects: | ||
| if obj.kind == 'gltf': | ||
| asset = assets[obj.asset.assetId] | ||
| if asset.metadata.mimeType != STAGE_MODEL_MIME[obj.format] or asset.metadata.selfContained is not True: | ||
| raise ValueError('Imported stage objects require a matching self-contained GLB or GLTF asset. 导入的舞台对象需要匹配的自包含 GLB 或 GLTF 素材。') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For HTTP AGENTS.md reference: AGENTS.md:L86-L89 Useful? React with 👍 / 👎. |
||
| # Animation metadata is attested by the client; verify it | ||
| # against the names the pinned bytes actually declare. | ||
| names = asset.metadata.animationNames or () | ||
| if tuple(obj.animationNames) != names or obj.hasAnimation != bool(names): | ||
| raise ValueError('Imported animation metadata must match the pinned asset bytes. 导入的动画信息必须与固定素材的实际字节一致。') | ||
| return self | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When opening a pre-change project containing a generation job with media references, these defaults add two null keys to every
ResolvedReference.metadatadump.InputSnapshot.fingerprint()consequently changes,Job.execution_identity()rejects the saved hash, andCommitLog._record()reports the existing commit as corrupt, making the project unavailable even if it never used the stage. The new defaultedStageObjectfields likewise invalidate historical editor command fingerprints checked byCommitRecord.consistent(). Omit unused new fields from serialization, following the existing timeline/audio extensions, to preserveAGENTS.md's stable-replay requirement.AGENTS.md reference: AGENTS.md:L67-L67
Useful? React with 👍 / 👎.