Search Unity

TriLib - Model Loading Package

Discussion in 'Assets and Asset Store' started by rickomax, Jun 21, 2017.

  1. g4ma

    g4ma

    Joined:
    Dec 18, 2018
    Posts:
    32
    It looks like you're right - your vertices count is too low but my model got many UV sets.

    And anyway this is a big regression, we are stuck to v2.1.6. Whilst waiting for an actual fix I can only advise you to stay at this version (or maybe 2.1.7 but I cannot guarantee it).
     
  2. salvolannister

    salvolannister

    Joined:
    Jan 3, 2019
    Posts:
    50
    Anyone having this error while using siccity GLTFUtility with ready player me plugin and Trilib?

    Code (CSharp):
    1. Scripted importers Siccity.GLTFUtility.GLBImporter and TriLibCore.Editor.TriLibGLTFScriptedImporter are targeting the glb extension, rejecting both.
    2. UnityEditor.Experimental.AssetImporters.ScriptedImporter:RegisterScriptedImporters()
     
  3. fra3point

    fra3point

    Joined:
    Aug 20, 2012
    Posts:
    269
    Hello,

    I'm having trouble importing correct physic camera options from FBX.

    Here's the camera settings which have been imported by Unity Editor (left) and Trilib (right):

    upload_2022-11-25_19-12-49.png upload_2022-11-25_19-13-46.png

    In particular, look at Field of View, Sensor Size and Focal Length.

    Please, note that in order to show physical properties, I had to add the following line to AssetLoader.ParseModel():

    unityCamera.usePhysicalProperties = true;


    I there something I can do to import correct camera options with Trilib 2.1.8?

    Thank you,
    Francesco
     
    Last edited: Nov 25, 2022
    Robintj likes this.
  4. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,609
    Hi I have a question before I purchase it. I plan on using it for GLTF2 format. Does it load objects separately per material or does it keep the original structure and pivots/origins? I am using a free importer right now and it is much slower than the Kronos importer they provide, but it doesn't split it up by material, which is something I need as I need them to have the original object list and original pivots set in Blender. If I have "Car", "person" and "ground" in my scene for example, and each one has 2 or 3 materials, I need it to import at runtime with "Car", "person" and "ground" with all of their materials on it instead of split (ground_mat1, etc).
     
  5. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,609
    Hi, awaiting a response :)
     
  6. HyunMok_Moon

    HyunMok_Moon

    Joined:
    Oct 14, 2016
    Posts:
    24
    Hello Ricardo,

    I used AssetLoaderOptions.UseOriginalPositionRotationAndScale = true option at old version.
    But in version 2.0, do I have to rotate Y 180 degree after model is loaded?
    I tested the same model, in old version with this original transform option and new 2.0 version loaded model looks different. (Y 180 rotated)

    Of course I can manually rotate Y 180 model object. But I have to handle this transform modification when load and save 3d model data, or it could make some trouble. I load model and rotate Y 180, when I save model rotate Y -180 to restore, though.
    FYI, I loaded COLLADA (dae) model file.

    Thank you!
     
    Last edited: Dec 7, 2022
  7. yama_82

    yama_82

    Joined:
    Nov 29, 2018
    Posts:
    1
    Hi!
    It's about importing a model using "AssetLoaderZip.LoadModelFromZipStream".
    The ZIP file contains multiple FBX files.
    Still, the result is a single GameObject.
    Is there a way to import GameObject separately for each FBX file in the ZIP file?
    Thank you in advance.
     
  8. otaro36

    otaro36

    Joined:
    Aug 25, 2021
    Posts:
    2
    Trilib error con mac os TriLibCore.fbx

    hola
    que tal, queria comentarte lo siguiente. Estamos teniendo un problema con la implementación de TriLib 2.1.8. El error que presentamos en Mac, este error se duplica con la biblioteca shap-zip-lib@1.2.2. Eliminamos el .dll pero ahora no lo hace. Registra otro error en el que nos dice relacionado con TriLibCore.fbx. Podrias ayudarnos? Te mando las capturas de pantalla para que los resuelvas, por favor. Esto solo nos pasa en macOS
     

    Attached Files:

  9. otaro36

    otaro36

    Joined:
    Aug 25, 2021
    Posts:
    2
    Trilib error with mac os TriLibCore.fbx

    hello
    How are you, I wanted to tell you about the following. We are having a problem with the implementation of TriLib 2.1.8. The error we presented on Mac, this error is duplicated with the shap-zip-lib@1.2.2 library. We deleted the .dll but now it doesn't. It registers another error in which it tells us related to TriLibCore.fbx. Could you help us? I'll send you the screenshots to solve them, please. This only happens to us on macOS
     
  10. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    973
    hello,

    On loading fbx models, these 2 texture import errors break trilib importer.

    I have tried various import settings and the only option is to switch the Generate MipMaps off.

    The below errors come from the AssetViever scene.

    This is the latest (2.1.8) version. (Unity 2022.1.0)

    Compressed TextureFormat RGBA Compressed DXT5|BC3 requires a texture size that is a multiple of 4
    UnityEngine.Texture2D:.ctor (int,int,UnityEngine.Experimental.Rendering.GraphicsFormat,UnityEngine.Experimental.Rendering.TextureCreationFlags)
    TriLibCore.Utils.TextureUtils:CreateTexture2DInternal (int,int,UnityEngine.Experimental.Rendering.GraphicsFormat,UnityEngine.Experimental.Rendering.TextureCreationFlags)
    TriLibCore.Utils.TextureUtils:LoadTexture2D (TriLibCore.TextureLoadingContext)
    TriLibCore.Textures.TextureLoaders:UnityLoadFromContext (TriLibCore.TextureLoadingContext)
    TriLibCore.Textures.TextureLoaders:CreateTexture (TriLibCore.TextureLoadingContext)
    TriLibCore.AssetLoader:processTextures (TriLibCore.AssetLoaderContext) (at Assets/TriLib/TriLibCore/Scripts/AssetLoader.cs:1192)
    TriLibCore.AssetLoader:processRootModel (TriLibCore.AssetLoaderContext) (at Assets/TriLib/TriLibCore/Scripts/AssetLoader.cs:1172)
    TriLibCore.Utils.ThreadUtils:RequestNewThreadFor<TriLibCore.AssetLoaderContext> (TriLibCore.AssetLoaderContext,System.Threading.CancellationToken&,System.Action`1<TriLibCore.AssetLoaderContext>,System.Action`1<TriLibCore.AssetLoaderContext>,System.Action`1<TriLibCore.IContextualizedError>,int,string,bool,System.Action`1<TriLibCore.AssetLoaderContext>)
    TriLibCore.AssetLoader:LoadModelInternal (TriLibCore.AssetLoaderContext,bool) (at Assets/TriLib/TriLibCore/Scripts/AssetLoader.cs:224)
    TriLibCore.AssetLoader:LoadModelFromStream (System.IO.Stream,string,string,System.Action`1<TriLibCore.AssetLoaderContext>,System.Action`1<TriLibCore.AssetLoaderContext>,System.Action`2<TriLibCore.AssetLoaderContext, single>,System.Action`1<TriLibCore.IContextualizedError>,UnityEngine.GameObject,TriLibCore.AssetLoaderOptions,object,bool,System.Action`1<TriLibCore.AssetLoaderContext>,bool) (at Assets/TriLib/TriLibCore/Scripts/AssetLoader.cs:134)
    TriLibCore.IOAssetLoader/<DoHandleFileLoading>d__13:MoveNext () (at Assets/TriLib/TriLibStandaloneFileBrowser/StandaloneFileBrowser/TriLib/IOAssetLoader.cs:77)
    UnityEngine.GUIUtility:processEvent (int,intptr,bool&)

    TriLibCore.General.ContextualizedError`1[TriLibCore.AssetLoaderContext]: A contextualized error has occurred. ---> UnityEngine.UnityException: Failed to create texture because of invalid parameters.
    at UnityEngine.Texture2D.Internal_Create (UnityEngine.Texture2D mono, System.Int32 w, System.Int32 h, System.Int32 mipCount, UnityEngine.Experimental.Rendering.GraphicsFormat format, UnityEngine.Experimental.Rendering.TextureCreationFlags flags, System.IntPtr nativeTex) [0x00021] in <18e8109bbc8d4d9bbd519504205f489b>:0
    at UnityEngine.Texture2D..ctor (System.Int32 width, System.Int32 height, UnityEngine.Experimental.Rendering.GraphicsFormat format, UnityEngine.Experimental.Rendering.TextureCreationFlags flags, System.Int32 mipCount, System.IntPtr nativeTex) [0x00015] in <18e8109bbc8d4d9bbd519504205f489b>:0
    at UnityEngine.Texture2D..ctor (System.Int32 width, System.Int32 height, UnityEngine.Experimental.Rendering.GraphicsFormat format, UnityEngine.Experimental.Rendering.TextureCreationFlags flags) [0x00000] in <18e8109bbc8d4d9bbd519504205f489b>:0
    at TriLibCore.Utils.TextureUtils.CreateTexture2DInternal (System.Int32 width, System.Int32 height, UnityEngine.Experimental.Rendering.GraphicsFormat graphicsFormat, UnityEngine.Experimental.Rendering.TextureCreationFlags textureCreationFlags) [0x00000] in <9850e0736b014a0a98e8cac05bf377d1>:0
    at TriLibCore.Utils.TextureUtils.LoadTexture2D (TriLibCore.TextureLoadingContext textureLoadingContext) [0x00078] in <9850e0736b014a0a98e8cac05bf377d1>:0
    at TriLibCore.Textures.TextureLoaders.UnityLoadFromContext (TriLibCore.TextureLoadingContext textureLoadingContext) [0x00000] in <9850e0736b014a0a98e8cac05bf377d1>:0
    at TriLibCore.Textures.TextureLoaders.CreateTexture (TriLibCore.TextureLoadingContext textureLoadingContext) [0x0001b] in <9850e0736b014a0a98e8cac05bf377d1>:0
    at TriLibCore.AssetLoader.ProcessTextures (TriLibCore.AssetLoaderContext assetLoaderContext) [0x00065] in D:\U22\AR configurator22\Assets\TriLib\TriLibCore\Scripts\AssetLoader.cs:1192
    at TriLibCore.AssetLoader.ProcessRootModel (TriLibCore.AssetLoaderContext assetLoaderContext) [0x00006] in D:\U22\AR configurator22\Assets\TriLib\TriLibCore\Scripts\AssetLoader.cs:1172
    at TriLibCore.Utils.ThreadUtils.RequestNewThreadFor[T] (T context, System.Threading.CancellationToken& cancellationToken, System.Action`1[T] onStart, System.Action`1[T] onComplete, System.Action`1[T] onError, System.Int32 timeout, System.String name, System.Boolean startImmediately, System.Action`1[T] onCompleteSameThread) [0x00108] in <2016f0bb4864467baa3d282ad3b52d51>:0
    --- End of inner exception stack trace ---
    UnityEngine.Debug:LogError (object)
    TriLibCore.Samples.AssetViewerBase:OnError (TriLibCore.IContextualizedError) (at Assets/TriLib/TriLibSamples/Common/Scripts/AssetViewerBase.cs:256)
    TriLibCore.Samples.AssetViewer:OnError (TriLibCore.IContextualizedError) (at Assets/TriLib/TriLibSamples/AssetViewer/Scripts/AssetViewer.cs:632)
    TriLibCore.General.ContextualizedAction`1<TriLibCore.IContextualizedError>:Invoke ()
    TriLibCore.Utils.Dispatcher:Update ()
     
  11. nedhaljalali

    nedhaljalali

    Joined:
    Sep 14, 2017
    Posts:
    13
    During the destruction of Mesh and while downloading the materials, I encounter this error. Is there a solution?

    some time the player cancel the game before the mesh get all texture ..
    and the mesh must be destoyed in the midile of geting the texture .

     
  12. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    @rickomax Hi, I just want to let you know of a small bug:

    When using the standalone file browser code on WebGL, the little "Select File" HTML that gets added on the page doesn't hide itself when you click "Cancel", only when you select a file. Is that something that can be changed?

    I added this line to the JSLib file to hide that section entirely, and it works, but I want to make sure that it also gets removed when the user clicks cancel. Or does it not matter?

     fileInput.style.display="none";


    Also, WebGL only works with the Async file browser code? In my desktop app I use the regular one, but I'm starting to build for WebGL as well. So I don't have to write two different functions depending on the platform, can the Sync/Regular one default to Async if it's unsupported?

    Thanks!
     
    Last edited: Jan 9, 2023
  13. vriog

    vriog

    Joined:
    Dec 6, 2014
    Posts:
    31
    Please, this package desperately needs async model loading in WebGL! So far it freezes when a new model is loading in! If anyone has any workaround I'd be super grateful if you shared it, otherwise please, developer, make this your top priority! Hopefully its not a showstopper Unity WebGL limitation!
     
  14. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    And sorry guys. I generally don't access the forum, so always try to reach me on Twitter or e-mail.
    That is the point I'm focusing with the upcoming update, but WebGL on Unity doesn't have threads support as far as I know, so there isn't much I can do about it besides trying to make things faster to decrease the stall.
     
  15. vriog

    vriog

    Joined:
    Dec 6, 2014
    Posts:
    31
    Is there any way to spread out the loading over different frames that way it loads slower but does not stall at all?
     
  16. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Been answered by e-mail, but yes, TriLib methods will be slowly ported to coroutines.
     
  17. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!

    Async methods are not supported by WebGL.
    I will look into the display issue.
     
  18. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    Please make sure you have updated TriLib to version 2.1.9.
    The cancelation might happen because of the Timeout field of your AssetLoaderOptions instance.
    You can try increasing this value.
     
  19. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    I guess this issue has been fixed on update 2.1.9, could you confirm it?
     
  20. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    I haven't seen such issue, but removing the SharpZipLib that comes with TriLib should work, as long as you have another SharpZipLib version in your project
     
  21. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    Not natively, you would have to scan the .Zip file contents yourself and load each file at once. You can see how TriLib finds model files inside the Zip file in the AssetLoaderZip.cs source
     
  22. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    I'm working on improving Collada support (which is broken in version 2.1.9). Remember Collada support is experimental, but I should have a hotfix for it released soon.
     
  23. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    TriLib will keep the original objects structures/pivots. For FBX files, the old pivot implementation was broken, so I'm working on a new one for the next update (after 2.1.9), but for the other file formats, it will keep the pivot as the original one.
     
  24. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Could you e-mail me the model with the camera you're trying to load?
    https://ricardoreis.net/contact
     
  25. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    You can disable TriLib editor importers under the "Edit->Project Settings->TriLib" menu.
     
  26. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    TriLib 2.1.9 has many mesh fixes/improvements.
    Regarding UV sets, the new update will always use the 4 UV sets if the model has only one of them.
    That was a last-time addition to make the mesh system work with newer Unity versions, and it should be improved to use more compact mesh components in a future update.
     
  27. fra3point

    fra3point

    Joined:
    Aug 20, 2012
    Posts:
    269
    Hi,

    there's no way to attach files in the form. Could you please send me your email address?

    Thanks,
    F.
     
  28. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Sent you by PM.
     
  29. GawebStudio

    GawebStudio

    Joined:
    Aug 14, 2017
    Posts:
    14
    Hi, a small question. Is it possible to skip loading materials with your script? My game update materials separately from the model, I'd just like to load the model data, not its materials, not sure if it's actually possible? But I see two different functions in your assets, one when model is loaded and second for material load. Can the material load be skipped completely since my script will overwrite them again later anyway? Thanks in advance.
     
    Last edited: Feb 9, 2023
  30. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    From my understanding, you can disable texture loading using the AssetLoaderOptions object passed into the loading functions.

    Without a material, a mesh won't render in Unity, so regardless of textures or not, materials will still be generated/allocated.

    Hope that helps!
     
  31. evilbert45

    evilbert45

    Joined:
    Jun 8, 2020
    Posts:
    1
    Bought the asset. Works out of the box. All good!
    But it isn't loading draco compressed glb model on WebGL platform. Is it supported on WebGL???
     
  32. HamzaMushtaq

    HamzaMushtaq

    Joined:
    Sep 24, 2017
    Posts:
    10
    hi mates, I hope you all are doing well.
    1:I want to import multiple models at the same time. Right now I can select multiple models but only the last one selected is getting imported. Does anyone know, how to do that?

    2: In Mobile devices while importing models. The file picker panel is showing me all types of assets while i set the extension to only .fbx, in the editor it is working perfectly but on mobile devices it is not.
    Kindly help me with those queries. Thanks in advance.
     
    Last edited: Mar 15, 2023
  33. patrick_unity535

    patrick_unity535

    Joined:
    Nov 15, 2018
    Posts:
    1
    Hey guys!

    I just updated from 2.1.2 to 2.1.9 for the performance increase, but I'm having a couple of issues when running deployed to a first gen Hololens(it works fine in editor).

    First: the obj loader throws the following error:
    Code (CSharp):
    1. Exception thrown at 0x76B47C82 in virtualmine-HL1.exe: Microsoft C++ exception: Il2CppExceptionWrapper at memory location 0x0228DFAC.
    2. You are passing a MemoryStream without GetBuffer() access. For better memory usage, please create your MemoryStream with 'publiclyVisible = true'.
    3. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    4. UnityEngine.Logger:Log(LogType, Object)
    5. UnityEngine.Debug:LogWarning(Object)
    6. TriLibCore.Extensions.StreamExtensions:ReadBytes(Stream)
    7. TriLibCore.ReaderBase:SetupStream(Stream&)
    8. TriLibCore.Obj.Reader.ObjReader:ReadStream(Stream, AssetLoaderContext, String, Action`2)
    9. TriLibCore.AssetLoader:SetupModelLoading(AssetLoaderContext)
    10. TriLibCore.AssetLoader:LoadModel(AssetLoaderContext)
    11. TriLibCore.Utils.ThreadUtils:RequestNewThreadFor(AssetLoaderContext, CancellationToken&, Action`1, Action`1, Action`1, Int32, String, Boolean, Action`1)
    12. TriLibCore.AssetLoader:LoadModelInternal(AssetLoaderContext)
    13. TriLibCore.AssetLoader:LoadModelFromStream(Stream, String, String, Action`1, Action`1, Action`2, Action`1, GameObject, AssetLoaderOptions, Object, Boolean, Action`1, Boolean)
    14. TriLibCore.<DownloadAsset>d__3:MoveNext()
    15. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
    Second:
    While debugging on the deployed hololens, the device eventually hits an exception that simply states ProjectName.exe has triggered a breakpoint, at the following point in the il2cpp code:

    upload_2023-3-15_13-47-59.png

    Any thoughts as to possible causes?

    Thanks!
     
  34. mark856ling

    mark856ling

    Joined:
    Mar 29, 2023
    Posts:
    1

    Attached Files:

  35. jgahide

    jgahide

    Joined:
    Apr 26, 2023
    Posts:
    1
    Hello, I am using Trilib 2 with Unity 2020.3.46.f1 for loading an FBX file on Hololens2. This is working well but I have an UI issue of everything freezing for sometime while the model is loading. After spending a couple of hours searching and trying options, I think I have found out that the
    Code (CSharp):
    1.                 ThreadUtils.RequestNewThreadFor(assetLoaderContext, ref assetLoaderContext.CancellationToken, LoadModel,
    2.                     ProcessRootModel, HandleError, assetLoaderContext.Options.Timeout, threadName, !assetLoaderContext.HaltTasks,
    3.                     assetLoaderContext.OnPreLoad);
    execute itself on the main thread. I have also forced the Async attribute in assetLoaderContext to be true.
    The profiler is giving me this :


    Am I missing something ?
    Thx
     
    Last edited: May 9, 2023
  36. RRD123

    RRD123

    Joined:
    Aug 24, 2022
    Posts:
    8
    Hello, I am having an issue with the file path when building it for iOS. It's working fine in the editor. But when build it for iOS, I am getting the below error message.

    Screenshot 2023-05-11 at 4.17.59 PM.png

    I couldn't find any reference related to Unity for the above error message. Can you help me fix this?

    My Unity Version is 2021.3.23f1
     
  37. RRD123

    RRD123

    Joined:
    Aug 24, 2022
    Posts:
    8
    Did you solve this issue? I am facing the same. It would be really helpful if you can help me in this. Thanks !
     
  38. OKIMYJ

    OKIMYJ

    Joined:
    Aug 17, 2016
    Posts:
    1
    Hi!
    I updated to version 2.1.9 and tried it, but I still have problems with the smoothness value.
    Regardless of the set value, it is unconditionally set to 1.
    Is there anything i can try?
    We are testing by downloading characters from the site at the address below.

    +) The color value is not being reflected.

    https://www.mixamo.com/#/?page=1&type=Character
     

    Attached Files:

  39. ibartha

    ibartha

    Joined:
    Oct 6, 2012
    Posts:
    7
    Hi,

    I am having the same issue with the imported asset materials.
    The materials appear 100% reflective until the material dropdown is clicked in the inspector.

    I tried to change the material base color alter the mapping at runtime did not fix the issue.
    Please see attached pictures for reference.

    I am running Unity 2020.3.25, URP, Vulcan
    I tried w the default and a custom assetLoaderOption
     

    Attached Files:

  40. ibartha

    ibartha

    Joined:
    Oct 6, 2012
    Posts:
    7
    adding this to the materials loaded callback helped

    foreach (var kvp in assetLoaderContext.LoadedMaterials){
    Material mat = kvp.Value;
    mat.SetFloat("_Smoothness", .5f);
    }
     
  41. kang2k

    kang2k

    Joined:
    May 2, 2023
    Posts:
    1
    Hello, please help me
    i load stl model. In hierarchy tree, i see my model with child "default", all setting from assetLoaderOptions, apply for "default". How apply settyngs for model, withot default ?
     
    Last edited: May 28, 2023
  42. HugoDidimo

    HugoDidimo

    Joined:
    Aug 6, 2018
    Posts:
    3
    upload_2023-5-29_15-12-13.png
    Hi guys,

    I am using Unity version 2022.2.19f1, and when I'm trying to debug my project, I keep getting these errors.
    This breaks Unity's UI.
    Anyone getting this issue?
     
  43. Rabbit312319

    Rabbit312319

    Joined:
    Jun 13, 2022
    Posts:
    1
    I want to know how to load a pmx file for MMD?
    I saw the relate post is in 2019, is the problem solved?
    I have the 2.2.0 version but still can't load pmx file
    Or is there anyting need to be set?
     
  44. Marcos-Elias

    Marcos-Elias

    Joined:
    Nov 1, 2014
    Posts:
    159
    Is there any chance of sharing the source code for current versions? I need to make custom changes on some importers. Closed assets are really bad for that. I sent you an email with more details.
     
    DrSeltsam likes this.
  45. DrSeltsam

    DrSeltsam

    Joined:
    Jul 24, 2019
    Posts:
    101
    I would also very much prefer if the source code was accessible to make custom changes, as mentioned by @Marcos-Elias ;) The assemblies can be easily extracted anyway using tools like ILSpy, but it's just unnecessarily cumbersome to maintain it when merging it with newer versions of TriLib, for example.
     
    Marcos-Elias likes this.
  46. emmasteimann

    emmasteimann

    Joined:
    Dec 2, 2016
    Posts:
    1
    Is it possible to make a texture read/write? It looks like the functionality may have been deprecated?

    MarkTexturesNoLongerReadable: "To reduce allocated resources, all TriLib Textures CPU data is released after the Texture is loaded, turning the Texture non-readable."

    Would making a custom mapper where I manually copy and import the textures separately as read/write be the right approach? Or is there an easier way?

    Any time I try do something like
    TriLibGameObject.GetComponentInChildren<MeshRenderer>().material.mainTexture
    it wont let me read the texture.
     
  47. trancanhluc

    trancanhluc

    Joined:
    Jun 11, 2015
    Posts:
    12
    Hi everyone! Has anyone who's been using TriLib version 2.0.0 to load models on mobile devices (iOS, Android) experienced a crash after loading the second model? I've been facing this issue where even after destroying the previously loaded object and releasing the unused assets, the app still crashes when attempting to load another model. The error message suggests a memory leak.

    To reproduce the issue, follow these steps:

    1) Edit the scene file at Trilib/TrilibSamples/LoadModelFromURL/LoadModelFromURL.scene.
    2) Add a button called "Reload" with an action below.

    public void ReLoad()
    {
    if (objectLoaded != null)
    {
    Destroy(objectLoaded);
    }
    var assetLoaderOptions = AssetLoader.CreateDefaultLoaderOptions();
    var webRequest = AssetDownloader.CreateWebRequest(ModelURL);
    AssetDownloader.LoadModelFromUri(webRequest, OnLoad, OnMaterialsLoad, OnProgress, OnError, null, assetLoaderOptions);
    }

    3) Build this scene for iOS/Android.
    4) Launch app -> Click the "Reload" button.
    The crash occurs on the second or third reload.
    If anyone has encountered a similar problem or has any insights on how to resolve this issue, please let me know. Thank you!
     
  48. PortalVRit

    PortalVRit

    Joined:
    Oct 19, 2018
    Posts:
    15
    I'm using Trilib 2 to load models and i get frezzes when the model load, investigating seems that the load happens on the main thread, so i found that there is a define symbols: TRILIB_LOAD_MESHES_ON_PARALLEL_THREAD
    tha i think will use another thread to load.

    when i enebled this i get an error in assetloader on this method calls:
    Extensions_2020_2.GeometryGroupExtensions.GenerateMeshParallel(model.GeometryGroup, assetLoaderContext, dataArrayCreationContext.DataArray, i);

    The name 'Extensions_2020_2' does not exist in the current context

    so where i can get this Extensions implementation to make things works?
     
  49. sandro-ixt

    sandro-ixt

    Joined:
    May 2, 2019
    Posts:
    13
    Hi,

    I'm using TriLib 2.2.0 and I found an issue when importing multiple models asynchronously in parallel. Here is the code I use:

    Code (CSharp):
    1. private static void Import(ImportedModel import)
    2. {
    3.     CacheEntry entry = new(import.Path, import.Included);
    4.     if (cache.TryGetValue(entry, out var cached))
    5.     {
    6.         UnityEngine.Object.Instantiate(cached, import.ModelParent);
    7.         return;
    8.     }
    9.     Stream stream = DeserializationUtility.OpenStream(
    10.         path: entry.path,
    11.         withinArchive: entry.included,
    12.         junk: out IDisposable junk);
    13.     if (entry.included)
    14.     {
    15.         // Stream is a deflate stream when the file is included in the
    16.         // save file's archive. TriLib accesses Stream.Length which is
    17.         // not supported in DeflateStream, so we copy the stream to a
    18.         // memory stream.
    19.         // Not using AssetLoaderZip because it loads all files from the
    20.         // archive, but we only want specific ones.
    21.         MemoryStream memStream = new();
    22.         stream.CopyTo(memStream);
    23.         stream.Dispose();
    24.         stream = memStream;
    25.     }
    26.     AssetLoader.LoadModelFromStream(
    27.         stream: stream,
    28.         filename: entry.path,
    29.         fileExtension: Path.GetExtension(entry.path),
    30.         onLoad: context => Dispose(stream, junk),
    31.         onMaterialsLoad: context => OnMaterialsLoad(context, entry),
    32.         onError: OnError,
    33.         wrapperGameObject: import.ModelParent.gameObject,
    34.         assetLoaderOptions: Refs.AssetLoaderOptions);
    35. }
    This code is invoked multiple times from an asynchronous context (but on the main thread). Here is the stack trace of the error I get:

    Code (CSharp):
    1. ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    2. Parameter name: index
    3. System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <1c8569827291471e9db0dcd976e97952>:0)
    4. TriLibCore.Utils.Dispatcher.ExecuteQueue (TriLibCore.Interfaces.IAssetLoaderContext assetLoaderContext) (at <b84015022aaa43caaac67d691ecc1716>:0)
    5. TriLibCore.AssetLoaderContext.ExecuteActionsQueue (System.Action`1[T] onFinish) (at <b84015022aaa43caaac67d691ecc1716>:0)
    6. TriLibCore.AssetLoader.ProcessMaterialRenderers (TriLibCore.AssetLoaderContext assetLoaderContext) (at Assets/1_Plugins/TriLib/TriLibCore/Scripts/AssetLoaders/AssetLoader.cs:1325)
    7. TriLibCore.Utils.ThreadUtils+<>c__DisplayClass0_0`1[T].<RequestNewThreadFor>b__0 () (at <b84015022aaa43caaac67d691ecc1716>:0)
    8. UnityEngine.Debug:LogException(Exception)
    9. ivp.ModelDeserializer:OnError(IContextualizedError) (at Assets/0_Project/2_Source/ModelImport/ModelDeserializer.cs:95)
    10. TriLibCore.General.ContextualizedAction`1:Invoke()
    11. TriLibCore.Utils.Dispatcher:Update()
    This does not happen every time, but quite often. Let me know in case there is anything I can do from my side to help troubleshoot this.
    Also I think I found a memory leak in AssetLoaderZip.ZipFileEntryToStream:

    Code (CSharp):
    1. /// <summary>Copies the contents of a Zip file Entry into a Memory Stream.</summary>
    2. /// <param name="fileExtension">The Model inside the Zip file extension.</param>
    3. /// <param name="zipEntry">The Zip file Entry.</param>
    4. /// <param name="zipFile">The Zip file instance.</param>
    5. /// <returns>A memory stream with the zip file entry contents.</returns>
    6. public static Stream ZipFileEntryToStream(out string fileExtension, ZipEntry zipEntry, ZipFile zipFile)
    7. {
    8.     var buffer = new byte[ZipBufferSize];
    9.     var zipFileStream = zipFile.GetInputStream(zipEntry);
    10.     var memoryStream = new MemoryStream(ZipBufferSize);
    11.     ICSharpCode.SharpZipLib.Core.StreamUtils.Copy(zipFileStream, memoryStream, buffer);
    12.     memoryStream.Seek(0, SeekOrigin.Begin);
    13.     zipFileStream.Close();
    14.     fileExtension = FileUtils.GetFileExtension(zipEntry.Name, false);
    15.     return memoryStream;
    16. }
    zipFileStream is closed, but never disposed.
     
  50. sandro-ixt

    sandro-ixt

    Joined:
    May 2, 2019
    Posts:
    13
    I also get a lot of crashes with this plugin. Here is a stack trace:

    Code (csharp):
    1.  
    2. 0x00007FFEA89E5E62 (UnityPlayer) block_remove
    3. 0x00007FFEA89E62C4 (UnityPlayer) tlsf_free
    4. 0x00007FFEA7123FF8 (UnityPlayer) DynamicHeapAllocator::Deallocate
    5. 0x00007FFEA7151A09 (UnityPlayer) DualThreadAllocator<DynamicHeapAllocator>::TryDeallocate
    6. 0x00007FFEA7124723 (UnityPlayer) MemoryManager::Deallocate
    7. 0x00007FFEA712E1AA (UnityPlayer) free_alloc_internal
    8. 0x00007FFEA6EC97D1 (UnityPlayer) UnsafeUtility::Free
    9. 0x00007FFEA6DD575D (UnityPlayer) UnsafeUtility_CUSTOM_Free
    10. 0x0000023A240195C5 (Mono JIT Code) (wrapper managed-to-native) Unity.Collections.LowLevel.Unsafe.UnsafeUtility:Free (void*,Unity.Collections.Allocator)
    11. 0x00000239B13FE1FB (Mono JIT Code) [C:\build\output\unity\unity\Runtime\Export\NativeArray\NativeArray.cs:199] Unity.Collections.NativeArray`1<char>:Dispose ()
    12. 0x0000023A33054B21 (Mono JIT Code) TriLibCore.AssetLoaderContext:Finalize ()
    13. 0x00000239B573F66C (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_virtual_void__this__ (object,intptr,intptr,intptr)
    14. 0x00007FFEA65007F5 (mono-2.0-bdwgc) mono_callspec_cleanup
    15. 0x00007FFEA6779338 (mono-2.0-bdwgc) mono_breakpoint_clean_code
    16. 0x00007FFEA6501E69 (mono-2.0-bdwgc) mono_gc_finalize_notify
    17. 0x00007FFEA649CF1B (mono-2.0-bdwgc) mono_profiler_init_etw
    18. 0x00007FFEA649D0F6 (mono-2.0-bdwgc) mono_profiler_init_etw
    19. 0x00007FFFE33B26AD (KERNEL32) BaseThreadInitThunk
    20. 0x00007FFFE46CAA68 (ntdll) RtlUserThreadStart
    21.  
    Is there any way to get support for this plugin? I sent you a request via the contact form on the website that is listed for support in the asset store weeks ago but got no reply.
     
    Last edited: Aug 28, 2023
    youenImaginVR likes this.