mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
repaired view
This commit is contained in:
parent
4205817e60
commit
3c16cfbc05
4 changed files with 31 additions and 27 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -1,3 +0,0 @@
|
||||||
[submodule "lib/Vendor/Three"]
|
|
||||||
path = lib/Vendor/Three
|
|
||||||
url = git://github.com/mrdoob/three.js.git
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
define(['Vendor/Wrapper/Three', 'Chuck/Settings'], function(Three, Settings) {
|
define(['Vendor/Three', 'Chuck/Settings'], function(Three, Settings) {
|
||||||
|
|
||||||
function CameraController() {
|
function CameraController() {
|
||||||
|
/*
|
||||||
this.camera = new Three.OrthographicCamera(
|
this.camera = new Three.OrthographicCamera(
|
||||||
-Settings.STAGE_WIDTH/2,
|
-Settings.STAGE_WIDTH/2,
|
||||||
Settings.STAGE_WIDTH/2,
|
Settings.STAGE_WIDTH/2,
|
||||||
|
|
@ -8,11 +9,13 @@ define(['Vendor/Wrapper/Three', 'Chuck/Settings'], function(Three, Settings) {
|
||||||
-Settings.STAGE_HEIGHT/2,
|
-Settings.STAGE_HEIGHT/2,
|
||||||
-2000,
|
-2000,
|
||||||
1000
|
1000
|
||||||
);
|
);*/
|
||||||
|
|
||||||
|
this.camera = new Three.OrthographicCamera( 600 / - 2, 600 / 2, 400 / 2, 400 / - 2, - 2000, 1000 );
|
||||||
|
|
||||||
//this.camera = new Three.PerspectiveCamera(45, 600 / 400, 1, 1000);
|
//this.camera = new Three.PerspectiveCamera(45, 600 / 400, 1, 1000);
|
||||||
|
|
||||||
this.camera.position.z = 481;
|
//this.camera.position.z = 481;
|
||||||
}
|
}
|
||||||
|
|
||||||
CameraController.prototype.getCamera = function(){
|
CameraController.prototype.getCamera = function(){
|
||||||
|
|
|
||||||
|
|
@ -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(){
|
function View(){
|
||||||
|
|
||||||
|
|
@ -13,14 +13,19 @@ define(["Vendor/Wrapper/Three", "Chuck/Settings", "Chuck/View/CameraController"]
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.renderer = new Three.WebGLRenderer();
|
this.renderer = new Three.WebGLRenderer({
|
||||||
this.renderer.setSize(600, 400);
|
//antialias: true,
|
||||||
|
preserveDrawingBuffer: true
|
||||||
|
});
|
||||||
|
this.renderer.setClearColorHex(0x333333, 1);
|
||||||
|
this.renderer.setSize(Settings.STAGE_WIDTH, Settings.STAGE_HEIGHT);
|
||||||
|
|
||||||
document.body.appendChild(this.renderer.domElement);
|
document.body.appendChild(this.renderer.domElement);
|
||||||
|
|
||||||
this.scene = new Three.Scene();
|
this.scene = new Three.Scene();
|
||||||
this.scene.add(this.cameraController.getCamera());
|
this.scene.add(this.cameraController.getCamera());
|
||||||
|
|
||||||
/*
|
|
||||||
var ambientLight = new Three.AmbientLight(0xffffff);
|
var ambientLight = new Three.AmbientLight(0xffffff);
|
||||||
this.scene.add(ambientLight);
|
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){
|
this.createMesh(100, 100, 100, 100, 'static/img/100.png', function(mesh){
|
||||||
console.log(mesh);
|
|
||||||
self.scene.add(mesh);
|
self.scene.add(mesh);
|
||||||
|
self.animate(self);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.createMesh(100, 100, 210, 100, 'static/img/100.png', function(mesh){
|
//this.animate(this);
|
||||||
self.scene.add(mesh);
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
this.animate(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
View.prototype.animate = function(scope) {
|
View.prototype.animate = function(scope) {
|
||||||
|
|
@ -55,26 +56,26 @@ define(["Vendor/Wrapper/Three", "Chuck/Settings", "Chuck/View/CameraController"]
|
||||||
}
|
}
|
||||||
|
|
||||||
View.prototype.render = function() {
|
View.prototype.render = function() {
|
||||||
console.log('render', this);
|
|
||||||
this.renderer.render(this.scene, this.cameraController.getCamera());
|
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();
|
var textureImg = new Image();
|
||||||
textureImg.onload = function(){
|
textureImg.onload = function(){
|
||||||
var material = new Three.MeshLambertMaterial({
|
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);
|
var mesh = new Three.Mesh(new Three.PlaneGeometry(width, height), material);
|
||||||
plane.overdraw = true;
|
mesh.overdraw = true;/*
|
||||||
plane.position.z = 0;
|
mesh.position.z = 0;
|
||||||
plane.position.x = x;
|
mesh.position.x = x;
|
||||||
plane.position.y = y;
|
mesh.position.y = y;
|
||||||
|
*/
|
||||||
callback(plane);
|
callback(mesh);
|
||||||
};
|
};
|
||||||
textureImg.src = img;
|
textureImg.src = imgPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
return View;
|
return View;
|
||||||
|
|
|
||||||
3
lib/Vendor/Three.js
vendored
Executable file
3
lib/Vendor/Three.js
vendored
Executable file
|
|
@ -0,0 +1,3 @@
|
||||||
|
define(["Vendor/Three/build/Three"], function() {
|
||||||
|
return THREE;
|
||||||
|
})
|
||||||
Loading…
Add table
Add a link
Reference in a new issue