@colijnit/configurator 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/builder.d.ts +10 -0
- package/app/components/answers/answers.component.d.ts +6 -0
- package/app/components/answers/answers.module.d.ts +2 -0
- package/app/components/selections/selections.component.d.ts +16 -0
- package/app/components/selections/selections.module.d.ts +2 -0
- package/bundles/colijnit-configurator.umd.js +224 -55
- package/bundles/colijnit-configurator.umd.js.map +1 -1
- package/bundles/colijnit-configurator.umd.min.js +2 -2
- package/bundles/colijnit-configurator.umd.min.js.map +1 -1
- package/colijnit-configurator.metadata.json +1 -1
- package/esm2015/app/builder.js +62 -38
- package/esm2015/app/components/answers/answers.component.js +29 -0
- package/esm2015/app/components/answers/answers.module.js +21 -0
- package/esm2015/app/components/selections/selections.component.js +83 -0
- package/esm2015/app/components/selections/selections.module.js +21 -0
- package/esm2015/public_api.js +5 -1
- package/esm2015/utils/threed.utils.js +3 -2
- package/esm5/app/builder.js +87 -51
- package/esm5/app/components/answers/answers.component.js +24 -0
- package/esm5/app/components/answers/answers.module.js +24 -0
- package/esm5/app/components/selections/selections.component.js +73 -0
- package/esm5/app/components/selections/selections.module.js +24 -0
- package/esm5/public_api.js +5 -1
- package/esm5/utils/threed.utils.js +3 -2
- package/fesm2015/colijnit-configurator.js +205 -40
- package/fesm2015/colijnit-configurator.js.map +1 -1
- package/fesm5/colijnit-configurator.js +221 -53
- package/fesm5/colijnit-configurator.js.map +1 -1
- package/package.json +2 -2
- package/public_api.d.ts +4 -0
- package/utils/threed.utils.d.ts +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("three"),require("@colijnit/configuratorapi/build/src/configurator"),require("@colijnit/configuratorapi/build/src/model/deco-node"),require("@colijnit/configuratorapi/build/src/service/business-object-factory"),require("@colijnit/configuratorapi/build/src/model/selection"),require("@colijnit/configuratorapi/build/src/enum/deco-node-type.enum"),require("axios"),require("@colijnit/configuratorapi/build/src/enum/deco-node-kind.enum"),require("jszip"),require("@colijnit/configuratorapi/build/src/model/article"),require("rxjs")):"function"==typeof define&&define.amd?define("@colijnit/configurator",["exports","three","@colijnit/configuratorapi/build/src/configurator","@colijnit/configuratorapi/build/src/model/deco-node","@colijnit/configuratorapi/build/src/service/business-object-factory","@colijnit/configuratorapi/build/src/model/selection","@colijnit/configuratorapi/build/src/enum/deco-node-type.enum","axios","@colijnit/configuratorapi/build/src/enum/deco-node-kind.enum","jszip","@colijnit/configuratorapi/build/src/model/article","rxjs"],t):t(((e=e||self).colijnit=e.colijnit||{},e.colijnit.configurator={}),e.three,e.configurator,e.decoNode,e.businessObjectFactory,e.selection,e.decoNodeType_enum,e.axios,e.decoNodeKind_enum,e.JSZip,e.article,e.rxjs)}(this,(function(e,t,n,r,
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("three"),require("@colijnit/configuratorapi/build/src/configurator"),require("@colijnit/configuratorapi/build/src/model/deco-node"),require("@colijnit/configuratorapi/build/src/service/business-object-factory"),require("@colijnit/configuratorapi/build/src/model/selection"),require("@colijnit/configuratorapi/build/src/enum/deco-node-type.enum"),require("axios"),require("@colijnit/configuratorapi/build/src/enum/deco-node-kind.enum"),require("jszip"),require("@colijnit/configuratorapi/build/src/model/article"),require("rxjs"),require("@angular/core"),require("@angular/common"),require("@angular/animations")):"function"==typeof define&&define.amd?define("@colijnit/configurator",["exports","three","@colijnit/configuratorapi/build/src/configurator","@colijnit/configuratorapi/build/src/model/deco-node","@colijnit/configuratorapi/build/src/service/business-object-factory","@colijnit/configuratorapi/build/src/model/selection","@colijnit/configuratorapi/build/src/enum/deco-node-type.enum","axios","@colijnit/configuratorapi/build/src/enum/deco-node-kind.enum","jszip","@colijnit/configuratorapi/build/src/model/article","rxjs","@angular/core","@angular/common","@angular/animations"],t):t(((e=e||self).colijnit=e.colijnit||{},e.colijnit.configurator={}),e.three,e.configurator,e.decoNode,e.businessObjectFactory,e.selection,e.decoNodeType_enum,e.axios,e.decoNodeKind_enum,e.JSZip,e.article,e.rxjs,e.ng.core,e.ng.common,e.ng.animations)}(this,(function(e,t,n,r,i,o,a,s,c,l,u,d,h,p,f){"use strict";s=s&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s;
|
|
2
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
15
|
***************************************************************************** */
|
|
16
|
-
var h=function(e,t){return(h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function p(e,t,n,r){return new(n||(n=Promise))((function(a,i){function o(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((r=r.apply(e,t||[])).next())}))}function f(e,t){var n,r,a,i,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(a=2&i[0]?r.return:i[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,i[1])).done)return a;switch(r=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,r=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!(a=o.trys,(a=a.length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){o.label=i[1];break}if(6===i[0]&&o.label<a[1]){o.label=a[1],a=i;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(i);break}a[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],r=0}finally{n=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}var m=function(){function e(){}return e.DisposeMaterial=function(e){var t=this;e&&(Array.isArray(e)?e.forEach((function(e){t.materialProps.filter((function(t){return e[t]})).forEach((function(t){return e[t].dispose()})),e.dispose()})):(this.materialProps.filter((function(t){return e[t]&&e[t].dispose})).forEach((function(t){return e[t].dispose()})),e.dispose&&e.dispose()))},e.DisposeObject=function(e){var t=this;e&&(e.children.length&&e.children.forEach((function(e){return t.DisposeObject(e)})),this.DisposeNode(e))},e.DisposeNode=function(e){var n=this;e.traverse((function(e){e instanceof t.Mesh&&(e.geometry&&e.geometry.dispose(),n.DisposeMaterial(e.material)),"function"==typeof e.dispose&&e.dispose()}))},e.materialProps=["map","lightMap","bumpMap","normalMap","specularMap","envMap","aoMap","roughnessMap","metalnessMap"],e}(),b=function(){function e(){}return e.StripMimeStringFromDataUri=function(e){if(!e)return"";var t=this.GetMimeStringFromDataUri(e);return e.substr(t.length+1)},e.GetMimeStringFromDataUri=function(e){return e?e.split(",")[0]:""},e.FileExists=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,s({method:"get",url:t+"getFiles.php?assetUrl="+e,responseType:"json"})];case 1:return[2,!!n.sent().data]}}))}))},e.FixUrl=function(t){if(!t)return"";var n=t;return n.endsWith("glb")||n.endsWith("obj")||n.endsWith("glb.gz")||n.endsWith("obj.gz")||(n=e.FixUnityUrl(n)),n=n.replace("/content/","/content43/")},e.FixGlbUrl=function(e){if(!e)return"";var t=e;return-1===e.indexOf("_webplayer")&&(t=e.concat("_webplayer")),(t=t.replace("/content/","/content43/")).endsWith(".glb")||(t=t.concat(".glb")),t},e.MimeTypeFromFilename=function(e){switch(/(?:\.([^.]+))?$/.exec(e)[1]){case"jpg":case"jpeg":return"image/jpeg";case"png":return"image/png";case"bmp":return"image/bmp"}},e.DownloadFile=function(e,t,n){void 0===n&&(n="text/plain");var r=document.createElement("a");r.setAttribute("href","data:"+n+";charset=utf-8,"+encodeURIComponent(t)),r.setAttribute("download",e),r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r)},e.ReadAsText=function(e){return new Promise((function(t){var n=new FileReader;n.readAsText(e),n.onloadend=function(e){2===e.target.readyState&&t(e.target.result)}}))},e.GetExtensionFromDataUri=function(e){return e.replace(/(data:image\/)(.*?)(;base64.*)/gi,"$2")},e.CreateDownloadFileNameFromBase64=function(e){return"preview."+this.GetExtensionFromDataUri(e)},e.DownloadFromDataUri=function(e,t){var n=document.createElement("a");n.download=t,n.href=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)},e.DocumentBodyToDataUri=function(e,t){return e?"data:"+t+";base64,"+e:""},e.FixUnityUrl=function(e){return(e=-1===e.indexOf("_webplayer")?e.concat("_webplayer.ione3d"):e.replace("_webplayer","_webplayer.ione3d")).endsWith(".gz")||(e=e.concat(".gz")),e.replace(".unity3d","")},e._cachedTextureUploads=new Map,e}(),g=function(){function e(){this._objectCache=new Map}return e.prototype.clearCache=function(){Array.from(this._objectCache.values()).forEach((function(e){return m.DisposeObject(e)})),this._objectCache.clear()},e.prototype.download3DSource=function(e){var t=this;return new Promise((function(n,r){return p(t,void 0,void 0,(function(){var t,a=this;return f(this,(function(i){switch(i.label){case 0:return e=e.replace(".unity3d",""),t=e+(e.indexOf(".glb")<0?".glb":""),this._objectCache.has(t)?[2,Promise.resolve(this._objectCache.get(t))]:[4,b.FileExists(t,"https://cdn1.colijn-it.nl/content43/")];case 1:return i.sent()?this.loadGlbSource(t).then((function(e){a._objectCache.set(t,e),n(e)})):r("GLB source not found! ("+t+")"),[2]}}))}))}))},e.prototype.readFileAsText=function(e){var t=new FileReader;return new Promise((function(n,r){t.onload=function(e){return n(e.target.result)},t.onerror=function(e){return r(e)},t.readAsText(e)}))},e.prototype.loadJsonModel=function(e){return p(this,void 0,void 0,(function(){var n,r,a=this;return f(this,(function(i){switch(i.label){case 0:return this._objectCache.has(e)?[2,Promise.resolve(this._objectCache.get(e))]:[4,this._readJsonFile(e)];case 1:return n=i.sent(),(r=new t.ObjectLoader).crossOrigin="Anonymous",[2,new Promise((function(t,i){try{var o=r.parse(n);a._objectCache.set(e,o),t(o)}catch(e){i(null)}}))]}}))}))},e.prototype.loadJsonObjectModel=function(e){return p(this,void 0,void 0,(function(){var n,r=this;return f(this,(function(a){return this._objectCache.has(e)?[2,Promise.resolve(this._objectCache.get(e))]:((n=new t.ObjectLoader).setCrossOrigin("Anonymous"),n.setResourcePath(""),[2,new Promise((function(t,a){n.load(e,(function(n){var a="Scene"===n.type&&"Object3D"===n.children[0].type?n.children[0]:n;r._objectCache.set(e,a),t(a)}),(function(e){return null}),(function(e){return a(e)}))}))])}))}))},e.prototype.loadGlbModel=function(e,t){return void 0===t&&(t=!0),p(this,void 0,void 0,(function(){var n;return f(this,(function(r){switch(r.label){case 0:return this._objectCache.has(e)?[2,Promise.resolve(this._objectCache.get(e))]:window.hasOwnProperty("loadGLTF")?[4,window.loadGLTF(e)]:(console.error("loadGLTF not defined in window global"),[2,null]);case 1:return(n=r.sent())?(this._cleanedUpObjects(n,t),this._objectCache.set(e,n),[2,n]):[2,null]}}))}))},e.prototype.loadGlbSource=function(e){return p(this,void 0,void 0,(function(){var n,r;return f(this,(function(a){switch(a.label){case 0:return[4,this.loadGlbModel(e,!1)];case 1:return(n=a.sent())&&(n.children=n.children.filter((function(e){return!(e instanceof t.Camera)})),n.children.sort((function(e,t){return e.name<t.name?1:-1})),n.children.forEach((function(e){e.traverse((function(e){e.visible=!e.name.toLowerCase().startsWith("c_")})),e.visible=!1})),1===n.children.length&&n.children[0]instanceof t.Group&&(r=n.children[0].children.slice(),n.children.length=0,n.children=r)),[2,n]}}))}))},e.prototype.textureFromUrl=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(n){return[2,new Promise((function(n,r){(new t.TextureLoader).load(e,(function(e){return e.wrapT=t.RepeatWrapping,e.wrapS=t.RepeatWrapping,e.repeat.set(1,1),e.needsUpdate=!0,n(e)}),null,r)}))]}))}))},e.prototype._cleanedUpObjects=function(e,n){var r=this;void 0===n&&(n=!0);var a=new t.Object3D;e.children.forEach((function(e){e instanceof t.Camera||(n&&e instanceof t.Group||1===e.children.length&&e.children[0]instanceof t.Group?r._addGroupChildrenToObject(e,a):n&&!(e instanceof t.Mesh)||!(e instanceof t.Mesh)&&!e.name&&e.children.length>0?(e.children.forEach((function(t){t.translateY(e.position.y)})),e.translateY(-e.position.y),a.children.length>0?a.add(e.clone()):a=e.clone()):a.add(e.clone()))}));var i=(new t.Box3).setFromObject(a),o=new t.Vector3;i.getCenter(o);var s=(new t.Vector3).add(o).negate();return a.children.forEach((function(e){e.position.add(s)})),a},e.prototype._addGroupChildrenToObject=function(e,n,r){var a=this;void 0===r&&(r=!0),e.children.forEach((function(i){r&&i instanceof t.Group?a._addGroupChildrenToObject(i,n):(i.translateY(e.position.y),n.add(i.clone()))}))},e.prototype._iterateChildren=function(e,n){for(var r=0;r<e.length;r++){var a=e[r];a instanceof t.Mesh?n(a):this._iterateChildren(a.children,n)}},e.prototype._readJsonFile=function(e){return p(this,void 0,void 0,(function(){var t,n;return f(this,(function(r){switch(r.label){case 0:return r.trys.push([0,5,,6]),[4,fetch(e)];case 1:return(t=r.sent()).ok?[3,2]:[2,""];case 2:return n=!1,[4,t.clone().text().then((function(e){""===e&&(n=!0)}))];case 3:return r.sent(),[2,n?{}:t.json()];case 4:return[3,6];case 5:return r.sent(),[2,""];case 6:return[2]}}))}))},e}(),v=function(){function e(){}return e.TrySelectorConnection=function(e,t,n,r,a){var i;a&&(r=a(i=r));for(var o=0;o<n.children.length;o++)for(var s=0;s<r.children.length;s++){var c=n.children[o],l=r.children[s];if(!c.connected&&!l.connected&&this.CanSelectorConnect(c,l)){if(!i)return this.SelectorConnect(e,t,c,l);var u=a(i,r,n);this.SelectorConnect(e,t,c,u.children[s])}}return!1},e.Convert3DPointToScreenPoint=function(e,n,r,a){if(!e)return new t.Vector2;var i=e.clone().project(n);return i.x=(i.x+1)/2*r,i.y=-(i.y-1)/2*a,new t.Vector2(i.x,i.y)},e.CanSelectorConnect=function(e,n){var r=e instanceof t.Object3D?e.name:e.connector,a=n instanceof t.Object3D?n.name:n.connector,i=e instanceof t.Object3D&&n instanceof t.Object3D&&e.parent===n.parent,o=r.toUpperCase().split("_"),s=a.toUpperCase().split("_");return o.length>=3&&s.length>=3&&!i&&("C"===o[0]&&"C"===s[0]&&o[1]===s[1]&&o[2]!==s[2])},e.SelectorConnect=function(e,n,r,a){if(!e||!n)return!1;r.connectedTo=a.parent.name,a.connectedTo=r.parent.name;var i=new t.Euler(0,0,0),o=new t.Vector3(0,0,0);e.updateMatrixWorld(!0),i.copy(n.rotation),n.getWorldPosition(o),n.rotation.set(0,0,0),n.position.set(0,0,0);var s=new t.Quaternion;r.getWorldQuaternion(s);var c=new t.Quaternion;a.getWorldQuaternion(c);var l=new t.Quaternion;r.parent.getWorldQuaternion(l);var u=new t.Quaternion;a.parent.getWorldQuaternion(u);var d=(new t.Quaternion).multiplyQuaternions(s.invert(),c).multiply((new t.Quaternion).multiplyQuaternions(l,l));a.parent.quaternion.copy(d),e.updateMatrixWorld(!0);var h=new t.Vector3;r.getWorldPosition(h);var p=new t.Vector3;a.getWorldPosition(p);var f=h.sub(p);return a.parent.position.x+=f.x,a.parent.position.y+=f.y,a.parent.position.z+=f.z,n.rotation.copy(i),n.position.copy(o),e.updateMatrixWorld(!0),r.connected=!0,a.connected=!0,!0},e}(),y=function(){this.specular=new t.Color(.3,.3,.3),this.shininess=0,this.repeatX=4,this.repeatY=4,this.loaded=!1},_=function(){function e(){}return e.CreateTextureFromBase64=function(n,r,a){return new Promise((function(i){e.textures.has(n)?i(e.textures.get(n)):r?(new t.TextureLoader).load(r,(function(r){r.anisotropy=16,r.wrapS=t.RepeatWrapping,r.wrapT=t.RepeatWrapping,r.repeat=new t.Vector2(a?a.repeatX:1,a?a.repeatY:1),r.needsUpdate=!0,e.textures.set(n,r),i(r)})):i(new t.Texture)}))},e.textures=new Map,e}(),w=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}(function(e,t){function n(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)})(t,e)}(y),function(){function e(){}return e.CreateMaterialFromAsset=function(n){return p(this,void 0,void 0,(function(){var r,a,i,o,s,c;return f(this,(function(l){switch(l.label){case 0:return r=new y,n?(n.settings&&e.setSettingsOfMaterial(r,n.settings),n.texture?(a=r,[4,_.CreateTextureFromBase64(n.id+"_texture",n.texture,r)]):[3,2]):[2,r];case 1:a.texture=l.sent(),r.texture.encoding=t.sRGBEncoding,r.textureFilename=n.textureFilename,l.label=2;case 2:return n.normal?(i=r,[4,_.CreateTextureFromBase64(n.id+"_normal",n.normal,r)]):[3,4];case 3:i.normal=l.sent(),r.normalFilename=n.normalFilename,l.label=4;case 4:return n.ao?(o=r,[4,_.CreateTextureFromBase64(n.id+"_ao",n.ao,r)]):[3,6];case 5:o.ao=l.sent(),r.aoFilename=n.aoFilename,l.label=6;case 6:return n.metalness?(s=r,[4,_.CreateTextureFromBase64(n.id+"_metalness",n.metalness,r)]):[3,8];case 7:s.metalness=l.sent(),r.metalnessFilename=n.metalnessFilename,l.label=8;case 8:return n.roughness?(c=r,[4,_.CreateTextureFromBase64(n.id+"_roughness",n.roughness,r)]):[3,10];case 9:c.roughness=l.sent(),r.roughnessFilename=n.roughnessFilename,l.label=10;case 10:return[2,r]}}))}))},e.setSettingsOfMaterial=function(e,n){var r=parseFloat(n.power);isNaN(r)||(e.shininess=r);var a=parseFloat(n.level);isNaN(a)||(e.specular=new t.Color(a,a,a));var i=n.hasOwnProperty("repeat"),o=i?parseFloat(n.repeat.repeatx):parseFloat(n.repeatx);isNaN(o)||(e.repeatX=Math.max(1,o));var s=i?parseFloat(n.repeat.repeaty):parseFloat(n.repeaty);isNaN(s)||(e.repeatY=Math.max(1,s));var c=parseFloat(n.metalness);isNaN(c)||(e.metalnessValue=Math.min(1,c));var l=parseFloat(n.roughness);isNaN(l)||(e.roughnessValue=Math.min(1,l))},e}()),j=function(){},F=function(){this.settings={}},x=function(){function e(){}return e.LoadVariation=function(t,n){return p(this,void 0,void 0,(function(){var r,a,i;return f(this,(function(o){switch(o.label){case 0:if(!n)return[2,null];n.indexOf("ione3d")<0&&(n=n.concat(".ione3d")),r=n.substr(0,n.lastIndexOf(".ione3d")),o.label=1;case 1:return o.trys.push([1,4,,5]),t.endsWith("/")||(t+="/"),window.hasOwnProperty("downloadVariation")?[4,window.downloadVariation(t.replace("https://cdn1.colijn-it.nl/","")+"variation/"+n)]:(console.error("downloadVariation not defined in window global"),[2,null]);case 2:return a=o.sent(),[4,e.GetVariationSettingsFromFile(r,a)];case 3:return[2,o.sent()];case 4:return i=o.sent(),i,[2,null];case 5:return[2]}}))}))},e.GetVariationSettingsFromFile=function(t,n){return p(this,void 0,void 0,(function(){var r,a,i,o;return f(this,(function(s){switch(s.label){case 0:return n?[4,e.GetZipContent(n)]:[2,null];case 1:return r=s.sent(),(a=new F).id=t,r.files["index.json"]?[4,r.files["index.json"].async("string")]:[3,3];case 2:o=s.sent(),i=JSON.parse(o),s.label=3;case 3:return i?[4,e.CreateSettingsBasedOnIndex(i,a,r)]:[3,5];case 4:return s.sent(),[3,7];case 5:return[4,e.CreateSettingsBasedOnFileName(a,r)];case 6:s.sent(),s.label=7;case 7:return[2,a]}}))}))},e.CreateSettingsBasedOnIndex=function(t,n,r){return p(this,void 0,void 0,(function(){var a,i,o,s,c,l;return f(this,(function(u){switch(u.label){case 0:return t.normalFile?(a=n,[4,e.LoadFileContentFromZip(r.files[t.normalFile],t.normalFile)]):[3,2];case 1:a.normal=u.sent(),n.normalFilename=t.normalFile,u.label=2;case 2:return t.aoFile?(i=n,[4,e.LoadFileContentFromZip(r.files[t.aoFile],t.aoFile)]):[3,4];case 3:i.ao=u.sent(),n.aoFilename=t.aoFile,u.label=4;case 4:return t.metalnessFile?(o=n,[4,e.LoadFileContentFromZip(r.files[t.metalnessFile],t.metalnessFile)]):[3,6];case 5:o.metalness=u.sent(),n.metalnessFilename=t.metalnessFile,u.label=6;case 6:return t.roughnessFile?(s=n,[4,e.LoadFileContentFromZip(r.files[t.roughnessFile],t.roughnessFile)]):[3,8];case 7:s.roughness=u.sent(),n.roughnessFilename=t.roughnessFile,u.label=8;case 8:return t.diffuseFile?(c=n,[4,e.LoadFileContentFromZip(r.files[t.diffuseFile],t.diffuseFile)]):[3,10];case 9:c.texture=u.sent(),n.textureFilename=t.diffuseFile,u.label=10;case 10:return l=n,[4,e.LoadFileContentFromZip(r.files["repeat.json"],"repeat.json",!1)];case 11:return l.settings=u.sent()||{},Object.assign(n.settings,t.repeat),n.settings.metalness=t.metalness,n.settings.roughness=t.roughness,[2]}}))}))},e.CreateSettingsBasedOnFileName=function(e,t){return p(this,void 0,void 0,(function(){var n,r,a,i,o,s,c,l=this;return f(this,(function(u){switch(u.label){case 0:for(o in n=[],r=function(r){var i;return f(this,(function(o){switch(o.label){case 0:return t.files[r]?[4,t.files[r]]:[3,2];case 1:(i=o.sent()).name.toLowerCase().indexOf("normal")>-1&&a.FileIsImage(i.name)?n.push(t.files[r].async("base64").then((function(t){e.normal="data:image/"+l.GetBase64FileType(i.name)+";base64,"+t,e.normalFilename=r}))):i.name.toLowerCase().indexOf("ao")>-1&&a.FileIsImage(i.name)?n.push(t.files[r].async("base64").then((function(t){e.ao="data:image/"+l.GetBase64FileType(i.name)+";base64,"+t,e.aoFilename=r}))):i.name.toLowerCase().indexOf("metalness")>-1&&a.FileIsImage(i.name)?n.push(t.files[r].async("base64").then((function(t){e.metalness="data:image/"+l.GetBase64FileType(i.name)+";base64,"+t,e.metalnessFilename=r}))):i.name.toLowerCase().indexOf("roughness")>-1&&a.FileIsImage(i.name)?n.push(t.files[r].async("base64").then((function(t){e.roughness="data:image/"+l.GetBase64FileType(i.name)+";base64,"+t,e.roughnessFilename=r}))):i.name.toLowerCase().indexOf("diffuse")>-1&&a.FileIsImage(i.name)?n.push(t.files[r].async("base64").then((function(t){e.texture="data:image/"+l.GetBase64FileType(i.name)+";base64,"+t,e.textureFilename=r}))):i.name.indexOf(".jp")>-1?n.push(t.files[r].async("base64").then((function(t){e.texture="data:image/jpeg;base64,"+t,e.textureFilename=r}))):i.name.indexOf(".json")>-1&&n.push(t.files[r].async("string").then((function(t){var n=JSON.parse(t);for(var r in n)n[r]&&(e.settings[r]=n[r])}))),o.label=2;case 2:return[2]}}))},a=this,i=[],t.files)i.push(o);s=0,u.label=1;case 1:return s<i.length?(c=i[s],[5,r(c)]):[3,4];case 2:u.sent(),u.label=3;case 3:return s++,[3,1];case 4:return[4,Promise.all(n)];case 5:return u.sent(),[2]}}))}))},e.LoadFileContentFromZip=function(e,t,n){var r=this;return void 0===n&&(n=!0),new Promise((function(a){e&&t?e.async(n?"base64":"string").then((function(e){a(n?"data:image/"+r.GetBase64FileType(t)+";base64,"+e:e)})):a(void 0)}))},e.FileIsImage=function(e){switch(e.substring(e.lastIndexOf(".")+1,e.length).toLowerCase()){case"jpg":case"jpeg":case"png":case"bmp":return!0;default:return!1}},e.GetBase64FileType=function(e){switch(e.substring(e.lastIndexOf(".")+1,e.length).toLowerCase()){case"jpg":case"jpeg":return"jpeg";case"png":return"png";case"bmp":return"bmp";default:return"jpeg"}},e.GetZipContent=function(e){return p(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,(new l).loadAsync(e)];case 1:return[2,t.sent()]}}))}))},e.MaterialCache=new Map,e}(),O=function(){function e(){this._lastKnownVariations=new Map}return e.prototype.clearCache=function(){for(var e=Array.from(this._lastKnownVariations.values()),t=0;t<e.length;t++){Array.from(e[t].values()).forEach((function(e){e.forEach((function(e){e.material.texture.dispose(),e.material.normal.dispose(),e.material.metalness.dispose(),e.material.roughness.dispose(),e.material.ao.dispose()}))}))}},e.prototype.loadPart=function(e,t,n){return void 0===n&&(n=!1),p(this,void 0,void 0,(function(){var r,a,i,s,c,l;return f(this,(function(u){switch(u.label){case 0:u.trys.push([0,6,,7]),r=t.length,a=0,u.label=1;case 1:return a<r?t[a].decoNode&&t[a].decoNode.gameObjectName&&t[a].decoNode.type===o.DecoNodeType.Part?[4,x.LoadVariation(this.assetPath,t[a].decoNode.gameObjectName||t[a].decoId)]:[3,4]:[3,5];case 2:return(i=u.sent())?((s=new j).decoId=parseFloat(t[a].decoNode.id),s.brandId=t[a].decoNode.brandId,s.gameObjectName=t[a].decoNode.gameObjectName,c=s,[4,w.CreateMaterialFromAsset(i)]):[3,4];case 3:c.material=u.sent(),this._applyMaterialPart(e,s,t[a].node,n),u.label=4;case 4:return a++,[3,1];case 5:return[3,7];case 6:return l=u.sent(),console.error(l),[3,7];case 7:return[2]}}))}))},e.prototype.loadVariation=function(e,t,n,r){return void 0===r&&(r=!1),p(this,void 0,void 0,(function(){var a,i,o,s,c,l,u,d,h;return f(this,(function(p){switch(p.label){case 0:p.trys.push([0,9,,10]),a=n.length,i=0,p.label=1;case 1:if(!(i<a))return[3,8];if(!(o=n[i].variations)||0===o.length)return this._getLastKnownVariations(e,n[i].nodeId)?(n[i].variations=this._getLastKnownVariations(e,n[i].nodeId),this._applyVariations(t,n[i],r),[3,7]):[3,7];s=[],c=0,p.label=2;case 2:return c<o.length?[4,x.LoadVariation(this.assetPath,o[c].gameObjectName||n[i].decoId)]:[3,6];case 3:return l=p.sent(),(u=new j).decoId=parseFloat(o[c].id),u.brandId=o[c].brandId,u.gameObjectName=o[c].gameObjectName,u.supplierArticleNr=o[c].supplierArticleNr,u.materialId=o[c].materialId,d=u,[4,w.CreateMaterialFromAsset(l)];case 4:d.material=p.sent(),s.push(u),p.label=5;case 5:return c++,[3,2];case 6:this._setLastKnownVariations(e,n[i].nodeId,s),n[i].variations=s,this._applyVariations(t,n[i],r),p.label=7;case 7:return i++,[3,1];case 8:return[3,10];case 9:return h=p.sent(),console.error(h),[3,10];case 10:return[2]}}))}))},e.prototype._getChildrenFilterByProp=function(e,t,n,r){return e.children.filter((function(e){return e.userData&&e.userData.hasOwnProperty(t)&&e.userData[t].hasOwnProperty(n)&&e.userData[t][n]===r}))},e.prototype._applyMaterialPart=function(e,n,r,a){var i=this;void 0===a&&(a=!1);for(var o=this._getChildrenFilterByProp(e,"selection","node",r),s=o.length,c=0;c<s;c++){var l=o[c];null!=l&&l.traverse((function(e){if(e instanceof t.Mesh&&n)if(Array.isArray(e.material))for(var r=0,o=e.material.length;r<o;r++)-1!==e.material[r].name.toLowerCase().indexOf("fixed_frame")&&(e.material[r]=i._setMeshMaterialFromVariation(e.material[r].name,n,a));else-1!==e.material.name.toLowerCase().indexOf("fixed_frame")&&(e.material=i._setMeshMaterialFromVariation(e.material.name,n,a))}))}},e.prototype._applyVariations=function(e,n,r){var a=this;void 0===r&&(r=!1);for(var i=this._getChildrenFilterByProp(e,"selection","node",n.node),o=i.length,s=0;s<o;s++){var c=i[s];null!=c&&c.traverse((function(e){if(e instanceof t.Mesh&&n.variations&&n.variations.length>0&&e.name.toLowerCase().indexOf("c_"))for(var i=0;i<n.variations.length;i++){var o=n.variations[i];if(o.material){var s=o.materialId?o.materialId.toLowerCase():"default";if(Array.isArray(e.material))for(var c=0,l=e.material.length;c<l;c++)-1!==e.material[c].name.toLowerCase().indexOf(s)&&(e.material[c]=a._setMeshMaterialFromVariation(e.material[c].name,o,r));else-1!==e.material.name.toLowerCase().indexOf(s)&&(e.material=a._setMeshMaterialFromVariation(e.material.name,o,r))}}}))}},e.prototype._setMeshMaterialFromVariation=function(e,n,r){if(void 0===r&&(r=!1),n.material.texture&&(n.material.texture.needsUpdate=!0),r){var a={name:e,roughness:n.material.roughnessValue?n.material.roughnessValue:1,metalness:n.material.metalnessValue?n.material.metalnessValue:0};return n.material.texture&&(a.map=n.material.texture),n.material.ao&&(a.aoMap=n.material.ao),n.material.roughness&&(a.roughnessMap=n.material.roughness),n.material.metalness&&(a.metalnessMap=n.material.metalness),n.material.normal&&(a.normalMap=n.material.normal),(i=new t.MeshStandardMaterial(a)).color.setRGB(1,1,1),i.needsUpdate=!0,i}var i;return(i=new t.MeshPhongMaterial({name:e,shininess:n.material.shininess,specular:n.material.specular,map:n.material.texture,normalMap:n.material.normal})).needsUpdate=!0,i},e.prototype._setLastKnownVariations=function(e,t,n){if(this._lastKnownVariations.has(e)){(r=this._lastKnownVariations.get(e)).set(t,n)}else{var r=new Map;this._lastKnownVariations.set(e,r.set(t,n))}},e.prototype._getLastKnownVariations=function(e,t){if(this._lastKnownVariations.has(e)){var n=this._lastKnownVariations.get(e);if(n.has(t))return n.get(t)}return null},e}(),N=function(){function e(e,t){if(this.selectionsReceived=new d.BehaviorSubject([]),this._selections=[],this._decos=[],this._placedAdjustables=[],this._placedAddables=[],this._adjustables=[],this._addables=[],!e)throw"No scene object provided!";if(!t)throw"No connection options provided!";this._scene=e,this._configuratorApi=new n.Configurator(t),this._boFactory=new a.BusinessObjectFactory,this._threedUtils=new g,this._variationHelper=new O}return e.prototype.buildModel=function(e,t,n){return p(this,void 0,void 0,(function(){var r,a,i;return f(this,(function(o){switch(o.label){case 0:if(!this._scene&&!e)return[2];o.label=1;case 1:return o.trys.push([1,12,,13]),n?[3,3]:[4,this._getGoodIdFromSku(t).catch((function(e){throw"Article with sku "+t+" not found!"}))];case 2:n=o.sent(),o.label=3;case 3:return[4,this._getArticle(n)];case 4:return(r=o.sent())&&r.assetUrl?(a=this,[4,this._threedUtils.download3DSource(r.assetUrl).catch((function(e){throw e}))]):[3,10];case 5:return a._source=o.sent(),this._source?(r.contentDeliveryUrl&&(this._variationHelper.assetPath=r.contentDeliveryUrl+(r.contentDeliveryUrl.endsWith("/")?"":"/")+(r.distSchema?r.distSchema:"UP_DBA")),[4,this._configuratorApi.setInstanceToConfigure(e)]):[3,8];case 6:return o.sent(),(i=[]).push(this._getSelections()),i.push(this._getDecos()),[4,Promise.all(i)];case 7:return o.sent(),this._linkSelectionsAndDecos(),[2,this._build(e)];case 8:throw"GLB source not found!";case 9:return[3,11];case 10:return[2,null];case 11:return[3,13];case 12:throw o.sent();case 13:return[2]}}))}))},e.prototype.initNodeInstance=function(e){return this._configuratorApi.initNodeInstance(e)},e.prototype.destroy=function(){this._threedUtils.clearCache(),this._variationHelper.clearCache()},e.prototype._build=function(e){return p(this,void 0,void 0,(function(){var n,r,a,i,o,s,c,l;return f(this,(function(u){switch(u.label){case 0:if(this._reset(),!((n=this._getAdjustables())&&n.length>0))return[3,2];for((r=new t.Object3D).visible=!1,this._scene.add(r),a=!1,i=0,o=n.length;i<o;i++){if(s=this._createAdjustable(r,n[i]))for(c=0,l=this._placedAdjustables.length;c<l;c++){if(v.TrySelectorConnection(this._scene,r,this._placedAdjustables[c],s)){this._placedAdjustables[c].visible=!0,s.visible=!0,a=!0;break}a=!1}!a&&this._placedAdjustables.length>1&&console.warn("No connection found for: ",s.name)}return this._placeAddables(r),this._updatePivot(r),[4,this._loadVariations(r,e)];case 1:return u.sent(),this._scene.remove(r),[2,r];case 2:throw"No adjustables found!"}}))}))},e.prototype._prepareTheSelections=function(){for(var e,t,n,r=this,a=this._selections.filter((function(e){return e.generic&&e.decoNode.variation&&!e.decoNode.type})).map((function(e,t,n){var a=r._selections.find((function(t){return t.artNodeIdDeco===e.decoNode.variation.id}));return a&&(e.decoNode.variation.supplierArticleNr=a.supplierArticleNr),e.decoNode.variation.materialId=e.hdecoGameObject,e.decoNode.variation})),i=!0,s=this._selections.length,l=!1,u=-1,d=0;d<s;d++){var h=this._selections[d];1===h.presentationLevel&&(n=h.hdecoPositioning),h.presentationLevel>u&&(h.hdecoPositioning=h.hdecoPositioning||n),h.decoNode&&(h.decoNode.type===o.DecoNodeType.Variation?e?(l?e.variations=[h.decoNode]:e.variations.push(h.decoNode),l=!1):(i&&(a.length=0,i=!1),a.push(h.decoNode)):h.decoNode.type===o.DecoNodeType.Part&&"string"==typeof h.decoNode.gameObjectName&&h.decoNode.gameObjectName.length&&(h.decoNode.kind===c.DecoNodeKind.Adjustable?(h.variations=a,this._adjustables.push(h),e&&e.nodeId===h.nodeId||(l=!0),e=h,t=h):h.decoNode.kind===c.DecoNodeKind.Addable&&(h.variations=t?t.variations:a,t&&t.addables.push(h),this._addables.push(h),e&&e.nodeId===h.nodeId||(l=!0),e=h))),u=h.presentationLevel}},e.prototype._createAdjustable=function(e,t){var n=this._source?this._source.getObjectByName(t.decoNode.gameObjectName):null;if(!n){var r=t.decoNode.gameObjectName.replace(/[.]/g,"");if(!(n=this._source?this._source.getObjectByName(r):null))return null}var a=n.clone();return a.name=this._createUniqueName(e,n),a.userData.selection=t,a.position.set(0,0,0),a.visible=!0,e.add(a),this._placedAdjustables.push(a),a},e.prototype._createAddable=function(e,t,n,r){var a=this._source.getObjectByName(t.decoNode.gameObjectName);if(!a)return null;var i=a.clone();return i.name=this._createUniqueName(e,a),i.userData.selection=t,i.position.set(0,0,0),i.visible=!0,r&&n?(e.add(i),this._placedAddables.push(i),i):i},e.prototype._placeAddables=function(e){for(var t=this,n=this._placedAdjustables.length,r=0;r<n;r++)if(this._placedAdjustables[r].userData.hasOwnProperty("selection")&&this._placedAdjustables[r].userData.selection){var a=this._placedAdjustables[r].userData.selection;if(a)for(var i=a.addables.length,o=void 0,s=0;s<i;s++)v.TrySelectorConnection(this._scene,e,this._placedAdjustables[r],a.addables[s],(function(n,r,a){return t._createAddable(e,n,r,a)})),o&&v.TrySelectorConnection(this._scene,e,o,a.addables[s],(function(n,r,a){return t._createAddable(e,n,r,a)})),o=this._placedAddables[this._placedAddables.length-1]}},e.prototype._createUniqueName=function(e,t){for(var n=0,r=t.name,a=e.getObjectByName(r);a;)n++,r=t.name+(0!==n?"_"+n:""),a=e.getObjectByName(r);return r},e.prototype._getGoodIdFromSku=function(e){return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return[4,this._configuratorApi.getGoodIdFromSku(e,!1)];case 1:return(t=n.sent()).validationResult.success&&t.resultObject?[2,t.resultObject]:[2]}}))}))},e.prototype._getArticle=function(e){return p(this,void 0,void 0,(function(){var t,n;return f(this,(function(r){switch(r.label){case 0:return[4,this._configuratorApi.getArticleQuickSel(e,!1)];case 1:return(t=r.sent()).validationResult.success&&t.resultObject?t.resultObject.hasOwnProperty("oArticle")?(n=Array.isArray(t.resultObject.oArticle)?t.resultObject.oArticle[0]:t.resultObject.oArticle,[2,this._boFactory.makeWithRawBackendData(u.Article,n)]):[2,this._boFactory.makeWithRawBackendData(u.Article,t.resultObject)]:[2]}}))}))},e.prototype._getSelections=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._selections.length=0,[4,this._configuratorApi.getSelections(!1)];case 1:if(!((e=t.sent()).resultObjects&&e.resultObjects.length>0))throw"No selections found!";return this._selections=this._boFactory.makeBOArrayFromRawBackendDataArray(i.Selection,e.resultObjects),this.selectionsReceived.next(this._selections),[2]}}))}))},e.prototype._getDecos=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this._decos.length=0,[4,this._configuratorApi.getDecos(!1)];case 1:if(!((e=t.sent()).resultObjects&&e.resultObjects.length>0))throw"No deconodes found!";return this._decos=this._boFactory.makeBOArrayFromRawBackendDataArray(r.DecoNode,e.resultObjects),[2]}}))}))},e.prototype._linkSelectionsAndDecos=function(){for(var e=this,t=this._selections.length,n=function(t){var n=a._selections[t].artNodeIdDeco,i=a._decos.find((function(e){return e.id===n}));i||(i=new r.DecoNode);var o=a._getVariations().find((function(n){return n.parentId===e._selections[t].artNodeIdDeco}));o&&(i.variation=o),a._selections[t].decoNode=i},a=this,i=0;i<t;i++)n(i)},e.prototype._getVariations=function(){return this._decos.filter((function(e){return e.type===o.DecoNodeType.Variation}))},e.prototype._loadVariations=function(e,t){return p(this,void 0,void 0,(function(){return f(this,(function(n){switch(n.label){case 0:return[4,this._variationHelper.loadPart(e,this._adjustables,!0)];case 1:return n.sent(),[4,this._variationHelper.loadVariation(t,e,this._adjustables,!0)];case 2:return n.sent(),[4,this._variationHelper.loadVariation(t,e,this._addables,!0)];case 3:return n.sent(),[2]}}))}))},e.prototype._getAdjustables=function(){return this._selections.filter((function(e){var t=e.decoNode;return t&&t.gameObjectName&&t.type===o.DecoNodeType.Part&&t.kind===c.DecoNodeKind.Adjustable}))},e.prototype._updatePivot=function(e){var n=(new t.Box3).setFromObject(e),r=new t.Vector3;n.getCenter(r);var a=(new t.Vector3).sub(r).setY(Math.abs(Math.min(n.min.y,0)));e.children.forEach((function(e){e.position.add(a)})),e.updateWorldMatrix(!1,!0)},e.prototype._reset=function(){this._placedAddables.length=0,this._placedAdjustables.length=0,this._adjustables.length=0,this._addables.length=0,this._prepareTheSelections()},e}();e.Builder=N,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
16
|
+
var m=function(e,t){return(m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function g(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}function b(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))}function v(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var w=function(){function e(){}return e.DisposeMaterial=function(e){var t=this;e&&(Array.isArray(e)?e.forEach((function(e){t.materialProps.filter((function(t){return e[t]})).forEach((function(t){return e[t].dispose()})),e.dispose()})):(this.materialProps.filter((function(t){return e[t]&&e[t].dispose})).forEach((function(t){return e[t].dispose()})),e.dispose&&e.dispose()))},e.DisposeObject=function(e){var t=this;e&&(e.children.length&&e.children.forEach((function(e){return t.DisposeObject(e)})),this.DisposeNode(e))},e.DisposeNode=function(e){var n=this;e.traverse((function(e){e instanceof t.Mesh&&(e.geometry&&e.geometry.dispose(),n.DisposeMaterial(e.material)),"function"==typeof e.dispose&&e.dispose()}))},e.materialProps=["map","lightMap","bumpMap","normalMap","specularMap","envMap","aoMap","roughnessMap","metalnessMap"],e}(),y=function(){function e(){}return e.StripMimeStringFromDataUri=function(e){if(!e)return"";var t=this.GetMimeStringFromDataUri(e);return e.substr(t.length+1)},e.GetMimeStringFromDataUri=function(e){return e?e.split(",")[0]:""},e.FileExists=function(e,t){return b(this,void 0,void 0,(function(){return v(this,(function(n){switch(n.label){case 0:return[4,s({method:"get",url:t+"getFiles.php?assetUrl="+e,responseType:"json"})];case 1:return[2,!!n.sent().data]}}))}))},e.FixUrl=function(t){if(!t)return"";var n=t;return n.endsWith("glb")||n.endsWith("obj")||n.endsWith("glb.gz")||n.endsWith("obj.gz")||(n=e.FixUnityUrl(n)),n=n.replace("/content/","/content43/")},e.FixGlbUrl=function(e){if(!e)return"";var t=e;return-1===e.indexOf("_webplayer")&&(t=e.concat("_webplayer")),(t=t.replace("/content/","/content43/")).endsWith(".glb")||(t=t.concat(".glb")),t},e.MimeTypeFromFilename=function(e){switch(/(?:\.([^.]+))?$/.exec(e)[1]){case"jpg":case"jpeg":return"image/jpeg";case"png":return"image/png";case"bmp":return"image/bmp"}},e.DownloadFile=function(e,t,n){void 0===n&&(n="text/plain");var r=document.createElement("a");r.setAttribute("href","data:"+n+";charset=utf-8,"+encodeURIComponent(t)),r.setAttribute("download",e),r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r)},e.ReadAsText=function(e){return new Promise((function(t){var n=new FileReader;n.readAsText(e),n.onloadend=function(e){2===e.target.readyState&&t(e.target.result)}}))},e.GetExtensionFromDataUri=function(e){return e.replace(/(data:image\/)(.*?)(;base64.*)/gi,"$2")},e.CreateDownloadFileNameFromBase64=function(e){return"preview."+this.GetExtensionFromDataUri(e)},e.DownloadFromDataUri=function(e,t){var n=document.createElement("a");n.download=t,n.href=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)},e.DocumentBodyToDataUri=function(e,t){return e?"data:"+t+";base64,"+e:""},e.FixUnityUrl=function(e){return(e=-1===e.indexOf("_webplayer")?e.concat("_webplayer.ione3d"):e.replace("_webplayer","_webplayer.ione3d")).endsWith(".gz")||(e=e.concat(".gz")),e.replace(".unity3d","")},e._cachedTextureUploads=new Map,e}(),_=function(){function e(){this._objectCache=new Map}return e.prototype.clearCache=function(){Array.from(this._objectCache.values()).forEach((function(e){return w.DisposeObject(e)})),this._objectCache.clear()},e.prototype.download3DSource=function(e){var t=this;return new Promise((function(n,r){return b(t,void 0,void 0,(function(){var t,i=this;return v(this,(function(o){switch(o.label){case 0:return e=e.replace(".unity3d",""),t=e+(e.indexOf(".glb")<0?".glb":""),this._objectCache.has(t)?(n(this._objectCache.get(t)),[2]):[4,y.FileExists(t,"https://cdn1.colijn-it.nl/content43/")];case 1:return o.sent()?this.loadGlbSource(t).then((function(e){i._objectCache.set(t,e),n(e)})):r("GLB source not found! ("+t+")"),[2]}}))}))}))},e.prototype.readFileAsText=function(e){var t=new FileReader;return new Promise((function(n,r){t.onload=function(e){return n(e.target.result)},t.onerror=function(e){return r(e)},t.readAsText(e)}))},e.prototype.loadJsonModel=function(e){return b(this,void 0,void 0,(function(){var n,r,i=this;return v(this,(function(o){switch(o.label){case 0:return this._objectCache.has(e)?[2,Promise.resolve(this._objectCache.get(e))]:[4,this._readJsonFile(e)];case 1:return n=o.sent(),(r=new t.ObjectLoader).crossOrigin="Anonymous",[2,new Promise((function(t,o){try{var a=r.parse(n);i._objectCache.set(e,a),t(a)}catch(e){o(null)}}))]}}))}))},e.prototype.loadJsonObjectModel=function(e){return b(this,void 0,void 0,(function(){var n,r=this;return v(this,(function(i){return this._objectCache.has(e)?[2,Promise.resolve(this._objectCache.get(e))]:((n=new t.ObjectLoader).setCrossOrigin("Anonymous"),n.setResourcePath(""),[2,new Promise((function(t,i){n.load(e,(function(n){var i="Scene"===n.type&&"Object3D"===n.children[0].type?n.children[0]:n;r._objectCache.set(e,i),t(i)}),(function(e){return null}),(function(e){return i(e)}))}))])}))}))},e.prototype.loadGlbModel=function(e,t){return void 0===t&&(t=!0),b(this,void 0,void 0,(function(){var n;return v(this,(function(r){switch(r.label){case 0:return this._objectCache.has(e)?[2,Promise.resolve(this._objectCache.get(e))]:window.hasOwnProperty("loadGLTF")?[4,window.loadGLTF(e)]:(console.error("loadGLTF not defined in window global"),[2,null]);case 1:return(n=r.sent())?(this._cleanedUpObjects(n,t),this._objectCache.set(e,n),[2,n]):[2,null]}}))}))},e.prototype.loadGlbSource=function(e){return b(this,void 0,void 0,(function(){var n,r;return v(this,(function(i){switch(i.label){case 0:return[4,this.loadGlbModel(e,!1)];case 1:return(n=i.sent())&&(n.children=n.children.filter((function(e){return!(e instanceof t.Camera)})),n.children.sort((function(e,t){return e.name<t.name?1:-1})),n.children.forEach((function(e){e.traverse((function(e){e.visible=!e.name.toLowerCase().startsWith("c_")})),e.visible=!1})),1===n.children.length&&n.children[0]instanceof t.Group&&(r=n.children[0].children.slice(),n.children.length=0,n.children=r)),[2,n]}}))}))},e.prototype.textureFromUrl=function(e){return b(this,void 0,void 0,(function(){return v(this,(function(n){return[2,new Promise((function(n,r){(new t.TextureLoader).load(e,(function(e){return e.wrapT=t.RepeatWrapping,e.wrapS=t.RepeatWrapping,e.repeat.set(1,1),e.needsUpdate=!0,n(e)}),null,r)}))]}))}))},e.prototype._cleanedUpObjects=function(e,n){var r=this;void 0===n&&(n=!0);var i=new t.Object3D;e.children.forEach((function(e){e instanceof t.Camera||(n&&e instanceof t.Group||1===e.children.length&&e.children[0]instanceof t.Group?r._addGroupChildrenToObject(e,i):n&&!(e instanceof t.Mesh)||!(e instanceof t.Mesh)&&!e.name&&e.children.length>0?(e.children.forEach((function(t){t.translateY(e.position.y)})),e.translateY(-e.position.y),i.children.length>0?i.add(e.clone()):i=e.clone()):i.add(e.clone()))}));var o=(new t.Box3).setFromObject(i),a=new t.Vector3;o.getCenter(a);var s=(new t.Vector3).add(a).negate();return i.children.forEach((function(e){e.position.add(s)})),i},e.prototype._addGroupChildrenToObject=function(e,n,r){var i=this;void 0===r&&(r=!0),e.children.forEach((function(o){r&&o instanceof t.Group?i._addGroupChildrenToObject(o,n):(o.translateY(e.position.y),n.add(o.clone()))}))},e.prototype._iterateChildren=function(e,n){for(var r=0;r<e.length;r++){var i=e[r];i instanceof t.Mesh?n(i):this._iterateChildren(i.children,n)}},e.prototype._readJsonFile=function(e){return b(this,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return r.trys.push([0,5,,6]),[4,fetch(e)];case 1:return(t=r.sent()).ok?[3,2]:[2,""];case 2:return n=!1,[4,t.clone().text().then((function(e){""===e&&(n=!0)}))];case 3:return r.sent(),[2,n?{}:t.json()];case 4:return[3,6];case 5:return r.sent(),[2,""];case 6:return[2]}}))}))},e}(),j=function(){function e(){}return e.TrySelectorConnection=function(e,t,n,r,i){var o;i&&(r=i(o=r));for(var a=0;a<n.children.length;a++)for(var s=0;s<r.children.length;s++){var c=n.children[a],l=r.children[s];if(!c.connected&&!l.connected&&this.CanSelectorConnect(c,l)){if(!o)return this.SelectorConnect(e,t,c,l);var u=i(o,r,n);this.SelectorConnect(e,t,c,u.children[s])}}return!1},e.Convert3DPointToScreenPoint=function(e,n,r,i){if(!e)return new t.Vector2;var o=e.clone().project(n);return o.x=(o.x+1)/2*r,o.y=-(o.y-1)/2*i,new t.Vector2(o.x,o.y)},e.CanSelectorConnect=function(e,n){var r=e instanceof t.Object3D?e.name:e.connector,i=n instanceof t.Object3D?n.name:n.connector,o=e instanceof t.Object3D&&n instanceof t.Object3D&&e.parent===n.parent,a=r.toUpperCase().split("_"),s=i.toUpperCase().split("_");return a.length>=3&&s.length>=3&&!o&&("C"===a[0]&&"C"===s[0]&&a[1]===s[1]&&a[2]!==s[2])},e.SelectorConnect=function(e,n,r,i){if(!e||!n)return!1;r.connectedTo=i.parent.name,i.connectedTo=r.parent.name;var o=new t.Euler(0,0,0),a=new t.Vector3(0,0,0);e.updateMatrixWorld(!0),o.copy(n.rotation),n.getWorldPosition(a),n.rotation.set(0,0,0),n.position.set(0,0,0);var s=new t.Quaternion;r.getWorldQuaternion(s);var c=new t.Quaternion;i.getWorldQuaternion(c);var l=new t.Quaternion;r.parent.getWorldQuaternion(l);var u=new t.Quaternion;i.parent.getWorldQuaternion(u);var d=(new t.Quaternion).multiplyQuaternions(s.invert(),c).multiply((new t.Quaternion).multiplyQuaternions(l,l));i.parent.quaternion.copy(d),e.updateMatrixWorld(!0);var h=new t.Vector3;r.getWorldPosition(h);var p=new t.Vector3;i.getWorldPosition(p);var f=h.sub(p);return i.parent.position.x+=f.x,i.parent.position.y+=f.y,i.parent.position.z+=f.z,n.rotation.copy(o),n.position.copy(a),e.updateMatrixWorld(!0),r.connected=!0,i.connected=!0,!0},e}(),F=function(){this.specular=new t.Color(.3,.3,.3),this.shininess=0,this.repeatX=4,this.repeatY=4,this.loaded=!1},x=function(){function e(){}return e.CreateTextureFromBase64=function(n,r,i){return new Promise((function(o){e.textures.has(n)?o(e.textures.get(n)):r?(new t.TextureLoader).load(r,(function(r){r.anisotropy=16,r.wrapS=t.RepeatWrapping,r.wrapT=t.RepeatWrapping,r.repeat=new t.Vector2(i?i.repeatX:1,i?i.repeatY:1),r.needsUpdate=!0,e.textures.set(n,r),o(r)})):o(new t.Texture)}))},e.textures=new Map,e}(),C=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}(function(e,t){function n(){this.constructor=e}m(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)})(t,e)}(F),function(){function e(){}return e.CreateMaterialFromAsset=function(n){return b(this,void 0,void 0,(function(){var r,i,o,a,s,c;return v(this,(function(l){switch(l.label){case 0:return r=new F,n?(n.settings&&e.setSettingsOfMaterial(r,n.settings),n.texture?(i=r,[4,x.CreateTextureFromBase64(n.id+"_texture",n.texture,r)]):[3,2]):[2,r];case 1:i.texture=l.sent(),r.texture.encoding=t.sRGBEncoding,r.textureFilename=n.textureFilename,l.label=2;case 2:return n.normal?(o=r,[4,x.CreateTextureFromBase64(n.id+"_normal",n.normal,r)]):[3,4];case 3:o.normal=l.sent(),r.normalFilename=n.normalFilename,l.label=4;case 4:return n.ao?(a=r,[4,x.CreateTextureFromBase64(n.id+"_ao",n.ao,r)]):[3,6];case 5:a.ao=l.sent(),r.aoFilename=n.aoFilename,l.label=6;case 6:return n.metalness?(s=r,[4,x.CreateTextureFromBase64(n.id+"_metalness",n.metalness,r)]):[3,8];case 7:s.metalness=l.sent(),r.metalnessFilename=n.metalnessFilename,l.label=8;case 8:return n.roughness?(c=r,[4,x.CreateTextureFromBase64(n.id+"_roughness",n.roughness,r)]):[3,10];case 9:c.roughness=l.sent(),r.roughnessFilename=n.roughnessFilename,l.label=10;case 10:return[2,r]}}))}))},e.setSettingsOfMaterial=function(e,n){var r=parseFloat(n.power);isNaN(r)||(e.shininess=r);var i=parseFloat(n.level);isNaN(i)||(e.specular=new t.Color(i,i,i));var o=n.hasOwnProperty("repeat"),a=o?parseFloat(n.repeat.repeatx):parseFloat(n.repeatx);isNaN(a)||(e.repeatX=Math.max(1,a));var s=o?parseFloat(n.repeat.repeaty):parseFloat(n.repeaty);isNaN(s)||(e.repeatY=Math.max(1,s));var c=parseFloat(n.metalness);isNaN(c)||(e.metalnessValue=Math.min(1,c));var l=parseFloat(n.roughness);isNaN(l)||(e.roughnessValue=Math.min(1,l))},e}()),O=function(){},N=function(){this.settings={}},A=function(){function e(){}return e.LoadVariation=function(t,n){return b(this,void 0,void 0,(function(){var r,i,o;return v(this,(function(a){switch(a.label){case 0:if(!n)return[2,null];n.indexOf("ione3d")<0&&(n=n.concat(".ione3d")),r=n.substr(0,n.lastIndexOf(".ione3d")),a.label=1;case 1:return a.trys.push([1,4,,5]),t.endsWith("/")||(t+="/"),window.hasOwnProperty("downloadVariation")?[4,window.downloadVariation(t.replace("https://cdn1.colijn-it.nl/","")+"variation/"+n)]:(console.error("downloadVariation not defined in window global"),[2,null]);case 2:return i=a.sent(),[4,e.GetVariationSettingsFromFile(r,i)];case 3:return[2,a.sent()];case 4:return o=a.sent(),o,[2,null];case 5:return[2]}}))}))},e.GetVariationSettingsFromFile=function(t,n){return b(this,void 0,void 0,(function(){var r,i,o,a;return v(this,(function(s){switch(s.label){case 0:return n?[4,e.GetZipContent(n)]:[2,null];case 1:return r=s.sent(),(i=new N).id=t,r.files["index.json"]?[4,r.files["index.json"].async("string")]:[3,3];case 2:a=s.sent(),o=JSON.parse(a),s.label=3;case 3:return o?[4,e.CreateSettingsBasedOnIndex(o,i,r)]:[3,5];case 4:return s.sent(),[3,7];case 5:return[4,e.CreateSettingsBasedOnFileName(i,r)];case 6:s.sent(),s.label=7;case 7:return[2,i]}}))}))},e.CreateSettingsBasedOnIndex=function(t,n,r){return b(this,void 0,void 0,(function(){var i,o,a,s,c,l;return v(this,(function(u){switch(u.label){case 0:return t.normalFile?(i=n,[4,e.LoadFileContentFromZip(r.files[t.normalFile],t.normalFile)]):[3,2];case 1:i.normal=u.sent(),n.normalFilename=t.normalFile,u.label=2;case 2:return t.aoFile?(o=n,[4,e.LoadFileContentFromZip(r.files[t.aoFile],t.aoFile)]):[3,4];case 3:o.ao=u.sent(),n.aoFilename=t.aoFile,u.label=4;case 4:return t.metalnessFile?(a=n,[4,e.LoadFileContentFromZip(r.files[t.metalnessFile],t.metalnessFile)]):[3,6];case 5:a.metalness=u.sent(),n.metalnessFilename=t.metalnessFile,u.label=6;case 6:return t.roughnessFile?(s=n,[4,e.LoadFileContentFromZip(r.files[t.roughnessFile],t.roughnessFile)]):[3,8];case 7:s.roughness=u.sent(),n.roughnessFilename=t.roughnessFile,u.label=8;case 8:return t.diffuseFile?(c=n,[4,e.LoadFileContentFromZip(r.files[t.diffuseFile],t.diffuseFile)]):[3,10];case 9:c.texture=u.sent(),n.textureFilename=t.diffuseFile,u.label=10;case 10:return l=n,[4,e.LoadFileContentFromZip(r.files["repeat.json"],"repeat.json",!1)];case 11:return l.settings=u.sent()||{},Object.assign(n.settings,t.repeat),n.settings.metalness=t.metalness,n.settings.roughness=t.roughness,[2]}}))}))},e.CreateSettingsBasedOnFileName=function(e,t){return b(this,void 0,void 0,(function(){var n,r,i,o,a,s,c,l=this;return v(this,(function(u){switch(u.label){case 0:for(a in n=[],r=function(r){var o;return v(this,(function(a){switch(a.label){case 0:return t.files[r]?[4,t.files[r]]:[3,2];case 1:(o=a.sent()).name.toLowerCase().indexOf("normal")>-1&&i.FileIsImage(o.name)?n.push(t.files[r].async("base64").then((function(t){e.normal="data:image/"+l.GetBase64FileType(o.name)+";base64,"+t,e.normalFilename=r}))):o.name.toLowerCase().indexOf("ao")>-1&&i.FileIsImage(o.name)?n.push(t.files[r].async("base64").then((function(t){e.ao="data:image/"+l.GetBase64FileType(o.name)+";base64,"+t,e.aoFilename=r}))):o.name.toLowerCase().indexOf("metalness")>-1&&i.FileIsImage(o.name)?n.push(t.files[r].async("base64").then((function(t){e.metalness="data:image/"+l.GetBase64FileType(o.name)+";base64,"+t,e.metalnessFilename=r}))):o.name.toLowerCase().indexOf("roughness")>-1&&i.FileIsImage(o.name)?n.push(t.files[r].async("base64").then((function(t){e.roughness="data:image/"+l.GetBase64FileType(o.name)+";base64,"+t,e.roughnessFilename=r}))):o.name.toLowerCase().indexOf("diffuse")>-1&&i.FileIsImage(o.name)?n.push(t.files[r].async("base64").then((function(t){e.texture="data:image/"+l.GetBase64FileType(o.name)+";base64,"+t,e.textureFilename=r}))):o.name.indexOf(".jp")>-1?n.push(t.files[r].async("base64").then((function(t){e.texture="data:image/jpeg;base64,"+t,e.textureFilename=r}))):o.name.indexOf(".json")>-1&&n.push(t.files[r].async("string").then((function(t){var n=JSON.parse(t);for(var r in n)n[r]&&(e.settings[r]=n[r])}))),a.label=2;case 2:return[2]}}))},i=this,o=[],t.files)o.push(a);s=0,u.label=1;case 1:return s<o.length?(c=o[s],[5,r(c)]):[3,4];case 2:u.sent(),u.label=3;case 3:return s++,[3,1];case 4:return[4,Promise.all(n)];case 5:return u.sent(),[2]}}))}))},e.LoadFileContentFromZip=function(e,t,n){var r=this;return void 0===n&&(n=!0),new Promise((function(i){e&&t?e.async(n?"base64":"string").then((function(e){i(n?"data:image/"+r.GetBase64FileType(t)+";base64,"+e:e)})):i(void 0)}))},e.FileIsImage=function(e){switch(e.substring(e.lastIndexOf(".")+1,e.length).toLowerCase()){case"jpg":case"jpeg":case"png":case"bmp":return!0;default:return!1}},e.GetBase64FileType=function(e){switch(e.substring(e.lastIndexOf(".")+1,e.length).toLowerCase()){case"jpg":case"jpeg":return"jpeg";case"png":return"png";case"bmp":return"bmp";default:return"jpeg"}},e.GetZipContent=function(e){return b(this,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return[4,(new l).loadAsync(e)];case 1:return[2,t.sent()]}}))}))},e.MaterialCache=new Map,e}(),M=function(){function e(){this._lastKnownVariations=new Map}return e.prototype.clearCache=function(){for(var e=Array.from(this._lastKnownVariations.values()),t=0;t<e.length;t++){Array.from(e[t].values()).forEach((function(e){e.forEach((function(e){e.material.texture.dispose(),e.material.normal.dispose(),e.material.metalness.dispose(),e.material.roughness.dispose(),e.material.ao.dispose()}))}))}},e.prototype.loadPart=function(e,t,n){return void 0===n&&(n=!1),b(this,void 0,void 0,(function(){var r,i,o,s,c,l;return v(this,(function(u){switch(u.label){case 0:u.trys.push([0,6,,7]),r=t.length,i=0,u.label=1;case 1:return i<r?t[i].decoNode&&t[i].decoNode.gameObjectName&&t[i].decoNode.type===a.DecoNodeType.Part?[4,A.LoadVariation(this.assetPath,t[i].decoNode.gameObjectName||t[i].decoId)]:[3,4]:[3,5];case 2:return(o=u.sent())?((s=new O).decoId=parseFloat(t[i].decoNode.id),s.brandId=t[i].decoNode.brandId,s.gameObjectName=t[i].decoNode.gameObjectName,c=s,[4,C.CreateMaterialFromAsset(o)]):[3,4];case 3:c.material=u.sent(),this._applyMaterialPart(e,s,t[i].node,n),u.label=4;case 4:return i++,[3,1];case 5:return[3,7];case 6:return l=u.sent(),console.error(l),[3,7];case 7:return[2]}}))}))},e.prototype.loadVariation=function(e,t,n,r){return void 0===r&&(r=!1),b(this,void 0,void 0,(function(){var i,o,a,s,c,l,u,d,h;return v(this,(function(p){switch(p.label){case 0:p.trys.push([0,9,,10]),i=n.length,o=0,p.label=1;case 1:if(!(o<i))return[3,8];if(!(a=n[o].variations)||0===a.length)return this._getLastKnownVariations(e,n[o].nodeId)?(n[o].variations=this._getLastKnownVariations(e,n[o].nodeId),this._applyVariations(t,n[o],r),[3,7]):[3,7];s=[],c=0,p.label=2;case 2:return c<a.length?[4,A.LoadVariation(this.assetPath,a[c].gameObjectName||n[o].decoId)]:[3,6];case 3:return l=p.sent(),(u=new O).decoId=parseFloat(a[c].id),u.brandId=a[c].brandId,u.gameObjectName=a[c].gameObjectName,u.supplierArticleNr=a[c].supplierArticleNr,u.materialId=a[c].materialId,d=u,[4,C.CreateMaterialFromAsset(l)];case 4:d.material=p.sent(),s.push(u),p.label=5;case 5:return c++,[3,2];case 6:this._setLastKnownVariations(e,n[o].nodeId,s),n[o].variations=s,this._applyVariations(t,n[o],r),p.label=7;case 7:return o++,[3,1];case 8:return[3,10];case 9:return h=p.sent(),console.error(h),[3,10];case 10:return[2]}}))}))},e.prototype._getChildrenFilterByProp=function(e,t,n,r){return e.children.filter((function(e){return e.userData&&e.userData.hasOwnProperty(t)&&e.userData[t].hasOwnProperty(n)&&e.userData[t][n]===r}))},e.prototype._applyMaterialPart=function(e,n,r,i){var o=this;void 0===i&&(i=!1);for(var a=this._getChildrenFilterByProp(e,"selection","node",r),s=a.length,c=0;c<s;c++){var l=a[c];null!=l&&l.traverse((function(e){if(e instanceof t.Mesh&&n)if(Array.isArray(e.material))for(var r=0,a=e.material.length;r<a;r++)-1!==e.material[r].name.toLowerCase().indexOf("fixed_frame")&&(e.material[r]=o._setMeshMaterialFromVariation(e.material[r].name,n,i));else-1!==e.material.name.toLowerCase().indexOf("fixed_frame")&&(e.material=o._setMeshMaterialFromVariation(e.material.name,n,i))}))}},e.prototype._applyVariations=function(e,n,r){var i=this;void 0===r&&(r=!1);for(var o=this._getChildrenFilterByProp(e,"selection","node",n.node),a=o.length,s=0;s<a;s++){var c=o[s];null!=c&&c.traverse((function(e){if(e instanceof t.Mesh&&n.variations&&n.variations.length>0&&e.name.toLowerCase().indexOf("c_"))for(var o=0;o<n.variations.length;o++){var a=n.variations[o];if(a.material){var s=a.materialId?a.materialId.toLowerCase():"default";if(Array.isArray(e.material))for(var c=0,l=e.material.length;c<l;c++)-1!==e.material[c].name.toLowerCase().indexOf(s)&&(e.material[c]=i._setMeshMaterialFromVariation(e.material[c].name,a,r));else-1!==e.material.name.toLowerCase().indexOf(s)&&(e.material=i._setMeshMaterialFromVariation(e.material.name,a,r))}}}))}},e.prototype._setMeshMaterialFromVariation=function(e,n,r){if(void 0===r&&(r=!1),n.material.texture&&(n.material.texture.needsUpdate=!0),r){var i={name:e,roughness:n.material.roughnessValue?n.material.roughnessValue:1,metalness:n.material.metalnessValue?n.material.metalnessValue:0};return n.material.texture&&(i.map=n.material.texture),n.material.ao&&(i.aoMap=n.material.ao),n.material.roughness&&(i.roughnessMap=n.material.roughness),n.material.metalness&&(i.metalnessMap=n.material.metalness),n.material.normal&&(i.normalMap=n.material.normal),(o=new t.MeshStandardMaterial(i)).color.setRGB(1,1,1),o.needsUpdate=!0,o}var o;return(o=new t.MeshPhongMaterial({name:e,shininess:n.material.shininess,specular:n.material.specular,map:n.material.texture,normalMap:n.material.normal})).needsUpdate=!0,o},e.prototype._setLastKnownVariations=function(e,t,n){if(this._lastKnownVariations.has(e)){(r=this._lastKnownVariations.get(e)).set(t,n)}else{var r=new Map;this._lastKnownVariations.set(e,r.set(t,n))}},e.prototype._getLastKnownVariations=function(e,t){if(this._lastKnownVariations.has(e)){var n=this._lastKnownVariations.get(e);if(n.has(t))return n.get(t)}return null},e}(),V=function(){function e(e,t){var r=this;if(this.selectionsReceived=new d.BehaviorSubject([]),this.answersReceived=new d.BehaviorSubject([]),this.questionReceived=new d.BehaviorSubject(void 0),this._selections=[],this._decos=[],this._placedAdjustables=[],this._placedAddables=[],this._adjustables=[],this._addables=[],this._articleCache=new Map,this._subs=[],!e)throw"No scene object provided!";if(!t)throw"No connection options provided!";this._scene=e,this._configuratorApi=new n.Configurator(t),this._boFactory=new i.BusinessObjectFactory,this._threedUtils=new _,this._variationHelper=new M,this._subs.push(this._configuratorApi.selectionsReceived.subscribe((function(e){return r.selectionsReceived.next(e)})),this._configuratorApi.answersReceived.subscribe((function(e){return r.answersReceived.next(e)})),this._configuratorApi.questionReceived.subscribe((function(e){return r.questionReceived.next(e)})))}return e.prototype.buildModel=function(e,t,n){return b(this,void 0,void 0,(function(){var r;return v(this,(function(i){switch(i.label){case 0:if(!this._scene&&!e)return[2];i.label=1;case 1:return i.trys.push([1,7,,8]),[4,this._prepareConfiguration(t,n)];case 2:return i.sent(),this._source?[4,this._configuratorApi.setInstanceToConfigure(e)]:[3,5];case 3:return i.sent(),(r=[]).push(this._getSelections(e)),r.push(this._getDecos()),[4,Promise.all(r)];case 4:return i.sent(),this._linkSelectionsAndDecos(),[2,this._build(e)];case 5:throw"GLB source not found!";case 6:return[3,8];case 7:throw i.sent();case 8:return[2]}}))}))},e.prototype.initNodeInstance=function(e){return this._configuratorApi.initNodeInstance(e)},e.prototype.destroy=function(){this._threedUtils.clearCache(),this._variationHelper.clearCache()},e.prototype.selectSelection=function(e){this._configuratorApi.selectSelection(e,!1)},e.prototype.getQuestionAndAnswers=function(){return b(this,void 0,void 0,(function(){return v(this,(function(e){return[2,this._configuratorApi.getQuestionAndAnswers(!1)]}))}))},e.prototype.selectAnswer=function(e){this._configuratorApi.selectAnswer(e,!1)},e.prototype._prepareConfiguration=function(e,t){return b(this,void 0,void 0,(function(){var n,r;return v(this,(function(i){switch(i.label){case 0:return[4,this._getArticle(e,t)];case 1:return(n=i.sent())&&n.assetUrl?(r=this,[4,this._threedUtils.download3DSource(n.assetUrl).catch((function(e){throw e}))]):[3,3];case 2:r._source=i.sent(),n.contentDeliveryUrl&&(this._variationHelper.assetPath=n.contentDeliveryUrl+(n.contentDeliveryUrl.endsWith("/")?"":"/")+(n.distSchema?n.distSchema:"UP_DBA")),i.label=3;case 3:return[2]}}))}))},e.prototype._build=function(e){return b(this,void 0,void 0,(function(){var n,r,i,o,a,s,c,l;return v(this,(function(u){switch(u.label){case 0:if(this._reset(),!((n=this._getAdjustables())&&n.length>0))return[3,2];for((r=new t.Object3D).visible=!1,this._scene.add(r),i=!1,o=0,a=n.length;o<a;o++){if(s=this._createAdjustable(r,n[o]))for(c=0,l=this._placedAdjustables.length;c<l;c++){if(j.TrySelectorConnection(this._scene,r,this._placedAdjustables[c],s)){this._placedAdjustables[c].visible=!0,s.visible=!0,i=!0;break}i=!1}!i&&this._placedAdjustables.length>1&&console.warn("No connection found for: ",s.name)}return this._placeAddables(r),this._updatePivot(r),[4,this._loadVariations(r,e)];case 1:return u.sent(),this._scene.remove(r),[2,r];case 2:throw"No adjustables found!"}}))}))},e.prototype._prepareTheSelections=function(){for(var e,t,n,r=this,i=this._selections.filter((function(e){return e.generic&&e.decoNode.variation&&!e.decoNode.type})).map((function(e,t,n){var i=r._selections.find((function(t){return t.artNodeIdDeco===e.decoNode.variation.id}));return i&&(e.decoNode.variation.supplierArticleNr=i.supplierArticleNr),e.decoNode.variation.materialId=e.hdecoGameObject,e.decoNode.variation})),o=!0,s=this._selections.length,l=!1,u=-1,d=0;d<s;d++){var h=this._selections[d];1===h.presentationLevel&&(n=h.hdecoPositioning),h.presentationLevel>u&&(h.hdecoPositioning=h.hdecoPositioning||n),h.decoNode&&(h.decoNode.type===a.DecoNodeType.Variation?e?(l?e.variations=[h.decoNode]:e.variations.push(h.decoNode),l=!1):(o&&(i.length=0,o=!1),i.push(h.decoNode)):h.decoNode.type===a.DecoNodeType.Part&&"string"==typeof h.decoNode.gameObjectName&&h.decoNode.gameObjectName.length&&(h.decoNode.kind===c.DecoNodeKind.Adjustable?(h.variations=i,this._adjustables.push(h),e&&e.nodeId===h.nodeId||(l=!0),e=h,t=h):h.decoNode.kind===c.DecoNodeKind.Addable&&(h.variations=t?t.variations:i,t&&t.addables.push(h),this._addables.push(h),e&&e.nodeId===h.nodeId||(l=!0),e=h))),u=h.presentationLevel}},e.prototype._createAdjustable=function(e,t){var n=this._source?this._source.getObjectByName(t.decoNode.gameObjectName):null;if(!n){var r=t.decoNode.gameObjectName.replace(/[.]/g,"");if(!(n=this._source?this._source.getObjectByName(r):null))return null}var i=n.clone();return i.name=this._createUniqueName(e,n),i.userData.selection=t,i.position.set(0,0,0),i.visible=!0,e.add(i),this._placedAdjustables.push(i),i},e.prototype._createAddable=function(e,t,n,r){var i=this._source.getObjectByName(t.decoNode.gameObjectName);if(!i)return null;var o=i.clone();return o.name=this._createUniqueName(e,i),o.userData.selection=t,o.position.set(0,0,0),o.visible=!0,r&&n?(e.add(o),this._placedAddables.push(o),o):o},e.prototype._placeAddables=function(e){for(var t=this,n=this._placedAdjustables.length,r=0;r<n;r++)if(this._placedAdjustables[r].userData.hasOwnProperty("selection")&&this._placedAdjustables[r].userData.selection){var i=this._placedAdjustables[r].userData.selection;if(i)for(var o=i.addables.length,a=void 0,s=0;s<o;s++)j.TrySelectorConnection(this._scene,e,this._placedAdjustables[r],i.addables[s],(function(n,r,i){return t._createAddable(e,n,r,i)})),a&&j.TrySelectorConnection(this._scene,e,a,i.addables[s],(function(n,r,i){return t._createAddable(e,n,r,i)})),a=this._placedAddables[this._placedAddables.length-1]}},e.prototype._createUniqueName=function(e,t){for(var n=0,r=t.name,i=e.getObjectByName(r);i;)n++,r=t.name+(0!==n?"_"+n:""),i=e.getObjectByName(r);return r},e.prototype._getGoodIdFromSku=function(e){return b(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return[4,this._configuratorApi.getGoodIdFromSku(e,!1)];case 1:return(t=n.sent()).validationResult.success&&t.resultObject?[2,t.resultObject]:[2]}}))}))},e.prototype._getArticle=function(e,t){return b(this,void 0,void 0,(function(){var n,r,i;return v(this,(function(o){switch(o.label){case 0:return this._articleCache.has(e)?[2,this._articleCache.get(e)]:t?[3,2]:[4,this._getGoodIdFromSku(e).catch((function(t){throw"Article with sku "+e+" not found!"}))];case 1:t=o.sent(),o.label=2;case 2:return[4,this._configuratorApi.getArticleQuickSel(t,!1)];case 3:return(r=o.sent()).validationResult.success&&r.resultObject&&(r.resultObject.hasOwnProperty("oArticle")?(i=Array.isArray(r.resultObject.oArticle)?r.resultObject.oArticle[0]:r.resultObject.oArticle,n=this._boFactory.makeWithRawBackendData(u.Article,i)):n=this._boFactory.makeWithRawBackendData(u.Article,r.resultObject)),this._articleCache.set(e,n),[2,n]}}))}))},e.prototype._getSelections=function(e){return b(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return this._selections.length=0,[4,this._configuratorApi.getSelections(!1)];case 1:if(!((t=n.sent()).resultObjects&&t.resultObjects.length>0))throw"No selections found!";return this._selections=this._boFactory.makeBOArrayFromRawBackendDataArray(o.Selection,t.resultObjects),this._selections.forEach((function(t){return t.instanceId=e})),[2]}}))}))},e.prototype._getDecos=function(){return b(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return this._decos.length=0,[4,this._configuratorApi.getDecos(!1)];case 1:if(!((e=t.sent()).resultObjects&&e.resultObjects.length>0))throw"No deconodes found!";return this._decos=this._boFactory.makeBOArrayFromRawBackendDataArray(r.DecoNode,e.resultObjects),[2]}}))}))},e.prototype._linkSelectionsAndDecos=function(){for(var e=this,t=this._selections.length,n=function(t){var n=i._selections[t].artNodeIdDeco,o=i._decos.find((function(e){return e.id===n}));o||(o=new r.DecoNode);var a=i._getVariations().find((function(n){return n.parentId===e._selections[t].artNodeIdDeco}));a&&(o.variation=a),i._selections[t].decoNode=o},i=this,o=0;o<t;o++)n(o)},e.prototype._getVariations=function(){return this._decos.filter((function(e){return e.type===a.DecoNodeType.Variation}))},e.prototype._loadVariations=function(e,t){return b(this,void 0,void 0,(function(){return v(this,(function(n){switch(n.label){case 0:return[4,this._variationHelper.loadPart(e,this._adjustables,!0)];case 1:return n.sent(),[4,this._variationHelper.loadVariation(t,e,this._adjustables,!0)];case 2:return n.sent(),[4,this._variationHelper.loadVariation(t,e,this._addables,!0)];case 3:return n.sent(),[2]}}))}))},e.prototype._getAdjustables=function(){return this._selections.filter((function(e){var t=e.decoNode;return t&&t.gameObjectName&&t.type===a.DecoNodeType.Part&&t.kind===c.DecoNodeKind.Adjustable}))},e.prototype._updatePivot=function(e){var n=(new t.Box3).setFromObject(e),r=new t.Vector3;n.getCenter(r);var i=(new t.Vector3).sub(r).setY(Math.abs(Math.min(n.min.y,0)));e.children.forEach((function(e){e.position.add(i)})),e.updateWorldMatrix(!1,!0)},e.prototype._reset=function(){this._placedAddables.length=0,this._placedAdjustables.length=0,this._adjustables.length=0,this._addables.length=0,this._prepareTheSelections()},e}(),D=function(){function e(){this.answers=[],this.answerClick=new h.EventEmitter}return g([h.Input()],e.prototype,"answers",void 0),g([h.Output()],e.prototype,"answerClick",void 0),e=g([h.Component({selector:"answers",template:'\n <ng-container *ngFor="let answer of answers">\n <div class="answers" (click)="answerClick.emit(answer)">\n <div class="answer" [textContent]="answer.commercialAnswer"></div>\n </div>\n </ng-container>\n ',styles:[":host{position:absolute;top:0;right:0;width:400px;height:100%;background:#fff}:host .answers{cursor:pointer}"]})],e)}(),S=function(){function e(){}return e=g([h.NgModule({imports:[p.CommonModule],declarations:[D],exports:[D]})],e)}(),P=function(){this.children=[],this.expanded=!1},I=function(){function e(){this.selectionViewModels=[],this.selectionClick=new h.EventEmitter}return Object.defineProperty(e.prototype,"selections",{set:function(e){this._prepareSelections(e)},enumerable:!0,configurable:!0}),e.prototype.expandClicked=function(e,t){t.preventDefault(),t.stopImmediatePropagation(),e.expanded=!e.expanded},e.prototype.selectSelection=function(e,t){t.preventDefault(),t.stopImmediatePropagation(),this.selectionClick.next(e)},e.prototype._prepareSelections=function(e){var t,n=this;this.selectionViewModels.length=0,e.forEach((function(e){1===e.presentationLevel?((t=new P).selection=e,n.selectionViewModels.push(t)):e.presentationLevel>1&&t&&t.children.push(e)}))},g([h.Input()],e.prototype,"selections",null),g([h.Output()],e.prototype,"selectionClick",void 0),e=g([h.Component({selector:"selections",template:'\n <ng-container *ngFor="let selectionViewModel of selectionViewModels">\n <div class="selection" (click)="selectSelection(selectionViewModel.selection, $event)">\n <div class="question" [textContent]="selectionViewModel.selection.commercialQuestion"></div>\n <div class="answer" [textContent]="selectionViewModel.selection.answer"></div>\n <div class="collapse-handle" [class.expanded]="selectionViewModel.expanded" \n *ngIf="selectionViewModel.children.length > 0" (click)="expandClicked(selectionViewModel, $event)"></div>\n <div *ngIf="selectionViewModel.children.length > 0 && selectionViewModel.expanded" @showHideChildren>\n <div class="child-selection" *ngFor="let selection of selectionViewModel.children"\n (click)="selectSelection(selection, $event)"\n >\n <div class="question" [textContent]="selection.commercialQuestion"></div>\n <div class="answer" [textContent]="selection.answer"></div>\n </div>\n </div>\n </div>\n </ng-container>\n ',animations:[f.trigger("showHideChildren",[f.state("void",f.style({height:"0"})),f.state("*",f.style({height:"*"})),f.transition("void <=> *",f.animate(200))])],styles:[":host{position:absolute;top:0;right:0;width:300px}:host .selection{position:relative;overflow:hidden;cursor:pointer;font-size:12px;border:1px solid gray}:host .question{font-weight:700}:host .answer{font-size:10px}:host .collapse-handle{position:absolute;top:10px;right:12px;border:solid #000;border-width:0 3px 3px 0;display:inline-block;padding:3px;transform:rotate(45deg);-webkit-transform:rotate(45deg)}:host .collapse-handle.expanded{transform:rotate(-135deg);-webkit-transform:rotate(-135deg)}:host .child-selection{margin-left:10px}"]})],e)}(),T=function(){function e(){}return e=g([h.NgModule({imports:[p.CommonModule],declarations:[I],exports:[I]})],e)}();e.AnswersComponent=D,e.AnswersModule=S,e.Builder=V,e.SelectionsComponent=I,e.SelectionsModule=T,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
17
17
|
//# sourceMappingURL=colijnit-configurator.umd.min.js.map
|