"use strict";
/**
Note: Usiing bevel thickness will offset the position slighly from the origin,
so becareful when giving it values of more than zero
conclusion:
do not try to use a planar UV when created 2d shapes from threejs's shapeGeometry.
ShapeGeometry already does the UV mapping work for you.
see the other jsfiddle UV Texture.
Loading texture in jsfiddle:
you have to encode the texture to base64
- if image is from your computer
https://www.base64-image.de/
- if image is on the web
http://www.greywyvern.com/code/php/binary2base64/
Note: Once shape geometry is converted to mesh, and you modify the size in any way, the UVs will start to distort unless you recreate or update the UVs.
*/
var scene, renderer, camera, controls;
init();
animate();
function init()
{
renderer = new THREE.WebGLRenderer( {antialias:true, alpha: true } );
var width = window.innerWidth;
var height = window.innerHeight;
renderer.setSize (width, height);
renderer.setClearColor(0x000000, 1); //using clear background color
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.appendChild (renderer.domElement);
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera (60, width/height, 1, 10000);
camera.position.y = 16;
camera.position.z = 40;
camera.lookAt (new THREE.Vector3(0,0,0));
scene.add( camera );
controls = new THREE.OrbitControls(camera, renderer.domElement);
var gridXZ = new THREE.GridHelper(100, 10,
new THREE.Color(0xffffff),
new THREE.Color(0xffffff)
);
scene.add(gridXZ);
//lights
createDirectionalLight();
var texture = loadTextureUsingImageDomHack();
var customExtrudePlane = createExtrudedShape(texture);
// to represent the 2d shape, you flip it -90 on X axis
customExtrudePlane.rotateX(THREE.Math.degToRad(-90));
//customExtrudePlane.edges.update();
//flipNormals(customExtrudePlane);
var vec2s = [
new THREE.Vector2(0,0),
new THREE.Vector2(0,120),
...
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.