Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
kovacsv committed May 3, 2021
2 parents 53af4ac + 98bd1a1 commit 92b993f
Show file tree
Hide file tree
Showing 58 changed files with 4,639 additions and 3,617 deletions.
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"globals" : {
"OV" : true,
"THREE" : false,
"rhino3dm" : false,
"TextEncoder" : false,
"TextDecoder" : false,
"XMLHttpRequest" : false,
Expand Down
34 changes: 20 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The repository is separated into two parts. See more information in the [Develop
- stl (text and binary)
- ply (text and binary)
- gltf (text and binary)
- 3dm (experimental)
- off (text only)

### Export
Expand All @@ -31,24 +32,29 @@ The repository is separated into two parts. See more information in the [Develop
- stl (text and binary)
- ply (text and binary)
- gltf (text and binary)
- 3dm (experimental)
- off (text only)

## Features

- Load model:
- Select files from a file browser dialog
- Drag and drop files from your computer
- Specify files by web url
- Specify files by web url in hash parameters
- Select files from a file browser dialog.
- Drag and drop files from your computer.
- Specify files by web url.
- Specify files by web url in hash parameters.
- Explore model:
- Orbit, pan, zoom
- Set up direction
- Fit to window
- Orbit, pan, zoom.
- Set up direction.
- Fit to window.
- Investigate model:
- List used and missing files
- List all materials and meshes
- Show/hide and zoom to a specific mesh
- List materials used by a specific mesh
- Show model information (model size, vertex and polygon count)
- Export model to various format
- Embed viewer in your website
- List used and missing files.
- List all materials and meshes.
- Show/hide and zoom to a specific mesh.
- List materials used by a specific mesh.
- Show model information (model size, vertex and polygon count).
- Export model to various format.
- Embed viewer in your website.

## External Libraries

Online 3D Viewer uses these wonderful libraries: [jquery](https://github.com/jquery/jquery), [three.js](https://github.com/mrdoob/three.js), [rhino3dm](https://github.com/mcneel/rhino3dm).
21 changes: 21 additions & 0 deletions libs/rhino3dm.license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Robert McNeel & Associates

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.
8 changes: 8 additions & 0 deletions libs/rhino3dm.min.js

Large diffs are not rendered by default.

Binary file added libs/rhino3dm.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "online-3d-viewer",
"description": "Online 3D Viewer",
"version": "0.7.7",
"version": "0.7.8",
"repository": "github:kovacsv/Online3DViewer",
"license": "MIT",
"devDependencies": {
Expand Down
28 changes: 22 additions & 6 deletions source/export/exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,32 @@ OV.Exporter = class
];
}

Export (model, format, extension)
AddExporter (exporter)
{
let files = [];
this.exporters.push (exporter);
}

Export (model, format, extension, callbacks)
{
let exporter = null;
for (let i = 0; i < this.exporters.length; i++) {
let exporter = this.exporters[i];
if (exporter.CanExport (format, extension)) {
exporter.Export (model, format, files);
let currentExporter = this.exporters[i];
if (currentExporter.CanExport (format, extension)) {
exporter = currentExporter;
break;
}
}
return files;
if (exporter === null) {
callbacks.onError ();
return;
}

exporter.Export (model, format, function (files) {
if (files.length === 0) {
callbacks.onError ();
} else {
callbacks.onSuccess (files);
}
});
}
};
9 changes: 6 additions & 3 deletions source/export/exporterbase.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ OV.ExporterBase = class
return false;
}

Export (model, format, files)
Export (model, format, onFinish)
{
this.ExportContent (model, format, files);
let files = [];
this.ExportContent (model, format, files, function () {
onFinish (files);
});
}

ExportContent (model, format, files)
ExportContent (model, format, files, onFinish)
{

}
Expand Down
9 changes: 5 additions & 4 deletions source/export/exportergltf.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ OV.ExporterGltf = class extends OV.ExporterBase
return (format === OV.FileFormat.Text && extension === 'gltf') || (format === OV.FileFormat.Binary && extension === 'glb');
}

ExportContent (model, format, files)
ExportContent (model, format, files, onFinish)
{
if (format === OV.FileFormat.Text) {
this.ExportAsciiContent (model, files);
} else if (format === OV.FileFormat.Binary) {
this.ExportBinaryContent (model, files);
}
onFinish ();
}

ExportAsciiContent (model, files)
Expand Down Expand Up @@ -195,9 +196,8 @@ OV.ExporterGltf = class extends OV.ExporterBase
let writer = new OV.BinaryWriter (mainBufferSize, true);
for (let meshIndex = 0; meshIndex < meshDataArr.length; meshIndex++) {
let meshData = meshDataArr[meshIndex];
let primitives = meshData.buffer.primitives;
for (let primitiveIndex = 0; primitiveIndex < primitives.length; primitiveIndex++) {
let primitive = primitives[primitiveIndex];
for (let primitiveIndex = 0; primitiveIndex < meshData.buffer.PrimitiveCount (); primitiveIndex++) {
let primitive = meshData.buffer.GetPrimitive (primitiveIndex);
let offset = writer.GetPosition ();
for (let i = 0; i < primitive.indices.length; i++) {
writer.WriteUnsignedInteger32 (primitive.indices[i]);
Expand Down Expand Up @@ -408,6 +408,7 @@ OV.ExporterGltf = class extends OV.ExporterBase
roughnessFactor : 1.0
},
emissiveFactor : ColorToRGB (material.emissive),
doubleSided : true,
alphaMode : 'OPAQUE'
};

Expand Down
Loading

0 comments on commit 92b993f

Please sign in to comment.