Skip to content

Commit

Permalink
Merge pull request #1145 from ThatOpen/Fix
Browse files Browse the repository at this point in the history
Fix Pathing
  • Loading branch information
beachtom authored Nov 17, 2024
2 parents 72edd32 + aa1346d commit 3a6a7c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/viewer/web-ifc-viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as ts from "typescript";
import { exampleCode } from './example';

let ifcAPI = new IfcAPI();
ifcAPI.SetWasmPath("./",true)
ifcAPI.SetWasmPath("./")
let ifcThree = new IfcThree(ifcAPI);

let timeout = undefined;
Expand Down
10 changes: 7 additions & 3 deletions src/ts/web-ifc-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ declare var __WASM_PATH__:string;

let WebIFCWasm: any;


let currentScriptPath: string;
if (typeof document !== 'undefined') {
const currentScriptData = (document.currentScript as HTMLScriptElement);
currentScriptPath = currentScriptData.src.substring(0, currentScriptData.src.lastIndexOf("/") + 1) ;
}

export * from "./ifc-schema";
import { Properties } from "./helpers/properties";
Expand Down Expand Up @@ -193,10 +197,10 @@ export class IfcAPI {
return this.wasmPath + path;
}

return prefix + this.wasmPath + path;
return (currentScriptPath !== undefined ? currentScriptPath : prefix) + this.wasmPath + path;
}
// otherwise use the default path
return prefix + path;
return (currentScriptPath !== undefined ? currentScriptPath : prefix) + path;
}

//@ts-ignore
Expand Down

0 comments on commit 3a6a7c0

Please sign in to comment.