Skip to content

Commit

Permalink
Use the static member of default CDN URL (#14476)
Browse files Browse the repository at this point in the history
* Fix breaking issue with ScriptBaseUrl

* formatting

* Use the static member

* replace without trailing slash
  • Loading branch information
RaananW committed Oct 30, 2023
1 parent 3d765d2 commit 919db41
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/dev/core/src/Debug/debugLayer.ts
Expand Up @@ -222,7 +222,7 @@ export class DebugLayer {
* By default it uses the babylonjs CDN.
* @ignoreNaming
*/
public static InspectorURL = `https://cdn.babylonjs.com/v${Engine.Version}/inspector/babylon.inspector.bundle.js`;
public static InspectorURL = `${Tools._DefaultCdnUrl}/v${Engine.Version}/inspector/babylon.inspector.bundle.js`;

private _scene: Scene;

Expand Down
4 changes: 2 additions & 2 deletions packages/dev/core/src/Engines/WebGPU/webgpuTintWASM.ts
Expand Up @@ -22,8 +22,8 @@ export interface TwgslOptions {
export class WebGPUTintWASM {
// Default twgsl options.
private static readonly _TWgslDefaultOptions: TwgslOptions = {
jsPath: "https://cdn.babylonjs.com/twgsl/twgsl.js",
wasmPath: "https://cdn.babylonjs.com/twgsl/twgsl.wasm",
jsPath: `${Tools._DefaultCdnUrl}/twgsl/twgsl.js`,
wasmPath: `${Tools._DefaultCdnUrl}/twgsl/twgsl.wasm`,
};

public static ShowWGSLShaderCode = false;
Expand Down
4 changes: 2 additions & 2 deletions packages/dev/core/src/Engines/webgpuEngine.ts
Expand Up @@ -165,8 +165,8 @@ export interface WebGPUEngineOptions extends ThinEngineOptions, GPURequestAdapte
export class WebGPUEngine extends Engine {
// Default glslang options.
private static readonly _GLSLslangDefaultOptions: GlslangOptions = {
jsPath: "https://cdn.babylonjs.com/glslang/glslang.js",
wasmPath: "https://cdn.babylonjs.com/glslang/glslang.wasm",
jsPath: `${Tools._DefaultCdnUrl}/glslang/glslang.js`,
wasmPath: `${Tools._DefaultCdnUrl}/glslang/glslang.wasm`,
};

/** true to enable using TintWASM to convert Spir-V to WGSL */
Expand Down
2 changes: 1 addition & 1 deletion packages/dev/core/src/Materials/Node/nodeMaterial.ts
Expand Up @@ -201,7 +201,7 @@ export class NodeMaterial extends PushMaterial {
private _animationFrame = -1;

/** Define the Url to load node editor script */
public static EditorURL = `https://cdn.babylonjs.com/v${Engine.Version}/nodeEditor/babylon.nodeEditor.js`;
public static EditorURL = `${Tools._DefaultCdnUrl}/v${Engine.Version}/nodeEditor/babylon.nodeEditor.js`;

/** Define the Url to load snippets */
public static SnippetUrl = Constants.SnippetUrl;
Expand Down
6 changes: 3 additions & 3 deletions packages/dev/core/src/Meshes/Compression/dracoCompression.ts
Expand Up @@ -308,9 +308,9 @@ export class DracoCompression implements IDisposable {
*/
public static Configuration: IDracoCompressionConfiguration = {
decoder: {
wasmUrl: "https://cdn.babylonjs.com/draco_wasm_wrapper_gltf.js",
wasmBinaryUrl: "https://cdn.babylonjs.com/draco_decoder_gltf.wasm",
fallbackUrl: "https://cdn.babylonjs.com/draco_decoder_gltf.js",
wasmUrl: `${Tools._DefaultCdnUrl}/draco_wasm_wrapper_gltf.js`,
wasmBinaryUrl: `${Tools._DefaultCdnUrl}/draco_decoder_gltf.wasm`,
fallbackUrl: `${Tools._DefaultCdnUrl}/draco_decoder_gltf.js`,
},
};

Expand Down
Expand Up @@ -55,7 +55,7 @@ export class MeshoptCompression implements IDisposable {
*/
public static Configuration: IMeshoptCompressionConfiguration = {
decoder: {
url: "https://cdn.babylonjs.com/meshopt_decoder.js",
url: `${Tools._DefaultCdnUrl}/meshopt_decoder.js`,
},
};

Expand Down
2 changes: 1 addition & 1 deletion packages/dev/core/src/Meshes/Node/nodeGeometry.ts
Expand Up @@ -49,7 +49,7 @@ export class NodeGeometry {
private _buildExecutionTime: number = 0;

/** Define the Url to load node editor script */
public static EditorURL = `https://cdn.babylonjs.com/v${Engine.Version}/nodeGeometryEditor/babylon.nodeGeometryEditor.js`;
public static EditorURL = `${Tools._DefaultCdnUrl}/v${Engine.Version}/nodeGeometryEditor/babylon.nodeGeometryEditor.js`;

/** Define the Url to load snippets */
public static SnippetUrl = Constants.SnippetUrl;
Expand Down
4 changes: 2 additions & 2 deletions packages/dev/core/src/Misc/basis.ts
Expand Up @@ -114,11 +114,11 @@ export const BasisToolsOptions = {
/**
* URL to use when loading the basis transcoder
*/
JSModuleURL: "https://cdn.babylonjs.com/basisTranscoder/1/basis_transcoder.js",
JSModuleURL: `${Tools._DefaultCdnUrl}/basisTranscoder/1/basis_transcoder.js`,
/**
* URL to use when loading the wasm module for the transcoder
*/
WasmModuleURL: "https://cdn.babylonjs.com/basisTranscoder/1/basis_transcoder.wasm",
WasmModuleURL: `${Tools._DefaultCdnUrl}/basisTranscoder/1/basis_transcoder.wasm`,
};

/**
Expand Down
6 changes: 4 additions & 2 deletions packages/dev/core/src/Misc/tools.ts
Expand Up @@ -488,7 +488,7 @@ export class Tools {
/**
* @internal
*/
public static _DefaultCdnUrl = "https://cdn.babylonjs.com/";
public static _DefaultCdnUrl = "https://cdn.babylonjs.com";

/**
* Get a script URL including preprocessing
Expand All @@ -502,7 +502,9 @@ export class Tools {
// if the base URL was set, and the script Url is an absolute path change the default path
if (Tools.ScriptBaseUrl && scriptUrl.startsWith(Tools._DefaultCdnUrl)) {
// change the default host, which is https://cdn.babylonjs.com with the one defined
const baseUrl = Tools.ScriptBaseUrl[Tools.ScriptBaseUrl.length - 1] === "/" ? Tools.ScriptBaseUrl : Tools.ScriptBaseUrl + "/";
// make sure no trailing slash is present

const baseUrl = Tools.ScriptBaseUrl[Tools.ScriptBaseUrl.length - 1] === "/" ? Tools.ScriptBaseUrl.substring(0, Tools.ScriptBaseUrl.length - 1) : Tools.ScriptBaseUrl;
scriptUrl = scriptUrl.replace(Tools._DefaultCdnUrl, baseUrl);
}

Expand Down
Expand Up @@ -5,7 +5,7 @@ import { GUIEditor } from "gui-editor/guiEditor";

declare let BABYLON: any;

let editorUrl = `https://cdn.babylonjs.com/v${Engine.Version}/guiEditor/babylon.guiEditor.js`;
let editorUrl = `${Tools._DefaultCdnUrl}/v${Engine.Version}/guiEditor/babylon.guiEditor.js`;
// eslint-disable-next-line @typescript-eslint/naming-convention
let guiEditorContainer: { GUIEditor: typeof GUIEditor };
/** Get the inspector from bundle or global */
Expand Down
2 changes: 1 addition & 1 deletion packages/dev/loaders/src/glTF/glTFValidation.ts
Expand Up @@ -89,7 +89,7 @@ export class GLTFValidation {
* The configuration. Defaults to `{ url: "https://cdn.babylonjs.com/gltf_validator.js" }`.
*/
public static Configuration: IGLTFValidationConfiguration = {
url: "https://cdn.babylonjs.com/gltf_validator.js",
url: `${Tools._DefaultCdnUrl}/gltf_validator.js`,
};

private static _LoadScriptPromise: Promise<void>;
Expand Down

0 comments on commit 919db41

Please sign in to comment.