In js, we don't know how to test if something is undefined
This commit is contained in:
parent
ae620e2cfc
commit
7c138c3c27
|
@ -4,7 +4,7 @@ var CameraContainer = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
CameraContainer.prototype.mainCamera = function(id) {
|
CameraContainer.prototype.mainCamera = function(id) {
|
||||||
if (id === undefined) {
|
if (typeof id === 'undefined') {
|
||||||
return this.cameras[this.current_camera];
|
return this.cameras[this.current_camera];
|
||||||
}
|
}
|
||||||
if (id >= cameras.length || id < 0) {
|
if (id >= cameras.length || id < 0) {
|
||||||
|
@ -37,7 +37,7 @@ CameraContainer.prototype.get = function(i) {
|
||||||
|
|
||||||
CameraContainer.prototype.getById = function(id) {
|
CameraContainer.prototype.getById = function(id) {
|
||||||
for (var i in this.cameras) {
|
for (var i in this.cameras) {
|
||||||
if (this.cameras[i].mesh !== undefined) {
|
if (typeof this.cameras[i].mesh !== 'undefined') {
|
||||||
if (this.cameras[i].mesh.id == id) {
|
if (this.cameras[i].mesh.id == id) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@ var Cube = function(size, style) {
|
||||||
// Super constructor call
|
// Super constructor call
|
||||||
Displayable.call(this);
|
Displayable.call(this);
|
||||||
|
|
||||||
if (size === undefined) size = 100;
|
if (typeof size === 'undefined') size = 100;
|
||||||
if (style === undefined) style = {};
|
if (typeof style === 'undefined') style = {};
|
||||||
|
|
||||||
this.geometry = new THREE.BoxGeometry(size, size, size);
|
this.geometry = new THREE.BoxGeometry(size, size, size);
|
||||||
// this.geometry.computeVertexNormals();
|
// this.geometry.computeVertexNormals();
|
||||||
|
@ -33,7 +33,7 @@ Cube.prototype.constructor = Cube;
|
||||||
var Plane = function(size1, size2, style) {
|
var Plane = function(size1, size2, style) {
|
||||||
Displayable.call(this);
|
Displayable.call(this);
|
||||||
|
|
||||||
if (style === undefined) style = {};
|
if (typeof style === 'undefined') style = {};
|
||||||
|
|
||||||
this.geometry = new THREE.PlaneBufferGeometry(size1, size2);
|
this.geometry = new THREE.PlaneBufferGeometry(size1, size2);
|
||||||
this.material = new THREE.MeshLambertMaterial(style);
|
this.material = new THREE.MeshLambertMaterial(style);
|
||||||
|
|
|
@ -5,7 +5,7 @@ var FixedCamera = function(arg1, arg2, arg3, arg4, position, target) {
|
||||||
THREE.PerspectiveCamera.apply(this, arguments);
|
THREE.PerspectiveCamera.apply(this, arguments);
|
||||||
|
|
||||||
// Set Position
|
// Set Position
|
||||||
if (position === undefined) {
|
if (typeof position === 'undefined') {
|
||||||
this.position = new THREE.Vector3(0,0,5);
|
this.position = new THREE.Vector3(0,0,5);
|
||||||
} else {
|
} else {
|
||||||
this.position.x = position.x;
|
this.position.x = position.x;
|
||||||
|
@ -14,7 +14,7 @@ var FixedCamera = function(arg1, arg2, arg3, arg4, position, target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (target === undefined)
|
if (typeof target === 'undefined')
|
||||||
target = new THREE.Vector3(0,0,0);
|
target = new THREE.Vector3(0,0,0);
|
||||||
|
|
||||||
var direction = target.clone();
|
var direction = target.clone();
|
||||||
|
|
|
@ -197,7 +197,7 @@ function click(event) {
|
||||||
|
|
||||||
// Looking for cameras
|
// Looking for cameras
|
||||||
for (i in intersects) {
|
for (i in intersects) {
|
||||||
if (minDistance === undefined || intersects[i].distance < minDistance) {
|
if (typeof minDistance === 'undefined' || intersects[i].distance < minDistance) {
|
||||||
// We will not consider a line as clickable
|
// We will not consider a line as clickable
|
||||||
if (! (intersects[i].object instanceof THREE.Line)) {
|
if (! (intersects[i].object instanceof THREE.Line)) {
|
||||||
minDistance = intersects[i].distance;
|
minDistance = intersects[i].distance;
|
||||||
|
@ -205,7 +205,7 @@ function click(event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bestIndex !== undefined) {
|
if (typeof bestIndex !== 'undefined') {
|
||||||
cameras.setById(intersects[bestIndex].object.id);
|
cameras.setById(intersects[bestIndex].object.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue