cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <canvas id="omega" width="800px" height="600px"/>
<img src="https://threejs.org/examples/textures/cube/skybox/px.jpg" crossOrigin = 'Anonymous'/>
<img src="https://threejs.org/examples/textures/cube/skybox/nx.jpg" crossOrigin = 'Anonymous'/>
<img src="https://threejs.org/examples/textures/cube/skybox/py.jpg" crossOrigin = 'Anonymous'/>
<img src="https://threejs.org/examples/textures/cube/skybox/ny.jpg" crossOrigin = 'Anonymous'/>
<img src="https://threejs.org/examples/textures/cube/skybox/pz.jpg" crossOrigin = 'Anonymous'/>
<img src="https://threejs.org/examples/textures/cube/skybox/nz.jpg" crossOrigin = 'Anonymous'/>

<img src="https://threejs.org/examples/textures/UV_Grid_Sm.jpg" crossOrigin = 'Anonymous'/>
<img src="https://threejs.org/examples/textures/lava/lavatile.jpg" crossOrigin = 'Anonymous'/>


            
          
!
            
              body {
  margin: 0;
  overflow: hidden;
}
            
          
!
            
              /**
 * OMEGA 3D Framework - http://lab.rackdoll.nl/js/omega/
 * v.0.0.1.8.1 Alpha - Sexy Fresnel Reflection Demo.
 * author: Rackdoll.
 */

var images, skybox_images, renderer, cam, scene ;
var chain, fresnel, DCT;
var objects = [];


function timeout() {
  setTimeout(function() {
    init();
  }, 500);
}

function init(){
   
    var imgs = document.getElementsByTagName("img");
    onLoadDone(imgs);
  
}

function onLoadDone(imgs){
  images = imgs;  
  skybox_images = [ images[0], images[1], images[2], images[3], images[4], images[5]];
  

  //adjust on window
  Omega3D.Recalibrate();

  //scene
  scene = new Omega3D.Scene();
  scene.setColor(0, 0, 0);
  
  

  //camera.
  cam = new Omega3D.cameras.Camera();
  cam.ratio = OMEGA.Omega3D.GL.viewPortWidth / OMEGA.Omega3D.GL.viewPortHeight;
  cam.LookAt(0, 0, 0, [0, -3, -5]);
  
  
  
  //light.
 var light = new Omega3D.Light(Omega3D.POINT_LIGHT);
  light.SetAmbient( 0.4, 0.4, 0.4);
  light.SetDiffuse( 0.6, 0.6, 0.6);
  light.SetPosition( 0, -6, 0 );
  light.SetRadius( 90.0 );
  scene.addLight(light);

  
  // SKYBOX
  var skybox_geom  = new Omega3D.Geometry.CubeGeometry(100.0, 100.0, 100.0);
  var skybox_tex   = new Omega3D.CubemapTexture(images);
  var skybox_mat   = new Omega3D.SkyBoxMaterial([skybox_tex], scene );
  var skybox       = new Omega3D.Object3D(new Omega3D.Mesh(skybox_geom), skybox_mat);
  scene.addChild( skybox );

  
  //OBJECT.
   DCT          = new Omega3D.DynamicCubemapTexture(images, 1024, 1024);
   var color        = new Omega3D.BasicTexture(images[6]);
   var geom         = new Omega3D.Mesh( new Omega3D.Geometry.SphereGeometry(1.25, 75.0,75.0) );
   var fresnel_data = { scale:"1.25", power:"1.0",minimum:"0.0",  color:"1.0, 1.0, 1.0"};
   var shader       = new Omega3D.Shaders.FresnelReflection( scene,fresnel_data );
   var mat          = new Omega3D.Material( shader, [DCT, color]);
   fresnel      = new Omega3D.Object3D( geom, mat );
   
    //set position.
    fresnel.SetPosition( 0.0, 0.0, 0.0);
    scene.addChild( fresnel );
  
   //objects.
   var smell_geom = new Omega3D.Mesh( new Omega3D.Geometry.SphereGeometry(0.5, 15.0,15.0) );
   var small_mat  = new Omega3D.BasicMaterial( [new Omega3D.BasicTexture(images[7])], scene, [1.0, 0, 0]);
   var step = Math.PI * 2.0 / 6;
   for( var i = 0; i < 6; i++){
       objects.push( new Omega3D.Object3D( smell_geom, small_mat ));
       objects[i].SetPosition( Math.cos(i*step ) * 3, 0, Math.sin(i*step) * 3);
       scene.addChild( objects[i] );
   }

   
  
  
  
  //create render chain.
  renderer = new Omega3D.WebGLRenderer;

  //Normal Rendering.
  var chain = new Omega3D.RenderChain();
  chain.AddRenderPass(new RenderPass(renderer, scene, cam));
  renderer.SetRenderChain(chain);

  //start render.
  render();
}

//RENDER.
function render() {
  requestAnimationFrame(render);
  
  //offste camera.
  var t = scene.getTime() * 0.5;
  var step = Math.PI * 2.0 / 6;
  for( var i = 2; i < scene.children.length; i++){
       scene.children[i].SetPosition( Math.cos(t + i*step ) * 3, 0, Math.sin(t + i*step) * 3);
   }
  
  cam.LookAt( 0, 0, 0,[Math.cos(t * 0.25) * 0.5, -5 + Math.cos(t * 0.35) * 3, Math.sin(t * 0.5) * 5.0]);
  
  //rotate fresnel.
  fresnel.Rotate( 0.005, 0.01, 0 );
  
  //set dynamic cubemap object to non renderable.
  fresnel.mayRender = false;


  //update faces dynamic cubemap.
  // 1. From Object Position.
  // 2. Renderer.
  // 3. Scene To Render.
  DCT.UpdateFaces(fresnel.GetPosition(), renderer, scene );


  //set dynamic cubemap object to renderable.
  fresnel.mayRender = true;

  
  //render step.
  renderer.render();
}

document.getElementsByTagName("body")[0].onload = timeout();
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console