; WorldAssetReady Example ; ----------------------- ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,1,-5 light=CreateLight() RotateEntity light,45,45,0 ; A plain crate that will receive its texture once the asset is ready crate=CreateCube() PositionEntity crate,0,1,0 ; Load the asset manifest world in the background manifest=LoadWorldAsync("../../../samples/worlds/asset-preload.world") While Not WorldReady(manifest) If WorldLoadState(manifest)=WORLD_LOAD_FAILED Then RuntimeError WorldLoadError(manifest) Cls Text 0,0,"Loading the asset manifest..." Flip Wend ; 'manual-texture' uses manual loading policy: resolving the handle ; starts its background preparation asset=FindWorldAsset(manifest,"manual-texture") tex=0 While Not KeyDown(1) If WorldAssetError(asset)<>"" Then RuntimeError WorldAssetError(asset) ; The moment WorldAssetReady reports true, use the asset If tex=0 And WorldAssetReady(asset) tex=WorldAssetTexture(asset) EntityTexture crate,tex EndIf TurnEntity crate,0,1,0 ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld Text 0,0,"Arrow keys: move camera Esc: exit" Text 0,20,"WorldAssetReady(asset) = "+WorldAssetReady(asset) If tex Then Text 0,40,"The crate wears the texture that just became ready" Flip Wend If tex Then FreeTexture tex FreeWorld manifest End