Giter VIP home page Giter VIP logo

create-react-app-typescript-babylonjs's Introduction

This project was bootstrapped with Create React App (CRA) v4 and then babylonjs-react was added. For TypeScript

npx create-react-app your-babylonjs-app --template typescript

Add babylonjs dependencies:

yarn add react-babylonjs
yarn add @babylonjs/core
yarn add @babylonjs/gui
# loaders are optional
yarn add @babylonjs/loaders

All of the code for the site is in /src/App.tsx

In the project directory, you can run:

npm start / yarn start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

View live demo

create-react-app-typescript-babylonjs's People

Contributors

brianzinn avatar jeremy-coleman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

create-react-app-typescript-babylonjs's Issues

Specify cannon dependency

As is, it seems like the project won't compile correctly without adding cannon as a dependency. Maybe this step should be added to the .readme?

yarn add react-babylonjs
yarn add @babylonjs/core
yarn add @babylonjs/gui
# loaders are optional
yarn add @babylonjs/loaders
yarn add cannon

npm start fails to compile

Failed to compile.

./node_modules/react-babylonjs/dist/react-babylonjs.js
Module not found: Can't resolve '@react-spring/animated' in 'C:\Users\******\Documents\ReactBabylonjsTest\node_modules\react-babylonjs\dist'

Steps to reproduce:

  1. Clone repo
  2. npm install
  3. npm start

diffuseTexture

Hi, could you help me.
I'm new to Babylonjs.
I would like to know how to add diffuseTexture to the material.

<standardMaterial name='material1' specularPower={16} diffuseColor={Color3.Black()} emissiveColor={new Color3(0.5, 0.5, 0.5)} reflectionFresnelParameters={FresnelParameters.Parse({ isEnabled: true, leftColor: [1, 1, 1], rightColor: [0, 0, 0], bias: 0.1, power: 1 })} diffuseTexture = {????} />

https://github.com/brianzinn/create-react-app-typescript-babylonjs/blob/141ede2e33a88e9c112f9a0dcc1bc292223b4dad/src/App.tsx

error TS2403: Subsequent variable declarations must have the same type.

I've just clone the site, and did "yarn install" and I get the following error:

E:\Files\playground\babylonjs-site\node_modules@types\react-dom\node_modules@types\react\index.d.ts
(3636,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'DetailedHTMLProps<AnchorHTMLAttributes, HTMLAnchorElement>', but here has type 'DetailedHTMLProps<AnchorHTMLAttributes, HTMLAnchorElement>'.

I also tried to start with a fresh "create-react-app" and adding babylonjs, but I get a similar error:
E:/Files/playground/babylon-starter/node_modules/babylonjs/babylon.d.ts
(299,5): All declarations of 'hasOrientation' must have identical modifiers.

Note: I also tried doing with "NPM Install"

Any ideas why this could be happening.

TypeError: Cannot assign to read only property 'jsx' of object '#<Object>'

I ran the following commands:

git clone git clone [email protected]:brianzinn/create-react-app-typescript-babylonjs.git
cd create-react-app-typescript-babylonjs
pnpm install
npm start

I got the following output & error:

> [email protected] start
> react-scripts start

/Users/[...]/demo/node_modules/.pnpm/[email protected][email protected]/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js:239
      appTsConfig.compilerOptions[option] = value;
                                          ^

TypeError: Cannot assign to read only property 'jsx' of object '#<Object>'
    at verifyTypeScriptSetup (/Users/[...]/demo/node_modules/.pnpm/[email protected][email protected]/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js:239:43)
    at Object.<anonymous> (/Users/[...]/demo/node_modules/.pnpm/[email protected][email protected]/node_modules/react-scripts/scripts/start.js:31:1)
    at Module._compile (node:internal/modules/cjs/loader:1097:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47

Offscreen canvas

Any luck with offscreen canvases?
I modified my component so I'm not using the canvas before I transfer to offscreen. That part seems to work, but if I try to use any SceneLoader on the worker thread I am getting this error:
Uncaught (in promise) ReferenceError: window is not defined at Function.e._ReturnFullUrlLocation (babylon.js:16)

I don't get that error if I use NullEngine. Deltakosh is loading assets just fine in the demo which makes me think this must be something specific to webpack/typescript. Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.