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 > > , > > 0xCD8028 > > , > > 0xD29D11 > > , > > 0xE37128 > > , > > 0xF06771 > > , > > 0xD23931 > > , > > 0xAF2C31 > > , > > 0x90333E > > , > > 0x863D50 > > , > > 0x584A5D > > , > > 0x549EC3 > > , > > 0x2C709D > > ... > > läs mer »
