-
Hi, I hope everyone is doing well. I'd like to set
A naive attempt to pass either
which makes sense as the CubeTexture constructor actually runs before the return statement is executed so there is no Engine yet. How do I make something like this work? More concrete short snippet of the relevant code in my component source file: import { Scene, Engine, useEngine, useCanvas, useScene } from 'react-babylonjs'
import {Vector3, CubeTexture, ...} from "@babylonjs/core"
export default function MyScene({ id }) {
const env = new CubeTexture(
"foo.env",
useScene(),...);
env.rotationY = ....; ...; ...;
return <>
<Engine
antialias
adaptToDeviceRatio
canvasId={id}
renderOptions={{
whenVisibleOnly: true,
}}
>
<Scene
clearColor={Color3.Black()}
ambientColor={Color3.Black()}
environmentTexture={env}
>
.... |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 9 replies
-
Does this help? You have also a callback when the scene is created. Also, a skybox component. Otherwise you have a chicken/egg problem. |
Beta Was this translation helpful? Give feedback.
-
I don’t know if I implemented this: |
Beta Was this translation helpful? Give feedback.
-
I got this working: <Engine antialias adaptToDeviceRatio canvasId="babylon-js">
<Scene>
<arcRotateCamera
name="camera1"
target={Vector3.Zero()}
minZ={0.001}
alpha={0}
beta={Math.PI / 2}
radius={5}
lowerBetaLimit={2}
upperRadiusLimit={5}
/>
<hemisphericLight name="light1" intensity={0.9} direction={Vector3.Down()} />
<sphere name='sphere1' segments={16} diameter={2}>
<pbrMaterial
name='pbr'
albedoColor={new Color3(1, 0.766, 0.336)}
metallic={1.0}
roughness={1.0}
useRoughnessFromMetallicTextureAlpha={false} useRoughnessFromMetallicTextureGreen useMetallnessFromMetallicTextureBlue>
<texture url='../../assets/textures/mr.jpg' assignTo='metallicTexture' />
</pbrMaterial>
</sphere>
<cubeTexture level={0.5} assignTo="environmentTexture" rootUrl='../../assets/textures/environment.env' />
</Scene>
</Engine> Would that work for you? I'll need to commit the code changes before it would work on your side. |
Beta Was this translation helpful? Give feedback.
-
... on the other hand if you add Are you planning to address in some way the issue of Scene.environmentTexture being present and easily discoverable, but attempts to use it naturally leading to frustration and lost time? |
Beta Was this translation helpful? Give feedback.
I got this working: