Skip to content

Instantly share code, notes, and snippets.

View camelgod's full-sized avatar
🔬
Joining 3D Web and EduTech together

Edvard Ødegaard camelgod

🔬
Joining 3D Web and EduTech together
  • Oslo, Norway
View GitHub Profile
const express = require("express");
const app = express();
const fs = require('fs');
const fetch = require('node-fetch');
const tokenFile = './.ret.credentials'
const token = JSON.parse(fs.readFileSync(tokenFile, 'utf8')).token;
const accountURL = 'https://myhubsURL.com/api/v1/accounts'
app.use(express.json())
@AndreasH96
AndreasH96 / floaty-object.js
Last active August 18, 2020 14:22
Modified version of hubs\src\components\floaty-object.js with the added ability to snap video objects and shared screens to objects. Usage: 1.replace the floaty-object.js file. 2. Create an image within Spoke named "snapobject" (see line 39). Now when you share a screen it should snap onto the image when released closed enough.
/* global AFRAME */
const COLLISION_LAYERS = require("../constants").COLLISION_LAYERS;
AFRAME.registerComponent("floaty-object", {
schema: {
// Make the object locked/kinematic upon load
autoLockOnLoad: { default: false },
// Make the object kinematic immediately upon release
autoLockOnRelease: { default: false },
@AndreasH96
AndreasH96 / mozilla_hubs_snap_shared_screen.js
Last active February 22, 2021 01:55
This code is based on a gist made by Utophia, https://gist.github.com/Utopiah/f2b11a8026030b726ecc8c8c9430a9b4 . It's made for being able to snap videos onto objects that are within object-groups. The code is made to be added into the file "floaty-objects.js" within the hubs client code base (2020-06-25).
snap(toSnap, snapOn) {
// Align rotation
toSnap.el.object3D.setRotationFromQuaternion(snapOn.object3D.getWorldQuaternion());
// Align position
toSnap.el.object3D.position.copy(snapOn.object3D.getWorldPosition());
// Set to same scale
toSnap.el.object3D.scale.copy(snapOn.object3D.getWorldScale());
// Move slightly to avoid texture tearing
var yourSceneURL = 'https://hubs.mozilla.com/LHzDxae/' // 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 https://hubs.mozilla.com/LHzDxae/objects.gltf | jq .nodes[].extensions.HUBS_components.media.src -r | grep uploads-prod.reticulum.io
function populateSceneFromMozGLTF(scene){
document.querySelector('*[networked-counter]').setAttribute('networked-counter', {max: 100})
for (var node of scene.nodes){
console.log(node)
// 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'),
// change YOURID with... YOUR ngrok id ;)
var lastModelTimestamp = null
var intervalCheck = setInterval(newModelReady, 500)
function newModelReady(){
fetch('http://YOURID.ngrok.io/timestamp.txt').then( response => { return response.json() } )
.then( timestamp => checkIfNovelModelAvailable(timestamp) )
}
/* How to use this script :
To play with it "as is" try it in the console of your browser first.
If you do like and want to make it permanent then a bit of UI integration is needed
(e.g. could add an icon, chat command, etc).
That would be done by using https://hubs.mozilla.com/docs/hubs-cloud-custom-clients.html
So that your integration remains easy to merge and maintainable over time it is recommended to
touch Hubs Cloud code itself as little as possible. For example having separate components for
@olmokramer
olmokramer / config
Last active August 8, 2023 18:18
Herbstluftwm workspaces for polybar
[module/herbstluftwm]
type = custom/script
exec-if = ps -C herbstluftwm >/dev/null 2>&1
exec = MONITOR=HDMI-0 ~/.config/polybar/herbstluftwm.sh
tail = true