How to use the aframe.registerSystem 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.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rvdleun / onoffice / client / src / aframe / peer.system.js View on Github external
import * as AFRAME from 'aframe';
import * as SimplePeer from 'simple-peer';

AFRAME.registerSystem('peer', {
    schema: {
        connectionLostText: {type: 'selector', default: '#connection-lost'}
    },

    onAddStreamFunc: null,

    listeners: [],

    init: function() {
        this.data.connectionLostText.setAttribute('visible', 'false');
    },

    connect: function(sessionId) {
        const peer = new SimplePeer({ initiator: true, streams: [] });

        // peer._pc.onconnectionstatechange = () => {
github delapuente / aframe-sharedspace-component / js / nsync / nsync.js View on Github external
import * as AFRAME from 'aframe';
import { AFrameEntityObserver } from './AFrameEntityObserver';
import { NetworkAdapter } from './NetworkAdapter';
import { SceneTree } from './SceneTree';

/**
 * The nsync system coordinates the network activity needed to keep all the
 * remote scenes synchronized. It stands for network synchronized.
 * TODO: Investigate takeRecords()
 */
export default AFRAME.registerSystem('nsync', {

  schema: {
    session: { default: 'room-101' },
    server: { default: 'localhost:9000' }
  },

  init() {
    this._uniqueId = 1;

    this._sceneTree = new SceneTree(this.el);
    this._network = new NetworkAdapter(this.data.session, this.data.server);
    this._network.onupdates = this._onupdates.bind(this);
    this._changes = [];
    this._collectChanges = this._collectChanges.bind(this);
    this._observer = new AFrameEntityObserver(this._collectChanges);
github rvdleun / onoffice / client / src / aframe / manipulate-source.component.js View on Github external
/*
    This component will allow the user to move and resize the screen
 */

import { THREE } from 'aframe';
import * as AFRAME from 'aframe';

window.console.log(AFRAME, THREE);

AFRAME.registerSystem('manipulate-source', {
    centerAllScreens: function() {
        const sources = document.querySelectorAll('[manipulate-source]');
        for(let i = 0; i
github Kif11 / three-body / src / systems / PendulumSystem.js View on Github external
import AFRAME from 'aframe';
const THREE = AFRAME.THREE;

//keeps track of all pendulums, and colors them all when in sync
AFRAME.registerSystem('pendulum', {
  schema: {
  },
  init: function () {
    this.pendulums = [];
    this.totalDist = 10;
  },
  registerPendulum: function(pendulum) {
    this.pendulums.push(pendulum);
  },
  getSynchStatus: function() {
    return (this.totalDist < 1)? true : false;
  },
  tick: function (time, timeDelta) {
    if( Math.abs(this.pendulums[0].dampeningFactor) < 0.1 || Math.abs(this.pendulums[1].dampeningFactor) < 0.1 || Math.abs(this.pendulums[2].dampeningFactor) < 0.1 ){
      this.totalDist = 10;
      this.pendulums.forEach((p) => {
github rvdleun / onoffice / client / src / aframe / cursor-position.system.js View on Github external
/*
    This component tracks the cursor position and updates the position of the entity accordingly
 */

import * as AFRAME from 'aframe';

AFRAME.registerSystem('cursor-position', {
    cursor: null,
    streamId: '',

    init: function() {
        setTimeout(() => {
            this.el.systems['peer'].on('cursor-position', (data) => {
                if (this.streamId !== data.streamId) {
                    this.streamId = data.streamId;

                    if (this.cursor) {
                        this.cursor.parentNode.removeChild(this.cursor);
                        this.cursor = null;
                    }

                    if (data.streamId === false) {
                        return;
github Kif11 / three-body / src / systems / RaycasterSystem.js View on Github external
import AFRAME from 'aframe';
const THREE = AFRAME.THREE;

import LaserFrag from '../shaders/LaserFrag.glsl';
import LaserVert from '../shaders/LaserVert.glsl';

import { setQuaternionFromDirection } from '../libs/Utils';

AFRAME.registerSystem('raycasterSystem', {
  schema: {
  },

  init: function () {
    this.raycaster = new THREE.Raycaster();
    this.mouse = new THREE.Vector2();

    this.triggerDown = false;
    this.mouseDown = false;

    this.tmps = {
      v1: new THREE.Vector3(),
      v2: new THREE.Vector3()
    };

    const controller = document.querySelector('#controller');
github rvdleun / onoffice / client / src / aframe / source.system.js View on Github external
/*
    This component displays a source. (a source being a screen)
 */

import * as AFRAME from 'aframe';

AFRAME.registerSystem('source', {
    assets: null,
    sources: null,

    id: 0,

    init: function() {
        window.setTimeout(() => {
            this.el.systems['peer'].onAddStreamFunc = this.onAddStream.bind(this);

            this.el.addEventListener('exit-vr', () => this.hideAll());

            this.el.addEventListener('peer-disconnected', () => this.hideAll());
        });
    },

    onAddStream: function(stream) {
github olioapps / aframe-typescript-toolkit / src / aframe_wrapper.ts View on Github external
register() {
        this.merge()
        registerSystem(this.name, this)
    }
}
github Kif11 / three-body / src / systems / SunSystem.js View on Github external
import AFRAME from 'aframe';
const THREE = AFRAME.THREE;

AFRAME.registerSystem('sunSystem', {
  schema: {
    speed: {
      type: 'float'
    },
    skyRadius: {
      type: 'float'
    },
    timeOffset: {
      type: 'float',
      default: 0
    },
    fogColor: {
      type: 'color',
      default: '#ffffff'
    },
  },