@@ -249,7 +249,8 @@ protected void ellipseImpl(float a, float b, float c, float d) {
249249 if (graphicsId == 0 ) {
250250 return ;
251251 }
252- PWebGPU .ellipse (graphicsId , a , b , c , d );
252+ // ellipseImpl receives corner-form; native expects center.
253+ PWebGPU .ellipse (graphicsId , a + c / 2f , b + d / 2f , c , d );
253254 }
254255
255256 @ Override
@@ -482,7 +483,29 @@ public void camera(float eyeX, float eyeY, float eyeZ,
482483 return ;
483484 }
484485 PWebGPU .mode3d (graphicsId );
485- // TODO: camera up vector is not yet exposed by libprocessing FFI
486+ PWebGPU .transformSetPosition (graphicsId , eyeX , eyeY , eyeZ );
487+ PWebGPU .transformLookAt (graphicsId , centerX , centerY , centerZ );
488+ }
489+
490+ public void cameraPosition (float x , float y , float z ) {
491+ if (graphicsId == 0 ) {
492+ return ;
493+ }
494+ PWebGPU .transformSetPosition (graphicsId , x , y , z );
495+ }
496+
497+ public void cameraLookAt (float x , float y , float z ) {
498+ if (graphicsId == 0 ) {
499+ return ;
500+ }
501+ PWebGPU .transformLookAt (graphicsId , x , y , z );
502+ }
503+
504+ public void mode3d () {
505+ if (graphicsId == 0 ) {
506+ return ;
507+ }
508+ PWebGPU .mode3d (graphicsId );
486509 }
487510
488511 @ Override
@@ -502,6 +525,46 @@ public void ortho(float left, float right, float bottom, float top, float near,
502525 PWebGPU .ortho (graphicsId , left , right , bottom , top , near , far );
503526 }
504527
528+ // ── Lights ───────────────────────────────────────────────────────────
529+
530+ @ Override
531+ public void directionalLight (float r , float g , float b ,
532+ float nx , float ny , float nz ) {
533+ if (graphicsId == 0 ) return ;
534+ long light = PWebGPU .lightCreateDirectional (graphicsId , r , g , b , 1.0f , 600.0f );
535+ PWebGPU .transformSetRotation (light , nx , ny , nz );
536+ }
537+
538+ @ Override
539+ public void pointLight (float r , float g , float b ,
540+ float x , float y , float z ) {
541+ if (graphicsId == 0 ) return ;
542+ long light = PWebGPU .lightCreatePoint (graphicsId , r , g , b , 1.0f , 100000.0f , 800.0f , 0.0f );
543+ PWebGPU .transformSetPosition (light , x , y , z );
544+ }
545+
546+ public long directionalLight (float r , float g , float b , float illuminance ) {
547+ if (graphicsId == 0 ) return 0 ;
548+ return PWebGPU .lightCreateDirectional (graphicsId , r , g , b , 1.0f , illuminance );
549+ }
550+
551+ public long pointLight (float r , float g , float b ,
552+ float intensity , float range , float radius ,
553+ float x , float y , float z ) {
554+ if (graphicsId == 0 ) return 0 ;
555+ long light = PWebGPU .lightCreatePoint (graphicsId , r , g , b , 1.0f , intensity , range , radius );
556+ PWebGPU .transformSetPosition (light , x , y , z );
557+ return light ;
558+ }
559+
560+ public long spotLight (float r , float g , float b ,
561+ float intensity , float range , float radius ,
562+ float innerAngle , float outerAngle ) {
563+ if (graphicsId == 0 ) return 0 ;
564+ return PWebGPU .lightCreateSpot (graphicsId , r , g , b , 1.0f ,
565+ intensity , range , radius , innerAngle , outerAngle );
566+ }
567+
505568 // ── Images / shapes ─────────────────────────────────────────────────
506569
507570 public PImageWebGPU createImage (int width , int height , int format ) {
@@ -525,6 +588,15 @@ public void model(long geometryId) {
525588 PWebGPU .model (graphicsId , geometryId );
526589 }
527590
591+ // ── Materials ───────────────────────────────────────────────────────
592+
593+ public void useMaterial (Material mat ) {
594+ if (graphicsId == 0 ) {
595+ return ;
596+ }
597+ PWebGPU .material (graphicsId , mat .id ());
598+ }
599+
528600 // ── Helpers ──────────────────────────────────────────────────────────
529601
530602 private byte [] pixelsToRGBA (int [] pixels ) {
0 commit comments