Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arcanis/rtworldreader
Javascript library for importing .rtw files into webgl applications
https://github.com/arcanis/rtworldreader
Last synced: 2 months ago
JSON representation
Javascript library for importing .rtw files into webgl applications
- Host: GitHub
- URL: https://github.com/arcanis/rtworldreader
- Owner: arcanis
- Created: 2013-07-14T13:41:26.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-09-19T06:55:52.000Z (over 9 years ago)
- Last Synced: 2024-05-01T21:19:41.182Z (8 months ago)
- Language: JavaScript
- Homepage: http://arcanis.github.io/RTWorldReader/example/
- Size: 617 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RTWorldReader
RTWorldReader is a javascript library dedicated to read and parse `.rtw` files, which are generated generated by the [Runtime World](http://runtimelegend.com/rep/rtworld/index) 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:
```js
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](http://www.runtimelegend.com/rep/rtworld/wiki?name=Build+and+Prepare+Runtime+World)).
**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`, booleanYou 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](https://github.com/arcanis/RTWorldReader/blob/master/sources/three.js) to find out how to use them. But really, it's just like a jQuery object.
## Example
You can see a live example [here](http://arcanis.github.io/RTWorldReader/example/) (source code [here](https://github.com/arcanis/RTWorldReader/blob/master/example/sources/example.js)).
![Demonstration](http://www.clipular.com/c?10643005=O4CDZaomPAtl8uZ4Akwy1UYHgTM&f=.png)
## 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.