Skip to content

Commit

Permalink
updated to use conversion service versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
techsoftrick committed Aug 29, 2023
1 parent a8ec837 commit 3134470
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 16,157 deletions.
64 changes: 8 additions & 56 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,16 @@
<link rel="stylesheet" href="stylesheets/demos-common.css" />
<link rel="stylesheet" href="stylesheets/drop-down.css" />


<script type="text/javascript" src="javascripts/communicator_scripts/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="javascripts/jquery-ui.min.js"></script>
<script type="text/javascript" src="javascripts/jquery.ui.touch-punch.min.js"></script>
<script type="text/javascript" src="javascripts/communicator_scripts/jquery.minicolors.min.js"></script>
<script type="text/javascript" src="javascripts/communicator_scripts/keymaster.min.js"></script>
<script type="text/javascript" src="javascripts/communicator_scripts/iscroll.min.js"></script>
<script type="text/javascript" src="javascripts/mobile-detect.min.js"></script>

<script type="text/javascript" src="javascripts/conversionService.js"></script>
<script type="text/javascript"
src="https://cdn.jsdelivr.net/gh/techsoft3d/hoops-web-viewer/hoops_web_viewer.js"></script>
<script type="text/javascript" src="javascripts/communicator_scripts/web_viewer_ui.js?v=latest" id="hwvUI"></script>
<script type="text/javascript"
src="javascripts/communicator_scripts/communicator_server_integration.js?v=latest"></script>
<script type="text/javascript" src="javascripts/communicator_scripts/sample.js?v=latest"></script>
<script type="text/javascript" src="javascripts/common/load_scripts.js"></script>


<style>
Expand All @@ -57,56 +52,13 @@
</style>

<script type="module">
var model_name = Sample._getParameterByName("instance");
var model_uid = modelUIDs[model_name]
loadScript()
var viewer = await startViewer(model_name, model_uid)

var ui = null;
var md = new MobileDetect(window.navigator.userAgent);

var date = new Date();
var start = date.getTime();

viewer.setCallbacks({
modelStructureReady: function () {
var date = new Date();
var start = date.getTime();

var end = date.getTime();
console.log("Load time = " + (end - start) / 1000.0 + " seconds.");

$(".dropdown").css("display", "inline-block");
},
});

var screenConfiguration = (md.mobile() !== null) ? Communicator.ScreenConfiguration.Mobile : Sample.screenConfiguration;
const uiConfig = {
containerId: "content",
screenConfiguration: screenConfiguration,
};


ui = new Communicator.Ui.Desktop.DesktopUi(viewer, uiConfig);


// const ui = new Communicator.Ui.Desktop.DesktopUi(viewer, uiConfig);

window.onresize = function () {
viewer.resizeCanvas();
};

if (model_name === "ferrari-engine-v12") {
$("#citation").text("Model courtesy of Darren Simpson");
} else if (model_name === "wren-mw54-turbo-jet") {
$("#citation").text("Model courtesy of Vasileios Thalassinos");
}
var end = date.getTime();

console.log("Load time = " + (end - start) / 1000.0 + " seconds.");

$(".dropdown").css("display", "inline-block");
await loadDynamicScript()
await loadIndividualScript("javascripts/communicator_scripts/web_viewer_ui.js")
await loadIndividualScript("javascripts/communicator_scripts/communicator_server_integration.js?v=latest")
await loadIndividualScript("javascripts/communicator_scripts/sample.js?v=latest")
initializeViewer()
</script>

</head>

<body>
Expand Down
40 changes: 18 additions & 22 deletions javascripts/common/load_scripts.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
const loadScripts = () => {
// Load common scripts and Communicator Scripts.
const HWP_VERSION = "latest";
async function loadDynamicScript() {
var result = await fetchVersionNumber();
var versionNumer = result['hcVersion']
var url = `https://cdn.jsdelivr.net/gh/techsoft3d/hoops-web-viewer@20${versionNumer}/hoops_web_viewer.js`

// URL of files to load.
const files = [
`https://cdn.jsdelivr.net/gh/techsoft3d/hoops-web-viewer@${HWP_VERSION}/hoops_web_viewer.js`,
"/javascripts/communicator_scripts/web_viewer_ui.js?v=latest",
"/javascripts/communicator_scripts/communicator_server_integration.js?v=latest",
"/javascripts/communicator_scripts/sample.js?v=latest",
];
return new Promise((resolve, reject) => {
$.getScript(url, async function () {
console.log('done')
resolve();
});
});
}

files.forEach((url) => {
console.log("loading files.");
jQuery.ajax({
url: url,
dataType: "script",
success: () => {
console.log("loaded!");
},
async: true,
});
async function loadIndividualScript(url) {
return new Promise((resolve, reject) => {
$.getScript(url, async function () {
console.log('done')
resolve();
});
});
};
}

loadScripts();
Loading

0 comments on commit 3134470

Please sign in to comment.