File size: 1,235 Bytes
f24ad59
ac7030c
 
 
f42b4a1
ac7030c
 
 
 
 
 
f42b4a1
 
 
 
 
 
 
 
 
ac7030c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { parseProjectionFromLoRA } from "@/app/api/parsers/parseProjectionFromLoRA"
import { MediaInfo, MediaProjection } from "@/types/general"

import { parseAssetToCheckIfGaussian } from "./parseAssetToCheckIfGaussian"
import { parseAssetToCheckIfLatent } from "./parseAssetToCheckIfLatent"

export function parseMediaProjectionType(media?: MediaInfo): MediaProjection {
  // note: we could also create a new value for when it is undetermined,
  // or we could also return undefined
  if (!media) { return "cartesian" }

  const isLatent = 
    media.projection === "latent" ||
    parseAssetToCheckIfLatent(media?.assetUrlHd) ||
    parseAssetToCheckIfLatent(media?.assetUrl)

  if (isLatent) {
    return "latent"
  }

  // TODO: add a way to detect its a gaussian splat (the file format, maybe?)
  const isGaussian =
    media.projection === "gaussian" ||
    parseAssetToCheckIfGaussian(media?.assetUrlHd) ||
    parseAssetToCheckIfGaussian(media?.assetUrl)
  
  if (isGaussian) {
    return "gaussian"
  }

  const isEquirectangular =
    media.projection === "equirectangular" ||
    parseProjectionFromLoRA(media.lora) === "equirectangular"

  if (isEquirectangular) {
    return "equirectangular"
  }

  return "cartesian"
}