From 9d8fdfad2af60edd25cdbd8db8ce7e57263bffcd Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 28 Feb 2025 17:32:21 +0100 Subject: [PATCH] wip #7347 @2 --- js/libs/fluidbook/fluidbook.js | 49 +- js/libs/fluidbook/fluidbook.menu.js | 46 +- js/libs/o3dv/o3dv.min.js | 3958 +++++++++++++++++++++++++++ style/fluidbook.less | 7 + 4 files changed, 4047 insertions(+), 13 deletions(-) create mode 100644 js/libs/o3dv/o3dv.min.js diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index fd900e2f..ccf46509 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -813,14 +813,11 @@ Fluidbook.prototype = { var rand = Math.round(Math.random() * 100000); this.waiters.push(rand); return rand; - }, - waiterActive: function (id) { + }, waiterActive: function (id) { return this.waiters.indexOf(id) > -1; - }, - resetWaiters: function () { + }, resetWaiters: function () { this.waiters = []; - }, - physicalToVirtual: function (page) { + }, physicalToVirtual: function (page) { return this.settings.numerotation[page - 1]; }, @@ -1246,6 +1243,46 @@ Fluidbook.prototype = { this.contentlock.unlockCurrentPage(); }, + initO3DV: function (containerID, model) { + // See https://kovacsv.github.io/Online3DViewer/Page_Usage.html + + let parentDiv = document.getElementById(containerID); + + // initialize the viewer with the parent element and some parameters + let viewer = new OV.EmbeddedViewer(parentDiv, { + // camera : new OV.Camera ( + // new OV.Coord3D (-1.5, 2.0, 3.0), + // new OV.Coord3D (0.0, 0.0, 0.0), + // new OV.Coord3D (0.0, 1.0, 0.0), + // 45.0 + // ), + backgroundColor: new OV.RGBAColor(255, 255, 255, 0), // defaultColor : new OV.RGBColor (200, 200, 200), + // edgeSettings : new OV.EdgeSettings (false, new OV.RGBColor (0, 0, 0), 1), + // environmentSettings : new OV.EnvironmentSettings ( + // [ + // 'assets/envmaps/fishermans_bastion/posx.jpg', + // 'assets/envmaps/fishermans_bastion/negx.jpg', + // 'assets/envmaps/fishermans_bastion/posy.jpg', + // 'assets/envmaps/fishermans_bastion/negy.jpg', + // 'assets/envmaps/fishermans_bastion/posz.jpg', + // 'assets/envmaps/fishermans_bastion/negz.jpg' + // ], + // false + // ) + }); + + // load a model providing model urls + viewer.LoadModelFromUrlList(['data/links/' + model,]); + $("#" + containerID).data('o3dv', viewer); + setInterval(function () { + try { + viewer.Resize(); + } catch (e) { + + } + }, 250); + }, + bugreport: function (e) { if (window.confirm('An error occured: ' + e.name + '. Do you want to send a report ?')) { var subject = '[Fluidbook error report] ' + e.message; diff --git a/js/libs/fluidbook/fluidbook.menu.js b/js/libs/fluidbook/fluidbook.menu.js index 98072ab3..3dee765f 100644 --- a/js/libs/fluidbook/fluidbook.menu.js +++ b/js/libs/fluidbook/fluidbook.menu.js @@ -132,6 +132,8 @@ FluidbookMenu.prototype = { this.openDownload(cb); } else if (view === 'pdf') { this.openPDF(param1, cb); + } else if (view === 'o3d') { + this.openObject3D(param1, cb); } else if (view === 'article') { this.fluidbook.articles.openArticle(param1, cb); } else { @@ -248,6 +250,24 @@ FluidbookMenu.prototype = { return res; }, + openObject3D(o3d, callback) { + var $this = this; + var hash = '#/o3d/' + o3d; + var a = $('a[href="' + hash + '"]'); + var model = $(a).attr('data-model'); + var view = this.getCaption('', $(a).attr('data-popup-close') === null || $(a).attr('data-popup-close') === undefined || $(a).attr('data-popup-close') === '1'); + + this.fluidbook.stats.trackEvent($(a).data('stats-type'), 'show', $(a).data('stats-name')); + view += '
'; + this.viewWrap(view, 'o3d', '', '', false, hash); + + this.fluidbook.initO3DV('o3dv_' + o3d, model); + + if (callback != undefined) { + callback(); + } + }, + openMultimedia: function (multimedia, callback) { var $this = this; var hash = '#/multimedia/' + multimedia; @@ -437,8 +457,7 @@ FluidbookMenu.prototype = { callback(); } $this.fluidbook.audioplayer.initAudios(); - }, - openWebVideo: function (service, video, callback) { + }, openWebVideo: function (service, video, callback) { var hash = '#/webvideo/' + service + '/' + video; var a = $('a[href="' + hash + '"]'); var markup = decodeURIComponent($(a).attr('data-video')); @@ -453,8 +472,7 @@ FluidbookMenu.prototype = { if (callback != undefined) { callback(); } - }, - openLocales: function (p1, p2, callback) { + }, openLocales: function (p1, p2, callback) { var view = this.getCaption('Select language'); view += '
'; view += '