浏览代码

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js into davrous

David Rousset 7 年之前
父节点
当前提交
b83526f439
共有 32 个文件被更改,包括 12028 次插入29702 次删除
  1. 584 582
      Playground/babylon.d.txt
  2. 19 2
      Tools/Gulp/config.json
  3. 8 4
      Tools/Gulp/gulpfile.js
  4. 14 6
      Tools/Gulp/package.json
  5. 97 0
      Viewer/assets/deepmerge.min.js
  6. 1 0
      Viewer/assets/es6-promise.min.js
  7. 29 0
      Viewer/assets/handlebars.min.js
  8. 9 9
      Viewer/package.json
  9. 1 1
      Viewer/src/configuration/loader.ts
  10. 1 2
      Viewer/src/index.ts
  11. 1 1
      Viewer/src/templateManager.ts
  12. 1 1
      Viewer/src/util/promiseObservable.ts
  13. 8 7
      Viewer/src/viewer/defaultViewer.ts
  14. 2 0
      Viewer/src/viewer/viewerManager.ts
  15. 35 0
      Viewer/tsconfig-gulp.json
  16. 51 0
      Viewer/webpack.gulp.config.js
  17. 0 18033
      dist/babylon.module.d.ts
  18. 618 616
      dist/preview release/babylon.d.ts
  19. 5 5
      dist/preview release/babylon.js
  20. 8 4
      dist/preview release/babylon.max.js
  21. 5 5
      dist/preview release/babylon.worker.js
  22. 10393 10391
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts
  23. 5 5
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js
  24. 8 4
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js
  25. 1 1
      dist/preview release/loaders/babylon.objFileLoader.min.js
  26. 1 1
      dist/preview release/loaders/babylonjs.loaders.min.js
  27. 82 0
      dist/preview release/viewer/babylon.viewer.js
  28. 7 3
      inspector/webpack.config.js
  29. 7 4
      src/Cameras/VR/babylon.vrExperienceHelper.ts
  30. 5 0
      src/Cameras/VR/babylon.webVRCamera.ts
  31. 16 14
      src/Gamepad/babylon.gamepadManager.ts
  32. 6 1
      src/babylon.scene.ts

文件差异内容过多而无法显示
+ 584 - 582
Playground/babylon.d.txt


+ 19 - 2
Tools/Gulp/config.json

@@ -1178,7 +1178,8 @@
         "loaders",
         "serializers",
         "inspector",
-        "gui"
+        "gui",
+        "viewer"
     ],
     "materialsLibrary": {
         "libraries": [
@@ -1661,5 +1662,21 @@
             "srcOutputDirectory": "../../inspector/",
             "distOutputDirectory": "/inspector/"
         }
+    },
+    "viewer": {
+        "libraries": [
+            {
+                "files": [],
+                "noBundleInName": true,
+                "output": "babylon.viewer.js",
+                "webpack": "../../Viewer/webpack.gulp.config.js",
+                "bundle": "true",
+                "moduleDeclaration": "BabylonViewer"
+            }
+        ],
+        "build": {
+            "srcOutputDirectory": "../../Viewer/",
+            "distOutputDirectory": "/viewer/"
+        }
     }
-}
+}

+ 8 - 4
Tools/Gulp/gulpfile.js

@@ -49,7 +49,8 @@ var tsConfig = {
     noImplicitThis: true,
     noUnusedLocals: true,
     strictNullChecks: true,
-    strictFunctionTypes: true
+    strictFunctionTypes: true,
+    types: []
 };
 var tsProject = typescript.createProject(tsConfig);
 
@@ -64,7 +65,8 @@ var externalTsConfig = {
     noImplicitReturns: true,
     noImplicitThis: true,
     noUnusedLocals: true,
-    strictNullChecks: true
+    strictNullChecks: true,
+    types: []
 };
 
 var minimist = require("minimist");
@@ -398,9 +400,11 @@ var buildExternalLibrary = function (library, settings, watch) {
 
         if (library.webpack) {
             return waitAll.on("end", function () {
-                webpack(require(library.webpack))
-                    .pipe(rename(library.output.replace(".js", ".bundle.js")))
+                return webpack(require(library.webpack))
+                    .pipe(rename(library.output.replace(".js", library.noBundleInName ? '.js' : ".bundle.js")))
                     .pipe(addModuleExports(library.moduleDeclaration, false, false, true))
+                    .pipe(uglify())
+                    .pipe(optimisejs())
                     .pipe(gulp.dest(outputDirectory))
             });
         }

+ 14 - 6
Tools/Gulp/package.json

@@ -9,9 +9,13 @@
     "readme": "https://github.com/BabylonJS/Babylon.js/edit/master/readme.md",
     "license": "(Apache-2.0)",
     "devDependencies": {
+        "@types/node": "^8.0.53",
+        "base64-image-loader": "^1.2.0",
         "css-loader": "^0.25.0",
+        "deepmerge": "^2.0.1",
         "del": "2.2.2",
-        "exports-loader": "^0.6.3",
+        "es6-promise": "^4.1.1",
+        "exports-loader": "^0.6.4",
         "gulp": "^3.8.11",
         "gulp-changed-in-place": "2.0.3",
         "gulp-clean-ts-extends": "~0.1.1",
@@ -24,20 +28,24 @@
         "gulp-replace": "~0.5.3",
         "gulp-sass": "3.1.0",
         "gulp-sourcemaps": "~1.9.1",
-        "gulp-typescript": "^3.2.2",
+        "gulp-typescript": "^3.2.3",
         "gulp-uglify": "^2.1.2",
         "gulp-util": "~3.0.4",
         "gulp-webserver": "^0.9.1",
-        "imports-loader": "^0.7.0",
+        "handlebars": "^4.0.11",
+        "html-loader": "^0.5.1",
+        "imports-loader": "^0.7.1",
+        "json-loader": "^0.5.7",
         "merge2": "~0.3.5",
         "minimist": "^1.2.0",
         "run-sequence": "~1.1.0",
-        "style-loader": "^0.13.1",
+        "style-loader": "^0.13.2",
         "through2": "~0.6.5",
+        "ts-loader": "^2.3.7",
         "typescript": "~2.6.1",
-        "webpack-stream": "^3.2.0"
+        "webpack-stream": "^4.0.0"
     },
     "scripts": {
         "install": "npm --prefix ../../Playground/ install ../../Playground/ && gulp typescript-compile && gulp typescript-libraries && gulp deployLocalDev"
     }
-}
+}

+ 97 - 0
Viewer/assets/deepmerge.min.js

@@ -0,0 +1,97 @@
+(function (global, factory) {
+	typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
+	typeof define === 'function' && define.amd ? define(factory) :
+	(global.deepmerge = factory());
+}(this, (function () { 'use strict';
+
+var isMergeableObject = function isMergeableObject(value) {
+	return isNonNullObject(value)
+		&& !isSpecial(value)
+};
+
+function isNonNullObject(value) {
+	return !!value && typeof value === 'object'
+}
+
+function isSpecial(value) {
+	var stringValue = Object.prototype.toString.call(value);
+
+	return stringValue === '[object RegExp]'
+		|| stringValue === '[object Date]'
+		|| isReactElement(value)
+}
+
+// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
+var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
+var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
+
+function isReactElement(value) {
+	return value.$$typeof === REACT_ELEMENT_TYPE
+}
+
+function emptyTarget(val) {
+	return Array.isArray(val) ? [] : {}
+}
+
+function cloneUnlessOtherwiseSpecified(value, optionsArgument) {
+	var clone = !optionsArgument || optionsArgument.clone !== false;
+
+	return (clone && isMergeableObject(value))
+		? deepmerge(emptyTarget(value), value, optionsArgument)
+		: value
+}
+
+function defaultArrayMerge(target, source, optionsArgument) {
+	return target.concat(source).map(function(element) {
+		return cloneUnlessOtherwiseSpecified(element, optionsArgument)
+	})
+}
+
+function mergeObject(target, source, optionsArgument) {
+	var destination = {};
+	if (isMergeableObject(target)) {
+		Object.keys(target).forEach(function(key) {
+			destination[key] = cloneUnlessOtherwiseSpecified(target[key], optionsArgument);
+		});
+	}
+	Object.keys(source).forEach(function(key) {
+		if (!isMergeableObject(source[key]) || !target[key]) {
+			destination[key] = cloneUnlessOtherwiseSpecified(source[key], optionsArgument);
+		} else {
+			destination[key] = deepmerge(target[key], source[key], optionsArgument);
+		}
+	});
+	return destination
+}
+
+function deepmerge(target, source, optionsArgument) {
+	var sourceIsArray = Array.isArray(source);
+	var targetIsArray = Array.isArray(target);
+	var options = optionsArgument || { arrayMerge: defaultArrayMerge };
+	var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
+
+	if (!sourceAndTargetTypesMatch) {
+		return cloneUnlessOtherwiseSpecified(source, optionsArgument)
+	} else if (sourceIsArray) {
+		var arrayMerge = options.arrayMerge || defaultArrayMerge;
+		return arrayMerge(target, source, optionsArgument)
+	} else {
+		return mergeObject(target, source, optionsArgument)
+	}
+}
+
+deepmerge.all = function deepmergeAll(array, optionsArgument) {
+	if (!Array.isArray(array)) {
+		throw new Error('first argument should be an array')
+	}
+
+	return array.reduce(function(prev, next) {
+		return deepmerge(prev, next, optionsArgument)
+	}, {})
+};
+
+var deepmerge_1 = deepmerge;
+
+return deepmerge_1;
+
+})));

文件差异内容过多而无法显示
+ 1 - 0
Viewer/assets/es6-promise.min.js


文件差异内容过多而无法显示
+ 29 - 0
Viewer/assets/handlebars.min.js


+ 9 - 9
Viewer/package.json

@@ -23,22 +23,22 @@
     },
     "homepage": "https://github.com/BabylonJS/Babylon.js#readme",
     "devDependencies": {
-        "@types/node": "^8.0.52",
+        "@types/node": "^8.0.53",
         "base64-image-loader": "^1.2.0",
         "html-loader": "^0.5.1",
         "json-loader": "^0.5.7",
         "ts-loader": "^2.3.7",
-        "typescript": "^2.6.1",
-        "uglifyjs-webpack-plugin": "^1.0.1",
+        "typescript": "^2.6.2",
+        "uglifyjs-webpack-plugin": "^1.1.1",
         "webpack": "^3.8.1",
-        "webpack-dev-server": "^2.9.4"
+        "webpack-dev-server": "^2.9.5"
     },
     "dependencies": {
-        "babylonjs": "^3.1.0-beta3",
-        "babylonjs-loaders": "^3.1.0-beta3",
-        "babylonjs-materials": "^3.1.0-beta3",
-        "babylonjs-post-process": "^3.1.0-beta3",
-        "babylonjs-procedural-textures": "^3.1.0-beta3",
+        "babylonjs": "^3.1.0-beta6",
+        "babylonjs-loaders": "^3.1.0-beta6",
+        "babylonjs-materials": "^3.1.0-beta6",
+        "babylonjs-post-process": "^3.1.0-beta6",
+        "babylonjs-procedural-textures": "^3.1.0-beta6",
         "deepmerge": "^2.0.1",
         "es6-promise": "^4.1.1",
         "handlebars": "^4.0.11"

+ 1 - 1
Viewer/src/configuration/loader.ts

@@ -2,7 +2,7 @@ import { mapperManager } from './mappers';
 import { ViewerConfiguration } from './configuration';
 import { getConfigurationType } from './types';
 
-import deepmerge from 'deepmerge';
+import * as deepmerge from '../../assets/deepmerge.min.js';
 
 export class ConfigurationLoader {
 

+ 1 - 2
Viewer/src/index.ts

@@ -22,8 +22,7 @@ import { InitTags } from './initializer';
 global.Promise = Promise || require('es6-promise').Promise;
 
 export let disableInit: boolean = false;
-
-setTimeout(() => {
+document.addEventListener("DOMContentLoaded", function (event) {
     if (disableInit) return;
     InitTags();
 });

+ 1 - 1
Viewer/src/templateManager.ts

@@ -143,7 +143,7 @@ export class TemplateManager {
 }
 
 
-import * as Handlebars from 'handlebars/dist/handlebars.min.js';
+import * as Handlebars from '../assets/handlebars.min.js';
 // register a new helper. modified https://stackoverflow.com/questions/9838925/is-there-any-method-to-iterate-a-map-with-handlebars-js
 Handlebars.registerHelper('eachInMap', function (map, block) {
     var out = '';

+ 1 - 1
Viewer/src/util/promiseObservable.ts

@@ -1,4 +1,4 @@
-import { Observable, Nullable, Observer } from "babylonjs";
+import { Observable } from 'babylonjs';
 
 export class PromiseObservable<T> extends Observable<T> {
 

+ 8 - 7
Viewer/src/viewer/defaultViewer.ts

@@ -1,12 +1,12 @@
+
+
 import { ViewerConfiguration } from './../configuration/configuration';
 import { Template } from './../templateManager';
 import { AbstractViewer } from './viewer';
-import { Observable, ShadowLight, CubeTexture, BouncingBehavior, FramingBehavior, Behavior, Light, Engine, Scene, AutoRotationBehavior, AbstractMesh, Quaternion, StandardMaterial, ShadowOnlyMaterial, ArcRotateCamera, ImageProcessingConfiguration, Color3, Vector3, SceneLoader, Mesh, HemisphericLight } from 'babylonjs';
+import { ShadowGenerator, Observable, ShadowLight, CubeTexture, BouncingBehavior, FramingBehavior, Behavior, Light, Engine, Scene, AutoRotationBehavior, AbstractMesh, Quaternion, StandardMaterial, ArcRotateCamera, ImageProcessingConfiguration, Color3, Vector3, SceneLoader, Mesh, HemisphericLight } from 'babylonjs';
 import { CameraBehavior } from '../interfaces';
 
-// A small hack for the inspector. to be removed!
-import * as BABYLON from 'babylonjs';
-window['BABYLON'] = BABYLON;
+import { ShadowOnlyMaterial } from 'babylonjs-materials';
 
 export class DefaultViewer extends AbstractViewer {
 
@@ -107,7 +107,7 @@ export class DefaultViewer extends AbstractViewer {
                                     let requestFullScreen = viewerElement.requestFullscreen || viewerElement.webkitRequestFullscreen || (<any>viewerElement).msRequestFullscreen || (<any>viewerElement).mozRequestFullScreen;
                                     requestFullScreen.call(viewerElement);
                                 } else {
-                                    let exitFullscreen = document.exitFullscreen || document.webkitExitFullscreen || (<any>document).msExitFullscreen || document.mozCancelFullScreen
+                                    let exitFullscreen = document.exitFullscreen || document.webkitExitFullscreen || (<any>document).msExitFullscreen || (<any>document).mozCancelFullScreen
                                     exitFullscreen.call(document);
                                 }
 
@@ -230,7 +230,8 @@ export class DefaultViewer extends AbstractViewer {
             //default configuration
             if (this.configuration.ground === true) {
                 ground.receiveShadows = true;
-                ground.material.alpha = 0.4;
+                if (ground.material)
+                    ground.material.alpha = 0.4;
             }
 
 
@@ -354,7 +355,7 @@ export class DefaultViewer extends AbstractViewer {
                 //position. Some lights don't support shadows
                 if (light instanceof ShadowLight) {
                     if (lightConfig.shadowEnabled) {
-                        var shadowGenerator = new BABYLON.ShadowGenerator(512, light);
+                        var shadowGenerator = new ShadowGenerator(512, light);
                         this.extendClassWithConfig(shadowGenerator, lightConfig.shadowConfig || {});
                         // add the focues meshes to the shadow list
                         let shadownMap = shadowGenerator.getShadowMap();

+ 2 - 0
Viewer/src/viewer/viewerManager.ts

@@ -1,3 +1,5 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
+
 import { Observable } from 'babylonjs';
 import { AbstractViewer } from './viewer';
 

+ 35 - 0
Viewer/tsconfig-gulp.json

@@ -0,0 +1,35 @@
+{
+    "compilerOptions": {
+        "target": "es5",
+        "module": "commonjs",
+        "noResolve": false,
+        "noImplicitAny": false, //mainly due to usage of external libs without typings.
+        "strictNullChecks": true,
+        "removeComments": true,
+        "preserveConstEnums": true,
+        "sourceMap": false,
+        "experimentalDecorators": true,
+        "isolatedModules": false,
+        "declaration": false,
+        "lib": [
+            "dom",
+            "es2015.promise",
+            "es5"
+        ],
+        "types": [
+            "node"
+        ],
+        "baseUrl": ".",
+        "paths": {
+            "babylonjs": [
+                "../dist/preview release/babylon.max.js"
+            ],
+            "babylonjs-materials": [
+                "../dist/preview release/materialsLibrary/babylonjs.materials.js"
+            ],
+            "babylonjs-loaders": [
+                "../dist/preview release/loaders/babylonjs.loaders.js"
+            ]
+        }
+    }
+}

+ 51 - 0
Viewer/webpack.gulp.config.js

@@ -0,0 +1,51 @@
+module.exports = {
+    //context: __dirname,
+    entry: [
+        __dirname + '/src/index.ts'
+    ]
+    ,
+    output: {
+        libraryTarget: 'var',
+        library: 'BabylonViewer',
+        umdNamedDefine: true
+    },
+    externals: {
+        cannon: true,
+        vertx: true
+    },
+    resolve: {
+        extensions: ['.ts', '.js'],
+        alias: {
+            "babylonjs": __dirname + '/../dist/preview release/babylon.max.js',
+            "babylonjs-materials": __dirname + '/../dist/preview release/materialsLibrary/babylonjs.materials.js',
+            "babylonjs-loaders": __dirname + '/../dist/preview release/loaders/babylonjs.loaders.js',
+            "es6-promise": __dirname + '/assets/es6-promise.min.js',
+            "deepmerge": __dirname + '/assets/deepmerge.min.js',
+        }
+    },
+    module: {
+        loaders: [{
+            test: /\.tsx?$/,
+            use: {
+                loader: 'ts-loader',
+                options: {
+                    configFile: 'tsconfig-gulp.json'
+                }
+            },
+            exclude: /node_modules/
+        },
+        {
+            test: /\.(html)$/,
+            use: {
+                loader: 'html-loader',
+                options: {
+                    minimize: true
+                }
+            }
+        },
+        {
+            test: /\.(jpe?g|png|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
+            use: 'base64-image-loader?limit=1000&name=[name].[ext]'
+        }]
+    }
+}

文件差异内容过多而无法显示
+ 0 - 18033
dist/babylon.module.d.ts


文件差异内容过多而无法显示
+ 618 - 616
dist/preview release/babylon.d.ts


文件差异内容过多而无法显示
+ 5 - 5
dist/preview release/babylon.js


+ 8 - 4
dist/preview release/babylon.max.js

@@ -71370,6 +71370,9 @@ var BABYLON;
             _this.onControllersAttachedObservable = new BABYLON.Observable();
             _this.onControllerMeshLoadedObservable = new BABYLON.Observable();
             _this.rigParenting = true; // should the rig cameras be used as parent instead of this camera.
+            if (webVROptions.defaultHeight) {
+                _this.position.y = webVROptions.defaultHeight;
+            }
             _this.minZ = 0.1;
             //legacy support - the compensation boolean was removed.
             if (arguments.length === 5) {
@@ -71948,13 +71951,14 @@ var BABYLON;
             this._isActionableMesh = false;
             this._workingVector = BABYLON.Vector3.Zero();
             this._scene = scene;
+            this._defaultHeight = webVROptions.defaultHeight || 1.7;
             if (!this._scene.activeCamera || isNaN(this._scene.activeCamera.position.x)) {
-                this._position = new BABYLON.Vector3(0, 2, 0);
-                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", new BABYLON.Vector3(0, 1.7, 0), scene);
+                this._position = new BABYLON.Vector3(0, this._defaultHeight, 0);
+                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._position.clone(), scene);
             }
             else {
                 this._position = this._scene.activeCamera.position.clone();
-                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._position, scene);
+                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._position.clone(), scene);
                 this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
                 this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
                 // Set rotation from previous camera
@@ -72620,7 +72624,7 @@ var BABYLON;
             // offset of the headset from the anchor. Then add the helper's position to account for user's height offset
             this.webVRCamera.leftCamera.globalPosition.subtractToRef(this.webVRCamera.position, this._workingVector);
             this._haloCenter.subtractToRef(this._workingVector, this._workingVector);
-            this._workingVector.addInPlace(this.position);
+            this._workingVector.y += this._defaultHeight;
             // Create animation from the camera's position to the new location
             this.currentVRCamera.animations = [];
             var animationCameraTeleportation = new BABYLON.Animation("animationCameraTeleportation", "position", 90, BABYLON.Animation.ANIMATIONTYPE_VECTOR3, BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT);

文件差异内容过多而无法显示
+ 5 - 5
dist/preview release/babylon.worker.js


文件差异内容过多而无法显示
+ 10393 - 10391
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


文件差异内容过多而无法显示
+ 5 - 5
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 8 - 4
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -71216,6 +71216,9 @@ var BABYLON;
             _this.onControllersAttachedObservable = new BABYLON.Observable();
             _this.onControllerMeshLoadedObservable = new BABYLON.Observable();
             _this.rigParenting = true; // should the rig cameras be used as parent instead of this camera.
+            if (webVROptions.defaultHeight) {
+                _this.position.y = webVROptions.defaultHeight;
+            }
             _this.minZ = 0.1;
             //legacy support - the compensation boolean was removed.
             if (arguments.length === 5) {
@@ -71794,13 +71797,14 @@ var BABYLON;
             this._isActionableMesh = false;
             this._workingVector = BABYLON.Vector3.Zero();
             this._scene = scene;
+            this._defaultHeight = webVROptions.defaultHeight || 1.7;
             if (!this._scene.activeCamera || isNaN(this._scene.activeCamera.position.x)) {
-                this._position = new BABYLON.Vector3(0, 2, 0);
-                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", new BABYLON.Vector3(0, 1.7, 0), scene);
+                this._position = new BABYLON.Vector3(0, this._defaultHeight, 0);
+                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._position.clone(), scene);
             }
             else {
                 this._position = this._scene.activeCamera.position.clone();
-                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._position, scene);
+                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._position.clone(), scene);
                 this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
                 this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
                 // Set rotation from previous camera
@@ -72466,7 +72470,7 @@ var BABYLON;
             // offset of the headset from the anchor. Then add the helper's position to account for user's height offset
             this.webVRCamera.leftCamera.globalPosition.subtractToRef(this.webVRCamera.position, this._workingVector);
             this._haloCenter.subtractToRef(this._workingVector, this._workingVector);
-            this._workingVector.addInPlace(this.position);
+            this._workingVector.y += this._defaultHeight;
             // Create animation from the camera's position to the new location
             this.currentVRCamera.animations = [];
             var animationCameraTeleportation = new BABYLON.Animation("animationCameraTeleportation", "position", 90, BABYLON.Animation.ANIMATIONTYPE_VECTOR3, BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT);

文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/loaders/babylon.objFileLoader.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/loaders/babylonjs.loaders.min.js


文件差异内容过多而无法显示
+ 82 - 0
dist/preview release/viewer/babylon.viewer.js


+ 7 - 3
inspector/webpack.config.js

@@ -1,7 +1,7 @@
 module.exports = {
     entry: [
         "../../dist/preview release/inspector/babylon.inspector.css",
-        "../../dist/preview release/inspector/babylon.inspector.min.js"
+        "../../dist/preview release/inspector/babylon.inspector.js"
     ],
     output: {
         libraryTarget: "var",
@@ -15,8 +15,12 @@ module.exports = {
     },
     module: {
         loaders: [
-            { test: /\.css$/, loader: "style!css" },
-            { test: /babylon.inspector.min.js$/, loader: "imports?Split=split!exports?INSPECTOR" }
+            { test: /\.css$/, use: ['style-loader', 'css-loader'] },
+            {
+                test: /babylon.inspector.js/, use: [
+                    "imports-loader?Split=split", "exports-loader?INSPECTOR"]
+
+            }
         ]
     }
 }

+ 7 - 4
src/Cameras/VR/babylon.vrExperienceHelper.ts

@@ -79,6 +79,7 @@ module BABYLON {
         private _currentHit: Nullable<PickingInfo>;
         private _pointerDownOnMeshAsked = false;
         private _isActionableMesh = false;
+        private _defaultHeight:number;
 
         public get deviceOrientationCamera(): DeviceOrientationCamera {
             return this._deviceOrientationCamera;
@@ -105,13 +106,15 @@ module BABYLON {
         constructor(scene: Scene, public webVROptions: WebVROptions = {}) {
             this._scene = scene;
 
+            this._defaultHeight = webVROptions.defaultHeight || 1.7;
+
             if (!this._scene.activeCamera || isNaN(this._scene.activeCamera.position.x)) {
-                this._position = new BABYLON.Vector3(0, 2, 0);
-                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", new BABYLON.Vector3(0, 1.7, 0), scene);
+                this._position = new BABYLON.Vector3(0, this._defaultHeight, 0);
+                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._position.clone(), scene);
             }
             else {
                 this._position = this._scene.activeCamera.position.clone();
-                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._position, scene);
+                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._position.clone(), scene);
                 this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
                 this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
                 // Set rotation from previous camera
@@ -844,7 +847,7 @@ module BABYLON {
             // offset of the headset from the anchor. Then add the helper's position to account for user's height offset
             this.webVRCamera.leftCamera!.globalPosition.subtractToRef(this.webVRCamera.position, this._workingVector);
             this._haloCenter.subtractToRef(this._workingVector, this._workingVector);
-            this._workingVector.addInPlace(this.position);
+            this._workingVector.y += this._defaultHeight;
             
             // Create animation from the camera's position to the new location
             this.currentVRCamera.animations = [];

+ 5 - 0
src/Cameras/VR/babylon.webVRCamera.ts

@@ -38,6 +38,7 @@ module BABYLON {
         useCustomVRButton?: boolean; // if you don't want to use the default VR button of the helper
         customVRButton?: HTMLButtonElement; //if you'd like to provide your own button to the VRHelper
         rayLength?: number; // to change the length of the ray for gaze/controllers.
+        defaultHeight?: number; // to change the default offset from the ground to account for user's height
     }
 
     export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
@@ -66,6 +67,10 @@ module BABYLON {
         constructor(name: string, position: Vector3, scene: Scene, private webVROptions: WebVROptions = {}) {
             super(name, position, scene);
 
+            if(webVROptions.defaultHeight){
+                this.position.y = webVROptions.defaultHeight;
+            }
+            
             this.minZ = 0.1;
 
             //legacy support - the compensation boolean was removed.

+ 16 - 14
src/Gamepad/babylon.gamepadManager.ts

@@ -3,7 +3,7 @@
         private _babylonGamepads: Array<Gamepad> = [];
         private _oneGamepadConnected: boolean = false;
 
-        private _isMonitoring: boolean = false;
+        public _isMonitoring: boolean = false;
         private _gamepadEventSupported: boolean;
         private _gamepadSupport: () => Array<any>;
 
@@ -13,24 +13,23 @@
         private _onGamepadConnectedEvent: Nullable<(evt: any) => void>;
         private _onGamepadDisconnectedEvent: Nullable<(evt: any) => void>;
 
-        constructor() {
+        constructor(private _scene?: Scene) {
             if (!Tools.IsWindowObjectExist()) {
                 this._gamepadEventSupported = false;
-            } else  {
+            } else {
                 this._gamepadEventSupported = 'GamepadEvent' in window;
                 this._gamepadSupport = (navigator.getGamepads ||
                     navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
             }
 
-
             this.onGamepadConnectedObservable = new Observable<Gamepad>((observer) => {
                 // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
                 for (var i in this._babylonGamepads) {
                     let gamepad = this._babylonGamepads[i];
-                    if (gamepad && gamepad._isConnected) {                      
+                    if (gamepad && gamepad._isConnected) {
                         this.onGamepadConnectedObservable.notifyObserver(observer, gamepad);
                     }
-                }   
+                }
             });
 
             this._onGamepadConnectedEvent = (evt) => {
@@ -52,10 +51,10 @@
                     newGamepad = this._addNewGamepad(gamepad);
                 }
                 this.onGamepadConnectedObservable.notifyObservers(newGamepad);
-                this._startMonitoringGamepads();                
+                this._startMonitoringGamepads();
             };
 
-            this._onGamepadDisconnectedEvent  = (evt) => {
+            this._onGamepadDisconnectedEvent = (evt) => {
                 let gamepad = evt.gamepad;
 
                 // Remove the gamepad from the list of gamepads to monitor.
@@ -63,11 +62,11 @@
                     if (this._babylonGamepads[i].index === gamepad.index) {
                         let disconnectedGamepad = this._babylonGamepads[i];
                         disconnectedGamepad._isConnected = false;
-                        
+
                         this.onGamepadDisconnectedObservable.notifyObservers(disconnectedGamepad);
                         break;
                     }
-                }            
+                }
             };
 
             if (this._gamepadSupport) {
@@ -150,7 +149,10 @@
         private _startMonitoringGamepads() {
             if (!this._isMonitoring) {
                 this._isMonitoring = true;
-                this._checkGamepadsStatus();
+                //back-comp
+                if (!this._scene) {
+                    this._checkGamepadsStatus();
+                }
             }
         }
 
@@ -158,7 +160,7 @@
             this._isMonitoring = false;
         }
 
-        private _checkGamepadsStatus() {
+        public _checkGamepadsStatus() {
             // Hack to be compatible Chrome
             this._updateGamepadObjects();
 
@@ -170,7 +172,7 @@
                 gamepad.update();
             }
 
-            if (this._isMonitoring) {
+            if (this._isMonitoring && !this._scene) {
                 Tools.QueueNewFrame(() => { this._checkGamepadsStatus(); });
             }
         }
@@ -190,7 +192,7 @@
                         this._babylonGamepads[i].browserGamepad = gamepads[i];
 
                         if (!this._babylonGamepads[i].isConnected) {
-                            this._babylonGamepads[i]._isConnected = true;                            
+                            this._babylonGamepads[i]._isConnected = true;
                             this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]);
                         }
                     }

+ 6 - 1
src/babylon.scene.ts

@@ -484,7 +484,7 @@
 
         public get gamepadManager(): GamepadManager {
             if (!this._gamepadManager) {
-                this._gamepadManager = new GamepadManager();
+                this._gamepadManager = new GamepadManager(this);
             }
 
             return this._gamepadManager;
@@ -3430,6 +3430,11 @@
                 }
             }
 
+            // update gamepad manager
+            if (this._gamepadManager && this._gamepadManager._isMonitoring) {
+                this._gamepadManager._checkGamepadsStatus();
+            }
+
             // Before render
             this.onBeforeRenderObservable.notifyObservers(this);