Start working on python package

This commit is contained in:
Yeicor
2024-02-01 21:03:20 +01:00
parent 24d9af17ee
commit 8fd3a2247a
15 changed files with 240 additions and 13 deletions

View File

@@ -1,10 +1,8 @@
import {ModelViewerElement} from '@google/model-viewer';
import {settings} from "./settings";
import {Renderer} from "@google/model-viewer/lib/three-components/Renderer";
import {$scene} from "@google/model-viewer/lib/model-viewer-base";
import {OrientationGizmo} from "./orientation";
import {$controls} from "@google/model-viewer/lib/features/controls";
import {ModelScene} from "@google/model-viewer/lib/three-components/ModelScene";
import {settings} from "./settings";
export class App {
element: ModelViewerElement
@@ -13,10 +11,12 @@ export class App {
this.element = new ModelViewerElement();
this.element.setAttribute('alt', 'The CAD Viewer is not supported on this browser.');
this.element.setAttribute('camera-controls', '');
this.element.setAttribute('camera-orbit', '30deg 75deg auto');
this.element.setAttribute('max-camera-orbit', 'Infinity 180deg auto');
this.element.setAttribute('min-camera-orbit', '-Infinity 0deg auto');
this.element.setAttribute('interaction-prompt', 'none'); // Quits selected views from gizmo
// this.element.setAttribute('auto-rotate', ''); // Messes with the gizmo (rotates model instead of camera)
if (settings.autoplay) this.element.setAttribute('autoplay', '');
if (settings.arModes) {
this.element.setAttribute('ar', '');
this.element.setAttribute('ar-modes', settings.arModes);
@@ -34,16 +34,13 @@ export class App {
let scene: ModelScene = this.element[$scene];
let gizmo = new OrientationGizmo(scene);
gizmo.install();
function updateGizmo() {
gizmo.update();
requestAnimationFrame(updateGizmo);
}
updateGizmo();
// document.body.appendChild(this.stats.dom)
// this.stats.dom.style.left = '';
// this.stats.dom.style.right = '0px';
// this.stats.dom.style.top = '120px';
// this.stats.showPanel(1); // 0: fps, 1: ms, 2: mb, 3+: custom
}
replaceModel(url: string) {

View File

@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>Yet Another CAD Viewer</title>
<meta name='viewport' content='width=device-width, initial-scale=1' />
<meta name='viewport' content='width=device-width, initial-scale=1'/>
<link rel="stylesheet" type="text/css" href="./index.css">
<script type="module" src="./index.ts"></script>
</head>

View File

@@ -1,7 +1,7 @@
import {App} from "./app";
import {settings} from "./settings";
const app = new App()
app.install();
app.replaceModel(`https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Duck/glTF-Binary/Duck.glb`)
app.replaceModel(settings.preloadModel)

View File

@@ -1,7 +1,12 @@
// @ts-ignore
import skyboxUrl from './../img/st_peters_square_night_8k.jpg';
import skyboxUrl from '../assets/st_peters_square_night_8k.jpg';
// @ts-ignore
import logo from "url:../assets/fox.glb";
export const settings = {
// ModelViewer settings
preloadModel: logo,
autoplay: true,
arModes: 'webxr scene-viewer quick-look',
shadowIntensity: 1,
background: skyboxUrl,