소스 검색

dist build viewer.js

Raanan Weber 7 년 전
부모
커밋
57f8630804
1개의 변경된 파일37개의 추가작업 그리고 24개의 파일을 삭제
  1. 37 24
      Viewer/dist/viewer.js

+ 37 - 24
Viewer/dist/viewer.js

@@ -74299,7 +74299,7 @@ var TemplateManager = (function () {
             }
             return template;
         };
-        var htmlTree = this.buildHTMLTree(templates).then(function (htmlTree) {
+        this.buildHTMLTree(templates).then(function (htmlTree) {
             internalInit(htmlTree, 'main');
         });
     };
@@ -74308,6 +74308,7 @@ var TemplateManager = (function () {
         var promises = Object.keys(templates).map(function (name) {
             var template = new Template(name, templates[name]);
             _this.templates[name] = template;
+            return template.initPromise;
         });
         return Promise.all(promises).then(function () {
             var templateStructure = {};
@@ -74375,8 +74376,12 @@ var Template = (function () {
     });
     Template.prototype.getChildElements = function () {
         var childrenArray = [];
-        for (var i = 0; i < this.fragment.children.length; ++i) {
-            childrenArray.push(helper_1.kebabToCamel(this.fragment.children.item(i).nodeName.toLowerCase()));
+        var children = this.fragment.children;
+        if (!children) {
+            children = this.fragment.querySelectorAll('*');
+        }
+        for (var i = 0; i < children.length; ++i) {
+            childrenArray.push(helper_1.kebabToCamel(children.item(i).nodeName.toLowerCase()));
         }
         return childrenArray;
     };
@@ -74428,23 +74433,31 @@ var Template = (function () {
     Template.prototype.registerEvents = function () {
         var _this = this;
         if (this._configuration.events) {
-            Object.keys(this._configuration.events).forEach(function (eventName) {
-                if (_this._configuration.events && _this._configuration.events[eventName]) {
+            var _loop_1 = function (eventName) {
+                if (this_1._configuration.events && this_1._configuration.events[eventName]) {
                     var functionToFire_1 = function (selector, event) {
                         _this.onEventTriggered.notifyObservers({ event: event, template: _this, selector: selector });
                     };
-                    if (typeof _this._configuration.events[eventName] === 'boolean') {
-                        _this.parent.addEventListener(eventName, functionToFire_1.bind(_this, '#' + _this.parent.id), false);
+                    if (typeof this_1._configuration.events[eventName] === 'boolean') {
+                        this_1.parent.addEventListener(eventName, functionToFire_1.bind(this_1, '#' + this_1.parent.id), false);
                     }
-                    else {
-                        var selectorsArray = _this._configuration.events[eventName];
-                        selectorsArray.forEach(function (selector) {
+                    else if (typeof this_1._configuration.events[eventName] === 'object') {
+                        var selectorsArray = Object.keys(this_1._configuration.events[eventName] || {});
+                        var event_1 = this_1._configuration.events[eventName] || {};
+                        selectorsArray.filter(function (selector) { return event_1[selector]; }).forEach(function (selector) {
+                            if (selector.indexOf('#') !== 0) {
+                                selector = '#' + selector;
+                            }
                             var htmlElement = _this.parent.querySelector(selector);
                             htmlElement && htmlElement.addEventListener(eventName, functionToFire_1.bind(_this, selector), false);
                         });
                     }
                 }
-            });
+            };
+            var this_1 = this;
+            for (var eventName in this._configuration.events) {
+                _loop_1(eventName);
+            }
         }
     };
     return Template;
@@ -100860,7 +100873,7 @@ exports.defaultConfiguration = {
                 visibilityTimeout: 2000
             },
             events: {
-                pointerdown: ['#fullscreen-button']
+                pointerdown: { 'fullscreen-button': true }
             }
         },
         overlay: {
@@ -100881,14 +100894,14 @@ exports.defaultConfiguration = {
         }
     },
     camera: {
-        behaviors: [
-            0,
-            {
+        behaviors: {
+            autoRotate: 0,
+            framing: {
                 type: 2,
                 zoomOnBoundingInfo: true,
                 zoomStopsAnimation: false
             }
-        ]
+        }
     },
     skybox: {
         cubeTexture: {
@@ -103372,7 +103385,7 @@ var DefaultViewer = (function (_super) {
                         switch (data.selector) {
                             case '#fullscreen-button':
                                 if (!isFullscreen) {
-                                    var requestFullScreen = viewerElement.requestFullscreen || viewerElement.webkitRequestFullscreen;
+                                    var requestFullScreen = viewerElement.requestFullscreen || viewerElement.webkitRequestFullscreen || viewerElement.msRequestFullscreen || viewerElement.mozRequestFullScreen;
                                     requestFullScreen.call(viewerElement);
                                 }
                                 else {
@@ -103536,12 +103549,13 @@ var DefaultViewer = (function (_super) {
         var _this = this;
         if (focusMeshes === void 0) { focusMeshes = []; }
         var sceneConfig = this.configuration.scene || { defaultLight: true };
-        if (!sceneConfig.defaultLight && (this.configuration.lights && this.configuration.lights.length)) {
+        if (!sceneConfig.defaultLight && (this.configuration.lights && Object.keys(this.configuration.lights).length)) {
             this.scene.lights.forEach(function (l) {
                 l.dispose();
             });
-            this.configuration.lights.forEach(function (lightConfig, idx) {
-                lightConfig.name = lightConfig.name || 'light-' + idx;
+            Object.keys(this.configuration.lights).forEach(function (name, idx) {
+                var lightConfig = _this.configuration.lights && _this.configuration.lights[name] || { name: name, type: 0 };
+                lightConfig.name = name;
                 var constructor = babylonjs_1.Light.GetConstructorFromName(lightConfig.type, lightConfig.name, _this.scene);
                 var light = constructor();
                 if (light.isEnabled() !== !lightConfig.disabled) {
@@ -103561,7 +103575,6 @@ var DefaultViewer = (function (_super) {
         }
     };
     DefaultViewer.prototype.setupCamera = function (focusMeshes) {
-        var _this = this;
         if (focusMeshes === void 0) { focusMeshes = []; }
         var sceneConfig = this.configuration.scene || { autoRotate: false, defaultCamera: true };
         if (sceneConfig.defaultCamera) {
@@ -103577,9 +103590,9 @@ var DefaultViewer = (function (_super) {
         this.camera.minZ = cameraConfig.minZ || this.camera.minZ;
         this.camera.maxZ = cameraConfig.maxZ || this.camera.maxZ;
         if (cameraConfig.behaviors) {
-            cameraConfig.behaviors.forEach(function (behaviorConfig) {
-                _this.setCameraBehavior(behaviorConfig, focusMeshes);
-            });
+            for (var name_1 in cameraConfig.behaviors) {
+                this.setCameraBehavior(cameraConfig.behaviors[name_1], focusMeshes);
+            }
         }
         ;
         if (sceneConfig.autoRotate) {