@@ -115,7 +115,7 @@ import p5 from '../core/main';
115115 * @param {p5.Color } color color as a <a href="#/p5.Color">p5.Color</a>
116116 * @chainable
117117 */
118- p5 . prototype . ambientLight = function ( v1 , v2 , v3 , a ) {
118+ p5 . prototype . ambientLight = function ( v1 , v2 , v3 , a ) {
119119 this . _assert3d ( 'ambientLight' ) ;
120120 p5 . _validateParameters ( 'ambientLight' , arguments ) ;
121121 const color = this . color ( ...arguments ) ;
@@ -229,7 +229,7 @@ p5.prototype.ambientLight = function(v1, v2, v3, a) {
229229 * @param {p5.Color } color color as a <a href="#/p5.Color">p5.Color</a>
230230 * @chainable
231231 */
232- p5 . prototype . specularColor = function ( v1 , v2 , v3 ) {
232+ p5 . prototype . specularColor = function ( v1 , v2 , v3 ) {
233233 this . _assert3d ( 'specularColor' ) ;
234234 p5 . _validateParameters ( 'specularColor' , arguments ) ;
235235 const color = this . color ( ...arguments ) ;
@@ -327,7 +327,7 @@ p5.prototype.specularColor = function(v1, v2, v3) {
327327 * @param {p5.Vector } direction
328328 * @chainable
329329 */
330- p5 . prototype . directionalLight = function ( v1 , v2 , v3 , x , y , z ) {
330+ p5 . prototype . directionalLight = function ( v1 , v2 , v3 , x , y , z ) {
331331 this . _assert3d ( 'directionalLight' ) ;
332332 p5 . _validateParameters ( 'directionalLight' , arguments ) ;
333333
@@ -454,7 +454,7 @@ p5.prototype.directionalLight = function(v1, v2, v3, x, y, z) {
454454 * @param {p5.Vector } position
455455 * @chainable
456456 */
457- p5 . prototype . pointLight = function ( v1 , v2 , v3 , x , y , z ) {
457+ p5 . prototype . pointLight = function ( v1 , v2 , v3 , x , y , z ) {
458458 this . _assert3d ( 'pointLight' ) ;
459459 p5 . _validateParameters ( 'pointLight' , arguments ) ;
460460
@@ -592,13 +592,60 @@ p5.prototype.pointLight = function(v1, v2, v3, x, y, z) {
592592 * @alt
593593 * light with slider having a slider for varying roughness
594594 */
595- p5 . prototype . imageLight = function ( img ) {
595+ p5 . prototype . imageLight = function ( img ) {
596596 // activeImageLight property is checked by _setFillUniforms
597597 // for sending uniforms to the fillshader
598598 this . _renderer . activeImageLight = img ;
599599 this . _renderer . _enableLighting = true ;
600600} ;
601601
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+
602649/**
603650 * Places an ambient and directional light in the scene.
604651 * The lights are set to ambientLight(128, 128, 128) and
@@ -634,7 +681,7 @@ p5.prototype.imageLight = function(img){
634681 * @alt
635682 * the light is partially ambient and partially directional
636683 */
637- p5 . prototype . lights = function ( ) {
684+ p5 . prototype . lights = function ( ) {
638685 this . _assert3d ( 'lights' ) ;
639686 // Both specify gray by default.
640687 const grayColor = this . color ( 'rgb(128,128,128)' ) ;
@@ -698,7 +745,7 @@ p5.prototype.lights = function() {
698745 * @alt
699746 * Two spheres with different falloff values show different intensity of light
700747 */
701- p5 . prototype . lightFalloff = function (
748+ p5 . prototype . lightFalloff = function (
702749 constantAttenuation ,
703750 linearAttenuation ,
704751 quadraticAttenuation
@@ -892,7 +939,7 @@ p5.prototype.lightFalloff = function(
892939 * @param {Number } [angle]
893940 * @param {Number } [concentration]
894941 */
895- p5 . prototype . spotLight = function (
942+ p5 . prototype . spotLight = function (
896943 v1 ,
897944 v2 ,
898945 v3 ,
@@ -1153,7 +1200,7 @@ p5.prototype.spotLight = function(
11531200 * Three white spheres. Each appears as a different
11541201 * color due to lighting.
11551202 */
1156- p5 . prototype . noLights = function ( ...args ) {
1203+ p5 . prototype . noLights = function ( ...args ) {
11571204 this . _assert3d ( 'noLights' ) ;
11581205 p5 . _validateParameters ( 'noLights' , args ) ;
11591206
0 commit comments