diff --git a/javascript labelling.ipynb b/javascript labelling.ipynb deleted file mode 100644 index 8247f1a1..00000000 --- a/javascript labelling.ipynb +++ /dev/null @@ -1,138 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "id": "3e2f207e-3b79-4fe3-a3c6-c2140a252973", - "metadata": {}, - "outputs": [], - "source": [ - "%%html\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "
" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "d20427d5-ffe1-4a9b-aca4-b1f5e680e9ad", - "metadata": {}, - "outputs": [], - "source": [ - "%%javascript\n", - "// Wait for DOM to be ready\n", - "function waitForElement() {\n", - " if (document.getElementById('container3D')) {\n", - " // Container element found, proceed with rendering\n", - " initThreeJS();\n", - " } else {\n", - " // Wait and check again\n", - " setTimeout(waitForElement, 100); // Adjust timing as needed\n", - " }\n", - "}\n", - "waitForElement();\n", - "\n", - "function initThreeJS() {\n", - " let scene, camera, renderer, controls;\n", - "\n", - " // Scene setup\n", - " scene = new THREE.Scene();\n", - "\n", - " // Camera setup\n", - " camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);\n", - " camera.position.set(0, 0.3, 0.7);\n", - "\n", - " // Renderer setup\n", - " const container = document.getElementById('container3D'); // Get the container element\n", - " renderer = new THREE.WebGLRenderer({ antialias: true });\n", - " renderer.setSize(container.clientWidth, container.clientHeight);\n", - " container.appendChild(renderer.domElement);\n", - "\n", - " // Orbit controls setup\n", - " controls = new THREE.OrbitControls(camera, renderer.domElement);\n", - "\n", - " // Lights setup\n", - " const directionalLight = new THREE.DirectionalLight(0xffffff, 1);\n", - " directionalLight.position.set(0, 1, 1);\n", - " scene.add(directionalLight);\n", - "\n", - " const ambientLight = new THREE.AmbientLight(0x404040);\n", - " scene.add(ambientLight);\n", - "\n", - " // Load mesh (replace with your model loading logic)\n", - " const loader = new THREE.GLTFLoader();\n", - " loader.load('models/model/scene.gltf', function (gltf) {\n", - " const mesh = gltf.scene;\n", - " scene.add(mesh);\n", - "\n", - " // Define labels\n", - " const labels = {\n", - " \"Ear Left\": new THREE.Vector3(-0.08508963, 0.15244128, -0.07269581),\n", - " \"Ear Right\": new THREE.Vector3(-0.01597024, 0.13926028, -0.02299697),\n", - " \"Nose\": new THREE.Vector3(-0.11643464, 0.05128627, 0.07609549),\n", - " \"Bottom\": new THREE.Vector3(0.14346997, -0.08839463, 0.04595339),\n", - " };\n", - "\n", - " // Add labels\n", - " for (const label in labels) {\n", - " const coord = labels[label];\n", - "\n", - " const labelDiv = document.createElement('div');\n", - " labelDiv.className = 'label';\n", - " labelDiv.textContent = label;\n", - " labelDiv.style.color = 'black';\n", - " labelDiv.style.fontSize = '20px';\n", - "\n", - " const labelObj = new THREE.CSS2DObject(labelDiv);\n", - " labelObj.position.copy(coord);\n", - " mesh.add(labelObj);\n", - " }\n", - " });\n", - "\n", - " // Animation function\n", - " function animate() {\n", - " requestAnimationFrame(animate);\n", - " controls.update();\n", - " renderer.render(scene, camera);\n", - " }\n", - "\n", - " // Handle window resize\n", - " window.addEventListener('resize', function () {\n", - " camera.aspect = container.clientWidth / container.clientHeight;\n", - " camera.updateProjectionMatrix();\n", - " renderer.setSize(container.clientWidth, container.clientHeight);\n", - " });\n", - "\n", - " // Start animation loop\n", - " animate();\n", - "}" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.12.0" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -}