Created
March 12, 2013 11:09
-
-
Save hurry07/5142069 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created with JetBrains WebStorm. | |
* User: lijie | |
* Date: 13-3-12 | |
* Time: 下午6:09 | |
* To change this template use File | Settings | File Templates. | |
*/ | |
function createPlane(path) { | |
var texture = THREE.ImageUtils.loadTexture(path); | |
var material = new THREE.MeshLambertMaterial({map: texture }); | |
//material.map.anisotropy = renderer.getMaxAnisotropy(); | |
var sphere = new THREE.Mesh(new THREE.PlaneGeometry(texture.image.width, texture.image.height), material); | |
sphere.position.set(0, 0, 0); | |
return sphere; | |
} | |
function createText(s) { | |
var c = document.createElement('canvas'); | |
var ctx = c.getContext('2d'); | |
ctx.font = '64px Arial'; | |
c.width = ctx.measureText(s).width; | |
c.height = Math.ceil(64*1.25); | |
ctx.font = '64px Arial'; | |
ctx.fillStyle = "#FF0000"; | |
ctx.fillText(s, 0, 64); | |
var tex = new THREE.Texture(c); | |
tex.needsUpdate = true; | |
var plane = new THREE.Mesh( | |
new THREE.PlaneGeometry(c.width, c.height), | |
new THREE.MeshBasicMaterial({ map: tex, color : 0xFFFFFF, opacity : 1 }) ); | |
plane.doubleSided = true; | |
return plane; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment