diff --git a/sandbox/embed_selfhost_errors.html b/sandbox/embed_selfhost_errors.html index c561800..dfee977 100644 --- a/sandbox/embed_selfhost_errors.html +++ b/sandbox/embed_selfhost_errors.html @@ -51,6 +51,7 @@ + diff --git a/sandbox/embed_selfhost_externallibs.html b/sandbox/embed_selfhost_externallibs.html index c615b63..3306850 100644 --- a/sandbox/embed_selfhost_externallibs.html +++ b/sandbox/embed_selfhost_externallibs.html @@ -51,6 +51,7 @@ + diff --git a/sandbox/embed_selfhost_fullscreen.html b/sandbox/embed_selfhost_fullscreen.html index f70cce1..c5df813 100644 --- a/sandbox/embed_selfhost_fullscreen.html +++ b/sandbox/embed_selfhost_fullscreen.html @@ -50,6 +50,7 @@ + diff --git a/sandbox/embed_selfhost_manual.html b/sandbox/embed_selfhost_manual.html index 40ac3ad..77260e5 100644 --- a/sandbox/embed_selfhost_manual.html +++ b/sandbox/embed_selfhost_manual.html @@ -51,6 +51,7 @@ + diff --git a/sandbox/embed_selfhost_multiple.html b/sandbox/embed_selfhost_multiple.html index 17533d9..cacbee9 100644 --- a/sandbox/embed_selfhost_multiple.html +++ b/sandbox/embed_selfhost_multiple.html @@ -51,6 +51,7 @@ + diff --git a/sandbox/embed_selfhost_single.html b/sandbox/embed_selfhost_single.html index ae7d0e6..29ff348 100644 --- a/sandbox/embed_selfhost_single.html +++ b/sandbox/embed_selfhost_single.html @@ -50,6 +50,7 @@ + diff --git a/sandbox/embed_selfhost_single_scroll.html b/sandbox/embed_selfhost_single_scroll.html index 4bf3491..ec07c2e 100644 --- a/sandbox/embed_selfhost_single_scroll.html +++ b/sandbox/embed_selfhost_single_scroll.html @@ -50,6 +50,7 @@ + diff --git a/source/import/importersvg.js b/source/import/importersvg.js new file mode 100644 index 0000000..63acbfa --- /dev/null +++ b/source/import/importersvg.js @@ -0,0 +1,85 @@ +OV.ImporterThreeSvg = class extends OV.ImporterThreeBase +{ + constructor () + { + super (); + } + + CanImportExtension (extension) + { + return extension === 'svg'; + } + + GetUpDirection () + { + return OV.Direction.Z; + } + + GetExternalLibraries () + { + return [ + 'three_loaders/SVGLoader.js' + ]; + } + + CreateLoader (manager) + { + return new THREE.SVGLoader (manager); + } + + GetMainObject (loadedObject) + { + function ShowFill (path) + { + const style = path.userData.style; + if (style.fill === undefined || style.fill === 'none') { + return false; + } + return true; + } + + function ShowStroke (path) + { + const style = path.userData.style; + if (style.stroke === undefined || style.stroke === 'none') { + return false; + } + return true; + } + + let object = new THREE.Object3D (); + + let fillsObject = new THREE.Object3D (); + let strokesObject = new THREE.Object3D (); + + fillsObject.name = 'Fills'; + strokesObject.name = 'Strokes'; + + object.add (fillsObject); + object.add (strokesObject); + + const material = new THREE.MeshPhongMaterial ({ + color: 0xcc0000 + }); + for (let path of loadedObject.paths) { + const shapes = THREE.SVGLoader.createShapes (path); + if (ShowFill (path)) { + for (const shape of shapes) { + const geometry = new THREE.ShapeGeometry (shape); + const mesh = new THREE.Mesh (geometry, material); + fillsObject.add (mesh); + } + } + if (ShowStroke (path)) { + for (const subPath of path.subPaths) { + const geometry = THREE.SVGLoader.pointsToStroke (subPath.getPoints (), path.userData.style); + if (geometry) { + const mesh = new THREE.Mesh (geometry, material); + strokesObject.add (mesh); + } + } + } + } + return object; + } +}; diff --git a/source/import/importerthree.js b/source/import/importerthree.js index a9e124f..d86e1de 100644 --- a/source/import/importerthree.js +++ b/source/import/importerthree.js @@ -440,80 +440,3 @@ OV.ImporterThree3mf = class extends OV.ImporterThreeBase return loadedObject; } }; - -OV.ImporterThreeSvg = class extends OV.ImporterThreeBase -{ - constructor () - { - super (); - } - - CanImportExtension (extension) - { - return extension === 'svg'; - } - - GetUpDirection () - { - return OV.Direction.Z; - } - - GetExternalLibraries () - { - return [ - 'three_loaders/SVGLoader.js' - ]; - } - - CreateLoader (manager) - { - return new THREE.SVGLoader (manager); - } - - GetMainObject (loadedObject) - { - function ShowFill (path) - { - const style = path.userData.style; - if (style.fill === undefined || style.fill === 'none') { - return false; - } - return true; - } - - function ShowStroke (path) - { - const style = path.userData.style; - if (style.stroke === undefined || style.stroke === 'none') { - return false; - } - return true; - } - - let object = new THREE.Object3D (); - - const material = new THREE.MeshPhongMaterial ({ - color: 0xcc0000 - }); - for (let path of loadedObject.paths) { - const shapes = THREE.SVGLoader.createShapes (path); - if (ShowFill (path)) { - for (const shape of shapes) { - const geometry = new THREE.ShapeGeometry (shape); - const mesh = new THREE.Mesh (geometry, material); - object.add (mesh); - } - } - if (ShowStroke (path)) { - for (const subPath of path.subPaths) { - const geometry = THREE.SVGLoader.pointsToStroke (subPath.getPoints (), path.userData.style); - if (geometry) { - const mesh = new THREE.Mesh (geometry, material); - object.add (mesh); - } - } - } - } - return object; - } -}; diff --git a/tools/config.json b/tools/config.json index 25e04e5..5a5cf87 100644 --- a/tools/config.json +++ b/tools/config.json @@ -47,6 +47,7 @@ "source/import/importergltf.js", "source/import/importero3dv.js", "source/import/importerthree.js", + "source/import/importersvg.js", "source/import/importer3dm.js", "source/import/importerifc.js", "source/import/filelist.js", diff --git a/website/embed.html b/website/embed.html index c33c16e..60fdaaf 100644 --- a/website/embed.html +++ b/website/embed.html @@ -60,6 +60,7 @@ + diff --git a/website/index.html b/website/index.html index 77c3897..cd2659b 100644 --- a/website/index.html +++ b/website/index.html @@ -60,6 +60,7 @@ +