var mod = {};
var objects = [];
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 35, window.innerWidth/window.innerHeight, 0.1, 3000 );
var renderer = new THREE.WebGLRenderer();
renderer.shadowMap.enabled = true; //req for shadow enabling
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setClearColor( 0xcccccc, 1 );
document.body.appendChild( renderer.domElement );
scene.add(camera);
var light1 = createSun();
light1.control.rotation.y += THREE.Math.degToRad(90);
light1.sun.intensity = 1.5;
var light2 = createSun();
light2.control.rotation.z += THREE.Math.degToRad(180);
light2.control.rotation.y += THREE.Math.degToRad(90);
light2.sun.intensity = 1.5;
controls = new THREE.OrbitControls(camera);
setToFullOrbit(controls)
camera.position.copy(new THREE.Vector3(125,125,125));
// fix first frame render issue going invisible
camera.lookAt(new THREE.Vector3(0,0,0));
var axisHelper = new THREE.AxisHelper(12);
scene.add(axisHelper);
// ---------------------- playground starts here ----------------------
//custom texture
var deckCustomTexture = loadTextureUsingImageDomHack(fti(2));
var deckTexture = new THREE.Texture({color:0xff0000});
// loadTextureUsingImageDomHack(fti(2));
var levelTexture = new THREE.Texture({color:0xff0000});
//loadTextureUsingImageDomHack(fti(2), true);
var matrix = new THREE.Matrix4();
// ground
var planeGeo = new THREE.PlaneBufferGeometry(400,300);
var groundMat = new THREE.MeshBasicMaterial(
{ color:0x00ff00}
);
var planeMesh = new THREE.Mesh(planeGeo, groundMat);
planeMesh.position.x += 90
planeMesh.position.z += 90
planeMesh.rotateX(THREE.Math.degToRad(-90));
scene.add(planeMesh);
rotateUVonPlanar(0, planeMesh); // works if called right after
//planeMesh.receiveShadow = true;
//apply loaded texture to ground
var groundMatCallBack = function(base64Str){
var groundImg = new Image();
groundImg.addEventListener('load', function(){
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.