include "Tlbx SceneKit.incl" _window = 1 begin enum output 1 _sceneView end enum local fn RotatingCubeScene as SCNSceneRef SCNSceneRef scene = fn SCNSceneInit SCNNodeRef rootNode = fn SCNSceneRootNode( scene ) SCNCameraRef camera = fn SCNCameraInit SCNNodeRef cameraNode = fn SCNNodeInit SCNNodeSetCamera( cameraNode, camera ) SCNNodeAddChildNode( rootNode, cameraNode ) SCNVector3 cameraPos = {0.0, 0.0, 10.0} SCNNodeSetPosition( cameraNode, cameraPos ) SCNNodeRef lightNode = fn SCNNodeInit SCNLightRef light = fn SCNLightInit SCNLightSetType( light, SCNLightTypeOmni ) SCNNodeSetPosition( lightNode, fn SCNVector3Make( 0.0, 10.0, 10.0 ) ) SCNNodeAddChildNode( rootNode, lightNode ) SCNNodeRef ambientLightNode = fn SCNNodeInit SCNLightRef ambientLight = fn SCNLightInit SCNLightSetType( ambientLight, SCNLightTypeAmbient ) SCNLightSetColor( ambientLight, fn ColorGray ) SCNNodeSetLight( ambientLightNode, ambientLight ) SCNNodeAddChildNode( rootNode, ambientLightNode ) SCNBoxRef boxGeometry = fn SCNBoxInit( 4.0, 4.0, 4.0, 0.0 ) SCNNodeRef boxNode = fn SCNNodeWithGeometry( boxGeometry ) SCNMaterialRef side1 = fn SCNMaterialInit SCNMaterialRef side2 = fn SCNMaterialInit SCNMaterialRef side3 = fn SCNMaterialInit SCNMaterialRef side4 = fn SCNMaterialInit SCNMaterialRef side5 = fn SCNMaterialInit SCNMaterialRef side6 = fn SCNMaterialInit SCNMaterialPropertySetContents( fn SCNMaterialMultiply( side1 ), fn ColorBlue ) SCNMaterialPropertySetContents( fn SCNMaterialMultiply( side2 ), fn ColorOrange ) SCNMaterialPropertySetContents( fn SCNMaterialMultiply( side3 ), fn ColorRed ) SCNMaterialPropertySetContents( fn SCNMaterialMultiply( side4 ), fn ColorGreen ) SCNMaterialPropertySetContents( fn SCNMaterialMultiply( side5 ), fn ColorYellow ) SCNMaterialPropertySetContents( fn SCNMaterialMultiply( side6 ), fn ColorCyan ) SCNGeometrySetMaterials( boxGeometry, @[side1,side2,side3,side4,side5,side6] ) SCNNodeAddChildNode( rootNode, boxNode ) SCNActionableRunAction( boxNode, fn SCNActionRepeatActionForever( fn SCNActionRotateByAngle( M_PI, fn SCNVector3Make( 0.0, 25.0, 5.0 ), 5.0 ) ) ) end fn = scene void local fn BuildWindow window _window, @"Rosetta Code Rotating Cube", ( 0, 0, 600, 600 ) scnview _sceneView, fn RotatingCubeScene, ( 0, 0, 600, 600 ) SCNViewSetBackgroundColor( _sceneView, fn ColorBlack ) SCNViewSetAllowsCameraControl( _sceneView, YES ) end fn void local fn DoDialog( ev as long, tag as long, wnd as long ) select (ev) case _windowWillClose : end end select end fn on dialog fn DoDialog fn BuildWindow HandleEvents