Giter Club home page Giter Club logo

react-babylonjs's Introduction

react-babylonjs

'react-babylonjs' integrates the Babylon.js real time 3D engine with React

react-babylonjs lets you build your scene and components using a familiar declarative syntax with the benefits of reusable components and hooks. The Babylon.js API is mostly covered declaratively thanks to code generation and even custom props allow you to declaratively add shadows, physics, 3D models, attach 2D/3D UI to meshes, etc.

Fully supports hooks. Full support for TypeScript with auto-completion on elements and compile time checks. Context API and hooks provide easy access to Scene/Engine/Canvas.

NPM version NPM downloads

How to Install

$ npm i react-babylonjs @babylonjs/core @babylonjs/gui

OR

$ yarn add react-babylonjs @babylonjs/core @babylonjs/gui

No third party dependencies outside of React + babylon.js

Babylon.js 4.x

Babylon.js 4.x is not currently compatible (follow peer dependency warnings) with @latest version. The last version compatible with both 4.x and 5.x was 3.0.31.

# Babylonjs.4.x only
$ yarn add [email protected]

Models

If you are using 3D models ensure you have added the @babylonjs/loaders NPM. It is not a direct dependency, but registers loaders as plugins via imports with side effects:

  • Register all model types import @babylonjs/loaders;
  • OBJ import '@babylonjs/loaders/OBJ';
  • glTF import '@babylonjs/loaders/glTF';

(more instructions on model loading in ES6 here )

Usage Styles

react-babylonjs tries to remain unopinionated about how you integrate BabylonJS with React. This module provides a 100% declarative option and/or you can customise by adding code. There are lots of escape hatches where you can switch to imperative coding and direct access to objects.

Connecting the pieces

If you are new to React or babylon.js (or both) there is some learning ahead. The babylon.js documentation site is really useful for understanding the basics of lighting, cameras, etc. This project aims to make easy to integrate those into React using JSX.

Here we re-use a SpinningBox component that can be clicked or hovered. These reusable components can be used to compose a declarative scene. We are using hooks for the clicking, hovering and spinning.

Connecting the pieces

import React, { useRef, useState } from 'react'
import {
  Engine,
  Scene,
  useBeforeRender,
  useClick,
  useHover,
} from 'react-babylonjs'
import { Vector3, Color3 } from '@babylonjs/core'

const DefaultScale = new Vector3(1, 1, 1)
const BiggerScale = new Vector3(1.25, 1.25, 1.25)

const SpinningBox = (props) => {
  // access Babylon scene objects with same React hook as regular DOM elements
  const boxRef = useRef(null)

  const [clicked, setClicked] = useState(false)
  useClick(() => setClicked((clicked) => !clicked), boxRef)

  const [hovered, setHovered] = useState(false)
  useHover(
    () => setHovered(true),
    () => setHovered(false),
    boxRef
  )

  // This will rotate the box on every Babylon frame.
  const rpm = 5
  useBeforeRender((scene) => {
    if (boxRef.current) {
      // Delta time smoothes the animation.
      var deltaTimeInMillis = scene.getEngine().getDeltaTime()
      boxRef.current.rotation.y +=
        (rpm / 60) * Math.PI * 2 * (deltaTimeInMillis / 1000)
    }
  })

  return (
    <box
      name={props.name}
      ref={boxRef}
      size={2}
      position={props.position}
      scaling={clicked ? BiggerScale : DefaultScale}
    >
      <standardMaterial
        name={`${props.name}-mat`}
        diffuseColor={hovered ? props.hoveredColor : props.color}
        specularColor={Color3.Black()}
      />
    </box>
  )
}

export const SceneWithSpinningBoxes = () => (
  <div>
    <Engine antialias adaptToDeviceRatio canvasId="babylonJS">
      <Scene>
        <arcRotateCamera
          name="camera1"
          target={Vector3.Zero()}
          alpha={Math.PI / 2}
          beta={Math.PI / 4}
          radius={8}
        />
        <hemisphericLight
          name="light1"
          intensity={0.7}
          direction={Vector3.Up()}
        />
        <SpinningBox
          name="left"
          position={new Vector3(-2, 0, 0)}
          color={Color3.FromHexString('#EEB5EB')}
          hoveredColor={Color3.FromHexString('#C26DBC')}
        />
        <SpinningBox
          name="right"
          position={new Vector3(2, 0, 0)}
          color={Color3.FromHexString('#C8F4F9')}
          hoveredColor={Color3.FromHexString('#3CACAE')}
        />
      </Scene>
    </Engine>
  </div>
)

code sandbox for above

Hooks, Shadows and Physics (and optionally TypeScript, too)

You can declaratively use many features together - here only the button click handler actually has any code - and we have declarative Physics, GUI, Lighting and Shadows. demo: Bouncy demo

import React, { useRef } from 'react';
// full code at https://github.com/brianzinn/create-react-app-typescript-babylonjs

const App: React.FC = () => {
  let sphereRef = useRef<Nullable<Mesh>>();

  const onButtonClicked = () => {
    if (sphereRef.current) {
      sphereRef.current.physicsImpostor!.applyImpulse(
        Vector3.Up().scale(10),
        sphereRef.current.getAbsolutePosition()
      );
    }
  };

  return (
    <Engine antialias={true} adaptToDeviceRatio={true} canvasId="sample-canvas">
      <Scene enablePhysics={[gravityVector, new CannonJSPlugin()]}>
        <arcRotateCamera name="arc" target={ new Vector3(0, 1, 0) }
          alpha={-Math.PI / 2} beta={(0.5 + (Math.PI / 4))}
          radius={4} minZ={0.001} wheelPrecision={50}
          lowerRadiusLimit={8} upperRadiusLimit={20} upperBetaLimit={Math.PI / 2}
        />
        <hemisphericLight name='hemi' direction={new Vector3(0, -1, 0)} intensity={0.8} />
        <directionalLight name="shadow-light" setDirectionToTarget={[Vector3.Zero()]} direction={Vector3.Zero()} position = {new Vector3(-40, 30, -40)}
          intensity={0.4} shadowMinZ={1} shadowMaxZ={2500}>
          <shadowGenerator mapSize={1024} useBlurExponentialShadowMap={true} blurKernel={32}
            shadowCasters={["sphere1", "dialog"]} forceBackFacesOnly={true} depthScale={100}
          />
        </directionalLight>
        <sphere ref={sphereRef} name="sphere1" diameter={2} segments={16} position={new Vector3(0, 2.5, 0)}>
          <physicsImpostor type={PhysicsImpostor.SphereImpostor} _options={{
              mass: 1,
              restitution: 0.9
          }} />
          <plane name="dialog" size={2} position={new Vector3(0, 1.5, 0)}>
            <advancedDynamicTexture name="dialogTexture" height={1024} width={1024} createForParentMesh={true} hasAlpha={true}>
              <rectangle name="rect-1" height={0.5} width={1} thickness={12} cornerRadius={12}>
                  <rectangle>
                    <babylon-button name="close-icon" background="green" onPointerDownObservable={onButtonClicked}>
                      <textBlock text={'\uf00d click me'} fontFamily="FontAwesome" fontStyle="bold" fontSize={200} color="white" />
                    </babylon-button>
                  </rectangle>
              </rectangle>
            </advancedDynamicTexture>
          </plane>
        </sphere>

        <ground name="ground1" width={10} height={10} subdivisions={2} receiveShadows={true}>
          <physicsImpostor type={PhysicsImpostor.BoxImpostor} _options={{
              mass: 0,
              restitution: 0.9
          }} />
        </ground>
        <vrExperienceHelper webVROptions={{ createDeviceOrientationCamera: false }} enableInteractions={true} />
      </Scene>
    </Engine>
  );
}

React Native

No online examples for native, but you can integrate using EngineCanvasContext.Provider:

import React, { useState } from 'react';
import { View } from 'react-native';

import { EngineView, useEngine } from '@babylonjs/react-native';
import { Camera } from '@babylonjs/core';
import { EngineCanvasContext, Scene } from 'react-babylonjs';

const EngineScreen: FunctionComponent<ViewProps> = (props: ViewProps) => {

  const engine = useEngine();
  const [camera, setCamera] = useState<Camera>();

  return (
    <View style={props.style}>
      <EngineCanvasContext.Provider value={{ engine, canvas: null }}>
        {engine &&
          <Scene>
            <arcRotateCamera
              name="camera1"
              onCreated={camera => setCamera(camera)}
            />
            <hemisphericLight name="light1" />
            { /* rest of declarative scene/components here */ }
          </Scene>
        }
      </EngineCanvasContext.Provider>
      <EngineView camera={camera} displayFrameRate={true} />
    </View>
  );
};

Developer Experience and Fast Refresh

With declarative (TSX/JSX) coding and fast refresh, you experience the same development workflow in 3D - ie: save changes in your editor and see them immediately in the browser. Note in this capture when the light is dimmed that the state changes persist even after code updates and scene refresh.

babylon.js Fast Refresh

API

This project uses code generation, which allows fast reconciliation and excellent typings support.

react-babylonjs API

Release History and changes

Changes and commit history

Storybook

~50 sample web pages with viewable source code on github pages.

Example Projects

Contributors

Thanks also to all the people who have contributed with issues/questions/discussions. All the great ideas and requests are why this project evolved beyond an experiment.

Made with ♥

react-babylonjs's People

Contributors

benallfree avatar brianzinn avatar coder89 avatar dennemark avatar flostellbrink avatar flyskywhy avatar hackmushroom avatar hookex avatar hugomcphee avatar kencyke avatar konsumer avatar larshoeg avatar nturley avatar pjoe avatar sevaseva avatar sunyanlbj23 avatar terry-gyde avatar vimcaw avatar voronp 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

react-babylonjs's Issues

Add a declarative way to define render loops

It seems to me that currently the only way to add a function to execute on every render is to do

function onSceneMount(e) {
  const { canvas, scene } = e

  // Your code here (ie: playground code could go here)...  
  scene.getEngine().runRenderLoop(() => {
      if (scene) {
          scene.render();
      }
  });
}

function NonDeclarative() {
  return (
    <Engine canvasId="sample-canvas">
      <Scene onSceneMount={onSceneMount} />
    </Engine>
  );
}

This is problematic not just because it is verbose, but also because this way render loop functions need to be added/changed/cleaned up imperatively by hand. I think a better way would be to control the lifecycle of render loops declaratively through the use of react hooks.

I propose adding a useRenderLoop() hook to the react-babylonjs API which would look something like this:

function Declarative() {
  useRenderLoop((engine /* or properties relevant to rendering like deltaTime */) => {
    // ...
  })

  return (
    <>
    // ...
    </>
  );
}

This would make adding render loops much less verbose, but more importantly it would allow us to declaratively manage replacing render loops on change or cleaning them up when a component unmounts.

Declarative Entities

I'm trying to make a simple character-chooser screen, with 3 characters (colored spheres, for now) and I can't seem to load them from imported definitions. I am trying to have all the characters/models in their own files, so I can just load the entities I need for a scene. I imagine that each component should track it's own position and visual state (like which animation to play, etc) via props, and the environment will set positions, lighting, terrain, etc. Here is an example, with just one:

App.js

import React from 'react'

import { Scene, FreeCamera, HemisphericLight } from 'react-babylonjs'
import { Vector3 } from 'babylonjs'

import PlayerFire from './player/PlayerFire'

const App = () => (
  <Scene id='character-choose'>
    <FreeCamera name='camera1' position={new Vector3(0, 5, -10)} target={Vector3.Zero()} />
    <HemisphericLight name='light1' intensity={0.7} direction={Vector3.Up()} />
    <PlayerFire position={Vector3(0, 1, 0)} />
  </Scene>
)

export default App

PlayerFire.js

import React from 'react'

import { Sphere, StandardMaterial } from 'react-babylonjs'
import { Vector3, Color3 } from 'babylonjs'

const PlayerFire = ({ position = Vector3.Zero() }) => (
  <Sphere name='PlayerFire' diameter={2} segments={16} position={position}>
    <StandardMaterial diffuseColor={Color3.Red()} specularColor={Color3.Black()} />
  </Sphere>
)

export default PlayerFire

I get this error and a blank screen:

no onSceneMount() or createCamera() defined.  Require camera declaration.

If I just do all the code inline like this, it works fine:

import React from 'react'

import { Scene, FreeCamera, HemisphericLight, Sphere, StandardMaterial } from 'react-babylonjs'
import { Vector3, Color3 } from 'babylonjs'

const App = () => (
  <Scene id='character-choose'>
    <FreeCamera name='camera1' position={new Vector3(0, 5, -10)} target={Vector3.Zero()} />
    <HemisphericLight name='light1' intensity={0.7} direction={Vector3.Up()} />
    <Sphere name='PlayerFire' diameter={2} segments={16} position={new Vector3(0, 1, 0)}>
      <StandardMaterial diffuseColor={Color3.Red()} specularColor={Color3.Black()} />
    </Sphere>
  </Scene>
)

export default App

Is context not working how I expect, or am I doing something else wrong?

Model is not recognized

I've been trying to load a .glb file using a Model just like this example: https://brianzinn.github.io/create-react-app-babylonjs/withModel

But when I do something similar in my react project, the Model component I've exported from the react-babylonjs package is a string, and of course I can't add any attribute, like rootUrl to load the file.

Could you please tell which is the best way to export the Model inside a Scene (I'm using the Scene of react-babylonjs under the alias ReactBabylonJsScene) just like in the example?

The way I'm importing the components is the following:

import { Scene as BabylonScene, Vector3, HemisphericLight, ArcRotateCamera } from 'babylonjs';
import { Scene as ReactBabylonJsScene, Model  } from 'react-babylonjs';

This is my package.json:
{
"name": "cerf-catalog-parts",
"version": "0.0.1",
"private": true,
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"build": "gulp bundle",
"clean": "gulp clean",
"test": "gulp test"
},
"dependencies": {
"@microsoft/sp-core-library": "1.7.0",
"@microsoft/sp-lodash-subset": "1.7.0",
"@microsoft/sp-office-ui-fabric-core": "1.7.0",
"@microsoft/sp-webpart-base": "1.7.0",
"@pnp/common": "^1.2.9",
"@pnp/logging": "^1.2.9",
"@pnp/odata": "^1.2.9",
"@pnp/sp": "^1.2.9",
"@pnp/spfx-controls-react": "^1.11.0",
"@types/es6-promise": "0.0.33",
"@types/react": "16.4.2",
"@types/react-dom": "16.0.5",
"@types/webpack-env": "1.13.1",
"babylonjs": "^3.3.0",
"babylonjs-gui": "^3.3.0",
"babylonjs-loaders": "^3.3.0",
"babylonjs-viewer": "^3.3.0",
"react": "16.3.2",
"react-babylonjs": "^1.0.3",
"react-dom": "16.3.2"
},
"devDependencies": {
"@microsoft/sp-build-web": "1.7.0",
"@microsoft/sp-tslint-rules": "1.7.0",
"@microsoft/sp-module-interfaces": "1.7.0",
"@microsoft/sp-webpart-workbench": "1.7.0",
"gulp": "~3.9.1",
"@types/chai": "3.4.34",
"@types/mocha": "2.2.38",
"ajv": "~5.2.2"
}
}

Hope you can give me a hand with this!

Cheers.

How to get the loading progress of the Model element?

Hi Brian, thank your great work, which helps me a lot. I'm a newcomer of babylon.js, same as README.md, I use the Model element to load a model, but wonder how to get the loading progress of the model.

I know, in native babylon.js,

BABYLON.SceneLoader.Load(Scenename, name.babylon, engine, function1, function2);

it's possible to get loading progress by function2 arguments, but in the Model element, how should I do?

<Model
  rotation={new Vector3(0, this.state.modelRotationY, 0)} position={new Vector3(0, 1, 0)}
  rootUrl={`${baseUrl}BoomBox/glTF/`} sceneFilename="BoomBox.gltf"
  scaling={new Vector3(20, 20, 20)}
/>

Attach 2D UI element to Mesh

I want to achieve this as per the official docs:
https://www.babylonjs-playground.com/#XCPP9Y#16

Normally you would use linkWithMesh() to link the rectangle with the mesh. How would I achieve this? I see there may be a prop attachToMeshesByName?

<Scene>
  <adtFullscreenUi name="ui1">
    <freeCamera name="camera1" position={new Vector3(0, 2, -10)} target={Vector3.Zero()} />
    <sphere name="sphere1" diameter={2} segments={4} position={new Vector3(2, 1, 0)} />

    <rectangle
      key={"label"}
      name={"label for Sphere"}
      background={"black"}
      height="30px"
      alpha={0.5}
      width="100px"
      cornerRadius={20}
      thickness={1}
      linkOffsetY={30}
      top={"10%"}
      attachToMeshesByName={"sphere1"}
    >
      <textBlock name={`sphere-text`} text="Sphere" color="White" />
    </rectangle>

  </adtFullscreenUi>
</Scene>

How to set some textures to the material?

Hi Brian, thanks for your kind help before. I try to set some textures to the material but get some errors, I have tried to find any demo but get nothing, Is there something wrong with my approach?

<Box
  name="ground"
  width={size}
  depth={size}
  height={thickness}
>
  <StandardMaterial
    name="ground material"
    useParallax
    useParallaxOcclusion
    specularColor={new Color4(0.9, 0.9, 0.9, 0.5)}
    position={Vector3.Zero()}
  >
    <diffuseTexture uScale={50} vScale={50} url="http://localhost:8666/texture/floor.jpg" />
    <bumpTexture uScale={50} vScale={50} url="http://localhost:8666/texture/floor_bump.jpg" />
    <reflectionTexture
      mirrorPlane={new Plane(0, -1.0, 0, -2.0)}
      level={0.1}
      reflectionTexture={10}
    />
  </StandardMaterial>
</Box>

Error:

Uncaught Error: Cannot generate type 'diffuseTexture/diffuseTexture' inside 'react-babylonjs' (ie: no DOM rendering on HTMLCanvas)

GUI on map functions

GUI elements in adtFullscreenUi are created correctly only on first render, if initial array was changed, gui elements do not change.
So, I have this initial state

private lastId = -5;
///
this.state = {
      scenes: [
        {
          title: `title ${this.lastId}`,
          position: this.lastId,
          id: (this.lastId++).toString()
        },
        {
          title: `title ${this.lastId}`,
          position: this.lastId,
          id: (this.lastId++).toString()
        },
        {
          title: `title ${this.lastId}`,
          position: this.lastId,
          id: (this.lastId++).toString()
        }
      ],
    }

Sphere objects work correctly

{
  state.scenes.map(s => (
    <sphere
      key={s.id}
      name={s.title} diameter={1} segments={16} position={new Vector3(s.position, 0, 0)}>
    </sphere>
  ))
}

image

Now, I want to create more spheres

handleAdd() {
  this.setState(state => ({
    ...state,
    scenes: [
      ...state.scenes,
      {
        title: `title ${this.lastId}`,
        position: this.lastId,
        id: (this.lastId++).toString()
      }
    ]
  }));
}
///
<div>
  <button onClick={this.handleAdd}>Add</button>
</div>
{
  state.scenes.map(s =>
    <div key={s.id}>
      <button >{s.title}</button>
    </div>
  )
}

Spheres are created correctly
image

And now I want to place titles of all spheres on full screen UI

<adtFullscreenUi name="fullScreenUI">
  {
    state.scenes.map(s => (
      <textBlock top={s.position * 20} text={s.title} />
    ))
  }
</adtFullscreenUi>

But textBlocks are created only for initial three elements
image

Working example is available here https://github.com/CAPCHIK/create-react-app-typescript-babylonjs

How I can use dynamic GUI objects?

Overall Questions

Hey there, I think this project is great just have a few questions for clarifications and remarks.

  1. I'm new to react now so I'm wondering why the react reconciler is necessary for this project?

  2. I'm just wondering why this package uses react-spring, babylonjs has animations built in. Do the animations not work well with react? I just think since babylonjs is already a heavy package, the necessities to get it working with react should be as minimal as possible. Maybe if using react-spring it would be a plugin to react babylonjs or a submodule of it.

Opinions and Remarks

  1. I think the canvas should be decoupled from the engine, I'd like to use Engine and scene basically as a provider and place the canvas where I would like so that I can still grab context to the engine and scene when outside of canvas. As well, I'm not able to put html markup inside child of Engine, Scene etc I'm assuming this is because of react reconciler? That means I have two completely separate trees, one for html and one for babylonjs, which would become cumbersome for me since I can't inject pages from nextjs.

For example:
I'm using nextjs and would like to put the scene and engine in my _app.tsx but only want the canvas a certain width and placing html content into my pages as well as the markup inside to trigger objects.

Let me know your thoughts! :)

Set hostInstance.parent for child of Camera?

I guess this is more of a question,

Whats the best way to set a mesh's parent to a Camera?

Could a camera property be added to automatically set parent/children on the hostInstance?

With this code:

<FreeCamera
...

/>
  <Box .../>
</FreeCamera>

The Box will not have its position local to the camera.

Adding Material/Texture to Model

Hi! I'm currently trying to figure out how to use this package to import a few .obj files into my scene with a diffuse texture set at runtime. For normal geometry components I've been able to assign the texture like so:

<box name='box'>
    <standardMaterial name={'mat'} >
        <texture assignTo='diffuseTexture' url={'./image.jpg'} />
    </standardMaterial>
</box>

When I try this for Models however, it doesn't work and instead just ignores the standard material:

<model rootUrl={`./`} sceneFilename='model.obj'>
    <standardMaterial name={'mat'}>
        <texture assignTo='diffuseTexture' url={'./image.jpg'} />
    </standardMaterial>
</model>

Is there a possible way of doing this with this package? Thanks!

About react reconciler's commit and removeChild.

I have two problems during my development. And want to discuss with you how to resolve it.

1. commit to root container

Now, the Babylon element will be added to the scene in the createInstance() method. So before prepareForCommit(). All elements were added to the scene and can be seen.
I think they should be attached to the scene together at the same time as ReactDom.

Below is a bug about it. An animation start in onCreated() callback.
Between the element first time seen and animation begin to run, the time intervals for a long time.
Due to so many sync js code must be run after the onCreated() method.

## Create ui tree process
$$: 456.82421875ms element create:
$$: 1871.689208984375ms element begin animate
[Violation] 'requestAnimationFrame' handler took 152ms
## update ui tree process
$$: 6537.644287109375ms element create
$$: 6878.276123046875ms element begin animate
[Violation] 'requestAnimationFrame' handler took 65ms

2. Maybe RemoveChild needs recursion operation.

Case: some deep children can't be removed.

Could not figure out how to render a `Model` as in the README.md example

Hi there, thanks for this library! It's really cool. I can see myself using it a lot in the future :D

Only caveat is that I could not get a model to render, as I couldn't figure out a way to type it. I also had some difficulty finding how are you dealing and loading models in the code.

I was able to force it to type doing:

declare global {
  namespace JSX {
    interface IntrinsicElements {
      'model': any
    }
  }
}

In particular, my problem is that <model> is not being catched by react-reconciler:
Screen Shot 2019-12-29 at 09 27 38

Also, I tried it in uppercase (hacking through:
declare global { var Model: any namespace JSX { interface IntrinsicElements { 'Model': any } } }) but it wasn't enough (Model never gets imported and it fails in runtime).

Could you advice with a better example than the one found in the storybook? The use of WithModel and the hidden file outside of the story makes it a very hard example to follow. Let me know if I can help in any way.

Edges Rendering support

Hi Brian,

Just wanted to say thank you for this repo, it has been really nice to use!

I have an issue with edge rendering in that it doesn't allow me to call enableEdgesRendering() on a tiledGround for example.

When I put the following code in my scene:

<tiledGround name={"ground"} 
             onCreated={g => g.enableEdgesRendering()} 
             edgesWidth={8.0} 
             edgesColor={Color4.FromInts(0,0,0,0)}
             xmax={60} xmin={-60} zmax={60} zmin={-60}/>

I get the following console error in react-reconciler.development.js?c996:1824: Uncaught EdgesRenderer needs to be imported before as it contains a side-effect required by your code.

The only way around this that i've found is to manually add the tiled ground to the scene using raw babylon, and call enableEdgesRendering() etc on that object.

Are there any plans to support this declaratively in future? Or is there a way for me to extend the existing tiledGround component myself?

Thanks,
Kathan

Sprites and imperative/declarative mix

Hello,

I apologize in advance for the lengthy issue but I am very confused about this.

I need to use Sprites and I wanted to use react-babylonjs, but I can't figure out how to do it or if it's even possible. I understand from this thread that sprites might not be fully implemented yet (although "needs improvement" left me wondering), and that opened up a question in my mind about determining exactly what is implemented thus far.

I guess my big question is how to determine which Babylon JS classes I can implement in a JSX React-like fashion and which ones I must do imperatively. I haven't found a comprehensive list of components that react-babylonjs offers as wrappers for Babylon JS elements.

Here's an example of why I'm so confused. This example imports { Vector3, Color3, Color4, Animation, ExponentialEase, EasingFunction, Texture } from '@babylonjs/core' and imports only Engine and Scene from react-babylonjs.

However, this example also implements the following Babylon JS classes in JSX/React component style without actually importing them:

<arcRotateCamera/>
<arcRotateCamera/>
<box/>
<standardMaterial/>
<plane/>
<rectangle/>
<stackPanel/>
<babylon-button/>
<advancedDynamicTexture/>
<vrExperienceHelper/>

Where are these coming from if they aren't imported? I see that a custom Components folder is being exported but the files in there don't appear as I would expect:

image

Another confusing example: Importing StandardMaterial to use it imperatively but then <standardMaterial/> is used decralatively in the React tree. What makes StandardMaterial different from <standardMaterial/>, and where does <standardMaterial/> come from?

I want to know so I can look at all the other available React components.

I tried to use <sprite/> and <spriteManager/> and it was a big fail.

Compounding my confusion is the fact that these components start with a lowercase letter. React docs say "User-Defined Components Must Be Capitalized".

Thank you for any clarification you can provide!

Edit: linked to note about sprites needing improvement: #6 (comment)

Filed to compile

My import to react:
import {Engine, Scene, FreeCamera, HemisphericLight, Sphere, Ground} from 'react-babylonjs';

My Code:

<Engine canvasId="render-labyrinth"> <Scene> <FreeCamera name="player" position={new Vector3(0, 5, -10)} target={Vector3.Zero()}/> <HemisphericLight name="light" intensity={0.7} direction={Vector3.Up()}/> <Sphere name="sphere1" diameter={2} segments={16} position={new Vector3(0, 1, 0)} /> <Ground name="ground1" width={6} height={6} subdivisions={2} /> </Scene> </Engine>

Error in terminal:

./node_modules/react-babylonjs/dist/react-babylonjs.es5.js
Module not found: Can't resolve 'babylonjs-gui' in '...\node_modules\react-babylonjs\dist'

How do you dispose of the engine?

Hi,

I'm looking for a way to dispose of the engine once my component containing it unmounts. I thought this might be done by default but it looks like it's not. Is there anyway to access the engine object from say a useEffect hook in the component the engine is declared in?

Babylon.js 4.0 support

Hi,

I tried to use your default react-babylonjs js template with the upgraded babylon.js 4.0.3 packages, which fails with a TypeError: "Cannot read property 'x' of undefined" for each child of the scene. I am not sure if this is a bug, but I guess 4.0 of babylon.js is currently not supported?

Thank you!

[discussion and proposal]: Animation

I would like to have a few full discussions with you and listen to your advice before we start coding.

Maybe we can do it in the following order.

  • discuss
  • form a proposal
  • add it to the roadmap
  • start to code

Animation

Declarative programming paradigm is not easy for animations. I would like to simplify it.
There are there ways to animate.

1. use requestAnimationFrame() and setState()

Each frame update involves a change in the state of the react tree.
This approach should have serious performance drawbacks.

2. use Babylonjs node and Babylonjs Animation

This update restricts the impact to a node. So there are performance advantages.
In this way, there is a bit more redundant code.
Maybe there is a way to simplify it with react features

3. with react-spring

I'm trying.
https://www.react-spring.io/docs/props/performance
https://github.com/react-spring/react-spring/blob/master/src/targets/three/index.ts

[large-]data-driven animation

todo

Can this be used to create an editor

Can this be used to create an editor that enables to add/edit objects, models, and read/update their various properties possbily presenting a panel like ui?

Main thing I wonder is if it is possible to see the properties of models, especially model files? I saw a <Model /> component. After loading a model file with it, is it holding all of the model file properties inside the component's state, or elsewhere?
Anywhere these model properties can be taken to a store, to a state and some ui panel can be dedicated to view and edit them.

How to use special shaders, like FresnelParameters

Firstly: wow what a cool project. I love it.

I've been going over the demos and reading the source. I'm curious how you do special shaders. I'd love to see a react implementation of some of the BPR or Fresnel Demos!

like this (Frresnel):
https://www.babylonjs-playground.com/#AQZJ4C#0

also this (PBR):
https://www.babylonjs.com/demos/pbr/

if I can figure it out first I'll post the solution here and make a PR for your demo app, if you already know how to do this, can you reply? thank you!

question

Hi
I have a question about react-babylon component : is it possible to convert a 2d line in 3d wall like ExtrudeBufferGeometry in three.js which extrudes a 2D shape to a 3D geometry and I think the link is broken : https://brianzinn.github.io/react-babylonjs/

react-spring/animated no work with last update

Good afternoon

The latest release of react-spring/animated no work

Error with react-spring/animated

Attempted import error: 'extendAnimated' is not exported from '@react-spring/animated' (imported as '$r').

It's possible upgrait it to animated instance extendAnimated

Errors when building current master

When trying to build current master 3b99df6 I got several errors.

I had to update typescript to latest (3.2.2) and do a number of fixes:

diff --git a/package.json b/package.json
index 77cc6e8..55fe9cd 100644
--- a/package.json
+++ b/package.json
@@ -112,7 +112,7 @@
     "tslint-config-prettier": "^1.1.0",
     "tslint-config-standard": "^6.0.0",
     "typedoc": "^0.11.1",
-    "typescript": "2.9.2",
+    "typescript": "3.2.2",
     "validate-commit-msg": "^2.12.2"
   },
   "peerDependencies": {
diff --git a/src/Engine.tsx b/src/Engine.tsx
index 5384c75..0810013 100644
--- a/src/Engine.tsx
+++ b/src/Engine.tsx
@@ -29,7 +29,10 @@ export function withBabylonJS<
   return function BoundComponent(props: R) {
     return (
       <BabylonJSContext.Consumer>
-        {ctx => <Component {...props} babylonJSContext={ctx} />}
+        {ctx => {
+          const newProps = {...props, babylonJSContext: ctx} as unknown as P;
+          return <Component {...newProps} />
+          }}
       </BabylonJSContext.Consumer>
     );
   };
@@ -67,20 +70,19 @@ export type EngineState = {
 }

 class Engine extends React.Component<EngineProps, EngineState> {
+  state = {
+    canRender: false
+  }

-  private _engine?: BABYLON.Nullable<BABYLON.Engine> = null;
+  private _engine?: BABYLON.Nullable<BabylonJSEngine> = null;
   private _canvas: BABYLON.Nullable<HTMLCanvasElement | WebGLRenderingContext> = null;

   constructor(props: EngineProps) {
     super(props);
-
-    this.state = {
-      canRender: false
-    };
   }

   componentDidMount() {
-    this._engine = new BABYLON.Engine(
+    this._engine = new BabylonJSEngine(
       this._canvas,
       this.props.antialias === true ? true : false, // default false
       this.props.engineOptions,
@@ -93,7 +95,7 @@ class Engine extends React.Component<EngineProps, EngineState> {
       })
     })

-    this._engine.onContextLostObservable.add((eventData: BABYLON.Engine) => {
+    this._engine.onContextLostObservable.add((eventData: BabylonJSEngine) => {
       console.log('context loss observable from Engine: ', eventData);
     })

diff --git a/src/Scene.tsx b/src/Scene.tsx
index 2576e1f..127fd8e 100644
--- a/src/Scene.tsx
+++ b/src/Scene.tsx
@@ -44,7 +44,10 @@ export function withScene<
   return function BoundComponent(props: R) {
     return (
       <SceneContext.Consumer>
-        {ctx => <Component {...props} sceneContext={ctx} />}
+        {ctx => {
+          const newProps = {...props, sceneContext: ctx} as unknown as P;
+          return <Component {...newProps} />
+          }}
       </SceneContext.Consumer>
     );
   };
diff --git a/tools/generate-code.ts b/tools/generate-code.ts
index f18c712..f133ade 100644
--- a/tools/generate-code.ts
+++ b/tools/generate-code.ts
@@ -22,6 +22,11 @@ const REACT_EXPORTS : Set<string> = new Set<string>();
 // These are the base/factory classes we used to generate everything.  Comment them out to skip generation (you must keep "Node", though)
 let classesOfInterest : Map<String, ClassNameSpaceTuple | undefined> = new Map<String, ClassNameSpaceTuple | undefined>();

+const excludedClasses = [
+  // SrollBar is not properly exported from babylonjs so have to skip it
+  "ScrollBar"
+];
+
 // always needed:
 classesOfInterest.set("Node", undefined)

@@ -652,7 +657,11 @@ const createClassesInheritedFrom = (sourceFile: SourceFile, classNamespaceTuple:
   console.log(`Building ${derivedClassesOrdered.size} ${baseClassName}s: `)

   derivedClassesOrdered.forEach((derivedClassDeclaration: ClassDeclaration) => {
-
+    if( excludedClasses.includes(derivedClassDeclaration.getName()!) ) {
+      console.log(` > Skipping: ${derivedClassDeclaration.getName()}`)
+      return
+    }
+
     REACT_EXPORTS.add(derivedClassDeclaration.getName()!)

     const newClassDeclaration = createClassDeclaration(derivedClassDeclaration, baseClassDeclaration, classNamespaceTuple.namespace, sourceFile, extra);
diff --git a/yarn.lock b/yarn.lock
index 58ead5e..0c2da22 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4751,11 +4751,7 @@ [email protected]:
   version "2.7.2"
   resolved "http://registry.npmjs.org/typescript/-/typescript-2.7.2.tgz#2d615a1ef4aee4f574425cdff7026edf81919836"

-[email protected]:
-  version "2.9.2"
-  resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.9.2.tgz#1cbf61d05d6b96269244eb6a3bce4bd914e0f00c"
-
-typescript@^3.0.1:
+[email protected], typescript@^3.0.1:
   version "3.2.2"
   resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.2.2.tgz#fe8101c46aa123f8353523ebdcf5730c2ae493e5"

I also tried updating to latest babylonjs (4.0.0-alpha.19) but that resulted in even more errors :S

[discussion and proposal]: InstancesMesh

@brianzinn

Hi, brianzinn. I'm busy with my works these days. But we can start to design InstancesMesh API.

Why use InstancesMesh

  • Better Performace. This API can draw large amounts of meshes of the same geometry by using only one GPU API call.
    (Have you ever compared the performance of the MergedMesh and InstancesMesh?)

Features

  • pass Instances data to one component. (InstancesData's length maybe change when update)
  • property: position、scale、color、alpha
  • events: click、[hover]. (The number of event registrations must be small)

API suggestion

// component name
<Instances/>

interface InstanceData {
    position: [number, number, number],
    scaling?: [number, number, number],
    color?: [number, number, number],
    alpha?: number,
}

interface InstancesProps {
    mesh: Babylon.Mesh | Ref<Babylon.Mesh>,
    data: InstanceData[],
    onClick: Function;
}

How can we change shadowGenerator darkness value?

Hello,

I'm new on react-babyonjs and it feels very promising! But starting simple on changing the value of the shadow's generator darkness semme's not working.

<Scene>
                <arcRotateCamera name="arc" target={new Vector3(0, 1, 0)}
                                 alpha={-Math.PI / 2} beta={(0.5 + (Math.PI / 4))}
                                 radius={4} minZ={0.001} wheelPrecision={50}
                                 lowerRadiusLimit={8} upperRadiusLimit={20} upperBetaLimit={Math.PI / 2}
                                 inertia={0.5}
                                 inertialPanningX={0} inertialPanningY={0}
                                 speed={10}
                />
                <hemisphericLight name='hemi' direction={new Vector3(0, -1, 0)} intensity={0.8}/>
                <directionalLight name="shadow-light" setDirectionToTarget={[Vector3.Zero()]} direction={Vector3.Zero()}
                                  position={new Vector3(-40, 30, -40)}
                                  intensity={1} shadowMinZ={1} shadowMaxZ={2500}>

                    <shadowGenerator mapSize={1024} useBlurExponentialShadowMap={true} blurKernel={32}
                                     shadowCasters={["sphere1"]} forceBackFacesOnly={true} depthScale={100}
                                     blurScale={1} setDarkness={0.5}
                    />

                </directionalLight>
                <sphere name="sphere1" diameter={2} segments={16} position={new Vector3(0, 2.5, 0)}>
                </sphere>

                <ground name="ground1" width={10} height={10} subdivisions={2} receiveShadows={true}>
                </ground>
            </Scene>

How i'm supposed to do in order to change the darkness value?
Is there something I missed?

Thank you

I'm urge to use InstancedMesh, but It's TODO at this project. What's the plan?

        // TODO: type: 'BabylonjsCoreInstancedMesh[]' property (not coded) BabylonjsCoreMesh.instances.
        // BabylonjsCoreMesh.isUnIndexed (boolean):
        if (oldProps.isUnIndexed !== newProps.isUnIndexed) {
            updates.push({
                propertyName: 'isUnIndexed',
                value: newProps.isUnIndexed,
                type: 'boolean'
            });
        }

Can you tell me how will you code the IstancedMesh at react-Babylonjs, I want to write the code by myself by clone this project.

Thank you very much.

Errors when using declarative mode in typescript project

Trying to get this working in a typescript project (with CRA 2):

const DefaultPlayground = () => (
    <Engine canvasId="sample-canvas" antialias width={400} height={300}>
        <Scene canvas={null} engine={null} scene={null}>
            <FreeCamera
                name="camera1"
                position={new Vector3(0, 5, -10)}
                target={Vector3.Zero()}
            />
            <HemisphericLight
                name="light1"
                intensity={0.7}
                direction={Vector3.Up()}
            />
            <Sphere
                name="sphere1"
                diameter={2}
                segments={16}
                position={new Vector3(0, 2, 0)}
            />
            <Ground
                name="ground1"
                width={6}
                height={6}
                subdivisions={2}
            />
        </Scene>
    </Engine>
)

I had to add the canvas={null} engine={null} scene={null} to Scene to get rid of first level of typescript errors, but also had to add custom definitions (to react-app-env.d.ts):

import { Vector3 } from 'babylonjs'
import { FreeCamera } from "react-babylonjs";
declare module 'react-babylonjs' {
    export declare class FreeCamera extends React.Component<{
        name?: string;
        position?: Vector3;
        target?: Vector3;
    }, any> {};

    export declare class HemisphericLight extends React.Component<{
        name?: string;
        intensity?: number;
        direction?: Vector3;
    }, any> {};

    export declare class Sphere extends React.Component<{
        name?: string;
        diameter?: number;
        segments?: number;
        position?: Vector3;
    }, any> {};

    export declare class Ground extends React.Component<{
        name?: string;
        width?: number;
        height?: number;
        subdivisions?: number;
    }, any> {};

}

Is there some better way of making the declarative style work in a typescript project?

updating lines points does not update the view

Just starting with babylon and react-babylonjs, so bear with me.

I have a component that gets a path as a prop (from redux). I'd like to draw this path and update it as the prop changes:

const TestPathPres = ({ path }: any) => {
    let points = [];
    for (let o = 0; o < path.length; o += 1) {
        let p = path.getPointAt(o);
        points.push(new Vector3(p.x, 0.15, -p.y));
    }

    console.log("rendering track", points, path);
    return <lines name="track" points={points}/>;
};

When the path updates, I see the updated points array in the console, so the redux integration and rerendering seem to work just fine.

However, the line does not update in the view. Tried adding the updatable flag, but no results either.

When I, for example, render a sphere on the first point of the path, updating the path does move the sphere to a new position

useRightHandedSystem breaks scene

if I set useRightHandedSystem of the Scene to true then I see nothing after any mouse click or movement. Reproduced with every example I tried

Can't get Typescript and useBeforeRender hook to work together

Hi,
is there any example of how to use useBeforeRender and typescript?
I haven't been able to get it to work. It just never calls the callback. During debugging I noticed that const {scene, sceneReady } = useContext(SceneContext); always returns {null, false} for me. So no wonder the callback is not called.

What's weird: Using the contextlogger component from the example I can see that useContext(SceneContext) returns the scene and sceneReady is true. (Edit: Oh, maybe the issue is that my component contains divs, engine and scene tag and it needs to be below context for the context to return something? I'll revisit)

I took a look at https://github.com/brianzinn/react-babylonjs/blob/9228ac840b5ede903f493d3d660ef941fd93de36/stories/babylonjs/Hooks/hooks.stories.js . It works locally for me. I tried to copy as much as I can (I had to to some casting to make the ReactScene stuff (const Scene = withScene(ReactScene)) not throw any typing errors. Maybe that's where the main issue is?

I would greatly appreciate any pointers/help. I am sorry if this is the wrong place to ask something like that, but maybe you can classify it as a "documentation issue".

How to use the default rendering pipeline

Hey brianzinn,

I've been using react-babylonjs for a while and I have generally always figured out how to do what I needed with react-babylonjs. I've figured out how to use materials, the non-declarative mode as well as make it work with react-spring (so far an excellent combo).

However I have just come across the rendering pipeline which allows for motion blur as well as depth of field effects and I'm not sure how I would use it with react-babylonjs.

Do you have an example or snippet where the rendering pipeline is used?

Question about Node.js module export

I notice that react-babylonjs export as ES Module now, but it only defines a “module” field in package.json, that’s nonstandard, in Node.js ES Module Documents, should define a exports field and shipping .mjs files or set type field to module in package.json.

Partial content of Node.js ES Module Documents

Node.js will treat the following as ES modules when passed to node as the initial input, or when referenced by import statements within ES module code:

  • Files ending in .mjs.
  • Files ending in .js when the nearest parent package.json file contains a top-level field "type" with a value of "module".
  • Strings passed in as an argument to --eval, or piped to node via STDIN, with the flag --input-type=module.

Package Entry Points

In a package’s package.json file, two fields can define entry points for a package: "main" and "exports". The "main" field is supported in all versions of Node.js, but its capabilities are limited: it only defines the main entry point of the package.

The "exports" field provides an alternative to "main" where the package main entry point can be defined while also encapsulating the package, preventing any other entry points besides those defined in "exports". This encapsulation allows module authors to define a public interface for their package.

If both "exports" and "main" are defined, the "exports" field takes precedence over "main". "exports" are not specific to ES modules or CommonJS; "main" will be overridden by "exports" if it exists. As such "main" cannot be used as a fallback for CommonJS but it can be used as a fallback for legacy versions of Node.js that do not support the "exports" field.

The hostInstance can't be recognized as Mesh

I want to generate an SCG Object from a mesh but get an error.

Code:

const ref = useCallback(node => {
  if (node) {
    console.log(node.hostInstance);
    const csg = CSG.FromMesh(node.hostInstance);
  }
}, []);

if (wallPath) {
  // noinspection RequiredAttributes
  return (
    <extrudePolygon
      ref={ref}
      name='wall'
      shape={wallPath}
    />
  )
} else {
  return null
}

It throws an error:

Uncaught BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh

Print the node.hostInstance by console.log:

t {state: "", metadata: null, reservedDataStore: null, doNotSerialize: false, _isDisposed: false, …}
onBeforeRenderObservable: (...)
onBeforeBindObservable: (...)
onAfterRenderObservable: (...)
onBeforeDrawObservable: (...)
morphTargetManager: (...)
source: (...)
isUnIndexed: (...)
_isMesh: (...)
hasLODLevels: (...)
geometry: (...)
isBlocked: (...)
areNormalsFrozen: (...)
_positions: (...)
facetNb: (...)
partitioningSubdivisions: (...)
partitioningBBoxRatio: (...)
mustDepthSortFacets: (...)
facetDepthSortFrom: (...)
isFacetDataEnabled: (...)
visibility: (...)
material: (...)
receiveShadows: (...)
hasVertexAlpha: (...)
useVertexColors: (...)
computeBonesUsingShaders: (...)
numBoneInfluencers: (...)
applyFog: (...)
layerMask: (...)
collisionMask: (...)
collisionGroup: (...)
lightSources: (...)
skeleton: (...)
scaling: (...)
useBones: (...)
isAnInstance: (...)
_effectiveMesh: (...)
checkCollisions: (...)
collider: (...)
billboardMode: (...)
preserveParentRotationForBillboard: (...)
infiniteDistance: (...)
position: (...)
rotation: (...)
rotationQuaternion: (...)
forward: (...)
up: (...)
right: (...)
absolutePosition: (...)
isWorldMatrixFrozen: (...)
nonUniformScaling: (...)
parent: (...)
animationPropertiesOverride: (...)
behaviors: (...)
worldMatrixFromCache: (...)
state: ""
metadata: null
reservedDataStore: null
doNotSerialize: false
_isDisposed: true
animations: []
_ranges: {}
onReady: null
_isEnabled: true
_isParentEnabled: true
_isReady: true
_currentRenderId: 0
_parentUpdateId: -1
_childUpdateId: 5
_waitingParentId: null
_cache: {parent: undefined, localMatrixUpdated: false, position: e, scaling: e, rotation: e, …}
_parentNode: null
_children: null
_worldMatrix: e {_isIdentity: true, _isIdentityDirty: false, _isIdentity3x2: false, _isIdentity3x2Dirty: true, updateFlag: 189, …}
_worldMatrixDeterminant: 0
_worldMatrixDeterminantIsDirty: true
_sceneRootNodesIndex: -1
_animationPropertiesOverride: null
_isNode: true
onDisposeObservable: e {_observers: Array(0), _eventState: e, _onObserverAdded: null}
_onDisposeObserver: null
_behaviors: []
name: "wall"
id: "wall"
_scene: Scene {rootNodes: Array(1), cameras: Array(0), lights: Array(0), meshes: Array(1), skeletons: Array(0), …}
uniqueId: 15
_forward: e {x: 0, y: 0, z: 1}
_forwardInverted: e {x: 0, y: 0, z: -1}
_up: e {x: 0, y: 1, z: 0}
_right: e {x: 1, y: 0, z: 0}
_rightInverted: e {x: -1, y: 0, z: 0}
_position: e {x: 0, y: 0, z: 0}
_rotation: e {x: 0, y: 0, z: 0}
_rotationQuaternion: null
_scaling: e {x: 1, y: 1, z: 1}
_isDirty: false
_transformToBoneReferal: null
_billboardMode: 0
_preserveParentRotationForBillboard: false
scalingDeterminant: 1
_infiniteDistance: false
ignoreNonUniformScaling: false
reIntegrateRotationIntoRotationQuaternion: false
_poseMatrix: e {_isIdentity: true, _isIdentityDirty: false, _isIdentity3x2: true, _isIdentity3x2Dirty: false, updateFlag: 179, …}
_localMatrix: e {_isIdentity: false, _isIdentityDirty: true, _isIdentity3x2: false, _isIdentity3x2Dirty: true, updateFlag: 188, …}
_usePivotMatrix: false
_absolutePosition: e {x: 0, y: 0, z: 0}
_pivotMatrix: e {_isIdentity: true, _isIdentityDirty: false, _isIdentity3x2: true, _isIdentity3x2Dirty: false, updateFlag: 174, …}
_postMultiplyPivotMatrix: false
_isWorldMatrixFrozen: false
_indexInSceneTransformNodesArray: -1
onAfterWorldMatrixUpdateObservable: e {_observers: Array(0), _eventState: e, _onObserverAdded: null}
_nonUniformScaling: false
_internalAbstractMeshDataInfo: _t {_hasVertexAlpha: false, _useVertexColors: true, _numBoneInfluencers: 4, _applyFog: true, _receiveShadows: false, …}
cullingStrategy: 0
onCollideObservable: e {_observers: Array(0), _eventState: e, _onObserverAdded: null}
onCollisionPositionChangeObservable: e {_observers: Array(0), _eventState: e, _onObserverAdded: null}
onMaterialChangedObservable: e {_observers: Array(0), _eventState: e}
definedFacingForward: true
_occlusionQuery: null
_renderingGroup: null
alphaIndex:
1.7976931348623157
e+308
isVisible: true
isPickable: true
showSubMeshesBoundingBox: false
isBlocker: false
enablePointerMoveEvents: false
renderingGroupId: 0
_material: null
outlineColor: e {r: 1, g: 0, b: 0}
outlineWidth: 0.02
overlayColor: e {r: 1, g: 0, b: 0}
overlayAlpha: 0.5
useOctreeForRenderingSelection: true
useOctreeForPicking: true
useOctreeForCollisions: true
alwaysSelectAsActiveMesh: false
doNotSyncBoundingInfo: false
actionManager: null
_meshCollisionData: dt {_checkCollisions: false, _collisionMask: -1, _collisionGroup: -1, _collider: null, _oldPositionForCollisions: e, …}
ellipsoid: e {x: 0.5, y: 1, z: 0.5}
ellipsoidOffset: e {x: 0, y: 0, z: 0}
edgesWidth: 1
edgesColor: e {r: 1, g: 0, b: 0, a: 1}
_edgesRenderer: null
_masterMesh: null
_boundingInfo: e {_isLocked: false, boundingBox: e, boundingSphere: e}
_renderId: 0
_intersectionsInProgress: []
_unIndexed: false
_lightSources: []
_waitingData: {lods: null, actions: null, freezeWorldMatrix: null}
_bonesTransformMatrices: null
onRebuildObservable: e {_observers: Array(0), _eventState: e, _onObserverAdded: null}
_onCollisionPositionChange: ƒ (e, t, r)
_internalMeshDataInfo: Dt {_areNormalsFrozen: false, _source: null, meshMap: null, _preActivateId: -1, _LODLevels: Array(0), …}
delayLoadState: 0
instances: []
_creationDataStorage: null
_geometry: null
_instanceDataStorage: St {visibleInstances: {…}, batchCache: It, instancesBufferSize: 2048, hardwareInstancedRendering: true}
_effectiveMaterial: null
_shouldGenerateFlatShading: false
_originalBuilderSideOrientation: 0
overrideMaterialSideOrientation: null
subMeshes: []
__proto__: t

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.