mirror of https://github.com/mode777/rayjs.git
				
				
				
			add broken example
This commit is contained in:
		
							parent
							
								
									8fd6508ac4
								
							
						
					
					
						commit
						17ef4e6fd9
					
				
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 164 B | 
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 36 KiB | 
|  | @ -0,0 +1,86 @@ | |||
| /******************************************************************************************* | ||||
| * | ||||
| *   raylib [models] example - Cubicmap loading and drawing | ||||
| * | ||||
| *   Example originally created with raylib 1.8, last time updated with raylib 3.5 | ||||
| * | ||||
| *   Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, | ||||
| *   BSD-like license that allows static linking with closed source software | ||||
| * | ||||
| *   Copyright (c) 2015-2023 Ramon Santamaria (@raysan5) | ||||
| * | ||||
| ********************************************************************************************/ | ||||
| 
 | ||||
| // Initialization
 | ||||
| //--------------------------------------------------------------------------------------
 | ||||
| const screenWidth = 800; | ||||
| const screenHeight = 450; | ||||
| 
 | ||||
| initWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing"); | ||||
| 
 | ||||
| // Define the camera to look into our 3d world
 | ||||
| const position = new Vector3(16.0, 14.0, 16.0);     // Camera position
 | ||||
| const target = new Vector3(0.0, 0.0, 0.0);          // Camera looking at point
 | ||||
| const up = Vector3(0.0, 1.0, 0.0);                  // Camera up vector (rotation towards target)
 | ||||
| const fovy = 45.0;                                  // Camera field-of-view Y
 | ||||
| const projection = CAMERA_PERSPECTIVE;              // Camera projection type
 | ||||
| const camera = new Camera3D(position, target, up, fovy, projection) | ||||
| 
 | ||||
| const image = loadImage("assets/cubicmap.png");      // Load cubicmap image (RAM)
 | ||||
| const cubicmap = loadTextureFromImage(image);       // Convert image to texture to display (VRAM)
 | ||||
| 
 | ||||
| const mesh = genMeshCubicmap(image, new Vector3(1.0, 1.0, 1.0)); | ||||
| const model = loadModelFromMesh(mesh); | ||||
| 
 | ||||
| // NOTE: By default each cube is mapped to one part of texture atlas
 | ||||
| const texture = loadTexture("assets/cubicmap_atlas.png");    // Load map texture
 | ||||
| //model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;    // Set map diffuse texture
 | ||||
| 
 | ||||
| const mapPosition = new Vector3(-16.0, 0.0, -8.0);          // Set model position
 | ||||
| 
 | ||||
| image = null;  // Unload cubesmap image from RAM, already uploaded to VRAM
 | ||||
| 
 | ||||
| setTargetFPS(60);                   // Set our game to run at 60 frames-per-second
 | ||||
| //--------------------------------------------------------------------------------------
 | ||||
| 
 | ||||
| // Main game loop
 | ||||
| while (!windowShouldClose())        // Detect window close button or ESC key
 | ||||
| { | ||||
|     // Update
 | ||||
|     //----------------------------------------------------------------------------------
 | ||||
|     updateCamera(camera, CAMERA_ORBITAL); | ||||
|     //----------------------------------------------------------------------------------
 | ||||
| 
 | ||||
|     // Draw
 | ||||
|     //----------------------------------------------------------------------------------
 | ||||
|     beginDrawing(); | ||||
| 
 | ||||
|         clearBackground(RAYWHITE); | ||||
| 
 | ||||
|         beginMode3D(camera); | ||||
| 
 | ||||
|             drawModel(model, mapPosition, 1.0, WHITE); | ||||
| 
 | ||||
|         endMode3D(); | ||||
| 
 | ||||
|         drawTextureEx(cubicmap, new Vector2(screenWidth - cubicmap.width*4.0 - 20, 20.0), 0.0, 4.0, WHITE); | ||||
|         drawRectangleLines(screenWidth - cubicmap.width*4 - 20, 20, cubicmap.width*4, cubicmap.height*4, GREEN); | ||||
| 
 | ||||
|         drawText("cubicmap image used to", 658, 90, 10, GRAY); | ||||
|         drawText("generate map 3d model", 658, 104, 10, GRAY); | ||||
| 
 | ||||
|         drawFPS(10, 10); | ||||
| 
 | ||||
|     endDrawing(); | ||||
|     //----------------------------------------------------------------------------------
 | ||||
| } | ||||
| 
 | ||||
| // De-Initialization
 | ||||
| //--------------------------------------------------------------------------------------
 | ||||
| cubicmap = null // Unload cubicmap texture
 | ||||
| texture = null // Unload map texture
 | ||||
| model = null // Unload map model
 | ||||
| 
 | ||||
| closeWindow();              // Close window and OpenGL context
 | ||||
| //--------------------------------------------------------------------------------------
 | ||||
| 
 | ||||
		Loading…
	
		Reference in New Issue