How to use @casual-simulation/aux-common - 10 common examples

To help you get started, we’ve selected a few @casual-simulation/aux-common 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 casual-simulation / aux / src / aux-vm-node / managers / AuxChannelManagerImpl.spec.ts View on Github external
[USERNAME_CLAIM]: 'abc',
                    [DEVICE_ID_CLAIM]: 'deviceId',
                    [SESSION_ID_CLAIM]: 'sessionId',
                },
                roles: [ADMIN_ROLE],
            };
            const first = await manager.loadChannel(info);

            let events: DeviceEvent[] = [];
            first.channel.onDeviceEvents.subscribe(e => events.push(...e));

            await manager.sendEvents(first, [
                deviceEvent(
                    device,
                    fileAdded(
                        createFile('testId', {
                            abc: 'def',
                        })
                    )
                ),
            ]);

            // Should map events to DeviceEvent
            expect(events).toEqual([
                {
                    type: 'device',
                    device: device,
                    event: fileAdded(
                        createFile('testId', {
                            abc: 'def',
                        })
                    ),
github casual-simulation / aux / src / aux-server / aux-web / shared / scene / decorators / IFramePlaneDecorator.ts View on Github external
botUpdated(calc: BotCalculationContext): void {
        // Get value of iframe plane position.
        this._localPosition = new Vector3(
            calculateNumericalTagValue(
                calc,
                this.bot3D.bot,
                'aux.iframe.x',
                DEFAULT_IFRAME_LOCAL_POSITION.x
            ),
            calculateNumericalTagValue(
                calc,
                this.bot3D.bot,
                'aux.iframe.y',
                DEFAULT_IFRAME_LOCAL_POSITION.y
            ),
            calculateNumericalTagValue(
                calc,
                this.bot3D.bot,
                'aux.iframe.z',
                DEFAULT_IFRAME_LOCAL_POSITION.z
            )
        );

        // Get value of iframe plane rotation.
        this._localRotation = new Vector3(
            calculateNumericalTagValue(
                calc,
                this.bot3D.bot,
                'aux.iframe.rotation.x',
                DEFUALT_IFRAME_LOCAL_ROTATION.x
            ),
            calculateNumericalTagValue(
github casual-simulation / aux / src / aux-server / aux-web / shared / scene / decorators / IFramePlaneDecorator.ts View on Github external
'aux.iframe.rotation.z',
                DEFUALT_IFRAME_LOCAL_ROTATION.z
            )
        );

        // Get value of iframe plane scale.
        this._planeScale = calculateNumericalTagValue(
            calc,
            this.bot3D.bot,
            'aux.iframe.scale',
            DEFAULT_IFRAME_PLANE_SCALE
        );

        // Get value of iframe plane size.
        const iframeSizeValue = new Vector2(
            calculateNumericalTagValue(
                calc,
                this.bot3D.bot,
                'aux.iframe.size.x',
                DEFAULT_IFRAME_PLANE_SIZE.x
            ),
            calculateNumericalTagValue(
                calc,
                this.bot3D.bot,
                'aux.iframe.size.y',
                DEFAULT_IFRAME_PLANE_SIZE.y
            )
        );
        let iframeSizeValueChanged = false;

        if (!iframeSizeValue.equals(this._planeSize)) {
            this._planeSize = iframeSizeValue;
github casual-simulation / aux / src / aux-server / aux-web / shared / scene / decorators / IFramePlaneDecorator.ts View on Github external
botUpdated(calc: BotCalculationContext): void {
        // Get value of iframe plane position.
        this._localPosition = new Vector3(
            calculateNumericalTagValue(
                calc,
                this.bot3D.bot,
                'aux.iframe.x',
                DEFAULT_IFRAME_LOCAL_POSITION.x
            ),
            calculateNumericalTagValue(
                calc,
                this.bot3D.bot,
                'aux.iframe.y',
                DEFAULT_IFRAME_LOCAL_POSITION.y
            ),
            calculateNumericalTagValue(
                calc,
                this.bot3D.bot,
                'aux.iframe.z',
                DEFAULT_IFRAME_LOCAL_POSITION.z
github casual-simulation / aux / src / aux-server / aux-web / shared / scene / decorators / IFramePlaneDecorator.ts View on Github external
// Get value of iframe plane rotation.
        this._localRotation = new Vector3(
            calculateNumericalTagValue(
                calc,
                this.bot3D.bot,
                'aux.iframe.rotation.x',
                DEFUALT_IFRAME_LOCAL_ROTATION.x
            ),
            calculateNumericalTagValue(
                calc,
                this.bot3D.bot,
                'aux.iframe.rotation.y',
                DEFUALT_IFRAME_LOCAL_ROTATION.y
            ),
            calculateNumericalTagValue(
                calc,
                this.bot3D.bot,
                'aux.iframe.rotation.z',
                DEFUALT_IFRAME_LOCAL_ROTATION.z
            )
        );

        // Get value of iframe plane scale.
        this._planeScale = calculateNumericalTagValue(
            calc,
            this.bot3D.bot,
            'aux.iframe.scale',
            DEFAULT_IFRAME_PLANE_SCALE
        );

        // Get value of iframe plane size.
github casual-simulation / aux / src / aux-server / aux-web / shared / scene / decorators / IFramePlaneDecorator.ts View on Github external
calc,
                this.bot3D.bot,
                'aux.iframe.z',
                DEFAULT_IFRAME_LOCAL_POSITION.z
            )
        );

        // Get value of iframe plane rotation.
        this._localRotation = new Vector3(
            calculateNumericalTagValue(
                calc,
                this.bot3D.bot,
                'aux.iframe.rotation.x',
                DEFUALT_IFRAME_LOCAL_ROTATION.x
            ),
            calculateNumericalTagValue(
                calc,
                this.bot3D.bot,
                'aux.iframe.rotation.y',
                DEFUALT_IFRAME_LOCAL_ROTATION.y
            ),
            calculateNumericalTagValue(
                calc,
                this.bot3D.bot,
                'aux.iframe.rotation.z',
                DEFUALT_IFRAME_LOCAL_ROTATION.z
            )
        );

        // Get value of iframe plane scale.
        this._planeScale = calculateNumericalTagValue(
            calc,
github casual-simulation / aux / src / aux-vm-node / managers / AuxUserAuthenticator.ts View on Github external
this._userUpdated.next(newUser.username);
                } else {
                    this._userUpdated.next(user.username);
                    this._userUpdated.next(newUser.username);
                }
            } else {
                // Remove user
                this._userTokens.delete(user.username);
                this._users.delete(user.username);
                this._botAccountMap.delete(bot.id);

                this._userUpdated.next(user.username);
            }
        } else {
            // We might have a new user
            if (hasValue(bot.tags['aux.account.username'])) {
                // We have a new user
                const newUser = this._calculateUserAccountInfo(context, bot);
                this._botAccountMap.set(bot.id, newUser);
                this._users.set(newUser.username, newUser);

                this._userUpdated.next(newUser.username);
            } else {
                // Do nothing
            }
        }
    }
github casual-simulation / aux / src / aux-vm-node / managers / AuxUserAuthenticator.ts View on Github external
private _updateTokenInfo(context: BotCalculationContext, bot: Bot) {
        const token = this._botTokenMap.get(bot.id);
        if (token) {
            // We had a token

            if (hasValue(bot.tags['aux.token.username'])) {
                let oldUserTokens = this._getTokensForUsername(token.username);

                // Update token
                this._tokens.delete(token.token);
                oldUserTokens.delete(token.token);

                const newToken = this._calculateUserTokenInfo(context, bot);
                let newUserTokens = this._getTokensForUsername(
                    newToken.username
                );

                newUserTokens.add(newToken.token);
                this._botTokenMap.set(bot.id, newToken);
                this._tokens.set(newToken.token, newToken);

                if (newToken.username === token.username) {
github casual-simulation / aux / src / aux-server / aux-web / shared / scene / decorators / AuxBot3DDecoratorFactory.ts View on Github external
loadDecorators(bot3d: AuxBot3D): AuxBot3DDecorator[] {
        let decorators: AuxBot3DDecorator[] = [];
        const isUser = !!bot3d.bot && hasValue(bot3d.bot.tags['_auxUser']);
        const isLocalUser = isUser && bot3d.bot.id === appManager.user.id;

        if (isUser) {
            if (isLocalUser) {
                // Local user gets controls for changing their user position in contexts.
                decorators.push(new UserControlsDecorator(bot3d, this.game));
            } else {
                // Remote user gets mesh to visualize where it is in contexts.
                decorators.push(new UserMeshDecorator(bot3d));
            }
        } else {
            let botShapeDecorator = new BotShapeDecorator(bot3d);
            let textureDecorator = new TextureDecorator(
                bot3d,
                botShapeDecorator
            );
github casual-simulation / aux / src / aux-server / aux-web / shared / scene / decorators / IFramePlaneDecorator.ts View on Github external
if (hasValue(iframeValue) && isValidURL(iframeValue)) {
            if (this.url !== iframeValue) {
                this.url = iframeValue;
                iframeValueChanged = true;
            }
        } else {
            if (this.url !== null && this.url !== undefined) {
                this.url = null;
                iframeValueChanged = true;
            }
        }

        let allowSizeChangeThisUpdate = true;
        if (iframeValueChanged) {
            if (hasValue(this.url)) {
                if (!this.mixerPlane) {
                    // Create the mixer plane.
                    this.mixerPlane = this._createMixerPlane();
                    allowSizeChangeThisUpdate = false; // Don't need to update element or plane size since our current values are accurate here.
                }

                HtmlMixerHelpers.setIframeSrc(this.mixerPlane, this.url);
            } else {
                // Remove the mixer plane.
                this._destroyMixerPlane();
            }
        }

        if (allowSizeChangeThisUpdate && this.mixerPlane) {
            if (iframeElementWidthValueChanged || iframeSizeValueChanged) {
                // Recreate the mixer plane if element width or plane size changes ONLY if the mixer plane already exists and wasnt created this frame.