كمال غابتي · دورة · مجاني

التثبيت المكاني في AR

فهم كيفية تثبيت المحتوى الرقمي في نقطة ثابتة في الفضاء الحقيقي.

المفهوم

التثبيت المكاني يربط جسماً افتراضياً بنقطة من العالم الحقيقي. حتى عند تحريك الكاميرا، يبقى الجسم في مكانه. في AR، تُحسب تحويلة العالم→الكاميرا في كل إطار.

الكود

// Spatial anchor simulation: object stays fixed as 'camera' moves
let anchorX = 200, anchorY = 140; // fixed world position
let camX = 0, camY = 0;
function setup() { createCanvas(400, 280); }
function draw() {
  background(11, 15, 20);
  // Camera follows mouse slowly (simulating head movement)
  camX = lerp(camX, mouseX - width/2, 0.05);
  camY = lerp(camY, mouseY - height/2, 0.05);
  // World origin indicator
  stroke(60,70,90,80); strokeWeight(1);
  line(0, height/2, width, height/2);
  line(width/2, 0, width/2, height);
  // Anchored object: screen pos = world pos - camera offset
  let sx = anchorX - camX, sy = anchorY - camY;
  noStroke(); fill(55, 227, 195);
  ellipse(sx, sy, 28, 28);
  fill(255,255,255,120); textAlign(CENTER);
  text('anchor', sx, sy + 24);
}

للمزيد

استكشف الدورات المجانية الأخرى على صفحة الورش.

تدرب، تعاون، انشر — في 15 دقيقة.

← احجز مكالمة