Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Pathing #1145

Merged
merged 2 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading