mirror of
https://github.com/yeicor-3d/yet-another-cad-viewer.git
synced 2026-01-24 23:24:14 +01:00
Start working on python package
This commit is contained in:
13
src/app.ts
13
src/app.ts
@@ -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) {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user