@@ -115,7 +115,7 @@ import p5 from '../core/main';
115
115
* @param {p5.Color } color color as a <a href="#/p5.Color">p5.Color</a>
116
116
* @chainable
117
117
*/
118
- p5 . prototype . ambientLight = function ( v1 , v2 , v3 , a ) {
118
+ p5 . prototype . ambientLight = function ( v1 , v2 , v3 , a ) {
119
119
this . _assert3d ( 'ambientLight' ) ;
120
120
p5 . _validateParameters ( 'ambientLight' , arguments ) ;
121
121
const color = this . color ( ...arguments ) ;
@@ -229,7 +229,7 @@ p5.prototype.ambientLight = function(v1, v2, v3, a) {
229
229
* @param {p5.Color } color color as a <a href="#/p5.Color">p5.Color</a>
230
230
* @chainable
231
231
*/
232
- p5 . prototype . specularColor = function ( v1 , v2 , v3 ) {
232
+ p5 . prototype . specularColor = function ( v1 , v2 , v3 ) {
233
233
this . _assert3d ( 'specularColor' ) ;
234
234
p5 . _validateParameters ( 'specularColor' , arguments ) ;
235
235
const color = this . color ( ...arguments ) ;
@@ -327,7 +327,7 @@ p5.prototype.specularColor = function(v1, v2, v3) {
327
327
* @param {p5.Vector } direction
328
328
* @chainable
329
329
*/
330
- p5 . prototype . directionalLight = function ( v1 , v2 , v3 , x , y , z ) {
330
+ p5 . prototype . directionalLight = function ( v1 , v2 , v3 , x , y , z ) {
331
331
this . _assert3d ( 'directionalLight' ) ;
332
332
p5 . _validateParameters ( 'directionalLight' , arguments ) ;
333
333
@@ -454,7 +454,7 @@ p5.prototype.directionalLight = function(v1, v2, v3, x, y, z) {
454
454
* @param {p5.Vector } position
455
455
* @chainable
456
456
*/
457
- p5 . prototype . pointLight = function ( v1 , v2 , v3 , x , y , z ) {
457
+ p5 . prototype . pointLight = function ( v1 , v2 , v3 , x , y , z ) {
458
458
this . _assert3d ( 'pointLight' ) ;
459
459
p5 . _validateParameters ( 'pointLight' , arguments ) ;
460
460
@@ -592,13 +592,60 @@ p5.prototype.pointLight = function(v1, v2, v3, x, y, z) {
592
592
* @alt
593
593
* light with slider having a slider for varying roughness
594
594
*/
595
- p5 . prototype . imageLight = function ( img ) {
595
+ p5 . prototype . imageLight = function ( img ) {
596
596
// activeImageLight property is checked by _setFillUniforms
597
597
// for sending uniforms to the fillshader
598
598
this . _renderer . activeImageLight = img ;
599
599
this . _renderer . _enableLighting = true ;
600
600
} ;
601
601
602
+ /**
603
+ * The `panorama(img)` method transforms images containing
604
+ * 360-degree content, such as maps or HDRIs, into immersive
605
+ * 3D backgrounds that surround your scene. This is similar to calling
606
+ * `background(color)`; call `panorama(img)` before drawing your
607
+ * scene to create a 360-degree background from your image. It
608
+ * operates on the concept of sphere mapping, where the image is
609
+ * mapped onto an infinitely large sphere based on the angles of the
610
+ * camera.
611
+ *
612
+ * To enable 360-degree viewing, either use `orbitControl()` or try changing
613
+ * the orientation of the camera to see different parts of the background.
614
+ *
615
+ * @method panorama
616
+ * @param {p5.Image } img A 360-degree image to use as a background panorama
617
+ * @example
618
+ * <div class="notest">
619
+ * <code>
620
+ * let img;
621
+ * function preload() {
622
+ * img = loadImage('assets/outdoor_spheremap.jpg');
623
+ * }
624
+ * function setup() {
625
+ * createCanvas(100 ,100 ,WEBGL);
626
+ * }
627
+ * function draw() {
628
+ * panorama(img);
629
+ * imageMode(CENTER);
630
+ * orbitControl();
631
+ * noStroke();
632
+ * push();
633
+ * imageLight(img);
634
+ * specularMaterial('green');
635
+ * shininess(200);
636
+ * metalness(100);
637
+ * sphere(25);
638
+ * pop();
639
+ * }
640
+ * </code>
641
+ * </div>
642
+ * @alt
643
+ * The image transformed into a panoramic scene.
644
+ */
645
+ p5 . prototype . panorama = function ( img ) {
646
+ this . filter ( this . _renderer . _getSphereMapping ( img ) ) ;
647
+ } ;
648
+
602
649
/**
603
650
* Places an ambient and directional light in the scene.
604
651
* The lights are set to ambientLight(128, 128, 128) and
@@ -634,7 +681,7 @@ p5.prototype.imageLight = function(img){
634
681
* @alt
635
682
* the light is partially ambient and partially directional
636
683
*/
637
- p5 . prototype . lights = function ( ) {
684
+ p5 . prototype . lights = function ( ) {
638
685
this . _assert3d ( 'lights' ) ;
639
686
// Both specify gray by default.
640
687
const grayColor = this . color ( 'rgb(128,128,128)' ) ;
@@ -698,7 +745,7 @@ p5.prototype.lights = function() {
698
745
* @alt
699
746
* Two spheres with different falloff values show different intensity of light
700
747
*/
701
- p5 . prototype . lightFalloff = function (
748
+ p5 . prototype . lightFalloff = function (
702
749
constantAttenuation ,
703
750
linearAttenuation ,
704
751
quadraticAttenuation
@@ -892,7 +939,7 @@ p5.prototype.lightFalloff = function(
892
939
* @param {Number } [angle]
893
940
* @param {Number } [concentration]
894
941
*/
895
- p5 . prototype . spotLight = function (
942
+ p5 . prototype . spotLight = function (
896
943
v1 ,
897
944
v2 ,
898
945
v3 ,
@@ -1153,7 +1200,7 @@ p5.prototype.spotLight = function(
1153
1200
* Three white spheres. Each appears as a different
1154
1201
* color due to lighting.
1155
1202
*/
1156
- p5 . prototype . noLights = function ( ...args ) {
1203
+ p5 . prototype . noLights = function ( ...args ) {
1157
1204
this . _assert3d ( 'noLights' ) ;
1158
1205
p5 . _validateParameters ( 'noLights' , args ) ;
1159
1206
0 commit comments