Skip to content

Added support for parallel Snap3D Generations #9

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions AI Playground/Assets/Scripts/Snap3DInteractable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export class Snap3DInteractable extends BaseScriptComponent {

setImage(image: Texture) {
this.img.enabled = true;
// Clone material to avoid replicating the preview image across instances
this.img.mainMaterial = this.img.mainMaterial.clone();
this.img.mainPass.baseTex = image;
}

Expand Down
12 changes: 1 addition & 11 deletions AI Playground/Assets/Scripts/Snap3DInteractableFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export class Snap3DInteractableFactory extends BaseScriptComponent {
@input
snap3DInteractablePrefab: ObjectPrefab;

private avaliableToRequest: boolean = true;
private wcfmp = WorldCameraFinderProvider.getInstance();

onAwake() {
Expand All @@ -39,11 +38,6 @@ export class Snap3DInteractableFactory extends BaseScriptComponent {
overridePosition?: vec3
): Promise<string> {
return new Promise((resolve, reject) => {
if (!this.avaliableToRequest) {
print("Already processing a request. Please wait.");
return;
}
this.avaliableToRequest = false;
let outputObj = this.snap3DInteractablePrefab.instantiate(
this.sceneObject
);
Expand Down Expand Up @@ -75,33 +69,29 @@ export class Snap3DInteractableFactory extends BaseScriptComponent {
assetOrError = assetOrError as Snap3DTypes.GltfAssetData;
if (!this.refineMesh) {
snap3DInteractable.setModel(assetOrError.gltfAsset, true);
this.avaliableToRequest = true;
resolve("Successfully created mesh with prompt: " + input);
} else {
snap3DInteractable.setModel(assetOrError.gltfAsset, false);
}
} else if (value === "refined_mesh") {
assetOrError = assetOrError as Snap3DTypes.GltfAssetData;
snap3DInteractable.setModel(assetOrError.gltfAsset, true);
this.avaliableToRequest = true;
resolve("Successfully created mesh with prompt: " + input);
} else if (value === "failed") {
assetOrError = assetOrError as Snap3DTypes.ErrorData;
print("Error: " + assetOrError.errorMsg);
//snap3DInteractable.onFailure(assetOrError.errorMsg);
this.avaliableToRequest = true;
reject("Failed to create mesh with prompt: " + input);
}
});
})
.catch((error) => {
snap3DInteractable.onFailure(error);
print("Error submitting task or getting status: " + error);
this.avaliableToRequest = true;
reject("Failed to create mesh with prompt: " + input);
});
});
}

private onTap() {}
private onTap() { }
}