Skip to content

Commit

Permalink
Replace viewer for 3d objects from 3dviewer.net to f3d.app
Browse files Browse the repository at this point in the history
see f3d.app PR merged for parsing model url and extension: f3d-app/f3d#1596
`https://f3d.app/web/#model=${modelUrl}`
  • Loading branch information
jo-chemla committed Sep 4, 2024
1 parent 3320c40 commit f528e59
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 38 deletions.
4 changes: 2 additions & 2 deletions assetActions.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,5 +15,5 @@ export default {
// Geoparquet, // not ready yet
Potree,
Protomaps,
Viewer3D,
F3D,
};
47 changes: 47 additions & 0 deletions src/actions/assets/F3D.js
Original file line number Diff line number Diff line change
@@ -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'});
}

}
36 changes: 0 additions & 36 deletions src/actions/assets/Viewer3D.js

This file was deleted.

0 comments on commit f528e59

Please sign in to comment.