This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IR-2225 Asset Loading Tech Debt (#10296)
* Move asset type enums to common * Asset type mapping * Asset loader cleanup * Test fix * Leverage useImmediateEffect better for resource hooks * debug * Texture loader * License * Texture scaling more generic, last cleanup * Remove comment --------- Co-authored-by: Josh Field <[email protected]>
- Loading branch information
1 parent
d0a75d7
commit 7e9bc80
Showing
30 changed files
with
554 additions
and
506 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
/* | ||
CPAL-1.0 License | ||
The contents of this file are subject to the Common Public Attribution License | ||
Version 1.0. (the "License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
https://github.com/EtherealEngine/etherealengine/blob/dev/LICENSE. | ||
The License is based on the Mozilla Public License Version 1.1, but Sections 14 | ||
and 15 have been added to cover use of software over a computer network and | ||
provide for limited attribution for the Original Developer. In addition, | ||
Exhibit A has been modified to be consistent with Exhibit B. | ||
Software distributed under the License is distributed on an "AS IS" basis, | ||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the | ||
specific language governing rights and limitations under the License. | ||
The Original Code is Ethereal Engine. | ||
The Original Developer is the Initial Developer. The Initial Developer of the | ||
Original Code is the Ethereal Engine team. | ||
All portions of the code written by the Ethereal Engine team are Copyright © 2021-2023 | ||
Ethereal Engine. All Rights Reserved. | ||
*/ | ||
|
||
/** List of Asset Types. */ | ||
export enum AssetType { | ||
Model = 'Model', | ||
Material = 'Material', | ||
Image = 'Image', | ||
Video = 'Video', | ||
Audio = 'Audio', | ||
Prefab = 'Prefab', | ||
Lookdev = 'Lookdev', | ||
Volumetric = 'Volumetric', | ||
Unknown = 'unknown' | ||
} | ||
|
||
/** List of Asset Extensions. */ | ||
export enum AssetExt { | ||
GLB = 'glb', | ||
GLTF = 'gltf', | ||
VRM = 'vrm', | ||
FBX = 'fbx', | ||
OBJ = 'obj', | ||
USDZ = 'usdz', | ||
BIN = 'bin', | ||
|
||
PNG = 'png', | ||
JPEG = 'jpeg', | ||
TGA = 'tga', | ||
KTX2 = 'ktx2', | ||
DDS = 'dds', | ||
|
||
MP4 = 'mp4', | ||
AVI = 'avi', | ||
WEBM = 'webm', | ||
MKV = 'mkv', | ||
MOV = 'mov', | ||
M3U8 = 'm3u8', | ||
MPD = 'mpd', | ||
|
||
MP3 = 'mp3', | ||
WAV = 'wav', | ||
OGG = 'ogg', | ||
M4A = 'm4a', | ||
FLAC = 'flac', | ||
AAC = 'acc', | ||
|
||
MAT = 'material', | ||
|
||
UVOL = 'uvol', | ||
JSON = 'json' | ||
} | ||
|
||
export const AssetExtToAssetType = (assetExt: AssetExt | undefined): AssetType => { | ||
switch (assetExt) { | ||
// Model | ||
case AssetExt.GLB: | ||
case AssetExt.GLTF: | ||
case AssetExt.VRM: | ||
case AssetExt.FBX: | ||
case AssetExt.OBJ: | ||
case AssetExt.USDZ: | ||
return AssetType.Model | ||
|
||
// Image | ||
case AssetExt.PNG: | ||
case AssetExt.JPEG: | ||
case AssetExt.TGA: | ||
case AssetExt.KTX2: | ||
case AssetExt.DDS: | ||
return AssetType.Image | ||
|
||
// Video | ||
case AssetExt.MP4: | ||
case AssetExt.AVI: | ||
case AssetExt.WEBM: | ||
case AssetExt.MKV: | ||
case AssetExt.MOV: | ||
case AssetExt.M3U8: | ||
case AssetExt.MPD: | ||
return AssetType.Video | ||
|
||
// Audio | ||
case AssetExt.MP3: | ||
case AssetExt.WAV: | ||
case AssetExt.OGG: | ||
case AssetExt.M4A: | ||
case AssetExt.FLAC: | ||
case AssetExt.AAC: | ||
return AssetType.Audio | ||
|
||
// Material | ||
case AssetExt.MAT: | ||
return AssetType.Material | ||
|
||
// Volumetric | ||
case AssetExt.JSON: | ||
case AssetExt.UVOL: | ||
return AssetType.Volumetric | ||
|
||
default: | ||
return AssetType.Unknown | ||
} | ||
} | ||
|
||
export const FileExtToAssetExt = (fileExt: string): AssetExt | undefined => { | ||
fileExt = fileExt.toLowerCase() | ||
if (fileExt === 'jpg') return AssetExt.JPEG | ||
return <AssetExt>fileExt | ||
} | ||
|
||
export const FileToAssetType = (fileName: string): AssetType => { | ||
fileName = fileName.toLowerCase() | ||
const split = fileName.split('.') | ||
const ext = split.pop() | ||
if (!ext) return AssetType.Unknown | ||
if (ext === 'gltf') { | ||
const prev = split.pop() | ||
if (prev) { | ||
if (prev === 'material') return AssetType.Material | ||
else if (prev === 'lookdev') return AssetType.Lookdev | ||
else if (prev === 'prefab') return AssetType.Prefab | ||
} | ||
} | ||
|
||
return AssetExtToAssetType(FileExtToAssetExt(ext)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.