Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
var yourSceneURL = '' // no trailing room name, only ID.
// Also works on Hubs Cloud servers but assets have to remain available (i.e no CORS, 404, etc)
// example of grabbing a local copy of assets hosted with the proxy
// curl | jq .nodes[] -r | grep
function populateSceneFromMozGLTF(scene){
document.querySelector('*[networked-counter]').setAttribute('networked-counter', {max: 100})
for (var node of scene.nodes){
var el = document.createElement("a-entity")
el.setAttribute("media-loader", { src:, fitToBox: true, resolve: true })
el.setAttribute("networked", { template: "#interactable-media" } )
if (node.translation) el.object3D.position.fromArray(node.translation)
if (node.scale) el.object3D.scale.fromArray(node.scale)
if (node.rotation) el.object3D.quaternion.fromArray(node.rotation)
// somehow doesn't seem to be applied right, might be xyzw/wxyz or translating to origin first?
el.setAttribute("pinnable", {pinned: true} )
console.log('All',scene.nodes.length,'objects loaded')
.then( response => { return response.json() } )
.then( scene => populateSceneFromMozGLTF( scene ) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment