filestash/public/assets/pages/viewerpage/application_3d/scene_cube.js
MickaelK 71b14e6eaf feature (3d): embed 3d viewer anywhere
This contains a bunch of things packaged in 1:

1) UI improvements for the 3D viewer to support all sort of file types
   and create a nice rendering in a clean way with all sort of options

2) enable people to use Filestash as an SDK so we can embed the 3d viewer
   elsewhere
2024-12-23 18:50:23 +11:00

23 lines
879 B
JavaScript

import { onDestroy } from "../../../lib/skeleton/index.js";
import { ViewCubeGizmo, SimpleCameraControls, ObjectPosition } from "../../../lib/vendor/three/viewcube.js";
export default function({ camera, renderer, refresh, controls }) {
const viewCubeGizmo = new ViewCubeGizmo(camera, renderer, {
pos: ObjectPosition.RIGHT_BOTTOM,
dimension: 130,
faceColor: 0xf9f9fa,
outlineColor: 0xe2e2e2,
});
const simpleCameraControls = new SimpleCameraControls(camera);
simpleCameraControls.setControls(controls);
refresh.push(() => {
viewCubeGizmo.update();
simpleCameraControls.update();
});
const onCubeClick = (event) => simpleCameraControls.flyTo(event.quaternion);
viewCubeGizmo.addEventListener("change", onCubeClick);
onDestroy(() => viewCubeGizmo.removeEventListener("change", onCubeClick));
}