|
From: <ma...@us...> - 2011-12-09 10:37:05
|
Revision: 556
http://openautomation.svn.sourceforge.net/openautomation/?rev=556&view=rev
Author: mayerch
Date: 2011-12-09 10:36:54 +0000 (Fri, 09 Dec 2011)
Log Message:
-----------
Cleanup totally unnecessary stuff
Modified Paths:
--------------
JSFloorPlan/trunk/jsfloorplan.js
Modified: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-09 10:31:43 UTC (rev 555)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-09 10:36:54 UTC (rev 556)
@@ -94,102 +94,13 @@
return element.setAttributeNS( XLINK_NS, attribute, value );
}
-/*
-function newXMLHttpRequest()
-{
- try { return new XMLHttpRequest() } catch(e){}
- try { return new ActiveXObject("MSXML3.XMLHTTP") } catch(e){}
- try { return new ActiveXObject("MSXML2.XMLHTTP.3.0") } catch(e){}
- try { return new ActiveXObject("Msxml2.XMLHTTP") } catch(e){}
- try { return new ActiveXObject("Microsoft.XMLHTTP") } catch(e){}
- return null;
-}
-
-if (typeof(XMLHttpRequest) == 'undefined')
-{
- function XMLHttpRequest()
- {
- try { return new ActiveXObject("MSXML3.XMLHTTP") } catch(e){}
- try { return new ActiveXObject("MSXML2.XMLHTTP.3.0") } catch(e){}
- try { return new ActiveXObject("Msxml2.XMLHTTP") } catch(e){}
- try { return new ActiveXObject("Microsoft.XMLHTTP") } catch(e){}
- return null;
- };
-}
-*/
-
/*******************************************************************/
/* IE compatability stuff ends here */
/*******************************************************************/
-var xmlDoc;
function loadFloorplan()
{
- /*
- var httpRequest = new newXMLHttpRequest();
- httpRequest.open("GET", "floorplan01.xml", false); // don't open async
-
- httpRequest.onreadystatechange = function()
- {
- var isLocal = (httpRequest.status == 0);
-
- if (httpRequest.readyState == 4 &&
- (httpRequest.status == 200 || isLocal))
- {
- if (httpRequest.responseXML == null)
- // Mozilla failure, local or HTTP
- failure();
- else if(httpRequest.responseXML.document == null)
- {
- // IE
- if (!isLocal) documentElement
- {
- // HTTP failure
- failure();
- } else {
- // Local failure--always happens, try
- // using Microsoft.XMLDOM to load
- xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
- xmlDoc.async = false;
- xmlDoc.loadXML(httpRequest.responseText);
-
- if (xmlDoc.documentElement != null)
- success(xmlDoc);
- else
- failure();
- }
- } else {
- success(httpRequest.responseXML);
- //xmlDoc = httpRequest.responseXML;
- }
- } else {
- alert( "big fail; readystate: "+httpRequest.readyState+" status: "+httpRequest.status);
- }
- };
- httpRequest.send();
- parseXMLFloorPlan();
- */
- // code for IE
- /*
- if (window.ActiveXObject)
- {
- xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
- }
- // code for Mozilla, Firefox, Opera, etc.
- else if (document.implementation.createDocument)
- {
- xmlDoc=document.implementation.createDocument("","",null);
- }
- else
- {
- alert('Your browser cannot handle this script');
- }
- xmlDoc.async=false;
- xmlDoc.onload = parseXMLFloorPlan;
- xmlDoc.load("floorplan01.xml");
- */
$.get('floorplan01.xml', parseXMLFloorPlan, 'xml');
-
}
var floor;
var floorCount = -1;
@@ -401,9 +312,6 @@
show3D( 35*Math.PI/180, 30*Math.PI/180, plan );
//document.getElementById( "top_level" ).appendChild( plan );
-
- // clean up and save space
- delete xmlDoc;
}
var floorNodes = new Object();
@@ -974,16 +882,6 @@
{
if( noSetup ) setup3D();
- //var dist = 30;
- /*
- //camera.position.z = rotation * 180 / Math.PI;
- //camera.rotation.z = rotation;
- //camera.rotation.y = tilt;
- camera.position.z = Math.sin(tilt) * dist;
- camera.position.x = Math.cos(tilt) * dist * Math.sin(rotation);
- camera.position.y = Math.cos(tilt) * dist * Math.cos(rotation);
- */
- //renderer.render(scene, camera);
var cx = -Math.cos(rotation) * Math.cos(tilt);
var cy = Math.sin(rotation) * Math.cos(tilt);
var cz = Math.sin(tilt);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-09 15:37:13
|
Revision: 558
http://openautomation.svn.sourceforge.net/openautomation/?rev=558&view=rev
Author: mayerch
Date: 2011-12-09 15:37:02 +0000 (Fri, 09 Dec 2011)
Log Message:
-----------
Corrected up vector calculation for the camera setup so that it's not jumping anymore at the extreme case
Modified Paths:
--------------
JSFloorPlan/trunk/jsfloorplan.js
Modified: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-09 12:49:24 UTC (rev 557)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-09 15:37:02 UTC (rev 558)
@@ -893,7 +893,7 @@
var cx = -Math.cos(rotation) * Math.cos(tilt);
var cy = Math.sin(rotation) * Math.cos(tilt);
var cz = Math.sin(tilt);
- camera.up = new THREE.Vector3( -cx, -cy, 1 );
+ 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 );
camera.lookAt( new THREE.Vector3( buildingProperties.x_center, buildingProperties.y_center, 0) );
pointLight.position = camera.position;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-09 17:28:43
|
Revision: 560
http://openautomation.svn.sourceforge.net/openautomation/?rev=560&view=rev
Author: mayerch
Date: 2011-12-09 17:28:37 +0000 (Fri, 09 Dec 2011)
Log Message:
-----------
Remove even more old SVG stuff to prepare for a clean WebGL/Three.js implementation
Modified Paths:
--------------
JSFloorPlan/trunk/jsfloorplan.js
Modified: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-09 16:48:33 UTC (rev 559)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-09 17:28:37 UTC (rev 560)
@@ -25,8 +25,6 @@
// setup script here:
// don't change anything below:
-var SVG_NS ="http://www.w3.org/2000/svg";
-var XLINK_NS ="http://www.w3.org/1999/xlink";
var ELEMENT_NODE = 1;
// calculate the distance between two cartesian 2D points
@@ -74,32 +72,6 @@
return pseudoangle_a - pseudoangle_b;
}
-/*******************************************************************/
-/* IE compatability stuff starts here */
-/*******************************************************************/
-/*
-// Fix problems of IE that it doesn't support the
-// createElementNS method
-function createSVGElement( element )
-{
- if( typeof document.createElementNS != 'undefined' )
- return document.createElementNS( SVG_NS, element );
-
- if( typeof document.createElement != 'undefined' )
- return document.createElement (element );
-
- return false;
-}
-function setXlinkAttribute( element, attribute, value )
-{
- return element.setAttributeNS( XLINK_NS, attribute, value );
-}
-*/
-
-/*******************************************************************/
-/* IE compatability stuff ends here */
-/*******************************************************************/
-
function loadFloorplan()
{
$.get('floorplan01.xml', parseXMLFloorPlan, 'xml');
@@ -120,9 +92,6 @@
function parseXMLFloorPlan( xmlDoc )
{
noFloorplan = false;
- // create the SVG node where all elements are collected in
- //var plan = document.createElementNS( SVG_NS, "g" );
- //var plan = createSVGElement( "g" );
// basic check if the document seems right
// this could be avoided if the XML file would be validated
@@ -313,7 +282,6 @@
imageCenter.z = buildingProperties.z_max / 2;
show3D( 35*Math.PI/180, 30*Math.PI/180 );
- //document.getElementById( "top_level" ).appendChild( plan );
}
var floorNodes = new Object();
@@ -429,327 +397,13 @@
function parseTextures( nodes )
{
return;
- var defs = createSVGElement( 'defs' );
for( var i=0; i < nodes.childNodes.length; i++ )
{
node = nodes.childNodes[i];
if (node.nodeType != ELEMENT_NODE) continue;
-
- var pattern = createSVGElement( 'pattern' );
- pattern.setAttribute( 'id', node.getAttribute('id') );
- pattern.setAttribute( 'x', 0 );
- pattern.setAttribute( 'y', 0 );
- pattern.setAttribute( 'width', Number( node.getAttribute('width' ) )*200 );
- pattern.setAttribute( 'height', Number( node.getAttribute('height') )*200 );
- /*
- textures[id] = new Object();
- textures[id].width = Number( node.getAttribute('width' ) );
- textures[id].height = Number( node.getAttribute('height') );
- textures[id].src = node.getAttribute('src' );
- textures[id].svg = createSVGElement( "image" );
- */
- var texture = createSVGElement( "image" );
- texture.setAttribute( "width", Number( node.getAttribute('width' ) )*200 );
- texture.setAttribute( "height", Number( node.getAttribute('height') )*200 );
- setXlinkAttribute( texture, "href", node.getAttribute('src') );
- //textures[id].setAttribute( "href", node.getAttribute('src') );
-
- pattern.appendChild( texture );
- defs.appendChild( pattern );
}
- document.getElementById( "top_level" ).appendChild( defs );
}
-/*
-//var wrapper = document.createElementNS( SVG_NS, "g" );
-var wrapper = createSVGElement( "g" );
-wrapper.setAttribute( "fill", fillColor );
-wrapper.setAttribute( "fill-opacity", fillOpacity );
-wrapper.setAttribute( "fill", "grey" );
-////wrapper.setAttribute( "stroke", "black" );
-////wrapper.setAttribute( "stroke-width", "1" );
-wrapper.setAttribute( "onmouseover", 'set_color(this);' );
-wrapper.setAttribute( "onmouseout", 'unset_color(this,"grey");' );
-wrapper.setAttribute( "transform", 'translate(400,200)' );
-
-var poly_stroke = createSVGElement( "path" );
-poly_stroke.setAttribute( "style", "stroke:black;stroke-width:1;" );
-var poly_only = createSVGElement( "path" );
-var poly_clear = createSVGElement( "path" );
-poly_clear.setAttribute( "style", "stroke:none;fill:none;" );
-*/
-
-run_count = 5;
-// show the diagram in a 2.5D perspective, i.e. isometric
-function show25D( rotation, tilt, plan )
-{
- ////t_25d_start = new Date;
- //console.log( rotation, tilt, plan );
- return;
-
- var h_short = Math.cos( tilt ); // horizontal shortening factor
- var v_short = Math.sin( tilt ); // vertical shortening factor
- var x_offset = -imageCenter.x * sc;
- var y_offset = (imageCenter.z *v_short- imageCenter.y* h_short) * sc; // correct tilt
-
- // to reduce the amount of trigonometric calls: pre calculate them
- var rot_s = Math.sin( rotation );
- var rot_c = Math.cos( rotation );
-
- // depth sorting of the elements
- var order = new Array;
- for( var i=1; i<lines[showFloor].length; i+=3 )
- {
- order.push( Array( i,
- rot_s * floorNodes[ lines[showFloor][i][0] ].x + rot_c * floorNodes[ lines[showFloor][i][0] ].y +
- rot_s * floorNodes[ lines[showFloor][i][1] ].x + rot_c * floorNodes[ lines[showFloor][i][1] ].y
- ));
- }
- order.sort( function(a,b){ return a[1]-b[1]; } );
- ////t_25d_after_sort = new Date;
-
- for( var o=0; o<order.length; o++ )
- {
- var i = order[o][0]-1;
-
- var s1 = rotate2D( rot_s, rot_c, vertices [ lines[showFloor][ i][0] ], imageCenter );
- var e1 = rotate2D( rot_s, rot_c, vertices [ lines[showFloor][ i][1] ], imageCenter );
- var sm = rotate2D( rot_s, rot_c, floorNodes[ lines[showFloor][++i][1] ], imageCenter );
- var em = rotate2D( rot_s, rot_c, floorNodes[ lines[showFloor][ i][0] ], imageCenter );
- var sh = v_short * floorNodes[ lines[showFloor][i][1] ].z;
- var eh = v_short * floorNodes[ lines[showFloor][i][0] ].z;
- var thickness = lines[showFloor][ i][2];
- var texture = lines[showFloor][ i][3];
- var holes = lines[showFloor][ i][4];
- var s2 = rotate2D( rot_s, rot_c, vertices [ lines[showFloor][++i][0] ], imageCenter );
- var e2 = rotate2D( rot_s, rot_c, vertices [ lines[showFloor][ i][1] ], imageCenter );
-
- var wallSideOrder = (s1.y*e1.x-s1.x*e1.y)*(e2.x-s2.x) - (s2.y*e2.x-s2.x*e2.y)*(e1.x-s1.x);
-
- var w = wrapper.cloneNode( true );
-
- // disable the textures as they are causing big troubles (at least
- // with FF3.0) in this implementation
- if( false && texture != 0 ) // showTextures
- {
- var img = poly_only.cloneNode( true );
- img.setAttribute( 'fill', 'url(#' + texture + ')' );
- img.setAttribute( "points",
- e1.x*sc + ',' + (e1.y*h_short+eh)*sc + ' ' +
- s1.x*sc + ',' + (s1.y*h_short+sh)*sc + ' ' +
- s1.x*sc + ',' + s1.y*h_short*sc + ' ' +
- e1.x*sc + ',' + e1.y*h_short*sc );
- var wi = 200; //textures[texture].width;
- var he = 200; //textures[texture].height;
- var ma = ((s1.x)-(s1.x))*sc/he;
- var mb = ((s1.y*h_short+sh)-(s1.y*h_short))*sc/he;
- var mc = ((e1.x)-(s1.x))*sc/wi;
- var md = ((e1.y)-(s1.y))*h_short*sc/wi;
- var me = s1.x*sc;
- var mf = s1.y*h_short*sc;
- img.setAttribute( "transformX", "matrix(" +
- ma.toFixed(3) + ' ' + mb.toFixed(3) + ' ' +
- mc.toFixed(3) + ' ' + md.toFixed(3) + ' ' +
- me.toFixed(3) + ' ' + mf.toFixed(3) + ')');
- w.appendChild( img );
- }
-
- var h = new Array;
- for( var j=0; j < holes.length; j++ )
- {
- h[j] = new Object;
- var wallLength = calcLength2D( sm, em );
- var fLeft = holes[j].distance / wallLength;
- var fRight = (holes[j].distance + holes[j].width) / wallLength;
- var normal_x = +(sm.y - em.y) / wallLength * thickness / 2;
- var normal_y = -(sm.x - em.x) / wallLength * thickness / 2;
- var xLeft = sm.x * fLeft + em.x * (1 - fLeft );
- var xRight = sm.x * fRight + em.x * (1 - fRight);
- var yLeft = sm.y * fLeft + em.y * (1 - fLeft );
- var yRight = sm.y * fRight + em.y * (1 - fRight);
- var lintel = sh - holes[j].lintel * v_short;
- var paparet = holes[j].paparet * v_short;
-
- h[j].tl1_x = ( ( xLeft - normal_x )*sc+x_offset).toFixed(1);
- h[j].tr1_x = ( ( xRight - normal_x )*sc+x_offset).toFixed(1);
- h[j].tl1_y = ( ((yLeft - normal_y)*h_short-lintel )*sc+y_offset).toFixed(1);
- h[j].tr1_y = ( ((yRight - normal_y)*h_short-lintel )*sc+y_offset).toFixed(1);
- h[j].bl1_y = ( ((yLeft - normal_y)*h_short-paparet)*sc+y_offset).toFixed(1);
- h[j].br1_y = ( ((yRight - normal_y)*h_short-paparet)*sc+y_offset).toFixed(1);
- h[j].tl2_x = ( ( xLeft + normal_x )*sc+x_offset).toFixed(1);
- h[j].tr2_x = ( ( xRight + normal_x )*sc+x_offset).toFixed(1);
- h[j].tl2_y = ( ((yLeft + normal_y)*h_short-lintel )*sc+y_offset).toFixed(1);
- h[j].tr2_y = ( ((yRight + normal_y)*h_short-lintel )*sc+y_offset).toFixed(1);
- h[j].bl2_y = ( ((yLeft + normal_y)*h_short-paparet)*sc+y_offset).toFixed(1);
- h[j].br2_y = ( ((yRight + normal_y)*h_short-paparet)*sc+y_offset).toFixed(1);
- }
-
- // note: don't pass the full float precision to the SVG as the
- // conversion time float -> text -> float can take a significant time...
- var e1_y_fh = ((e1.y * h_short - eh) * sc +y_offset).toFixed(1);
- var s1_y_fh = ((s1.y * h_short - sh) * sc +y_offset).toFixed(1);
- var em_y_fh = ((em.y * h_short - eh) * sc +y_offset).toFixed(1);
- var sm_y_fh = ((sm.y * h_short - sh) * sc +y_offset).toFixed(1);
- var e2_y_fh = ((e2.y * h_short - eh) * sc +y_offset).toFixed(1);
- var s2_y_fh = ((s2.y * h_short - sh) * sc +y_offset).toFixed(1);
- s1.y = (s1.y * h_short * sc+y_offset).toFixed(2); s1.x = (s1.x * sc+x_offset).toFixed(2);
- e1.y = (e1.y * h_short * sc+y_offset).toFixed(2); e1.x = (e1.x * sc+x_offset).toFixed(2);
- sm.y = (sm.y * h_short * sc+y_offset).toFixed(2); sm.x = (sm.x * sc+x_offset).toFixed(2);
- em.y = (em.y * h_short * sc+y_offset).toFixed(2); em.x = (em.x * sc+x_offset).toFixed(2);
- s2.y = (s2.y * h_short * sc+y_offset).toFixed(2); s2.x = (s2.x * sc+x_offset).toFixed(2);
- e2.y = (e2.y * h_short * sc+y_offset).toFixed(2); e2.x = (e2.x * sc+x_offset).toFixed(2);
- if( showWallSides ) // the sides of the walls
- {
- var path1 =
- 'M' + e1.x + ',' + (e1_y_fh) +
- 'L' + s1.x + ',' + (s1_y_fh) +
- 'L' + s1.x + ',' + s1.y +
- 'L' + e1.x + ',' + e1.y + 'z';
- for( var j=0; showHoles && j < h.length; j++ )
- {
- path1 +=
- 'M' + h[j].tl1_x + ',' + h[j].tl1_y +
- 'L' + h[j].tl1_x + ',' + h[j].bl1_y +
- 'L' + h[j].tr1_x + ',' + h[j].br1_y +
- 'L' + h[j].tr1_x + ',' + h[j].tr1_y + 'z';
- }
- var path2 =
- 'M' + e2.x + ',' + (e2_y_fh) +
- 'L' + s2.x + ',' + (s2_y_fh) +
- 'L' + s2.x + ',' + s2.y +
- 'L' + e2.x + ',' + e2.y + 'z';
- for( var j=0; showHoles && j < h.length; j++ )
- {
- path2 +=
- 'M' + h[j].tl2_x + ',' + h[j].tl2_y +
- 'L' + h[j].tl2_x + ',' + h[j].bl2_y +
- 'L' + h[j].tr2_x + ',' + h[j].br2_y +
- 'L' + h[j].tr2_x + ',' + h[j].tr2_y + 'z';
- }
- var path3 = '';
- for( var j=0; showHoles && j < h.length; j++ )
- {
- if( wallSideOrder > 0 )
- {
- path3 +=
- 'M' + h[j].tr1_x + ',' + h[j].tr1_y + 'L' + h[j].tr2_x + ',' + h[j].tr2_y +
- 'L' + h[j].tl2_x + ',' + h[j].tl2_y + 'L' + h[j].tl1_x + ',' + h[j].tl1_y +'z'+
- 'M' + h[j].tr1_x + ',' + h[j].br1_y + 'L' + h[j].tr2_x + ',' + h[j].br2_y +
- 'L' + h[j].tr2_x + ',' + h[j].tr2_y + 'L' + h[j].tr1_x + ',' + h[j].tr1_y +'z'+
- 'M' + h[j].tl1_x + ',' + h[j].bl1_y + 'L' + h[j].tl2_x + ',' + h[j].bl2_y +
- 'L' + h[j].tr2_x + ',' + h[j].br2_y + 'L' + h[j].tr1_x + ',' + h[j].br1_y +'z'+
- 'M' + h[j].tl1_x + ',' + h[j].tl1_y + 'L' + h[j].tl2_x + ',' + h[j].tl2_y +
- 'L' + h[j].tl2_x + ',' + h[j].bl2_y + 'L' + h[j].tl1_x + ',' + h[j].bl1_y +'z';
- } else {
- path3 +=
- 'M' + h[j].tl1_x + ',' + h[j].tl1_y + 'L' + h[j].tl2_x + ',' + h[j].tl2_y +
- 'L' + h[j].tr2_x + ',' + h[j].tr2_y + 'L' + h[j].tr1_x + ',' + h[j].tr1_y +'z'+
- 'M' + h[j].tr1_x + ',' + h[j].tr1_y + 'L' + h[j].tr2_x + ',' + h[j].tr2_y +
- 'L' + h[j].tr2_x + ',' + h[j].br2_y + 'L' + h[j].tr1_x + ',' + h[j].br1_y +'z'+
- 'M' + h[j].tr1_x + ',' + h[j].br1_y + 'L' + h[j].tr2_x + ',' + h[j].br2_y +
- 'L' + h[j].tl2_x + ',' + h[j].bl2_y + 'L' + h[j].tl1_x + ',' + h[j].bl1_y +'z'+
- 'M' + h[j].tl1_x + ',' + h[j].bl1_y + 'L' + h[j].tl2_x + ',' + h[j].bl2_y +
- 'L' + h[j].tl2_x + ',' + h[j].tl2_y + 'L' + h[j].tl1_x + ',' + h[j].tl1_y +'z';
- }
- }
-
- var frontPath;
- var backPath;
- // backside culling:
- if( wallSideOrder < 0 )
- {
- frontPath = path2;
- backPath = path1;
- /*if( showBackside )
- path = path1;
- path += path2;*/
- } else {
- frontPath = path1;
- backPath = path2;
- /*if( showBackside )
- path = path2;
- path += path1;*/
- }
- if( !showBackside )
- {
- backPath = '';
- }
- backPath += path3;
- var wall = showSideLines ? poly_stroke.cloneNode( true )
- : poly_only.cloneNode( true ) ;
- wall.setAttribute( 'd', backPath );
- w.appendChild( wall );
- var wall = showSideLines ? poly_stroke.cloneNode( true )
- : poly_only.cloneNode( true ) ;
- wall.setAttribute( 'd', frontPath );
- w.appendChild( wall );
- }
- if( showWallTop ) // the top of the walls
- {
- var rect3 = showTopLines ? poly_stroke.cloneNode( true ) : poly_only.cloneNode( true ) ;
- rect3.setAttribute( 'd',
- 'M' + sm.x + ',' + sm_y_fh +
- 'L' + s1.x + ',' + s1_y_fh +
- 'L' + e1.x + ',' + e1_y_fh +
- 'L' + em.x + ',' + em_y_fh +
- 'L' + e2.x + ',' + e2_y_fh +
- 'L' + s2.x + ',' + s2_y_fh + 'z' );
- w.appendChild( rect3 );
- }
- plan.appendChild( w );
-
- // clean up, so that the garbage collector doesn't bite us
- delete s1;
- delete e1;
- delete sm;
- delete em;
- delete s2;
- delete e2;
- delete h;
- } // end for( o=0; o<order.length; o++ )
-
- // show zones
- if( showZones )
- {
- var w = wrapper.cloneNode( true );
- for( j=0; j<rooms[showFloor].length; j++ )
- {
- for( var k=0; k<rooms[showFloor][j].zones.length; k++ )
- {
- var area = showVisibleZones ? poly_stroke.cloneNode( true )
- : poly_clear.cloneNode( true ) ;
- var points = '';
- for( var l=0; l<rooms[showFloor][j].zones[k].corners.length; l++ )
- {
- n = rooms[showFloor][j].zones[k].corners[l];
- var p = rotate2D( rot_s, rot_c, floorNodes[n], imageCenter );
- var h = v_short * floorNodes[n].z;
- p.y = ((p.y * h_short - h) * sc +y_offset).toFixed(2);
- p.x = (p.x * sc+x_offset).toFixed(2);
- points += (( 0 == l ) ? 'M' : 'L') + p.x + ',' + p.y;
- }
- area.setAttribute( 'd', points+'z' );
- if( rooms[showFloor][j].zones[k].onclick )
- area.setAttribute( 'onclick', rooms[showFloor][j].zones[k].onclick );
- w.appendChild( area );
- }
- }
- plan.appendChild( w );
- } //if( showZones )
-
- ////t_25d_end = new Date;
-}
-
-/*
-plan = createSVGElement( "g" );
-function replaceSVG( SVGelement )
-{
- SVGelement.replaceChild( plan, SVGelement.lastChild );
- delete plan;
- plan = createSVGElement( "g" );
-}
-*/
-
var noSetup = true;
function setup3D()
{
@@ -760,7 +414,6 @@
for( var i=0; i<lines[showFloor].length; )
{
- //console.log(i);
/*
var s1 = rotate2D( rot_s, rot_c, vertices [ lines[showFloor][ i][0] ], imageCenter );
var e1 = rotate2D( rot_s, rot_c, vertices [ lines[showFloor][ i][1] ], imageCenter );
@@ -808,25 +461,9 @@
*/
var geometry = new THREE.Geometry();
-//var vertices = [];
-//vertices.push(new THREE.Vector3(0, 0, 0));
-//vertices.push(new THREE.Vector3(1, 0, 0));
-//vertices.push(new THREE.Vector3(0, 1, 0));
- /*
- for ( j = 0; j < vertices.length; j = j + 4) {
- geometry.vertices.push(new THREE.Vertex(Tvertices[j]));
- geometry.vertices.push(new THREE.Vertex(Tvertices[j+1]));
- geometry.vertices.push(new THREE.Vertex(Tvertices[j+2]));
- geometry.vertices.push(new THREE.Vertex(Tvertices[j+3]));
-
- geometry.faces.push(new THREE.Face3( j, j+1, j+2 ));
- geometry.faces.push(new THREE.Face3( j+2, j+1, j+3 ));
-
- //geometry.faceVertexUvs[0].push([
- // new THREE.UV(u_value, v_value)), new THREE.UV(u_value, v_value)), new THREE.UV(u_value, v_value))
- //]);
- }
- */
+ //geometry.faceVertexUvs[0].push([
+ // new THREE.UV(u_value, v_value)), new THREE.UV(u_value, v_value)), new THREE.UV(u_value, v_value))
+ //]);
geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(e1.x,e1.y,0)));
geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(e1.x,e1.y,sh)));
geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(s1.x,s1.y,0)));
@@ -878,12 +515,6 @@
var $container = $('#top_level');
// attach the render-supplied DOM element
$container.append(renderer.domElement);
- // draw!
- //scene.add( camera );
- //renderer.render(scene, camera);
- //render();
-// animate();
-
}
function show3D( rotation, tilt )
@@ -925,6 +556,5 @@
break;
};
-
render();
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-09 22:48:39
|
Revision: 563
http://openautomation.svn.sourceforge.net/openautomation/?rev=563&view=rev
Author: mayerch
Date: 2011-12-09 22:48:33 +0000 (Fri, 09 Dec 2011)
Log Message:
-----------
Clean up
Modified Paths:
--------------
JSFloorPlan/trunk/jsfloorplan.js
Modified: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-09 22:42:32 UTC (rev 562)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-09 22:48:33 UTC (rev 563)
@@ -80,9 +80,6 @@
// this array will contain all vertices to show in the svg
var vertices = Array();
-// this array will contain all the lines to show by refencing
-// the corresponding vertices
-var lines = Array();
// infos about the building
var buildingProperties = { floor: [], Object3D: new THREE.Object3D() };
var imageCenter = new Object;
@@ -132,8 +129,6 @@
buildingProperties.floor[floorCount].height = floorheight;
buildingProperties.floor[floorCount].heightOfGround = heightOfGround;
- lines[floorCount] = new Array;
-
var floorWallsStart = floorWalls.length;
// iterate over the content of this floor
@@ -289,35 +284,15 @@
var v1 = new Object; v1.x = s1.x-s2.x; v1.y = s1.y-s2.y;
var v2 = new Object; v2.x = e1.x-s2.x; v2.y = e1.y-s2.y;
var v3 = new Object; v3.x = e1.x-e2.x; v3.y = e1.y-e2.y;
- /*
if( (v1.x*v2.y - v1.y*v2.x)*(v2.x*v3.y - v2.y*v3.x) > 0 )
{
- e1 = vertices[ floorWalls[j].endVertex [1] ];
- e2 = vertices[ floorWalls[j].endVertex [0] ];
- /////
- lines[floorCount].push( Array(floorWalls[j].startVertex[0],floorWalls[j].endVertex[1]) );
- lines[floorCount].push( Array(floorWalls[j].start ,floorWalls[j].end , floorWalls[j].thickness, floorWalls[j].texture, floorWalls[j].holes) );
- lines[floorCount].push( Array(floorWalls[j].startVertex[1],floorWalls[j].endVertex[0]) );
- } else {
- lines[floorCount].push( Array(floorWalls[j].startVertex[0],floorWalls[j].endVertex[0]) );
- lines[floorCount].push( Array(floorWalls[j].start ,floorWalls[j].end , floorWalls[j].thickness, floorWalls[j].texture, floorWalls[j].holes) );
- lines[floorCount].push( Array(floorWalls[j].startVertex[1],floorWalls[j].endVertex[1]) );
+ e1 = vertices [ floorWalls[j].endVertex[1] ];
+ e2 = vertices [ floorWalls[j].endVertex[0] ];
}
- */
- //#######################################
- var s1 = vertices [ floorWalls[j].startVertex[0] ];
- var e1 = vertices [ floorWalls[j].endVertex[1] ];
var sm = floorNodes[ floorWalls[j].start ];
var em = floorNodes[ floorWalls[j].end ];
var sh = floorNodes[ floorWalls[j].start ].z ;
var eh = floorNodes[ floorWalls[j].end ].z ;
- var s2 = vertices [ floorWalls[j].startVertex[1] ];
- var e2 = vertices [ floorWalls[j].endVertex[0] ];
- if( (v1.x*v2.y - v1.y*v2.x)*(v2.x*v3.y - v2.y*v3.x) < 0 )
- {
- e1 = vertices [ floorWalls[j].endVertex[0] ];
- e2 = vertices [ floorWalls[j].endVertex[1] ];
- }
var wallSideOrder = (s2.x-s1.x)*(e1.y-s1.y) - (s2.y-s1.y)*(e1.x-s1.x);
var geometry = new THREE.Geometry();
@@ -364,8 +339,6 @@
geometry.computeFaceNormals();
var mesh = new THREE.Mesh(geometry, cubeMaterial);
wallGroup.add(mesh);
-
- //#######################################
} // end for( j=0; j<floorWalls.length; j++ )
Object3D.add( lineGroup );
Object3D.add( wallGroup );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-12 22:08:57
|
Revision: 573
http://openautomation.svn.sourceforge.net/openautomation/?rev=573&view=rev
Author: mayerch
Date: 2011-12-12 22:08:51 +0000 (Mon, 12 Dec 2011)
Log Message:
-----------
Fix wrong vertex order so that wall tops will seem solid again
Modified Paths:
--------------
JSFloorPlan/trunk/jsfloorplan.js
Modified: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-12 19:12:30 UTC (rev 572)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-12 22:08:51 UTC (rev 573)
@@ -299,10 +299,10 @@
//geometry.faceVertexUvs[0].push([
// new THREE.UV(u_value, v_value)), new THREE.UV(u_value, v_value)), new THREE.UV(u_value, v_value))
//]);
+ geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(s1.x,s1.y,heightOfGround )));
+ geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(s1.x,s1.y,heightOfGround + sh)));
geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(e1.x,e1.y,heightOfGround )));
geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(e1.x,e1.y,heightOfGround + sh)));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(s1.x,s1.y,heightOfGround )));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(s1.x,s1.y,heightOfGround + sh)));
geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(sm.x,sm.y,heightOfGround + sh)));
geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(s2.x,s2.y,heightOfGround )));
@@ -314,26 +314,26 @@
if( wallSideOrder < 0 )
{
// Add the wall sides
- geometry.faces.push(new THREE.Face3( 0, 1, 2 ));
- geometry.faces.push(new THREE.Face3( 3, 2, 1 ));
+ geometry.faces.push(new THREE.Face3( 2, 3, 0 ));
+ geometry.faces.push(new THREE.Face3( 1, 0, 3 ));
geometry.faces.push(new THREE.Face3( 5, 6, 7 ));
geometry.faces.push(new THREE.Face3( 8, 7, 6 ));
// Add the wall tops
- geometry.faces.push(new THREE.Face3( 4, 3, 6 ));
- geometry.faces.push(new THREE.Face3( 1, 6, 3 ));
- geometry.faces.push(new THREE.Face3( 6, 1, 8 ));
- geometry.faces.push(new THREE.Face3( 9, 8, 1 ));
+ geometry.faces.push(new THREE.Face3( 1, 6, 9 ));
+ geometry.faces.push(new THREE.Face3( 6, 1, 3 ));
+ geometry.faces.push(new THREE.Face3( 6, 3, 8 ));
+ geometry.faces.push(new THREE.Face3( 4, 8, 3 ));
} else {
// Add the wall sides
- geometry.faces.push(new THREE.Face3( 0, 2, 1 ));
- geometry.faces.push(new THREE.Face3( 3, 1, 2 ));
+ geometry.faces.push(new THREE.Face3( 2, 0, 3 ));
+ geometry.faces.push(new THREE.Face3( 1, 3, 0 ));
geometry.faces.push(new THREE.Face3( 5, 7, 6 ));
geometry.faces.push(new THREE.Face3( 8, 6, 7 ));
// Add the wall tops
- geometry.faces.push(new THREE.Face3( 4, 6, 3 ));
- geometry.faces.push(new THREE.Face3( 1, 3, 6 ));
- geometry.faces.push(new THREE.Face3( 6, 8, 1 ));
- geometry.faces.push(new THREE.Face3( 9, 1, 8 ));
+ geometry.faces.push(new THREE.Face3( 1, 9, 6 ));
+ geometry.faces.push(new THREE.Face3( 6, 3, 1 ));
+ geometry.faces.push(new THREE.Face3( 6, 8, 3 ));
+ geometry.faces.push(new THREE.Face3( 8, 4, 3 ));
}
geometry.computeFaceNormals();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-16 18:42:09
|
Revision: 579
http://openautomation.svn.sourceforge.net/openautomation/?rev=579&view=rev
Author: mayerch
Date: 2011-12-16 18:42:03 +0000 (Fri, 16 Dec 2011)
Log Message:
-----------
Initial support for shadows
Modified Paths:
--------------
JSFloorPlan/trunk/jsfloorplan.js
Modified: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-16 14:24:07 UTC (rev 578)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-16 18:42:03 UTC (rev 579)
@@ -422,6 +422,8 @@
//console.log(geometry, cubeMaterial);
geometry.computeFaceNormals();
var mesh = new THREE.Mesh(geometry, cubeMaterial);
+ mesh.castShadow = true;
+ mesh.receiveShadow = true;
wallGroup.add(mesh);
} // end for( j=0; j<floorWalls.length; j++ )
Object3D.add( lineGroup );
@@ -576,9 +578,10 @@
var showFloor = showStates.showFloor;
///////////
- scene.add(pointLight);
+ scene.add(sunLight);
+ //scene.add(pointLight);
scene.add(ambientLight);
- scene.add( camera );
+ //scene.add( camera );
var $container = $('#top_level');
// attach the render-supplied DOM element
$container.append(renderer.domElement);
@@ -598,11 +601,29 @@
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);
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.lookAt( new THREE.Vector3( buildingProperties.x_center, buildingProperties.y_center, heightOfGround) );
+ camera.lookAt( target );
pointLight.position = camera.position;
+ // set up sun
+ var sx = -Math.cos(lightDirection) * Math.cos(lightHeight);
+ var sy = Math.sin(lightDirection) * Math.cos(lightHeight);
+ var sz = Math.sin(lightHeight);
+ sunLight.target.position = target;
+ sunLight.position = new THREE.Vector3( sx * lightDistance, sy * lightDistance, sz * lightDistance );
+ sunLight.intensity = lightStrength / 100.0;
+ sunLightViewLine.geometry.vertices[0].position = sunLight.position;
+ sunLightViewLine.geometry.vertices[1].position = sunLight.target.position;
+ sunLightViewLine.geometry.__dirtyVertices = true;
+
+ if( showStates.showLightView )
+ {
+ camera.position = sunLight.position;
+ camera.lookAt( sunLight.target.position );
+ }
+
// update opacity
cubeMaterial.opacity = showStates.fillOpacity;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-16 23:02:57
|
Revision: 582
http://openautomation.svn.sourceforge.net/openautomation/?rev=582&view=rev
Author: mayerch
Date: 2011-12-16 23:02:51 +0000 (Fri, 16 Dec 2011)
Log Message:
-----------
Fix texture orientation (up<->down; left<->right)
Modified Paths:
--------------
JSFloorPlan/trunk/jsfloorplan.js
Modified: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-16 22:44:03 UTC (rev 581)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-16 23:02:51 UTC (rev 582)
@@ -395,16 +395,19 @@
//geometry.faces = Tfaces;
for( var f = 0; f < Tfaces.length; f++ )
{
- var uv_a = new THREE.UV( Tvertices[Tfaces[f].a].x, Tvertices[Tfaces[f].a].y );
- var uv_b = new THREE.UV( Tvertices[Tfaces[f].b].x, Tvertices[Tfaces[f].b].y );
- var uv_c = new THREE.UV( Tvertices[Tfaces[f].c].x, Tvertices[Tfaces[f].c].y );
+ var uv_a1 = new THREE.UV( Tvertices[Tfaces[f].a].x, 1-Tvertices[Tfaces[f].a].y );
+ var uv_b1 = new THREE.UV( Tvertices[Tfaces[f].b].x, 1-Tvertices[Tfaces[f].b].y );
+ var uv_c1 = new THREE.UV( Tvertices[Tfaces[f].c].x, 1-Tvertices[Tfaces[f].c].y );
+ var uv_a2 = new THREE.UV( 1-Tvertices[Tfaces[f].c].x, 1-Tvertices[Tfaces[f].c].y );
+ var uv_b2 = new THREE.UV( 1-Tvertices[Tfaces[f].b].x, 1-Tvertices[Tfaces[f].b].y );
+ var uv_c2 = new THREE.UV( 1-Tvertices[Tfaces[f].a].x, 1-Tvertices[Tfaces[f].a].y );
// wall side 1
geometry.faces.push( Tfaces[f] );
- geometry.faceVertexUvs[0].push([ uv_a, uv_b, uv_c ]);
+ geometry.faceVertexUvs[0].push([ uv_a1, uv_b1, uv_c1 ]);
// wall side 2
geometry.faces.push(new THREE.Face3(Tfaces[f].c+wall1verticesLength, Tfaces[f].b+wall1verticesLength, Tfaces[f].a+wall1verticesLength ) );
- geometry.faceVertexUvs[0].push([ uv_c, uv_b, uv_a ]);
+ geometry.faceVertexUvs[0].push([ uv_a2, uv_b2, uv_c2 ]);
}
// wall top
var mId = geometry.vertices.length;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-18 13:24:12
|
Revision: 587
http://openautomation.svn.sourceforge.net/openautomation/?rev=587&view=rev
Author: mayerch
Date: 2011-12-18 13:24:06 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
Prepare for later fix of holes
Modified Paths:
--------------
JSFloorPlan/trunk/jsfloorplan.js
Modified: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-18 13:23:11 UTC (rev 586)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-18 13:24:06 UTC (rev 587)
@@ -365,11 +365,23 @@
var sId, eId;
for( var v = 0; v < Tvertices.length; v++ )
{
+ /* prepare for later...
+ // project s1, e1 and s2, e2 onto line sm->em
+ var lSquaredInv = 1.0 / ((em.x-sm.x)*(em.x-sm.x) + (em.y-sm.y)*(em.y-sm.y));
+ var s1f = 1-((s1.x-sm.x)*(em.x-sm.x) + (s1.y-sm.y)*(em.y-sm.y))*lSquaredInv;
+ var e1f = 1-((e1.x-sm.x)*(em.x-sm.x) + (e1.y-sm.y)*(em.y-sm.y))*lSquaredInv;
+ var s2f = 1-((s2.x-sm.x)*(em.x-sm.x) + (s2.y-sm.y)*(em.y-sm.y))*lSquaredInv;
+ var e2f = 1-((e2.x-sm.x)*(em.x-sm.x) + (e2.y-sm.y)*(em.y-sm.y))*lSquaredInv;
+
var tv = Tvertices[v];
- var x1 = s1.x * tv.x + e1.x * (1 - tv.x);
- var x2 = s2.x * tv.x + e2.x * (1 - tv.x);
- var y1 = s1.y * tv.x + e1.y * (1 - tv.x);
- var y2 = s2.y * tv.x + e2.y * (1 - tv.x);
+ var tvx1 = Math.min( 1.0, Math.max( 0.0, (tv.x - s1f) * (e1f - s1f) ) ); // map between s1 and e1
+ var tvx2 = Math.min( 1.0, Math.max( 0.0, (tv.x - s2f) * (e2f - s2f) ) ); // map between s2 and e2
+ var x1 = s1.x * tvx1 + e1.x * (1 - tvx1);
+ var x2 = s2.x * tvx2 + e2.x * (1 - tvx2);
+ var y1 = s1.y * tvx1 + e1.y * (1 - tvx1);
+ var y2 = s2.y * tvx2 + e2.y * (1 - tvx2);
+ console.log( sm, em, s1, e1, tvx1, x1, y1, s2, e2, tvx2, x2, y2 );
+ */
var z = heightOfGround + sh*tv.y;
if( wallSideOrder > 0 )
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|