How to use the aframe.utils.bind function in aframe

To help you get started, we’ve selected a few aframe examples, based on popular ways it is used in public projects.

github delapuente / aframe-sharedspace-component / src / components / sharedspace / participation / index.js View on Github external
import { utils } from 'aframe';
import EventTarget from 'event-target-shim';
import { GuestList } from './guest-list';
import { RTCInterface } from '../rtc-interface';
import { panic } from '../../../utils';

const bind = utils.bind;
const log = utils.debug('sharedspace:participant:log');
const warn = utils.debug('sharedspace:participant:warn');
const error = utils.debug('sharedspace:participant:error');

/**
 * The Participation class represents the participation model.
 *
 * This model tries to guarantee the entering order for all participants to be
 * the same and so, the problems translates to keeping a list of participants
 * the same for all the participants.
 *
 * To that end, the source of trust is centralized into the "host" participant.
 *
 * For choosing the "host", a participant starts with "unknown" role. As soon as
 * it discovers another participant, it creates a two item participant list
 * with itself and the other participant, and broadcast this list along with its
github delapuente / aframe-sharedspace-component / src / components / sharedspace / rtc-interface.js View on Github external
import { utils } from 'aframe';
import signalhub from 'signalhub';
import WebRtcSwarm from 'webrtc-swarm';
import EventTarget from 'event-target-shim';
import { panic } from '../../utils';

const bind = utils.bind;
const log = utils.debug('sharedspace:rtc-interface:log');
const error = utils.debug('sharedspace:rtc-interface:error');

class RTCInterface extends EventTarget {

  constructor(room, { id, stream, signaling }) {
    super();
    this._id = id;
    this._stream = stream;
    this._hub = signalhub(room, [signaling]);
  }

  get me() {
    return this._swarm.me;
  }
github delapuente / aframe-sharedspace-component / src / components / avatars / index.js View on Github external
import { registerComponent, utils } from 'aframe';
import { SceneTree } from './scene-tree';
import { EntityObserver } from './entity-observer';

const bind = utils.bind;
const log = utils.debug('sharedspace:avatars:log');
const warn = utils.debug('sharedspace:avatars:warn');
const error = utils.debug('sharedspace:avatars:error');

export default registerComponent('avatars', {

  dependendies: ['sharedspace'],

  schema: {
    template: { type: 'selector', default: 'template' },
    placement: { type: 'string', default: 'position-around' },
    onmyself: { type: 'string', default: 'auto' },
    audio: { default: true },
    autoremove: { default: true }
  },
github delapuente / aframe-sharedspace-component / src / components / sharedspace / index.js View on Github external
import { registerComponent, utils } from 'aframe';
import { Participation } from './participation';
import { panic } from '../../utils';

const bind = utils.bind;
const log = utils.debug('sharedspace:log');
const warn = utils.debug('sharedspace:warn');
const error = utils.debug('sharedspace:error');

export default registerComponent('sharedspace', {
  schema: {
    hold: { default: false },
    provider: { default: 'https://salvadelapuente.com:9000' },
    room: { default: 'room-101' },
    audio: { default: false },
    me: { default: '' }
  },

  update() {
    if (!this._initializing && !this._connected && !this.data.hold) {
      this._start();