{"version":3,"sources":["../js/Greenlight3dView.js"],"names":["g_oThreeDView","ThreeDView","this","g_bCreateThreeDPreviews","g_oThreeDViews","g_oApprovalThreeDViews","g_oConsumerModelTemplates","prototype","ThreeDViewInitialize","oComboControlDocuments","g_oaComboControls","deepCopyArray","documents","oApprovalIds","oDocumentIds","i","length","push","greenlightDocumentId","addId","j","greenlightApprovalId","GetApproval3DViews","oControl","comboControl_GetControlById","$","hide","selectedDocumentIndex","document","documentType","eDocumentTypes","PDF","pages","trimBox","show","GetConsumerModelTemplates","unbind","click","g_oTextTools","g_bHighlightInProgress","iGreenlightDocumentPageIndex","selectedPageIndex","GetCurrentThreeDViews","documentId","documentPageId","consumerId","html","is","hidePopupWindow","displayPopupWindow","RenderModels","filter","szModelName","ModelFileName","toLowerCase","contains","substring","ModelThumbnailPath","append","g_oProgressBar","addProgressBar","c_szGeneratingPreview","GetConsumerModelFile","id","split","RenderThreeDViews","undefined","iDocumentId","szModelTemplateName","ModelTemplateName","g_oViewer","g_oaCompareDocuments","Approval3DViewId","g_szSessionId","oThreeDViewIndex","findfirst","x","iDocumentIndex","comboControl_SelectOption","ToggleThreeDView","ParentAnnotations","ParentDocument","ParentDocumentPageId","DocumentId","ApprovalId","oDocument","oThreeDView","GetThreeDView","szPrimaryArtworkTexture","GetFileNameWithoutExtension","ModelTemplatePrimaryArtworkFileName","szModelTemplatePath","ModelTemplatePath","oJSON","SessionId","ModelPrimaryTextureName","ModelPath","ajax","type","url","data","JSON","stringify","contentType","dataType","success","response","ToggleThreeDView_CH","failure","removeProgressBar","g_oGreenlightMessages","displayErrorBubble","c_szFailedToLoadParentAnnotations","error","AddThreeDViewAnnotation","ApprovalUserId","ThirdPartyMemberId","CompareDocumentId","NewAnnotation","PrimaryArtWorkTexture","iThreeDViewdocumentId","_oldId","ThreeDViewDocumentId","AddThreeDViewAnnotation_CH","g_oAnnotations","c_szAnnotationFailedtoSave","ApprovalIds","DocumentIds","GetApproval3DViews_CH","Contents","c_szFailedToGetPreviewsCurrentApproval","approvalId","parentDocumentId","parentDocumentPageId","ParentDocumentId","ConsumerId","GetCurrentThreeDViews_CH","c_szFailedToGetPreviewsCurrentDocument","GetConsumerModelTemplates_CH","c_szFailedToGetModelTemplates","Index","AssetId","ThreeDTemplateId","ModelFilePath","ModelFileMimeType","ModelPrimaryArtworkFileName","GreenlightDocumentId","GetConsumerModelFile_CH","c_szFailedToDownloadModelFile","GenerateThreeDView","DocumentPageNumber","PrimaryArtworkImage","ImageRequest","comboControl_ClearOption","Success","GenerateThreeDView_CH","c_szFailedToGeneratePreview","displaySuccessBubble","c_szAnnotationSavedSuccessfully","oAnnotationCanvas","getCanvas","oArtworkCanvas","getLinkedArtworkCanvas","g_szCanvasId","g_iApprovalType","ThreeD","g_oScene","children","Id","splice","g_oAnnotationsMade","responseObj","parse","setupAnnotations","Annotations","ColladaMaterialName","remove","redraw","renderPageAnnotationNumbers","g_oAnnotationHub","server","send","g_iApprovalId","g_oUserDetails","EmailAddress","ex","oTimer","setTimeout","currentTimeoutListRemove","g_bNonAnnotationActionInProgress","initiateAnnotationDraw","currentTimeoutListAdd","iApprovalId","g_oActiveBubbles","closeBubble","g_oCompare","getAnnotationCanvasId","oNewThreeDAnnotations","szColladaMaterialTexture","g_szColladaTexture","g_oAnnotationViewer","g_oArtworkViewer","clearMesh","g_oCompareViewer","g_oCompareAnnotationViewer","oResponse","parseJSON","oThreeDViews","ThreeDViews","oThreeDViewDocuments","Documents","oThreeDViewDocument","documentName","oDocumentAdded","iParentDocumentId","AddToDocumentList","e","oTemplateModelData","oSelectedPage","documentPageNumber","getImageRequest","oNewThreeDViewResponse","ThreeDViewDocument","iParentIndex","comboControl_CreateNewControl","c_szCompareDocument","c_szSelectCompareDocument","c_szDeactivateCompareDocument","g_oApprovalFiles","Setup","c_szInvalidDocument","map","some","y","szThreeDControlRightArrow","g_oSettings","c_iSkinType","attr","TraversePolygonsForGeometries","node","uvx","uvy","threeDdocumentId","szColladaModelTexture","geometry","baryData","ObtainBaryDataFromVertices","faceVertexUvs","faces","daeMaterial","vertexa","vertices","a","vertexb","b","vertexc","c","worldX","worldY","worldZ","z","THREE","Vector3","applyMatrix4","matrixWorld","worldVectorPoint","uvX","uvY","faceVertexUvArray","point","results","result","PtInTriangle","p","p0","p1","p2","x0","y0","x1","y1","x2","y2","x3","y3","b0","b1","b2","b3","oDocumentList","ApprovalThreeDViewId","window"],"mappings":"AAuBA,IAAIA,cAAgB,IAEnB,WACA,aAEA,SAASC,aAGRC,KAAKC,yBAA0B,EAG/BD,KAAKE,eAAiB,GAGtBF,KAAKG,uBAAyB,GAG9BH,KAAKI,0BAA4B,GAMlCL,WAAWM,UAAUC,qBAAuB,WAE3CR,cAAcI,eAAiB,GAC/BJ,cAAcK,uBAAyB,GACvCL,cAAcM,0BAA4B,GAG1C,IAAIG,uBAAyB,GAG5BA,4BADqC,IAAzBC,kBAAkB,GACLC,cAAcD,kBAAkB,GAAGE,WAEnCD,cAAcD,kBAAkB,GAAGE,WAM7D,IAFA,IAAIC,aAAe,GACfC,aAAe,GACVC,EAAI,EAAGA,EAAIN,uBAAuBO,OAAQD,IAAK,CACvDD,aAAaG,KAAKR,uBAAuBM,GAAGG,sBAE5C,IADA,IAAIC,OAAQ,EACHC,EAAI,EAAGA,EAAIP,aAAaG,OAAQI,IACxC,GAAIP,aAAaO,KAAOX,uBAAuBM,GAAGM,qBAAsB,CACvEF,OAAQ,EACR,MAGEA,OACHN,aAAaI,KAAKR,uBAAuBM,GAAGM,sBAO9C,GAHArB,cAAcsB,mBAAmBT,aAAcC,cAG3Cd,cAAcG,wBAAyB,CAC1C,IAAIoB,SAAWC,4BAA4B,4BAA4B,GACvEC,EAAE,oBAAoBC,OAIU,EAA5BH,SAASX,UAAUI,SAAiD,GAAnCO,SAASI,uBAA+BJ,SAASX,UAAUW,SAASI,uBAAuBC,SAASC,eAAiBC,eAAeC,KAAOR,SAASX,UAAUW,SAASI,uBAAuBC,SAASI,MAAM,GAAGC,SACpPR,EAAE,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AKP,GAAGxM,EACRgN,GAAKR,GAAG3C,EAERoD,IAAMJ,GAAKF,KAAOK,GAAKJ,KAAOG,GAAKJ,KAAOG,GAAKF,IAC/CM,KAAOL,GAAKJ,KAAOO,GAAKN,KAAOK,GAAKN,KAAOK,GAAKJ,KAAOO,GACvDE,KAAOJ,GAAKN,KAAOG,GAAKF,KAAOC,GAAKF,KAAOO,GAAKN,KAAOO,GACvDG,KAAOT,GAAKF,KAAOK,GAAKJ,KAAOG,GAAKJ,KAAOG,GAAKF,KAAOO,GAE3D,OAAS,EAALC,IAAe,EAALC,IAAe,EAALC,GAChB,CAACF,GAAIC,GAAIC,IAET,IAOT/R,WAAWM,UAAUgN,kBAAoB,SAAU0E,cAAe5M,UAAWiI,mBAG5E,IAFA,IAAIS,aAAe,EAEVhN,EAAI,EAAGA,EAAIkR,cAAcjR,OAAQD,IACzC,GAAIkR,cAAclR,GAAGG,uBAAyBoM,kBAAmB,CAChES,aAAehN,EACf,MAYF,OARIgN,eAAiBkE,cAAcjR,OAAS,EAE3CiR,cAAchR,KAAKoE,WAInB4M,cAAcxH,OAAOsD,aAAe,EAAG,EAAG1I,WAEpC0I,cAMR9N,WAAWM,UAAUgF,cAAgB,SAAU2M,sBAC9C,OAAOzQ,EAAEkD,UAAU3E,cAAcK,uBAAwB,SAAUuE,GAClE,OAAOA,EAAEJ,mBAAqB0N,wBAOhCC,OAAOlS,WAAaA,WAz4BrB","file":"Greenlight3dView-f6d87157b1.js","sourcesContent":["/*\r\n * Copyright (c) 2018 SGS Europe. All rights reserved.\r\n *\r\n * This program is the CONFIDENTIAL and PROPRIETARY property of 2018 SGS Europe.\r\n * Any unauthorised use, reproduction, or transfer of this program is strictly\r\n * prohibited.\r\n *\r\n * File Name: Greenlight3dView.js\r\n *\r\n * Description: JavaScript code for the 3D view module.\r\n *\r\n * History: 24-AUG-18 S Norman Initial implementation.\r\n * 16-JAN-19 S Norman Make sure to use the correct canvas when in compare mode and saving an annotation.\r\n * Now clears the annotations from the scene after setting up the annotations so that they can be redrawn in the correct positions. (DR212)\r\n * Clear active bubble notifications when loading or generating a 3D preview.\r\n * 18-JAN-19 S Norman Added a length check when clearing the compare Combo Control as there may be no compare docs.\r\n * 21-JAN-19 S Norman Made it possible for supporting document to create 3d views. Added extra initialization code, MultiView can now just call this function when switching approvals.\r\n * 22-JAN-19 S Norman Fixed an issue where a try catch would not work on IE or Edge. Added the on click event functionality initialisation to the ThreeDViewInitialize method.\r\n * 24-JAN-19 S Norman Fixed an issue where after generating a 3D preview, MultiView switching would cause the new 3D preview document to go missing.\r\n * 25-JAN-19 S Norman Made the file names for the models and 3D previews shortened when they are too long for rendering them within the pop-up.\r\n * 29-JAN-19 S Norman Removed whitespace from the thumbnail path.\r\n */\r\n\r\nvar g_oThreeDView = {};\r\n\r\n(function () {\r\n\t\"use strict\";\r\n\r\n\tfunction ThreeDView() {\r\n\r\n\t\t// Instance setting flag sent from dragonfly.\r\n\t\tthis.g_bCreateThreeDPreviews = false;\r\n\r\n\t\t// List of 3dViews for the current document.\r\n\t\tthis.g_oThreeDViews = {};\r\n\r\n\t\t// List of 3DViews on the approval.\r\n\t\tthis.g_oApprovalThreeDViews = {};\r\n\r\n\t\t// List of models for the current instance.\r\n\t\tthis.g_oConsumerModelTemplates = {};\r\n\t}\r\n\r\n /*\r\n\t* Initializes the 3D View module by loading the current approvals 3D views and setting up on clicks for the 3D Tool.\r\n\t*/\r\n\tThreeDView.prototype.ThreeDViewInitialize = function () {\r\n\t\t// Reset any objects, used when switching from multiview.js\r\n\t\tg_oThreeDView.g_oThreeDViews = {};\r\n\t\tg_oThreeDView.g_oApprovalThreeDViews = {};\r\n\t\tg_oThreeDView.g_oConsumerModelTemplates = {};\r\n\r\n\t\t// Load 3D views for the current approval for global usage, will populate g_oApprovalThreeDViews.\r\n\t\tvar oComboControlDocuments = [];\r\n\t\t// If we have at least 1 compare document\r\n\t\tif (!(typeof g_oaComboControls[1] === \"undefined\")) {\r\n\t\t\toComboControlDocuments = deepCopyArray(g_oaComboControls[1].documents);\r\n\t\t} else {\r\n\t\t\toComboControlDocuments = deepCopyArray(g_oaComboControls[0].documents);\r\n\t\t}\r\n\r\n\t\t// Get a unique list of approval Ids\r\n\t\tvar oApprovalIds = [];\r\n\t\tvar oDocumentIds = [];\r\n\t\tfor (var i = 0; i < oComboControlDocuments.length; i++) {\r\n\t\t\toDocumentIds.push(oComboControlDocuments[i].greenlightDocumentId);\r\n\t\t\tvar addId = true;\r\n\t\t\tfor (var j = 0; j < oApprovalIds.length; j++) {\r\n\t\t\t\tif (oApprovalIds[j] === oComboControlDocuments[i].greenlightApprovalId) {\r\n\t\t\t\t\taddId = false;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (addId) { // Add only unique values\r\n\t\t\t\toApprovalIds.push(oComboControlDocuments[i].greenlightApprovalId);\r\n\t\t\t}\r\n\t\t}\r\n\t\t// For each approval id get the 3D views and add to g_oApprovalThreeDViews.\r\n\t\tg_oThreeDView.GetApproval3DViews(oApprovalIds, oDocumentIds);\r\n\r\n\t\t// If instance setting is true and its not read only, show the ThreeD Viewer icon\r\n\t\tif (g_oThreeDView.g_bCreateThreeDPreviews) {\r\n\t\t\tvar oControl = comboControl_GetControlById(\"approvalNameComboControl\", false);\r\n\t\t\t$('#btnThreeDViewer').hide();\r\n\r\n\t\t\t// Ensure we have a valid document selected before continue. \r\n\t\t\t// If the document is a pdf and the first page which we are on has a trim-box and not in read only mode\r\n\t\t\tif (oControl.documents.length > 0 && oControl.selectedDocumentIndex != -1 && oControl.documents[oControl.selectedDocumentIndex].document.documentType === eDocumentTypes.PDF && oControl.documents[oControl.selectedDocumentIndex].document.pages[0].trimBox) {\r\n\t\t\t\t$('#btnThreeDViewer').show();\r\n\t\t\t}\r\n\r\n\t\t\t// Populate model templates from instance\r\n\t\t\tg_oThreeDView.GetConsumerModelTemplates();\r\n\t\t\t$(\"#btnThreeDViewer\").unbind(\"click\");\r\n\t\t\t// btnThreeDViewer on click to show ThreeDViews and models for the current page.\r\n\t\t\t$(\"#btnThreeDViewer\").click(function () {\r\n\r\n\t\t\t\t// If we have an active text highlight, prevent the drop down.\r\n\t\t\t\tif (g_oTextTools.g_bHighlightInProgress) {\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// If the current document is a pdf.\r\n\t\t\t\tif (g_oaComboControls[0].documents[g_oaComboControls[0].selectedDocumentIndex].document.documentType === 1) {\r\n\t\t\t\t\tvar iGreenlightDocumentPageIndex = (g_oaComboControls[0].selectedPageIndex === -1) ? 0 : g_oaComboControls[0].selectedPageIndex;\r\n\t\t\t\t\t\tg_oThreeDView.GetCurrentThreeDViews(\r\n\t\t\t\t\t\t\tg_oaComboControls[0].documents[g_oaComboControls[0].selectedDocumentIndex].greenlightApprovalId,\r\n\t\t\t\t\t\t\tg_oaComboControls[0].documents[g_oaComboControls[0].selectedDocumentIndex].document.documentId,\r\n\t\t\t\t\t\t\tg_oaComboControls[0].documents[g_oaComboControls[0].selectedDocumentIndex].document.pages[iGreenlightDocumentPageIndex].documentPageId,\r\n\t\t\t\t\t\t\tg_oaComboControls[0].documents[g_oaComboControls[0].selectedDocumentIndex].document.consumerId\r\n\t\t\t\t\t);\r\n\t\t\t\t\tg_oThreeDView.GetConsumerModelTemplates();\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\t$('#tblModelImagePlaceHolders').html('');\r\n\t\t\t\t\t$('#tblThreeDViewImagePlaceHolders').html('');\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif ($('#divModalOverlay').is(\":visible\")) {\r\n\t\t\t\t\thidePopupWindow(\"divModalOverlay\");\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\tdisplayPopupWindow(\"divModalOverlay\", 80, 75);\r\n\t\t\t\t}\r\n\r\n\t\t\t});\r\n\t\t}\r\n\t\telse {\r\n\t\t\t$('#btnThreeDViewer').hide();\r\n\t\t}\r\n\t};\r\n\r\n /*\r\n\t* Renders the consumers models to the pop-up window and sets up the on clicks.\r\n\t*/\r\n\tThreeDView.prototype.RenderModels = function (filter) {\r\n\t\t$('#tblModelImagePlaceHolders').html('');\r\n\t\tif (!g_oThreeDView.g_oConsumerModelTemplates || !g_oThreeDView.g_oConsumerModelTemplates.length) {\r\n\t\t\t$('#divModelBodyModels').hide();\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t$('#divModelBodyModels').show();\r\n\t\tvar szModelName = \"\";\r\n\t\tvar html = \"\";\r\n\t\t// Generate models html\r\n\t\tfor (var i = 0; i < g_oThreeDView.g_oConsumerModelTemplates.length; i++) {\r\n\t\t\tszModelName = g_oThreeDView.g_oConsumerModelTemplates[i].ModelFileName;\t\t\t\r\n\t\t\tif (!filter || filter === \"\" || szModelName.toLowerCase().contains(filter)) {\r\n\t\t\t\tszModelName = szModelName.length > 15 ? szModelName.substring(0, 15) + \"...\" : szModelName;\r\n\t\t\t\thtml += \"\";\r\n\t\t\t\thtml += \"\";\r\n\t\t\t\thtml += \"\" + szModelName + \"\";\r\n\t\t\t\thtml += \"\";\r\n\t\t\t}\r\n\t\t}\r\n\t\thtml += \"\";\r\n\t\t$('#tblModelImagePlaceHolders').append(html);\r\n\r\n\t\t// Setup on clicks for models\r\n\t\tfor (var j = 0; j < g_oThreeDView.g_oConsumerModelTemplates.length; j++) {\r\n\t\t\tszModelName = g_oThreeDView.g_oConsumerModelTemplates[j].ModelFileName;\r\n\t\t\tif (!filter || filter === \"\" || szModelName.toLowerCase().contains(filter)) {\r\n\t\t\t\t$(\"#rowThreeDViewer_NewModel_\" + j).unbind(\"click\");\r\n\t\t\t\t$(\"#rowThreeDViewer_NewModel_\" + j).click(function () {\r\n\t\t\t\t\thidePopupWindow(\"divModalOverlay\");\r\n\t\t\t\t\tg_oProgressBar.addProgressBar(g_oThreeDView.c_szGeneratingPreview, true);\r\n\t\t\t\t\tg_oThreeDView.GetConsumerModelFile(this.id.split('_')[2]);\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n /*\r\n\t* Renders the 3D Previews to the pop-up window and sets up the on clicks.\r\n\t*/\r\n\tThreeDView.prototype.RenderThreeDViews = function (filter) {\r\n\t\t$('#tblThreeDViewImagePlaceHolders').html('');\r\n\t\tif (g_oThreeDView.g_oThreeDViews !== undefined && g_oThreeDView.g_oThreeDViews.length > 0) {\r\n\t\t\t$('#divModelBodyThreeDViews').show();\r\n\t\t\tvar iDocumentId = -1;\r\n\t\t\tvar szModelTemplateName = \"\";\r\n\t\t\tvar szThreeDThumbnailPath = \"\";\r\n\t\t\tvar html = \"\";\r\n\t\t\t// Generate ThreeDView HTML\r\n\t\t\tfor (var i = 0; i < g_oThreeDView.g_oThreeDViews.length; i++) {\r\n\t\t\t\tszModelTemplateName = g_oThreeDView.g_oThreeDViews[i].ModelTemplateName;\t\t\t\t\r\n\t\t\t\tif (!filter || filter === \"\" || szModelTemplateName.toLowerCase().contains(filter)) {\r\n\t\t\t\t\tfor (var j = 0; j < g_oViewer.g_oaCompareDocuments.length; j++) {\r\n\t\t\t\t\t\tif (g_oViewer.g_oaCompareDocuments[j].document.Approval3DViewId === g_oThreeDView.g_oThreeDViews[i].Approval3DViewId) {\r\n\t\t\t\t\t\t\tiDocumentId = g_oViewer.g_oaCompareDocuments[j].greenlightDocumentId;\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tszModelTemplateName = g_oThreeDView.g_oThreeDViews[i].ModelTemplateName.length > 15 ? g_oThreeDView.g_oThreeDViews[i].ModelTemplateName.substring(0, 15) + \"...\" : g_oThreeDView.g_oThreeDViews[i].ModelTemplateName;\t\t\t\t\t\r\n\t\t\t\t\tszThreeDThumbnailPath = \"/ViewImage/GetImage?threeDThumbnailPath=\" + g_oThreeDView.g_oThreeDViews[i].ModelThumbnailPath + \"&documentId=\" + iDocumentId + \"&pageNumber=0&sessionId=\" + g_szSessionId + \"&thumb=1&fileName=\" + iDocumentId + \"&fileExtension=jpg\";\r\n\t\t\t\t\thtml += \"\";\r\n\t\t\t\t\thtml += \"\";\r\n\t\t\t\t\thtml += \"\" + szModelTemplateName + \"\";\r\n\t\t\t\t\thtml += \"\";\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\thtml += \"\";\r\n\t\t\t//Append row\r\n\t\t\t$('#tblThreeDViewImagePlaceHolders > tbody:last-child').append(html);\r\n\r\n\t\t\t// Setup on clicks\r\n\t\t\tfor (i = 0; i < g_oThreeDView.g_oThreeDViews.length; i++) {\r\n\t\t\t\tszModelTemplateName = g_oThreeDView.g_oThreeDViews[i].ModelTemplateName;\r\n\t\t\t\tif (!filter || filter === \"\" || szModelTemplateName.toLowerCase().contains(filter)) {\r\n\t\t\t\t\t$(\"#rowThreeDViewer_Existing_\" + i).unbind(\"click\");\r\n\t\t\t\t\t$(\"#rowThreeDViewer_Existing_\" + i).click(function () {\r\n\t\t\t\t\t\tvar oThreeDViewIndex = this.id.split('_')[2];\r\n\t\t\t\t\t\tvar iDocumentId = $.findfirst(g_oaComboControls[0].documents, function (x) {\r\n\t\t\t\t\t\t\t\t\t\t\t\treturn x.document.Approval3DViewId === g_oThreeDView.g_oThreeDViews[oThreeDViewIndex].Approval3DViewId;\r\n\t\t\t\t\t\t\t\t\t\t\t}).greenlightDocumentId;\r\n\t\t\t\t\t\tvar iDocumentIndex = 0;\r\n\r\n\t\t\t\t\t\tfor (var i = 0; i < g_oaComboControls[0].documents.length; i++) {\r\n\t\t\t\t\t\t\tif (g_oaComboControls[0].documents[i].greenlightDocumentId === iDocumentId) {\r\n\t\t\t\t\t\t\t\tiDocumentIndex = i;\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t// Change selected item.\r\n\t\t\t\t\t\tcomboControl_SelectOption(0, iDocumentIndex, -1, true);\r\n\t\t\t\t\t\thidePopupWindow(\"divModalOverlay\");\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\t$('#divModelBodyThreeDViews').hide();\r\n\t\t}\r\n\t};\r\n\r\n /*\r\n\t* - - - A J A X R E Q U E S T S- - -\r\n\t*/\r\n\r\n /*\r\n\t* Called when switching to a 3D preview to load the parents annotations onto the 3D artwork.\r\n\t*/\r\n\tThreeDView.prototype.ToggleThreeDView = function (ParentAnnotations, ParentDocument, ParentDocumentPageId, DocumentId, ApprovalId) {\r\n\t\tvar oDocument = $.findfirst(g_oViewer.g_oaCompareDocuments, function (x) {\n\t\t\t\t\t\t\treturn x.greenlightDocumentId === DocumentId;\r\n\t\t\t\t\t\t});\n\t\tvar oThreeDView = g_oThreeDView.GetThreeDView(oDocument.document.Approval3DViewId);\r\n\t\tvar szPrimaryArtworkTexture = GetFileNameWithoutExtension(oThreeDView.ModelTemplatePrimaryArtworkFileName);\r\n\t\tvar szModelTemplatePath = oThreeDView.ModelTemplatePath + '\\\\' + oThreeDView.ModelTemplateName;\r\n\t\tvar oJSON = {\r\n\t\t\tSessionId: g_szSessionId,\r\n\t\t\tParentAnnotations: ParentAnnotations,\r\n\t\t\tParentDocument: ParentDocument,\r\n\t\t\tParentDocumentPageId: ParentDocumentPageId,\r\n\t\t\tDocumentId: DocumentId,\r\n\t\t\tApprovalId: ApprovalId,\r\n\t\t\tModelPrimaryTextureName: szPrimaryArtworkTexture,\r\n\t\t\tModelPath: szModelTemplatePath\r\n\t\t};\r\n\t\t$.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: \"api/Greenlight3dView/ToggleThreeDView\",\r\n\t\t\tdata: JSON.stringify(oJSON),\r\n\t\t\tcontentType: \"application/json; charset=utf-8\",\r\n\t\t\tdataType: \"json\",\r\n\t\t\tsuccess: function (response) {\r\n\t\t\t\tg_oThreeDView.ToggleThreeDView_CH(response, ApprovalId);\r\n\t\t\t},\r\n\t\t\tfailure: function (response) {\r\n\t\t\t\tg_oProgressBar.removeProgressBar();\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oThreeDView.c_szFailedToLoadParentAnnotations);\r\n\t\t\t},\r\n\t\t\terror: function (response) {\r\n\t\t\t\t// Remove the progress bar.\r\n\t\t\t\tg_oProgressBar.removeProgressBar();\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oThreeDView.c_szFailedToLoadParentAnnotations);\r\n\t\t\t}\r\n\t\t});\r\n\t};\r\n\r\n /*\r\n\t* Called when adding an annotation to a 3D preview. The annotations gets added to the parent as a post-it.\r\n\t*/\r\n\tThreeDView.prototype.AddThreeDViewAnnotation = function (ApprovalId, ApprovalUserId, SessionId, ThirdPartyMemberId, CompareDocumentId, NewAnnotation, ParentDocument, ParentDocumentPageId, ModelTemplatePath, PrimaryArtWorkTexture, iThreeDViewdocumentId, _oldId) {\r\n\t\t// Build up the annotation string.\r\n\t\tvar oJSON = {\r\n\t\t\tSessionId: SessionId,\r\n\t\t\tApprovalId: ApprovalId,\r\n\t\t\tApprovalUserId: ApprovalUserId,\r\n\t\t\tThirdPartyMemberId: ThirdPartyMemberId,\r\n\t\t\tNewAnnotation: NewAnnotation,\r\n\t\t\tParentDocument: ParentDocument,\r\n\t\t\tParentDocumentPageId: ParentDocumentPageId,\r\n\t\t\tModelPath: ModelTemplatePath,\r\n\t\t\tModelPrimaryTextureName: PrimaryArtWorkTexture,\r\n\t\t\tCompareDocumentId: CompareDocumentId,\r\n\t\t\tThreeDViewDocumentId: iThreeDViewdocumentId\r\n\t\t};\r\n\r\n\t\t$.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: \"api/Greenlight3dView/AddThreeDViewAnnotation\",\r\n\t\t\tdata: JSON.stringify(oJSON),\r\n\t\t\tcontentType: \"application/json; charset=utf-8\",\r\n\t\t\tdataType: \"json\",\r\n\t\t\tsuccess: function (response) {\r\n\t\t\t\tg_oThreeDView.AddThreeDViewAnnotation_CH(response, _oldId);\r\n\t\t\t},\r\n\t\t\tfailure: function (response) {\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oAnnotations.c_szAnnotationFailedtoSave);\r\n\t\t\t},\r\n\t\t\terror: function (response) {\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oAnnotations.c_szAnnotationFailedtoSave);\r\n\t\t\t}\r\n\t\t});\r\n\t};\r\n\r\n /*\r\n\t* Gets the 3D views for an approval.\r\n\t*/\r\n\tThreeDView.prototype.GetApproval3DViews = function (ApprovalIds, DocumentIds) {\r\n\t\tvar oJSON = {\r\n\t\t\tSessionId: g_szSessionId,\r\n\t\t\tApprovalIds: ApprovalIds,\r\n\t\t\tDocumentIds: DocumentIds\r\n\t\t};\r\n\t\t$.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: \"api/Greenlight3dView/GetApproval3DViews\",\r\n\t\t\tdata: JSON.stringify(oJSON),\r\n\t\t\tcontentType: \"application/json; charset=utf-8\",\r\n\t\t\tdataType: \"json\",\r\n\t\t\tsuccess: function (response) {\r\n\t\t\t\tg_oThreeDView.GetApproval3DViews_CH(response.Contents);\r\n\t\t\t},\r\n\t\t\tfailure: function (response) {\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oThreeDView.c_szFailedToGetPreviewsCurrentApproval);\r\n\t\t\t},\r\n\t\t\terror: function (response) {\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oThreeDView.c_szFailedToGetPreviewsCurrentApproval);\r\n\t\t\t}\r\n\t\t});\r\n\t};\r\n\r\n /*\r\n\t* Gets the 3D views for a document.\r\n\t*/\r\n\tThreeDView.prototype.GetCurrentThreeDViews = function (approvalId, parentDocumentId, parentDocumentPageId, consumerId) {\r\n\t\tvar oJSON = {\r\n\t\t\tApprovalId: approvalId,\r\n\t\t\tParentDocumentId: parentDocumentId,\r\n\t\t\tParentDocumentPageId: parentDocumentPageId,\r\n\t\t\tConsumerId: consumerId,\r\n\t\t\tSessionId: g_szSessionId\r\n\t\t};\r\n\t\t$.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: \"api/Greenlight3dView/GetCurrentThreeDViews\",\r\n\t\t\tdata: JSON.stringify(oJSON),\r\n\t\t\tcontentType: \"application/json; charset=utf-8\",\r\n\t\t\tdataType: \"json\",\r\n\t\t\tsuccess: function (response) {\r\n\t\t\t\tg_oThreeDView.GetCurrentThreeDViews_CH(response.Contents);\r\n\t\t\t},\r\n\t\t\tfailure: function (response) {\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oThreeDView.c_szFailedToGetPreviewsCurrentDocument);\r\n\t\t\t},\r\n\t\t\terror: function (response) {\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oThreeDView.c_szFailedToGetPreviewsCurrentDocument);\r\n\t\t\t}\r\n\t\t});\r\n\t};\r\n\r\n /*\r\n\t* Gets the consumer model template metadata from the consumer.\r\n\t*/\r\n\tThreeDView.prototype.GetConsumerModelTemplates = function () {\r\n\t\tvar oJSON = {\r\n\t\t\tSessionId: g_szSessionId\r\n\t\t};\r\n\r\n\t\t$.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: \"api/Greenlight3dView/GetConsumerModelTemplates\",\r\n\t\t\tdata: JSON.stringify(oJSON),\r\n\t\t\tcontentType: \"application/json; charset=utf-8\",\r\n\t\t\tdataType: \"json\",\r\n\t\t\tsuccess: function (response) {\r\n\t\t\t\tg_oThreeDView.GetConsumerModelTemplates_CH(response.Contents);\r\n\t\t\t},\r\n\t\t\tfailure: function (response) {\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oThreeDView.c_szFailedToGetModelTemplates);\r\n\t\t\t},\r\n\t\t\terror: function (response) {\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oThreeDView.c_szFailedToGetModelTemplates);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t};\r\n\r\n /*\r\n\t* Gets a 3D model file from the consumer and puts it in the cache.\r\n\t*/\r\n\tThreeDView.prototype.GetConsumerModelFile = function (Index) {\r\n\t\tvar oJSON = {\r\n\t\t\tSessionId: g_szSessionId,\r\n\t\t\tAssetId: g_oThreeDView.g_oConsumerModelTemplates[Index].AssetId,\r\n\t\t\tThreeDTemplateId: g_oThreeDView.g_oConsumerModelTemplates[Index].ThreeDTemplateId,\r\n\t\t\tModelFilePath: g_oThreeDView.g_oConsumerModelTemplates[Index].ModelFilePath,\r\n\t\t\tModelFileMimeType: g_oThreeDView.g_oConsumerModelTemplates[Index].ModelFileMimeType,\r\n\t\t\tModelFileName: g_oThreeDView.g_oConsumerModelTemplates[Index].ModelFileName,\r\n\t\t\tModelPrimaryArtworkFileName: g_oThreeDView.g_oConsumerModelTemplates[Index].ModelPrimaryArtworkFileName,\r\n\t\t\tGreenlightDocumentId: g_oaComboControls[0].documents[g_oaComboControls[0].selectedDocumentIndex].greenlightDocumentId\r\n\t\t};\r\n\r\n\t\t$.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: \"api/Greenlight3dView/GetConsumerModelFile\",\r\n\t\t\tdata: JSON.stringify(oJSON),\r\n\t\t\tcontentType: \"application/json; charset=utf-8\",\r\n\t\t\tdataType: \"json\",\r\n\t\t\tsuccess: function (response) {\r\n\t\t\t\tg_oThreeDView.GetConsumerModelFile_CH(response.Contents);\r\n\t\t\t},\r\n\t\t\tfailure: function (response) {\r\n\t\t\t\t// Remove the progress bar.\r\n\t\t\t\tg_oProgressBar.removeProgressBar();\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oThreeDView.c_szFailedToDownloadModelFile);\r\n\t\t\t},\r\n\t\t\terror: function (response) {\r\n\t\t\t\t// Remove the progress bar.\r\n\t\t\t\tg_oProgressBar.removeProgressBar();\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oThreeDView.c_szFailedToDownloadModelFile);\r\n\t\t\t}\r\n\t\t});\r\n\t};\r\n\r\n /*\r\n\t* Manipulates the cached 3D model template and replaces the primary artwork texture with the trim of a pdf document.\r\n\t*/\r\n\tThreeDView.prototype.GenerateThreeDView = function (ConsumerId, ApprovalId, ParentDocumentId, ParentDocumentPageId, DocumentPageNumber, ModelTemplatePath, PrimaryArtworkImage, ImageRequest) {\r\n\t\tif (g_oaComboControls.length > 1) {\r\n\t\t\t// Deactivate compare mode if we are in compare mode.\r\n\t\t\tcomboControl_ClearOption(1, true);\r\n\t\t}\r\n\r\n\t\tvar oJSON = {\r\n\t\t\tConsumerId: ConsumerId,\r\n\t\t\tApprovalId: ApprovalId,\r\n\t\t\tParentDocumentId: ParentDocumentId,\r\n\t\t\tParentDocumentPageId: ParentDocumentPageId,\r\n\t\t\tDocumentPageNumber: DocumentPageNumber,\r\n\t\t\tModelPath: ModelTemplatePath,\r\n\t\t\tPrimaryArtworkImage: PrimaryArtworkImage,\r\n\t\t\tImageRequest: ImageRequest\r\n\t\t};\r\n\r\n\t\t$.ajax({\r\n\t\t\ttype: \"POST\",\r\n\t\t\turl: \"api/Greenlight3dView/GenerateThreeDView\",\r\n\t\t\tdata: JSON.stringify(oJSON),\r\n\t\t\tcontentType: \"application/json; charset=utf-8\",\r\n\t\t\tdataType: \"json\",\r\n\t\t\tsuccess: function (response) {\r\n\t\t\t\t// If successful.\r\n\t\t\t\tif (response.Success) {\r\n\t\t\t\t\tg_oThreeDView.GenerateThreeDView_CH(response.Contents);\r\n\t\t\t\t}\r\n\t\t\t\t// If unsuccessful.\r\n\t\t\t\telse {\r\n\t\t\t\t\t// Remove the progress bar.\r\n\t\t\t\t\tg_oProgressBar.removeProgressBar();\r\n\t\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oThreeDView.c_szFailedToGeneratePreview);\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tfailure: function (response) {\r\n\t\t\t\t// Remove the progress bar.\r\n\t\t\t\tg_oProgressBar.removeProgressBar();\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oThreeDView.c_szFailedToGeneratePreview);\r\n\t\t\t},\r\n\t\t\terror: function (response) {\r\n\t\t\t\t// Remove the progress bar.\r\n\t\t\t\tg_oProgressBar.removeProgressBar();\r\n\t\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oThreeDView.c_szFailedToGeneratePreview);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t};\r\n\r\n /*\r\n\t* - - - C A L L B A C K H A N D L E R S - - -\r\n\t*/\r\n\r\n /*\r\n\t* Callback when adding a annotation to a 3D preview, sets up and renders the annotation.\r\n\t*/\r\n\tThreeDView.prototype.AddThreeDViewAnnotation_CH = function (response, _oldId) {\r\n\t\t// Display the success bubble.\r\n\t\tg_oGreenlightMessages.displaySuccessBubble(g_oAnnotations.c_szAnnotationSavedSuccessfully);\r\n\r\n\t\t// Determine the canvas to use.\r\n\t\tvar oAnnotationCanvas = g_oViewer.getCanvas(\"AnnotationViewer\");\r\n\t\tvar oArtworkCanvas = g_oViewer.getLinkedArtworkCanvas(oAnnotationCanvas.g_szCanvasId);\r\n\r\n\t\t// Splice the old ID out the array, it will be re-rendered later.\r\n\t\tif (g_oAnnotations.g_iApprovalType === eDocumentTypes.ThreeD) {\r\n\t\t\tfor (var i = (oArtworkCanvas.g_oScene.children.length - 1); i > -1; i--) {\r\n\t\t\t\t// Remove both the Annotation object & the Annotation Number from the 3D scene array.\r\n\t\t\t\tif (oArtworkCanvas.g_oScene.children[i].Id == _oldId || oArtworkCanvas.g_oScene.children[i].Id === \"annNo_\" + _oldId) {\r\n\t\t\t\t\toArtworkCanvas.g_oScene.children.splice(i, 1);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tg_oAnnotations.g_oAnnotationsMade = [];\r\n\r\n\t\tvar responseObj = JSON.parse(response.Contents);\r\n\r\n\t\t// Setup annotations sending in the collada texture.\r\n\t\tg_oAnnotations.setupAnnotations(responseObj.Annotations, oArtworkCanvas, oAnnotationCanvas, responseObj.ColladaMaterialName);\r\n\r\n\t\t// If the annotation save was called on the main annotation only\r\n\t\t$(\".annotation\").remove();\r\n\r\n\t\toAnnotationCanvas.redraw(false);\r\n\r\n\t\t// Recalculate the page annotation numbers.\r\n\t\tg_oAnnotations.renderPageAnnotationNumbers();\r\n\r\n\t\t// Attempt to send annotations to signalR.\r\n\t\ttry {\r\n\t\t\tg_oAnnotations.g_oAnnotationHub.server.send(g_oAnnotations.g_iApprovalId, g_oUserDetails.EmailAddress);\r\n\t\t} catch(ex) {}\r\n\r\n\t\t// Rebind the draw functions once annotation saves.\r\n\t\t// Use setTimeout to make sure we ONLY rebind the canvas functions,\r\n\t\t// once they have finished, as they will execute twice!.\r\n\t\tvar oTimer = setTimeout(function () {\r\n\t\t\tg_oAnnotations.currentTimeoutListRemove(oTimer);\r\n\r\n\t\t\t// Only reset the annotation mouse events if there are no other actions in progress (i.e. Pan or Marquee Zoom).\r\n\t\t\tif (!g_oAnnotations.g_bNonAnnotationActionInProgress) {\r\n\t\t\t\tg_oAnnotations.initiateAnnotationDraw(0, oArtworkCanvas, oAnnotationCanvas);\r\n\t\t\t}\r\n\t\t}, 1000);\r\n\r\n\t\tg_oAnnotations.currentTimeoutListAdd(oTimer);\r\n\t};\r\n\r\n /*\r\n\t* Callback when switching to a 3D preview, sets up the annotations sending in the collada texture.\r\n\t*/\r\n\tThreeDView.prototype.ToggleThreeDView_CH = function (response, iApprovalId) {\r\n\t\t// Close any active bubbles\r\n\t\tfor (var i = 0; i < g_oActiveBubbles.length; i++) {\r\n\t\t\tg_oGreenlightMessages.closeBubble(g_oActiveBubbles[i].id, true, true);\r\n\t\t}\r\n\t\tvar responseObj = JSON.parse(response.Contents);\r\n\r\n\t\t// Determine the canvas to used for rendering based on the annotation toggle.\r\n\t\tvar oAnnotationCanvas = g_oViewer.getCanvas(g_oCompare.getAnnotationCanvasId());\r\n\t\tvar oArtworkCanvas = g_oViewer.getLinkedArtworkCanvas(oAnnotationCanvas.g_szCanvasId);\r\n\r\n\t\tvar oNewThreeDAnnotations = responseObj.Annotations;\r\n\t\tvar szColladaMaterialTexture = responseObj.ColladaMaterialName;\r\n\r\n\t\tg_oAnnotations.g_szColladaTexture = szColladaMaterialTexture;\r\n\r\n\t\tvar oControl = comboControl_GetControlById(\"approvalNameComboControl\", false);\r\n\t\t// Ensure these annotations are in sync with the current document\r\n\t\tif (oNewThreeDAnnotations.length > 0) {\r\n\t\t\t// Refresh the g_oAnnotations object with the new details.\r\n\t\t\tg_oAnnotations.g_oAnnotationViewer = g_oViewer.g_oAnnotationViewer;\r\n\t\t\tg_oAnnotations.g_oArtworkViewer = g_oViewer.g_oArtworkViewer;\r\n\t\t\tg_oAnnotations.g_iApprovalType = g_oaComboControls[0].documents[g_oaComboControls[0].selectedDocumentIndex].document.documentType;\r\n\t\t\tg_oAnnotations.g_iApprovalId = iApprovalId;\r\n\r\n\t\t\t// Clear out the annotations.\r\n\t\t\tg_oAnnotations.g_oAnnotationsMade = [];\r\n\r\n\t\t\t// Setup the annotations.\r\n\t\t\tg_oAnnotations.setupAnnotations(oNewThreeDAnnotations, oArtworkCanvas, oAnnotationCanvas, szColladaMaterialTexture);\r\n\r\n\t\t\t// Clear 3D annotation mesh.\r\n\t\t\tg_oAnnotations.clearMesh(g_oCompare.g_oArtworkViewer, g_oCompare.g_oAnnotationViewer);\r\n\t\t\tg_oAnnotations.clearMesh(g_oCompare.g_oCompareViewer, g_oCompare.g_oCompareAnnotationViewer);\r\n\r\n\t\t\t// Remove the progress bar.\r\n\t\t\tg_oProgressBar.removeProgressBar();\r\n\t\t}\r\n\t};\r\n\r\n /*\r\n\t* Callback when getting the 3D views for an approval, populates g_oApprovalThreeDViews.\r\n\t*/\r\n\tThreeDView.prototype.GetApproval3DViews_CH = function (response) {\r\n\r\n\t\t// Extract the response and 3D information.\r\n\t\tvar oResponse = $.parseJSON(response);\r\n\t\tvar oThreeDViews = oResponse.ThreeDViews;\r\n\t\tvar oThreeDViewDocuments = oResponse.Documents;\r\n\r\n\t\t// If we do not have anything in the 3D views.\r\n\t\tif (!(g_oThreeDView.g_oApprovalThreeDViews.length > 0)) {\r\n\r\n\t\t\t// Populate Approval Three D View global.\r\n\t\t\tg_oThreeDView.g_oApprovalThreeDViews = oThreeDViews;\r\n\t\t}\r\n\t\t// If we already have 3D views.\r\n\t\telse {\r\n\r\n\t\t\t// If it doesn't exist in the list then add it.\r\n\t\t\tfor (var i = 0; i < oThreeDViews.length; i++) {\r\n\r\n\t\t\t\t// Try to get the 3D view.\r\n\t\t\t\tvar oThreeDView = g_oThreeDView.GetThreeDView(oThreeDViews[i].Approval3DViewId);\r\n\r\n\t\t\t\t// If we could not get the 3D view.\r\n\t\t\t\tif (!oThreeDView) {\r\n\r\n\t\t\t\t\t// Add it to the list.\r\n\t\t\t\t\tg_oThreeDView.g_oApprovalThreeDViews.push(oThreeDViews[i]);\r\n\r\n\t\t\t\t\t// Get the 3D view.\r\n\t\t\t\t\toThreeDView = g_oThreeDView.GetThreeDView(oThreeDViews[i].Approval3DViewId);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Get the 3D view document.\r\n\t\t\t\tvar oThreeDViewDocument = $.findfirst(oThreeDViewDocuments, function (x) {\r\n\t\t\t\t\treturn x.Approval3DViewId === oThreeDView.Approval3DViewId;\r\n\t\t\t\t});\r\n\r\n\t\t\t\t// Outline the document.\r\n\t\t\t\tvar oDocument = {\r\n\t\t\t\t\tdocument: oThreeDViewDocument,\r\n\t\t\t\t\tdocumentName: $.findfirst(g_oViewer.g_oaCompareDocuments, function (x) {\r\n\t\t\t\t\t\treturn x.greenlightDocumentId === oThreeDView.ParentDocumentId;\r\n\t\t\t\t\t}).documentName + \" \" + oThreeDViewDocument.documentName,\r\n\t\t\t\t\tgreenlightApprovalId: oThreeDView.ApprovalId,\r\n\t\t\t\t\tgreenlightDocumentId: oThreeDViewDocument.documentId\r\n\t\t\t\t};\r\n\r\n\t\t\t\t// Find the added document.\r\n\t\t\t\tvar oDocumentAdded = $.findfirst(g_oaComboControls[0].documents, function (x) {\r\n\t\t\t\t\treturn x.greenlightDocumentId === oThreeDViewDocument.documentId;\r\n\t\t\t\t});\r\n\r\n\t\t\t\t// If successful.\r\n\t\t\t\tif (typeof oDocumentAdded === \"undefined\" || oDocumentAdded.length === 0) {\r\n\r\n\t\t\t\t\t// Load 3D View Document to correct position of document arrays.\r\n\t\t\t\t\tvar iParentDocumentId = $.findfirst(g_oViewer.g_oaCompareDocuments, function (x) {\r\n\t\t\t\t\t\treturn x.greenlightDocumentId === oThreeDView.ParentDocumentId;\r\n\t\t\t\t\t}).greenlightDocumentId;\r\n\r\n\t\t\t\t\t// Add to combo control 0 as its removed when switching with multi-view.\r\n\t\t\t\t\tg_oThreeDView.AddToDocumentList(g_oaComboControls[0].documents, oDocument, iParentDocumentId);\r\n\t\t\t\t\tg_oThreeDView.AddToDocumentList(g_oaComboControls[1].documents, oDocument, iParentDocumentId);\r\n\t\t\t\t\tg_oThreeDView.AddToDocumentList(g_oViewer.g_oaCompareDocuments, oDocument, iParentDocumentId);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n /*\r\n\t* Callback when getting consumer model templates, if no templates exist hides the Three D module icon.\r\n\t*/\r\n\tThreeDView.prototype.GetConsumerModelTemplates_CH = function (response) {\r\n\t\t\r\n\t\t// Check we have a valid response and parse this to our consumer templates.\r\n\t\ttry {\r\n\t\t\tif (response !== \"\") {\r\n\t\t\t\tg_oThreeDView.g_oConsumerModelTemplates = $.parseJSON(response);\r\n\t\t\t}\r\n\t\t}\r\n\t\tcatch (e) {\r\n\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oThreeDView.c_szFailedToGetModelTemplates);\r\n\t\t\tg_oThreeDView.g_oConsumerModelTemplates = {};\r\n\t\t}\r\n\r\n\t\t// If we have valid consumer templates.\r\n\t\tif (g_oThreeDView.g_oConsumerModelTemplates[0] && g_oThreeDView.g_oConsumerModelTemplates.length > 0) {\r\n\r\n\t\t\t// Render the models.\r\n\t\t\tg_oThreeDView.RenderModels();\r\n\t\t}\r\n\t\t// If we do not have valid consumer templates.\r\n\t\telse {\r\n\r\n\t\t\t// Reset the object and hide the button.\r\n\t\t\tg_oThreeDView.g_oConsumerModelTemplates = {};\r\n\t\t\t$('#btnThreeDViewer').hide();\r\n\t\t}\r\n\t};\r\n\r\n /*\r\n\t* Callback when getting a consumer model file, if successful calls generate 3D view to generate the new 3D preview.\r\n\t*/\r\n\tThreeDView.prototype.GetConsumerModelFile_CH = function (response) {\r\n\t\tvar oTemplateModelData = $.parseJSON(response);\r\n\t\tvar iGreenlightDocumentPageIndex = (g_oaComboControls[0].selectedPageIndex === -1) ? 0 : g_oaComboControls[0].selectedPageIndex;\r\n\t\tvar oSelectedPage = g_oaComboControls[0].documents[g_oaComboControls[0].selectedDocumentIndex].document.pages[iGreenlightDocumentPageIndex];\r\n\r\n\t\t// Generate new 3DView\r\n\t\tthis.GenerateThreeDView(\r\n\t\t\tg_oaComboControls[0].documents[g_oaComboControls[0].selectedDocumentIndex].document.consumerId,\r\n\t\t\tg_oaComboControls[0].documents[g_oaComboControls[0].selectedDocumentIndex].greenlightApprovalId,\r\n\t\t\toTemplateModelData.GreenlightDocumentId,\r\n\t\t\toSelectedPage.documentPageId,\r\n\t\t\toSelectedPage.documentPageNumber,\r\n\t\t\toTemplateModelData.ModelFilePath,\r\n\t\t\toTemplateModelData.ModelPrimaryArtworkFileName,\r\n\t\t\tg_oViewer.g_oArtworkViewer.getImageRequest(true)\r\n\t\t);\r\n\r\n\t};\r\n\r\n /*\r\n\t* Callback when generating a 3D preview, sets up the combo controls, adding the new 3D document\r\n\t*/\r\n\tThreeDView.prototype.GenerateThreeDView_CH = function (response) {\r\n\t\tif (response !== \"\") {\r\n\t\t\tvar oNewThreeDViewResponse = $.parseJSON(response);\r\n\t\t\tvar oDocument = {\r\n\t\t\t\tdocument: oNewThreeDViewResponse.ThreeDViewDocument,\r\n\t\t\t\tdocumentName: $.findfirst(g_oViewer.g_oaCompareDocuments, function (x) {\r\n\t\t\t\t\t\t\t\t\treturn x.greenlightDocumentId === oNewThreeDViewResponse.ThreeDView[0].ParentDocumentId;\r\n\t\t\t\t\t\t\t\t}).documentName + \" \" + oNewThreeDViewResponse.ThreeDViewDocument.documentName,\r\n\t\t\t\tgreenlightApprovalId: oNewThreeDViewResponse.ThreeDView[0].ApprovalId,\r\n\t\t\t\tgreenlightDocumentId: oNewThreeDViewResponse.ThreeDViewDocument.documentId\r\n\t\t\t};\r\n\t\t\t// Load 3D View Document to correct position of document arrays.\r\n\t\t\tvar iParentDocumentId = $.findfirst(g_oViewer.g_oaCompareDocuments, function (x) {\r\n\t\t\t\t\t\t\t\t\t\treturn x.greenlightDocumentId === oNewThreeDViewResponse.ThreeDView[0].ParentDocumentId;\r\n\t\t\t\t\t\t\t\t\t}).greenlightDocumentId;\r\n\t\t\t//Add to compare list\r\n\t\t\tg_oThreeDView.AddToDocumentList(g_oViewer.g_oaCompareDocuments, oDocument, iParentDocumentId);\r\n\r\n\t\t\t// Add to combo control 0, Return the parent index for this combo control as we need it for selecting the option.\r\n\t\t\tvar iParentIndex = g_oThreeDView.AddToDocumentList(g_oaComboControls[0].documents, oDocument, iParentDocumentId);\r\n\r\n\t\t\t// If compare documents exist\r\n\t\t\tif (typeof g_oaComboControls[1] !== \"undefined\") {\r\n\t\t\t\t// Add to combo control 1 (compare documents)\r\n\t\t\t\tg_oThreeDView.AddToDocumentList(g_oaComboControls[1].documents, oDocument, iParentDocumentId);\r\n\t\t\t} else {\r\n\t\t\t\t// Reshow the tools if hidden.\r\n\t\t\t\t$(\"#tblCompareTools\").show();\r\n\r\n\t\t\t\t// Create the compare document combo control.\r\n\t\t\t\tcomboControl_CreateNewControl(\"approvalCompareComboControl\", \"divCompareName\", g_oCompare.c_szCompareDocument, g_oaComboControls[0].documents, false, \"g_oCompare.compareDocChangeEvent();\", g_oCompare.c_szSelectCompareDocument, g_oCompare.c_szDeactivateCompareDocument, 0);\r\n\r\n\t\t\t\t// Setup the page select option.\r\n\t\t\t\tg_oApprovalFiles.Setup(comboControl_GetControlById(\"approvalCompareComboControl\", true));\r\n\t\t\t}\r\n\t\t\t// Add threeDView to threeDView list\r\n\t\t\tif (g_oThreeDView.g_oApprovalThreeDViews.length > 0) {\r\n\t\t\t\tg_oThreeDView.g_oApprovalThreeDViews.push(oNewThreeDViewResponse.ThreeDView[0]);\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tg_oThreeDView.g_oApprovalThreeDViews = oNewThreeDViewResponse.ThreeDView;\r\n\t\t\t}\r\n\t\t\tif (g_oThreeDView.g_oThreeDViews.length > 0) {\r\n\t\t\t\tg_oThreeDView.g_oThreeDViews.push(oNewThreeDViewResponse.ThreeDView[0]);\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tg_oThreeDView.g_oThreeDViews = oNewThreeDViewResponse.ThreeDView;\r\n\t\t\t}\r\n\t\t}\r\n\t\t// validate that we have an index.\r\n\t\tif (iParentIndex != undefined) {\r\n\t\t\tcomboControl_SelectOption(0, iParentIndex + 1, -1, true);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tg_oGreenlightMessages.displayErrorBubble(g_oViewer.c_szInvalidDocument);\r\n\t\t}\r\n\t};\r\n\r\n /*\r\n\t* Callback when getting three d views for the current document, calls the render function after populating list.\r\n\t*/\r\n\tThreeDView.prototype.GetCurrentThreeDViews_CH = function (response) {\r\n\t\tif (response !== \"\") {\r\n\t\t\tg_oThreeDView.g_oThreeDViews = $.parseJSON(response);\r\n\t\t\t// filter out everything we cannot render\r\n\t\t\tg_oThreeDView.g_oThreeDViews = g_oThreeDView.g_oThreeDViews.filter(function (x) {\r\n\t\t\t\treturn g_oaComboControls[0].documents.map(function (x) {\r\n\t\t\t\t\treturn x.document.Approval3DViewId;\r\n\t\t\t\t}).some(function (y) {\r\n\t\t\t\t\treturn y === x.Approval3DViewId;\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t}\r\n\t\telse {\r\n\t\t\tg_oThreeDView.g_oThreeDViews = {};\r\n\t\t}\r\n\t\t// Hide the models if we have 3D Previews\r\n\t\tif (g_oThreeDView.g_oThreeDViews[0]) {\r\n\r\n\t\t\tvar szThreeDControlRightArrow = g_oSettings.c_iSkinType === 0 ? \"img/Arrow_Right_White_16.png\" : \"img/Arrow_Right_16.png\";\r\n\r\n\t\t\t// Hide models\r\n\t\t\t$('#imgExpandModels').attr('src', szThreeDControlRightArrow);\r\n\t\t\t$('#tblModelImagePlaceHolders').hide();\r\n\r\n\t\t}\r\n\t\tg_oThreeDView.RenderThreeDViews();\r\n\t};\r\n\r\n /*\r\n\t* - - - F U N C T I O N S - - -\r\n\t*/\n\n /*\r\n\t* Takes the 2D point, run through the geometries and return a 3D world vector if a match is found.\r\n\t*/\n\tThreeDView.prototype.TraversePolygonsForGeometries = function (node, uvx, uvy, threeDdocumentId, szColladaModelTexture) {\n\t\tif (node.geometry) {\n\t\t\t// Return a list of possible polygons that have the annotation within them.\n\t\t\t// The returned objects will have the x,y,z barycentric coordinates of the point inside the respective polygon\n\t\t\tvar baryData = this.ObtainBaryDataFromVertices(uvx, uvy, node.geometry.faceVertexUvs);\n\t\t\tfor (var j = 0; j < baryData.length; j++) {\n\t\t\t\t// Check to ensure that the material name matches the selected texture. Otherwise we get UV points on other materials which don't represent the artwork = bad.\n\t\t\t\tif (node.geometry.faces[baryData[j][0]].daeMaterial === szColladaModelTexture) {\n\t\t\t\t\t// We have a proper match. Get the points for the relevant vertices.\n\t\t\t\t\tvar vertexa = node.geometry.vertices[node.geometry.faces[baryData[j][0]].a];\n\t\t\t\t\tvar vertexb = node.geometry.vertices[node.geometry.faces[baryData[j][0]].b];\n\t\t\t\t\tvar vertexc = node.geometry.vertices[node.geometry.faces[baryData[j][0]].c];\n\t\t\t\t\t// We know the percentage along each vertex. Multiply out to triangulate the position.\n\t\t\t\t\tvar worldX = vertexa.x * baryData[j][1] + vertexb.x * baryData[j][2] + vertexc.x * baryData[j][3];\n\t\t\t\t\tvar worldY = vertexa.y * baryData[j][1] + vertexb.y * baryData[j][2] + vertexc.y * baryData[j][3];\n\t\t\t\t\tvar worldZ = vertexa.z * baryData[j][1] + vertexb.z * baryData[j][2] + vertexc.z * baryData[j][3];\n\t\t\t\t\tvar vector = new THREE.Vector3(worldX, worldY, worldZ);\n\t\t\t\t\t// Convert to world vs local space.\n\t\t\t\t\tvar worldVector = vector.applyMatrix4(node.matrixWorld);\n\t\t\t\t\treturn worldVector;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Recurse through any child nodes.\n\t\tif (node.children) {\n\t\t\tfor (var i = 0; i < node.children.length; i++) {\n\t\t\t\tvar worldVectorPoint = g_oThreeDView.TraversePolygonsForGeometries(node.children[i], uvx, uvy, threeDdocumentId, szColladaModelTexture);\n\t\t\t\tif (worldVectorPoint) {\n\t\t\t\t\treturn worldVectorPoint;\r\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n /*\r\n\t* Obtains binary data from vertices.\r\n\t*/\n\tThreeDView.prototype.ObtainBaryDataFromVertices = function (uvX, uvY, faceVertexUvArray) {\n\t\tvar point = {};\n\t\tpoint.x = uvX;\n\t\tpoint.y = uvY;\n\t\tvar results = [];\n\t\tfor (var i = 0; i < faceVertexUvArray[0].length; i++) {\n\t\t\tvar result = g_oThreeDView.PtInTriangle(point, faceVertexUvArray[0][i][0], faceVertexUvArray[0][i][1], faceVertexUvArray[0][i][2]);\n\t\t\tif (result.length) {\n\t\t\t\tresults.push([i, result[0], result[1], result[2]]);\n\t\t\t}\n\t\t}\n\t\treturn results;\n\t};\n\n /*\r\n\t* Gets a single point in the centre of a triangle.\r\n\t*/\n\tThreeDView.prototype.PtInTriangle = function(p, p0, p1, p2) {\n\t\tvar x0 = p.x;\n\t\tvar y0 = p.y;\n\t\tvar x1 = p0.x;\n\t\tvar y1 = p0.y;\n\t\tvar x2 = p1.x;\n\t\tvar y2 = p1.y;\n\t\tvar x3 = p2.x;\n\t\tvar y3 = p2.y;\n\n\t\tvar b0 = (x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1);\n\t\tvar b1 = ((x2 - x0) * (y3 - y0) - (x3 - x0) * (y2 - y0)) / b0;\n\t\tvar b2 = ((x3 - x0) * (y1 - y0) - (x1 - x0) * (y3 - y0)) / b0;\n\t\tvar b3 = ((x1 - x0) * (y2 - y0) - (x2 - x0) * (y1 - y0)) / b0;\n\n\t\tif (b1 > 0 && b2 > 0 && b3 > 0) {\n\t\t\treturn [b1, b2, b3];\n\t\t} else {\n\t\t\treturn [];\n\t\t}\n\t};\n\n /*\r\n\t* Adds a ThreeDView document to a document list. Returns the parents index.\r\n\t*/\n\tThreeDView.prototype.AddToDocumentList = function (oDocumentList, oDocument, iParentDocumentId) {\n\t\tvar iParentIndex = 0;\r\n\t\t// Find the parents index\r\n\t\tfor (var i = 0; i < oDocumentList.length; i++) {\r\n\t\t\tif (oDocumentList[i].greenlightDocumentId === iParentDocumentId) {\r\n\t\t\t\tiParentIndex = i;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\t// If parent is last in list we can push\r\n\t\tif (iParentIndex === oDocumentList.length - 1) {\r\n\t\t\t// Add document to end.\r\n\t\t\toDocumentList.push(oDocument);\r\n\t\t}\r\n\t\telse {\r\n\t\t\t// Insert Document after parent.\r\n\t\t\toDocumentList.splice(iParentIndex + 1, 0, oDocument);\r\n\t\t}\r\n\t\treturn iParentIndex;\r\n\t};\n\r\n /*\r\n\t* Returns a ThreeDView object given the ApprovalThreeDViewId.\r\n\t*/\r\n\tThreeDView.prototype.GetThreeDView = function (ApprovalThreeDViewId) {\r\n\t\treturn $.findfirst(g_oThreeDView.g_oApprovalThreeDViews, function (x) {\r\n\t\t\treturn x.Approval3DViewId === ApprovalThreeDViewId;\r\n\t\t});\r\n\t};\r\n\r\n /*\r\n\t* Add the ThreeDView object to the window.\r\n\t*/\r\n\twindow.ThreeDView = ThreeDView;\r\n\r\n}());\r\n\r\n"]}