Skip to content

Commit

Permalink
Fixed CRLF issues with global find and dos2unix:
Browse files Browse the repository at this point in the history
find . -not \( -path "./.git/*" -o -path "./node_modules/*" \) -type f -exec dos2unix {} \;
Updated docs from three.js
  • Loading branch information
kaisalmen committed Feb 6, 2018
1 parent 9cb11c2 commit 5c63ec2
Show file tree
Hide file tree
Showing 8 changed files with 1,035 additions and 1,012 deletions.
88 changes: 44 additions & 44 deletions .gitignore
@@ -1,44 +1,44 @@
.idea

/build
/node_modules

/resource/obj/1*
/resource/obj/2*
/resource/obj/capsule
/resource/obj/cerberus
/resource/obj/datamogensen
/resource/obj/emmy3d
/resource/obj/PTV1
/resource/obj/rolleiflex
/resource/obj/totoro
/resource/obj/vive-controller
/resource/obj/walt
/resource/obj/zomax
/resource/pcd

/screenshots

/test/meshspray/main.html
/test/meshspray/main.min.html
/test/meshspray/webgl_*.html
/test/objloader2/main.html
/test/objloader2/main.min.html
/test/objloader2/webgl_*.html
/test/wwobjloader2/main.html
/test/wwobjloader2/main.min.html
/test/wwobjloader2/webgl_*.html
/test/wwobjloader2stage/main.html
/test/wwobjloader2stage/main.min.html
/test/wwobjloader2stage/webgl_*.html
/test/wwparallels/main.html
/test/wwparallels/main.min.html
/test/wwparallels/webgl_*.html

/*.log
/*.tgz
/docs/styles
/docs/fonts
/docs/img
/docs/scripts
/docs/*
.idea

/build
/node_modules

/resource/obj/1*
/resource/obj/2*
/resource/obj/capsule
/resource/obj/cerberus
/resource/obj/datamogensen
/resource/obj/emmy3d
/resource/obj/PTV1
/resource/obj/rolleiflex
/resource/obj/totoro
/resource/obj/vive-controller
/resource/obj/walt
/resource/obj/zomax
/resource/pcd

/screenshots

/test/meshspray/main.html
/test/meshspray/main.min.html
/test/meshspray/webgl_*.html
/test/objloader2/main.html
/test/objloader2/main.min.html
/test/objloader2/webgl_*.html
/test/wwobjloader2/main.html
/test/wwobjloader2/main.min.html
/test/wwobjloader2/webgl_*.html
/test/wwobjloader2stage/main.html
/test/wwobjloader2stage/main.min.html
/test/wwobjloader2stage/webgl_*.html
/test/wwparallels/main.html
/test/wwparallels/main.min.html
/test/wwparallels/webgl_*.html

/*.log
/*.tgz
/docs/styles
/docs/fonts
/docs/img
/docs/scripts
/docs/*
14 changes: 7 additions & 7 deletions LICENSE
@@ -1,8 +1,8 @@
The MIT License (MIT)
Copyright (c) 2016-2017 Kai Salmen
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 MIT License (MIT)
Copyright (c) 2016-2017 Kai Salmen

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.
186 changes: 93 additions & 93 deletions README.md
@@ -1,93 +1,93 @@
OBJLoader2 (sync&async) for three.js
===

[![Latest NPM release](https://img.shields.io/npm/v/wwobjloader2.svg)](https://www.npmjs.com/package/wwobjloader2)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/kaisalmen/WWOBJLoader/blob/master/LICENSE)

OBJLoader2 is a new loader for the OBJ file format that is additionally executable within a web worker.

Interested in recent changes? Check the [CHANGELOG](CHANGELOG.md).

## Repository structure / NPM content
The directory structure is organized as follows:
- **build**: Contains build libraries and documentation (NPM only)
- **src**: Contains the sources for the loaders
- **test**: Contains Tests/HTML examples
- **resource**: Contains OBJs, MTLs and textures (GitHub only)

## Building
**This only applies to GitHub:** Before you can start to play around some post-checkout initialization steps have to be performed.<br>
**[npm](https://nodejs.org)** and **[gulp](http://gulpjs.com/)** must be installed on your local platform. They are required for retrieving dependencies and for building combined source bundles and the documentation.
After checkout run:<br>
```bash
npm update
```

You require gulp to be able to build the bundles. If you have not yet installed the cli, execute this:<br>
```bash
npm install --global gulp-cli
```

From the project's root run `gulp` to create The documentation in directory **build/docs** and the bundles in directory **build**:
- **OBJLoader2[.min].js**: Contains all code required for the loader to work
- **LoaderSupport[.min].js**: Consists of common support functions, worker control and worker director code

### Models and resources
Use gulp to download missing resources (OBJ, MTL files and textures):
```bash
gulp get-resources
```


## Implementation Overview
Version 2.0.0 introduced substantial enhancements and chances especially but not only to the way the web worker execution of the parser is performed:
- `OBJLoader2` and `WWOBJLoader2` have been fused. Worker based asynchronous execution of the loader is now handled by `parseAsync`, `load` with `useAsync` flag or `run` which is used for batch processing (see example **OBJLoader2 usage options** below). Common functionality independent of OBJ parsing has been moved to package `THREE.LoaderSupport` located in `LoaderSupport.js`. The Parser can either be executed directly or it is run inside a web worker (`THREE.LoaderSupport.WorkerSupport` handles the building and execution). Raw results are passed to a common mesh builder function. These support classes can be used to transform other Loaders to support asynchronous parsing.

### Features
`OBJLoader2` contains all features of the existing `OBJLoader` and it has to . These are some interesting POIs:
- `OBJLoader2.parse` method accepts arraybuffer or string as input. Text processing is approx. 15-20 pecent slower
- `OBJLoader2.parseAsync` only accepts arraybuffer as input as buffer is passed to worker.
- Face N-Gons are supported
- Indexed rendering is now available, but `OBJLoader2` must it must be switched on via `setUseIndices` (see `useLoadSync` in example **OBJLoader2 usage options** below).
- `OBJLoader2` must now be re-instantiated every time it is used, but caching of worker code via `WorkerSupport` and `LoaderDirector` is available
- `ConsoleLogger` now encapsulates all console logging. Logging can be fully deactivated or switched to debug mode (issue #15)
- Progress callbacks provide numerical values to indicate overall progress of download or parsing (issue #16)
- New mesh detection solely relies on 'v' and 'f' occurrences. 'o' and 'g' are meta information, that no longer drive the decision (issue #21)
- Multi-Materials are created when needed
- Flat smoothing defined by "s 0" or "s off" is supported and Multi-Material is created when one object/group defines both smoothing groups equal and not equal to zero.
- Multiple mesh definitions within one group are supported (issue #27)
- Negative face indices are now supported (issue #28)
- Support for points (added) and lines (fixed) (issue #33)

### Directing the symphony
`LoaderDirector` is able to create a configurable amount of `OBJLoader2` via reflection just by providing parameters. It is now able to direct all loaders that over automation via `run` and use `WorkerSupport` to allow running the `Parser` in a web worker. An instruction queue is fed and all workers created will work to deplete it once they have been started.


### Web Worker Support
`LoaderSupport` offers utility functions used to serialize existing code into strings that are used to build the web worker code. Any loader that uses it must provide a function that builds the parser code (for example see `buildCode` inside `OBJLoader2.parseAsync`). `WorkerSupport` provides wrapper code to create the web worker and to organize communication with it. Configuration of the Parser inside the worker is handled by a configuration object that configures the parser identical to synchronous usage.

## Examples:
[OBJLoader2 basic usage](https://kaisalmen.de/wwobjloader2/objloader2/main.min.html)<br>
[OBJLoader2 usage options](https://kaisalmen.de/wwobjloader2/wwobjloader2/main.min.html)<br>
[OBJLoader2 Stage](https://kaisalmen.de/wwobjloader2/wwobjloader2stage/main.min.html)<br>
[LoaderDirector Mesh Spray](https://kaisalmen.de/wwobjloader2/meshspray/main.min.html)<br>
[LoaderDirector Parallels Demo](https://kaisalmen.de/wwobjloader2/wwparallels/main.min.html)<br>

## Http server for development
If you have `docker` and `docker-compose` installed on your development platform, you are now able to launch `nginx` which is serving the complete content of this repository. Any changes to files are directly available in the HTTP server. This is solely meant for development.

From the command-line, use the following command to launch the HTTP server:
```bash
docker-compose up -d
```
Content is available here: [http://localhost:8085](http://localhost:8085)<br>
Nginx configuration is stored here: `resource/nginx/nginx.conf`. Adjust according your needs.

From the command-line, use the following to stop the HTTP server:
```bash
docker-compose down
```

Have fun!

Kai
OBJLoader2 (sync&async) for three.js
===

[![Latest NPM release](https://img.shields.io/npm/v/wwobjloader2.svg)](https://www.npmjs.com/package/wwobjloader2)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/kaisalmen/WWOBJLoader/blob/master/LICENSE)

OBJLoader2 is a new loader for the OBJ file format that is additionally executable within a web worker.

Interested in recent changes? Check the [CHANGELOG](CHANGELOG.md).

## Repository structure / NPM content
The directory structure is organized as follows:
- **build**: Contains build libraries and documentation (NPM only)
- **src**: Contains the sources for the loaders
- **test**: Contains Tests/HTML examples
- **resource**: Contains OBJs, MTLs and textures (GitHub only)

## Building
**This only applies to GitHub:** Before you can start to play around some post-checkout initialization steps have to be performed.<br>
**[npm](https://nodejs.org)** and **[gulp](http://gulpjs.com/)** must be installed on your local platform. They are required for retrieving dependencies and for building combined source bundles and the documentation.
After checkout run:<br>
```bash
npm update
```

You require gulp to be able to build the bundles. If you have not yet installed the cli, execute this:<br>
```bash
npm install --global gulp-cli
```

From the project's root run `gulp` to create The documentation in directory **build/docs** and the bundles in directory **build**:
- **OBJLoader2[.min].js**: Contains all code required for the loader to work
- **LoaderSupport[.min].js**: Consists of common support functions, worker control and worker director code

### Models and resources
Use gulp to download missing resources (OBJ, MTL files and textures):
```bash
gulp get-resources
```


## Implementation Overview
Version 2.0.0 introduced substantial enhancements and chances especially but not only to the way the web worker execution of the parser is performed:
- `OBJLoader2` and `WWOBJLoader2` have been fused. Worker based asynchronous execution of the loader is now handled by `parseAsync`, `load` with `useAsync` flag or `run` which is used for batch processing (see example **OBJLoader2 usage options** below). Common functionality independent of OBJ parsing has been moved to package `THREE.LoaderSupport` located in `LoaderSupport.js`. The Parser can either be executed directly or it is run inside a web worker (`THREE.LoaderSupport.WorkerSupport` handles the building and execution). Raw results are passed to a common mesh builder function. These support classes can be used to transform other Loaders to support asynchronous parsing.

### Features
`OBJLoader2` contains all features of the existing `OBJLoader` and it has to . These are some interesting POIs:
- `OBJLoader2.parse` method accepts arraybuffer or string as input. Text processing is approx. 15-20 pecent slower
- `OBJLoader2.parseAsync` only accepts arraybuffer as input as buffer is passed to worker.
- Face N-Gons are supported
- Indexed rendering is now available, but `OBJLoader2` must it must be switched on via `setUseIndices` (see `useLoadSync` in example **OBJLoader2 usage options** below).
- `OBJLoader2` must now be re-instantiated every time it is used, but caching of worker code via `WorkerSupport` and `LoaderDirector` is available
- `ConsoleLogger` now encapsulates all console logging. Logging can be fully deactivated or switched to debug mode (issue #15)
- Progress callbacks provide numerical values to indicate overall progress of download or parsing (issue #16)
- New mesh detection solely relies on 'v' and 'f' occurrences. 'o' and 'g' are meta information, that no longer drive the decision (issue #21)
- Multi-Materials are created when needed
- Flat smoothing defined by "s 0" or "s off" is supported and Multi-Material is created when one object/group defines both smoothing groups equal and not equal to zero.
- Multiple mesh definitions within one group are supported (issue #27)
- Negative face indices are now supported (issue #28)
- Support for points (added) and lines (fixed) (issue #33)

### Directing the symphony
`LoaderDirector` is able to create a configurable amount of `OBJLoader2` via reflection just by providing parameters. It is now able to direct all loaders that over automation via `run` and use `WorkerSupport` to allow running the `Parser` in a web worker. An instruction queue is fed and all workers created will work to deplete it once they have been started.


### Web Worker Support
`LoaderSupport` offers utility functions used to serialize existing code into strings that are used to build the web worker code. Any loader that uses it must provide a function that builds the parser code (for example see `buildCode` inside `OBJLoader2.parseAsync`). `WorkerSupport` provides wrapper code to create the web worker and to organize communication with it. Configuration of the Parser inside the worker is handled by a configuration object that configures the parser identical to synchronous usage.

## Examples:
[OBJLoader2 basic usage](https://kaisalmen.de/wwobjloader2/objloader2/main.min.html)<br>
[OBJLoader2 usage options](https://kaisalmen.de/wwobjloader2/wwobjloader2/main.min.html)<br>
[OBJLoader2 Stage](https://kaisalmen.de/wwobjloader2/wwobjloader2stage/main.min.html)<br>
[LoaderDirector Mesh Spray](https://kaisalmen.de/wwobjloader2/meshspray/main.min.html)<br>
[LoaderDirector Parallels Demo](https://kaisalmen.de/wwobjloader2/wwparallels/main.min.html)<br>

## Http server for development
If you have `docker` and `docker-compose` installed on your development platform, you are now able to launch `nginx` which is serving the complete content of this repository. Any changes to files are directly available in the HTTP server. This is solely meant for development.

From the command-line, use the following command to launch the HTTP server:
```bash
docker-compose up -d
```
Content is available here: [http://localhost:8085](http://localhost:8085)<br>
Nginx configuration is stored here: `resource/nginx/nginx.conf`. Adjust according your needs.

From the command-line, use the following to stop the HTTP server:
```bash
docker-compose down
```

Have fun!

Kai
22 changes: 11 additions & 11 deletions docker-compose.yml
@@ -1,11 +1,11 @@
version: '3.3'

services:
obj2nginx:
image: nginx
ports:
- 8085:80
volumes:
- .:/usr/share/nginx/html:ro
- ./resource/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
container_name: obj2nginx
version: '3.3'

services:
obj2nginx:
image: nginx
ports:
- 8085:80
volumes:
- .:/usr/share/nginx/html:ro
- ./resource/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
container_name: obj2nginx
27 changes: 25 additions & 2 deletions docs/threejs/LoaderSupport.html
Expand Up @@ -405,12 +405,35 @@ <h3>LoaderBase( [page:LoadingManager manager], [page:LoaderSupport.ConsoleLogger
[page:LoaderSupport.ConsoleLogger logger] - logger to be used
</div>
<div>
Base class to be used by loaders.
Base class to be used by Loaders that provide load, parse, parseAsync and run
</div>


<h2>Methods</h2>


<h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError], [page:Function onMeshAlter], [page:boolean useAsync] )</h3>
<div>
[page:String url] - A string containing the path/URL of the file to be loaded.<br>
[page:Function onLoad] - A function to be called after loading is successfully completed. The function receives loaded [page:Object3D] as an argument.<br>
[page:Function onProgress] - (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, which contains [page:Integer total] and [page:Integer loaded] bytes.<br>
[page:Function onError] - (optional) A function to be called if an error occurs during loading. The function receives the error as an argument.<br>
[page:Function onMeshAlter] - (optional) A function to be called after a new mesh raw data becomes available for alteration.<br>
[page:boolean useAsync] - (optional) If true, uses async loading with worker, if false loads data synchronously.
</div>
<div>
Use this convenient method to load a file at the given URL. By default the fileLoader uses an ArrayBuffer.
</div>

<h3>[method:ConsoleLogger checkResourceDescriptorFiles] ( [page:THREE.LoaderSupport.ResourceDescriptor resources], [page:Object fileDesc] )</h3>
<div>
[page:THREE.LoaderSupport.ResourceDescriptor resources] - Array of {@link THREE.LoaderSupport.ResourceDescriptor}
[page:Object fileDesc] - Object describing which resources are of interest (ext, type (string or UInt8Array) and ignore (boolean))
</div>
<div>
Identify files or content of interest from an Array of {@link THREE.LoaderSupport.ResourceDescriptor}. Returns Object with each "ext" and the corresponding {@link THREE.LoaderSupport.ResourceDescriptor}
</div>


<h3>[method:ConsoleLogger getLogger] ()</h3>
<div>
Returns [page:LoaderSupport.ConsoleLogger].
Expand Down

0 comments on commit 5c63ec2

Please sign in to comment.