<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Interactive 3D Human Skull Anatomy</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
overflow: hidden;
background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
color: #e2e8f0;
}
#canvas-container {
width: 100vw;
height: 100vh;
position: relative;
}
#info-panel {
position: absolute;
top: 20px;
left: 20px;
background: rgba(15, 23, 42, 0.85);
padding: 20px;
border-radius: 12px;
max-width: 320px;
backdrop-filter: blur(12px);
border: 1px solid rgba(94, 234, 212, 0.2);
box-shadow: 0 8px 32px rgba(2, 8, 20, 0.4);
transition: transform 0.3s ease;
}
#info-panel:hover {
transform: translateY(-2px);
}
#info-panel h1 {
font-size: 24px;
margin-bottom: 15px;
color: #5eead4;
text-shadow: 0 0 8px rgba(94, 234, 212, 0.3);
}
#info-panel p {
font-size: 14px;
line-height: 1.6;
color: #cbd5e1;
}
#controls {
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
background: rgba(15, 23, 42, 0.85);
padding: 15px 30px;
border-radius: 30px;
display: flex;
gap: 15px;
align-items: center;
backdrop-filter: blur(12px);
border: 1px solid rgba(94, 234, 212, 0.2);
box-shadow: 0 8px 32px rgba(2, 8, 20, 0.4);
}
.control-group {
display: flex;
align-items: center;
gap: 10px;
}
.control-group label {
font-size: 13px;
color: #5eead4;
font-weight: 500;
}
.toggle-btn {
background: rgba(94, 234, 212, 0.15);
border: 1px solid rgba(94, 234, 212, 0.3);
color: #5eead4;
padding: 8px 16px;
border-radius: 20px;
cursor: pointer;
font-size: 13px;
transition: all 0.3s ease;
font-weight: 500;
}
.toggle-btn:hover {
background: rgba(94, 234, 212, 0.25);
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(94, 234, 212, 0.2);
}
.toggle-btn.active {
background: rgba(94, 234, 212, 0.3);
box-shadow: 0 0 15px rgba(94, 234, 212, 0.4);
}
#tooltip {
position: absolute;
background: rgba(15, 23, 42, 0.95);
color: #5eead4;
padding: 10px 15px;
border-radius: 8px;
font-size: 14px;
pointer-events: none;
display: none;
z-index: 1000;
border: 1px solid rgba(94, 234, 212, 0.3);
backdrop-filter: blur(4px);
box-shadow: 0 4px 20px rgba(2, 8, 20, 0.5);
font-weight: 500;
}
#feature-info {
position: absolute;
top: 20px;
right: 20px;
background: rgba(15, 23, 42, 0.85);
padding: 20px;
border-radius: 12px;
max-width: 280px;
backdrop-filter: blur(12px);
border: 1px solid rgba(94, 234, 212, 0.2);
box-shadow: 0 8px 32px rgba(2, 8, 20, 0.4);
display: none;
transition: transform 0.3s ease;
}
#feature-info:hover {
transform: translateY(-2px);
}
#feature-info h3 {
color: #5eead4;
margin-bottom: 10px;
font-size: 18px;
text-shadow: 0 0 8px rgba(94, 234, 212, 0.3);
}
#feature-info p {
font-size: 14px;
line-height: 1.6;
color: #cbd5e1;
}
.close-btn {
position: absolute;
top: 10px;
right: 10px;
background: rgba(94, 234, 212, 0.15);
border: 1px solid rgba(94, 234, 212, 0.3);
color: #5eead4;
width: 24px;
height: 24px;
border-radius: 50%;
cursor: pointer;
font-size: 14px;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
}
.close-btn:hover {
background: rgba(94, 234, 212, 0.25);
transform: rotate(90deg);
}
#loading {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 20px;
color: #5eead4;
text-shadow: 0 0 10px rgba(94, 234, 212, 0.5);
}
#sutures-panel {
position: absolute;
bottom: 20px;
right: 20px;
background: rgba(15, 23, 42, 0.85);
padding: 15px;
border-radius: 12px;
backdrop-filter: blur(12px);
border: 1px solid rgba(94, 234, 212, 0.2);
box-shadow: 0 8px 32px rgba(2, 8, 20, 0.4);
}
#sutures-panel h4 {
color: #5eead4;
margin-bottom: 10px;
font-size: 16px;
}
.suture-toggle {
background: rgba(94, 234, 212, 0.15);
border: 1px solid rgba(94, 234, 212, 0.3);
color: #5eead4;
padding: 6px 12px;
border-radius: 15px;
cursor: pointer;
font-size: 12px;
margin: 2px;
transition: all 0.3s ease;
}
.suture-toggle:hover {
background: rgba(94, 234, 212, 0.25);
}
.suture-toggle.active {
background: rgba(94, 234, 212, 0.3);
box-shadow: 0 0 10px rgba(94, 234, 212, 0.3);
}
#measurements-panel {
position: absolute;
top: 50%;
left: 20px;
transform: translateY(-50%);
background: rgba(15, 23, 42, 0.85);
padding: 15px;
border-radius: 12px;
backdrop-filter: blur(12px);
border: 1px solid rgba(94, 234, 212, 0.2);
box-shadow: 0 8px 32px rgba(2, 8, 20, 0.4);
display: none;
}
#measurements-panel h4 {
color: #5eead4;
margin-bottom: 10px;
font-size: 16px;
}
.measurement-item {
font-size: 12px;
color: #cbd5e1;
margin: 5px 0;
}
</style>
</head>
<body>
<div id="canvas-container">
<div id="loading">Loading 3D Skull Model...</div>
</div>
<div id="info-panel">
<h1>Human Skull Anatomy</h1>
<p>Explore the intricate structures of the human skull. Rotate by dragging, zoom with scroll, and click on highlighted areas to learn more.</p>
</div>
<div id="controls">
<div class="control-group">
<label>View Mode:</label>
<button class="toggle-btn active" id="normal-view">Normal</button>
<button class="toggle-btn" id="xray-view">X-Ray</button>
</div>
<div class="control-group">
<label>Features:</label>
<button class="toggle-btn active" id="toggle-features">Show All</button>
</div>
<div class="control-group">
<label>Rotation:</label>
<button class="toggle-btn" id="auto-rotate">Auto</button>
</div>
<div class="control-group">
<label>Measure:</label>
<button class="toggle-btn" id="toggle-measure">Off</button>
</div>
</div>
<div id="sutures-panel">
<h4>Cranial Sutures</h4>
<button class="suture-toggle" id="sagittal-suture">Sagittal</button>
<button class="suture-toggle" id="coronal-suture">Coronal</button>
<button class="suture-toggle" id="lambdoid-suture">Lambdoid</button>
<button class="suture-toggle" id="squamosal-suture">Squamosal</button>
</div>
<div id="measurements-panel">
<h4>Skull Measurements</h4>
<div class="measurement-item">Cranial Length: ~18-20 cm</div>
<div class="measurement-item">Cranial Width: ~14-16 cm</div>
<div class="measurement-item">Cranial Height: ~13-15 cm</div>
<div class="measurement-item">Mandible Length: ~8-10 cm</div>
<div class="measurement-item">Foramen Magnum: ~3.5 cm</div>
</div>
<div id="tooltip"></div>
<div id="feature-info">
<button class="close-btn" onclick="closeFeatureInfo()">×</button>
<h3 id="feature-title"></h3>
<p id="feature-description"></p>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/OrbitControls.js"></script>
<script>
// Scene setup
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x0f172a);
scene.fog = new THREE.Fog(0x0f172a, 15, 60);
// Camera setup
const camera = new THREE.PerspectiveCamera(
60,
window.innerWidth / window.innerHeight,
0.1,
1000
);
camera.position.set(0, 2, 6);
// Renderer setup
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true
});
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputEncoding = THREE.sRGBEncoding;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.2;
document.getElementById('canvas-container').appendChild(renderer.domElement);
// Controls
const controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.dampingFactor = 0.08;
controls.minDistance = 3;
controls.maxDistance = 15;
controls.maxPolarAngle = Math.PI * 0.8;
// Lighting setup with ambient and directional lights
const ambientLight = new THREE.AmbientLight(0x5eead4, 0.3);
scene.add(ambientLight);
const mainLight = new THREE.DirectionalLight(0xffffff, 1.2);
mainLight.position.set(8, 12, 8);
mainLight.castShadow = true;
mainLight.shadow.mapSize.width = 2048;
mainLight.shadow.mapSize.height = 2048;
mainLight.shadow.camera.near = 0.1;
mainLight.shadow.camera.far = 50;
mainLight.shadow.camera.left = -15;
mainLight.shadow.camera.right = 15;
mainLight.shadow.camera.top = 15;
mainLight.shadow.camera.bottom = -15;
scene.add(mainLight);
const fillLight = new THREE.DirectionalLight(0x38bdf8, 0.4);
fillLight.position.set(-8, 8, -8);
scene.add(fillLight);
const rimLight = new THREE.DirectionalLight(0x818cf8, 0.3);
rimLight.position.set(0, -5, -10);
scene.add(rimLight);
// Detailed anatomical feature data with descriptions
const featureData = {
frontalBone: {
name: "Frontal Bone",
description: "The frontal bone forms the forehead and upper orbit of the eye. It contains the frontal sinuses and protects the frontal lobe of the brain.",
color: 0xff6b6b
},
parietalBones: {
name: "Parietal Bones",
description: "Two parietal bones form the sides and roof of the skull. They articulate with each other at the sagittal suture.",
color: 0x4ecdc4
},
temporalBones: {
name: "Temporal Bones",
description: "The temporal bones house the inner ear structures and form part of the base of the skull. They contain the mastoid process and styloid process.",
color: 0x45b7d1
},
occipitalBone: {
name: "Occipital Bone",
description: "The occipital bone forms the back and base of the skull. It contains the foramen magnum where the spinal cord passes through.",
color: 0xf7b731
},
sphenoidBone: {
name: "Sphenoid Bone",
description: "The sphenoid bone is a complex bone resembling a butterfly. It forms the base of the skull and parts of the eye orbit.",
color: 0x5f27cd
},
ethmoidBone: {
name: "Ethmoid Bone",
description: "The ethmoid bone is located between the eyes and forms part of the nasal cavity. It contains the cribriform plate for olfactory nerves.",
color: 0x00d2d3
},
maxilla: {
name: "Maxilla",
description: "The maxilla forms the upper jaw and contains the maxillary sinuses. It supports the upper teeth and forms part of the hard palate.",
color: 0xff9ff3
},
mandible: {
name: "Mandible",
description: "The mandible is the largest and strongest facial bone, forming the lower jaw. It's the only movable skull bone.",
color: 0x54a0ff
},
zygomaticBones: {
name: "Zygomatic Bones",
description: "The zygomatic bones form the cheekbones and part of the eye orbit. They articulate with multiple facial bones.",
color: 0x5f27cd
},
nasalBones: {
name: "Nasal Bones",
description: "The nasal bones are small oblong bones that form the bridge of the nose. They vary in size and shape among individuals.",
color: 0x26de81
}
};
// Suture data
const sutureData = {
sagittal: {
name: "Sagittal Suture",
description: "Connects the two parietal bones along the midline of the skull."
},
coronal: {
name: "Coronal Suture",
description: "Connects the frontal bone to the parietal bones."
},
lambdoid: {
name: "Lambdoid Suture",
description: "Connects the occipital bone to the parietal bones."
},
squamosal: {
name: "Squamosal Suture",
description: "Connects the temporal bones to the parietal bones."
}
};
// Create skull group
const skullGroup = new THREE.Group();
scene.add(skullGroup);
// Sutures group
const suturesGroup = new THREE.Group();
scene.add(suturesGroup);
// Create more anatomically accurate skull model
function createSkull() {
const boneMaterial = new THREE.MeshPhongMaterial({
color: 0xf5f5dc,
shininess: 30,
specular: 0x222222
});
const xrayMaterial = new THREE.MeshPhongMaterial({
color: 0x5eead4,
transparent: true,
opacity: 0.4,
emissive: 0x5eead4,
emissiveIntensity: 0.2,
specular: 0x5eead4
});
// Create more accurate frontal bone with proper curvature
const frontalShape = new THREE.Shape();
frontalShape.moveTo(-1.2, 0);
frontalShape.bezierCurveTo(-1.2, 1.8, -0.6, 2.2, 0, 2.2);
frontalShape.bezierCurveTo(0.6, 2.2, 1.2, 1.8, 1.2, 0);
frontalShape.bezierCurveTo(1.2, -0.3, 0.6, -0.5, 0, -0.5);
frontalShape.bezierCurveTo(-0.6, -0.5, -1.2, -0.3, -1.2, 0);
const frontalExtrudeSettings = {
depth: 0.8,
bevelEnabled: true,
bevelSegments: 8,
steps: 2,
bevelSize: 0.1,
bevelThickness: 0.1
};
const frontalGeometry = new THREE.ExtrudeGeometry(frontalShape, frontalExtrudeSettings);
const frontalBone = new THREE.Mesh(frontalGeometry, boneMaterial.clone());
frontalBone.position.set(0, 0.5, 1.0);
frontalBone.rotation.x = -0.1;
frontalBone.userData = {
feature: 'frontalBone',
originalMaterial: frontalBone.material.clone(),
xrayMaterial: xrayMaterial.clone()
};
skullGroup.add(frontalBone);
// Create parietal bones with more accurate shape
const parietalShape = new THREE.Shape();
parietalShape.moveTo(0, 0);
parietalShape.bezierCurveTo(0, 1.8, 0.8, 1.8, 1.0, 1.2);
parietalShape.bezierCurveTo(1.2, 0.6, 1.0, 0, 0.8, -0.2);
parietalShape.bezierCurveTo(0.4, -0.3, 0.2, -0.2, 0, 0);
const parietalExtrudeSettings = {
depth: 0.6,
bevelEnabled: true,
bevelSegments: 6,
steps: 2,
bevelSize: 0.05,
bevelThickness: 0.05
};
const leftParietalGeometry = new THREE.ExtrudeGeometry(parietalShape, parietalExtrudeSettings);
const leftParietal = new THREE.Mesh(leftParietalGeometry, boneMaterial.clone());
leftParietal.position.set(-0.7, 0.8, -0.3);
leftParietal.rotation.y = -0.2;
leftParietal.rotation.z = 0.1;
leftParietal.userData = {
feature: 'parietalBones',
originalMaterial: leftParietal.material.clone(),
xrayMaterial: xrayMaterial.clone()
};
skullGroup.add(leftParietal);
const rightParietalGeometry = new THREE.ExtrudeGeometry(parietalShape, parietalExtrudeSettings);
const rightParietal = new THREE.Mesh(rightParietalGeometry, boneMaterial.clone());
rightParietal.position.set(0.7, 0.8, -0.3);
rightParietal.rotation.y = 0.2;
rightParietal.rotation.z = -0.1;
rightParietal.userData = {
feature: 'parietalBones',
originalMaterial: rightParietal.material.clone(),
xrayMaterial: xrayMaterial.clone()
};
skullGroup.add(rightParietal);
// Create temporal bones with mastoid process
const temporalGroup = new THREE.Group();
// Main temporal bone
const temporalMain = new THREE.Mesh(
new THREE.BoxGeometry(0.9, 1.2, 0.7),
boneMaterial.clone()
);
temporalMain.position.set(0, 0, 0);
// Mastoid process
const mastoidProcess = new THREE.Mesh(
new THREE.SphereGeometry(0.25, 16, 16),
boneMaterial.clone()
);
mastoidProcess.position.set(0, -0.6, -0.2);
mastoidProcess.scale.set(1, 1.5, 1.2);
temporalGroup.add(temporalMain);
temporalGroup.add(mastoidProcess);
const leftTemporal = temporalGroup.clone();
leftTemporal.position.set(-1.2, 0.1, -0.4);
leftTemporal.rotation.z = 0.1;
leftTemporal.userData = {
feature: 'temporalBones',
originalMaterial: boneMaterial.clone(),
xrayMaterial: xrayMaterial.clone()
};
skullGroup.add(leftTemporal);
const rightTemporal = temporalGroup.clone();
rightTemporal.position.set(1.2, 0.1, -0.4);
rightTemporal.rotation.z = -0.1;
rightTemporal.userData = {
feature: 'temporalBones',
originalMaterial: boneMaterial.clone(),
xrayMaterial: xrayMaterial.clone()
};
skullGroup.add(rightTemporal);
// Create more accurate occipital bone with foramen magnum
const occipitalGroup = new THREE.Group();
// Main occipital bone
const occipitalMain = new THREE.Mesh(
new THREE.SphereGeometry(1.0, 32, 32, 0, Math.PI, 0, Math.PI * 0.8),
boneMaterial.clone()
);
occipitalMain.rotation.x = 0.3;
// Foramen magnum (approximated as a cylinder)
const foramenMagnum = new THREE.Mesh(
new THREE.CylinderGeometry(0.15, 0.15, 0.3, 16),
xrayMaterial.clone()
);
foramenMagnum.position.set(0, -0.4, -0.6);
foramenMagnum.rotation.x = Math.PI / 2;
occipitalGroup.add(occipitalMain);
occipitalGroup.add(foramenMagnum);
const occipitalBone = occipitalGroup;
occipitalBone.position.set(0, 0.2, -1.1);
occipitalBone.userData = {
feature: 'occipitalBone',
originalMaterial: boneMaterial.clone(),
xrayMaterial: xrayMaterial.clone()
};
skullGroup.add(occipitalBone);
// Create sphenoid bone with greater wings
const sphenoidGroup = new THREE.Group();
// Body of sphenoid
const sphenoidBody = new THREE.Mesh(
new THREE.BoxGeometry(0.8, 0.4, 0.6),
boneMaterial.clone()
);
// Greater wings
const leftGreaterWing = new THREE.Mesh(
new THREE.BoxGeometry(0.6, 0.2, 0.8),
boneMaterial.clone()
);
leftGreaterWing.position.set(-0.5, 0, 0);
leftGreaterWing.rotation.z = 0.3;
const rightGreaterWing = new THREE.Mesh(
new THREE.BoxGeometry(0.6, 0.2, 0.8),
boneMaterial.clone()
);
rightGreaterWing.position.set(0.5, 0, 0);
rightGreaterWing.rotation.z = -0.3;
sphenoidGroup.add(sphenoidBody);
sphenoidGroup.add(leftGreaterWing);
sphenoidGroup.add(rightGreaterWing);
const sphenoidBone = sphenoidGroup;
sphenoidBone.position.set(0, -0.2, 0.1);
sphenoidBone.userData = {
feature: 'sphenoidBone',
originalMaterial: boneMaterial.clone(),
xrayMaterial: xrayMaterial.clone()
};
skullGroup.add(sphenoidBone);
// Create ethmoid bone with cribriform plate
const ethmoidGroup = new THREE.Group();
const ethmoidBody = new THREE.Mesh(
new THREE.BoxGeometry(0.4, 0.3, 0.15),
boneMaterial.clone()
);
// Cribriform plate (perforated)
const cribriformPlate = new THREE.Mesh(
new THREE.BoxGeometry(0.5, 0.05, 0.2),
boneMaterial.clone()
);
cribriformPlate.position.set(0, 0.2, 0);
ethmoidGroup.add(ethmoidBody);
ethmoidGroup.add(cribriformPlate);
const ethmoidBone = ethmoidGroup;
ethmoidBone.position.set(0, 0.3, 1.1);
ethmoidBone.userData = {
feature: 'ethmoidBone',
originalMaterial: boneMaterial.clone(),
xrayMaterial: xrayMaterial.clone()
};
skullGroup.add(ethmoidBone);
// Create maxilla with alveolar process
const maxillaGroup = new THREE.Group();
const maxillaBody = new THREE.Mesh(
new THREE.BoxGeometry(1.2, 0.8, 0.6),
boneMaterial.clone()
);
// Alveolar process for teeth
const alveolarProcess = new THREE.Mesh(
new THREE.BoxGeometry(1.3, 0.2, 0.7),
boneMaterial.clone()
);
alveolarProcess.position.set(0, -0.5, 0.1);
maxillaGroup.add(maxillaBody);
maxillaGroup.add(alveolarProcess);
const maxilla = maxillaGroup;
maxilla.position.set(0, -0.4, 0.7);
maxilla.userData = {
feature: 'maxilla',
originalMaterial: boneMaterial.clone(),
xrayMaterial: xrayMaterial.clone()
};
skullGroup.add(maxilla);
// Create mandible with condyles and coronoid processes
const mandibleGroup = new THREE.Group();
// Body of mandible
const mandibleBody = new THREE.Mesh(
new THREE.BoxGeometry(1.4, 0.6, 0.5),
boneMaterial.clone()
);
// Ramus
const leftRamus = new THREE.Mesh(
new THREE.BoxGeometry(0.2, 0.8, 0.4),
boneMaterial.clone()
);
leftRamus.position.set(-0.6, 0.4, 0);
const rightRamus = new THREE.Mesh(
new THREE.BoxGeometry(0.2, 0.8, 0.4),
boneMaterial.clone()
);
rightRamus.position.set(0.6, 0.4, 0);
// Condyles
const leftCondyle = new THREE.Mesh(
new THREE.SphereGeometry(0.15, 16, 16),
boneMaterial.clone()
);
leftCondyle.position.set(-0.6, 0.8, 0);
const rightCondyle = new THREE.Mesh(
new THREE.SphereGeometry(0.15, 16, 16),
boneMaterial.clone()
);
rightCondyle.position.set(0.6, 0.8, 0);
// Coronoid processes
const leftCoronoid = new THREE.Mesh(
new THREE.ConeGeometry(0.1, 0.3, 8),
boneMaterial.clone()
);
leftCoronoid.position.set(-0.6, 0.7, 0.2);
const rightCoronoid = new THREE.Mesh(
new THREE.ConeGeometry(0.1, 0.3, 8),
boneMaterial.clone()
);
rightCoronoid.position.set(0.6, 0.7, 0.2);
mandibleGroup.add(mandibleBody);
mandibleGroup.add(leftRamus);
mandibleGroup.add(rightRamus);
mandibleGroup.add(leftCondyle);
mandibleGroup.add(rightCondyle);
mandibleGroup.add(leftCoronoid);
mandibleGroup.add(rightCoronoid);
const mandible = mandibleGroup;
mandible.position.set(0, -1.0, 0.3);
mandible.userData = {
feature: 'mandible',
originalMaterial: boneMaterial.clone(),
xrayMaterial: xrayMaterial.clone()
};
skullGroup.add(mandible);
// Create zygomatic bones with temporal process
const zygomaticGroup = new THREE.Group();
// Main zygomatic body
const zygomaticBody = new THREE.Mesh(
new THREE.SphereGeometry(0.25, 16, 16),
boneMaterial.clone()
);
// Temporal process
const temporalProcess = new THREE.Mesh(
new THREE.BoxGeometry(0.6, 0.15, 0.15),
boneMaterial.clone()
);
temporalProcess.position.set(-0.3, 0, 0);
temporalProcess.rotation.z = 0.3;
// Frontal process
const frontalProcess = new THREE.Mesh(
new THREE.BoxGeometry(0.15, 0.5, 0.15),
boneMaterial.clone()
);
frontalProcess.position.set(0, 0.2, 0.2);
zygomaticGroup.add(zygomaticBody);
zygomaticGroup.add(temporalProcess);
zygomaticGroup.add(frontalProcess);
const leftZygomatic = zygomaticGroup.clone();
leftZygomatic.position.set(-0.8, -0.1, 0.8);
leftZygomatic.userData = {
feature: 'zygomaticBones',
originalMaterial: boneMaterial.clone(),
xrayMaterial: xrayMaterial.clone()
};
skullGroup.add(leftZygomatic);
const rightZygomatic = zygomaticGroup.clone();
rightZygomatic.position.set(0.8, -0.1, 0.8);
rightZygomatic.rotation.y = Math.PI;
rightZygomatic.userData = {
feature: 'zygomaticBones',
originalMaterial: boneMaterial.clone(),
xrayMaterial: xrayMaterial.clone()
};
skullGroup.add(rightZygomatic);
// Create nasal bones
const nasalGroup = new THREE.Group();
const leftNasalBone = new THREE.Mesh(
new THREE.BoxGeometry(0.15, 0.4, 0.08),
boneMaterial.clone()
);
leftNasalBone.position.set(-0.1, 0, 0);
const rightNasalBone = new THREE.Mesh(
new THREE.BoxGeometry(0.15, 0.4, 0.08),
boneMaterial.clone()
);
rightNasalBone.position.set(0.1, 0, 0);
nasalGroup.add(leftNasalBone);
nasalGroup.add(rightNasalBone);
const nasalBones = nasalGroup;
nasalBones.position.set(0, 0.4, 1.2);
nasalBones.userData = {
feature: 'nasalBones',
originalMaterial: boneMaterial.clone(),
xrayMaterial: xrayMaterial.clone()
};
skullGroup.add(nasalBones);
createSutures();
// Hide loading message
document.getElementById('loading').style.display = 'none';
}
function createSutures() {
const sutureMaterial = new THREE.LineBasicMaterial({
color: 0x8b4513,
linewidth: 3
});
// Sagittal suture
const sagittalPoints = [];
for (let i = 0; i <= 20; i++) {
const y = 1.5 - (i * 0.15);
const z = -0.2 + Math.sin(i * 0.3) * 0.1;
sagittalPoints.push(new THREE.Vector3(0, y, z));
}
const sagittalGeometry = new THREE.BufferGeometry().setFromPoints(sagittalPoints);
const sagittalSuture = new THREE.Line(sagittalGeometry, sutureMaterial.clone());
sagittalSuture.userData = { suture: 'sagittal' };
suturesGroup.add(sagittalSuture);
// Coronal suture
const coronalPoints = [];
for (let i = 0; i <= 20; i++) {
const x = -1 + (i * 0.1);
const y = 1.2 + Math.sin(i * 0.4) * 0.1;
const z = 0.8 + Math.cos(i * 0.3) * 0.2;
coronalPoints.push(new THREE.Vector3(x, y, z));
}
const coronalGeometry = new THREE.BufferGeometry().setFromPoints(coronalPoints);
const coronalSuture = new THREE.Line(coronalGeometry, sutureMaterial.clone());
coronalSuture.userData = { suture: 'coronal' };
suturesGroup.add(coronalSuture);
// Lambdoid suture
const lambdoidPoints = [];
for (let i = 0; i <= 20; i++) {
const x = -0.8 + (i * 0.08);
const y = 0.8 - Math.sin(i * 0.3) * 0.2;
const z = -0.8 + Math.cos(i * 0.4) * 0.1;
lambdoidPoints.push(new THREE.Vector3(x, y, z));
}
const lambdoidGeometry = new THREE.BufferGeometry().setFromPoints(lambdoidPoints);
const lambdoidSuture = new THREE.Line(lambdoidGeometry, sutureMaterial.clone());
lambdoidSuture.userData = { suture: 'lambdoid' };
suturesGroup.add(lambdoidSuture);
// Squamosal sutures
const squamosalPointsLeft = [];
for (let i = 0; i <= 15; i++) {
const y = 0.5 - (i * 0.06);
const z = -0.5 + (i * 0.06);
const x = -1.0 + Math.sin(i * 0.4) * 0.1;
squamosalPointsLeft.push(new THREE.Vector3(x, y, z));
}
const squamosalGeometryLeft = new THREE.BufferGeometry().setFromPoints(squamosalPointsLeft);
const squamosalSutureLeft = new THREE.Line(squamosalGeometryLeft, sutureMaterial.clone());
squamosalSutureLeft.userData = { suture: 'squamosal' };
suturesGroup.add(squamosalSutureLeft);
const squamosalPointsRight = [];
for (let i = 0; i <= 15; i++) {
const y = 0.5 - (i * 0.06);
const z = -0.5 + (i * 0.06);
const x = 1.0 - Math.sin(i * 0.4) * 0.1;
squamosalPointsRight.push(new THREE.Vector3(x, y, z));
}
const squamosalGeometryRight = new THREE.BufferGeometry().setFromPoints(squamosalPointsRight);
const squamosalSutureRight = new THREE.Line(squamosalGeometryRight, sutureMaterial.clone());
squamosalSutureRight.userData = { suture: 'squamosal' };
suturesGroup.add(squamosalSutureRight);
}
createSkull();
// Mouse interaction
const raycaster = new THREE.Raycaster();
const mouse = new THREE.Vector2();
let hoveredObject = null;
let isXrayView = false;
let featuresVisible = true;
let autoRotate = false;
let measurementsVisible = false;
function onMouseMove(event) {
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
raycaster.setFromCamera(mouse, camera);
const intersects = raycaster.intersectObjects(skullGroup.children, true);
if (intersects.length > 0 && featuresVisible) {
const object = intersects[0].object;
if (hoveredObject !== object && object.userData.feature) {
// Reset previous hover
if (hoveredObject) {
hoveredObject.material.emissive = new THREE.Color(0x000000);
hoveredObject.material.emissiveIntensity = 0;
}
// Highlight new object
hoveredObject = object;
if (!isXrayView) {
hoveredObject.material.emissive = new THREE.Color(0x5eead4);
hoveredObject.material.emissiveIntensity = 0.3;
}
// Show tooltip
const tooltip = document.getElementById('tooltip');
tooltip.style.display = 'block';
tooltip.style.left = event.clientX + 15 + 'px';
tooltip.style.top = event.clientY - 40 + 'px';
tooltip.textContent = featureData[object.userData.feature].name;
}
} else {
// Hide tooltip and reset hover
if (hoveredObject) {
hoveredObject.material.emissive = new THREE.Color(0x000000);
hoveredObject.material.emissiveIntensity = 0;
hoveredObject = null;
}
document.getElementById('tooltip').style.display = 'none';
}
}
function onClick(event) {
if (hoveredObject && hoveredObject.userData.feature) {
showFeatureInfo(hoveredObject.userData.feature);
}
}
function showFeatureInfo(featureKey) {
const feature = featureData[featureKey];
document.getElementById('feature-title').textContent = feature.name;
document.getElementById('feature-description').textContent = feature.description;
document.getElementById('feature-info').style.display = 'block';
}
function closeFeatureInfo() {
document.getElementById('feature-info').style.display = 'none';
}
// View mode controls
document.getElementById('normal-view').addEventListener('click', function() {
isXrayView = false;
this.classList.add('active');
document.getElementById('xray-view').classList.remove('active');
skullGroup.children.forEach(child => {
child.traverse((node) => {
if (node.userData.originalMaterial) {
node.material = node.userData.originalMaterial;
}
});
});
});
document.getElementById('xray-view').addEventListener('click', function() {
isXrayView = true;
this.classList.add('active');
document.getElementById('normal-view').classList.remove('active');
skullGroup.children.forEach(child => {
child.traverse((node) => {
if (node.userData.xrayMaterial) {
node.material = node.userData.xrayMaterial;
}
});
});
});
document.getElementById('toggle-features').addEventListener('click', function() {
featuresVisible = !featuresVisible;
this.textContent = featuresVisible ? 'Hide All' : 'Show All';
this.classList.toggle('active');
if (!featuresVisible) {
document.getElementById('tooltip').style.display = 'none';
if (hoveredObject) {
hoveredObject.material.emissive = new THREE.Color(0x000000);
hoveredObject.material.emissiveIntensity = 0;
hoveredObject = null;
}
}
});
document.getElementById('auto-rotate').addEventListener('click', function() {
autoRotate = !autoRotate;
this.classList.toggle('active');
controls.autoRotate = autoRotate;
controls.autoRotateSpeed = 1.0;
});
document.getElementById('toggle-measure').addEventListener('click', function() {
measurementsVisible = !measurementsVisible;
this.textContent = measurementsVisible ? 'On' : 'Off';
this.classList.toggle('active');
document.getElementById('measurements-panel').style.display = measurementsVisible ? 'block' : 'none';
});
// Suture controls
document.getElementById('sagittal-suture').addEventListener('click', function() {
this.classList.toggle('active');
suturesGroup.children.forEach(child => {
if (child.userData.suture === 'sagittal') {
child.visible = !child.visible;
}
});
});
document.getElementById('coronal-suture').addEventListener('click', function() {
this.classList.toggle('active');
suturesGroup.children.forEach(child => {
if (child.userData.suture === 'coronal') {
child.visible = !child.visible;
}
});
});
document.getElementById('lambdoid-suture').addEventListener('click', function() {
this.classList.toggle('active');
suturesGroup.children.forEach(child => {
if (child.userData.suture === 'lambdoid') {
child.visible = !child.visible;
}
});
});
document.getElementById('squamosal-suture').addEventListener('click', function() {
this.classList.toggle('active');
suturesGroup.children.forEach(child => {
if (child.userData.suture === 'squamosal') {
child.visible = !child.visible;
}
});
});
// Event listeners
window.addEventListener('mousemove', onMouseMove);
window.addEventListener('click', onClick);
window.addEventListener('resize', onWindowResize);
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
// Main animation loop with subtle skull rotation
function animate() {
requestAnimationFrame(animate);
// Gentle rotation when not interacting
if (!controls.autoRotate && !hoveredObject) {
skullGroup.rotation.y += 0.002;
}
controls.update();
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>