2015-05-06 15:31:52 +02:00
|
|
|
# 3D Interface
|
2015-05-19 18:03:35 +02:00
|
|
|
A prototype for a user-friendly 3D interface allowing to browse 3D scenes /
|
|
|
|
models written with Node.js.
|
2015-05-06 15:31:52 +02:00
|
|
|
|
2015-05-19 18:03:35 +02:00
|
|
|
It is hosted by [OpenShift](https://www.openshift.com/) at
|
|
|
|
[3dinterface.no-ip.org](http://3dinterface.no-ip.org).
|
2015-05-11 17:45:08 +02:00
|
|
|
|
2015-06-23 15:31:23 +02:00
|
|
|
## Database setup
|
2015-05-19 18:03:35 +02:00
|
|
|
First you need to configure the database. You can create a postgres database
|
|
|
|
where you want, and you can initialize it by running the script
|
|
|
|
`sql/backup.pgsql`.
|
|
|
|
|
2015-06-23 15:31:23 +02:00
|
|
|
## Nodejs configuration
|
2015-05-19 18:03:35 +02:00
|
|
|
Then, you have to set up nodejs to access to your database. Basically, you have
|
|
|
|
to create a file `private.js` at the root of the repository looking like this :
|
|
|
|
|
|
|
|
``` javascript
|
|
|
|
module.exports.url = ... // the url to connect to your database
|
|
|
|
|
|
|
|
module.exports.secret = ... // A secret string used to hash stuff
|
|
|
|
```
|
2015-06-23 15:31:23 +02:00
|
|
|
## Compiling the static js files
|
2015-05-29 10:49:36 +02:00
|
|
|
There are two ways to compile the static js files :
|
|
|
|
|
2015-06-30 15:13:49 +02:00
|
|
|
- either you don't mind not minifying the code, and you can use `compiler.sh`
|
|
|
|
to compile
|
|
|
|
- or you absolutely want to minify the code
|
2015-05-29 10:49:36 +02:00
|
|
|
|
2015-06-30 15:13:49 +02:00
|
|
|
First, `cd` to `utils/`. Here you'll find a script `build_all.sh` that, as its
|
|
|
|
name suggests, builds all. By default, it minifies the code, but you can pass
|
|
|
|
the option `--dev` to avoid minifying (which is a quite long operation).
|
2015-05-29 10:49:36 +02:00
|
|
|
|
2015-06-30 15:13:49 +02:00
|
|
|
If it worked, you should see lots of files in `*.min.js` in your `static/js`
|
|
|
|
directory, and a `geo.min.js` in your `lib` (at the root of the repository).
|
2015-05-22 18:05:24 +02:00
|
|
|
|
2015-06-23 15:31:23 +02:00
|
|
|
## Running the server
|
2015-05-19 18:03:35 +02:00
|
|
|
As usual with NodeJS, it's quite easy to test. Just ensure you have `node`
|
|
|
|
installed on your machine, clone this repo somewhere, and then, in the repo do
|
2015-05-11 17:45:08 +02:00
|
|
|
|
|
|
|
``` sh
|
|
|
|
npm install
|
|
|
|
node server.js
|
|
|
|
```
|
|
|
|
|
2015-06-30 15:13:49 +02:00
|
|
|
You should be able to go to [localhost:4000](http://localhost:4000) and see the
|
|
|
|
result.
|
|
|
|
|
|
|
|
Please note that some static files (some meshes / textures) are not on this
|
|
|
|
repository (especially the heavy ones).
|
2015-06-12 11:30:01 +02:00
|
|
|
|
2015-06-30 15:13:49 +02:00
|
|
|
## Developping
|
|
|
|
If you want to dev on this project, the `utils/demon.sh` may help you : it is
|
|
|
|
based on [nodemon](https://github.com/remy/nodemon) (that basically restarts
|
|
|
|
the server everytime there is a change in the code) and
|
|
|
|
[inotify](http://man7.org/linux/man-pages/man7/inotify.7.html) (that basically
|
|
|
|
recompiles everything when there is a modification). To use it, just `cd` to
|
|
|
|
`utils` and run `demon.sh` (note that it doesn't minify the code since this
|
|
|
|
operation is heavy and too long to redo everytime there is a change).
|