GitXplorerGitXplorer
a

RTWorldReader

public
6 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
02dc606c26dd9d0864b05f4978c5fcd393d38bb2

Removes debug logs

aarcanis committed 9 years ago
Unverified
8d2fc320f4a9ccf9434052478278a715c0b87078

Promisifies the library

aarcanis committed 9 years ago
Unverified
59b029f241c9325ab5f6289042c986bf587ca965

Fixes RTWorldReader to work with the latest Runtime World release

aarcanis committed 9 years ago
Unverified
09e0ada904a86b657d032244a28e00164124ddb9

Adds ambient light

aarcanis committed 11 years ago
Unverified
4ab80c9de14081fc780e7d3807e5b80f20698229

Fixes more typos

aarcanis committed 11 years ago
Unverified
11b0a26d326014b6ca20cda1f3f9ac9d1219e059

Fixes typo

aarcanis committed 11 years ago

README

The README file for this repository.

RTWorldReader

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).

API

Standard

RTWorldReader.loadUrl( url ) -> Promise< Node >

Load a world from an URL. The URL is expected returning a binary rtw file.

RTWorldReader.loadBuffer( buffer ) -> Promise< Node >

Load a world directly from the input buffer parameter.


Importers

new RTWorldReader.ThreeEntity( worldNode )

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.


For developers

RTWorldReader.debug

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, boolean
  • compiling, boolean
  • textures, boolean
  • lightmaps, boolean
  • brushes, boolean

You sometime have to switch on multiple flags to display some informations.

new RTWorldReader.Node( [:] )

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.

Example

You can see a live example here (source code here).

Demonstration

License (MIT)

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.