Jarosław Maciejewski
Minecraft in FrameVR.io
Important information
Currently writing article works with Minecraft 1.16
Currently, Mineways does not export and cannot see the following [do not put them on your map in Minecraft]:
- the inscriptions on the boards
- book on the landing
- candles [candles, *_candle] [added in MC 1.17]
- boat
- minecart
- spore_bloosom
- hanging_roots
- glow_lichen
- *amethyst*
- *dripstone*
- big_dripleaf
- moss_carpet
- azalea
- oxidized_copper
- waxed_cut_copper
- waxed_cooper_block
- oxidized_cut_copper_stairs
- raw_iron_block
- raw_copper_block
- raw_gold_block
Introduction
FrameVR.io is an internet project that allows you to explore the virtual world, mainly using VR glasses, although you can also explore using a computer or smartphone. It offers, among others the ability to share your screen, voice chat, password protect your scenery, load your own scenery, add various resources to the scenery: pictures, 360° spheres, 360° movies, PDFs, videos, sounds or models. There are a lot of these options.
I decided that one of my scenery in FrameVR will be based on the famous world from Minecraft, which is available to the public at: https://framevr.io/nitro. It turned out that a lot of people were delighted with my idea of the scenery in FrameVR (which is very nice to me) and started asking me how I did it.
So, in this article, I want to provide a description from creating a world in Minecraft to exporting to FrameVR.
Here is a short list of my comments at the beginning:
- you should have Minecraft installed on your computer,
- you should have basic Blender skills,
- you should have node.js, which should be added to the system path,
- it does everything on Windows, but should be done on other system without any problems.
Step one: Minecraft
We will start our adventure with Minecraft, but before we launch the game, it is worth drawing a preview of our world on a piece of paper or in your head. Then we will know what to do in Minecraft and we will save ourselves time for unnecessary thinking about what else to add to the scenery. Our world should not be large, all elements placed reasonably so as to fit within the limit imposed by FrameVR for the environment, which is currently 15 MB.
Before you run Minecraft, I recommend installing the following plugins:
- Fabric API – API base for most other plugins,
- Fabric Mod – a plug that “connects” the above API to other plugins (with Fabric API it is required),
- Warp Mod Fabric – a plug-in that allows you to manage and navigate through a saved list of places,
- World Edit – a known plug that allows you to perform some operations more easily.
The above plugins are recommended but not required, however, it is worth making your work with Minecraft easier.
If we are ready, we have a plan, we know what we want to do, we run Minecraft (from the original instance in the latest version or Fabric instance), we go to the single player mode, we create a new world.
When creating a new world, we choose the following options (they are my recommendations):
- game mode: creative – access to all options,
- difficulty level: peaceful – all mobs are nice to us,
- allow cheats: enabled – we enable the possibility of entering commands in the chat,
- in Game Rules:
- World Updates:
- Advance time of day: off – turn off the automatic change of time of day
- Update weather: wyłączony – we turn off the automatic change of weather,
- Random tick speed rate: 1000 – we speed up the game time a bit,
- Drops – here we give everything off,
- Spawning – here we give everything off,
- World Updates:
- More world options…
- Generate structures: on/off – it’s up to us whether we want to generate additional structures, e.g. villages,
- Bonus chest: disabled – we don’t need it,
- World type: the type of map depends on us, I work on a super flat one.
If we set everything up in the options we wanted, we create the world and enter it.
We immediately enter two commands in the chat, i.e. the sky is always cloudless and we always have noon:
/weather clear
/time set noon
When creating our world, we keep the following tips in mind:
- there is no need to put text on the plates, because they will not be exported,
In general, my world in Minecraft looks like this:
The characteristic rectangle made of gold ore blocks attracts attention. In my world, it marks the limits to which the planned idea is to be built.
If our work in Minecraft is ready, we are leaving the world and the game.
Step two: Mineways
The next step is export our Minecraft world to OBJ file that can be easily read by Blender. To do this, we need the Mineways program Mineways, to reach this end point, which we download from the website, unpack the ZIP archive and run it. Although the program description in this thread is quite extensive, the program itself is easy to use. I recommend that you close other memory eaters programs before exporting, because while exporting, we may get a message that the program was unable to reserve enough memory.
We start our steps in this program by loading our world into the program.
We do this by clicking on ‘File’ in the top bar of the program and selecting ‘Open World’. We will see here a list with the names of the worlds from Minecraft, so we choose our target from which we have made our world.
Our world will be loaded into the program. We see everything from above.
Operating the program with the keyboard and mouse is very simple:
- -/+ or moving the mouse wheel – zooming the map,
- holding the left mouse button – moving the map,
- holding the right mouse button – selecting the area to be exported.
A message will appear, which will inform you that the depth level has been set by the program and will be changed. Click on OK.
On the map, we see a section of our world that is surrounded by the characteristic yellow lines that are actually gold ore blocks.
We zoom in on the map and by holding down the right mouse button we make the appropriate rectangle that will cover the area we want to export. We can improve this area, just zoom in on the map, move it to the selected border and use the mouse cursor (it should be changed to the icon for changing the vertical dimension) to change the borders of the purple area.
Be sure not to mark the yellow lines when selecting the area.
In the upper part of the program window you will find two bars:
- Height – the maximum height is 255 and that is what the bar is set to. Up to this amount, the program will take into account the blocks set.
- Depth – this is the minimum height from which blocks will be considered.
Now we decide what textures are to be applied to the individual blocks from Minecraft.
To change it, click on ‘File’ => ‘Choose Terrain File’. We have a list here with the names of the texture packs that are in the Mineways program folder.
By default, the package used is ‘terrainExt.png’, so if we want to use only Minecraft block textures, we don’t need to change anything here. Otherwise we can choose a different package from the list. The appearance of the individual texture packs can be found on the Mineways website Mineways (Documentation => Textures), where there are project links to the Sketchfab website and other preview images.
I use the terrainExt_JG-RTX256 package, which contains other higher resolution textures and which are pleasing to the eye, especially since FrameVR is dedicated to people who will navigate the scenery wearing VR glasses.
You can add your own texture assets to the Mineways folder. On the website of this program you will find instructions on how to convert to a single file, where it basically comes down to issuing two commands on the command line.
From the ‘File’ menu, select the ‘Export for Rendering’ option and in the new dialog we choose the location and name of the file, where we want to save our OBJ file with the selected fragment of our work. For the file type, make sure the option: ‘Wavefront OBJ, absolute (* .obj)’ is selected.
After clicking on ‘Save’ another dialog box will appear with more options to choose from.
In this window, we basically mark two options:
- ‘Export tiles for textures to’
- ‘Export separate types’
- ‘Split by block type’
And just in case, we check that ‘Make each block’ is set to 1000.
It’s best to compare your window with the picture. We ignore the values for ‘World coordinates selection volume’, which will be different when selecting the area in the program.
The option ‘Export separate types’ combined with the ‘Split by block type’ allows you to reduce the size of the resulting file by more than 50% (as opposed to the option ‘Export individuals blocks’) because the program combines the same blocks that are “glued” into one block, removes the faces of the blocks that are not visible to the recipient. So we can safely build full structures in Minecraft because they will be simplified anyway when exporting to a file.
If everything is correct, click on ‘OK’. The program will export our world to an OBJ file.
When the whole process is finished, a message will be displayed that shows statistics and a question whether it should appear every time you export to a file until we close the program completely. Click on ‘No’ and close the program.
An additional 3 items should appear in the OBJ file save location: .obj file, .mtl file, and textures folder.
Step three: Blender
In Blender, we will process our model in more detail, add other objects and export it to a GLB file that is supported by FrameVR.
So we run Blender, delete the current content of the workspace, and import our OBJ model to Blender. To do this, select ‘File’ => ‘Import’ => ‘Wavefront (.obj)’ from the menu, select the location where our OBJ model is located, click the ‘Import OBJ’ button (there is no need to change the settings on the right windows). Our model will be imported to Blender.
We change the way of displaying textures (key [Z] and then [2]) – ‘Viewport shading’ to ‘Material Preview’. Thanks to this, we can see the model with all textures regardless of the lighting.
We move our object to set the starting point for the avatars on the surface of the block. In Blender, this is easy as the starting point will be the ‘World Origin’ point indicated by two clearly intersecting lines: red and green. Initially, this point is also indicated by the locate, move, and transform cursor. Let’s also set the appropriate height – with the ‘super flat’ world we lower the object.
On the ‘Object Properties’ tab in the ‘Transform’ section, where we have given the location of the object, let’s make sure that X, Y and Z contain only integers.
If we look at our world, we will notice some imperfections, e.g. a tram shelter made of glass is not transparent, the water is too blue, there are black borders around the flowers. It doesn’t look very interesting.
To fix this problem, for these textures you should set ‘Alpha’ as the image referring to ‘Base color’ and ‘Blend Mode’ set to: ‘Alpha Clip’ or ‘Alpha Blend’.
If we have a lot of textures, it is quite a time-consuming task.
That’s why I’m here to help – we’ll use my Python script to fix this problem. To do this, go to the ‘Scripting’ tab and create a new window. Paste my script in this window and run it.
import bpy
import re
from mathutils import *
from math import *
for material in bpy.data.materials:
material.shadow_method = 'NONE'
#When method=BLEND
arrayMaterials = [".*water_still.*", ".*water_flow.*", ".*glass.*", ".*sunflower_back.*", ".*sunflower_front.*", ".*trapdoor.*"]
for am in arrayMaterials:
if re.match(am, material.name):
links = material.node_tree.links
nodes = material.node_tree.nodes
material.blend_method = 'BLEND'
links.new(nodes['Principled BSDF'].inputs['Alpha'], nodes['Image Texture'].outputs['Alpha'])
#When method=CLIP
arrayMaterials = [".*leaves.*", ".*fern.*", ".*dandelion.*", ".*blue_orchid.*", ".*allium.*", ".*azure_bluet.*", ".*tulip.*", ".*oxeye_daisy.*", ".*cornflower.*", ".*lily_.*", ".*torch.*", ".*vine.*", ".*sunflower_top.*", ".*lilac.*", ".*peony.*", ".*campfire_fire.*", ".*campfire_log.*", ".*soul_campfire.*", ".*grass.*", ".*sunflower_bottom.*", ".*MW_bed.*", ".*bamboo_small_leaves.*", ".*bamboo_large_leaves.*", ".*ladder.*", ".*stonecutter.*", ".*bell.*", ".*cobweb.*", ".*_door_.*", ".*rail.*", ".*rose.*", ".*poppy.*", ".*scaffolding.*", "sugar_cane", "sea_pickle", ".*fungus.*", ".*coral.*", ".*kelp.*", ".*mushroom.*", "crimson_roots", "warped_roots", "nether_sprouts", "iron_bars", "chain", ".*lantern.*"]
for am in arrayMaterials:
if re.match(am, material.name):
links = material.node_tree.links
nodes = material.node_tree.nodes
material.blend_method = 'CLIP'
links.new(nodes['Principled BSDF'].inputs['Alpha'], nodes['Image Texture'].outputs['Alpha'])
#Show backface
arrayMaterials = [".*water_still.*", ".*water_flow.*", ".*sunflower_back.*", ".*sunflower_front.*"]
for am in arrayMaterials:
material.show_transparent_back = False
if re.match(am, material.name):
material.show_transparent_back = True
This code fixes the mentioned errors with the transparency of objects, turns off shadows.
If you go back to the ‘Layout’ view you will see that the problems will disappear.
However, I encourage you to use ‘Fly Navigation’ and fly around the entire facility, looking for such strange errors related to the incorrect display of textures and fixing them manually. If you see something like this, add it to the script above, but I tried to include all known block textures in this script.
Only execute this script when you delete the old object and add a new object exported from Mineways.
If we have fixed bugs related to an object, we can add other objects to our Blender project, e.g. for me they are avatar Alex, avatar Steve, Golem, cat.
If in FrameVR our avatar cannot enter, for example up the stairs, add a transparent ‘plane’ as a board to climb at a certain angle (0-60°).
If we added objects, placed them appropriately on the scenery, etc., then we have to do one more operation. When we add such scenery to FrameVR.io, black spots can be noticed in some places, that appear on the underside of objects.
To solve this problem, add the original material image as ‘Emission’ to each material, and set ‘Emission Strength’ to 0.3.
With many materials and many objects it is quite a time consuming task, so I come again with my own script, which will quickly achieve this goal.
So we switch back to the tab: ‘Scripting’, delete the previous content, paste the following content and run:
import bpy
from mathutils import *
from math import *
for objects in bpy.data.objects:
for materialSlots in objects.material_slots:
if not materialSlots.name:
continue
material = bpy.data.materials[materialSlots.name]
material.shadow_method = 'NONE'
material.show_transparent_back = False
if hasattr(material.node_tree, 'nodes'):
nodes = material.node_tree.nodes
if "Image Texture" in nodes:
links = bpy.data.materials[materialSlots.name].node_tree.links
links.new(nodes['Principled BSDF'].inputs['Emission'], nodes['Image Texture'].outputs['Color'])
nodes['Principled BSDF'].inputs['Emission Strength'].default_value = 0.3
We can execute this code every time we add a new object to our project.
If our Blender project is ready, it is worth saving it in Blender format to have the project ready for editing. Before saving, don’t forget to enable the option to pack everything into one file (‘File’ => ‘External Data’ => ‘Automatically Pack Into .blend’).
The export to a GLB file looks like this:
- in the ‘File’ menu select: ‘Export’, and then: gITF 2.0 (.glb/.gltf),
- In the new window, indicate the location where the file is to be saved,
- Make sure that on the right side in ‘Format’ we have the selected option ‘gITF Binary (.glb),
- Click on the button ‘Export gITF 2.0’,
- Our project will be saved to a single GLB file.
Step Four: Compressing the GLB File
The maximum size of a GLB file that can be loaded as an environment on FrameVR is 15 MB. If our file has a larger size, we either reduce the number of elements on the Minecraft map and in Blender project, or we can try to reduce the size of the original GLB using a compression algorithm created by Google. The Draco algorithm add-on comes to the rescue, which is executed as a Node.js script called gltf-pipeline.
Open a command prompt in the folder where the GLB file is located and enter the command to install the gltf-pipeline project available throughout the system:
npm install -g gltf-pipeline
Then enter and confirm the following command:
for /L %i in (0,1,10) do gltf-pipeline -i minecraft.glb -o output_draco_%i.glb -d --draco.compressionLevel %i
where:
- minecraft.glb – the name of the input file, which must be the same as the one exported using Blender.
- output_draco_%i.glb – output file name, %i it serves as information on the level of compression used.
We are waiting for the command to be carried out.
In the example image above, we can see the original GLB file exported from Blender and 11 other additional files that are output files using Draco compression. A compression ratio of 0-10 is given at the end of each name.
You can already see that with the compression at the 0 level, Draco reduces the original GLB file by almost 50%, then to level 2 we get even smaller files slightly over 50%. However, from levels 3 to 10, compression doesn’t really matter that much.
Therefore, I even recommend modifying the above command to generate GLB with compression Draco at 0-2 [change from (0,1,10) to (0,1,2)].
If, even after compression using the Draco algorithm, our GLB file is too large, consider changes in the Blender project, which will reduce the size of the GLB file.
Attachments
The article is a revised version of the first article on zenodo.org