Pārlūkot izejas kodu

stability changes and bug fixes

Raanan Weber 7 gadi atpakaļ
vecāks
revīzija
d9dcee2c4b

+ 1 - 0
Tools/Gulp/package.json

@@ -10,6 +10,7 @@
     "license": "(Apache-2.0)",
     "devDependencies": {
         "@types/node": "^8.9.4",
+        "base64-font-loader": "0.0.4",
         "base64-image-loader": "^1.2.1",
         "chai": "^4.1.2",
         "color-support": "^1.1.3",

+ 1 - 0
Viewer/package.json

@@ -24,6 +24,7 @@
     "homepage": "https://github.com/BabylonJS/Babylon.js#readme",
     "devDependencies": {
         "@types/node": "^8.9.4",
+        "base64-font-loader": "0.0.4",
         "base64-image-loader": "^1.2.1",
         "html-loader": "^0.5.5",
         "json-loader": "^0.5.7",

+ 1 - 1
Viewer/src/configuration/types/extended.ts

@@ -256,7 +256,7 @@ export let extendedConfiguration: ViewerConfiguration = {
     },
     loaderPlugins: {
         extendedMaterial: true,
-        minecraft: true,
+        applyMaterialConfig: true,
         msftLod: true,
         telemetry: true
     },

+ 19 - 0
Viewer/src/loader/plugins/applyMaterialConfig.ts

@@ -0,0 +1,19 @@
+import { ILoaderPlugin } from "./loaderPlugin";
+import { telemetryManager } from "../../telemetryManager";
+import { ViewerModel } from "../..";
+import { Tools, ISceneLoaderPlugin, ISceneLoaderPluginAsync, Material } from "babylonjs";
+import { IGLTFLoaderData, GLTF2 } from "babylonjs-loaders";
+
+
+export class ApplyMaterialConfigPlugin implements ILoaderPlugin {
+
+    private _model: ViewerModel;
+
+    public onInit(loader: ISceneLoaderPlugin | ISceneLoaderPluginAsync, model: ViewerModel) {
+        this._model = model;
+    }
+
+    public onMaterialLoaded(material: Material) {
+        this._model && this._model._applyModelMaterialConfiguration(material);
+    }
+}

+ 2 - 2
Viewer/src/loader/plugins/index.ts

@@ -1,7 +1,7 @@
 import { TelemetryLoaderPlugin } from "./telemetryLoaderPlugin";
 import { ILoaderPlugin } from "./loaderPlugin";
 import { MSFTLodLoaderPlugin } from './msftLodLoaderPlugin';
-import { MinecraftLoaderPlugin } from './minecraftLoaderPlugin';
+import { ApplyMaterialConfigPlugin } from './applyMaterialConfig';
 import { ExtendedMaterialLoaderPlugin } from './extendedMaterialLoaderPlugin';
 
 const pluginCache: { [key: string]: ILoaderPlugin } = {};
@@ -15,7 +15,7 @@ export function getLoaderPluginByName(name: string) {
             case 'msftLod':
                 pluginCache[name] = new MSFTLodLoaderPlugin();
                 break;
-            case 'minecraft':
+            case 'applyMaterialConfig':
                 pluginCache[name] = new MSFTLodLoaderPlugin();
                 break;
             case 'extendedMaterial':

+ 0 - 39
Viewer/src/loader/plugins/minecraftLoaderPlugin.ts

@@ -1,39 +0,0 @@
-import { ILoaderPlugin } from "./loaderPlugin";
-import { telemetryManager } from "../../telemetryManager";
-import { ViewerModel } from "../..";
-import { Tools, ISceneLoaderPlugin, ISceneLoaderPluginAsync, Material } from "babylonjs";
-import { IGLTFLoaderData, GLTF2 } from "babylonjs-loaders";
-
-
-export class MinecraftLoaderPlugin implements ILoaderPlugin {
-
-    private _model: ViewerModel;
-
-    private _minecraftEnabled: boolean;
-
-    public onInit(loader: ISceneLoaderPlugin | ISceneLoaderPluginAsync, model: ViewerModel) {
-        this._model = model;
-        this._minecraftEnabled = false;
-    }
-
-    public onParsed(data: IGLTFLoaderData) {
-        if (data && data.json && data.json['meshes'] && data.json['meshes'].length) {
-            var meshes = data.json['meshes'] as GLTF2.IMesh[];
-            for (var i = 0; i < meshes.length; i++) {
-                var mesh = meshes[i];
-                if (mesh && mesh.extras && mesh.extras.MSFT_minecraftMesh) {
-                    this._minecraftEnabled = true;
-                    break;
-                }
-            }
-        }
-    }
-
-    public onMaterialLoaded(material: Material) {
-        if (this._minecraftEnabled && material.needAlphaBlending()) {
-            material.forceDepthWrite = true;
-            material.backFaceCulling = true;
-            material.separateCullingPass = true;
-        }
-    }
-}

+ 2 - 4
Viewer/src/model/viewerModel.ts

@@ -509,7 +509,7 @@ export class ViewerModel implements IDisposable {
      * Apply a material configuration to a material
      * @param material Material to apply configuration to
      */
-    private _applyModelMaterialConfiguration(material: Material) {
+    public _applyModelMaterialConfiguration(material: Material) {
         if (!this._modelConfiguration.material) return;
 
         extendClassWithConfig(material, this._modelConfiguration.material);
@@ -734,8 +734,6 @@ export class ViewerModel implements IDisposable {
         this.skeletons.length = 0;
         this._animations.forEach(ag => ag.dispose());
         this._animations.length = 0;
-        this._meshes.forEach(m => m.dispose());
-        this._meshes.length = 0;
-        this.rootMesh.dispose();
+        this.rootMesh.dispose(false, true);
     }
 }

+ 1 - 1
Viewer/src/viewer/defaultViewer.ts

@@ -7,7 +7,7 @@ import { SpotLight, MirrorTexture, Plane, ShadowGenerator, Texture, BackgroundMa
 import { CameraBehavior } from '../interfaces';
 import { ViewerModel } from '../model/viewerModel';
 import { extendClassWithConfig } from '../helper';
-import { IModelAnimation } from 'model/modelAnimation';
+import { IModelAnimation } from '../model/modelAnimation';
 
 /**
  * The Default viewer is the default implementation of the AbstractViewer.

+ 5 - 1
Viewer/webpack.gulp.config.js

@@ -47,8 +47,12 @@ module.exports = {
             }
         },
         {
-            test: /\.(jpe?g|png|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
+            test: /\.(jpe?g|png|ttf|eot|svg?)(\?[a-z0-9=&.]+)?$/,
             use: 'base64-image-loader?limit=1000&name=[name].[ext]'
+        },
+        {
+            test: /\.(woff|ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
+            loader: 'base64-font-loader'
         }]
     }
 }