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
+
<title>3D Apartment Visualization</title>
|
| 6 |
+
<!-- Content Security Policy: relax eval restrictions -->
|
| 7 |
+
<meta
|
| 8 |
+
http-equiv="Content-Security-Policy"
|
| 9 |
+
content="default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.jsdelivr.net; style-src 'self' 'unsafe-inline';"
|
| 10 |
+
/>
|
| 11 |
+
<style>
|
| 12 |
+
body {
|
| 13 |
+
margin: 0;
|
| 14 |
+
overflow: hidden;
|
| 15 |
+
background-color: #202020;
|
| 16 |
+
}
|
| 17 |
+
canvas {
|
| 18 |
+
display: block;
|
| 19 |
+
}
|
| 20 |
+
</style>
|
| 21 |
+
</head>
|
| 22 |
+
<body>
|
| 23 |
+
<script type="module">
|
| 24 |
+
// Import Three.js and OrbitControls directly from the CDN.
|
| 25 |
+
import * as THREE from 'https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js';
|
| 26 |
+
import { OrbitControls } from 'https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/controls/OrbitControls.js';
|
| 27 |
+
|
| 28 |
+
// Set up the scene.
|
| 29 |
+
const scene = new THREE.Scene();
|
| 30 |
+
scene.background = new THREE.Color(0x202020);
|
| 31 |
+
|
| 32 |
+
// Set up the camera.
|
| 33 |
+
const camera = new THREE.PerspectiveCamera(
|
| 34 |
+
75,
|
| 35 |
+
window.innerWidth / window.innerHeight,
|
| 36 |
+
0.1,
|
| 37 |
+
1000
|
| 38 |
+
);
|
| 39 |
+
camera.position.set(100, 100, 300);
|
| 40 |
+
|
| 41 |
+
// Set up the renderer.
|
| 42 |
+
const renderer = new THREE.WebGLRenderer({ antialias: true });
|
| 43 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
| 44 |
+
document.body.appendChild(renderer.domElement);
|
| 45 |
+
|
| 46 |
+
// Set up OrbitControls.
|
| 47 |
+
const controls = new OrbitControls(camera, renderer.domElement);
|
| 48 |
+
controls.enableDamping = true;
|
| 49 |
+
controls.dampingFactor = 0.05;
|
| 50 |
+
|
| 51 |
+
// Apartment data.
|
| 52 |
+
const apartments = [
|
| 53 |
+
{ rank: 1, pricePerSqm: 90788, block: 'D' },
|
| 54 |
+
{ rank: 2, pricePerSqm: 95584, block: 'D' },
|
| 55 |
+
{ rank: 3, pricePerSqm: 96545, block: 'C' },
|
| 56 |
+
{ rank: 4, pricePerSqm: 100171, block: 'C' },
|
| 57 |
+
{ rank: 5, pricePerSqm: 101833, block: 'C' },
|
| 58 |
+
{ rank: 6, pricePerSqm: 102200, block: 'B' },
|
| 59 |
+
{ rank: 7, pricePerSqm: 106238, block: 'D' },
|
| 60 |
+
{ rank: 8, pricePerSqm: 106327, block: 'B' },
|
| 61 |
+
{ rank: 9, pricePerSqm: 107423, block: 'B' },
|
| 62 |
+
{ rank: 10, pricePerSqm: 109136, block: 'A' }
|
| 63 |
+
];
|
| 64 |
+
|
| 65 |
+
// Create a group to hold all apartment spheres.
|
| 66 |
+
const apartmentGroup = new THREE.Group();
|
| 67 |
+
scene.add(apartmentGroup);
|
| 68 |
+
|
| 69 |
+
// Define colors for the blocks.
|
| 70 |
+
const blockColors = {
|
| 71 |
+
'A': 0xff0000,
|
| 72 |
+
'B': 0x0000ff,
|
| 73 |
+
'C': 0x00ff00,
|
| 74 |
+
'D': 0xffff00
|
| 75 |
+
};
|
| 76 |
+
|
| 77 |
+
// Create a sphere for each apartment.
|
| 78 |
+
apartments.forEach(apartment => {
|
| 79 |
+
// Calculate position based on apartment data.
|
| 80 |
+
const x = apartment.rank * 30;
|
| 81 |
+
const y = -(apartment.pricePerSqm - 90000) / 50;
|
| 82 |
+
let z;
|
| 83 |
+
switch (apartment.block) {
|
| 84 |
+
case 'A':
|
| 85 |
+
z = 0;
|
| 86 |
+
break;
|
| 87 |
+
case 'B':
|
| 88 |
+
z = 100;
|
| 89 |
+
break;
|
| 90 |
+
case 'C':
|
| 91 |
+
z = 200;
|
| 92 |
+
break;
|
| 93 |
+
case 'D':
|
| 94 |
+
z = 300;
|
| 95 |
+
break;
|
| 96 |
+
default:
|
| 97 |
+
z = 0;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
// Create the sphere geometry and material.
|
| 101 |
+
const geometry = new THREE.SphereGeometry(5, 16, 16);
|
| 102 |
+
const material = new THREE.MeshPhongMaterial({
|
| 103 |
+
color: blockColors[apartment.block] || 0xffffff
|
| 104 |
+
});
|
| 105 |
+
const sphere = new THREE.Mesh(geometry, material);
|
| 106 |
+
sphere.position.set(x, y, z);
|
| 107 |
+
apartmentGroup.add(sphere);
|
| 108 |
+
});
|
| 109 |
+
|
| 110 |
+
// Add lighting.
|
| 111 |
+
const ambientLight = new THREE.AmbientLight(0xffffff, 0.5);
|
| 112 |
+
scene.add(ambientLight);
|
| 113 |
+
const directionalLight = new THREE.DirectionalLight(0xffffff, 1);
|
| 114 |
+
directionalLight.position.set(0, 1, 1);
|
| 115 |
+
scene.add(directionalLight);
|
| 116 |
+
|
| 117 |
+
// Handle window resize.
|
| 118 |
+
window.addEventListener('resize', () => {
|
| 119 |
+
camera.aspect = window.innerWidth / window.innerHeight;
|
| 120 |
+
camera.updateProjectionMatrix();
|
| 121 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
| 122 |
+
});
|
| 123 |
+
|
| 124 |
+
// Animation loop.
|
| 125 |
+
function animate() {
|
| 126 |
+
requestAnimationFrame(animate);
|
| 127 |
+
controls.update();
|
| 128 |
+
renderer.render(scene, camera);
|
| 129 |
+
}
|
| 130 |
+
animate();
|
| 131 |
+
</script>
|
| 132 |
+
</body>
|
| 133 |
</html>
|