Skip to content

Commit

Permalink
DPO3DPKRT-701/generate downloads support for scenes (#566)
Browse files Browse the repository at this point in the history
(fix) restoring generate-downloads functionality with support for returned svx scenes and draco/usdz models
(fix) modified tags assigned to 'Download:<downloadType>' to allow for capturing a model's use and it's type.
  • Loading branch information
EMaslowskiQ authored Jan 23, 2024
1 parent e7cd3b1 commit 3f80548
Show file tree
Hide file tree
Showing 12 changed files with 875 additions and 184 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,5 @@ server/config/solr/data/packratMeta/data
### Per-developer settings ###
JTConfig

### Init Scripts ###
### Environment Setup Scripts ###
*.bat
19 changes: 14 additions & 5 deletions server/collections/impl/PublishScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,13 @@ export class PublishScene {
return null;
}

// LOG.info(`>>> computeDownloadMSXMap (${idScene}): ${H.Helpers.JSONStringify(MSXs)}`,LOG.LS.eDEBUG);
const DownloadMSXMap: Map<number, DBAPI.ModelSceneXref> = new Map<number, DBAPI.ModelSceneXref>();
for (const MSX of MSXs) {
if (MSX.Usage && MSX.Usage.startsWith('Download')) {
// HACK: Packrat is misusing the Usage property returned by Cook for Voyager scene generation. Some
// assets like draco and USDZ downloads are used by the viewer & as a download. temporarily adding
// their Usage types until a file's 'downloadable' property is detached from 'Usage'. (#DPO3DPKRT-777)
if (MSX.Usage && (MSX.Usage.startsWith('Download:') || MSX.Usage.startsWith('App3D') || MSX.Usage.startsWith('iOSApp3D'))) {
const SOI: DBAPI.SystemObjectInfo | undefined = await CACHE.SystemObjectCache.getSystemFromObjectID({ eObjectType: COMMON.eSystemObjectType.eModel, idObject: MSX.idModel });
if (SOI)
DownloadMSXMap.set(SOI.idSystemObject, MSX);
Expand All @@ -303,14 +307,14 @@ export class PublishScene {
return PublishScene.sendResult(true);

if (newDownloadState) {
LOG.info(`PublishScene.handleSceneUpdates generating downloads for scene ${idScene} (skipping)`, LOG.LS.eGQL);
LOG.info(`PublishScene.handleSceneUpdates generating downloads for scene ${idScene}`, LOG.LS.eGQL);
// Generate downloads
const workflowEngine: WF.IWorkflowEngine | null = await WF.WorkflowFactory.getInstance();
if (!workflowEngine)
return PublishScene.sendResult(false, `Unable to fetch workflow engine for download generation for scene ${idScene}`);

// HACK: temporarily skip generate downloads while development on that wraps up
// workflowEngine.generateSceneDownloads(idScene, { idUserInitiator: idUser }); // don't await
// trigger the workflow/recipe
workflowEngine.generateSceneDownloads(idScene, { idUserInitiator: _idUser }); // don't await
return { success: true, downloadsGenerated: true, downloadsRemoved: false };
} else { // Remove downloads
LOG.info(`PublishScene.handleSceneUpdates removing downloads for scene ${idScene}`, LOG.LS.eGQL);
Expand Down Expand Up @@ -343,6 +347,7 @@ export class PublishScene {
}

private async collectAssets(ePublishedStateIntended?: COMMON.ePublishedState): Promise<boolean> {
// LOG.info(`>>> collectAssets.DownloadMSXMap: ${H.Helpers.JSONStringify(this.DownloadMSXMap)}`,LOG.LS.eDEBUG);
if (!this.DownloadMSXMap)
return false;
this.assetVersions = await DBAPI.AssetVersion.fetchLatestFromSystemObject(this.idSystemObject);
Expand Down Expand Up @@ -416,6 +421,8 @@ export class PublishScene {
}
}
}

// LOG.info(`>>> collectAssets.SAC: ${H.Helpers.JSONStringify(this.SacList)}`,LOG.LS.eDEBUG);
return true;
}

Expand Down Expand Up @@ -487,6 +494,7 @@ export class PublishScene {
this.resourcesHotFolder = path.join(Config.collection.edan.resourcesHotFolder, this.scene.EdanUUID!); // eslint-disable-line @typescript-eslint/no-non-null-assertion

for (const SAC of this.SacList.values()) {
// LOG.info(`>>> stageDownloads.SAC: ${H.Helpers.JSONStringify(SAC)}`,LOG.LS.eDEBUG);
if (!SAC.model && !SAC.metadataSet) // SAC is not a attachment, skip it
continue;

Expand Down Expand Up @@ -692,7 +700,8 @@ export class PublishScene {
case '.usdz': FILE_TYPE = 'usdz'; break;
}

switch (SAC.modelSceneXref.Usage?.replace('Download ', '').toLowerCase()) {
// handle download types
switch (SAC.modelSceneXref.Usage?.replace('Download:', '').toLowerCase()) {
case undefined:
case 'webassetglblowuncompressed': category = 'Low resolution'; MODEL_FILE_TYPE = 'glb'; break;
case 'webassetglbarcompressed': category = 'Low resolution'; MODEL_FILE_TYPE = 'glb'; DRACO_COMPRESSED = true; break;
Expand Down
1 change: 1 addition & 0 deletions server/db/api/ModelSceneXref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export class ModelSceneXref extends DBC.DBObject<ModelSceneXrefBase> implements
}

public computeModelAutomationTag(): string {
// LOG.info(`>>> computeModelAutomationTag for ${this.Name} (${this.Usage}|${this.Quality}|${this.UVResolution})`,LOG.LS.eDEBUG);
return `scene-${this.Usage}-${this.Quality}-${this.UVResolution}`;
}

Expand Down
1 change: 1 addition & 0 deletions server/db/api/Scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export class Scene extends DBC.DBObject<SceneBase> implements SceneBase, SystemO

/** fetches scenes which are children of the specified idModelParent */
static async fetchChildrenScenes(idModelParent: number): Promise<Scene[] | null> {
// LOG.info(`>>>> idModelParent: ${idModelParent}`,LOG.LS.eDEBUG);
if (!idModelParent)
return null;
try {
Expand Down
2 changes: 1 addition & 1 deletion server/job/impl/Cook/JobCook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ export abstract class JobCook<T> extends JobPackrat {
// TODO: more robust support with alt type
// const stat = await webdavClient.stat(destination);
// const fileSize = (stat as FileStat).size;
// console.log(`>>>> fetchFile file size: ${fileSize} | ${destination}`);
// LOG.info(`>>>> fetchFile file size: ${fileSize} | ${destination}`,LOG.LS.eDEBUG);
// if(fileSize <= 0)
// throw new Error(`destination file doesn't exist or is empty. (${fileSize} bytes | ${destination})`);

Expand Down
Loading

0 comments on commit 3f80548

Please sign in to comment.