ドラッグで制御点移動、ダブルクリックで制御点の重み変更、スライダー視点変更

6x6 NURBS Surface Renderer(z-sort)

30°
30°
350
10
10

  I've created an interactive 6x6 NURBS surface renderer that meets all your requirements. The implementation includes: Key Features: Rendering Options: Wireframe display (toggle on/off) Shaded surface display with depth sorting (toggle on/off) Control points visualization (toggle on/off) Control net visualization (toggle on/off) View Control: Horizontal angle slider (0-360°) Vertical angle slider (-89° to 89°) Zoom slider for adjusting view distance Control Point Interaction: Control points visualized as blue dots Mouse hover highlights the closest control point Click and drag to move control points in 3D space Double-click on a control point to open a dialog for weight adjustment Surface Generation: Fully implemented NURBS surface using Bernstein

パラメーター範囲の正確な処理: u、vの値が確実に[0,1]の範囲に収まるように修正し、端の値を正確に1.0に設定 これにより境界での数値的な不安定さを解消 法線計算の改善: 境界での法線計算を強化し、前方差分/後方差分/中心差分を適切に使い分け パラメーター範囲外への参照を回避する処理を追加 三角形化の安全性向上: インデックスの範囲チェックを追加し、配列の範囲外アクセスを防止 有効なインデックスの場合のみ三角形を生成するように変更 制御点の表示改善: 制御点を奥行きでソートして正しく表示 識別しやすいように制御点のインデックス(i,j)を表示

Prompt: 6x6点の3次NURBS曲面をワイヤーフレームと陰影表示が選択表示できるコードをhtmlとJavaScriptでかけ。外部ライブラリーは使用せず曲面を三角形化し奥行きソート法で描画する。見る方向は水平方向と垂直方向の角度を操作するスライダーとする、制御点も表示制御点はマウスドラッグで移動できるようにしてください。さらにダブルクリックで制御点の重みも指定できるように
入力は4行だが870行のコード