2015-07-01 16:31:43 +02:00
|
|
|
L3D.Displayable = function() {
|
2015-04-02 12:38:06 +02:00
|
|
|
// Nothing to do here
|
2015-07-01 10:14:15 +02:00
|
|
|
};
|
2015-04-02 12:38:06 +02:00
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.Displayable.prototype.addToScene = function(scene) {
|
2015-04-02 12:38:06 +02:00
|
|
|
scene.add(this.mesh);
|
2015-07-01 10:14:15 +02:00
|
|
|
};
|
2015-04-02 12:38:06 +02:00
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.Displayable.prototype.translate = function(x,y,z) {
|
2015-04-02 12:38:06 +02:00
|
|
|
this.geometry.applyMatrix(new THREE.Matrix4().makeTranslation(x,y,z));
|
2015-07-01 10:14:15 +02:00
|
|
|
};
|
2015-04-02 12:38:06 +02:00
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
// class L3D.Cube extends L3D.Displayable
|
|
|
|
L3D.Cube = function(size, style) {
|
2015-04-02 12:38:06 +02:00
|
|
|
// Super constructor call
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.Displayable.call(this);
|
2015-04-02 12:38:06 +02:00
|
|
|
|
2015-04-07 12:04:59 +02:00
|
|
|
if (size === undefined) size = 100;
|
|
|
|
if (style === undefined) style = {};
|
2015-04-02 12:38:06 +02:00
|
|
|
|
|
|
|
this.geometry = new THREE.BoxGeometry(size, size, size);
|
|
|
|
|
|
|
|
this.material = new THREE.MeshLambertMaterial(style);
|
|
|
|
|
|
|
|
this.mesh = new THREE.Mesh(this.geometry, this.material);
|
|
|
|
this.mesh.castShadow = false;
|
2015-07-01 10:14:15 +02:00
|
|
|
};
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.Cube.prototype = Object.create(L3D.Displayable.prototype);
|
|
|
|
L3D.Cube.prototype.constructor = L3D.Cube;
|
2015-04-02 12:38:06 +02:00
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
// class L3D.Plane extends L3D.Displayable
|
|
|
|
L3D.Plane = function(size1, size2, style) {
|
|
|
|
L3D.Displayable.call(this);
|
2015-04-02 12:38:06 +02:00
|
|
|
|
2015-04-07 12:04:59 +02:00
|
|
|
if (style === undefined) style = {};
|
2015-04-02 12:38:06 +02:00
|
|
|
|
|
|
|
this.geometry = new THREE.PlaneBufferGeometry(size1, size2);
|
|
|
|
this.material = new THREE.MeshLambertMaterial(style);
|
2015-04-14 16:58:39 +02:00
|
|
|
this.material.side = THREE.DoubleSide;
|
2015-04-02 12:38:06 +02:00
|
|
|
this.mesh = new THREE.Mesh(this.geometry, this.material);
|
|
|
|
|
|
|
|
this.mesh.receiveShadow = true;
|
2015-07-01 10:14:15 +02:00
|
|
|
};
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.Plane.prototype = Object.create(L3D.Displayable.prototype);
|
|
|
|
L3D.Plane.prototype.constructor = L3D.Plane;
|
2015-04-02 12:38:06 +02:00
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.Plane.prototype.addToScene = function(scene) {
|
2015-04-02 12:38:06 +02:00
|
|
|
scene.add(this.mesh);
|
2015-07-01 10:14:15 +02:00
|
|
|
};
|