<script src="https://rawgit.com/mrdoob/three.js/dev/build/three.js"></script>
<script src="https://rawgit.com/mrdoob/three.js/dev/examples/js/controls/OrbitControls.js"></script>
<div id="con">
A single mesh, however, cannot have two different materials in threejs. And a material cannot show more than one texture at once. So if we really want end grains...we'll have to create 2 meshes for every one board, which can eat performance depending on how many framming boards there are.
</div>
<!--
<img id='testImg' src='https://www.webkit.org/blog-files/acid3-100.png'>-->
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( 0x555555, 1 );
document.body.appendChild( renderer.domElement );
scene.add(camera);
var light1 = createSun();
light1.control.rotation.y += THREE.Math.degToRad(90);
light1.sun.intensity = 2.5;
var light2 = createSun();
light2.control.rotation.z += THREE.Math.degToRad(180);
light2.control.rotation.y += THREE.Math.degToRad(90);
light2.sun.intensity = 2.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 ----------------------
// ground
/*
var planeGeo = new THREE.PlaneBufferGeometry(12,12);
var groundMat = new THREE.MeshBasicMaterial({ color:0xf4b942});
var planeMesh = new THREE.Mesh(planeGeo, groundMat);
//planeMesh.position.x += 32
//planeMesh.position.z += 32
//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(){
var groundTexture = createTextureFromImage(fti(1), this);
groundMat.map = groundTexture;
groundTexture.needsUpdate = true;
groundMat.needsUpdate = true;
});
groundImg.src = base64Str;
}
var grassUrl =...
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.