forked from radiantearth/stac-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace viewer for 3d objects from 3dviewer.net to f3d.app
see f3d.app PR merged for parsing model url and extension: f3d-app/f3d#1596 `https://f3d.app/web/#model=${modelUrl}`
- Loading branch information
Showing
3 changed files
with
49 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'}); | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.