From a0594d5ee23b933889e7b48bb99cdec8cf873239 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Mon, 3 Apr 2023 17:35:10 +0200 Subject: [PATCH] Enable calling Init3DViewerElements from everywhere #375 --- docs/Function_Init3DViewerElements.html | 15 ++++++-------- docs/Page_MigrationGuide.html | 7 +++++++ docs/Page_Usage.html | 12 +++++++----- docs/source/MigrationGuide.html | 7 +++++++ docs/source/Usage.html | 12 +++++++----- sandbox/embed_background.html | 4 +++- sandbox/embed_camera.html | 5 ++++- sandbox/embed_edges.html | 4 +++- sandbox/embed_filehost.html | 4 +++- sandbox/embed_iframe_envmaps.html | 6 ++++-- sandbox/embed_selfhost_errors.html | 4 +++- sandbox/embed_selfhost_externallibs.html | 6 ++++-- sandbox/embed_selfhost_fullscreen.html | 4 +++- sandbox/embed_selfhost_multiple.html | 5 +++-- sandbox/embed_selfhost_multiple_2.html | 4 +++- sandbox/embed_selfhost_single.html | 4 +++- sandbox/embed_selfhost_single_scroll.html | 4 +++- source/engine/viewer/embeddedviewer.js | 24 ++++++++++------------- 18 files changed, 83 insertions(+), 48 deletions(-) diff --git a/docs/Function_Init3DViewerElements.html b/docs/Function_Init3DViewerElements.html index 3f871c4..dfd33d9 100644 --- a/docs/Function_Init3DViewerElements.html +++ b/docs/Function_Init3DViewerElements.html @@ -61,16 +61,13 @@

Init3DViewerElements

-
Init3DViewerElements (onReady)
+
Init3DViewerElements ()
Description
-
Loads all the models on the page. This function looks for all the elements with online_3d_viewer class name, and loads the model according to the tag's parameters.
-
Parameters
-
-onReady -function -
-
-
Callback that called when all models are loaded. It has one parameter that is an array of the created EmbeddedViewer objects.
+
Loads all the models on the page. This function looks for all the elements with online_3d_viewer class name, and loads the model according to the tag's parameters. It must be called after the document is loaded.
+
Returns
+
+EmbeddedViewer[] +Array of the created EmbeddedViewer objects.
diff --git a/docs/Page_MigrationGuide.html b/docs/Page_MigrationGuide.html index d34e814..57bdec1 100644 --- a/docs/Page_MigrationGuide.html +++ b/docs/Page_MigrationGuide.html @@ -64,6 +64,13 @@

This document lists changes in the engine to help you to migrate your code base.

+

0.8.21

+ +
    +
  • Init3DViewerElements must be called when the document is loaded and returns an array of the created EmbeddedViewer objects. Earlier it registered a load event handler inside, now it's the responsibility of the caller.
  • +
+ +

0.8.21

    diff --git a/docs/Page_Usage.html b/docs/Page_Usage.html index 006c3d3..f61060f 100644 --- a/docs/Page_Usage.html +++ b/docs/Page_Usage.html @@ -92,12 +92,14 @@ There are two ways to use the library:
  • environmentmapbg: Boolean ("true" or "false") to set the environment map as background.
-

After placing the elements, call the Init3DViewerElements function to initalize all the viewers. It must be called from the main JavaScript file outside of the onload event.

+

After placing the elements, call the Init3DViewerElements function to initalize all the viewers. It must be called after the document is loaded.

-
// tell the engine where to find the libs folder
-OV.SetExternalLibLocation ('libs');
-// init all viewers on the page
-OV.Init3DViewerElements ();
+
window.addEventListener ('load', () => {
+    // tell the engine where to find the libs folder
+    OV.SetExternalLibLocation ('libs');
+    // init all viewers on the page
+    OV.Init3DViewerElements ();
+});

Initialization from code

diff --git a/docs/source/MigrationGuide.html b/docs/source/MigrationGuide.html index 46cfa45..bd48c5d 100644 --- a/docs/source/MigrationGuide.html +++ b/docs/source/MigrationGuide.html @@ -2,6 +2,13 @@

This document lists changes in the engine to help you to migrate your code base.

+

0.8.21

+ +
    +
  • {@link Init3DViewerElements} must be called when the document is loaded and returns an array of the created {@link EmbeddedViewer} objects. Earlier it registered a load event handler inside, now it's the responsibility of the caller.
  • +
+ +

0.8.21

    diff --git a/docs/source/Usage.html b/docs/source/Usage.html index 4951a1d..1b66ed6 100644 --- a/docs/source/Usage.html +++ b/docs/source/Usage.html @@ -30,12 +30,14 @@ There are two ways to use the library:
  • environmentmapbg: Boolean ("true" or "false") to set the environment map as background.
-

After placing the elements, call the {@link Init3DViewerElements} function to initalize all the viewers. It must be called from the main JavaScript file outside of the onload event.

+

After placing the elements, call the {@link Init3DViewerElements} function to initalize all the viewers. It must be called after the document is loaded.

-
// tell the engine where to find the libs folder
-OV.SetExternalLibLocation ('libs');
-// init all viewers on the page
-OV.Init3DViewerElements ();
+
window.addEventListener ('load', () => {
+    // tell the engine where to find the libs folder
+    OV.SetExternalLibLocation ('libs');
+    // init all viewers on the page
+    OV.Init3DViewerElements ();
+});

Initialization from code

diff --git a/sandbox/embed_background.html b/sandbox/embed_background.html index c12460a..8aad587 100644 --- a/sandbox/embed_background.html +++ b/sandbox/embed_background.html @@ -10,7 +10,9 @@