Hi there, I had some camera settings adjusted upon Viewer (now Viewport) initialization which are no longer working as expected after migrating from 1.15.7 to 2.0.7.
Here’s my React component:
import React, { useEffect } from "react";
import { createViewport, createSession } from "@shapediver/viewer";
const ModelViewer = (props) => {
useEffect(async () => {
const session = await createSession({
ticket: ticket,
modelViewUrl: "https://sdeuc1.eu-central-1.shapediver.com",
id: "mySession",
});
const viewport = await createViewport({
canvas: containerRef.current,
id: "myViewport",
branding: {
backgroundColor: "#ffffff",
busyModeDisplay: "blur",
},
});
const camera = viewport.camera;
camera.cubePositionRestriction = {
min: [-Infinity, -Infinity, 0],
max: [Infinity, Infinity, Infinity],
};
camera.cubeTargetRestriction = {
min: [-Infinity, -Infinity, 0],
max: [Infinity, Infinity, Infinity],
};
await camera.animate(
[
{
position: [-187, -344, 110],
target: camera.defaultTarget,
},
{
position: [-10, -244, 80],
target: camera.defaultTarget,
},
{
position: camera.defaultPosition,
target: camera.defaultTarget,
},
],
{
duration: 10000,
easing: "Cubic.InOut",
interpolation: "Linear",
}
);
console.log("here", viewport, camera);
}, []);
return <canvas ref={containerRef} />;
};
export default ModelViewer;
The log output shows that the PerspectiveCameraApi has the settings correctly configured. However, the Viewport does not animate or restrict the camera controls as intended.
I’m using shapediver v2.0.7 and react v17.0.2. Is there something obvious I’m missing in the migration here? Let me know if I can provide any additional info.