Skip to content

Instantly share code, notes, and snippets.

@Utopiah
Created May 20, 2020 07:18
Show Gist options
  • Select an option

  • Save Utopiah/7d2dcc343f1204a9cc2385a893786dbe to your computer and use it in GitHub Desktop.

Select an option

Save Utopiah/7d2dcc343f1204a9cc2385a893786dbe to your computer and use it in GitHub Desktop.
// mandatory settings on authorship
const account_id = 0000000000000000000000 // 18 digits found in /admin#/accounts of the scripting enabled Cloud instance
const email = '[email protected]' // the email account you used to register on that instance
// mandatory settings on execution
const room_ids = ['abc1234', 'def5678'] // the rooms you created and that you want your script to run on
const script_name = 'hubs cloud scripting template'
// optional parameters to restrict execution
const run_only_for_author = true // with false the script is run on every client connecting to that room
const run_only_for_logged_in_users = false // the script will only be excuted for users that are logged in
const run_only_for_matching_emails = /.*@domain.tld/ // regex to match emails of logged in users
// your script
function custom_script(){
console.log('scripting:', script_name)
var url = "https://sketchfab.com/3d-models/eye-implant-e988ba5725fe4111b82f945a068c7c81"
var el = document.createElement("a-entity")
AFRAME.scenes[0].appendChild(el)
el.setAttribute("media-loader", { src: url, fitToBox: true, resolve: true })
el.setAttribute("networked", { template: "#interactable-media" } )
el.setAttribute("position", "1 1 1")
}
export { custom_script };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment