Re: Babylon.js
Posted: Wed Jul 19, 2017 6:55 pm
Code: Select all
EnableExplicit
IncludeFile "babylon/babylon.sbi"
Global Scene, Camera, Mesh, Material
Declare LoadGame()
Declare RenderGame()
UseModule BJS
InitEngine(@LoadGame())
Procedure LoadGame()
Scene = CreateScene()
If Scene
CreateCamera("camera", 0, 0, 10, #BJS_ArcRotate)
SkyBox("sky", "data/textures/sky/TropicalSunnyDay")
CreateLight("point", 0, 200, 2)
Mesh = CreateSphere("sphere cube", 4)
Material = CreateMaterial("")
SetMaterialColor(Material, #BJS_Diffuse, RGB(0, 0, 0))
SetMaterialTexture(Material, #BJS_Reflection, LoadCubeTexture("data/textures/sky/TropicalSunnyDay"))
SetMeshMaterial(Mesh, Material)
RenderLoop(@RenderGame())
EndIf
EndProcedure
Procedure RenderGame()
RenderWorld()
EndProcedure
Code: Select all
Camera = CreateCamera("camera", 0, 5, 7, #BJS_ArcRotate)
Code: Select all
Light = CreateLight("room light", 0, 10, 0, 1, #BJS_Hemispheric)
Code: Select all
Sphere = CreateSphere("sphere", 2)
MoveMesh(Sphere, 0, 5, 0)
CreateMeshBody(Sphere, #BJS_SphereBody, 1, 0.9, 0)
Code: Select all
;Create a sphere
Sphere = CreateSphere("sphere", 2)
;Load texture
TexSphere = LoadTexture("Data/textures/tree.png")
;Create material and apply texture
MatSphere = CreateMaterial("MatSphere")
SetMaterialTexture(MatSphere, #BJS_Diffuse, TexSphere, #True) ;#True because the texture has an alpha layer
;Apply material
SetMeshMaterial(Sphere, MatSphere)
Code: Select all
;GUI : Scene ScreenShoot
GUI = CreateDynamicTexture()
Shoot = Button3D("shoot", 20, 20, 150, 24, "ScreenShoot", @ScreenShoot())
SetColor3D(Shoot, #BJS_BackColor, RGBA(222, 184, 135, 140))
AddControl3D(GUI, Shoot)