Jelajahi Sumber

Stronger typing

Ben Adams 7 tahun lalu
induk
melakukan
9bf5ef0aa0

+ 3 - 3
inspector/src/helpers/Helpers.ts

@@ -153,17 +153,17 @@ module INSPECTOR {
         public static LoadScript() {
             BABYLON.Tools.LoadFile("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/highlight.min.js", (elem) => {
                 let script = Helpers.CreateElement('script', '', Inspector.DOCUMENT.body);
-                script.textContent = elem;
+                script.textContent = elem as string;
 
                 // Load glsl detection
                 BABYLON.Tools.LoadFile("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/languages/glsl.min.js", (elem) => {
                     let script = Helpers.CreateElement('script', '', Inspector.DOCUMENT.body);
-                    script.textContent = elem;
+                    script.textContent = elem as string;
 
                     // Load css style
                     BABYLON.Tools.LoadFile("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/styles/zenburn.min.css", (elem) => {
                         let style = Helpers.CreateElement('style', '', Inspector.DOCUMENT.body);
-                        style.textContent = elem;
+                        style.textContent = elem as string;
                     });
                 }, undefined, undefined, undefined, () => {
                     console.log("erreur");

+ 2 - 2
loaders/src/glTF/1.0/babylon.glTFLoader.ts

@@ -1282,7 +1282,7 @@ module BABYLON.GLTF1 {
                 setTimeout(() => onSuccess(new Uint8Array(GLTFUtils.DecodeBase64(buffer.uri))));
             }
             else {
-                Tools.LoadFile(gltfRuntime.rootUrl + buffer.uri, data => onSuccess(new Uint8Array(data)), onProgress, undefined, true, request => {
+                Tools.LoadFile(gltfRuntime.rootUrl + buffer.uri, data => onSuccess(new Uint8Array(data as ArrayBuffer)), onProgress, undefined, true, request => {
                     if (request) {
                         onError(request.status + " " + request.statusText);
                     }
@@ -1309,7 +1309,7 @@ module BABYLON.GLTF1 {
                 setTimeout(() => onSuccess(new Uint8Array(GLTFUtils.DecodeBase64(source.uri))));
             }
             else {
-                Tools.LoadFile(gltfRuntime.rootUrl + source.uri, data => onSuccess(new Uint8Array(data)), undefined, undefined, true, request => {
+                Tools.LoadFile(gltfRuntime.rootUrl + source.uri, data => onSuccess(new Uint8Array(data as ArrayBuffer)), undefined, undefined, true, request => {
                     if (request) {
                         onError(request.status + " " + request.statusText);
                     }

+ 1 - 1
loaders/src/glTF/2.0/babylon.glTFLoader.ts

@@ -1558,7 +1558,7 @@ module BABYLON.GLTF2 {
 
             let request = Tools.LoadFile(this._rootUrl + uri, data => {
                 this._tryCatchOnError(() => {
-                    onSuccess(new Uint8Array(data));
+                    onSuccess(new Uint8Array(data as ArrayBuffer));
                 });
             }, event => {
                 this._tryCatchOnError(() => {

+ 1 - 1
src/Audio/babylon.sound.ts

@@ -130,7 +130,7 @@ module BABYLON {
                                 if (codecSupportedFound) {
                                     // Loading sound using XHR2
                                     if (!this._streaming) {
-                                        Tools.LoadFile(url, (data) => { this._soundLoaded(data); }, undefined, this._scene.database, true);
+                                        Tools.LoadFile(url, (data) => { this._soundLoaded(data as ArrayBuffer); }, undefined, this._scene.database, true);
                                     }
                                     // Streaming sound using HTML5 Audio tag
                                     else {

+ 1 - 1
src/Materials/babylon.effect.ts

@@ -494,7 +494,7 @@
                     var includeShaderUrl = Engine.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
 
                     Tools.LoadFile(includeShaderUrl, (fileContent) => {
-                        Effect.IncludesShadersStore[includeFile] = fileContent;
+                        Effect.IncludesShadersStore[includeFile] = fileContent as string;
                         this._processIncludes(<string>returnValue, callback);
                     });
                     return;

+ 1 - 1
src/Mesh/babylon.geometry.ts

@@ -562,7 +562,7 @@
                     return;
                 }
 
-                this._delayLoadingFunction(JSON.parse(data), this);
+                this._delayLoadingFunction(JSON.parse(data as string), this);
 
                 this.delayLoadState = Engine.DELAYLOADSTATE_LOADED;
                 this._delayInfo = [];

+ 2 - 2
src/Tools/babylon.assetsManager.ts

@@ -130,7 +130,7 @@ module BABYLON {
 
         public runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void) {
             Tools.LoadFile(this.url, (data) => {
-                this.text = data;
+                this.text = data as string;
                 onSuccess();
             }, undefined, scene.database, false, (request, exception) => {
                 if (request) {
@@ -150,7 +150,7 @@ module BABYLON {
         public runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void) {
             Tools.LoadFile(this.url, (data) => {
 
-                this.data = data;
+                this.data = data as ArrayBuffer;
                 onSuccess();
             }, undefined, scene.database, true, (request, exception) => {
                 if (request) {