@onerjs/core 8.35.2 → 8.35.4

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.
@@ -277,7 +277,7 @@ type DefaultPluginOptions<BasePluginOptions> = {
277
277
  enabled?: boolean;
278
278
  } & BasePluginOptions;
279
279
  export type PluginOptions = ISceneLoaderOptions["pluginOptions"];
280
- type SceneSource = string | File | ArrayBufferView;
280
+ type SceneSource = string | File | ArrayBufferView | object;
281
281
  /**
282
282
  * Defines common options for loading operations performed by SceneLoader.
283
283
  */
@@ -107,6 +107,10 @@ async function loadDataAsync(fileInfo, scene, onSuccess, onProgress, onError, on
107
107
  // eslint-disable-next-line no-throw-literal
108
108
  throw "When using ArrayBufferView to load data the file extension must be provided.";
109
109
  }
110
+ if (fileInfo.jsonData && !pluginExtension) {
111
+ // eslint-disable-next-line no-throw-literal
112
+ throw "When using object to load data the file extension must be provided.";
113
+ }
110
114
  const fileExtension = !directLoad && !pluginExtension ? getFilenameExtension(fileInfo.url) : "";
111
115
  let registeredPlugin = pluginExtension
112
116
  ? getPluginForExtension(pluginExtension, true)
@@ -225,7 +229,7 @@ async function loadDataAsync(fileInfo, scene, onSuccess, onProgress, onError, on
225
229
  }
226
230
  request = plugin.loadFile
227
231
  ? plugin.loadFile(scene, fileInfo.rawData || fileInfo.file || fileInfo.url, fileInfo.rootUrl, dataCallback, onProgress, useArrayBuffer, errorCallback, name)
228
- : scene._loadFile(fileInfo.file || fileInfo.url, dataCallback, onProgress, true, useArrayBuffer, errorCallback);
232
+ : scene._loadFile(fileInfo.jsonData || fileInfo.file || fileInfo.url, dataCallback, onProgress, true, useArrayBuffer, errorCallback);
229
233
  };
230
234
  const engine = scene.getEngine();
231
235
  let canUseOfflineSupport = engine.enableOfflineSupport;
@@ -254,6 +258,7 @@ function GetFileInfo(rootUrl, sceneSource) {
254
258
  let name;
255
259
  let file = null;
256
260
  let rawData = null;
261
+ let jsonData = null;
257
262
  if (!sceneSource) {
258
263
  url = rootUrl;
259
264
  name = Tools.GetFilename(rootUrl);
@@ -269,6 +274,11 @@ function GetFileInfo(rootUrl, sceneSource) {
269
274
  name = RandomGUID();
270
275
  rawData = sceneSource;
271
276
  }
277
+ else if (typeof sceneSource === "object") {
278
+ url = "";
279
+ name = RandomGUID();
280
+ jsonData = sceneSource;
281
+ }
272
282
  else if (sceneSource.startsWith("data:")) {
273
283
  url = sceneSource;
274
284
  name = "";
@@ -293,6 +303,7 @@ function GetFileInfo(rootUrl, sceneSource) {
293
303
  name: name,
294
304
  file: file,
295
305
  rawData,
306
+ jsonData,
296
307
  };
297
308
  }
298
309
  /**