Skip to content

Commit

Permalink
create default camera which does autofitting by default
Browse files Browse the repository at this point in the history
  • Loading branch information
hybridherbst committed Nov 18, 2024
1 parent 7ac7e56 commit ccbdf55
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/components/engineViews/BabylonEngineComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,8 @@ export const BabylonEngineComponent = (props: {behaveGraphRef: any, setBehaveGra
const createScene = () => {
// Create a scene
sceneRef.current = new Scene(engineRef.current!);
sceneRef.current?.createDefaultCamera(true, true, true);

// Create a camera
const camera = new ArcRotateCamera('camera', Math.PI / 3, Math.PI / 3, 10, Vector3.Zero(), sceneRef.current);
camera.attachControl(canvasRef.current, true);
camera.minZ = 0.001;
canvasRef.current!.addEventListener("wheel", (e: any) => {
e.preventDefault();
e.stopPropagation();
Expand Down Expand Up @@ -115,6 +112,8 @@ export const BabylonEngineComponent = (props: {behaveGraphRef: any, setBehaveGra
const container = await SceneLoader.LoadAssetContainerAsync("", url, sceneRef.current, undefined, ".glb");
container.addAllToScene();

sceneRef.current?.createDefaultCamera(true, true, true);

return {nodes:buildGlTFNodeLayout(container.rootNodes[0]), animations: container.animationGroups, materials: container.materials};
};

Expand Down

0 comments on commit ccbdf55

Please sign in to comment.