Giter VIP home page Giter VIP logo

rtworldreader's Introduction

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.

rtworldreader's People

Contributors

arcanis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.