Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/backendtest #241

Merged
merged 60 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
c68265a
dded new announcements tests
ayandajuqu Aug 20, 2024
3b063be
added rubiks cube tester
ayandajuqu Aug 20, 2024
77c2b1b
added rubkis cube img
ayandajuqu Aug 20, 2024
8c110b6
added document binding
ayandajuqu Aug 27, 2024
5f9ba4d
resolved image conflict
ayandajuqu Aug 27, 2024
aae1f37
added sphere for 3d objects
ayandajuqu Aug 27, 2024
1af6d78
added normalisation of mouse
ayandajuqu Aug 28, 2024
7df1396
added initialisation
ayandajuqu Aug 28, 2024
70d660c
refactoerd 3d quizzes
ayandajuqu Aug 30, 2024
d4f65d1
modified mouseclickevent
ayandajuqu Aug 30, 2024
fe0d8de
modified scene init
ayandajuqu Aug 30, 2024
f7581bb
modified onMount
ayandajuqu Aug 30, 2024
3380810
minor fixes
ayandajuqu Sep 2, 2024
8c59f41
finished sphere addition
ayandajuqu Sep 3, 2024
f225af8
saved sphere position in local storage
ayandajuqu Sep 3, 2024
b7a5a24
added correct pin code
ayandajuqu Sep 3, 2024
a69a5ee
finalised changes
ayandajuqu Sep 3, 2024
99ebc50
removed existing code andadded new
ayandajuqu Sep 9, 2024
456d3d7
discplaced list questions
ayandajuqu Sep 10, 2024
c5d1057
replaced quiz logic with component
ayandajuqu Sep 10, 2024
430b21a
added 3d question handling
ayandajuqu Sep 10, 2024
a084b5c
added 2d handling
ayandajuqu Sep 10, 2024
49e157e
changed to assessments
ayandajuqu Sep 11, 2024
93ad893
added speech synthesis.ts
ayandajuqu Sep 11, 2024
c8dfed0
added speech synth in common side bar
ayandajuqu Sep 11, 2024
95946fb
added post mcq and 3d
ayandajuqu Sep 12, 2024
9920f3d
added 3d form content
ayandajuqu Sep 12, 2024
1382d19
accomodated null options
ayandajuqu Sep 12, 2024
c0d8641
resolved merge conflict
ayandajuqu Sep 12, 2024
d803f15
added q type in 3d
ayandajuqu Sep 12, 2024
6f10801
added 2d form outline
ayandajuqu Sep 12, 2024
7b62a23
added formatting materials to get 3d
ayandajuqu Sep 12, 2024
06aa29e
added materials to scene
ayandajuqu Sep 12, 2024
67a2b81
added student selection
ayandajuqu Sep 12, 2024
a53e0fe
fixed bug
ayandajuqu Sep 13, 2024
bd41775
fixed list questions component
ayandajuqu Sep 13, 2024
5140235
added points for ed
ayandajuqu Sep 13, 2024
b4aa25f
added proximity checer
ayandajuqu Sep 13, 2024
ce3c227
removed breakable changegs
ayandajuqu Sep 13, 2024
777444d
fixed conflict
ayandajuqu Sep 13, 2024
eeb9378
added linting
ayandajuqu Sep 13, 2024
577dfae
added points
ayandajuqu Sep 13, 2024
7cbf858
fixed question marking
ayandajuqu Sep 13, 2024
1d9edb3
added model marking
ayandajuqu Sep 13, 2024
17ac959
finalised marking 1
ayandajuqu Sep 13, 2024
c8282d7
added styling
ayandajuqu Sep 17, 2024
fc63da1
added new menu
ayandajuqu Sep 17, 2024
56d4630
changed scene to add menu
ayandajuqu Sep 17, 2024
bafcc05
fixed menu
ayandajuqu Sep 17, 2024
846efa2
added camera and lighting
ayandajuqu Sep 17, 2024
5106253
finished 4d tru/false
ayandajuqu Sep 17, 2024
ce11ee9
added speech synth to non components
ayandajuqu Sep 17, 2024
f273303
fixed formatting
ayandajuqu Sep 17, 2024
b5e0219
fixed linting
ayandajuqu Sep 17, 2024
0679a44
resolved conflict
ayandajuqu Sep 17, 2024
36f1e2d
added new implementation
ayandajuqu Sep 17, 2024
43f1676
added tests
ayandajuqu Sep 18, 2024
c8e37fa
fixed linting
ayandajuqu Sep 18, 2024
18ff1d1
changed proximity
ayandajuqu Sep 18, 2024
13a16e3
fixed linting
ayandajuqu Sep 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added images/rubiks-cube.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"@sendgrid/mail": "^8.1.3",
"@stream-io/node-sdk": "^0.2.6",
"@stream-io/video-client": "^1.4.4",
"@sveltejs/adapter-vercel": "^5.4.1",
"@sveltejs/adapter-vercel": "^5.4.3",
"@threlte/core": "^7.3.1",
"@threlte/extras": "^8.11.4",
"@threlte/xr": "^0.1.4",
Expand Down
259 changes: 259 additions & 0 deletions src/src/lib/components/annotations/3dAnnotations.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
<script lang="ts">
import { onMount } from 'svelte';
import * as THREE from 'three';
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
import { CSS2DRenderer, CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer.js';
import Menu from '$lib/components/hotspot/3dMenu.svelte';
import { Button } from 'flowbite-svelte';

Check warning on line 8 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L1-L8

Added lines #L1 - L8 were not covered by tests

let canvas: HTMLCanvasElement;
let camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGLRenderer;
let controls: OrbitControls;
let labelRenderer: CSS2DRenderer;
let raycaster: THREE.Raycaster;
let mouse: THREE.Vector2;
let annotationMode = false; // Toggle for annotation mode
let annotationText = '';
let activePoint: THREE.Vector3 | null = null;
let tooltipX: number = 0;
let tooltipY: number = 0;

Check warning on line 20 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L10-L20

Added lines #L10 - L20 were not covered by tests

export let data: {

Check warning on line 22 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L22

Added line #L22 was not covered by tests
role: string;
models: { title: string; file_path: string; description: string }[];
};

let { models } = data;
let selectedModel: string | null = null;
const annotations: {

Check warning on line 29 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L27-L29

Added lines #L27 - L29 were not covered by tests
[key: string]: { position: THREE.Vector3; text: string; labelDiv: HTMLDivElement };
} = {};

function toggleAnnotationMode() {
annotationMode = !annotationMode;
if (!annotationMode) {
activePoint = null; // Clear active point when exiting annotation mode

Check warning on line 36 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L33-L36

Added lines #L33 - L36 were not covered by tests
}
}

function addAnnotation() {
if (annotationText.trim() && activePoint) {
createAnnotation(activePoint, annotationText);
annotationText = ''; // Clear text after adding
activePoint = null; // Clear active point

Check warning on line 44 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L40-L44

Added lines #L40 - L44 were not covered by tests
}
}

function createAnnotation(position: THREE.Vector3, text: string) {

Check warning on line 48 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L48

Added line #L48 was not covered by tests
// Create a circle as a THREE.Sprite
const circleTexture = new THREE.TextureLoader().load('/images/circle.png');
const spriteMaterial = new THREE.SpriteMaterial({
map: circleTexture,
depthTest: false,
depthWrite: false,
sizeAttenuation: false

Check warning on line 55 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L50-L55

Added lines #L50 - L55 were not covered by tests
});
const sprite = new THREE.Sprite(spriteMaterial);
sprite.position.copy(position);
sprite.scale.set(0.05, 0.05, 0.05);
scene.add(sprite);

Check warning on line 60 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L57-L60

Added lines #L57 - L60 were not covered by tests

const labelDiv = document.createElement('div');
labelDiv.className = 'annotation-label';
labelDiv.textContent = text;
const label = new CSS2DObject(labelDiv);
label.position.copy(position);
scene.add(label);

Check warning on line 67 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L62-L67

Added lines #L62 - L67 were not covered by tests

annotations[text] = { position, text, labelDiv };

Check warning on line 69 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L69

Added line #L69 was not covered by tests
}

function onMouseClick(event: MouseEvent) {
if (!annotationMode) return;

Check warning on line 73 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L72-L73

Added lines #L72 - L73 were not covered by tests

const rect = canvas.getBoundingClientRect();
mouse.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;

Check warning on line 77 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L75-L77

Added lines #L75 - L77 were not covered by tests

raycaster.setFromCamera(mouse, camera);
const intersects = raycaster.intersectObjects(scene.children, true);

Check warning on line 80 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L79-L80

Added lines #L79 - L80 were not covered by tests

if (intersects.length > 0) {
const point = intersects[0].point;
activePoint = point;

Check warning on line 84 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L82-L84

Added lines #L82 - L84 were not covered by tests

const vector = new THREE.Vector3();
vector.copy(activePoint).project(camera);

Check warning on line 87 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L86-L87

Added lines #L86 - L87 were not covered by tests

const canvas = renderer.domElement;
const widthHalf = 0.5 * canvas.width;
const heightHalf = 0.5 * canvas.height;

Check warning on line 91 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L89-L91

Added lines #L89 - L91 were not covered by tests

tooltipX = vector.x * widthHalf + widthHalf;
tooltipY = -(vector.y * heightHalf) + heightHalf;

Check warning on line 94 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L93-L94

Added lines #L93 - L94 were not covered by tests
}
}

onMount(() => {
initScene();
animate();

Check warning on line 100 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L98-L100

Added lines #L98 - L100 were not covered by tests

window.addEventListener('click', onMouseClick);

Check warning on line 102 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L102

Added line #L102 was not covered by tests
});

function initScene() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.z = 5;

Check warning on line 108 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L105-L108

Added lines #L105 - L108 were not covered by tests

renderer = new THREE.WebGLRenderer({ canvas });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0xffffff);

Check warning on line 112 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L110-L112

Added lines #L110 - L112 were not covered by tests

labelRenderer = new CSS2DRenderer();
labelRenderer.setSize(window.innerWidth, window.innerHeight);
labelRenderer.domElement.style.position = 'absolute';
labelRenderer.domElement.style.top = '0';
labelRenderer.domElement.style.pointerEvents = 'none';
document.body.appendChild(labelRenderer.domElement);

Check warning on line 119 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L114-L119

Added lines #L114 - L119 were not covered by tests

raycaster = new THREE.Raycaster();
mouse = new THREE.Vector2();

Check warning on line 122 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L121-L122

Added lines #L121 - L122 were not covered by tests

const ambientLight = new THREE.AmbientLight(0x404040);
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.5);
directionalLight.position.set(1, 1, 1).normalize();
scene.add(directionalLight);

Check warning on line 128 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L124-L128

Added lines #L124 - L128 were not covered by tests

controls = new OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.dampingFactor = 0.25;
controls.enableRotate = true;

Check warning on line 133 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L130-L133

Added lines #L130 - L133 were not covered by tests

window.addEventListener('resize', onWindowResize, false);

Check warning on line 135 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L135

Added line #L135 was not covered by tests
}

function loadModel(file_path: string) {
const loader = new GLTFLoader();
loader.load(file_path, (gltf) => {
scene.add(gltf.scene);

Check warning on line 141 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L138-L141

Added lines #L138 - L141 were not covered by tests
});
}

function handleModelSelection(file_path: string) {
selectedModel = file_path;
localStorage.setItem('selectedModel', selectedModel);
loadModel(file_path);

Check warning on line 148 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L145-L148

Added lines #L145 - L148 were not covered by tests
}

function animate() {
requestAnimationFrame(animate);

Check warning on line 152 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L151-L152

Added lines #L151 - L152 were not covered by tests

// Get the canvas's bounding rect
if (!canvas) return;
const rect = canvas.getBoundingClientRect();
const canvasWidth = rect.width;
const canvasHeight = rect.height;

Check warning on line 158 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L155-L158

Added lines #L155 - L158 were not covered by tests

Object.values(annotations).forEach(({ position, labelDiv }) => {
const spriteScreenPosition = position.clone().project(camera);

Check warning on line 161 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L160-L161

Added lines #L160 - L161 were not covered by tests

// normalized coordinates to pixel coordinates
const widthHalf = canvasWidth / 2;
const heightHalf = canvasHeight / 2;
const spriteX = spriteScreenPosition.x * widthHalf + widthHalf;
const spriteY = -(spriteScreenPosition.y * heightHalf) + heightHalf;

Check warning on line 167 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L164-L167

Added lines #L164 - L167 were not covered by tests

// Update the label's position
labelDiv.style.position = 'absolute';
labelDiv.style.left = `${spriteX + rect.left}px`;
labelDiv.style.top = `${spriteY + rect.top}px`;

Check warning on line 172 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L170-L172

Added lines #L170 - L172 were not covered by tests

console.log(`Sprite Position: ${spriteX}, ${spriteY}`);
console.log(`Canvas Bounds: ${rect.left}, ${rect.top}, ${rect.width}, ${rect.height}`);

Check warning on line 175 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L174-L175

Added lines #L174 - L175 were not covered by tests

// Show/hide labels based on visibility
if (
spriteScreenPosition.z < 0 ||
spriteX < 0 ||
spriteX > canvasWidth ||
spriteY < 0 ||
spriteY > canvasHeight

Check warning on line 183 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L179-L183

Added lines #L179 - L183 were not covered by tests
) {
labelDiv.style.display = 'none';

Check warning on line 185 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L185

Added line #L185 was not covered by tests
} else {
labelDiv.style.display = 'block';

Check warning on line 187 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L187

Added line #L187 was not covered by tests
}
});

// Render the scene and labels
renderer.render(scene, camera);
labelRenderer.render(scene, camera);

Check warning on line 193 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L192-L193

Added lines #L192 - L193 were not covered by tests
}

function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
labelRenderer.setSize(window.innerWidth, window.innerHeight);

Check warning on line 200 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L196-L200

Added lines #L196 - L200 were not covered by tests
}
</script>

<div class="scene-wrapper">
<Menu {models} onModelSelect={handleModelSelection} />
<Button on:click={toggleAnnotationMode}>
{annotationMode ? 'Exit Annotation Mode' : 'Enter Annotation Mode'}

Check warning on line 207 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L204-L207

Added lines #L204 - L207 were not covered by tests
</Button>
<canvas bind:this={canvas}></canvas>

Check warning on line 209 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L209

Added line #L209 was not covered by tests

<!-- Annotation input -->
{#if annotationMode && activePoint}
<div class="annotation-input" style="left: {tooltipX}px; top: {tooltipY}px;">
<input type="text" bind:value={annotationText} placeholder="Enter annotation" />
<button on:click={addAnnotation}>Add Annotation</button>
</div>

Check warning on line 216 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L212-L216

Added lines #L212 - L216 were not covered by tests
{/if}
</div>

Check warning on line 218 in src/src/lib/components/annotations/3dAnnotations.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/annotations/3dAnnotations.svelte#L218

Added line #L218 was not covered by tests

<style>
.scene-wrapper {
position: relative;
width: 100%;
height: 100vh;
}

canvas {
width: 100%;
height: calc(100vh / 4);
max-width: 100%;
object-fit: contain;
}

.annotation-input {
position: absolute;
background: white;
border: 1px solid black;
padding: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
z-index: 1000;
}

.annotation-input input {
width: 100px; /* Adjust width */
}

.annotation-input button {
margin-top: 5px;
}

:global(.annotation-label) {
background-color: rgba(41, 39, 39, 0.7);
padding: 2px 5px;
border-radius: 3px;
font-size: 12px;
pointer-events: none;
user-select: none;
}
</style>
61 changes: 61 additions & 0 deletions src/src/lib/components/hotspot/3dMenu.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<script lang="ts">
import { Button, Drawer, Hr, Listgroup, ListgroupItem, CloseButton } from 'flowbite-svelte';
import { BarsOutline } from 'flowbite-svelte-icons';
import { sineIn } from 'svelte/easing';

Check warning on line 4 in src/src/lib/components/hotspot/3dMenu.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/hotspot/3dMenu.svelte#L1-L4

Added lines #L1 - L4 were not covered by tests

export let models: { title: string; file_path: string; description: string }[];
export let onModelSelect: (file_path: string) => void;

Check warning on line 7 in src/src/lib/components/hotspot/3dMenu.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/hotspot/3dMenu.svelte#L6-L7

Added lines #L6 - L7 were not covered by tests

let isClosed = true;

Check warning on line 9 in src/src/lib/components/hotspot/3dMenu.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/hotspot/3dMenu.svelte#L9

Added line #L9 was not covered by tests

const transitionParams = { x: -320, duration: 200, easing: sineIn };

Check warning on line 11 in src/src/lib/components/hotspot/3dMenu.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/hotspot/3dMenu.svelte#L11

Added line #L11 was not covered by tests

function handleModelSelect(file_path: string) {
onModelSelect(file_path);

Check warning on line 14 in src/src/lib/components/hotspot/3dMenu.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/hotspot/3dMenu.svelte#L13-L14

Added lines #L13 - L14 were not covered by tests
}
</script>

<!-- Menu Button to Open Drawer -->
<Button
on:click={() => (isClosed = false)}

Check warning on line 20 in src/src/lib/components/hotspot/3dMenu.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/hotspot/3dMenu.svelte#L20

Added line #L20 was not covered by tests
color="dark"
class="m-4 rounded-md border border-gray-300 bg-blue-700 bg-opacity-70 p-1 backdrop-blur-md dark:border-gray-700"
>
<BarsOutline size="xl" />
</Button>

<!-- Drawer for Menu -->
<Drawer
{transitionParams}
transitionType="fly"
bind:hidden={isClosed}

Check warning on line 31 in src/src/lib/components/hotspot/3dMenu.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/hotspot/3dMenu.svelte#L31

Added line #L31 was not covered by tests
class="flex h-full flex-col bg-transparent bg-opacity-30 backdrop-blur-md"
>
<div class="flex items-center justify-between">
<h1 class="text-xl font-bold text-white">Menu</h1>
<CloseButton on:click={() => (isClosed = true)} class="mb-4 text-white" />
</div>

Check warning on line 37 in src/src/lib/components/hotspot/3dMenu.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/hotspot/3dMenu.svelte#L34-L37

Added lines #L34 - L37 were not covered by tests

<Hr />

<!-- Models List -->
<Listgroup class="bg-transparent bg-opacity-30 backdrop-blur-md">
<h3 class="p-1 text-center text-xl font-bold text-white">Available Models</h3>
{#each models as model}

Check warning on line 44 in src/src/lib/components/hotspot/3dMenu.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/hotspot/3dMenu.svelte#L43-L44

Added lines #L43 - L44 were not covered by tests
<ListgroupItem
class="flex w-full items-center p-2 text-lg text-white transition-colors hover:bg-gray-700"
>
<span>{model.title}</span>

Check warning on line 48 in src/src/lib/components/hotspot/3dMenu.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/hotspot/3dMenu.svelte#L48

Added line #L48 was not covered by tests
<Button
on:click={() => handleModelSelect(model.file_path)}

Check warning on line 50 in src/src/lib/components/hotspot/3dMenu.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/hotspot/3dMenu.svelte#L50

Added line #L50 was not covered by tests
color="light"
class="ml-auto p-2"
>

Check warning on line 53 in src/src/lib/components/hotspot/3dMenu.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/hotspot/3dMenu.svelte#L53

Added line #L53 was not covered by tests
Load
</Button>

Check warning on line 55 in src/src/lib/components/hotspot/3dMenu.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/hotspot/3dMenu.svelte#L55

Added line #L55 was not covered by tests
</ListgroupItem>
{/each}
</Listgroup>

<Hr />
</Drawer>
Loading
Loading