Replies: 4 comments 6 replies
-
hi @ekaradon That's a good question. I'm happy to add anything that would be useful or if you could provide a syntax. One thing I have tried to do is stick as close to the API as possible, but in some cases like here it can be useful to add new functionality. It's a bit of work, because I really need to move the specific properties to specific objects whereas many are now global (ie: if new props are added they should be for cameras only). Here is non-declarative sample that may give you some ideas: I feel like we would need multiple properties on cameras to enforce not only active, but add to active cameras (as you have done). Everytime a camera is added it goes through this The other thing that you noticed is that 'Viewport' isn't assigned by the renderer - I can add that to the code generation (there are currently around 200 properties not assigned due to their type). That's because you can dynamically declare how the reconciler can handle some argument types (like Vector3 as any array, for example) - that can only be done if the property type is known and is a cool feature, but comes with a bit of baggage and props that don't assign. This could be added as an issue, but good idea to discuss the syntax here. |
Beta Was this translation helpful? Give feedback.
-
I had another idea, which was to update the LifecycleListener to handle custom property updates. It would have off to there instead of using the other prop handlers. |
Beta Was this translation helpful? Give feedback.
-
I have put more thought into the declarative syntax following a recent issue created for multiple scene and canvas support. What about a syntax like this:
If that was connected automatically then what is remaining is how to set the activeCameras declaratively. |
Beta Was this translation helpful? Give feedback.
-
@ekaradon Although I have not addressed your question on how to set several cameras as active - did manage to make partial progress by adding const size = 2;
const shade = 0;
const BoxWithArrows = ({ position }) => {
return (<transformNode position={position} name="transform-node">
<lines
name="red-line"
points={
[
new Vector3.Zero(),
new Vector3(size, 0, 0),
new Vector3(size * 0.95, 0.05 * size, 0),
new Vector3(size, 0, 0),
new Vector3(size * 0.95, -0.05 * size, 0)
]
}
color={new Color3(1, shade, shade)}
/>
<lines
name="green-line"
points={
[
new Vector3.Zero(),
new Vector3(0, size, 0),
new Vector3(-0.05 * size, size * 0.95, 0),
new Vector3(0, size, 0),
new Vector3(0.05 * size, size * 0.95, 0)
]
}
color={new Color3(shade, 1, shade)}
/>
<lines
name="blue-line"
points={
[
new Vector3.Zero(),
new Vector3(0, 0, size),
new Vector3(0, -0.05 * size, size * 0.95),
new Vector3(0, 0, size),
new Vector3(0, 0.05 * size, size * 0.95)
]
}
color={new Color3(shade, shade, 1)}
/>
<box
name="color-box"
faceColors={[
Color3.Blue(),
Color3.Red(),
Color3.Green(),
Color3.White(),
Color3.Yellow(),
Color3.Black()
]}
></box>
</transformNode>)
}
const MultiViewport = () => {
const scene = useScene();
const alwaysActive = (camera) => {
scene.activeCameras = [...(scene.activeCameras || []), camera];
}
return (
<>
<BoxWithArrows position={Vector3.Zero()} />
<hemisphericLight name='light1' intensity={0.7} direction={Vector3.Up()} />
<arcRotateCamera name='camera1' alpha={3 * Math.PI / 8} beta={3 * Math.PI / 8} radius={15} target={new Vector3(0, 2, 0)} onCreated={alwaysActive}>
<viewport x={0} y={0.5} height={1} width={1} />
</arcRotateCamera>
<arcRotateCamera name='camera2' alpha={5 * Math.PI / 8} beta={5 * Math.PI / 8} radius={30} target={new Vector3(0, 2, 0)} onCreated={alwaysActive}>
<viewport x={0} y={0} height={1} width={0.5} />
</arcRotateCamera>
</>
)
} It looks to have all of the functionality of the multiview playground from docs: One thing also of interest is your Then to get back to your original question we could add an |
Beta Was this translation helpful? Give feedback.
-
Hello,
So I want to try this: https://doc.babylonjs.com/divingDeeper/cameras/multiViewsPart2
But with react-babylonjs, I don't succeed to find a way to do it.
I can mix both of the approach, for example this works:
But it seems, I can't do it with the declarative way?
Is it possible on a way I didn't see? If it's not, could we add something in order to support it? I'm willing to help if I can but I would need directions first?
Beta Was this translation helpful? Give feedback.
All reactions