; CreateWorldAsset Example ; ------------------------ ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() SeedRnd MilliSecs() camera=CreateCamera() PositionEntity camera,0,1,-5 light=CreateLight() RotateEntity light,45,45,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 ; The manifest's model asset is ready along with its world model_asset=FindWorldAsset(manifest,"display-model") ; CreateWorldAsset instantiates an ordinary entity from the model asset pickup=CreateWorldAsset(model_asset) PositionEntity pickup,0,1,0 count=1 While Not KeyDown(1) ; Space spawns another pickup from the same asset If KeyHit(57) item=CreateWorldAsset(model_asset) PositionEntity item,Rnd(-4,4),Rnd(0,2),Rnd(0,4) TurnEntity item,Rnd(360),Rnd(360),0 count=count+1 EndIf TurnEntity pickup,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,"Space: spawn another pickup Arrow keys: move camera Esc: exit" Text 0,20,"CreateWorldAsset instances made from one model asset: "+count Flip Wend FreeWorld manifest End