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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Abstract Position Auction Visualizer</title>
|
| 7 |
+
<style>
|
| 8 |
+
body { margin: 0; overflow: hidden; background-color: #111; color: #fff; font-family: 'Inter', sans-serif; display: flex; }
|
| 9 |
+
#canvasContainer { flex-grow: 1; position: relative; }
|
| 10 |
+
canvas { display: block; }
|
| 11 |
+
#info {
|
| 12 |
+
position: absolute;
|
| 13 |
+
top: 10px;
|
| 14 |
+
left: 10px;
|
| 15 |
+
padding: 10px;
|
| 16 |
+
background: rgba(0,0,0,0.6);
|
| 17 |
+
border-radius: 8px;
|
| 18 |
+
font-size: 14px;
|
| 19 |
+
max-width: 280px; /* Adjusted width */
|
| 20 |
+
z-index: 10;
|
| 21 |
+
}
|
| 22 |
+
.button-container {
|
| 23 |
+
position: absolute;
|
| 24 |
+
bottom: 20px;
|
| 25 |
+
left: 50%;
|
| 26 |
+
transform: translateX(-50%);
|
| 27 |
+
display: flex;
|
| 28 |
+
gap: 10px;
|
| 29 |
+
z-index: 10;
|
| 30 |
+
}
|
| 31 |
+
.button-container button {
|
| 32 |
+
background-color: #007bff;
|
| 33 |
+
color: white;
|
| 34 |
+
border: none;
|
| 35 |
+
padding: 10px 15px;
|
| 36 |
+
text-align: center;
|
| 37 |
+
text-decoration: none;
|
| 38 |
+
display: inline-block;
|
| 39 |
+
font-size: 14px;
|
| 40 |
+
border-radius: 5px;
|
| 41 |
+
cursor: pointer;
|
| 42 |
+
transition: background-color 0.3s ease;
|
| 43 |
+
}
|
| 44 |
+
.button-container button:hover {
|
| 45 |
+
background-color: #0056b3;
|
| 46 |
+
}
|
| 47 |
+
.button-container button.active {
|
| 48 |
+
background-color: #28a745;
|
| 49 |
+
}
|
| 50 |
+
#messageBox {
|
| 51 |
+
position: absolute;
|
| 52 |
+
top: 50%;
|
| 53 |
+
left: 50%;
|
| 54 |
+
transform: translate(-50%, -50%);
|
| 55 |
+
background-color: rgba(0,0,0,0.85);
|
| 56 |
+
color: white;
|
| 57 |
+
padding: 20px;
|
| 58 |
+
border-radius: 10px;
|
| 59 |
+
text-align: center;
|
| 60 |
+
display: none;
|
| 61 |
+
z-index: 1000;
|
| 62 |
+
box-shadow: 0 0 15px rgba(255,255,255,0.3);
|
| 63 |
+
min-width: 300px;
|
| 64 |
+
}
|
| 65 |
+
#auctionLogContainer {
|
| 66 |
+
width: 300px; /* Width of the auction log panel */
|
| 67 |
+
height: 100vh;
|
| 68 |
+
background: rgba(10,10,20,0.85);
|
| 69 |
+
padding: 15px;
|
| 70 |
+
box-sizing: border-box;
|
| 71 |
+
overflow-y: auto;
|
| 72 |
+
font-size: 12px;
|
| 73 |
+
border-left: 1px solid #333;
|
| 74 |
+
}
|
| 75 |
+
#auctionLogContainer h3 {
|
| 76 |
+
margin-top: 0;
|
| 77 |
+
color: #00ffff; /* Cyan title */
|
| 78 |
+
border-bottom: 1px solid #00ffff;
|
| 79 |
+
padding-bottom: 5px;
|
| 80 |
+
}
|
| 81 |
+
.log-entry {
|
| 82 |
+
margin-bottom: 8px;
|
| 83 |
+
padding: 5px;
|
| 84 |
+
background-color: rgba(255,255,255,0.05);
|
| 85 |
+
border-radius: 4px;
|
| 86 |
+
border-left: 3px solid #00aaff;
|
| 87 |
+
}
|
| 88 |
+
.log-entry strong { color: #aadeff; }
|
| 89 |
+
</style>
|
| 90 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 91 |
+
</head>
|
| 92 |
+
<body>
|
| 93 |
+
<div id="canvasContainer">
|
| 94 |
+
<!-- Info panel and buttons will be relative to this -->
|
| 95 |
+
<div id="info">
|
| 96 |
+
<h2 class="text-lg font-semibold mb-2">Abstract Auction Visualizer</h2>
|
| 97 |
+
<p><strong>Concept:</strong> Matching 'creatives' to 'positions' in AI content.</p>
|
| 98 |
+
<p class="mt-2"><strong>Interaction:</strong>
|
| 99 |
+
<br>- Drag to rotate, Scroll to zoom.
|
| 100 |
+
<br>- Click a Creative, then a Position.
|
| 101 |
+
</p>
|
| 102 |
+
<p id="score" class="mt-2 font-bold">Player Score: 0</p>
|
| 103 |
+
<p id="modeInfo" class="mt-1">Mode: MNL (Order-Insensitive)</p>
|
| 104 |
+
<p id="status" class="mt-1 text-xs">Status: Idle</p>
|
| 105 |
+
</div>
|
| 106 |
+
|
| 107 |
+
<div class="button-container">
|
| 108 |
+
<button id="mnlButton" class="active">MNL Mode</button>
|
| 109 |
+
<button id="cascadeButton">Cascade Mode</button>
|
| 110 |
+
<button id="resetButton">Reset Scene</button>
|
| 111 |
+
</div>
|
| 112 |
+
|
| 113 |
+
<div id="messageBox">
|
| 114 |
+
<p id="messageText"></p>
|
| 115 |
+
<button id="closeMessageButton" class="mt-4 bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">OK</button>
|
| 116 |
+
</div>
|
| 117 |
+
<!-- Canvas will be appended here by Three.js -->
|
| 118 |
+
</div>
|
| 119 |
+
|
| 120 |
+
<div id="auctionLogContainer">
|
| 121 |
+
<h3><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-terminal-fill inline-block mr-1" viewBox="0 0 16 16">
|
| 122 |
+
<path d="M0 3a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3zm9.5 5.5h-3a.5.5 0 0 0 0 1h3a.5.5 0 0 0 0-1zm-6.354-.354a.5.5 0 1 0 .708.708l2 2a.5.5 0 0 0 .708 0l2-2a.5.5 0 0 0-.708-.708L5.5 9.793 3.146 7.146z"/>
|
| 123 |
+
</svg>Auction Log</h3>
|
| 124 |
+
<div id="auctionLogEntries">
|
| 125 |
+
<!-- Log entries will be added here -->
|
| 126 |
+
</div>
|
| 127 |
+
</div>
|
| 128 |
+
|
| 129 |
+
<script type="importmap">
|
| 130 |
+
{
|
| 131 |
+
"imports": {
|
| 132 |
+
"three": "https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js",
|
| 133 |
+
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/"
|
| 134 |
+
}
|
| 135 |
+
}
|
| 136 |
+
</script>
|
| 137 |
+
<script type="module">
|
| 138 |
+
import * as THREE from 'three';
|
| 139 |
+
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
| 140 |
+
|
| 141 |
+
let scene, camera, renderer, controls;
|
| 142 |
+
let aiContentGroup;
|
| 143 |
+
let sponsoredCreatives = [];
|
| 144 |
+
let placementPositions = [];
|
| 145 |
+
|
| 146 |
+
let selectedCreative = null;
|
| 147 |
+
let playerScore = 0; // Score for player's manual matches
|
| 148 |
+
let currentMode = 'MNL';
|
| 149 |
+
|
| 150 |
+
const raycaster = new THREE.Raycaster();
|
| 151 |
+
const mouse = new THREE.Vector2();
|
| 152 |
+
|
| 153 |
+
let auctionLog = [];
|
| 154 |
+
const MAX_LOG_ENTRIES = 20;
|
| 155 |
+
let auctionIntervalId = null;
|
| 156 |
+
|
| 157 |
+
// --- UI Elements ---
|
| 158 |
+
const canvasContainer = document.getElementById('canvasContainer');
|
| 159 |
+
const scoreElement = document.getElementById('score');
|
| 160 |
+
const modeInfoElement = document.getElementById('modeInfo');
|
| 161 |
+
const statusElement = document.getElementById('status');
|
| 162 |
+
const mnlButton = document.getElementById('mnlButton');
|
| 163 |
+
const cascadeButton = document.getElementById('cascadeButton');
|
| 164 |
+
const resetButton = document.getElementById('resetButton');
|
| 165 |
+
const messageBox = document.getElementById('messageBox');
|
| 166 |
+
const messageText = document.getElementById('messageText');
|
| 167 |
+
const closeMessageButton = document.getElementById('closeMessageButton');
|
| 168 |
+
const auctionLogEntriesContainer = document.getElementById('auctionLogEntries');
|
| 169 |
+
|
| 170 |
+
function showMessage(text, duration = 3000) {
|
| 171 |
+
messageText.textContent = text;
|
| 172 |
+
messageBox.style.display = 'block';
|
| 173 |
+
if (duration > 0) {
|
| 174 |
+
setTimeout(() => {
|
| 175 |
+
if (messageText.textContent === text) { // Only hide if it's the same message
|
| 176 |
+
messageBox.style.display = 'none';
|
| 177 |
+
}
|
| 178 |
+
}, duration);
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
+
closeMessageButton.addEventListener('click', () => messageBox.style.display = 'none');
|
| 182 |
+
|
| 183 |
+
function updateStatus(text) {
|
| 184 |
+
if(statusElement) statusElement.textContent = `Status: ${text}`;
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
// --- Initialization ---
|
| 188 |
+
function init() {
|
| 189 |
+
scene = new THREE.Scene();
|
| 190 |
+
scene.background = new THREE.Color(0x111118);
|
| 191 |
+
scene.fog = new THREE.Fog(0x111118, 15, 60); // Adjusted fog
|
| 192 |
+
|
| 193 |
+
camera = new THREE.PerspectiveCamera(75, canvasContainer.clientWidth / canvasContainer.clientHeight, 0.1, 1000);
|
| 194 |
+
camera.position.set(0, 3, 12); // Slightly further out
|
| 195 |
+
|
| 196 |
+
renderer = new THREE.WebGLRenderer({ antialias: true });
|
| 197 |
+
renderer.setSize(canvasContainer.clientWidth, canvasContainer.clientHeight);
|
| 198 |
+
renderer.setPixelRatio(window.devicePixelRatio);
|
| 199 |
+
canvasContainer.appendChild(renderer.domElement); // Append to specific container
|
| 200 |
+
|
| 201 |
+
controls = new OrbitControls(camera, renderer.domElement);
|
| 202 |
+
controls.enableDamping = true;
|
| 203 |
+
controls.dampingFactor = 0.05;
|
| 204 |
+
controls.minDistance = 5;
|
| 205 |
+
controls.maxDistance = 40;
|
| 206 |
+
|
| 207 |
+
const ambientLight = new THREE.AmbientLight(0xffffff, 0.6);
|
| 208 |
+
scene.add(ambientLight);
|
| 209 |
+
const directionalLight = new THREE.DirectionalLight(0xffffff, 1.0);
|
| 210 |
+
directionalLight.position.set(5, 10, 7.5);
|
| 211 |
+
scene.add(directionalLight);
|
| 212 |
+
const pointLight = new THREE.PointLight(0x66ccff, 1, 150); // Softer blue
|
| 213 |
+
pointLight.position.set(-8, -3, -8);
|
| 214 |
+
scene.add(pointLight);
|
| 215 |
+
|
| 216 |
+
createAIContentStructure();
|
| 217 |
+
spawnSponsoredCreatives(7); // Start with a few more
|
| 218 |
+
createPlacementPositions(10); // And more positions
|
| 219 |
+
|
| 220 |
+
window.addEventListener('resize', onWindowResize, false);
|
| 221 |
+
renderer.domElement.addEventListener('click', onClick, false);
|
| 222 |
+
mnlButton.addEventListener('click', () => setMode('MNL'));
|
| 223 |
+
cascadeButton.addEventListener('click', () => setMode('CASCADE'));
|
| 224 |
+
resetButton.addEventListener('click', resetScene);
|
| 225 |
+
|
| 226 |
+
startAuctionSimulation();
|
| 227 |
+
updateUI();
|
| 228 |
+
animate();
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
// --- Procedural "AI Content" Structure ---
|
| 232 |
+
function createAIContentStructure() {
|
| 233 |
+
aiContentGroup = new THREE.Group();
|
| 234 |
+
scene.add(aiContentGroup);
|
| 235 |
+
const baseGeometry = new THREE.TorusKnotGeometry(2, 0.6, 100, 16, 2, 3); // More complex shape
|
| 236 |
+
|
| 237 |
+
for (let i = 0; i < 4; i++) { // More layers
|
| 238 |
+
const material = new THREE.MeshStandardMaterial({
|
| 239 |
+
color: new THREE.Color(0.2 + i * 0.1, 0.4 + i*0.05, 0.6 - i*0.1),
|
| 240 |
+
transparent: true,
|
| 241 |
+
opacity: 0.25 + i * 0.1,
|
| 242 |
+
wireframe: i % 2 !== 0,
|
| 243 |
+
metalness: 0.4,
|
| 244 |
+
roughness: 0.5,
|
| 245 |
+
side: THREE.DoubleSide
|
| 246 |
+
});
|
| 247 |
+
const layerMesh = new THREE.Mesh(baseGeometry.clone(), material); // Clone geometry
|
| 248 |
+
const scale = 1 + i * 0.10; // Increased scale difference
|
| 249 |
+
layerMesh.scale.set(scale, scale, scale);
|
| 250 |
+
|
| 251 |
+
const uniqueGeometry = baseGeometry.clone();
|
| 252 |
+
const posAttr = uniqueGeometry.attributes.position;
|
| 253 |
+
for (let j = 0; j < posAttr.count; j++) {
|
| 254 |
+
const v = new THREE.Vector3().fromBufferAttribute(posAttr, j);
|
| 255 |
+
v.x += (Math.random() - 0.5) * 0.15 * (i + 1); // Slightly more displacement
|
| 256 |
+
v.y += (Math.random() - 0.5) * 0.15 * (i + 1);
|
| 257 |
+
v.z += (Math.random() - 0.5) * 0.15 * (i + 1);
|
| 258 |
+
posAttr.setXYZ(j, v.x, v.y, v.z);
|
| 259 |
+
}
|
| 260 |
+
posAttr.needsUpdate = true;
|
| 261 |
+
uniqueGeometry.computeVertexNormals();
|
| 262 |
+
layerMesh.geometry = uniqueGeometry;
|
| 263 |
+
|
| 264 |
+
layerMesh.userData.isAiContentLayer = true;
|
| 265 |
+
layerMesh.userData.originalBaseScale = scale;
|
| 266 |
+
aiContentGroup.add(layerMesh);
|
| 267 |
+
}
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
// --- "Sponsored Creatives" (Bidders) ---
|
| 271 |
+
function spawnSponsoredCreatives(count) {
|
| 272 |
+
sponsoredCreatives.forEach(c => { /* dispose geometry and material */ }); // Full cleanup needed
|
| 273 |
+
sponsoredCreatives = [];
|
| 274 |
+
|
| 275 |
+
const creativeGeometries = [ /* same as before */
|
| 276 |
+
new THREE.BoxGeometry(0.5, 0.5, 0.5), new THREE.SphereGeometry(0.3, 16, 16),
|
| 277 |
+
new THREE.ConeGeometry(0.3, 0.6, 16), new THREE.TorusGeometry(0.3, 0.1, 8, 20)
|
| 278 |
+
];
|
| 279 |
+
const creativeColors = [0xff6347, 0x4682b4, 0x32cd32, 0xffd700, 0x9370db];
|
| 280 |
+
|
| 281 |
+
for (let i = 0; i < count; i++) {
|
| 282 |
+
const geometry = creativeGeometries[Math.floor(Math.random() * creativeGeometries.length)];
|
| 283 |
+
const material = new THREE.MeshStandardMaterial({
|
| 284 |
+
color: creativeColors[Math.floor(Math.random() * creativeColors.length)],
|
| 285 |
+
metalness: 0.5, roughness: 0.4, emissive: 0x111111
|
| 286 |
+
});
|
| 287 |
+
const creative = new THREE.Mesh(geometry, material);
|
| 288 |
+
|
| 289 |
+
const angle = (i / count) * Math.PI * 2;
|
| 290 |
+
const radius = 6 + Math.random() * 2.5; // Slightly further out
|
| 291 |
+
creative.position.set(Math.cos(angle) * radius, (Math.random() - 0.5) * 4, Math.sin(angle) * radius);
|
| 292 |
+
|
| 293 |
+
creative.userData = {
|
| 294 |
+
isCreative: true,
|
| 295 |
+
id: `CRTV_${i}_${Date.now()}`,
|
| 296 |
+
type: Math.floor(Math.random() * 3) ,
|
| 297 |
+
maxBid: 50 + Math.random() * 100 // Bidder's max willingness to pay
|
| 298 |
+
};
|
| 299 |
+
scene.add(creative);
|
| 300 |
+
sponsoredCreatives.push(creative);
|
| 301 |
+
}
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
// --- "Placement Positions" ---
|
| 305 |
+
function createPlacementPositions(count) {
|
| 306 |
+
placementPositions.forEach(p => { /* dispose */ }); // Full cleanup
|
| 307 |
+
placementPositions = [];
|
| 308 |
+
|
| 309 |
+
if (!aiContentGroup || aiContentGroup.children.length === 0) return;
|
| 310 |
+
const baseMeshLayer = aiContentGroup.children.find(child => child.userData.isAiContentLayer);
|
| 311 |
+
if (!baseMeshLayer) return;
|
| 312 |
+
|
| 313 |
+
const geometry = baseMeshLayer.geometry;
|
| 314 |
+
const vertices = geometry.attributes.position;
|
| 315 |
+
|
| 316 |
+
for (let i = 0; i < count; i++) {
|
| 317 |
+
const vertexIndex = Math.floor(Math.random() * vertices.count);
|
| 318 |
+
const posOnSurf = new THREE.Vector3().fromBufferAttribute(vertices, vertexIndex);
|
| 319 |
+
const worldPos = posOnSurf.clone().applyMatrix4(baseMeshLayer.matrixWorld);
|
| 320 |
+
const localPosInGrp = aiContentGroup.worldToLocal(worldPos.clone());
|
| 321 |
+
|
| 322 |
+
const posGeom = new THREE.SphereGeometry(0.18, 16, 16); // Slightly larger
|
| 323 |
+
const posMat = new THREE.MeshStandardMaterial({
|
| 324 |
+
color: 0x00dd00, emissive: 0x003300, transparent: true,
|
| 325 |
+
opacity: 0.5, wireframe: true, roughness: 0.7, metalness: 0.1
|
| 326 |
+
});
|
| 327 |
+
const positionMarker = new THREE.Mesh(posGeom, posMat);
|
| 328 |
+
positionMarker.position.copy(localPosInGrp);
|
| 329 |
+
|
| 330 |
+
positionMarker.userData = {
|
| 331 |
+
isPosition: true, id: `POS_${i}_${Date.now()}`, type: Math.floor(Math.random() * 3),
|
| 332 |
+
occupied: false, originalColorHex: posMat.color.getHex(),
|
| 333 |
+
originalEmissiveHex: posMat.emissive.getHex()
|
| 334 |
+
};
|
| 335 |
+
aiContentGroup.add(positionMarker);
|
| 336 |
+
placementPositions.push(positionMarker);
|
| 337 |
+
}
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
// --- Core Game/Auction Logic ---
|
| 341 |
+
function placeCreative(creative, position, source = "user", bidDetails = {}) {
|
| 342 |
+
if (!creative || !position || position.userData.occupied) return false;
|
| 343 |
+
|
| 344 |
+
position.userData.occupied = true;
|
| 345 |
+
position.userData.matchedCreativeType = creative.userData.type;
|
| 346 |
+
position.userData.source = source; // 'user' or 'auction'
|
| 347 |
+
|
| 348 |
+
position.material.color.set(creative.material.color.getHex()); // Match creative color
|
| 349 |
+
position.material.opacity = 0.95;
|
| 350 |
+
position.material.wireframe = false;
|
| 351 |
+
position.material.emissive.setHex(new THREE.Color(creative.material.color).multiplyScalar(0.5).getHex());
|
| 352 |
+
|
| 353 |
+
position.geometry.dispose();
|
| 354 |
+
position.geometry = new THREE.SphereGeometry(0.28, 16, 16); // Even larger when occupied
|
| 355 |
+
position.material.needsUpdate = true;
|
| 356 |
+
|
| 357 |
+
scene.remove(creative);
|
| 358 |
+
if(creative.geometry) creative.geometry.dispose();
|
| 359 |
+
if(creative.material) creative.material.dispose();
|
| 360 |
+
sponsoredCreatives = sponsoredCreatives.filter(c => c !== creative);
|
| 361 |
+
|
| 362 |
+
if (source === "user") {
|
| 363 |
+
playerScore += bidDetails.score || 50; // User gets points
|
| 364 |
+
showMessage(`Matched! Creative Type: ${creative.userData.type} to Pos Type: ${position.userData.type}. Score: +${bidDetails.score || 50}`, 2000);
|
| 365 |
+
} else if (source === "auction") {
|
| 366 |
+
// Log auction details
|
| 367 |
+
addAuctionLogEntry(
|
| 368 |
+
`Auction: Pos ${position.userData.id.substring(0,7)} won by ${creative.userData.id.substring(0,8)} (Type ${creative.userData.type}). Bid: ${bidDetails.bid.toFixed(2)}, Est. CTR: ${bidDetails.ctr.toFixed(2)}`
|
| 369 |
+
);
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
selectedCreative = null;
|
| 373 |
+
updateUI();
|
| 374 |
+
|
| 375 |
+
if (sponsoredCreatives.length < 3) { // Keep a minimum number of creatives
|
| 376 |
+
setTimeout(() => spawnSponsoredCreatives(5 + Math.floor(playerScore/100)), 1000);
|
| 377 |
+
}
|
| 378 |
+
if (placementPositions.every(p => p.userData.occupied)) {
|
| 379 |
+
showMessage(`All positions filled! Final Player Score: ${playerScore}. Scene resetting...`, 4000);
|
| 380 |
+
setTimeout(resetScene, 4000);
|
| 381 |
+
}
|
| 382 |
+
return true;
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
function attemptUserMatch(creative, position) {
|
| 386 |
+
if (!creative || !position || position.userData.occupied) {
|
| 387 |
+
showMessage("Invalid selection or position occupied.", 2000);
|
| 388 |
+
selectedCreative = null;
|
| 389 |
+
updateUI();
|
| 390 |
+
return;
|
| 391 |
+
}
|
| 392 |
+
let matchScore = 0;
|
| 393 |
+
const typeMatch = creative.userData.type === position.userData.type;
|
| 394 |
+
if (typeMatch) matchScore += 50; else matchScore += 10;
|
| 395 |
+
// User matches are simpler, direct score
|
| 396 |
+
placeCreative(creative, position, "user", { score: matchScore });
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
// --- Auction Simulation ---
|
| 400 |
+
function runAuctionCycle() {
|
| 401 |
+
updateStatus("Running auctions...");
|
| 402 |
+
const availablePositions = placementPositions.filter(p => !p.userData.occupied);
|
| 403 |
+
const availableCreatives = sponsoredCreatives.slice(); // Work with a copy
|
| 404 |
+
|
| 405 |
+
if (availablePositions.length === 0 || availableCreatives.length === 0) {
|
| 406 |
+
updateStatus("No auctions: positions full or no creatives.");
|
| 407 |
+
return;
|
| 408 |
+
}
|
| 409 |
+
|
| 410 |
+
availablePositions.forEach(pos => {
|
| 411 |
+
if (pos.userData.occupied || availableCreatives.length === 0) return; // Check again
|
| 412 |
+
|
| 413 |
+
let bestBid = -1;
|
| 414 |
+
let winnerInfo = null;
|
| 415 |
+
|
| 416 |
+
availableCreatives.forEach(crt => {
|
| 417 |
+
const typeMatch = crt.userData.type === pos.userData.type;
|
| 418 |
+
const simulatedCTR = (typeMatch ? 0.6 : 0.15) + Math.random() * 0.2; // 0.15 to 0.8
|
| 419 |
+
|
| 420 |
+
let bidValue = crt.userData.maxBid * (simulatedCTR / 0.8); // Bid proportional to CTR
|
| 421 |
+
bidValue *= (0.8 + Math.random() * 0.4); // Randomness in bid strength
|
| 422 |
+
|
| 423 |
+
// Cascade mode might prioritize filling earlier/better slots more aggressively
|
| 424 |
+
// or consider sequence, for now, let's make it slightly more competitive
|
| 425 |
+
if (currentMode === 'CASCADE' && typeMatch) {
|
| 426 |
+
bidValue *= 1.2;
|
| 427 |
+
}
|
| 428 |
+
|
| 429 |
+
if (bidValue > bestBid) {
|
| 430 |
+
bestBid = bidValue;
|
| 431 |
+
winnerInfo = { creative: crt, position: pos, bid: bidValue, ctr: simulatedCTR };
|
| 432 |
+
}
|
| 433 |
+
});
|
| 434 |
+
|
| 435 |
+
if (winnerInfo) {
|
| 436 |
+
placeCreative(winnerInfo.creative, winnerInfo.position, "auction", { bid: winnerInfo.bid, ctr: winnerInfo.ctr });
|
| 437 |
+
// Remove winner from this cycle's available creatives
|
| 438 |
+
const winnerIndex = availableCreatives.indexOf(winnerInfo.creative);
|
| 439 |
+
if (winnerIndex > -1) availableCreatives.splice(winnerIndex, 1);
|
| 440 |
+
}
|
| 441 |
+
});
|
| 442 |
+
updateStatus("Auctions complete. Idle.");
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
function addAuctionLogEntry(message) {
|
| 446 |
+
const entry = document.createElement('div');
|
| 447 |
+
entry.classList.add('log-entry');
|
| 448 |
+
entry.innerHTML = message.replace(/CRTV_(\w{4}).*?(\w{4})/, '<strong>CRTV-$1..$2</strong>')
|
| 449 |
+
.replace(/POS_(\w{4}).*?(\w{4})/, '<strong>POS-$1..$2</strong>');
|
| 450 |
+
|
| 451 |
+
auctionLogEntriesContainer.prepend(entry);
|
| 452 |
+
auctionLog.unshift(message);
|
| 453 |
+
if (auctionLog.length > MAX_LOG_ENTRIES) {
|
| 454 |
+
auctionLog.pop();
|
| 455 |
+
if (auctionLogEntriesContainer.children.length > MAX_LOG_ENTRIES) {
|
| 456 |
+
auctionLogEntriesContainer.removeChild(auctionLogEntriesContainer.lastChild);
|
| 457 |
+
}
|
| 458 |
+
}
|
| 459 |
+
}
|
| 460 |
+
|
| 461 |
+
function startAuctionSimulation() {
|
| 462 |
+
if (auctionIntervalId) clearInterval(auctionIntervalId);
|
| 463 |
+
// Run more frequently for more dynamic feel
|
| 464 |
+
auctionIntervalId = setInterval(runAuctionCycle, 4000 + Math.random() * 2000);
|
| 465 |
+
addAuctionLogEntry("Auction simulation started.");
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
function stopAuctionSimulation() {
|
| 469 |
+
if (auctionIntervalId) clearInterval(auctionIntervalId);
|
| 470 |
+
auctionIntervalId = null;
|
| 471 |
+
addAuctionLogEntry("Auction simulation stopped.");
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
function resetScene() {
|
| 475 |
+
stopAuctionSimulation();
|
| 476 |
+
playerScore = 0;
|
| 477 |
+
selectedCreative = null;
|
| 478 |
+
currentMode = 'MNL';
|
| 479 |
+
auctionLog = [];
|
| 480 |
+
auctionLogEntriesContainer.innerHTML = ""; // Clear log display
|
| 481 |
+
|
| 482 |
+
while(aiContentGroup.children.length > 0){ /* full dispose logic */ }
|
| 483 |
+
scene.remove(aiContentGroup);
|
| 484 |
+
placementPositions = [];
|
| 485 |
+
sponsoredCreatives.forEach(c => { /* full dispose */ });
|
| 486 |
+
sponsoredCreatives = [];
|
| 487 |
+
|
| 488 |
+
createAIContentStructure();
|
| 489 |
+
spawnSponsoredCreatives(7);
|
| 490 |
+
createPlacementPositions(10);
|
| 491 |
+
|
| 492 |
+
showMessage("Scene Reset. Auction simulation restarting.", 2000);
|
| 493 |
+
startAuctionSimulation();
|
| 494 |
+
updateUI();
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
function setMode(mode) {
|
| 498 |
+
currentMode = mode;
|
| 499 |
+
addAuctionLogEntry(`Switched to <strong>${mode}</strong> mode.`);
|
| 500 |
+
updateUI();
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
function updateUI() {
|
| 504 |
+
scoreElement.textContent = `Player Score: ${playerScore}`;
|
| 505 |
+
modeInfoElement.textContent = `Mode: ${currentMode === 'MNL' ? 'MNL (Order-Insensitive)' : 'Cascade (Order-Sensitive)'}`;
|
| 506 |
+
mnlButton.classList.toggle('active', currentMode === 'MNL');
|
| 507 |
+
cascadeButton.classList.toggle('active', currentMode === 'CASCADE');
|
| 508 |
+
|
| 509 |
+
sponsoredCreatives.forEach(c => {
|
| 510 |
+
if (c.material && c.material.emissive) {
|
| 511 |
+
c.material.emissive.setHex(c === selectedCreative ? 0xffee00 : 0x111111);
|
| 512 |
+
}
|
| 513 |
+
});
|
| 514 |
+
}
|
| 515 |
+
|
| 516 |
+
// --- Event Handlers ---
|
| 517 |
+
function onWindowResize() {
|
| 518 |
+
camera.aspect = canvasContainer.clientWidth / canvasContainer.clientHeight;
|
| 519 |
+
camera.updateProjectionMatrix();
|
| 520 |
+
renderer.setSize(canvasContainer.clientWidth, canvasContainer.clientHeight);
|
| 521 |
+
}
|
| 522 |
+
|
| 523 |
+
function onClick(event) {
|
| 524 |
+
// Calculate mouse position relative to the canvas container
|
| 525 |
+
const rect = renderer.domElement.getBoundingClientRect();
|
| 526 |
+
mouse.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
|
| 527 |
+
mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
|
| 528 |
+
|
| 529 |
+
raycaster.setFromCamera(mouse, camera);
|
| 530 |
+
const clickableObjects = [...sponsoredCreatives, ...aiContentGroup.children];
|
| 531 |
+
const intersects = raycaster.intersectObjects(clickableObjects, false);
|
| 532 |
+
|
| 533 |
+
if (intersects.length > 0) {
|
| 534 |
+
let clickedObj = null;
|
| 535 |
+
for (let i = 0; i < intersects.length; i++) { if (intersects[i].object.visible) { clickedObj = intersects[i].object; break; } }
|
| 536 |
+
if (!clickedObj) return;
|
| 537 |
+
|
| 538 |
+
if (clickedObj.userData.isCreative) {
|
| 539 |
+
if (selectedCreative === clickedObj) {
|
| 540 |
+
selectedCreative = null; showMessage("Creative deselected.", 1500);
|
| 541 |
+
} else {
|
| 542 |
+
selectedCreative = clickedObj; showMessage(`Creative ${selectedCreative.userData.id.substring(0,8)} selected. Click a position.`, 2000);
|
| 543 |
+
}
|
| 544 |
+
updateUI();
|
| 545 |
+
}
|
| 546 |
+
else if (clickedObj.userData.isPosition) {
|
| 547 |
+
if (selectedCreative) {
|
| 548 |
+
attemptUserMatch(selectedCreative, clickedObj);
|
| 549 |
+
} else {
|
| 550 |
+
showMessage("Select a Creative (shape) first.", 1500);
|
| 551 |
+
}
|
| 552 |
+
}
|
| 553 |
+
else if (clickedObj.userData.isAiContentLayer && selectedCreative) {
|
| 554 |
+
selectedCreative = null; showMessage("Selection cleared.", 1500); updateUI();
|
| 555 |
+
}
|
| 556 |
+
} else if (selectedCreative) {
|
| 557 |
+
selectedCreative = null; showMessage("Selection cleared.", 1500); updateUI();
|
| 558 |
+
}
|
| 559 |
+
}
|
| 560 |
+
|
| 561 |
+
// --- Animation Loop ---
|
| 562 |
+
function animate() {
|
| 563 |
+
requestAnimationFrame(animate);
|
| 564 |
+
const time = Date.now();
|
| 565 |
+
|
| 566 |
+
if (aiContentGroup) {
|
| 567 |
+
aiContentGroup.rotation.y += 0.0008; // Slower rotation
|
| 568 |
+
aiContentGroup.rotation.x += 0.0003;
|
| 569 |
+
|
| 570 |
+
aiContentGroup.children.forEach((child) => {
|
| 571 |
+
if (child.userData.isAiContentLayer) {
|
| 572 |
+
const scaleFactor = Math.sin(time * 0.0004 + child.userData.originalBaseScale * 7) * 0.015;
|
| 573 |
+
const baseScale = child.userData.originalBaseScale;
|
| 574 |
+
child.scale.setScalar(baseScale + scaleFactor);
|
| 575 |
+
}
|
| 576 |
+
else if (child.userData.isPosition && !child.userData.occupied) {
|
| 577 |
+
child.material.opacity = 0.4 + Math.sin(time * 0.0025 + child.userData.id.hashCode()) * 0.25;
|
| 578 |
+
child.material.emissive.setHex(new THREE.Color(child.userData.originalEmissiveHex).multiplyScalar(0.5 + Math.sin(time*0.002 + child.userData.id.hashCode())*0.5 ).getHex());
|
| 579 |
+
child.rotation.y += 0.015;
|
| 580 |
+
} else if (child.userData.isPosition && child.userData.occupied) {
|
| 581 |
+
// Optional: Subtle pulse for occupied slots
|
| 582 |
+
child.material.emissiveIntensity = 0.8 + Math.sin(time * 0.0015 + child.userData.id.hashCode()) * 0.2;
|
| 583 |
+
|
| 584 |
+
}
|
| 585 |
+
});
|
| 586 |
+
}
|
| 587 |
+
|
| 588 |
+
sponsoredCreatives.forEach(creative => {
|
| 589 |
+
creative.rotation.x += 0.005; creative.rotation.y += 0.007;
|
| 590 |
+
const hashOffset = creative.userData.id ? creative.userData.id.hashCode() : 0;
|
| 591 |
+
creative.position.y += Math.sin(time * 0.001 + hashOffset) * 0.008; // Slightly more float
|
| 592 |
+
});
|
| 593 |
+
|
| 594 |
+
controls.update();
|
| 595 |
+
renderer.render(scene, camera);
|
| 596 |
+
}
|
| 597 |
+
|
| 598 |
+
String.prototype.hashCode = function() { /* same as before */
|
| 599 |
+
var h=0,i,c;if(this.length===0)return h;for(i=0;i<this.length;i++){c=this.charCodeAt(i);h=((h<<5)-h)+c;h|=0;}return h;
|
| 600 |
+
};
|
| 601 |
+
|
| 602 |
+
// Start everything
|
| 603 |
+
init();
|
| 604 |
+
</script>
|
| 605 |
+
</body>
|
| 606 |
</html>
|