This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // see the alternative that fetch directly from the room to clone | |
| // https://gist.github.com/Utopiah/8eb0d83e467d13994fd69c4631130561 | |
| function getObjects(){ | |
| var myObjects = [] | |
| for (var media of document.querySelectorAll("[media-loader]")){ | |
| if (media.components.pinnable && media.components.pinnable.attrValue.pinned) | |
| myObjects.push({ | |
| src:media.components['media-loader'].attrValue.src, | |
| position: media.getAttribute('position'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var board_bbox = { | |
| x_min: -1.2, x_max: -0.8, | |
| z_min: -6, z_max: -2, | |
| } | |
| var player = document.querySelector("#avatar-rig") // only works for the current device running the script | |
| player = document.querySelector("#naf-z83mq48") // Fabien - Utopiah on Quest | |
| var intervalExecuteCheck = setInterval(checkProximityAndExecute, 500) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* examples of usage : | |
| slides.setupSlides() // load and layout slides with links | |
| slides.nextSlide() // switch to the next slide (loops) | |
| slides.removeAllMedia() // remove all slides | |
| slides.startAutoPresent() // move from slide to slide in the allotated time then drops them all | |
| slides.dropAllContent() | |
| */ | |
| var slides = { | |
| timer:20000, //ms |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for (var drawing of document.querySelectorAll("[networked-drawing]")){ | |
| drawing.components["networked-drawing"].serializeDrawing().then( pinLastDrawingAsGlb ) | |
| drawing.remove() | |
| } | |
| function pinLastDrawingAsGlb(){ | |
| var networked = document.querySelectorAll("[networked][animation__pin-end]") | |
| networked[networked.length-1].setAttribute("pinnable", {pinned:true}) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const hubs_utils = { | |
| removeEntitiesFromMediaList, | |
| setPinEntities, | |
| loadAssetsFromURLs, | |
| getAvatarFromName, | |
| getFirstElementFromHash, | |
| objects3DFromPartialName, | |
| getFirstElementFromPartialURL, | |
| getAvatarFromName, | |
| resetUserMediaRotation, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var done = '8742' // hashes of objects already in the room | |
| var inprogress = '9125' | |
| var todo = '28d4' | |
| var ideas = { | |
| left: ['InnovateIdeas1', 'InnovateIdeas2'], // to do | |
| right: ['InnovateIdeas3', 'InnovateIdeas4'], // done | |
| back: ['InnovateIdeas5', 'InnovateIdeas6', 'InnovateIdeas7', 'InnovateIdeas8', 'InnovateIdeas9', 'InnovateIdeas10' ], // in progress | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // examples of animations https://gist.github.com/Utopiah/7b6be1814abc25f027a85878859ed28a#file-collaborative_game_design_demo_hubs-js-L79 | |
| var FizzyText = function() { | |
| this.message = 'dat.gui x Mozilla Hubs'; | |
| this.jump_anim = 0; | |
| this.scale_anim = 0; | |
| }; | |
| var text = new FizzyText(); | |
| var gui = new dat.GUI(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // make sure you have DATgui available (e.g execute the code from the console then delete it) | |
| // -------------- object setup | |
| var gramoURL = 'https://poly.google.com/view/9MZ0sCt1REv' | |
| loadAssetsFromURLs([gramoURL]) | |
| var obj = getFirstElementFromHash('9MZ0') | |
| // -------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // to execute on the Twitch chat room that will control the Hubs room | |
| var chatHistory = [] | |
| function pimvrSaveRemote(page, data) { | |
| // removed to go live, use instead WebSockets or a JSON store e.g. https://jsonbox.io | |
| } | |
| const watchedNode = document.querySelector("[role=log]") | |
| const observer = new MutationObserver(function(mutations) { |