feat(assets): publish reusable area packages
This commit is contained in:
17
examples/three-asset-package.js
Normal file
17
examples/three-asset-package.js
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
const { resolveAsset, placement } = require("./asset-package-resolver");
|
||||
|
||||
async function loadPackage(loader, manifestUrl, assetId = "main", handoffEnuPlacement) {
|
||||
const manifest = await fetch(manifestUrl).then((response) => {
|
||||
if (!response.ok) throw new Error(`Could not load manifest: ${response.status}`);
|
||||
return response.json();
|
||||
});
|
||||
const scene = await loader.loadAsync(resolveAsset(manifestUrl, manifest, assetId));
|
||||
// Three.js does not georeference local ENU itself; the embedding host owns it.
|
||||
const enuPlacement = placement(manifest);
|
||||
if (handoffEnuPlacement) handoffEnuPlacement(enuPlacement, scene.scene);
|
||||
return { manifest, scene: scene.scene, placement: enuPlacement };
|
||||
}
|
||||
|
||||
module.exports = { loadPackage };
|
||||
Reference in New Issue
Block a user