@fredrik: I think it's an interesting idea, but tbh I think it might be a bit too complex to become an engine feature (and definitely a feature included in the AssetLibrary. If anything, it could be dealt with by a standalone class.)
I can imagine adding a couple of events however, that are dispatched as a dependency starts loading, so that a standalone system like this can still be created. By listening for when each dependency starts and finishes loading, the system can calculate the progress from it's internal mapping of file sizes and dependencies (which may or may not come from some XML file.) Alternatively, we could add a simple measure to define the estimated file size in the AssetLoaderContext, and that could be used to calculate the total progress internally in AssetLoader (because even though it has no idea of how many files might be referenced by the next dependency, it can keep count of how many bytes has been loaded and use that along with the user-estimated file size to calculate progress.) This would just require a single number, which makes the feature less heavy on the engine-side. How that number is calculated (e.g. manually, by prefab, or by a server at runtime) would still be up to the user and all of your ideas would still work. Could this serve as a good compromise? Cheers /R On May 19, 2:16 pm, fredrik <[email protected]> wrote: > Hi, > > I have a suggestion on how to track the loading progress for more > complex situations, and where you really want the progress to be > calculated accurately. > My suggestion is to introduce a new XML format, containing the output > from an analysis of filesizes, locations and dependecies. > The xml data would be an argument to a new > AssetLibrary.loadFilesByScanResult(scanResult:XML). > The scanResult could be generated: > a) manually > b) by using Prefab > c) by using a special Away3dAntTask, which then easy could be used > for a build with continuous integration > d) by calling server side scripts in runtime > e) by the help from a few new Away3d Air utility classes. > > What do you think? Do you need any help? > > Kind regards, > Fredrik > > Kind regards > Fredrik > > On 2 Maj, 08:49, richardolsson <[email protected]> wrote: > > > > > > > > > @Jim: > > > That's a good idea, and I'm currently working on how Away4 should > > report loading progress. But unfortunately what you are suggesting is > > not a very reliable method because you can never know how many > > textures (and other dependencies) are in a loaded file. Some file > > formats can reference other files with lots of data so potentially the > > "totalTextures" property you're suggesting might inrease infinitely. > > Because of this, I'm not sure the approach is actually solving > > anything (because the purpose of a loading bar is to reliably display > > the progress of loading.) > > > Imagine two scenarios, for clarity: > > > 1. An AWD file is loaded. It contains references to 5 external > > textures and 4 external AWD files. That's ten files total, meaning > > that when the master file and the five textures have been loaded it's > > at 60 per cent, which is cool. However, as the four external AWD files > > each are loaded (and status reaches 100% save the parsing) they are > > found to contain one texture each. We realize there are 14 files, and > > only ten of those are loaded. The user will see the progress bar > > suddenly jump back to 70%. > > > 2. A heavy collada file is loaded. After it's been read into memory > > Away needs to parse it. Lets say this takes 5 seconds. During those > > five seconds the progress will be almost 100% (save the parsing) but > > during parsing the collada file is found to reference 19 external > > textures. Progress jumps back to 5%. > > > As you can imagine, problems like these sort of defeat the purpose of > > loading feedback. :( > > > I am continuing to think about this, and we are discussing it in the > > team, but I would love your thoughts on the above. Should we have per- > > dependency loading feedback but not even try to do the "total > > progress" thing? Should we not care about the issues described above > > because they're edge cases? Please let us know what you think. > > > Cheers > > /R > > > On May 1, 11:34 pm, "[email protected]" <[email protected]> > > wrote: > > > > Anyway no matters... > > > > My suggestion which I said I would get back to you on was an idea is > > > for the general test loader - you can show a colored bar for each > > > texture loaded then very easy to adapt that for an animation and you > > > have better control of actual loading information than the current > > > away code provides. > > > > Suggested changes in the Loader3D class... > > > > public function get fractionTotalTextureLoaded(): Number > > > { > > > > return _loadQueue.currentItemIndex * 1 / > > > _loadQueue.numItems + ( _bytesLoaded /_bytesTotal ) / > > > _loadQueue.numItems; > > > > } > > > > public function get fractionCurrentTextureLoad(): Number > > > { > > > > return ( _bytesLoaded /_bytesTotal ) /_loadQueue.numItems; > > > > } > > > > public function get totalTextures(): int > > > { > > > > return _loadQueue.numItems ; > > > > } > > > > public function get textureIndex(): int > > > { > > > if( _loadQueue == null ) > > > { > > > return 0; > > > } > > > return _loadQueue.currentItemIndex ; > > > > } > > > > Then currently I am using my own ColladaLoader that just wraps access > > > more like my normal approach. > > > > package loaders > > > { > > > > import flash.events.Event; > > > import flash.events.ProgressEvent; > > > import flash.display.Loader; > > > import flash.display.Sprite; > > > > import away3d.loaders.Collada; > > > import away3d.core.base.Object3D; > > > import away3d.loaders.Loader3D; > > > import away3d.loaders.LoaderCube; > > > import away3d.core.base.Mesh; > > > import away3d.events.Loader3DEvent; > > > import org.osflash.signals.Signal; > > > import away3d.loaders.Loader3D; > > > import away3d.loaders.utils.*; > > > > public class ColladaLoader > > > { > > > > public var loader: Loader3D; > > > private var ratio: Number; > > > private var file: String; > > > public var content: Object3D; > > > public var finished: Signal = new Signal(); > > > public var progressed: Signal = new Signal(); > > > public var fraction: Number; > > > public var fractionGeometry: Number; > > > public var textureFractions: Array; > > > > public function ColladaLoader( _file: String, _ratio: Number ) > > > { > > > > ratio = _ratio; > > > file = _file; > > > > } > > > > public function load() > > > { > > > > loader = Collada.load( file, { scaling: 1, > > > bothsides: false } ); > > > loader.loaderSize = 0; > > > loader.addEventListener( Loader3DEvent.LOAD_SUCCESS, > > > loaded ); > > > loader.addEventListener( Loader3DEvent.LOAD_ERROR, > > > onError ); > > > loader.z = -2000; > > > fraction = 0; > > > loader.addEventListener( Loader3DEvent.LOAD_PROGRESS, > > > loaderProgress ); > > > > } > > > > private function loaded( e: Loader3DEvent ) > > > { > > > > content = loader.handle as Object3D; > > > trace( content ); > > > finished.dispatch(); > > > > } > > > > private function onError( e: Loader3DEvent ) > > > { > > > > trace( 'error loading ' + file ); > > > > } > > > > private function loaderProgress ( e : Loader3DEvent ) > > > { > > > > var textureIndex: int ; > > > var totalTextures: int; > > > fractionGeometry = 0 ; > > > > if( loader.handle.bytesLoaded != 0 && > > > loader.handle.bytesTotal != 0 ) > > > { > > > if( loader.handle.mode == 'loading_textures' ) > > > { > > > > textureIndex = ( loader.handle as > > > Loader3D ).textureIndex ; > > > //trace( 'texture index '+ textureIndex ); > > > totalTextures = ( loader.handle as > > > Loader3D ).totalTextures ; > > > //trace( 'totalTextures' + totalTextures ); > > > > if( textureFractions == null ) > > > { > > > > textureFractions = []; > > > > } > > > > if( textureIndex != 0 && textureIndex != null ) > > > { > > > > // populate already loaded sections > > > for( var i = 0; i < textureIndex - 1; i++ ) > > > { > > > > textureFractions[ i ] = 1/totalTextures ; > > > > } > > > > textureFractions[ textureIndex ] = > > > ( loader.handle as Loader3D ).fractionCurrentTextureLoad ; > > > > } > > > > fraction = ( 1 - ratio ) + ratio*( loader.handle > > > as Loader3D ).fractionTotalTextureLoaded; > > > > } > > > else if( loader.handle.mode == 'loading_geometry' ) > > > { > > > fraction = ( 1 - > > > ratio )*loader.handle.bytesLoaded / loader.handle.bytesTotal; > > > fractionGeometry = loader.handle.bytesLoaded / > > > loader.handle.bytesTotal; > > > } > > > progressed.dispatch(); > > > > } > > > } > > > } > > > > } > > > > And to draw the bars I use some colors, based on some rainbow image of > > > pencils so rather than using an equation they hopefully have a nice > > > feel to them > > > > private static var rainbowPencilColors: Array = > > > [ 0xD2D0C1 > > > , ... > > read more »
