Code viewer for World: crown

See raw JS.


// Cloned by Mathias Bazin on 11 Jun 2018 from World "One Cube World" by Starter user 
// Please leave this clone trail here.
 

const skycolor          = 'LightBlue';          // sky color

const objectsize        = 300;                  // size of object   

const startRadius       = 1000;                 // distance from centre we start the camera at

const maxRadius         = startRadius * 10;     // maximum distance from camera we render things 

const skycolorObject    = new THREE.Color ( skycolor.toLowerCase() );                              


function World() 
{ 
   

  this.newRun = function() 
  {
      
    threeworld.init3d ( startRadius, maxRadius, skycolorObject ); 
      
      
    var light = new THREE.AmbientLight( 0x404040, 2 ); // soft white light
    threeworld.scene.add( light );
    
    var shape             = new THREE.CylinderGeometry ( 100, 100, 100, 32, 1, true );
    var material = new THREE.MeshNormalMaterial({color:0xffff00});
    material.side = THREE.DoubleSide

    var ball = new THREE.SphereGeometry ( 10 )
    var ruby = new THREE.MeshBasicMaterial({color:0xff0000});
    var jewel = new THREE.Mesh ( ball, ruby );
    material = new THREE.MeshBasicMaterial({color:0xffff00});
    
    var circleShape = new THREE.CylinderGeometry(101,101,10,1,true)
    var circleMaterial = new THREE.MeshBasicMaterial({color: 0xcccc00});
    
    var crown = new THREE.Mesh(shape, material);
    crown.material.side = THREE.DoubleSide;
    
    var ball1 = new THREE.Mesh(ball, ruby);
    ball1.position.set(0,-10,100);
    var ball2 = new THREE.Mesh(ball, ruby);
    ball2.position.set(0,-10,-100);
    var ball3 = new THREE.Mesh(ball, ruby);
    ball3.position.set(100,-10,0);
    var ball4 = new THREE.Mesh(ball, ruby);
    ball4.position.set(-100,-10,0);
    
    var circle = new THREE.Mesh(circleShape, circleMaterial);
    circle.material.side = THREE.DoubleSide;
    circle.position.set(0,0,0);
    
    crown.add(ball1);
    crown.add(ball2);
    crown.add(ball3);
    crown.add(ball4);
    crown.add(circle);

    threeworld.scene.add(crown);
    
    
    
//     var loader = new THREE.OBJLoader();

// // load a resource
//     loader.load(
// 	// resource URL
// 	"/uploads/mathias/crown3.obj",
// 	// called when resource is loaded
// 	function ( object ) {
        
//         object.material = material;
//         object.rotateX(-Math.PI/2);
        
//         object.traverse( function ( child ) {

//         if ( child instanceof THREE.Mesh ) {

//             child.material = material;

//         }}
//         );
        
// 		threeworld.scene.add( object );

// 	},
// 	// called when loading is in progresses
// 	function ( xhr ) {

// 		console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );

// 	},
// 	// called when loading has errors
// 	function ( error ) {

// 		console.log( 'An error happened' );

// 	}
// );
    
    
//     var mm = new THREE.MTLLoader();
// 	mm.setTexturePath ( "/uploads/mathias/" );
// 	mm.setPath        ( "/uploads/mathias/" );
// 	mm.load( "DIAMOND.mtl", function( materials ) {
 
// 		materials.preload();
// 		var oo = new THREE.OBJLoader();
// 		oo.setMaterials ( materials );
// 		oo.setPath ( "/uploads/mathias/" );
// 		oo.load( "DIAMOND.obj", function ( object ) {

//             object.traverse( function ( child ) {

//         if ( child instanceof THREE.Mesh ) {

//             child.material = material;

//         }

//     } );

            
//             object.material = material;
//             object.scale.multiplyScalar(100);
// 		    threeworld.scene.add(object);
			
// 		} );
		
// 	} );
  };

}