mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
repaired view
This commit is contained in:
parent
4205817e60
commit
3c16cfbc05
4 changed files with 31 additions and 27 deletions
|
|
@ -1,4 +1,4 @@
|
|||
define(["Vendor/Wrapper/Three", "Chuck/Settings", "Chuck/View/CameraController"], function(Three, Settings, CameraController){
|
||||
define(["Vendor/Three", "Chuck/Settings", "Chuck/View/CameraController"], function(Three, Settings, CameraController){
|
||||
|
||||
function View(){
|
||||
|
||||
|
|
@ -13,14 +13,19 @@ define(["Vendor/Wrapper/Three", "Chuck/Settings", "Chuck/View/CameraController"]
|
|||
|
||||
var self = this;
|
||||
|
||||
this.renderer = new Three.WebGLRenderer();
|
||||
this.renderer.setSize(600, 400);
|
||||
this.renderer = new Three.WebGLRenderer({
|
||||
//antialias: true,
|
||||
preserveDrawingBuffer: true
|
||||
});
|
||||
this.renderer.setClearColorHex(0x333333, 1);
|
||||
this.renderer.setSize(Settings.STAGE_WIDTH, Settings.STAGE_HEIGHT);
|
||||
|
||||
document.body.appendChild(this.renderer.domElement);
|
||||
|
||||
this.scene = new Three.Scene();
|
||||
this.scene.add(this.cameraController.getCamera());
|
||||
|
||||
/*
|
||||
|
||||
var ambientLight = new Three.AmbientLight(0xffffff);
|
||||
this.scene.add(ambientLight);
|
||||
|
||||
|
|
@ -30,15 +35,11 @@ define(["Vendor/Wrapper/Three", "Chuck/Settings", "Chuck/View/CameraController"]
|
|||
|
||||
|
||||
this.createMesh(100, 100, 100, 100, 'static/img/100.png', function(mesh){
|
||||
console.log(mesh);
|
||||
self.scene.add(mesh);
|
||||
self.animate(self);
|
||||
});
|
||||
|
||||
this.createMesh(100, 100, 210, 100, 'static/img/100.png', function(mesh){
|
||||
self.scene.add(mesh);
|
||||
});
|
||||
*/
|
||||
this.animate(this);
|
||||
//this.animate(this);
|
||||
}
|
||||
|
||||
View.prototype.animate = function(scope) {
|
||||
|
|
@ -55,26 +56,26 @@ define(["Vendor/Wrapper/Three", "Chuck/Settings", "Chuck/View/CameraController"]
|
|||
}
|
||||
|
||||
View.prototype.render = function() {
|
||||
console.log('render', this);
|
||||
|
||||
this.renderer.render(this.scene, this.cameraController.getCamera());
|
||||
}
|
||||
|
||||
View.prototype.createMesh = function(width, height, x, y, img, callback) {
|
||||
View.prototype.createMesh = function(width, height, x, y, imgPath, callback) {
|
||||
var textureImg = new Image();
|
||||
textureImg.onload = function(){
|
||||
var material = new Three.MeshLambertMaterial({
|
||||
map: Three.ImageUtils.loadTexture(img)
|
||||
map: Three.ImageUtils.loadTexture(imgPath)
|
||||
});
|
||||
|
||||
var plane = new Three.Mesh(new Three.PlaneGeometry(width, height), material);
|
||||
plane.overdraw = true;
|
||||
plane.position.z = 0;
|
||||
plane.position.x = x;
|
||||
plane.position.y = y;
|
||||
|
||||
callback(plane);
|
||||
var mesh = new Three.Mesh(new Three.PlaneGeometry(width, height), material);
|
||||
mesh.overdraw = true;/*
|
||||
mesh.position.z = 0;
|
||||
mesh.position.x = x;
|
||||
mesh.position.y = y;
|
||||
*/
|
||||
callback(mesh);
|
||||
};
|
||||
textureImg.src = img;
|
||||
textureImg.src = imgPath;
|
||||
}
|
||||
|
||||
return View;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue