|
@@ -73996,7 +73996,8 @@ var AbstractViewer = (function () {
|
|
this.prepareContainerElement();
|
|
this.prepareContainerElement();
|
|
loader_1.default.loadConfiguration(initialConfiguration).then(function (configuration) {
|
|
loader_1.default.loadConfiguration(initialConfiguration).then(function (configuration) {
|
|
_this.configuration = configuration;
|
|
_this.configuration = configuration;
|
|
- _this.templateManager.initTemplate(_this.configuration.template);
|
|
|
|
|
|
+ var templateConfiguration = _this.configuration.template || {};
|
|
|
|
+ _this.templateManager.initTemplate(templateConfiguration);
|
|
_this.templateManager.onAllLoaded.add(function () {
|
|
_this.templateManager.onAllLoaded.add(function () {
|
|
_this.onTemplatesLoaded();
|
|
_this.onTemplatesLoaded();
|
|
});
|
|
});
|
|
@@ -74016,6 +74017,9 @@ var AbstractViewer = (function () {
|
|
AbstractViewer.prototype.initEngine = function () {
|
|
AbstractViewer.prototype.initEngine = function () {
|
|
var _this = this;
|
|
var _this = this;
|
|
var canvasElement = this.templateManager.getCanvas();
|
|
var canvasElement = this.templateManager.getCanvas();
|
|
|
|
+ if (!canvasElement) {
|
|
|
|
+ return Promise.reject('Canvas element not found!');
|
|
|
|
+ }
|
|
var config = this.configuration.engine || {};
|
|
var config = this.configuration.engine || {};
|
|
this.engine = new babylonjs_1.Engine(canvasElement, !!config.antialiasing);
|
|
this.engine = new babylonjs_1.Engine(canvasElement, !!config.antialiasing);
|
|
window.addEventListener('resize', function () {
|
|
window.addEventListener('resize', function () {
|
|
@@ -74280,7 +74284,7 @@ var TemplateManager = (function () {
|
|
this.templates[name] = template;
|
|
this.templates[name] = template;
|
|
var childrenMap = configuration.children || {};
|
|
var childrenMap = configuration.children || {};
|
|
var childrenTemplates = Object.keys(childrenMap).map(function (name) {
|
|
var childrenTemplates = Object.keys(childrenMap).map(function (name) {
|
|
- return _this.initTemplate(configuration.children[name], name, template);
|
|
|
|
|
|
+ return _this.initTemplate(childrenMap[name], name, template);
|
|
});
|
|
});
|
|
template.onLoaded.add(function () {
|
|
template.onLoaded.add(function () {
|
|
var addToParent = function () {
|
|
var addToParent = function () {
|
|
@@ -74391,7 +74395,7 @@ var Template = (function () {
|
|
var _this = this;
|
|
var _this = this;
|
|
if (this.configuration.events) {
|
|
if (this.configuration.events) {
|
|
Object.keys(this.configuration.events).forEach(function (eventName) {
|
|
Object.keys(this.configuration.events).forEach(function (eventName) {
|
|
- if (_this.configuration.events[eventName]) {
|
|
|
|
|
|
+ if (_this.configuration.events && _this.configuration.events[eventName]) {
|
|
var functionToFire_1 = function (selector, event) {
|
|
var functionToFire_1 = function (selector, event) {
|
|
_this.onEventTriggered.notifyObservers({ event: event, template: _this, selector: selector });
|
|
_this.onEventTriggered.notifyObservers({ event: event, template: _this, selector: selector });
|
|
};
|
|
};
|
|
@@ -74414,7 +74418,7 @@ var Template = (function () {
|
|
exports.Template = Template;
|
|
exports.Template = Template;
|
|
function getTemplateAsHtml(templateConfig) {
|
|
function getTemplateAsHtml(templateConfig) {
|
|
if (!templateConfig) {
|
|
if (!templateConfig) {
|
|
- return Promise.resolve(undefined);
|
|
|
|
|
|
+ return Promise.reject('No templateConfig provided');
|
|
}
|
|
}
|
|
else if (templateConfig.html) {
|
|
else if (templateConfig.html) {
|
|
return Promise.resolve(templateConfig.html);
|
|
return Promise.resolve(templateConfig.html);
|
|
@@ -74426,7 +74430,13 @@ function getTemplateAsHtml(templateConfig) {
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
location_1 = location_1.replace('#', '');
|
|
location_1 = location_1.replace('#', '');
|
|
- document.getElementById('#' + location_1);
|
|
|
|
|
|
+ var element = document.getElementById('#' + location_1);
|
|
|
|
+ if (element) {
|
|
|
|
+ return Promise.resolve(element.innerHTML);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ return Promise.reject('Template ID not found');
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -103292,12 +103302,18 @@ var DefaultViewer = (function (_super) {
|
|
DefaultViewer.prototype.setModelMetaData = function () {
|
|
DefaultViewer.prototype.setModelMetaData = function () {
|
|
var navbar = this.templateManager.getTemplate('navBar');
|
|
var navbar = this.templateManager.getTemplate('navBar');
|
|
var metadataContainer = navbar.parent.querySelector('#model-metadata');
|
|
var metadataContainer = navbar.parent.querySelector('#model-metadata');
|
|
- if (typeof this.configuration.model === 'object') {
|
|
|
|
|
|
+ if (metadataContainer && typeof this.configuration.model === 'object') {
|
|
if (this.configuration.model.title) {
|
|
if (this.configuration.model.title) {
|
|
- metadataContainer.querySelector('span.model-title').innerHTML = this.configuration.model.title;
|
|
|
|
|
|
+ var element = metadataContainer.querySelector('span.model-title');
|
|
|
|
+ if (element) {
|
|
|
|
+ element.innerHTML = this.configuration.model.title;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if (this.configuration.model.subtitle) {
|
|
if (this.configuration.model.subtitle) {
|
|
- metadataContainer.querySelector('span.model-subtitle').innerHTML = this.configuration.model.subtitle;
|
|
|
|
|
|
+ var element = metadataContainer.querySelector('span.model-subtitle');
|
|
|
|
+ if (element) {
|
|
|
|
+ element.innerHTML = this.configuration.model.subtitle;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if (this.configuration.model.thumbnail) {
|
|
if (this.configuration.model.thumbnail) {
|
|
metadataContainer.querySelector('.thumbnail').style.backgroundImage = "url('" + this.configuration.model.thumbnail + "')";
|
|
metadataContainer.querySelector('.thumbnail').style.backgroundImage = "url('" + this.configuration.model.thumbnail + "')";
|
|
@@ -103369,7 +103385,8 @@ var DefaultViewer = (function (_super) {
|
|
DefaultViewer.prototype.setupLights = function (focusMeshes) {
|
|
DefaultViewer.prototype.setupLights = function (focusMeshes) {
|
|
var _this = this;
|
|
var _this = this;
|
|
if (focusMeshes === void 0) { focusMeshes = []; }
|
|
if (focusMeshes === void 0) { focusMeshes = []; }
|
|
- if (!this.configuration.scene.defaultLight && (this.configuration.lights && this.configuration.lights.length)) {
|
|
|
|
|
|
+ var sceneConfig = this.configuration.scene || { defaultLight: true };
|
|
|
|
+ if (!sceneConfig.defaultLight && (this.configuration.lights && this.configuration.lights.length)) {
|
|
this.scene.lights.forEach(function (l) {
|
|
this.scene.lights.forEach(function (l) {
|
|
l.dispose();
|
|
l.dispose();
|
|
});
|
|
});
|
|
@@ -103396,7 +103413,8 @@ var DefaultViewer = (function (_super) {
|
|
DefaultViewer.prototype.setupCamera = function (focusMeshes) {
|
|
DefaultViewer.prototype.setupCamera = function (focusMeshes) {
|
|
var _this = this;
|
|
var _this = this;
|
|
if (focusMeshes === void 0) { focusMeshes = []; }
|
|
if (focusMeshes === void 0) { focusMeshes = []; }
|
|
- if (this.configuration.scene.defaultCamera) {
|
|
|
|
|
|
+ var sceneConfig = this.configuration.scene || { autoRotate: false, defaultCamera: true };
|
|
|
|
+ if (sceneConfig.defaultCamera) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
var cameraConfig = this.configuration.camera || {};
|
|
var cameraConfig = this.configuration.camera || {};
|
|
@@ -103414,7 +103432,7 @@ var DefaultViewer = (function (_super) {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
;
|
|
;
|
|
- if (this.configuration.scene.autoRotate) {
|
|
|
|
|
|
+ if (sceneConfig.autoRotate) {
|
|
this.camera.useAutoRotationBehavior = true;
|
|
this.camera.useAutoRotationBehavior = true;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -103432,6 +103450,9 @@ var DefaultViewer = (function (_super) {
|
|
case 2:
|
|
case 2:
|
|
behavior = new babylonjs_1.FramingBehavior();
|
|
behavior = new babylonjs_1.FramingBehavior();
|
|
break;
|
|
break;
|
|
|
|
+ default:
|
|
|
|
+ behavior = null;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
if (behavior) {
|
|
if (behavior) {
|
|
if (typeof behaviorConfig === "object") {
|
|
if (typeof behaviorConfig === "object") {
|