Bundle three.js together with the library.

This commit is contained in:
kovacsv 2022-05-20 18:52:37 +02:00
parent d428a5c859
commit f133ced651
45 changed files with 59 additions and 15550 deletions

View File

@ -2,7 +2,6 @@ path_classifiers:
library: library:
- libs/*.js - libs/*.js
- libs/loaders/*.js - libs/loaders/*.js
- libs/three_loaders/*.js
test: test:
- test - test
- sandbox - sandbox

View File

@ -1,21 +0,0 @@
The MIT License
Copyright © 2010-2022 three.js authors
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.

6
libs/three.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,487 +0,0 @@
( function () {
class TGALoader extends THREE.DataTextureLoader {
constructor( manager ) {
super( manager );
}
parse( buffer ) {
// reference from vthibault, https://github.com/vthibault/roBrowser/blob/master/src/Loaders/Targa.js
function tgaCheckHeader( header ) {
switch ( header.image_type ) {
// check indexed type
case TGA_TYPE_INDEXED:
case TGA_TYPE_RLE_INDEXED:
if ( header.colormap_length > 256 || header.colormap_size !== 24 || header.colormap_type !== 1 ) {
console.error( 'THREE.TGALoader: Invalid type colormap data for indexed type.' );
}
break;
// check colormap type
case TGA_TYPE_RGB:
case TGA_TYPE_GREY:
case TGA_TYPE_RLE_RGB:
case TGA_TYPE_RLE_GREY:
if ( header.colormap_type ) {
console.error( 'THREE.TGALoader: Invalid type colormap data for colormap type.' );
}
break;
// What the need of a file without data ?
case TGA_TYPE_NO_DATA:
console.error( 'THREE.TGALoader: No data.' );
// Invalid type ?
default:
console.error( 'THREE.TGALoader: Invalid type "%s".', header.image_type );
} // check image width and height
if ( header.width <= 0 || header.height <= 0 ) {
console.error( 'THREE.TGALoader: Invalid image size.' );
} // check image pixel size
if ( header.pixel_size !== 8 && header.pixel_size !== 16 && header.pixel_size !== 24 && header.pixel_size !== 32 ) {
console.error( 'THREE.TGALoader: Invalid pixel size "%s".', header.pixel_size );
}
} // parse tga image buffer
function tgaParse( use_rle, use_pal, header, offset, data ) {
let pixel_data, palettes;
const pixel_size = header.pixel_size >> 3;
const pixel_total = header.width * header.height * pixel_size; // read palettes
if ( use_pal ) {
palettes = data.subarray( offset, offset += header.colormap_length * ( header.colormap_size >> 3 ) );
} // read RLE
if ( use_rle ) {
pixel_data = new Uint8Array( pixel_total );
let c, count, i;
let shift = 0;
const pixels = new Uint8Array( pixel_size );
while ( shift < pixel_total ) {
c = data[ offset ++ ];
count = ( c & 0x7f ) + 1; // RLE pixels
if ( c & 0x80 ) {
// bind pixel tmp array
for ( i = 0; i < pixel_size; ++ i ) {
pixels[ i ] = data[ offset ++ ];
} // copy pixel array
for ( i = 0; i < count; ++ i ) {
pixel_data.set( pixels, shift + i * pixel_size );
}
shift += pixel_size * count;
} else {
// raw pixels
count *= pixel_size;
for ( i = 0; i < count; ++ i ) {
pixel_data[ shift + i ] = data[ offset ++ ];
}
shift += count;
}
}
} else {
// raw pixels
pixel_data = data.subarray( offset, offset += use_pal ? header.width * header.height : pixel_total );
}
return {
pixel_data: pixel_data,
palettes: palettes
};
}
function tgaGetImageData8bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image, palettes ) {
const colormap = palettes;
let color,
i = 0,
x,
y;
const width = header.width;
for ( y = y_start; y !== y_end; y += y_step ) {
for ( x = x_start; x !== x_end; x += x_step, i ++ ) {
color = image[ i ];
imageData[ ( x + width * y ) * 4 + 3 ] = 255;
imageData[ ( x + width * y ) * 4 + 2 ] = colormap[ color * 3 + 0 ];
imageData[ ( x + width * y ) * 4 + 1 ] = colormap[ color * 3 + 1 ];
imageData[ ( x + width * y ) * 4 + 0 ] = colormap[ color * 3 + 2 ];
}
}
return imageData;
}
function tgaGetImageData16bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) {
let color,
i = 0,
x,
y;
const width = header.width;
for ( y = y_start; y !== y_end; y += y_step ) {
for ( x = x_start; x !== x_end; x += x_step, i += 2 ) {
color = image[ i + 0 ] + ( image[ i + 1 ] << 8 ); // Inversed ?
imageData[ ( x + width * y ) * 4 + 0 ] = ( color & 0x7C00 ) >> 7;
imageData[ ( x + width * y ) * 4 + 1 ] = ( color & 0x03E0 ) >> 2;
imageData[ ( x + width * y ) * 4 + 2 ] = ( color & 0x001F ) >> 3;
imageData[ ( x + width * y ) * 4 + 3 ] = color & 0x8000 ? 0 : 255;
}
}
return imageData;
}
function tgaGetImageData24bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) {
let i = 0,
x,
y;
const width = header.width;
for ( y = y_start; y !== y_end; y += y_step ) {
for ( x = x_start; x !== x_end; x += x_step, i += 3 ) {
imageData[ ( x + width * y ) * 4 + 3 ] = 255;
imageData[ ( x + width * y ) * 4 + 2 ] = image[ i + 0 ];
imageData[ ( x + width * y ) * 4 + 1 ] = image[ i + 1 ];
imageData[ ( x + width * y ) * 4 + 0 ] = image[ i + 2 ];
}
}
return imageData;
}
function tgaGetImageData32bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) {
let i = 0,
x,
y;
const width = header.width;
for ( y = y_start; y !== y_end; y += y_step ) {
for ( x = x_start; x !== x_end; x += x_step, i += 4 ) {
imageData[ ( x + width * y ) * 4 + 2 ] = image[ i + 0 ];
imageData[ ( x + width * y ) * 4 + 1 ] = image[ i + 1 ];
imageData[ ( x + width * y ) * 4 + 0 ] = image[ i + 2 ];
imageData[ ( x + width * y ) * 4 + 3 ] = image[ i + 3 ];
}
}
return imageData;
}
function tgaGetImageDataGrey8bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) {
let color,
i = 0,
x,
y;
const width = header.width;
for ( y = y_start; y !== y_end; y += y_step ) {
for ( x = x_start; x !== x_end; x += x_step, i ++ ) {
color = image[ i ];
imageData[ ( x + width * y ) * 4 + 0 ] = color;
imageData[ ( x + width * y ) * 4 + 1 ] = color;
imageData[ ( x + width * y ) * 4 + 2 ] = color;
imageData[ ( x + width * y ) * 4 + 3 ] = 255;
}
}
return imageData;
}
function tgaGetImageDataGrey16bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) {
let i = 0,
x,
y;
const width = header.width;
for ( y = y_start; y !== y_end; y += y_step ) {
for ( x = x_start; x !== x_end; x += x_step, i += 2 ) {
imageData[ ( x + width * y ) * 4 + 0 ] = image[ i + 0 ];
imageData[ ( x + width * y ) * 4 + 1 ] = image[ i + 0 ];
imageData[ ( x + width * y ) * 4 + 2 ] = image[ i + 0 ];
imageData[ ( x + width * y ) * 4 + 3 ] = image[ i + 1 ];
}
}
return imageData;
}
function getTgaRGBA( data, width, height, image, palette ) {
let x_start, y_start, x_step, y_step, x_end, y_end;
switch ( ( header.flags & TGA_ORIGIN_MASK ) >> TGA_ORIGIN_SHIFT ) {
default:
case TGA_ORIGIN_UL:
x_start = 0;
x_step = 1;
x_end = width;
y_start = 0;
y_step = 1;
y_end = height;
break;
case TGA_ORIGIN_BL:
x_start = 0;
x_step = 1;
x_end = width;
y_start = height - 1;
y_step = - 1;
y_end = - 1;
break;
case TGA_ORIGIN_UR:
x_start = width - 1;
x_step = - 1;
x_end = - 1;
y_start = 0;
y_step = 1;
y_end = height;
break;
case TGA_ORIGIN_BR:
x_start = width - 1;
x_step = - 1;
x_end = - 1;
y_start = height - 1;
y_step = - 1;
y_end = - 1;
break;
}
if ( use_grey ) {
switch ( header.pixel_size ) {
case 8:
tgaGetImageDataGrey8bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image );
break;
case 16:
tgaGetImageDataGrey16bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image );
break;
default:
console.error( 'THREE.TGALoader: Format not supported.' );
break;
}
} else {
switch ( header.pixel_size ) {
case 8:
tgaGetImageData8bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image, palette );
break;
case 16:
tgaGetImageData16bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image );
break;
case 24:
tgaGetImageData24bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image );
break;
case 32:
tgaGetImageData32bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image );
break;
default:
console.error( 'THREE.TGALoader: Format not supported.' );
break;
}
} // Load image data according to specific method
// let func = 'tgaGetImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
// func(data, y_start, y_step, y_end, x_start, x_step, x_end, width, image, palette );
return data;
} // TGA constants
const TGA_TYPE_NO_DATA = 0,
TGA_TYPE_INDEXED = 1,
TGA_TYPE_RGB = 2,
TGA_TYPE_GREY = 3,
TGA_TYPE_RLE_INDEXED = 9,
TGA_TYPE_RLE_RGB = 10,
TGA_TYPE_RLE_GREY = 11,
TGA_ORIGIN_MASK = 0x30,
TGA_ORIGIN_SHIFT = 0x04,
TGA_ORIGIN_BL = 0x00,
TGA_ORIGIN_BR = 0x01,
TGA_ORIGIN_UL = 0x02,
TGA_ORIGIN_UR = 0x03;
if ( buffer.length < 19 ) console.error( 'THREE.TGALoader: Not enough data to contain header.' );
let offset = 0;
const content = new Uint8Array( buffer ),
header = {
id_length: content[ offset ++ ],
colormap_type: content[ offset ++ ],
image_type: content[ offset ++ ],
colormap_index: content[ offset ++ ] | content[ offset ++ ] << 8,
colormap_length: content[ offset ++ ] | content[ offset ++ ] << 8,
colormap_size: content[ offset ++ ],
origin: [ content[ offset ++ ] | content[ offset ++ ] << 8, content[ offset ++ ] | content[ offset ++ ] << 8 ],
width: content[ offset ++ ] | content[ offset ++ ] << 8,
height: content[ offset ++ ] | content[ offset ++ ] << 8,
pixel_size: content[ offset ++ ],
flags: content[ offset ++ ]
}; // check tga if it is valid format
tgaCheckHeader( header );
if ( header.id_length + offset > buffer.length ) {
console.error( 'THREE.TGALoader: No data.' );
} // skip the needn't data
offset += header.id_length; // get targa information about RLE compression and palette
let use_rle = false,
use_pal = false,
use_grey = false;
switch ( header.image_type ) {
case TGA_TYPE_RLE_INDEXED:
use_rle = true;
use_pal = true;
break;
case TGA_TYPE_INDEXED:
use_pal = true;
break;
case TGA_TYPE_RLE_RGB:
use_rle = true;
break;
case TGA_TYPE_RGB:
break;
case TGA_TYPE_RLE_GREY:
use_rle = true;
use_grey = true;
break;
case TGA_TYPE_GREY:
use_grey = true;
break;
} //
const imageData = new Uint8Array( header.width * header.height * 4 );
const result = tgaParse( use_rle, use_pal, header, offset, content );
getTgaRGBA( imageData, header.width, header.height, result.pixel_data, result.palettes );
return {
data: imageData,
width: header.width,
height: header.height,
flipY: true,
generateMipmaps: true,
minFilter: THREE.LinearMipmapLinearFilter
};
}
}
THREE.TGALoader = TGALoader;
} )();

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -20,8 +20,8 @@
"build_css_prod": "cleancss -o build/o3dv.website.min.css website/css/*", "build_css_prod": "cleancss -o build/o3dv.website.min.css website/css/*",
"build_engine_dev": "npm run update_engine_exports && esbuild source/engine/main.js --bundle --minify --global-name=OV --sourcemap --outfile=build/o3dv.min-dev.js", "build_engine_dev": "npm run update_engine_exports && esbuild source/engine/main.js --bundle --minify --global-name=OV --sourcemap --outfile=build/o3dv.min-dev.js",
"build_engine_prod": "npm run update_engine_exports && esbuild source/engine/main.js --bundle --minify --global-name=OV --outfile=build/o3dv.min.js", "build_engine_prod": "npm run update_engine_exports && esbuild source/engine/main.js --bundle --minify --global-name=OV --outfile=build/o3dv.min.js",
"build_website_dev": "esbuild source/website/index.js --bundle --minify --global-name=OV --sourcemap --outfile=build/o3dv.website.min-dev.js", "build_website_dev": "esbuild source/website/index.js --bundle --minify --global-name=OV --tree-shaking=false --sourcemap --outfile=build/o3dv.website.min-dev.js",
"build_website_prod": "esbuild source/website/index.js --bundle --minify --global-name=OV --outfile=build/o3dv.website.min.js" "build_website_prod": "esbuild source/website/index.js --bundle --minify --global-name=OV --tree-shaking=true --outfile=build/o3dv.website.min.js"
}, },
"devDependencies": { "devDependencies": {
"clean-css-cli": "^5.5.2", "clean-css-cli": "^5.5.2",

View File

@ -7,7 +7,6 @@
<title>Online 3D Viewer</title> <title>Online 3D Viewer</title>
<script type="text/javascript" src="../../libs/three.min.js"></script>
<script type="text/javascript" src="../build/o3dv.min-dev.js"></script> <script type="text/javascript" src="../build/o3dv.min-dev.js"></script>
<script type='text/javascript'> <script type='text/javascript'>

View File

@ -7,7 +7,6 @@
<title>Online 3D Viewer</title> <title>Online 3D Viewer</title>
<script type="text/javascript" src="../../libs/three.min.js"></script>
<script type="text/javascript" src="../build/o3dv.min-dev.js"></script> <script type="text/javascript" src="../build/o3dv.min-dev.js"></script>
<script type='text/javascript'> <script type='text/javascript'>

View File

@ -7,7 +7,6 @@
<title>Online 3D Viewer</title> <title>Online 3D Viewer</title>
<script type="text/javascript" src="../../libs/three.min.js"></script>
<script type="text/javascript" src="../build/o3dv.min-dev.js"></script> <script type="text/javascript" src="../build/o3dv.min-dev.js"></script>
<script type='text/javascript'> <script type='text/javascript'>

View File

@ -7,7 +7,6 @@
<title>Online 3D Viewer</title> <title>Online 3D Viewer</title>
<script type="text/javascript" src="../../libs/three.min.js"></script>
<script type="text/javascript" src="../build/o3dv.min-dev.js"></script> <script type="text/javascript" src="../build/o3dv.min-dev.js"></script>
<style> <style>

View File

@ -7,7 +7,6 @@
<title>Online 3D Viewer</title> <title>Online 3D Viewer</title>
<script type="text/javascript" src="../../libs/three.min.js"></script>
<script type="text/javascript" src="../build/o3dv.min-dev.js"></script> <script type="text/javascript" src="../build/o3dv.min-dev.js"></script>
<style> <style>

View File

@ -7,7 +7,6 @@
<title>Online 3D Viewer</title> <title>Online 3D Viewer</title>
<script type="text/javascript" src="../../libs/three.min.js"></script>
<script type="text/javascript" src="../build/o3dv.min-dev.js"></script> <script type="text/javascript" src="../build/o3dv.min-dev.js"></script>
<style> <style>

View File

@ -7,7 +7,6 @@
<title>Online 3D Viewer</title> <title>Online 3D Viewer</title>
<script type="text/javascript" src="../../libs/three.min.js"></script>
<script type="text/javascript" src="../build/o3dv.min-dev.js"></script> <script type="text/javascript" src="../build/o3dv.min-dev.js"></script>
<script type='text/javascript'> <script type='text/javascript'>

View File

@ -7,7 +7,6 @@
<title>Online 3D Viewer</title> <title>Online 3D Viewer</title>
<script type="text/javascript" src="../../libs/three.min.js"></script>
<script type="text/javascript" src="../build/o3dv.min-dev.js"></script> <script type="text/javascript" src="../build/o3dv.min-dev.js"></script>
<script type='text/javascript'> <script type='text/javascript'>

View File

@ -7,7 +7,6 @@
<title>Online 3D Viewer</title> <title>Online 3D Viewer</title>
<script type="text/javascript" src="../../libs/three.min.js"></script>
<script type="text/javascript" src="../build/o3dv.min-dev.js"></script> <script type="text/javascript" src="../build/o3dv.min-dev.js"></script>
<script type='text/javascript'> <script type='text/javascript'>

View File

@ -7,9 +7,6 @@
<title>Online 3D Viewer</title> <title>Online 3D Viewer</title>
<script type="text/javascript" src="../../libs/three.min.js"></script>
<script type="text/javascript" src="../../libs/three.min.js"></script>
<script type="text/javascript" src="../build/o3dv.min-dev.js"></script> <script type="text/javascript" src="../build/o3dv.min-dev.js"></script>
<style> <style>

View File

@ -7,9 +7,6 @@
<title>Online 3D Viewer</title> <title>Online 3D Viewer</title>
<script type="text/javascript" src="../../libs/three.min.js"></script>
<script type="text/javascript" src="../../libs/three.min.js"></script>
<script type="text/javascript" src="../build/o3dv.min-dev.js"></script> <script type="text/javascript" src="../build/o3dv.min-dev.js"></script>
<script type='text/javascript'> <script type='text/javascript'>

View File

@ -7,9 +7,6 @@
<title>Online 3D Viewer</title> <title>Online 3D Viewer</title>
<script type="text/javascript" src="../../libs/three.min.js"></script>
<script type="text/javascript" src="../../libs/three.min.js"></script>
<script type="text/javascript" src="../build/o3dv.min-dev.js"></script> <script type="text/javascript" src="../build/o3dv.min-dev.js"></script>
<script type='text/javascript'> <script type='text/javascript'>

View File

@ -7,7 +7,6 @@
<title>Online 3D Viewer</title> <title>Online 3D Viewer</title>
<script type="text/javascript" src="../../libs/three.min.js"></script>
<script type="text/javascript" src="../build/o3dv.min-dev.js"></script> <script type="text/javascript" src="../build/o3dv.min-dev.js"></script>
<script type='text/javascript'> <script type='text/javascript'>

View File

@ -7,7 +7,6 @@
<title>Online 3D Viewer</title> <title>Online 3D Viewer</title>
<script type="text/javascript" src="../../libs/three.min.js"></script>
<script type="text/javascript" src="../build/o3dv.min-dev.js"></script> <script type="text/javascript" src="../build/o3dv.min-dev.js"></script>
<script type='text/javascript'> <script type='text/javascript'>

View File

@ -7,7 +7,7 @@
<title>Online 3D Viewer</title> <title>Online 3D Viewer</title>
<script type="text/javascript" src="../../libs/three.min.js"></script> <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/three@0.130.0/build/three.min.js"></script>
<script type='text/javascript'> <script type='text/javascript'>
function HasHighpDriverIssue () function HasHighpDriverIssue ()
{ {

View File

@ -7,7 +7,7 @@
<title>Online 3D Viewer</title> <title>Online 3D Viewer</title>
<script type="text/javascript" src="../../libs/three.min.js"></script> <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/three@0.130.0/build/three.min.js"></script>
<script type='text/javascript'> <script type='text/javascript'>
function Sandbox3D () function Sandbox3D ()
{ {

View File

@ -1,5 +1,4 @@
import { RunTaskAsync } from '../core/taskrunner.js'; import { RunTaskAsync } from '../core/taskrunner.js';
import { LoadExternalLibrary } from '../io/externallibs.js';
import { FileSource, GetFileName } from '../io/fileutils.js'; import { FileSource, GetFileName } from '../io/fileutils.js';
import { Color } from '../model/color.js'; import { Color } from '../model/color.js';
import { File, FileList } from './filelist.js'; import { File, FileList } from './filelist.js';
@ -16,6 +15,8 @@ import { ImporterStl } from './importerstl.js';
import { ImporterBim } from './importerbim.js'; import { ImporterBim } from './importerbim.js';
import { ImporterThree3mf, ImporterThreeDae, ImporterThreeFbx, ImporterThreeWrl } from './importerthree.js'; import { ImporterThree3mf, ImporterThreeDae, ImporterThreeFbx, ImporterThreeWrl } from './importerthree.js';
import * as fflate from 'fflate';
export class ImportSettings export class ImportSettings
{ {
constructor () constructor ()
@ -251,23 +252,19 @@ export class Importer
onReady (); onReady ();
return; return;
} }
LoadExternalLibrary ('loaders/fflate.min.js').then (() => { for (let i = 0; i < archives.length; i++) {
for (let i = 0; i < archives.length; i++) { const archiveFile = archives[i];
const archiveFile = archives[i]; const archiveBuffer = new Uint8Array (archiveFile.content);
const archiveBuffer = new Uint8Array (archiveFile.content); const decompressed = fflate.unzipSync (archiveBuffer);
const decompressed = fflate.unzipSync (archiveBuffer); for (const fileName in decompressed) {
for (const fileName in decompressed) { if (Object.prototype.hasOwnProperty.call (decompressed, fileName)) {
if (Object.prototype.hasOwnProperty.call (decompressed, fileName)) { let file = new File (fileName, FileSource.Decompressed);
let file = new File (fileName, FileSource.Decompressed); file.SetContent (decompressed[fileName].buffer);
file.SetContent (decompressed[fileName].buffer); fileList.AddFile (file);
fileList.AddFile (file);
}
} }
} }
onReady (); }
}).catch (() => { onReady ();
onReady ();
});
} }
GetFileList () GetFileList ()

View File

@ -1,5 +1,6 @@
import { Direction } from '../geometry/geometry.js'; import { Direction } from '../geometry/geometry.js';
import { ImporterThreeBase } from './importerthree.js'; import { ImporterThreeBase } from './importerthree.js';
import { SVGLoader } from 'three/examples/jsm/loaders/SVGLoader.js';
export class ImporterThreeSvg extends ImporterThreeBase export class ImporterThreeSvg extends ImporterThreeBase
{ {
@ -18,16 +19,9 @@ export class ImporterThreeSvg extends ImporterThreeBase
return Direction.Z; return Direction.Z;
} }
GetExternalLibraries ()
{
return [
'three_loaders/SVGLoader.js'
];
}
CreateLoader (manager) CreateLoader (manager)
{ {
return new THREE.SVGLoader (manager); return new SVGLoader (manager);
} }
GetMainObject (loadedObject) GetMainObject (loadedObject)
@ -71,7 +65,7 @@ export class ImporterThreeSvg extends ImporterThreeBase
object.rotation.x = Math.PI; object.rotation.x = Math.PI;
for (let path of loadedObject.paths) { for (let path of loadedObject.paths) {
const shapes = THREE.SVGLoader.createShapes (path); const shapes = SVGLoader.createShapes (path);
if (ShowFill (path)) { if (ShowFill (path)) {
let pathStyle = path.userData.style; let pathStyle = path.userData.style;
let pathMaterial = GetOrCreateMaterial (materials, pathStyle.fill, pathStyle.opacity); let pathMaterial = GetOrCreateMaterial (materials, pathStyle.fill, pathStyle.opacity);

View File

@ -3,13 +3,19 @@ import { Direction } from '../geometry/geometry.js';
import { Matrix } from '../geometry/matrix.js'; import { Matrix } from '../geometry/matrix.js';
import { Transformation } from '../geometry/transformation.js'; import { Transformation } from '../geometry/transformation.js';
import { Base64DataURIToArrayBuffer, CreateObjectUrl, GetFileExtensionFromMimeType } from '../io/bufferutils.js'; import { Base64DataURIToArrayBuffer, CreateObjectUrl, GetFileExtensionFromMimeType } from '../io/bufferutils.js';
import { LoadExternalLibrary } from '../io/externallibs.js';
import { GetFileExtension, GetFileName } from '../io/fileutils.js'; import { GetFileExtension, GetFileName } from '../io/fileutils.js';
import { PhongMaterial, TextureMap } from '../model/material.js'; import { PhongMaterial, TextureMap } from '../model/material.js';
import { Node, NodeType } from '../model/node.js'; import { Node, NodeType } from '../model/node.js';
import { ConvertThreeColorToColor, ConvertThreeGeometryToMesh } from '../threejs/threeutils.js'; import { ConvertThreeColorToColor, ConvertThreeGeometryToMesh } from '../threejs/threeutils.js';
import { ImporterBase } from './importerbase.js'; import { ImporterBase } from './importerbase.js';
import * as THREE from 'three';
import { TGALoader } from 'three/examples/jsm/loaders/TGALoader.js';
import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader.js';
import { ColladaLoader } from 'three/examples/jsm/loaders/ColladaLoader.js';
import { VRMLLoader } from 'three/examples/jsm/loaders/VRMLLoader.js';
import { ThreeMFLoader } from 'three/examples/jsm/loaders/3MFLoader.js';
export class ImporterThreeBase extends ImporterBase export class ImporterThreeBase extends ImporterBase
{ {
constructor () constructor ()
@ -17,11 +23,6 @@ export class ImporterThreeBase extends ImporterBase
super (); super ();
} }
GetExternalLibraries ()
{
return null;
}
CreateLoader (manager) CreateLoader (manager)
{ {
return null; return null;
@ -53,30 +54,7 @@ export class ImporterThreeBase extends ImporterBase
ImportContent (fileContent, onFinish) ImportContent (fileContent, onFinish)
{ {
async function LoadLibraries (libraries, onFinish, onError) this.LoadModel (fileContent, onFinish);
{
try {
for (let i = 0; i < libraries.length; i++) {
await LoadExternalLibrary (libraries[i]);
}
} catch (err) {
onError ();
}
onFinish ();
}
const libraries = this.GetExternalLibraries ();
if (libraries === null) {
onFinish ();
return;
}
LoadLibraries (libraries, () => {
this.LoadModel (fileContent, onFinish);
}, () => {
this.SetError ('Failed to load three.js loader.');
onFinish ();
});
} }
LoadModel (fileContent, onFinish) LoadModel (fileContent, onFinish)
@ -307,19 +285,10 @@ export class ImporterThreeFbx extends ImporterThreeBase
return Direction.Y; return Direction.Y;
} }
GetExternalLibraries ()
{
return [
'loaders/fflate.min.js',
'three_loaders/TGALoader.js',
'three_loaders/FBXLoader.js'
];
}
CreateLoader (manager) CreateLoader (manager)
{ {
manager.addHandler (/\.tga$/i, new THREE.TGALoader (manager)); manager.addHandler (/\.tga$/i, new TGALoader (manager));
return new THREE.FBXLoader (manager); return new FBXLoader (manager);
} }
GetMainObject (loadedObject) GetMainObject (loadedObject)
@ -345,18 +314,10 @@ export class ImporterThreeDae extends ImporterThreeBase
return Direction.Y; return Direction.Y;
} }
GetExternalLibraries ()
{
return [
'three_loaders/TGALoader.js',
'three_loaders/ColladaLoader.js'
];
}
CreateLoader (manager) CreateLoader (manager)
{ {
manager.addHandler (/\.tga$/i, new THREE.TGALoader (manager)); manager.addHandler (/\.tga$/i, new TGALoader (manager));
return new THREE.ColladaLoader (manager); return new ColladaLoader (manager);
} }
GetMainObject (loadedObject) GetMainObject (loadedObject)
@ -382,17 +343,9 @@ export class ImporterThreeWrl extends ImporterThreeBase
return Direction.Y; return Direction.Y;
} }
GetExternalLibraries ()
{
return [
'three_loaders/chevrotain.min.js',
'three_loaders/VRMLLoader.js'
];
}
CreateLoader (manager) CreateLoader (manager)
{ {
return new THREE.VRMLLoader (manager); return new VRMLLoader (manager);
} }
GetMainObject (loadedObject) GetMainObject (loadedObject)
@ -434,17 +387,9 @@ export class ImporterThree3mf extends ImporterThreeBase
return Direction.Z; return Direction.Z;
} }
GetExternalLibraries ()
{
return [
'loaders/fflate.min.js',
'three_loaders/3MFLoader.js'
];
}
CreateLoader (manager) CreateLoader (manager)
{ {
return new THREE.ThreeMFLoader (manager); return new ThreeMFLoader (manager);
} }
GetMainObject (loadedObject) GetMainObject (loadedObject)

View File

@ -6,6 +6,8 @@ import { MeshInstanceId } from '../model/meshinstance.js';
import { GetMeshType, MeshType } from '../model/meshutils.js'; import { GetMeshType, MeshType } from '../model/meshutils.js';
import { ConvertColorToThreeColor, GetShadingType, ShadingType } from './threeutils.js'; import { ConvertColorToThreeColor, GetShadingType, ShadingType } from './threeutils.js';
import * as THREE from 'three';
export class ModelToThreeConversionParams export class ModelToThreeConversionParams
{ {
constructor () constructor ()

View File

@ -4,6 +4,8 @@ import { RevokeObjectUrl } from '../main.js';
import { ConvertModelToThreeObject, ModelToThreeConversionOutput, ModelToThreeConversionParams } from './threeconverter.js'; import { ConvertModelToThreeObject, ModelToThreeConversionOutput, ModelToThreeConversionParams } from './threeconverter.js';
import { ConvertColorToThreeColor, HasHighpDriverIssue } from './threeutils.js'; import { ConvertColorToThreeColor, HasHighpDriverIssue } from './threeutils.js';
import * as THREE from 'three';
export class ThreeModelLoader export class ThreeModelLoader
{ {
constructor () constructor ()

View File

@ -5,6 +5,8 @@ import { MaterialType } from '../model/material.js';
import { Mesh } from '../model/mesh.js'; import { Mesh } from '../model/mesh.js';
import { Triangle } from '../model/triangle.js'; import { Triangle } from '../model/triangle.js';
import * as THREE from 'three';
// Some mobile devices say that they support mediump, but in reality they don't. At the end // Some mobile devices say that they support mediump, but in reality they don't. At the end
// all materials rendered as black. This hack renders a single plane with red material and // all materials rendered as black. This hack renders a single plane with red material and
// it checks if it's really red. If it's not, then probably there is a driver issue. // it checks if it's really red. If it's not, then probably there is a driver issue.

View File

@ -7,6 +7,8 @@ import { GetDomElementInnerDimensions } from './domutils.js';
import { Navigation } from './navigation.js'; import { Navigation } from './navigation.js';
import { ViewerExtraGeometry, ViewerGeometry } from './viewergeometry.js'; import { ViewerExtraGeometry, ViewerGeometry } from './viewergeometry.js';
import * as THREE from 'three';
export function GetDefaultCamera (direction) export function GetDefaultCamera (direction)
{ {
if (direction === Direction.X) { if (direction === Direction.X) {

View File

@ -1,6 +1,8 @@
import { Color } from '../model/color.js'; import { Color } from '../model/color.js';
import { ConvertColorToThreeColor } from '../threejs/threeutils.js'; import { ConvertColorToThreeColor } from '../threejs/threeutils.js';
import * as THREE from 'three';
export function SetThreeMeshPolygonOffset (mesh, offset) export function SetThreeMeshPolygonOffset (mesh, offset)
{ {
function SetMaterialsPolygonOffset (materials, offset) function SetMaterialsPolygonOffset (materials, offset)

View File

@ -2,7 +2,6 @@ import { RunTaskAsync } from '../engine/core/taskrunner.js';
import { Coord3D } from '../engine/geometry/coord3d.js'; import { Coord3D } from '../engine/geometry/coord3d.js';
import { Matrix } from '../engine/geometry/matrix.js'; import { Matrix } from '../engine/geometry/matrix.js';
import { FileFormat } from '../engine/io/fileutils.js'; import { FileFormat } from '../engine/io/fileutils.js';
import { LoadExternalLibrary } from '../engine/io/externallibs.js';
import { Exporter } from '../engine/export/exporter.js'; import { Exporter } from '../engine/export/exporter.js';
import { ExporterModel, ExporterSettings } from '../engine/export/exportermodel.js'; import { ExporterModel, ExporterSettings } from '../engine/export/exportermodel.js';
import { AddDiv, ClearDomElement } from '../engine/viewer/domutils.js'; import { AddDiv, ClearDomElement } from '../engine/viewer/domutils.js';
@ -13,6 +12,8 @@ import { DownloadArrayBufferAsFile } from './utils.js';
import { CookieGetStringVal, CookieSetStringVal } from './cookiehandler.js'; import { CookieGetStringVal, CookieSetStringVal } from './cookiehandler.js';
import { HandleEvent } from './eventhandler.js'; import { HandleEvent } from './eventhandler.js';
import * as fflate from 'fflate';
function AddSelectWithCookieSave (parentElement, cookieKey, options, defaultSelectedIndex, onChange) function AddSelectWithCookieSave (parentElement, cookieKey, options, defaultSelectedIndex, onChange)
{ {
let previousOption = CookieGetStringVal (cookieKey, null); let previousOption = CookieGetStringVal (cookieKey, null);
@ -101,18 +102,14 @@ class ModelExporterUI
let file = files[0]; let file = files[0];
DownloadArrayBufferAsFile (file.GetBufferContent (), file.GetName ()); DownloadArrayBufferAsFile (file.GetBufferContent (), file.GetName ());
} else if (files.length > 1) { } else if (files.length > 1) {
LoadExternalLibrary ('loaders/fflate.min.js').then (() => { let filesInZip = {};
let filesInZip = {}; for (let file of files) {
for (let file of files) { filesInZip[file.name] = new Uint8Array (file.content);
filesInZip[file.name] = new Uint8Array (file.content); }
} let zippedContent = fflate.zipSync (filesInZip);
let zippedContent = fflate.zipSync (filesInZip); let zippedBuffer = zippedContent.buffer;
let zippedBuffer = zippedContent.buffer; progressDialog.Close ();
progressDialog.Close (); DownloadArrayBufferAsFile (zippedBuffer, 'model.zip');
DownloadArrayBufferAsFile (zippedBuffer, 'model.zip');
}).catch (() => {
progressDialog.Close ();
});
} }
} }
}); });

View File

@ -2,6 +2,8 @@ import { BigEps, IsEqualEps, RadDeg } from '../engine/geometry/geometry.js';
import { AddDiv, ClearDomElement } from '../engine/viewer/domutils.js'; import { AddDiv, ClearDomElement } from '../engine/viewer/domutils.js';
import { AddSvgIconElement, IsDarkTextNeededForColor } from './utils.js'; import { AddSvgIconElement, IsDarkTextNeededForColor } from './utils.js';
import * as THREE from 'three';
function GetFaceWorldNormal (intersection) function GetFaceWorldNormal (intersection)
{ {
let normalMatrix = new THREE.Matrix4 (); let normalMatrix = new THREE.Matrix4 ();

View File

@ -23,6 +23,8 @@ import { ShadingType } from '../engine/threejs/threeutils.js';
import { MeasureTool } from './measuretool.js'; import { MeasureTool } from './measuretool.js';
import { CloseAllDialogs } from './dialog.js'; import { CloseAllDialogs } from './dialog.js';
import * as THREE from 'three';
export const WebsiteUIState = export const WebsiteUIState =
{ {
Undefined : 0, Undefined : 0,

View File

@ -1,6 +1,5 @@
import globals from './utils/globals.js'; import globals from './utils/globals.js';
import * as OV from '../source/engine/main.js'; import * as OV from '../source/engine/main.js';
import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import core_test from './tests/core_test.js'; import core_test from './tests/core_test.js';

View File

@ -89,11 +89,6 @@ export default function SetGlobals ()
}; };
element.onload (); element.onload ();
}); });
} else if (element.src.indexOf ('fflate') !== -1) {
import ('fflate').then (mod => {
global.fflate = mod;
element.onload ();
});
} else { } else {
element.onerror (); element.onerror ();
} }

View File

@ -1,10 +1,6 @@
{ {
"website_lib_files" : [ "website_lib_files" : [
"libs/pickr.monolith.min.css", "libs/pickr.monolith.min.css",
"libs/pickr.es5.min.js", "libs/pickr.es5.min.js"
"libs/three.min.js"
],
"embed_lib_files" : [
"libs/three.min.js"
] ]
} }

View File

@ -37,7 +37,6 @@ def CreateDestinationDir (config, rootDir, websiteDir, version, testBuild):
shutil.copytree (os.path.join (rootDir, 'website', 'info'), os.path.join (websiteDir, 'info')) shutil.copytree (os.path.join (rootDir, 'website', 'info'), os.path.join (websiteDir, 'info'))
websiteLibFiles = config['website_lib_files'] websiteLibFiles = config['website_lib_files']
embedLibFiles = config['embed_lib_files']
websiteFiles = [ websiteFiles = [
'o3dv/o3dv.website.min.css', 'o3dv/o3dv.website.min.css',
'o3dv/o3dv.website.min.js' 'o3dv/o3dv.website.min.js'
@ -54,7 +53,6 @@ def CreateDestinationDir (config, rootDir, websiteDir, version, testBuild):
htmlFilePath = os.path.join (websiteDir, htmlFileName) htmlFilePath = os.path.join (websiteDir, htmlFileName)
replacer = Tools.TokenReplacer (htmlFilePath, False) replacer = Tools.TokenReplacer (htmlFilePath, False)
replacer.ReplaceTokenFileLinks ('<!-- website libs start -->', '<!-- website libs end -->', websiteLibFiles, version) replacer.ReplaceTokenFileLinks ('<!-- website libs start -->', '<!-- website libs end -->', websiteLibFiles, version)
replacer.ReplaceTokenFileLinks ('<!-- embed libs start -->', '<!-- embed libs end -->', embedLibFiles, version)
replacer.ReplaceTokenFileLinks ('<!-- website start -->', '<!-- website end -->', websiteFiles, version) replacer.ReplaceTokenFileLinks ('<!-- website start -->', '<!-- website end -->', websiteFiles, version)
initScriptContent = '' initScriptContent = ''
initScriptContent += '<script type="text/javascript">' + replacer.eolChar initScriptContent += '<script type="text/javascript">' + replacer.eolChar
@ -92,10 +90,6 @@ def CreatePackage (rootDir, websiteDir, packageDir, version):
zip = zipfile.ZipFile (zipPath, mode = 'w', compression = zipfile.ZIP_DEFLATED) zip = zipfile.ZipFile (zipPath, mode = 'w', compression = zipfile.ZIP_DEFLATED)
for lib in os.listdir (os.path.join (websiteDir, 'libs', 'loaders')): for lib in os.listdir (os.path.join (websiteDir, 'libs', 'loaders')):
zip.write (os.path.join (websiteDir, 'libs', 'loaders', lib), 'libs/loaders/' + lib) zip.write (os.path.join (websiteDir, 'libs', 'loaders', lib), 'libs/loaders/' + lib)
for lib in os.listdir (os.path.join (websiteDir, 'libs', 'three_loaders')):
zip.write (os.path.join (websiteDir, 'libs', 'three_loaders', lib), 'libs/three_loaders/' + lib)
zip.write (os.path.join (websiteDir, 'libs', 'three.min.js'), 'three.min.js')
zip.write (os.path.join (websiteDir, 'libs', 'three.license.md'), 'three.license.md')
zip.write (os.path.join (rootDir, 'build', 'o3dv.min.js'), 'o3dv.min.js') zip.write (os.path.join (rootDir, 'build', 'o3dv.min.js'), 'o3dv.min.js')
zip.write (os.path.join (rootDir, 'LICENSE.md'), 'o3dv.license.md') zip.write (os.path.join (rootDir, 'LICENSE.md'), 'o3dv.license.md')
zip.close () zip.close ()

View File

@ -8,17 +8,6 @@ pickrFileMap = [
[os.path.join ('@simonwep', 'pickr', 'dist', 'themes', 'monolith.min.css'), os.path.join ('pickr.monolith.min.css')] [os.path.join ('@simonwep', 'pickr', 'dist', 'themes', 'monolith.min.css'), os.path.join ('pickr.monolith.min.css')]
] ]
threeJsFileMap = [
[os.path.join ('three', 'LICENSE'), os.path.join ('three.license.md')],
[os.path.join ('three', 'build', 'three.min.js'), os.path.join ('three.min.js')],
[os.path.join ('three', 'examples', 'js', 'libs', 'chevrotain.min.js'), os.path.join ('three_loaders', 'chevrotain.min.js')],
[os.path.join ('three', 'examples', 'js', 'loaders', '3MFLoader.js'), os.path.join ('three_loaders', '3MFLoader.js')],
[os.path.join ('three', 'examples', 'js', 'loaders', 'ColladaLoader.js'), os.path.join ('three_loaders', 'ColladaLoader.js')],
[os.path.join ('three', 'examples', 'js', 'loaders', 'FBXLoader.js'), os.path.join ('three_loaders', 'FBXLoader.js')],
[os.path.join ('three', 'examples', 'js', 'loaders', 'VRMLLoader.js'), os.path.join ('three_loaders', 'VRMLLoader.js')],
[os.path.join ('three', 'examples', 'js', 'loaders', 'SVGLoader.js'), os.path.join ('three_loaders', 'SVGLoader.js')]
]
dracoFileMap = [ dracoFileMap = [
[os.path.join ('draco3d', 'draco_decoder_nodejs.js'), os.path.join ('loaders', 'draco_decoder.js')], [os.path.join ('draco3d', 'draco_decoder_nodejs.js'), os.path.join ('loaders', 'draco_decoder.js')],
[os.path.join ('draco3d', 'draco_decoder.wasm'), os.path.join ('loaders', 'draco_decoder.wasm')], [os.path.join ('draco3d', 'draco_decoder.wasm'), os.path.join ('loaders', 'draco_decoder.wasm')],
@ -68,7 +57,6 @@ def Main (argv):
libsDir = os.path.join (rootDir, 'libs') libsDir = os.path.join (rootDir, 'libs')
UpdateModule (pickrFileMap, nodeModulesDir, libsDir) UpdateModule (pickrFileMap, nodeModulesDir, libsDir)
UpdateModule (threeJsFileMap, nodeModulesDir, libsDir)
UpdateModule (dracoFileMap, nodeModulesDir, libsDir) UpdateModule (dracoFileMap, nodeModulesDir, libsDir)
UpdateModule (rhino3dmFileMap, nodeModulesDir, libsDir) UpdateModule (rhino3dmFileMap, nodeModulesDir, libsDir)
UpdateModule (fflateFileMap, nodeModulesDir, libsDir) UpdateModule (fflateFileMap, nodeModulesDir, libsDir)

View File

@ -11,10 +11,6 @@
<!-- meta start --> <!-- meta start -->
<!-- meta end --> <!-- meta end -->
<!-- embed libs start -->
<script type="text/javascript" src="../libs/three.min.js"></script>
<!-- embed libs end -->
<!-- website start --> <!-- website start -->
<link rel="stylesheet" type="text/css" href="css/icons.css"> <link rel="stylesheet" type="text/css" href="css/icons.css">
<link rel="stylesheet" type="text/css" href="css/themes.css"> <link rel="stylesheet" type="text/css" href="css/themes.css">

View File

@ -11,7 +11,6 @@
<!-- website libs start --> <!-- website libs start -->
<link rel="stylesheet" type="text/css" href="../libs/pickr.monolith.min.css"> <link rel="stylesheet" type="text/css" href="../libs/pickr.monolith.min.css">
<script type="text/javascript" src="../libs/pickr.es5.min.js"></script> <script type="text/javascript" src="../libs/pickr.es5.min.js"></script>
<script type="text/javascript" src="../libs/three.min.js"></script>
<!-- website libs end --> <!-- website libs end -->
<!-- meta start --> <!-- meta start -->