@@ -147,7 +147,7 @@ internal void TransferToInternalBuffer()
147147 internal void _ResolveUri ( ReadContext context )
148148 {
149149 // No uri to decode.
150- if ( String . IsNullOrWhiteSpace ( _uri ) ) return ;
150+ if ( _uri == null ) return ;
151151
152152 // Try decode Base64 embedded image.
153153 if ( Memory . MemoryImage . TryParseMime64 ( _uri , out var memImage ) )
@@ -158,16 +158,19 @@ internal void _ResolveUri(ReadContext context)
158158 // Then it's a regular URI
159159 else
160160 {
161+ var satelliteUri = _uri ;
162+
161163 // try resolve the full path
162- if ( context . TryGetFullPath ( _uri , out string fullPath ) )
164+ if ( context . TryGetFullPath ( satelliteUri , out string fullPath ) )
163165 {
164166 _SatelliteContent = fullPath ;
165167 }
166168
167169 // full path could not be resolved, use direct load instead.
168170 else
169171 {
170- _SatelliteContent = new SharpGLTF . Memory . MemoryImage ( context . ReadAllBytesToEnd ( _uri ) , _uri ) ;
172+ var data = context . ReadAllBytesToEnd ( satelliteUri ) ;
173+ _SatelliteContent = new SharpGLTF . Memory . MemoryImage ( data , satelliteUri ) ;
171174 }
172175 }
173176
@@ -236,9 +239,8 @@ internal void _WriteToSatellite(WriteContext writer, string satelliteUri)
236239 }
237240
238241 satelliteUri = writer . WriteImage ( satelliteUri , imimg ) ;
239-
240- satelliteUri = satelliteUri . Replace ( "\\ " , "/" , StringComparison . Ordinal ) ;
241- _uri = satelliteUri . _EscapeStringInternal ( ) ;
242+
243+ _uri = UriKind . RelativeOrAbsolute . ToUri ( satelliteUri ) . OriginalString ;
242244 _mimeType = null ;
243245 }
244246
@@ -331,16 +333,19 @@ public Image UseImage(Memory.MemoryImage imageContent)
331333 }
332334
333335 /// <summary>
334- /// Transfers all the <see cref="ModelRoot. LogicalImages"/> content into <see cref="BufferView"/> instances
336+ /// Transfers all the <see cref="LogicalImages"/> content into <see cref="BufferView"/> instances
335337 /// </summary>
336338 /// <remarks>
337- /// Images can be stored in three different ways:
338- /// - As satellite files.
339- /// - Embedded as MIME64 into the JSON document
340- /// - Referenced with <see cref="BufferView"/>
341- ///
342- /// This call ensures all images will be internalized as <see cref="BufferView"/> instances.
343- ///
339+ /// Images can be stored in three different ways:<br/>
340+ /// - As satellite files.<br/>
341+ /// - Embedded as MIME64 into the JSON document<br/>
342+ /// - Referenced with <see cref="BufferView"/><br/>
343+ /// </remarks>
344+ /// <remarms>
345+ /// This call ensures all images will be internalized as <see cref="BufferView"/> instances.<br/>
346+ /// To write a GLB file, it is advised to call <see cref="MergeImages"/> before <see cref="MergeBuffers()"/>
347+ /// </remarms>
348+ /// <remarks>
344349 /// This action cannot be reversed.
345350 /// </remarks>
346351 public void MergeImages ( )
0 commit comments