How to use @microsoft/mixed-reality-extension-sdk - 10 common examples

To help you get started, we’ve selected a few @microsoft/mixed-reality-extension-sdk 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 microsoft / mixed-reality-extension-sdk / packages / functional-tests / src / server.ts View on Github external
import * as MRE from '@microsoft/mixed-reality-extension-sdk';
import dotenv from 'dotenv';
import { resolve as resolvePath } from 'path';
import { App } from './app';

// Read .env if file exists
dotenv.config();

process.on('uncaughtException', (err) => console.log('uncaughtException', err));
process.on('unhandledRejection', (reason) => console.log('unhandledRejection', reason));

// MRE.log.enable('network');
// MRE.log.enable('network-content');

// Start listening for connections, and serve static files
const server = new MRE.WebHost({
	// baseUrl: 'http://.ngrok.io',
	baseDir: resolvePath(__dirname, '../public'),
});

// Handle new application sessions
server.adapter.onConnection((context, params) => new App(context, params, server.baseUrl));

export default server;
github microsoft / mixed-reality-extension-sdk / packages / functional-tests / src / app.ts View on Github external
private setupRunner() {
		// Main label at the top of the stage
		this.contextLabel = MRE.Actor.Create(this.context, {
			actor: {
				name: 'contextLabel',
				text: {
					contents: this.activeTestName,
					height: 0.2,
					anchor: MRE.TextAnchorLocation.MiddleCenter,
					justify: MRE.TextJustify.Center,
					color: NeutralColor
				},
				transform: {
					local: {
						position: { y: 1.8 }
					}
				}
			}
		});

		this.testRoot = MRE.Actor.Create(this.context, {
			actor: {
				name: 'testRoot',
				exclusiveToUser: this.exclusiveUser && this.exclusiveUser.id || undefined
			}
		});
github microsoft / mixed-reality-extension-sdk-samples / samples / solar-system / src / app.ts View on Github external
sunPrimitives.forEach((prim) => {
                // Add a collider so that the behavior system will work properly on Unity host apps.
                const center = { x: 0, y: 0, z: 0 } as MRESDK.Vector3Like;
                const radius = 3;
                prim.setCollider('sphere', false, center, radius);

                const buttonBehavior = prim.setBehavior(MRESDK.ButtonBehavior);

                buttonBehavior.onClick('pressed', () => {
                    if (this.animationsRunning) {
                        this.pauseAnimations();
                        this.animationsRunning = false;
                    } else {
                        this.resumeAnimations();
                        this.animationsRunning = true;
                    }
                });

                buttonBehavior.onHover('enter', () => {
                    console.log(`Hover entered on ${sunEntity.model.name}.`);
                });

                buttonBehavior.onHover('exit', () => {
github microsoft / mixed-reality-extension-sdk-samples / samples / solar-system / src / app.ts View on Github external
private createBody(bodyName: string) {
        console.log(`Loading ${bodyName}`);

        const facts = database[bodyName];

        const distanceMultiplier = Math.pow(facts.distance, 1 / 3);
        const scaleMultiplier = Math.pow(facts.diameter, 1 / 3) / 25;

        const positionValue = { x: distanceMultiplier, y: 0, z: 0 };
        const scaleValue = { x: scaleMultiplier / 2, y: scaleMultiplier / 2, z: scaleMultiplier / 2 };
        const obliquityValue = MRESDK.Quaternion.RotationAxis(
            MRESDK.Vector3.Forward(), facts.obliquity * MRESDK.DegreesToRadians);
        const inclinationValue = MRESDK.Quaternion.RotationAxis(
            MRESDK.Vector3.Forward(), facts.inclination * MRESDK.DegreesToRadians);

        // Object layout for celestial body is:
        //  inclination                 -- orbital plane. centered on sol and tilted
        //      position                -- position of center of celestial body (orbits sol)
        //          label               -- centered above position. location of label.
        //          obliquity0          -- centered on position. hidden node to account
        //                                 for the fact that obliquity is a world-relative axis
        //              obliquity1      -- centered on position. tilt of obliquity axis
        //                  model       -- centered on position. the celestial body (rotates)
        try {
            const inclination = MRESDK.Actor.CreateEmpty(this.context, {
                actor: {
                    name: `${bodyName}-inclination`,
                    transform: {
                        rotation: inclinationValue
                    }
github microsoft / mixed-reality-extension-sdk-samples / samples / solar-system / src / app.ts View on Github external
private createBody(bodyName: string) {
        console.log(`Loading ${bodyName}`);

        const facts = database[bodyName];

        const distanceMultiplier = Math.pow(facts.distance, 1 / 3);
        const scaleMultiplier = Math.pow(facts.diameter, 1 / 3) / 25;

        const positionValue = { x: distanceMultiplier, y: 0, z: 0 };
        const scaleValue = { x: scaleMultiplier / 2, y: scaleMultiplier / 2, z: scaleMultiplier / 2 };
        const obliquityValue = MRESDK.Quaternion.RotationAxis(
            MRESDK.Vector3.Forward(), facts.obliquity * MRESDK.DegreesToRadians);
        const inclinationValue = MRESDK.Quaternion.RotationAxis(
            MRESDK.Vector3.Forward(), facts.inclination * MRESDK.DegreesToRadians);

        // Object layout for celestial body is:
        //  inclination                 -- orbital plane. centered on sol and tilted
        //      position                -- position of center of celestial body (orbits sol)
        //          label               -- centered above position. location of label.
        //          obliquity0          -- centered on position. hidden node to account
        //                                 for the fact that obliquity is a world-relative axis
        //              obliquity1      -- centered on position. tilt of obliquity axis
        //                  model       -- centered on position. the celestial body (rotates)
        try {
            const inclination = MRESDK.Actor.CreateEmpty(this.context, {
                actor: {
                    name: `${bodyName}-inclination`,
                    transform: {
                        app: { rotation: inclinationValue }
                    }
github microsoft / mixed-reality-extension-sdk-samples / samples / hello-world / src / server.ts View on Github external
* Licensed under the MIT License.
 */

import { WebHost } from '@microsoft/mixed-reality-extension-sdk';
import dotenv from 'dotenv';
import { resolve as resolvePath } from 'path';
import App from './app';

process.on('uncaughtException', err => console.log('uncaughtException', err));
process.on('unhandledRejection', reason => console.log('unhandledRejection', reason));

// Read .env if file exists
dotenv.config();

// Start listening for connections, and serve static files
const server = new WebHost({
	// baseUrl: 'http://.ngrok.io',
	baseDir: resolvePath(__dirname, '../public')
});

// Handle new application sessions
server.adapter.onConnection(context => new App(context, server.baseUrl));
github microsoft / mixed-reality-extension-sdk-samples / samples / solar-system / src / server.ts View on Github external
import { log, WebHost } from '@microsoft/mixed-reality-extension-sdk';
import dotenv from 'dotenv';
import { resolve as resolvePath } from 'path';
import App from './app';

// Read .env if file exists
dotenv.config();

process.on('uncaughtException', err => console.log('uncaughtException', err));
process.on('unhandledRejection', reason => console.log('unhandledRejection', reason));

log.enable('app');

// Start listening for connections, and serve static files
const server = new WebHost({
    // baseUrl: 'http://.ngrok.io',
    baseDir: resolvePath(__dirname, '../public')
});

// Handle new application sessions
server.adapter.onConnection(context => new App(context, server.baseUrl));
github microsoft / mixed-reality-extension-sdk-samples / samples / tic-tac-toe / src / server.ts View on Github external
import { log, WebHost } from '@microsoft/mixed-reality-extension-sdk';
import dotenv from 'dotenv';
import { resolve as resolvePath } from 'path';
import App from './app';

// Read .env if file exists
dotenv.config();

process.on('uncaughtException', err => console.log('uncaughtException', err));
process.on('unhandledRejection', reason => console.log('unhandledRejection', reason));

log.enable('app');

// Start listening for connections, and serve static files
const server = new WebHost({
    // baseUrl: 'http://.ngrok.io',
    baseDir: resolvePath(__dirname, '../public')
});

// Handle new application sessions
server.adapter.onConnection(context => new App(context, server.baseUrl));
github microsoft / mixed-reality-extension-sdk-samples / samples / wear-a-hat / src / server.ts View on Github external
import { log, WebHost } from '@microsoft/mixed-reality-extension-sdk';
import dotenv from 'dotenv';
import { resolve as resolvePath } from 'path';
import App from './app';

// Read .env if file exists
dotenv.config();

process.on('uncaughtException', err => console.log('uncaughtException', err));
process.on('unhandledRejection', reason => console.log('unhandledRejection', reason));

log.enable('app');

// Start listening for connections, and serve static files
const server = new WebHost({
    // baseUrl: 'http://.ngrok.io',
    baseDir: resolvePath(__dirname, '../public')
});

// Handle new application sessions
server.adapter.onConnection(context => new App(context, server.baseUrl));
github microsoft / mixed-reality-extension-sdk-samples / samples / chess-game / src / server.ts View on Github external
/* Sample .env file:
 *  PORT=80
 *  BASE_URL=http://.ngrok.io
 *  MRE_LOGGING=app:error,network,network-content
 */

import { WebHost } from '@microsoft/mixed-reality-extension-sdk';
import { resolve as resolvePath } from 'path';
import App from './app';

process.on('uncaughtException', err => console.log('uncaughtException', err));
process.on('unhandledRejection', reason => console.log('unhandledRejection', reason));

// Start listening for connections, and serve static files
const server = new WebHost({
	baseDir: resolvePath(__dirname, '../public')
});

// Handle new application sessions
server.adapter.onConnection(context => new App(context, server.baseUrl));

@microsoft/mixed-reality-extension-sdk

The Mixed Reality Extension SDK enables developers to build 3D world extensions for AltspaceVR, using Node.JS.

MIT
Latest version published 4 years ago

Package Health Score

48 / 100
Full package analysis