0
的基本问题是,我不能让我的例子对象文本工作 - 我没有在控制台中看到任何错误,所以我不reayll知道为什么它不希望跑。WebGL的对象文本不工作
我知道代码工作,如果我只是使用一些正常功能,不,也许我在什么地方搞砸范围或者我应该使用对象构造对象的文字符号?
我有大约一看,看不出任何问题与使用对象文本内的WebGL所以假设我有一些狡猾的编码回事。
我已经提交的jsfiddle为您检查 - 请忽略纹理的跨域问题。
var MyCube = {
container : null,
renderer : null,
scene : null,
camera : null,
cube : null,
animating : null,
light : null,
mapUrl : null,
map : null,
material : null,
geometry : null,
animating : false,
onLoad : function(){
this.container = $("#container");
this.renderer = new THREE.WebGLRenderer({ antialias: true });
this.renderer.setSize(this.container.offsetWidth, this.container.offsetHeight);
$(this.container).append(this.renderer.domElement);
this.scene = new THREE.Scene();
this.camera = new THREE.PerspectiveCamera(45,
this.container.offsetWidth/this.container.offsetHeight, 1, 4000);
this.camera.position.set(0, 0, 3);
this.light = new THREE.DirectionalLight(0xffffff, 1.5);
this.light.position.set(0, 0, 1);
this.scene.add(this.light);
this.mapUrl = "molumen_small_funny_angry_monster-999px.png";
this.map = THREE.ImageUtils.loadTexture(this.mapUrl);
this.material = new THREE.MeshPhongMaterial({ map: this.map });
this.geometry = new THREE.CubeGeometry(1, 1, 1);
this.cube = new THREE.Mesh(this.geometry, this.material);
this.cube.rotation.x = Math.PI/5;
this.cube.rotation.y = Math.PI/5;
this.scene.add(this.cube);
this.myrun();
},
myrun : function(){
MyCube.renderer.render(MyCube.scene,MyCube.camera);
if(MyCube.animating)
{
MyCube.cube.rotation.y -= 0.11;
MyCube.cube.rotation.x -= 0.10;
}
requestAnimationFrame(MyCube.myrun);
}
}
MyCube.onLoad();
$('#container').click(function(){
MyCube.animating = !MyCube.animating;
return false;
});
终于解决 - 谢谢你没有Stackoverflow !!!!!!! – user1806692 2013-05-06 23:59:46