diff --git a/assetActions.config.js b/assetActions.config.js index 433ce53ab..a0b98c2a9 100644 --- a/assetActions.config.js +++ b/assetActions.config.js @@ -5,7 +5,7 @@ import GeoJsonIo from './src/actions/assets/GeoJsonIo.js'; import Potree from './src/actions/assets/Potree.js'; import Protomaps from './src/actions/assets/Protomaps.js'; import OGC3dTiles from './src/actions/assets/OGC3dTiles.js'; -import Viewer3D from './src/actions/assets/Viewer3D.js'; +import F3D from './src/actions/assets/F3D.js'; export default { //Felt @@ -15,5 +15,5 @@ export default { // Geoparquet, // not ready yet Potree, Protomaps, - Viewer3D, + F3D, }; \ No newline at end of file diff --git a/src/actions/assets/F3D.js b/src/actions/assets/F3D.js new file mode 100644 index 000000000..57e6e12cb --- /dev/null +++ b/src/actions/assets/F3D.js @@ -0,0 +1,47 @@ +import AssetActionPlugin from "../AssetActionPlugin"; +import URI from 'urijs'; +import i18n from "../../i18n"; + +// obj & ply files are usually with mime-type text/plain +const F3D_SUPPORTED_TYPES = [ + 'model/gltf-binary', + 'model/gltf+json', + 'application/fbx', +]; +// below is usually text/plain +const F3D_SUPPORTED_FILEEXTS = ['.obj', '.ply', '.fbx', '.glb', '.gltf']; +export default class F3D extends AssetActionPlugin { + + get show() { + return this.component.isBrowserProtocol && ( + F3D_SUPPORTED_TYPES.includes(this.asset.type) + || F3D_SUPPORTED_FILEEXTS.map( + f => this.asset.href.toLowerCase().includes(f) + ).some(e => e) + ); + } + + get uri() { + // `https://f3d.app/web/#model=${modelUrl}` see PR merged for parsing model url and extension: https://github.com/f3d-app/f3d/pull/1596 + // Could enforce extension to help f3d.app determine the mesh type and loader to use + let uri = new URI("https://f3d.app/web"); + uri.addQuery("model", encodeURI(this.component.href)); + uri = uri.toString().replace('?', '#'); + return uri; + } + + get uri_3dviewer() { + // `https://3dviewer.net/#model=${modelUrl}` misconception, # is not a fragment but a query, can be replaced + // let uri = new URI("https://3dviewer.net/"); + // uri.addQuery("model", this.component.href); + // uri = uri.toString().replace('?', '#'); + const extension = ''; // '.obj'; + let uri = `https://3dviewer.net/#model=${this.component.href.replace('%2F', '/')}#${extension}`; + return uri; + } + + get text() { + return i18n.t('actions.openIn', {service: 'f3d.app'}); + } + +} \ No newline at end of file diff --git a/src/actions/assets/Viewer3D.js b/src/actions/assets/Viewer3D.js deleted file mode 100644 index 594ac027b..000000000 --- a/src/actions/assets/Viewer3D.js +++ /dev/null @@ -1,36 +0,0 @@ -import AssetActionPlugin from "../AssetActionPlugin"; -import URI from 'urijs'; -import i18n from "../../i18n"; - -// obj & ply files are usually with mime-type text/plain -const VIEWER3D_SUPPORTED_TYPES = [ - 'model/gltf-binary', - 'model/gltf+json', - 'application/fbx', -]; -// below is usually text/plain -const VIEWER3D_SUPPORTED_FILEEXTS = ['.obj', '.ply', '.fbx', '.glb', '.gltf']; -export default class Viewer3D extends AssetActionPlugin { - - get show() { - return this.component.isBrowserProtocol && ( - VIEWER3D_SUPPORTED_TYPES.includes(this.asset.type) - || VIEWER3D_SUPPORTED_FILEEXTS.map( - f => this.asset.href.toLowerCase().includes(f) - ).some(e => e) - ); - } - - get uri() { - // `https://3dviewer.net/#model=${modelUrl}` misconception, # is not a fragment but a query, can be replaced - let uri = new URI("https://3dviewer.net/"); - uri.addQuery("model", this.component.href); // returns the URI instance for chaining - uri = uri.toString().replace('?', '#'); - return uri; - } - - get text() { - return i18n.t('actions.openIn', {service: '3dviewer.net'}); - } - -} \ No newline at end of file