Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add React Native for macOS support. #593

Closed
wants to merge 0 commits into from

Conversation

jihoobyeon
Copy link

@jihoobyeon jihoobyeon commented Jul 31, 2023

Describe the change

We can now run BabylonReactNative on macOS.

plus additional class component support - Higher-order component withEngine and Prop type for class WithEngineProps added.

usage:

import React from 'react';
import { View } from 'react-native';
import { Camera, Scene } from '@babylonjs/core';
import { EngineView, withEngine, WithEngineProps } from '@babylonjs/react-native';

class App extends React.Component<WithEngineProps, { camera: Camera | undefined }> {
    constructor(props: WithEngineProps) {
        super(props);
        this.state = { camera: undefined };
    }

    async componentDidMount() {
        while (!this.props.engine) await new Promise((_: any) => setTimeout(_, 100));

        const scene = new Scene(this.props.engine);
        scene.createDefaultCamera(true);

        const sphere = MeshBuilder.CreateSphere('sphere', { diameter: 1 }, scene);
        const camera = scene.activeCamera!;
        this.setState({ camera });
    }

    componentWillUnmount() { this.props.engine?.dispose(); }

    render() {
        return (
            <View style={{ flex: 1 }}>
                <EngineView style={{ flex: 1 }} camera={ this.state.camera } />
            </View>
        );
    }
}

export default withEngine(App);

Screenshots

스크린샷 2023-07-31 오후 6 18 21

Documentation

Have you updated the documentation to reflect your changes? Yes

Testing

Have you tested the final iteration of your changes? Yes

@jihoobyeon
Copy link
Author

@jihoobyeon please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

@matthargett
Copy link

looks like build pipeline locked up? what needs to be done, beyond fixing the branch conflicts for this to be merged? It looks like we'll need to do a few of these things to support visionOS as well.

@bghgary
Copy link
Contributor

bghgary commented Dec 4, 2023

I would say it at least needs a full code review from the team and infrastructure to make sure it stays working.

See the original forum post for context: https://forum.babylonjs.com/t/im-trying-to-make-babylonreactnative-to-work-on-macos/39178

As for visionOS, maybe @CedricGuillemet has thoughts.

@jihoobyeon
Copy link
Author

I was busy for working at other part of my app, so I almost forgot about it! Thanks for reminding me @matthargett :)

And @bghgary, When your team will do full code review?
Actually this is my first time to contribute to big open source like this, so I'm little nervous; I hope I did not made any mistake!

@bghgary
Copy link
Contributor

bghgary commented Dec 13, 2023

When your team will do full code review?

It's a bit hard to do this since it's a change that we probably need to try locally before it will make sense. It might also be good to add infrastructure for macOS (CI, etc., build for macOS at a minimum) before we review the changes.

Actually this is my first time to contribute to big open source like this, so I'm little nervous; I hope I did not made any mistake!

No worries. Thanks for spending time contributing!

@Saadnajmi
Copy link

When your team will do full code review?

It's a bit hard to do this since it's a change that we probably need to try locally before it will make sense. It might also be good to add infrastructure for macOS (CI, etc., build for macOS at a minimum) before we review the changes.

Actually this is my first time to contribute to big open source like this, so I'm little nervous; I hope I did not made any mistake!

No worries. Thanks for spending time contributing!

Hi! I'm unfamiliar with the project, but I am excited to see more macOS support across packages! For macOS CI, have you considered using React Native Test App as your example app / playground? It's basically a template app that reduces the boiler plate as much as possible, targets multiple React Native versions, and has macOS and Windows support built in. If the playground was updated to use react-native-test-app, adding macOS to it and CI should be a breeze.

[BabylonNativeInterop updateView:self];
}

#ifndef TARGET_OS_OSX

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if !TARGET_OS_OSX would be better here

@ryantrem
Copy link
Member

For macOS CI, have you considered using React Native Test App as your example app / playground? It's basically a template app that reduces the boiler plate as much as possible, targets multiple React Native versions, and has macOS and Windows support built in. If the playground was updated to use react-native-test-app, adding macOS to it and CI should be a breeze.

I was not aware of this. It looks pretty cool. Seems like it could help with reducing maintenance cost of the test app, and make it easier to add an additional platform (MacOS).

@CedricGuillemet
Copy link
Contributor

React Native Test App

I've open an issue to keep track #632

@kelset
Copy link
Contributor

kelset commented Jan 18, 2024

@CedricGuillemet I forgot to post here, but I chatted with Ryan over on Teams and I'll be attempting to add RNTA to this repo myself soon-ish. We ironed out a few things over the last few days and I think I'm very close to be able to start on this 👍 (I'll also post a comment in the issue you made)

@kelset
Copy link
Contributor

kelset commented Feb 22, 2024

update, here's the PR adding a RNTA based example app: #641

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants