NVIDIA-Omniverse / web-viewer-sample

This sample demonstrates how a front-end client can present a streamed Omniverse Kit application and how to send messages between the two apps.
Other
21 stars 8 forks source link

missinng WindowNoUI #1

Open mastrimax opened 2 months ago

mastrimax commented 2 months ago

I have noticed that the "WindowNoUI" component, which is mentioned in the documentation for usd_explorer and usd_composer, appears to be missing. When I attempt to modify the code in web-viewer-sample/src/App.tsx from: import Window from './Window'; to: import Window from './WindowNoUI'; I encounter the following error:

[plugin:vite:import-analysis] Failed to resolve import "./WindowNoUI" from "src/App.tsx". Does the file exist?

Could you please confirm if the WindowNoUI file should be present in the project? Thank you for your assistance.

Best regards, Massimo

Gango98 commented 2 months ago

Hi Massimo, I've the same problem. At the moment, I solved by writing my own 'WindowNoUI.tsx' by removing unuseful things from 'Window.tsx'.

I hope they will fix this. There are too many inconsistent things in these docs.

Here is the code:

/*
 * SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 * SPDX-License-Identifier: LicenseRef-NvidiaProprietary
 *
 * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
 * property and proprietary rights in and to this material, related
 * documentation and any modifications thereto. Any use, reproduction,
 * disclosure or distribution of this material and related documentation
 * without an express license agreement from NVIDIA CORPORATION or
 * its affiliates is strictly prohibited.
 */
import React from 'react';
import AppStream from './AppStream'; // Ensure .tsx extension if needed
import StreamConfig from '../stream.config.json';

interface AppState {
    gfnUser: string | null;
}

export default class App extends React.Component<{}, AppState> {

    constructor(props: {}) {
        super(props);

        this.state = {
            gfnUser: null
        }
    }

    /**
    * @function _onStreamStarted
    *
    * Send a request to open an asset when stream has started.
    */
    private _onStreamStarted(): void { }

    /**
    * @function _handleCustomEvent
    *
    * Handle message from stream.
    */
    private _handleCustomEvent(event: any): void { }

    /**
    * @function _handleAppStreamFocus
    *
    */
    private _handleAppStreamFocus(): void {
        console.log('User is interacting in streamed viewer');
    }

    /**
    * @function _handleAppStreamBlur
    *
    * Update state when AppStream is not in focus.
    */
    private _handleAppStreamBlur(): void {
        console.log('User is not interacting in streamed viewer');
    }

    render() {
        const streamConfig: any = StreamConfig.source === 'gfn' ? {
            ...StreamConfig[StreamConfig.source],
            source: StreamConfig.source,
            //@ts-ignore
            GFN: GFN
        } : {
            //@ts-ignore
            ...StreamConfig[StreamConfig.source],
            source: StreamConfig.source
        };

        return (
            <div
                style={{
                    position: 'absolute',
                    top: 0,
                    left: 0,
                    width: '100%',
                    height: '100%'
                }}
            >
                {/* Streamed app */}
                <AppStream
                    streamConfig={streamConfig}
                    onLoggedIn={(userId) => this.setState({ gfnUser: userId })}
                    onStarted={() => this._onStreamStarted()}
                    onFocus={() => this._handleAppStreamFocus()}
                    onBlur={() => this._handleAppStreamBlur()}
                    style={{
                        position: 'absolute',
                        left: 0,
                        top: 0,
                        height: `100%`,
                        width: `100%`,
                        visibility: this.state.gfnUser ? 'visible' : 'hidden'
                    }}
                    handleCustomEvent={(event) => this._handleCustomEvent(event)}
                />
            </div>
        );
    }
}
mastrimax commented 2 months ago

Thanks so much Matteo