Aluode commited on
Commit
5d9d122
·
verified ·
1 Parent(s): 398c88c

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +6 -0
index.html CHANGED
@@ -645,6 +645,12 @@ function retreat(){ /* stepped back — re-dream the past */
645
  }
646
 
647
  /* ---------------- JS twins of the SDFs (collision + transitions) ---------- */
 
 
 
 
 
 
648
  /* the SAME kernel, mirrored exactly for collision and gate transitions */
649
  function shapeSDJ(x,y,z,d){
650
  const s=d.size;
 
645
  }
646
 
647
  /* ---------------- JS twins of the SDFs (collision + transitions) ---------- */
648
+ /* corridor segment distance — the twin of GLSL sdSeg */
649
+ function sdSegJ(px,py,pz,a,b){
650
+ const bax=b[0]-a[0],bay=b[1]-a[1],baz=b[2]-a[2];
651
+ const pax=px-a[0],pay=py-a[1],paz=pz-a[2];
652
+ const h=Math.min(Math.max((pax*bax+pay*bay+paz*baz)/(bax*bax+bay*bay+baz*baz),0),1);
653
+ return Math.hypot(pax-bax*h,pay-bay*h,paz-baz*h);}
654
  /* the SAME kernel, mirrored exactly for collision and gate transitions */
655
  function shapeSDJ(x,y,z,d){
656
  const s=d.size;