RTWorldReader is a javascript library dedicated to read and parse .rtw
files, which are generated generated by the Runtime World editor. Quite useful for 3D games, since it allows you to create your world from a full-featured editor, without having to build your own.
RTWorldReader has a built-in importer for Three.js, so that loading a world in a scene can be done in less than four lines of code:
var scene = new THREE.Scene( );
RTWorldReader.loadUrl( "assets/world.rtw" ).then( function ( worldNode ) {
var worldEntity = new RTWorldReader.ThreeEntity( worldNode );
scene.add( worldEntity );
} );
Important: RTWorldReader only works with the latest version of Runtime World! Unfortunately, the latest official release has been made in 2012, so you will have to build the editor yourself (instructions there).
Important: Don't forget to save your maps with their extra data (BGEO, TEXD & LIMD).
Load a world from an URL. The URL is expected returning a binary rtw
file.
Load a world directly from the input buffer parameter.
Returns a new Three.js entity, ready to be inserted in a scene. You of course need to include Three.js in order to use this element. Each entity named in the world editor will be available threw one of the following properties (#
means 'instance') :
RTWorldReader.ThreeEntity#groups
(AENT
chunks)RTWorldReader.ThreeEntity#lights
(PLGT
chunks)RTWorldReader.ThreeEntity#entities
(UENT
chunks)
You can also use RTWorldReader.ThreeEntity#all
, which will contains a full map of the entities, regardless their type. Please note that entities other that groups, lights and user entities are not registed at all for the time being. Please open an issue if it's a problem for you.
Object containing the following debug flags that you can toggle to switch verbosity :
level
, can be one of the following :RTWorldReader.LOG_NONE
RTWorldReader.LOG_NOTICE
RTWorldReader.LOG_WARNING
RTWorldReader.LOG_ERROR
RTWorldReader.LOG_FATAL
loading
, booleancompiling
, booleantextures
, booleanlightmaps
, booleanbrushes
, boolean
You sometime have to switch on multiple flags to display some informations.
A node instance is a jQuery-like object which has the following method :
array( )
get( [ n ] )
at( [ n ] )
slice( [ begin [, end ] ] )
append( item1, ... )
prepend( item1, ... )
forEach( fn, context )
map( fn, context )
filter( fn, context )
children( [ label ] )
find( label )
descendants( )
prop( name )
content( [ label ] )
You should not have to manipulate nodes, except if you need to write your own importer. If that's what you're looking for, consider looking at the source code of bundled importers such as the three.js one to find out how to use them. But really, it's just like a jQuery object.
You can see a live example here (source code here).
Copyright (C) 2013 Maël Nison
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.