|
From: <ma...@us...> - 2011-12-18 15:45:33
|
Revision: 592
http://openautomation.svn.sourceforge.net/openautomation/?rev=592&view=rev
Author: mayerch
Date: 2011-12-18 15:45:26 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
Initial encapsualting the whole JSFloorPlan3D functionality.
(=> Commit to prepare a big whitespace chage)
Modified Paths:
--------------
JSFloorPlan/trunk/index.html
JSFloorPlan/trunk/src/jsfloorplan.js
JSFloorPlan/trunk/src/jsfloorplan_example_helper.js
Modified: JSFloorPlan/trunk/index.html
===================================================================
--- JSFloorPlan/trunk/index.html 2011-12-18 14:39:40 UTC (rev 591)
+++ JSFloorPlan/trunk/index.html 2011-12-18 15:45:26 UTC (rev 592)
@@ -14,8 +14,8 @@
<script src="lib/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
<script src="lib/poly2tri.js" type="text/javascript"></script>
<script src="lib/Three.js" type="text/javascript"></script>
+<script src="src/jsfloorplan.js" type="text/javascript"></script>
<script src="src/jsfloorplan_example_helper.js" type="text/javascript"></script>
-<script src="src/jsfloorplan.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="css/ui-lightness/jquery-ui-1.8.16.custom.css" />
<link rel="stylesheet" type="text/css" href="demo.css" />
<!-- -->
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-18 14:39:40 UTC (rev 591)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2011-12-18 15:45:26 UTC (rev 592)
@@ -39,6 +39,8 @@
var JSFLOORPLAN3D = {};
}
+JSFLOORPLAN3D= function () {
+var JSFloorPlan3D = this;
// don't change anything below:
var ELEMENT_NODE = 1;
@@ -87,20 +89,22 @@
return pseudoangle_a - pseudoangle_b;
}
-function loadFloorplan()
-{
- $.get('floorplan01.xml', parseXMLFloorPlan, 'xml');
-}
+//function loadFloorplan()
+//{
+// $.get('floorplan01.xml', parseXMLFloorPlan, 'xml');
+//}
var floor;
// this array will contain all vertices to show in the svg
var vertices = Array();
// infos about the building
-var buildingProperties = { floor: [], Object3D: new THREE.Object3D() };
+JSFloorPlan3D.buildingProperties = { floor: [], Object3D: new THREE.Object3D() };
var imageCenter = new Object;
var noFloorplan = true;
-function parseXMLFloorPlan( xmlDoc )
+
+//return { parseXMLFloorPlan: function( xmlDoc )
+JSFloorPlan3D.parseXMLFloorPlan = function( xmlDoc )
{
noFloorplan = false;
@@ -135,16 +139,16 @@
"Expected: 'floor', found '" + floor.tagName + "'" );
floorCount++;
- buildingProperties.floor[floorCount] = {};
+ JSFloorPlan3D.buildingProperties.floor[floorCount] = {};
var floorName = floor.getAttribute('name');
- buildingProperties.floor[floorCount].name = floorName;
+ JSFloorPlan3D.buildingProperties.floor[floorCount].name = floorName;
var floorheight = Number( floor.getAttribute('height') );
- buildingProperties.floor[floorCount].height = floorheight;
- buildingProperties.floor[floorCount].heightOfGround = heightOfGround;
+ JSFloorPlan3D.buildingProperties.floor[floorCount].height = floorheight;
+ JSFloorPlan3D.buildingProperties.floor[floorCount].heightOfGround = heightOfGround;
- var floorWallsStart = floorWalls.length;
+ var floorWallsStart = 0;// floorWalls.length; <- not defined here yet...
// iterate over the content of this floor
for( var j=0; j < floor.childNodes.length; j++ )
@@ -472,23 +476,24 @@
Object3D.add( lineGroup );
Object3D.add( wallGroup );
- buildingProperties.floor[floorCount].Object3D = Object3D;
- buildingProperties.floor[floorCount].nodeGroup = nodeGroup;
- buildingProperties.floor[floorCount].lineGroup = lineGroup;
- buildingProperties.floor[floorCount].wallGroup = wallGroup;
- buildingProperties.Object3D.add( Object3D ); // add / link; note: we use that JavaScript is not copying objects but uses ref counting on them here!
+ JSFloorPlan3D.buildingProperties.floor[floorCount].Object3D = Object3D;
+ JSFloorPlan3D.buildingProperties.floor[floorCount].nodeGroup = nodeGroup;
+ JSFloorPlan3D.buildingProperties.floor[floorCount].lineGroup = lineGroup;
+ JSFloorPlan3D.buildingProperties.floor[floorCount].wallGroup = wallGroup;
+ JSFloorPlan3D.buildingProperties.Object3D.add( Object3D ); // add / link; note: we use that JavaScript is not copying objects but uses ref counting on them here!
heightOfGround += floorheight;
} // end floor
- buildingProperties.x_center = (buildingProperties.x_max - buildingProperties.x_min) / 2;
- buildingProperties.y_center = (buildingProperties.y_max - buildingProperties.y_min) / 2;
- imageCenter.x = buildingProperties.x_center;
- imageCenter.y = buildingProperties.y_center;
- imageCenter.z = buildingProperties.z_max / 2;
+ JSFloorPlan3D.buildingProperties.x_center = (JSFloorPlan3D.buildingProperties.x_max - JSFloorPlan3D.buildingProperties.x_min) / 2;
+ JSFloorPlan3D.buildingProperties.y_center = (JSFloorPlan3D.buildingProperties.y_max - JSFloorPlan3D.buildingProperties.y_min) / 2;
+ imageCenter.x = JSFloorPlan3D.buildingProperties.x_center;
+ imageCenter.y = JSFloorPlan3D.buildingProperties.y_center;
+ imageCenter.z = JSFloorPlan3D.buildingProperties.z_max / 2;
- show3D( 35*Math.PI/180, 30*Math.PI/180 );
-}
+ JSFloorPlan3D.show3D( 35*Math.PI/180, 30*Math.PI/180 );
+//}
+};
var floorNodes = new Object();
function parseFloorNodes( nodes, floorheight )
@@ -507,21 +512,21 @@
floorNodes[id] = point;
- if( undefined == buildingProperties.x_min )
+ if( undefined == JSFloorPlan3D.buildingProperties.x_min )
{
- buildingProperties.x_min = point.x;
- buildingProperties.x_max = point.x;
- buildingProperties.y_min = point.y;
- buildingProperties.y_max = point.y;
- buildingProperties.z_min = point.z;
- buildingProperties.z_max = point.z;
+ JSFloorPlan3D.buildingProperties.x_min = point.x;
+ JSFloorPlan3D.buildingProperties.x_max = point.x;
+ JSFloorPlan3D.buildingProperties.y_min = point.y;
+ JSFloorPlan3D.buildingProperties.y_max = point.y;
+ JSFloorPlan3D.buildingProperties.z_min = point.z;
+ JSFloorPlan3D.buildingProperties.z_max = point.z;
} else {
- if( buildingProperties.x_min > point.x ) buildingProperties.x_min = point.x;
- if( buildingProperties.x_max < point.x ) buildingProperties.x_max = point.x;
- if( buildingProperties.y_min > point.y ) buildingProperties.y_min = point.y;
- if( buildingProperties.y_max < point.y ) buildingProperties.y_max = point.y;
- if( buildingProperties.z_min > point.z ) buildingProperties.z_min = point.z;
- if( buildingProperties.z_max < point.z ) buildingProperties.z_max = point.z;
+ if( JSFloorPlan3D.buildingProperties.x_min > point.x ) JSFloorPlan3D.buildingProperties.x_min = point.x;
+ if( JSFloorPlan3D.buildingProperties.x_max < point.x ) JSFloorPlan3D.buildingProperties.x_max = point.x;
+ if( JSFloorPlan3D.buildingProperties.y_min > point.y ) JSFloorPlan3D.buildingProperties.y_min = point.y;
+ if( JSFloorPlan3D.buildingProperties.y_max < point.y ) JSFloorPlan3D.buildingProperties.y_max = point.y;
+ if( JSFloorPlan3D.buildingProperties.z_min > point.z ) JSFloorPlan3D.buildingProperties.z_min = point.z;
+ if( JSFloorPlan3D.buildingProperties.z_max < point.z ) JSFloorPlan3D.buildingProperties.z_max = point.z;
}
}
}
@@ -616,7 +621,7 @@
if( noFloorplan ) return;
noSetup = false;
- scene.add( buildingProperties.Object3D );
+ scene.add( JSFloorPlan3D.buildingProperties.Object3D );
var showFloor = showStates.showFloor;
@@ -635,7 +640,7 @@
selectChange( 'showFloor' );
}
-function show3D( rotation, tilt )
+JSFloorPlan3D.show3D = function( rotation, tilt )
{
if( noSetup ) setup3D();
@@ -643,10 +648,10 @@
var cx = -Math.cos(rotation) * Math.cos(tilt);
var cy = Math.sin(rotation) * Math.cos(tilt);
var cz = Math.sin(tilt);
- var heightOfGround = buildingProperties.floor[ showStates.showFloor ].heightOfGround;
- var target = new THREE.Vector3( buildingProperties.x_center, buildingProperties.y_center, heightOfGround);
+ var heightOfGround = JSFloorPlan3D.buildingProperties.floor[ showStates.showFloor ].heightOfGround;
+ var target = new THREE.Vector3( JSFloorPlan3D.buildingProperties.x_center, JSFloorPlan3D.buildingProperties.y_center, heightOfGround);
camera.up = new THREE.Vector3( Math.cos(rotation) * Math.sin(tilt), -Math.sin(rotation) * Math.sin(tilt), Math.cos(tilt) );
- camera.position = new THREE.Vector3( cx*dist + buildingProperties.x_center, cy*dist + buildingProperties.y_center, dist * cz + heightOfGround);
+ camera.position = new THREE.Vector3( cx*dist + JSFloorPlan3D.buildingProperties.x_center, cy*dist + JSFloorPlan3D.buildingProperties.y_center, dist * cz + heightOfGround);
camera.lookAt( target );
pointLight.position = camera.position;
@@ -694,4 +699,6 @@
};
render();
-}
\ No newline at end of file
+}
+
+};//());
\ No newline at end of file
Modified: JSFloorPlan/trunk/src/jsfloorplan_example_helper.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan_example_helper.js 2011-12-18 14:39:40 UTC (rev 591)
+++ JSFloorPlan/trunk/src/jsfloorplan_example_helper.js 2011-12-18 15:45:26 UTC (rev 592)
@@ -21,7 +21,13 @@
//
//////////////////////////////////////////////////////////////////////////////
+j = new JSFLOORPLAN3D();
+function loadFloorplan()
+{
+ $.get('floorplan01.xml', j.parseXMLFloorPlan, 'xml');
+}
+
function three_init()
{
return;
@@ -183,7 +189,7 @@
function animate() {
requestAnimationFrame( animate );
//render();
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
//stats.update();
}
@@ -238,14 +244,14 @@
$('input').change(function(e){
showStates[ e.target.name ] = e.target.checked;
selectChange( e.target.name );
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
}).each(function(){
showStates[ this.name ] = this.checked; // init
});
$('select').change(function(e){
showStates[ e.target.name ] = e.target.value;
selectChange( e.target.name );
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
}).each(function(){
showStates[ this.name ] = this.value; // init
});
@@ -259,7 +265,7 @@
switch( name )
{
case 'showNodes':
- $( buildingProperties.floor ).each( function(){
+ $( j.buildingProperties.floor ).each( function(){
THREE.SceneUtils.traverseHierarchy( this.nodeGroup, function( object ) {
object.visible = showStates['showNodes'];
});
@@ -267,7 +273,7 @@
break;
case 'showWallLines':
- $( buildingProperties.floor ).each( function(){
+ $( j.buildingProperties.floor ).each( function(){
THREE.SceneUtils.traverseHierarchy( this.lineGroup, function( object ) {
object.visible = showStates['showWallLines'];
});
@@ -275,7 +281,7 @@
break;
case 'showFloor':
- $( buildingProperties.floor ).each( function( number ){
+ $( j.buildingProperties.floor ).each( function( number ){
THREE.SceneUtils.traverseHierarchy( this.wallGroup, function( object ) {
object.visible = ( showStates['showFloor'] == number );
});
@@ -316,7 +322,7 @@
if( tilt < 0 )
tilt_dir = 1;
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
//////
var middle = new Date();
@@ -397,7 +403,7 @@
if( redraw )
{
- show3D( roll, tilt, plan );
+ j.show3D( roll, tilt, plan );
}
}
*/
@@ -421,7 +427,7 @@
if( redraw )
{
- show3D( roll, tilt, plan );
+ j.show3D( roll, tilt, plan );
}
}
*/
@@ -462,49 +468,49 @@
{
if( globalInUpdateSlider ) return true;
roll = ui.value * Math.PI / 180;
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
}
function tiltChange( event, ui )
{
if( globalInUpdateSlider ) return true;
tilt = ui.value * Math.PI / 180;
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
}
function distChange( event, ui )
{
if( globalInUpdateSlider ) return true;
dist = ui.value;
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
}
function lightDirectionChange( event, ui )
{
if( globalInUpdateSlider ) return true;
lightDirection = ui.value * Math.PI / 180;
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
}
function lightHeightChange( event, ui )
{
if( globalInUpdateSlider ) return true;
lightHeight = ui.value * Math.PI / 180;
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
}
function lightStrengthChange( event, ui )
{
if( globalInUpdateSlider ) return true;
lightStrength = ui.value;
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
}
function lightDistanceChange( event, ui )
{
if( globalInUpdateSlider ) return true;
lightDistance = ui.value;
- show3D( roll, tilt );
+ j.show3D( roll, tilt );
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|