|
From: <ma...@us...> - 2011-12-09 10:31:57
|
Revision: 555
http://openautomation.svn.sourceforge.net/openautomation/?rev=555&view=rev
Author: mayerch
Date: 2011-12-09 10:31:43 +0000 (Fri, 09 Dec 2011)
Log Message:
-----------
Move from old SVG implementation to WebGL using Three.js. Also moving towards jQuery to make things easier.
This is still much work in progress and the first working version. It's still needing lots of polishing to reach a similar state it was before with the SVG implementation.
Modified Paths:
--------------
JSFloorPlan/trunk/index.html
JSFloorPlan/trunk/jsfloorplan.js
JSFloorPlan/trunk/jsfloorplan_example_helper.js
Added Paths:
-----------
JSFloorPlan/trunk/css/
JSFloorPlan/trunk/css/ui-lightness/
JSFloorPlan/trunk/css/ui-lightness/images/
JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png
JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png
JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png
JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png
JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png
JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png
JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png
JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png
JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png
JSFloorPlan/trunk/css/ui-lightness/images/ui-icons_222222_256x240.png
JSFloorPlan/trunk/css/ui-lightness/images/ui-icons_228ef1_256x240.png
JSFloorPlan/trunk/css/ui-lightness/images/ui-icons_ef8c08_256x240.png
JSFloorPlan/trunk/css/ui-lightness/images/ui-icons_ffd27a_256x240.png
JSFloorPlan/trunk/css/ui-lightness/images/ui-icons_ffffff_256x240.png
JSFloorPlan/trunk/css/ui-lightness/jquery-ui-1.8.16.custom.css
JSFloorPlan/trunk/lib/
JSFloorPlan/trunk/lib/Three.js
JSFloorPlan/trunk/lib/jquery-1.7.1.min.js
JSFloorPlan/trunk/lib/jquery-ui-1.8.16.custom.min.js
Added: JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png
===================================================================
(Binary files differ)
Property changes on: JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png
===================================================================
(Binary files differ)
Property changes on: JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png
===================================================================
(Binary files differ)
Property changes on: JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png
===================================================================
(Binary files differ)
Property changes on: JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png
===================================================================
(Binary files differ)
Property changes on: JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png
===================================================================
(Binary files differ)
Property changes on: JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png
===================================================================
(Binary files differ)
Property changes on: JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png
===================================================================
(Binary files differ)
Property changes on: JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png
===================================================================
(Binary files differ)
Property changes on: JSFloorPlan/trunk/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: JSFloorPlan/trunk/css/ui-lightness/images/ui-icons_222222_256x240.png
===================================================================
(Binary files differ)
Property changes on: JSFloorPlan/trunk/css/ui-lightness/images/ui-icons_222222_256x240.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: JSFloorPlan/trunk/css/ui-lightness/images/ui-icons_228ef1_256x240.png
===================================================================
(Binary files differ)
Property changes on: JSFloorPlan/trunk/css/ui-lightness/images/ui-icons_228ef1_256x240.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: JSFloorPlan/trunk/css/ui-lightness/images/ui-icons_ef8c08_256x240.png
===================================================================
(Binary files differ)
Property changes on: JSFloorPlan/trunk/css/ui-lightness/images/ui-icons_ef8c08_256x240.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: JSFloorPlan/trunk/css/ui-lightness/images/ui-icons_ffd27a_256x240.png
===================================================================
(Binary files differ)
Property changes on: JSFloorPlan/trunk/css/ui-lightness/images/ui-icons_ffd27a_256x240.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: JSFloorPlan/trunk/css/ui-lightness/images/ui-icons_ffffff_256x240.png
===================================================================
(Binary files differ)
Property changes on: JSFloorPlan/trunk/css/ui-lightness/images/ui-icons_ffffff_256x240.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: JSFloorPlan/trunk/css/ui-lightness/jquery-ui-1.8.16.custom.css
===================================================================
--- JSFloorPlan/trunk/css/ui-lightness/jquery-ui-1.8.16.custom.css (rev 0)
+++ JSFloorPlan/trunk/css/ui-lightness/jquery-ui-1.8.16.custom.css 2011-12-09 10:31:43 UTC (rev 555)
@@ -0,0 +1,568 @@
+/*
+ * jQuery UI CSS Framework 1.8.16
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Theming/API
+ */
+
+/* Layout helpers
+----------------------------------*/
+.ui-helper-hidden { display: none; }
+.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); }
+.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
+.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
+.ui-helper-clearfix { display: inline-block; }
+/* required comment for clearfix to work in Opera \*/
+* html .ui-helper-clearfix { height:1%; }
+.ui-helper-clearfix { display:block; }
+/* end clearfix */
+.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }
+
+
+/* Interaction Cues
+----------------------------------*/
+.ui-state-disabled { cursor: default !important; }
+
+
+/* Icons
+----------------------------------*/
+
+/* states and images */
+.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }
+
+
+/* Misc visuals
+----------------------------------*/
+
+/* Overlays */
+.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
+
+
+/*
+ * jQuery UI CSS Framework 1.8.16
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Theming/API
+ *
+ * To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Trebuchet%20MS,%20Tahoma,%20Verdana,%20Arial,%20sans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=f6a828&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=35&borderColorHeader=e78f08&fcHeader=ffffff&iconColorHeader=ffffff&bgColorContent=eeeeee&bgTextureContent=03_highlight_soft.png&bgImgOpacityContent=100&borderColorContent=dddddd&fcContent=333333&iconColorContent=222222&bgColorDefault=f6f6f6&bgTextureDefault=02_glass.png&bgImgOpacityDefault=100&borderColorDefault=cccccc&fcDefault=1c94c4&iconColorDefault=ef8c08&bgColorHover=fdf5ce&bgTextureHover=02_glass.png&bgImgOpacityHover=100&borderColorHover=fbcb09&fcHover=c77405&iconColorHover=ef8c08&bgColorActive=ffffff&bgTextureActive=02_glass.png&bgImgOpacityActive=65&borderColorActive=fbd850&fcActive=eb8f00&iconColorActive=ef8c08&bgColorHighlight=ffe45c&bgTextureHighlight=03_highlight_soft.png&bgImgOpacityHighlight=75&borderColorHighlight=fed22f&fcHighlight=363636&iconColorHighlight=228ef1&bgColorError=b81900&bgTextureError=08_diagonals_thick.png&bgImgOpacityError=18&borderColorError=cd0a0a&fcError=ffffff&iconColorError=ffd27a&bgColorOverlay=666666&bgTextureOverlay=08_diagonals_thick.png&bgImgOpacityOverlay=20&opacityOverlay=50&bgColorShadow=000000&bgTextureShadow=01_flat.png&bgImgOpacityShadow=10&opacityShadow=20&thicknessShadow=5px&offsetTopShadow=-5px&offsetLeftShadow=-5px&cornerRadiusShadow=5px
+ */
+
+
+/* Component containers
+----------------------------------*/
+.ui-widget { font-family: Trebuchet MS, Tahoma, Verdana, Arial, sans-serif; font-size: 1.1em; }
+.ui-widget .ui-widget { font-size: 1em; }
+.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Trebuchet MS, Tahoma, Verdana, Arial, sans-serif; font-size: 1em; }
+.ui-widget-content { border: 1px solid #dddddd; background: #eeeeee url(images/ui-bg_highlight-soft_100_eeeeee_1x100.png) 50% top repeat-x; color: #333333; }
+.ui-widget-content a { color: #333333; }
+.ui-widget-header { border: 1px solid #e78f08; background: #f6a828 url(images/ui-bg_gloss-wave_35_f6a828_500x100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; }
+.ui-widget-header a { color: #ffffff; }
+
+/* Interaction states
+----------------------------------*/
+.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #cccccc; background: #f6f6f6 url(images/ui-bg_glass_100_f6f6f6_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #1c94c4; }
+.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #1c94c4; text-decoration: none; }
+.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #fbcb09; background: #fdf5ce url(images/ui-bg_glass_100_fdf5ce_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #c77405; }
+.ui-state-hover a, .ui-state-hover a:hover { color: #c77405; text-decoration: none; }
+.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #fbd850; background: #ffffff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #eb8f00; }
+.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #eb8f00; text-decoration: none; }
+.ui-widget :active { outline: none; }
+
+/* Interaction Cues
+----------------------------------*/
+.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fed22f; background: #ffe45c url(images/ui-bg_highlight-soft_75_ffe45c_1x100.png) 50% top repeat-x; color: #363636; }
+.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636; }
+.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a; background: #b81900 url(images/ui-bg_diagonals-thick_18_b81900_40x40.png) 50% 50% repeat; color: #ffffff; }
+.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #ffffff; }
+.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #ffffff; }
+.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; }
+.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; }
+.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; }
+
+/* Icons
+----------------------------------*/
+
+/* states and images */
+.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png); }
+.ui-widget-content .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
+.ui-widget-header .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); }
+.ui-state-default .ui-icon { background-image: url(images/ui-icons_ef8c08_256x240.png); }
+.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_ef8c08_256x240.png); }
+.ui-state-active .ui-icon {background-image: url(images/ui-icons_ef8c08_256x240.png); }
+.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_228ef1_256x240.png); }
+.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_ffd27a_256x240.png); }
+
+/* positioning */
+.ui-icon-carat-1-n { background-position: 0 0; }
+.ui-icon-carat-1-ne { background-position: -16px 0; }
+.ui-icon-carat-1-e { background-position: -32px 0; }
+.ui-icon-carat-1-se { background-position: -48px 0; }
+.ui-icon-carat-1-s { background-position: -64px 0; }
+.ui-icon-carat-1-sw { background-position: -80px 0; }
+.ui-icon-carat-1-w { background-position: -96px 0; }
+.ui-icon-carat-1-nw { background-position: -112px 0; }
+.ui-icon-carat-2-n-s { background-position: -128px 0; }
+.ui-icon-carat-2-e-w { background-position: -144px 0; }
+.ui-icon-triangle-1-n { background-position: 0 -16px; }
+.ui-icon-triangle-1-ne { background-position: -16px -16px; }
+.ui-icon-triangle-1-e { background-position: -32px -16px; }
+.ui-icon-triangle-1-se { background-position: -48px -16px; }
+.ui-icon-triangle-1-s { background-position: -64px -16px; }
+.ui-icon-triangle-1-sw { background-position: -80px -16px; }
+.ui-icon-triangle-1-w { background-position: -96px -16px; }
+.ui-icon-triangle-1-nw { background-position: -112px -16px; }
+.ui-icon-triangle-2-n-s { background-position: -128px -16px; }
+.ui-icon-triangle-2-e-w { background-position: -144px -16px; }
+.ui-icon-arrow-1-n { background-position: 0 -32px; }
+.ui-icon-arrow-1-ne { background-position: -16px -32px; }
+.ui-icon-arrow-1-e { background-position: -32px -32px; }
+.ui-icon-arrow-1-se { background-position: -48px -32px; }
+.ui-icon-arrow-1-s { background-position: -64px -32px; }
+.ui-icon-arrow-1-sw { background-position: -80px -32px; }
+.ui-icon-arrow-1-w { background-position: -96px -32px; }
+.ui-icon-arrow-1-nw { background-position: -112px -32px; }
+.ui-icon-arrow-2-n-s { background-position: -128px -32px; }
+.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; }
+.ui-icon-arrow-2-e-w { background-position: -160px -32px; }
+.ui-icon-arrow-2-se-nw { background-position: -176px -32px; }
+.ui-icon-arrowstop-1-n { background-position: -192px -32px; }
+.ui-icon-arrowstop-1-e { background-position: -208px -32px; }
+.ui-icon-arrowstop-1-s { background-position: -224px -32px; }
+.ui-icon-arrowstop-1-w { background-position: -240px -32px; }
+.ui-icon-arrowthick-1-n { background-position: 0 -48px; }
+.ui-icon-arrowthick-1-ne { background-position: -16px -48px; }
+.ui-icon-arrowthick-1-e { background-position: -32px -48px; }
+.ui-icon-arrowthick-1-se { background-position: -48px -48px; }
+.ui-icon-arrowthick-1-s { background-position: -64px -48px; }
+.ui-icon-arrowthick-1-sw { background-position: -80px -48px; }
+.ui-icon-arrowthick-1-w { background-position: -96px -48px; }
+.ui-icon-arrowthick-1-nw { background-position: -112px -48px; }
+.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; }
+.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; }
+.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; }
+.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; }
+.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; }
+.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; }
+.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; }
+.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; }
+.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; }
+.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; }
+.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; }
+.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; }
+.ui-icon-arrowreturn-1-w { background-position: -64px -64px; }
+.ui-icon-arrowreturn-1-n { background-position: -80px -64px; }
+.ui-icon-arrowreturn-1-e { background-position: -96px -64px; }
+.ui-icon-arrowreturn-1-s { background-position: -112px -64px; }
+.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; }
+.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; }
+.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; }
+.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; }
+.ui-icon-arrow-4 { background-position: 0 -80px; }
+.ui-icon-arrow-4-diag { background-position: -16px -80px; }
+.ui-icon-extlink { background-position: -32px -80px; }
+.ui-icon-newwin { background-position: -48px -80px; }
+.ui-icon-refresh { background-position: -64px -80px; }
+.ui-icon-shuffle { background-position: -80px -80px; }
+.ui-icon-transfer-e-w { background-position: -96px -80px; }
+.ui-icon-transferthick-e-w { background-position: -112px -80px; }
+.ui-icon-folder-collapsed { background-position: 0 -96px; }
+.ui-icon-folder-open { background-position: -16px -96px; }
+.ui-icon-document { background-position: -32px -96px; }
+.ui-icon-document-b { background-position: -48px -96px; }
+.ui-icon-note { background-position: -64px -96px; }
+.ui-icon-mail-closed { background-position: -80px -96px; }
+.ui-icon-mail-open { background-position: -96px -96px; }
+.ui-icon-suitcase { background-position: -112px -96px; }
+.ui-icon-comment { background-position: -128px -96px; }
+.ui-icon-person { background-position: -144px -96px; }
+.ui-icon-print { background-position: -160px -96px; }
+.ui-icon-trash { background-position: -176px -96px; }
+.ui-icon-locked { background-position: -192px -96px; }
+.ui-icon-unlocked { background-position: -208px -96px; }
+.ui-icon-bookmark { background-position: -224px -96px; }
+.ui-icon-tag { background-position: -240px -96px; }
+.ui-icon-home { background-position: 0 -112px; }
+.ui-icon-flag { background-position: -16px -112px; }
+.ui-icon-calendar { background-position: -32px -112px; }
+.ui-icon-cart { background-position: -48px -112px; }
+.ui-icon-pencil { background-position: -64px -112px; }
+.ui-icon-clock { background-position: -80px -112px; }
+.ui-icon-disk { background-position: -96px -112px; }
+.ui-icon-calculator { background-position: -112px -112px; }
+.ui-icon-zoomin { background-position: -128px -112px; }
+.ui-icon-zoomout { background-position: -144px -112px; }
+.ui-icon-search { background-position: -160px -112px; }
+.ui-icon-wrench { background-position: -176px -112px; }
+.ui-icon-gear { background-position: -192px -112px; }
+.ui-icon-heart { background-position: -208px -112px; }
+.ui-icon-star { background-position: -224px -112px; }
+.ui-icon-link { background-position: -240px -112px; }
+.ui-icon-cancel { background-position: 0 -128px; }
+.ui-icon-plus { background-position: -16px -128px; }
+.ui-icon-plusthick { background-position: -32px -128px; }
+.ui-icon-minus { background-position: -48px -128px; }
+.ui-icon-minusthick { background-position: -64px -128px; }
+.ui-icon-close { background-position: -80px -128px; }
+.ui-icon-closethick { background-position: -96px -128px; }
+.ui-icon-key { background-position: -112px -128px; }
+.ui-icon-lightbulb { background-position: -128px -128px; }
+.ui-icon-scissors { background-position: -144px -128px; }
+.ui-icon-clipboard { background-position: -160px -128px; }
+.ui-icon-copy { background-position: -176px -128px; }
+.ui-icon-contact { background-position: -192px -128px; }
+.ui-icon-image { background-position: -208px -128px; }
+.ui-icon-video { background-position: -224px -128px; }
+.ui-icon-script { background-position: -240px -128px; }
+.ui-icon-alert { background-position: 0 -144px; }
+.ui-icon-info { background-position: -16px -144px; }
+.ui-icon-notice { background-position: -32px -144px; }
+.ui-icon-help { background-position: -48px -144px; }
+.ui-icon-check { background-position: -64px -144px; }
+.ui-icon-bullet { background-position: -80px -144px; }
+.ui-icon-radio-off { background-position: -96px -144px; }
+.ui-icon-radio-on { background-position: -112px -144px; }
+.ui-icon-pin-w { background-position: -128px -144px; }
+.ui-icon-pin-s { background-position: -144px -144px; }
+.ui-icon-play { background-position: 0 -160px; }
+.ui-icon-pause { background-position: -16px -160px; }
+.ui-icon-seek-next { background-position: -32px -160px; }
+.ui-icon-seek-prev { background-position: -48px -160px; }
+.ui-icon-seek-end { background-position: -64px -160px; }
+.ui-icon-seek-start { background-position: -80px -160px; }
+/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */
+.ui-icon-seek-first { background-position: -80px -160px; }
+.ui-icon-stop { background-position: -96px -160px; }
+.ui-icon-eject { background-position: -112px -160px; }
+.ui-icon-volume-off { background-position: -128px -160px; }
+.ui-icon-volume-on { background-position: -144px -160px; }
+.ui-icon-power { background-position: 0 -176px; }
+.ui-icon-signal-diag { background-position: -16px -176px; }
+.ui-icon-signal { background-position: -32px -176px; }
+.ui-icon-battery-0 { background-position: -48px -176px; }
+.ui-icon-battery-1 { background-position: -64px -176px; }
+.ui-icon-battery-2 { background-position: -80px -176px; }
+.ui-icon-battery-3 { background-position: -96px -176px; }
+.ui-icon-circle-plus { background-position: 0 -192px; }
+.ui-icon-circle-minus { background-position: -16px -192px; }
+.ui-icon-circle-close { background-position: -32px -192px; }
+.ui-icon-circle-triangle-e { background-position: -48px -192px; }
+.ui-icon-circle-triangle-s { background-position: -64px -192px; }
+.ui-icon-circle-triangle-w { background-position: -80px -192px; }
+.ui-icon-circle-triangle-n { background-position: -96px -192px; }
+.ui-icon-circle-arrow-e { background-position: -112px -192px; }
+.ui-icon-circle-arrow-s { background-position: -128px -192px; }
+.ui-icon-circle-arrow-w { background-position: -144px -192px; }
+.ui-icon-circle-arrow-n { background-position: -160px -192px; }
+.ui-icon-circle-zoomin { background-position: -176px -192px; }
+.ui-icon-circle-zoomout { background-position: -192px -192px; }
+.ui-icon-circle-check { background-position: -208px -192px; }
+.ui-icon-circlesmall-plus { background-position: 0 -208px; }
+.ui-icon-circlesmall-minus { background-position: -16px -208px; }
+.ui-icon-circlesmall-close { background-position: -32px -208px; }
+.ui-icon-squaresmall-plus { background-position: -48px -208px; }
+.ui-icon-squaresmall-minus { background-position: -64px -208px; }
+.ui-icon-squaresmall-close { background-position: -80px -208px; }
+.ui-icon-grip-dotted-vertical { background-position: 0 -224px; }
+.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; }
+.ui-icon-grip-solid-vertical { background-position: -32px -224px; }
+.ui-icon-grip-solid-horizontal { background-position: -48px -224px; }
+.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
+.ui-icon-grip-diagonal-se { background-position: -80px -224px; }
+
+
+/* Misc visuals
+----------------------------------*/
+
+/* Corner radius */
+.ui-corner-all, .ui-corner-top, .ui-corner-left, .ui-corner-tl { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; -khtml-border-top-left-radius: 4px; border-top-left-radius: 4px; }
+.ui-corner-all, .ui-corner-top, .ui-corner-right, .ui-corner-tr { -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; -khtml-border-top-right-radius: 4px; border-top-right-radius: 4px; }
+.ui-corner-all, .ui-corner-bottom, .ui-corner-left, .ui-corner-bl { -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; -khtml-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; }
+.ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br { -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; -khtml-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; }
+
+/* Overlays */
+.ui-widget-overlay { background: #666666 url(images/ui-bg_diagonals-thick_20_666666_40x40.png) 50% 50% repeat; opacity: .50;filter:Alpha(Opacity=50); }
+.ui-widget-shadow { margin: -5px 0 0 -5px; padding: 5px; background: #000000 url(images/ui-bg_flat_10_000000_40x100.png) 50% 50% repeat-x; opacity: .20;filter:Alpha(Opacity=20); -moz-border-radius: 5px; -khtml-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; }/*
+ * jQuery UI Resizable 1.8.16
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Resizable#theming
+ */
+.ui-resizable { position: relative;}
+.ui-resizable-handle { position: absolute;font-size: 0.1px;z-index: 99999; display: block; }
+.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; }
+.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; }
+.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; }
+.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; }
+.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; }
+.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; }
+.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; }
+.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; }
+.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}/*
+ * jQuery UI Selectable 1.8.16
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Selectable#theming
+ */
+.ui-selectable-helper { position: absolute; z-index: 100; border:1px dotted black; }
+/*
+ * jQuery UI Accordion 1.8.16
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Accordion#theming
+ */
+/* IE/Win - Fix animation bug - #4615 */
+.ui-accordion { width: 100%; }
+.ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 1px; zoom: 1; }
+.ui-accordion .ui-accordion-li-fix { display: inline; }
+.ui-accordion .ui-accordion-header-active { border-bottom: 0 !important; }
+.ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em .7em; }
+.ui-accordion-icons .ui-accordion-header a { padding-left: 2.2em; }
+.ui-accordion .ui-accordion-header .ui-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; }
+.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; margin-top: -2px; position: relative; top: 1px; margin-bottom: 2px; overflow: auto; display: none; zoom: 1; }
+.ui-accordion .ui-accordion-content-active { display: block; }
+/*
+ * jQuery UI Autocomplete 1.8.16
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Autocomplete#theming
+ */
+.ui-autocomplete { position: absolute; cursor: default; }
+
+/* workarounds */
+* html .ui-autocomplete { width:1px; } /* without this, the menu expa...
[truncated message content] |
|
From: <ma...@us...> - 2011-12-09 12:49:30
|
Revision: 557
http://openautomation.svn.sourceforge.net/openautomation/?rev=557&view=rev
Author: mayerch
Date: 2011-12-09 12:49:24 +0000 (Fri, 09 Dec 2011)
Log Message:
-----------
Fix UI (but it's not linked to the display yet...)
Modified Paths:
--------------
JSFloorPlan/trunk/index.html
JSFloorPlan/trunk/jsfloorplan.js
JSFloorPlan/trunk/jsfloorplan_example_helper.js
Modified: JSFloorPlan/trunk/index.html
===================================================================
--- JSFloorPlan/trunk/index.html 2011-12-09 10:36:54 UTC (rev 556)
+++ JSFloorPlan/trunk/index.html 2011-12-09 12:49:24 UTC (rev 557)
@@ -49,7 +49,7 @@
</pre>
<hr />
<h2>Einstellungen:</h2>
-<form name="settings" method="get">
+<form>
<table>
<tr>
<td>
@@ -59,31 +59,31 @@
</tr>
<tr>
<td>
- Zeige Wände: <input type="checkbox" name="showWallSides" onclick="check('showWallSides',true)" checked="checked" />
+ Zeige Wände: <input type="checkbox" name="showWallSides" checked="checked" />
</td><td>
- Zeige Deckel: <input type="checkbox" name="showWallTop" onclick="check('showWallTop',true)" checked="checked" />
+ Zeige Deckel: <input type="checkbox" name="showWallTop" checked="checked" />
</td><td>
- Zeige Rückseite: <input type="checkbox" name="showBackside" onclick="check('showBackside',true)" checked="checked" />
+ Zeige Rückseite: <input type="checkbox" name="showBackside" checked="checked" />
</td><td>
- Zeige MouseOver: <input type="checkbox" name="wallMouseOver" onclick="check('wallMouseOver',true)" />
+ Zeige MouseOver: <input type="checkbox" name="wallMouseOver" />
</td>
</tr>
<tr>
<td>
- Wand-Umrandung: <input type="checkbox" name="showSideLines" onclick="check('showSideLines',true)" checked="checked" />
+ Wand-Umrandung: <input type="checkbox" name="showSideLines" checked="checked" />
</td><td>
- Deckel-Umrandung: <input type="checkbox" name="showTopLines" onclick="check('showTopLines',true)" checked="checked" />
+ Deckel-Umrandung: <input type="checkbox" name="showTopLines" checked="checked" />
</td><td>
- Zeige "Löcher": <input type="checkbox" name="showHoles" onclick="check('showHoles',true)" checked="checked" />
+ Zeige "Löcher": <input type="checkbox" name="showHoles" checked="checked" />
</td><td>
- Erzeuge Zonen: <input type="checkbox" name="showZones" onclick="check('showZones',true)" checked="checked" />
+ Erzeuge Zonen: <input type="checkbox" name="showZones" checked="checked" />
</td><td>
- Zeige Zonen: <input type="checkbox" name="showVisibleZones" onclick="check('showVisibleZones',true)" checked="checked" />
+ Zeige Zonen: <input type="checkbox" name="showVisibleZones" checked="checked" />
</td>
</tr>
<tr>
<td>
- Transparenz: <select size="1" name="fillOpacity" onchange="selectValue('fillOpacity',true)">
+ Transparenz: <select size="1" name="fillOpacity">
<option value="0.1">0.1 - sehr transparent</option>
<option value="0.2">0.2</option>
<option value="0.3">0.3</option>
@@ -96,7 +96,7 @@
<option value="1.0">1.0 - undurchsichtig</option>
</select>
</td><td>
- Farbe: <select size="1" name="fillColor" onchange="selectValue('fillColor',true)">
+ Farbe: <select size="1" name="fillColor">
<option value="black" selected="selected">Schwarz</option>
<option value="grey">Grau</option>
<option value="white">Weiß</option>
@@ -105,7 +105,7 @@
<option value="green">Grün</option>
</select>
</td><td>
- Stockwerk: <select size="1" name="showFloor" onchange="selectValue('showFloor',true)">
+ Stockwerk: <select size="1" name="showFloor">
<option value="0" selected="selected">0</option>
<option value="1">1</option>
</select>
Modified: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-09 10:36:54 UTC (rev 556)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-09 12:49:24 UTC (rev 557)
@@ -77,6 +77,7 @@
/*******************************************************************/
/* IE compatability stuff starts here */
/*******************************************************************/
+/*
// Fix problems of IE that it doesn't support the
// createElementNS method
function createSVGElement( element )
@@ -93,6 +94,7 @@
{
return element.setAttributeNS( XLINK_NS, attribute, value );
}
+*/
/*******************************************************************/
/* IE compatability stuff ends here */
@@ -120,7 +122,7 @@
noFloorplan = false;
// create the SVG node where all elements are collected in
//var plan = document.createElementNS( SVG_NS, "g" );
- var plan = createSVGElement( "g" );
+ //var plan = createSVGElement( "g" );
// basic check if the document seems right
// this could be avoided if the XML file would be validated
@@ -310,7 +312,7 @@
imageCenter.y = buildingProperties.y_center;
imageCenter.z = buildingProperties.z_max / 2;
- show3D( 35*Math.PI/180, 30*Math.PI/180, plan );
+ show3D( 35*Math.PI/180, 30*Math.PI/180 );
//document.getElementById( "top_level" ).appendChild( plan );
}
@@ -458,6 +460,7 @@
document.getElementById( "top_level" ).appendChild( defs );
}
+/*
//var wrapper = document.createElementNS( SVG_NS, "g" );
var wrapper = createSVGElement( "g" );
wrapper.setAttribute( "fill", fillColor );
@@ -474,6 +477,7 @@
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
@@ -736,6 +740,7 @@
////t_25d_end = new Date;
}
+/*
plan = createSVGElement( "g" );
function replaceSVG( SVGelement )
{
@@ -743,6 +748,7 @@
delete plan;
plan = createSVGElement( "g" );
}
+*/
var noSetup = true;
function setup3D()
@@ -750,6 +756,8 @@
if( noFloorplan ) return;
noSetup = false;
+ var showFloor = showStates.showFloor;
+
for( var i=0; i<lines[showFloor].length; )
{
//console.log(i);
@@ -878,7 +886,7 @@
}
-function show3D( rotation, tilt, plan )
+function show3D( rotation, tilt )
{
if( noSetup ) setup3D();
Modified: JSFloorPlan/trunk/jsfloorplan_example_helper.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan_example_helper.js 2011-12-09 10:36:54 UTC (rev 556)
+++ JSFloorPlan/trunk/jsfloorplan_example_helper.js 2011-12-09 12:49:24 UTC (rev 557)
@@ -57,6 +57,7 @@
ASPECT,
NEAR,
FAR );
+/*
var controls = new THREE.TrackballControls( camera );
//controls.rotateSpeed = 1.0;
//controls.zoomSpeed = 1.2;
@@ -69,7 +70,7 @@
controls.dynamicDampingFactor = 0.3;
controls.keys = [ 65, 83, 68 ];
-
+*/
var scene = new THREE.Scene();
// the camera starts at 0,0,0 so pull it back
@@ -145,7 +146,7 @@
function animate() {
requestAnimationFrame( animate );
//render();
- show3D();
+ show3D( roll, tilt );
//stats.update();
}
@@ -163,6 +164,8 @@
/////////////////////////////////////////////////////////////////////////////
// setup script here:
var sc = 40; // overall scaling
+var showStates = {};
+/*
var showWallSides = true;
var showWallTop = true;
var showSideLines = true;
@@ -175,6 +178,7 @@
var wallMouseOver = true;
var fillOpacity = 0.5;
var fillColor = 'black';
+*/
var redrawInterval = 50; // in milliseconds; = 20 fps
var roll = 35*Math.PI/180;
@@ -194,21 +198,20 @@
function init()
{
- check( 'showWallSides' , false );
- check( 'showWallTop' , false );
- check( 'showSideLines' , false );
- check( 'showTopLines' , false );
- check( 'showBackside' , false );
- check( 'showHoles' , false );
- check( 'showZones' , false );
- check( 'showVisibleZones' , false );
- check( 'wallMouseOver' , false );
- selectValue( 'fillOpacity', false );
- selectValue( 'fillColor' , false );
- selectValue( 'showFloor' , false );
-
+ $('input').change(function(e){
+ showStates[ e.target.name ] = e.target.checked;
+ show3D( roll, tilt );
+ }).each(function(){
+ showStates[ this.name ] = this.checked; // init
+ });
+ $('select').change(function(e){
+ showStates[ e.target.name ] = e.target.value;
+ show3D( roll, tilt );
+ }).each(function(){
+ showStates[ this.name ] = this.value; // init
+ });
+
loadFloorplan();
-
createSlider();
}
@@ -224,6 +227,7 @@
animation = setInterval(move, redrawInterval);
toggle = true;
}
+ return true;
}
function move()
@@ -239,7 +243,7 @@
if( tilt < 0 )
tilt_dir = 1;
- show3D( roll, tilt, plan );
+ show3D( roll, tilt );
//////
var middle = new Date();
@@ -285,6 +289,7 @@
document.getElementById('status').firstChild.data = text;
}
+/*
function set_color( event )
{
if( 'blue' != fillColor )
@@ -297,7 +302,8 @@
{
event.setAttribute( 'fill', fillColor );
}
-
+*/
+/*
function check( what, redraw )
{
eval( what +' = document.forms[0].elements[what].checked' );
@@ -321,7 +327,9 @@
show3D( roll, tilt, plan );
}
}
+*/
+/*
function selectValue( what, redraw )
{
var val = document.forms[0].elements[what].options[ document.forms[0].elements[what].selectedIndex ].value;
@@ -343,6 +351,7 @@
show3D( roll, tilt, plan );
}
}
+*/
// Create the little graphics for the roll and the tilt angle
// as well as the buttons to manipulate them
@@ -350,7 +359,7 @@
{
$( "#rollSlider" ).slider({ min: 0, max: 360, change: rollChange, slide: rollChange});
$( "#tiltSlider" ).slider({ min: 0, max: 90, change: tiltChange, slide: tiltChange});
- $( "#distSlider" ).slider({ min: 5, max: 30, change: distChange, slide: distChange});
+ $( "#distSlider" ).slider({ min: 5, max: 30, change: distChange, slide: distChange});
updateSlider();
}
@@ -368,21 +377,21 @@
function rollChange( event, ui )
{
- if( globalInUpdateSlider ) return;
+ if( globalInUpdateSlider ) return true;
roll = ui.value * Math.PI / 180;
- show3D( roll, tilt, plan );
+ show3D( roll, tilt );
}
function tiltChange( event, ui )
{
- if( globalInUpdateSlider ) return;
+ if( globalInUpdateSlider ) return true;
tilt = ui.value * Math.PI / 180;
- show3D( roll, tilt, plan );
+ show3D( roll, tilt );
}
function distChange( event, ui )
{
- if( globalInUpdateSlider ) return;
+ if( globalInUpdateSlider ) return true;
dist = ui.value;
- show3D( roll, tilt, plan );
+ show3D( roll, tilt );
}
\ 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 16:48:39
|
Revision: 559
http://openautomation.svn.sourceforge.net/openautomation/?rev=559&view=rev
Author: mayerch
Date: 2011-12-09 16:48:33 +0000 (Fri, 09 Dec 2011)
Log Message:
-----------
Make opacity and color selector work (again)
Modified Paths:
--------------
JSFloorPlan/trunk/index.html
JSFloorPlan/trunk/jsfloorplan.js
Modified: JSFloorPlan/trunk/index.html
===================================================================
--- JSFloorPlan/trunk/index.html 2011-12-09 15:37:02 UTC (rev 558)
+++ JSFloorPlan/trunk/index.html 2011-12-09 16:48:33 UTC (rev 559)
@@ -88,17 +88,17 @@
<option value="0.2">0.2</option>
<option value="0.3">0.3</option>
<option value="0.4">0.4</option>
-<option value="0.5" selected="selected">0.5 - halb transparent</option>
+<option value="0.5">0.5 - halb transparent</option>
<option value="0.6">0.6</option>
<option value="0.7">0.7</option>
<option value="0.8">0.8</option>
<option value="0.9">0.9</option>
-<option value="1.0">1.0 - undurchsichtig</option>
+<option value="1.0" selected="selected">1.0 - undurchsichtig</option>
</select>
</td><td>
Farbe: <select size="1" name="fillColor">
-<option value="black" selected="selected">Schwarz</option>
-<option value="grey">Grau</option>
+<option value="black">Schwarz</option>
+<option value="grey" selected="selected">Grau</option>
<option value="white">Weiß</option>
<option value="blue">Blau</option>
<option value="red">Rot</option>
Modified: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-09 15:37:02 UTC (rev 558)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-09 16:48:33 UTC (rev 559)
@@ -890,6 +890,7 @@
{
if( noSetup ) setup3D();
+ // set up camera
var cx = -Math.cos(rotation) * Math.cos(tilt);
var cy = Math.sin(rotation) * Math.cos(tilt);
var cz = Math.sin(tilt);
@@ -897,5 +898,33 @@
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;
+
+ // update opacity
+ cubeMaterial.opacity = showStates.fillOpacity;
+
+ // update color
+ switch( showStates.fillColor )
+ {
+ case 'black':
+ cubeMaterial.color.setRGB( 0.1, 0.1, 0.1 );
+ break;
+ case 'grey':
+ cubeMaterial.color.setRGB( 0.5, 0.5, 0.5 );
+ break;
+ case 'white':
+ cubeMaterial.color.setRGB( 1.0, 1.0, 1.0 );
+ break;
+ case 'blue':
+ cubeMaterial.color.setRGB( 0.0, 0.0, 0.8 );
+ break;
+ case 'red':
+ cubeMaterial.color.setRGB( 0.8, 0.0, 0.0 );
+ break;
+ case 'green':
+ cubeMaterial.color.setRGB( 0.0, 0.8, 0.0 );
+ 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 21:09:00
|
Revision: 561
http://openautomation.svn.sourceforge.net/openautomation/?rev=561&view=rev
Author: mayerch
Date: 2011-12-09 21:08:54 +0000 (Fri, 09 Dec 2011)
Log Message:
-----------
Add check boxes to show nodes and/or wall lines
Modified Paths:
--------------
JSFloorPlan/trunk/index.html
JSFloorPlan/trunk/jsfloorplan.js
JSFloorPlan/trunk/jsfloorplan_example_helper.js
Modified: JSFloorPlan/trunk/index.html
===================================================================
--- JSFloorPlan/trunk/index.html 2011-12-09 17:28:37 UTC (rev 560)
+++ JSFloorPlan/trunk/index.html 2011-12-09 21:08:54 UTC (rev 561)
@@ -83,6 +83,17 @@
</tr>
<tr>
<td>
+ Zeige Nodes: <input type="checkbox" name="showNodes" />
+ </td><td>
+ Zeige Walls: <input type="checkbox" name="showWallLines" />
+ </td><td>
+ </td><td>
+ </td><td>
+ </td><td>
+ </td>
+ </tr>
+ <tr>
+ <td>
Transparenz: <select size="1" name="fillOpacity">
<option value="0.1">0.1 - sehr transparent</option>
<option value="0.2">0.2</option>
Modified: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-09 17:28:37 UTC (rev 560)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-09 21:08:54 UTC (rev 561)
@@ -77,7 +77,6 @@
$.get('floorplan01.xml', parseXMLFloorPlan, 'xml');
}
var floor;
-var floorCount = -1;
// this array will contain all vertices to show in the svg
var vertices = Array();
@@ -85,7 +84,7 @@
// the corresponding vertices
var lines = Array();
// infos about the building
-var buildingProperties = new Object;
+var buildingProperties = { floor: [], Object3D: new THREE.Object3D() };
var imageCenter = new Object;
var noFloorplan = true;
@@ -93,6 +92,9 @@
{
noFloorplan = false;
+ var floorCount = -1;
+ var heightOfGround = 0; // the base level of the current floor
+
// basic check if the document seems right
// this could be avoided if the XML file would be validated
// with a DTD
@@ -120,9 +122,16 @@
return alert( "ERROR: Not a valid floor plan! " +
"Expected: 'floor', found '" + floor.tagName + "'" );
+ floorCount++;
+ buildingProperties.floor[floorCount] = {};
+
var floorName = floor.getAttribute('name');
+ buildingProperties.floor[floorCount].name = floorName;
+
var floorheight = floor.getAttribute('height');
- floorCount++;
+ buildingProperties.floor[floorCount].height = floorheight;
+ buildingProperties.floor[floorCount].heightOfGround = heightOfGround;
+
lines[floorCount] = new Array;
var floorWallsStart = floorWalls.length;
@@ -153,6 +162,9 @@
// accessable objects
// => derive the necessary information
+ // group all elements on this floor
+ var Object3D = new THREE.Object3D();
+
// add the information to each node to which nodes it's connected to
for( var j = floorWallsStart; j < floorWalls.length; j++ )
{
@@ -162,11 +174,19 @@
floorNodes[ floorWalls[j].start ].neighbour.push( j+1 );
floorNodes[ floorWalls[j].end ].neighbour.push( -j-1 );
}
+
+ var nodeGroup = new THREE.Object3D(); nodeGroup.name = 'nodeGroup';
for( var id in floorNodes )
{
// calculate the vectors showing to the neighbours
var vectors = new Array();
var start = floorNodes[id];
+
+ // show them on request as spheres
+ var sphere = new THREE.Mesh( new THREE.SphereGeometry(0.1, 4, 4), sphereMaterial);
+ sphere.position = new THREE.Vector3( start.x, start.y, heightOfGround );
+ nodeGroup.add(sphere);
+
for( var j=0; j<floorNodes[id].neighbour.length; j++ )
{
var vec = new Object;
@@ -247,10 +267,19 @@
vertices.push( vertex );
}
} // end for( var id in floorNodes )
+ Object3D.add( nodeGroup );
// show walls
+ var wallGroup = new THREE.Object3D(); wallGroup.name = 'wallGroup';
for( var j = floorWallsStart; j<floorWalls.length; j++ )
{
+ var vs = floorNodes[ floorWalls[j].start ];
+ var ve = floorNodes[ floorWalls[j].end ];
+ var lineGeo = new THREE.Geometry();
+ lineGeo.vertices.push( new THREE.Vertex( new THREE.Vector3( vs.x, vs.y, heightOfGround ) ) );
+ lineGeo.vertices.push( new THREE.Vertex( new THREE.Vector3( ve.x, ve.y, heightOfGround ) ) );
+ wallGroup.add( new THREE.Line( lineGeo, lineMaterial ) );
+
var s1 = vertices[ floorWalls[j].startVertex[0] ];
var e1 = vertices[ floorWalls[j].endVertex [0] ];
var s2 = vertices[ floorWalls[j].startVertex[1] ];
@@ -273,6 +302,14 @@
lines[floorCount].push( Array(floorWalls[j].startVertex[1],floorWalls[j].endVertex[1]) );
}
} // end for( j=0; j<floorWalls.length; j++ )
+ Object3D.add( wallGroup );
+
+ buildingProperties.floor[floorCount].Object3D = Object3D;
+ buildingProperties.floor[floorCount].nodeGroup = nodeGroup;
+ 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!
+
+ heightOfGround += floorheight;
} // end floor
buildingProperties.x_center = (buildingProperties.x_max - buildingProperties.x_min) / 2;
@@ -410,6 +447,8 @@
if( noFloorplan ) return;
noSetup = false;
+ scene.add( buildingProperties.Object3D );
+
var showFloor = showStates.showFloor;
for( var i=0; i<lines[showFloor].length; )
@@ -515,6 +554,10 @@
var $container = $('#top_level');
// attach the render-supplied DOM element
$container.append(renderer.domElement);
+
+ // Init after the scene was set up
+ selectChange( 'showNodes' );
+ selectChange( 'showWallLines' );
}
function show3D( rotation, tilt )
Modified: JSFloorPlan/trunk/jsfloorplan_example_helper.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan_example_helper.js 2011-12-09 17:28:37 UTC (rev 560)
+++ JSFloorPlan/trunk/jsfloorplan_example_helper.js 2011-12-09 21:08:54 UTC (rev 561)
@@ -51,7 +51,7 @@
// create a WebGL renderer, camera
// and a scene
-var renderer = new THREE.WebGLRenderer();
+var renderer = new THREE.WebGLRenderer({antialias: true});
var camera = new THREE.PerspectiveCamera(
VIEW_ANGLE,
ASPECT,
@@ -113,6 +113,8 @@
cube.position = new THREE.Vector3(50,50,50);
//scene.add( cube );
+var lineMaterial = new THREE.LineBasicMaterial( { color: 0x0099ff, linewidth: 2 } );
+
// create a point light
var pointLight = new THREE.PointLight( 0xFFFFFF );
@@ -200,6 +202,7 @@
{
$('input').change(function(e){
showStates[ e.target.name ] = e.target.checked;
+ selectChange( e.target.name );
show3D( roll, tilt );
}).each(function(){
showStates[ this.name ] = this.checked; // init
@@ -215,6 +218,28 @@
createSlider();
}
+function selectChange( name )
+{
+ switch( name )
+ {
+ case 'showNodes':
+ $( buildingProperties.floor ).each( function(){
+ THREE.SceneUtils.traverseHierarchy( this.nodeGroup, function( object ) {
+ object.visible = showStates['showNodes'];
+ });
+ });
+ break;
+
+ case 'showWallLines':
+ $( buildingProperties.floor ).each( function(){
+ THREE.SceneUtils.traverseHierarchy( this.wallGroup, function( object ) {
+ object.visible = showStates['showWallLines'];
+ });
+ });
+ break;
+ }
+}
+
var toggle = false;
var animation;
function my_click()
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:42:38
|
Revision: 562
http://openautomation.svn.sourceforge.net/openautomation/?rev=562&view=rev
Author: mayerch
Date: 2011-12-09 22:42:32 +0000 (Fri, 09 Dec 2011)
Log Message:
-----------
Structure improvements: create 3D objects inline
Modified Paths:
--------------
JSFloorPlan/trunk/jsfloorplan.js
JSFloorPlan/trunk/jsfloorplan_example_helper.js
Modified: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-09 21:08:54 UTC (rev 561)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-09 22:42:32 UTC (rev 562)
@@ -128,7 +128,7 @@
var floorName = floor.getAttribute('name');
buildingProperties.floor[floorCount].name = floorName;
- var floorheight = floor.getAttribute('height');
+ var floorheight = Number( floor.getAttribute('height') );
buildingProperties.floor[floorCount].height = floorheight;
buildingProperties.floor[floorCount].heightOfGround = heightOfGround;
@@ -268,8 +268,9 @@
}
} // end for( var id in floorNodes )
Object3D.add( nodeGroup );
-
+
// show walls
+ var lineGroup = new THREE.Object3D(); lineGroup.name = 'lineGroup';
var wallGroup = new THREE.Object3D(); wallGroup.name = 'wallGroup';
for( var j = floorWallsStart; j<floorWalls.length; j++ )
{
@@ -278,7 +279,7 @@
var lineGeo = new THREE.Geometry();
lineGeo.vertices.push( new THREE.Vertex( new THREE.Vector3( vs.x, vs.y, heightOfGround ) ) );
lineGeo.vertices.push( new THREE.Vertex( new THREE.Vector3( ve.x, ve.y, heightOfGround ) ) );
- wallGroup.add( new THREE.Line( lineGeo, lineMaterial ) );
+ lineGroup.add( new THREE.Line( lineGeo, lineMaterial ) );
var s1 = vertices[ floorWalls[j].startVertex[0] ];
var e1 = vertices[ floorWalls[j].endVertex [0] ];
@@ -288,6 +289,7 @@
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] ];
@@ -301,11 +303,76 @@
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]) );
}
+ */
+ //#######################################
+ 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();
+
+ //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,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 )));
+ geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(s2.x,s2.y,heightOfGround + sh)));
+ geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(e2.x,e2.y,heightOfGround )));
+ geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(e2.x,e2.y,heightOfGround + sh)));
+ geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(em.x,em.y,heightOfGround + sh)));
+
+ 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( 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 ));
+ } 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( 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.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 );
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!
@@ -333,7 +400,7 @@
var point = new Object;
point.x = Number( node.getAttribute('x') );
point.y = Number( node.getAttribute('y') );
- point.z = node.hasAttribute('z') ? Number( node.getAttribute('z') ) : floorheight;
+ point.z = Number( node.hasAttribute('z') ? node.getAttribute('z') : floorheight );
point.neighbour = new Array;
floorNodes[id] = point;
@@ -451,102 +518,6 @@
var showFloor = showStates.showFloor;
- for( var i=0; i<lines[showFloor].length; )
- {
- /*
- 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 s1 = vertices [ lines[showFloor][ i][0] ];
- var e1 = vertices [ lines[showFloor][ i][1] ];
- var sm = floorNodes[ lines[showFloor][++i][1] ];
- var em = floorNodes[ lines[showFloor][ i][0] ];
-// var sh = 2.44;//floorNodes[ lines[showFloor][i][1] ].z ;
-// var eh = 2.44;//floorNodes[ lines[showFloor][i][0] ].z ;
- var sh = floorNodes[ lines[showFloor][i][1] ].z ;
- var eh = floorNodes[ lines[showFloor][i][0] ].z ;
- var s2 = vertices [ lines[showFloor][++i][0] ];
- var e2 = vertices [ lines[showFloor][ i][1] ];
- ++i;
- var wallSideOrder = (s2.x-s1.x)*(e1.y-s1.y) - (s2.y-s1.y)*(e1.x-s1.x);
- //var Tvertices = [];
-
- /**************
- var sphere = new THREE.Mesh( new THREE.SphereGeometry(0.1, 4, 4), sphereMaterial);
- sphere.position = new THREE.Vector3(sm.x,sm.y,0);
- //Tvertices.push(sphere.position);
- scene.add(sphere);
- var sphere = new THREE.Mesh( new THREE.SphereGeometry(0.1, 4, 4), sphereMaterial);
- sphere.position = new THREE.Vector3(sm.x,sm.y,sh);
- //Tvertices.push(sphere.position);
- scene.add(sphere);
- var sphere = new THREE.Mesh( new THREE.SphereGeometry(0.1, 4, 4), sphereMaterial);
- sphere.position = new THREE.Vector3(em.x,em.y,0);
- //Tvertices.push(sphere.position);
- scene.add(sphere);
- var sphere = new THREE.Mesh( new THREE.SphereGeometry(0.1, 4, 4), sphereMaterial);
- sphere.position = new THREE.Vector3(em.x,em.y,eh);
- //Tvertices.push(sphere.position);
- scene.add(sphere);
- */
- var geometry = new THREE.Geometry();
-
- //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)));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(s1.x,s1.y,sh)));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(sm.x,sm.y,sh)));
-
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(s2.x,s2.y,0)));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(s2.x,s2.y,sh)));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(e2.x,e2.y,0)));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(e2.x,e2.y,sh)));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(em.x,em.y,sh)));
-
- 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( 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 ));
- } 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( 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.computeFaceNormals();
- //var mesh = new THREE.Mesh(geometry, new THREE.MeshNormalMaterial());
- var mesh = new THREE.Mesh(geometry, cubeMaterial);
- scene.add(mesh);
- }
-
///////////
scene.add(pointLight);
scene.add(ambientLight);
Modified: JSFloorPlan/trunk/jsfloorplan_example_helper.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan_example_helper.js 2011-12-09 21:08:54 UTC (rev 561)
+++ JSFloorPlan/trunk/jsfloorplan_example_helper.js 2011-12-09 22:42:32 UTC (rev 562)
@@ -232,7 +232,7 @@
case 'showWallLines':
$( buildingProperties.floor ).each( function(){
- THREE.SceneUtils.traverseHierarchy( this.wallGroup, function( object ) {
+ THREE.SceneUtils.traverseHierarchy( this.lineGroup, function( object ) {
object.visible = showStates['showWallLines'];
});
});
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-10 10:03:17
|
Revision: 564
http://openautomation.svn.sourceforge.net/openautomation/?rev=564&view=rev
Author: mayerch
Date: 2011-12-10 10:03:11 +0000 (Sat, 10 Dec 2011)
Log Message:
-----------
Enable switching between floors
Modified Paths:
--------------
JSFloorPlan/trunk/jsfloorplan.js
JSFloorPlan/trunk/jsfloorplan_example_helper.js
Modified: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-09 22:48:33 UTC (rev 563)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-10 10:03:11 UTC (rev 564)
@@ -502,6 +502,7 @@
// Init after the scene was set up
selectChange( 'showNodes' );
selectChange( 'showWallLines' );
+ selectChange( 'showFloor' );
}
function show3D( rotation, tilt )
@@ -512,9 +513,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;
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) );
+ 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) );
pointLight.position = camera.position;
// update opacity
Modified: JSFloorPlan/trunk/jsfloorplan_example_helper.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan_example_helper.js 2011-12-09 22:48:33 UTC (rev 563)
+++ JSFloorPlan/trunk/jsfloorplan_example_helper.js 2011-12-10 10:03:11 UTC (rev 564)
@@ -209,6 +209,7 @@
});
$('select').change(function(e){
showStates[ e.target.name ] = e.target.value;
+ selectChange( e.target.name );
show3D( roll, tilt );
}).each(function(){
showStates[ this.name ] = this.value; // init
@@ -237,6 +238,14 @@
});
});
break;
+
+ case 'showFloor':
+ $( buildingProperties.floor ).each( function( number ){
+ THREE.SceneUtils.traverseHierarchy( this.wallGroup, function( object ) {
+ object.visible = ( showStates['showFloor'] == number );
+ });
+ });
+ break;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-13 15:35:10
|
Revision: 575
http://openautomation.svn.sourceforge.net/openautomation/?rev=575&view=rev
Author: mayerch
Date: 2011-12-13 15:35:00 +0000 (Tue, 13 Dec 2011)
Log Message:
-----------
Added inital support for textures
Modified Paths:
--------------
JSFloorPlan/trunk/jsfloorplan.js
JSFloorPlan/trunk/jsfloorplan_example_helper.js
Added Paths:
-----------
JSFloorPlan/trunk/media/
JSFloorPlan/trunk/media/demo_texture_512x512.png
Modified: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-13 12:43:52 UTC (rev 574)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-13 15:35:00 UTC (rev 575)
@@ -315,9 +315,13 @@
{
// Add the wall sides
geometry.faces.push(new THREE.Face3( 2, 3, 0 ));
+ geometry.faceVertexUvs[0].push([ new THREE.UV(1,1), new THREE.UV(1,0), new THREE.UV(0,1) ]);
geometry.faces.push(new THREE.Face3( 1, 0, 3 ));
+ geometry.faceVertexUvs[0].push([ new THREE.UV(0,0), new THREE.UV(0,1), new THREE.UV(1,0) ]);
geometry.faces.push(new THREE.Face3( 5, 6, 7 ));
+ geometry.faceVertexUvs[0].push([ new THREE.UV(1,1), new THREE.UV(1,0), new THREE.UV(0,1) ]);
geometry.faces.push(new THREE.Face3( 8, 7, 6 ));
+ geometry.faceVertexUvs[0].push([ new THREE.UV(0,0), new THREE.UV(0,1), new THREE.UV(1,0) ]);
// Add the wall tops
geometry.faces.push(new THREE.Face3( 1, 6, 9 ));
geometry.faces.push(new THREE.Face3( 6, 1, 3 ));
@@ -326,9 +330,13 @@
} else {
// Add the wall sides
geometry.faces.push(new THREE.Face3( 2, 0, 3 ));
+ geometry.faceVertexUvs[0].push([ new THREE.UV(0,1), new THREE.UV(1,1), new THREE.UV(0,0) ]);
geometry.faces.push(new THREE.Face3( 1, 3, 0 ));
+ geometry.faceVertexUvs[0].push([ new THREE.UV(1,0), new THREE.UV(0,0), new THREE.UV(1,1) ]);
geometry.faces.push(new THREE.Face3( 5, 7, 6 ));
+ geometry.faceVertexUvs[0].push([ new THREE.UV(0,1), new THREE.UV(1,1), new THREE.UV(0,0) ]);
geometry.faces.push(new THREE.Face3( 8, 6, 7 ));
+ geometry.faceVertexUvs[0].push([ new THREE.UV(1,0), new THREE.UV(0,0), new THREE.UV(1,1) ]);
// Add the wall tops
geometry.faces.push(new THREE.Face3( 1, 9, 6 ));
geometry.faces.push(new THREE.Face3( 6, 3, 1 ));
Modified: JSFloorPlan/trunk/jsfloorplan_example_helper.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan_example_helper.js 2011-12-13 12:43:52 UTC (rev 574)
+++ JSFloorPlan/trunk/jsfloorplan_example_helper.js 2011-12-13 15:35:00 UTC (rev 575)
@@ -113,6 +113,8 @@
cube.position = new THREE.Vector3(50,50,50);
//scene.add( cube );
+cubeMaterial = new THREE.MeshBasicMaterial({ map: THREE.ImageUtils.loadTexture( 'media/demo_texture_512x512.png' ) });
+
var lineMaterial = new THREE.LineBasicMaterial( { color: 0x0099ff, linewidth: 2 } );
// create a point light
Added: JSFloorPlan/trunk/media/demo_texture_512x512.png
===================================================================
(Binary files differ)
Property changes on: JSFloorPlan/trunk/media/demo_texture_512x512.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-15 18:31:23
|
Revision: 577
http://openautomation.svn.sourceforge.net/openautomation/?rev=577&view=rev
Author: mayerch
Date: 2011-12-15 18:31:12 +0000 (Thu, 15 Dec 2011)
Log Message:
-----------
Add trianglulation lib and triangulate walls to handle holes.
Also make wireframe view togglable via web page.
Modified Paths:
--------------
JSFloorPlan/trunk/index.html
JSFloorPlan/trunk/jsfloorplan.js
JSFloorPlan/trunk/jsfloorplan_example_helper.js
Added Paths:
-----------
JSFloorPlan/trunk/lib/poly2tri.js
Modified: JSFloorPlan/trunk/index.html
===================================================================
--- JSFloorPlan/trunk/index.html 2011-12-15 18:24:48 UTC (rev 576)
+++ JSFloorPlan/trunk/index.html 2011-12-15 18:31:12 UTC (rev 577)
@@ -12,6 +12,7 @@
<!-- -->
<script src="lib/jquery-1.7.1.min.js" type="text/javascript"></script>
<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="jsfloorplan_example_helper.js" type="text/javascript"></script>
<script src="jsfloorplan.js" type="text/javascript"></script>
@@ -87,6 +88,7 @@
</td><td>
Zeige Walls: <input type="checkbox" name="showWallLines" />
</td><td>
+ Zeige Wireframe: <input type="checkbox" name="showWireframe" />
</td><td>
</td><td>
</td><td>
Modified: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-15 18:24:48 UTC (rev 576)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-15 18:31:12 UTC (rev 577)
@@ -280,6 +280,7 @@
var e1 = vertices[ floorWalls[j].endVertex [0] ];
var s2 = vertices[ floorWalls[j].startVertex[1] ];
var e2 = vertices[ floorWalls[j].endVertex [1] ];
+
// check that the start and end points aren't twisted
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;
@@ -296,54 +297,127 @@
var wallSideOrder = (s2.x-s1.x)*(e1.y-s1.y) - (s2.y-s1.y)*(e1.x-s1.x);
var geometry = new THREE.Geometry();
- //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(sm.x,sm.y,heightOfGround + sh)));
+ var normal1 = new THREE.Vector3(sm.y-em.y,-sm.x+em.x,0); // fixme? normalize
+ var normal2 = new THREE.Vector3(1,0,0);
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(s2.x,s2.y,heightOfGround )));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(s2.x,s2.y,heightOfGround + sh)));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(e2.x,e2.y,heightOfGround )));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(e2.x,e2.y,heightOfGround + sh)));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(em.x,em.y,heightOfGround + sh)));
+ var sourrounding = [ new poly2tri.Point(0,0), new poly2tri.Point(0,1), new poly2tri.Point(1,1), new poly2tri.Point(1,0) ];
+ sourrounding[1].startEndMarker = 'start';
+ sourrounding[2].startEndMarker = 'end';
+ var holesToAdd = [];
- if( wallSideOrder < 0 )
+ if( floorWalls[j].holes.length )
{
- // Add the wall sides
- geometry.faces.push(new THREE.Face3( 2, 3, 0 ));
- geometry.faceVertexUvs[0].push([ new THREE.UV(1,1), new THREE.UV(1,0), new THREE.UV(0,1) ]);
- geometry.faces.push(new THREE.Face3( 1, 0, 3 ));
- geometry.faceVertexUvs[0].push([ new THREE.UV(0,0), new THREE.UV(0,1), new THREE.UV(1,0) ]);
- geometry.faces.push(new THREE.Face3( 5, 6, 7 ));
- geometry.faceVertexUvs[0].push([ new THREE.UV(1,1), new THREE.UV(1,0), new THREE.UV(0,1) ]);
- geometry.faces.push(new THREE.Face3( 8, 7, 6 ));
- geometry.faceVertexUvs[0].push([ new THREE.UV(0,0), new THREE.UV(0,1), new THREE.UV(1,0) ]);
- // Add the wall tops
- 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( 2, 0, 3 ));
- geometry.faceVertexUvs[0].push([ new THREE.UV(0,1), new THREE.UV(1,1), new THREE.UV(0,0) ]);
- geometry.faces.push(new THREE.Face3( 1, 3, 0 ));
- geometry.faceVertexUvs[0].push([ new THREE.UV(1,0), new THREE.UV(0,0), new THREE.UV(1,1) ]);
- geometry.faces.push(new THREE.Face3( 5, 7, 6 ));
- geometry.faceVertexUvs[0].push([ new THREE.UV(0,1), new THREE.UV(1,1), new THREE.UV(0,0) ]);
- geometry.faces.push(new THREE.Face3( 8, 6, 7 ));
- geometry.faceVertexUvs[0].push([ new THREE.UV(1,0), new THREE.UV(0,0), new THREE.UV(1,1) ]);
- // Add the wall tops
- 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 ));
+ var holes = floorWalls[j].holes;
+ for( var h = 0; h < holes.length; h++ )
+ {
+ var wallLength = calcLength2D( sm, em );
+ var fLeft = holes[h].distance / wallLength;
+ var fRight = (holes[h].distance + holes[h].width) / wallLength;
+ if( fLeft < 0.0 ) fLeft = 0.01; //// FIXME
+ if( fRight > 1.0 ) fRight = 0.99; //// FIXME
+ var lintel = (sh - holes[h].lintel) / sh;
+ var paparet = holes[h].paparet / sh;
+ if( 1 == lintel )
+ {
+ // not a hole, the sourrounding goes to the groud...
+
+ if( paparet == 0 ) continue; // FIXME: Assume paparet != 0 - otherwise it should be two walls...
+
+ console.log( sourrounding );
+ sourrounding.splice( -2, 0, new poly2tri.Point(fLeft,1), new poly2tri.Point(fLeft,paparet), new poly2tri.Point(fRight,paparet), new poly2tri.Point(fRight,1) );
+ console.log( sourrounding );
+ continue;
+ }
+ //if( 0 == paparet ) paparet = 0.01; //// FIXME
+ if( 0 == paparet )
+ {
+ // not a hole, the sourrounding goes to the groud...
+
+ if( lintel == 1 ) continue; // FIXME: Assume lintel != 1 - otherwise it should be two walls...
+
+ sourrounding.splice( 0, 0, new poly2tri.Point(fRight,0), new poly2tri.Point(fRight,lintel), new poly2tri.Point(fLeft,lintel), new poly2tri.Point(fLeft,0) );
+ continue;
+ }
+
+ holesToAdd.push( [new poly2tri.Point(fLeft,paparet), new poly2tri.Point(fRight,paparet), new poly2tri.Point(fRight,lintel), new poly2tri.Point(fLeft,lintel)] );
+ }
+ } // if( floorWalls[j].holes.length )
+ var swctx = new poly2tri.SweepContext( sourrounding );
+ for( var htA = 0; htA < holesToAdd.length; htA++ )
+ swctx.AddHole( holesToAdd[htA] );
+
+ // Do the triangulation - FIXME: handle exceptions, don't ignore them...
+ try {
+ poly2tri.sweep.Triangulate(swctx);
+ }catch(err){}
+
+ // mark all points to make sure that we don't need to double vertices
+ for( var tp = 0; tp < swctx.point_count(); tp++ )
+ swctx.GetPoint( tp ).id = tp;
+
+ // translate poly2tri triangles to THREE.js faces:
+ var p2tF = [];
+ $.each(swctx.GetTriangles(), function(idx, val) {
+ p2tF.push(new THREE.Face3(val.GetPoint(0).id, val.GetPoint(1).id, val.GetPoint(2).id));
+ });
+
+ Tvertices = swctx.points_;
+ Tfaces = p2tF;
+ var wall1vertices = [];
+ var wall2vertices = [];
+ var sId, eId;
+ for( var v = 0; v < Tvertices.length; v++ )
+ {
+ 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 z = heightOfGround + sh*tv.y;
+ if( wallSideOrder > 0 )
+ {
+ wall1vertices.push(new THREE.Vertex(new THREE.Vector3(x1,y1,z), normal1));
+ wall2vertices.push(new THREE.Vertex(new THREE.Vector3(x2,y2,z), normal1));
+ } else {
+ wall1vertices.push(new THREE.Vertex(new THREE.Vector3(x2,y2,z), normal1));
+ wall2vertices.push(new THREE.Vertex(new THREE.Vector3(x1,y1,z), normal1));
+ }
+ if( 'startEndMarker' in tv )
+ {
+ if( 'start' == tv.startEndMarker )
+ {
+ sId = wall1vertices.length - 1;
+ } else {
+ eId = wall1vertices.length - 1;
+ }
+ }
}
-
+ var wall1verticesLength = wall1vertices.length;
+ geometry.vertices = wall1vertices.concat( wall2vertices );
+ var s1id = sId, s2id = sId + wall1verticesLength, e1id = eId, e2id = eId + wall1verticesLength;
+ //geometry.faces = Tfaces;
+ for( var f = 0; f < Tfaces.length; f++ )
+ {
+ // wall side 1
+ geometry.faces.push( Tfaces[f] );
+ // wall side 2
+ geometry.faces.push(new THREE.Face3(Tfaces[f].c+wall1verticesLength, Tfaces[f].b+wall1verticesLength, Tfaces[f].a+wall1verticesLength ) );
+ }
+ // wall top
+ var mId = geometry.vertices.length;
+ geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(sm.x,sm.y,heightOfGround )));
+ geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(sm.x,sm.y,heightOfGround+sh)));
+ geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(em.x,em.y,heightOfGround )));
+ geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(em.x,em.y,heightOfGround+eh)));
+ geometry.faces.push(new THREE.Face3(s1id, s2id, mId+1) );
+ geometry.faces.push(new THREE.Face3(s2id, s1id, e1id ) );
+ geometry.faces.push(new THREE.Face3(e2id, s2id, e1id ) );
+ geometry.faces.push(new THREE.Face3(e2id, e1id, mId+3) );
+ /*
+ * geometry.faces.push(new THREE.Face3( 2, 3, 0 ));
+ * geometry.faceVertexUvs[0].push([ new THREE.UV(1,1), new THREE.UV(1,0), new THREE.UV(0,1) ]);
+ */
+ //console.log(geometry, cubeMaterial);
geometry.computeFaceNormals();
var mesh = new THREE.Mesh(geometry, cubeMaterial);
wallGroup.add(mesh);
Modified: JSFloorPlan/trunk/jsfloorplan_example_helper.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan_example_helper.js 2011-12-15 18:24:48 UTC (rev 576)
+++ JSFloorPlan/trunk/jsfloorplan_example_helper.js 2011-12-15 18:31:12 UTC (rev 577)
@@ -113,7 +113,7 @@
cube.position = new THREE.Vector3(50,50,50);
//scene.add( cube );
-cubeMaterial = new THREE.MeshBasicMaterial({ map: THREE.ImageUtils.loadTexture( 'media/demo_texture_512x512.png' ) });
+//cubeMaterial = new THREE.MeshBasicMaterial({ map: THREE.ImageUtils.loadTexture( 'media/demo_texture_512x512.png' ) });
var lineMaterial = new THREE.LineBasicMaterial( { color: 0x0099ff, linewidth: 2 } );
@@ -248,6 +248,10 @@
});
});
break;
+
+ case 'showWireframe':
+ cubeMaterial.wireframe = showStates['showWireframe'];
+ break;
}
}
Added: JSFloorPlan/trunk/lib/poly2tri.js
===================================================================
--- JSFloorPlan/trunk/lib/poly2tri.js (rev 0)
+++ JSFloorPlan/trunk/lib/poly2tri.js 2011-12-15 18:31:12 UTC (rev 577)
@@ -0,0 +1,1751 @@
+/*
+ * Modified version by Christian Mayer (c) 2011 to avoid the originally used
+ * namespace
+ */
+/******************************************************************************/
+/*
+ * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
+ * http://code.google.com/p/poly2tri/
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of Poly2Tri nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+//Namespace('poly2tri');
+poly2tri = {};
+// ------------------------------------------------------------------------Point
+poly2tri.Point = function() {
+ this.x = null;
+ this.y = null;
+
+ if (arguments.length == 0) {
+ this.x = 0.0;
+ this.y = 0.0;
+ } else if (arguments.length == 2) {
+ this.x = arguments[0];
+ this.y = arguments[1];
+ } else {
+ alert('Invalid poly2tri.Point constructor call!');
+ }
+
+ // The edges this point constitutes an upper ending point
+ this.edge_list = [];
+
+}
+
+/**
+ * Set this Point instance to the origo. <code>(0; 0)</code>
+ */
+poly2tri.Point.prototype.set_zero = function() {
+ this.x = 0.0;
+ this.y = 0.0;
+}
+
+/**
+ * Set the coordinates of this instance.
+ * @param x number.
+ * @param y number;
+ */
+poly2tri.Point.prototype.set = function(x, y) {
+ this.x = x;
+ this.y = y;
+}
+
+/**
+ * Negate this Point instance. (component-wise)
+ */
+poly2tri.Point.prototype.negate = function() {
+ this.x = -this.x;
+ this.y = -this.y;
+}
+
+/**
+ * Add another Point object to this instance. (component-wise)
+ * @param n Point object.
+ */
+poly2tri.Point.prototype.add = function(n) {
+ this.x += n.x;
+ this.y += n.y;
+}
+
+/**
+ * Subtract this Point instance with another point given. (component-wise)
+ * @param n Point object.
+ */
+poly2tri.Point.prototype.sub = function(n) {
+ this.x -= n.x;
+ this.y -= n.y;
+}
+
+/**
+ * Multiply this Point instance by a scalar. (component-wise)
+ * @param s scalar.
+ */
+poly2tri.Point.prototype.mul = function(s) {
+ this.x *= s;
+ this.y *= s;
+}
+
+/**
+ * Return the distance of this Point instance from the origo.
+ */
+poly2tri.Point.prototype.length = function() {
+ return Math.sqrt(this.x*this.x + this.y*this.y);
+}
+
+/**
+ * Normalize this Point instance (as a vector).
+ * @return The original distance of this instance from the origo.
+ */
+poly2tri.Point.prototype.normalize = function() {
+ var len = this.length();
+ this.x /= len;
+ this.y /= len;
+ return len;
+}
+
+/**
+ * Test this Point object with another for equality.
+ * @param p Point object.
+ * @return <code>True</code> if <code>this == p</code>, <code>false</code> otherwise.
+ */
+poly2tri.Point.prototype.equals = function(p) {
+ return poly2tri.equals(this, p);
+}
+
+/**
+ * Negate a point component-wise and return the result as a new Point object.
+ * @param p Point object.
+ * @return the resulting Point object.
+ */
+poly2tri.negate = function(p) {
+ return new poly2tri.Point(-p.x, -p.y);
+}
+
+/**
+ * Compare two points component-wise.
+ * @param a Point object.
+ * @param b Point object.
+ * @return <code>-1</code> if <code>a < b</code>, <code>1</code> if
+ * <code>a > b</code>, <code>0</code> otherwise.
+ */
+poly2tri.cmp = function(a, b) {
+ if (a.y == b.y) {
+ return a.x - b.x;
+ } else {
+ return a.y - b.y;
+ }
+}
+
+/**
+ * Add two points component-wise and return the result as a new Point object.
+ * @param a Point object.
+ * @param b Point object.
+ * @return the resulting Point object.
+ */
+poly2tri.add = function(a, b) {
+ return new poly2tri.Point(a.x+b.x, a.y+b.y);
+}
+
+/**
+ * Subtract two points component-wise and return the result as a new Point object.
+ * @param a Point object.
+ * @param b Point object.
+ * @return the resulting Point object.
+ */
+poly2tri.sub = function(a, b) {
+ return new poly2tri.Point(a.x-b.x, a.y-b.y);
+}
+
+/**
+ * Multiply a point by a scalar and return the result as a new Point object.
+ * @param s the scalar (a number).
+ * @param p Point object.
+ * @return the resulting Point object.
+ */
+poly2tri.mul = function(s, p) {
+ return new poly2tri.Point(s*p.x, s*p.y);
+}
+
+/**
+ * Test two Point objects for equality.
+ * @param a Point object.
+ * @param b Point object.
+ * @return <code>True</code> if <code>a == b</code>, <code>false</code> otherwise.
+ */
+poly2tri.equals = function(a, b) {
+ return a.x == b.x && a.y == b.y;
+}
+
+/**
+ * Peform the dot product on two vectors.
+ * @param a Point object.
+ * @param b Point object.
+ * @return The dot product (as a number).
+ */
+poly2tri.dot = function(a, b) {
+ return a.x*b.x + a.y*b.y;
+}
+
+/**
+ * Perform the cross product on either two points (this produces a scalar)
+ * or a point and a scalar (this produces a point).
+ * This function requires two parameters, either may be a Point object or a
+ * number.
+ * @return a Point object or a number, depending on the parameters.
+ */
+poly2tri.cross = function() {
+ var a0_p = false;
+ var a1_p = false;
+ if (arguments.length == 2) {
+ if (typeof(arguments[0]) == 'number') {
+ a0_p = true;
+ }
+ if (typeof(arguments[1] == 'number')) {
+ a1_p = true;
+ }
+
+ if (a0_p) {
+ if (a1_p) return arguments[0].x*arguments[1].y - arguments[0].y*arguments[1].x;
+ else return new poly2tri.Point(arguments[1]*arguments[0].y, -arguments[1]*arguments[0].x);
+ } else {
+ if (a1_p) return new poly2tri.Point(-arguments[0]*arguments[1].y, arguments[0]*arguments[1].x);
+ else return arguments[0]*arguments[1];
+ }
+ } else {
+ alert('Invalid poly2tri.cross call!');
+ return undefined;
+ }
+}
+
+
+// -------------------------------------------------------------------------Edge
+poly2tri.Edge = function() {
+ this.p = null;
+ this.q = null;
+
+ if (arguments.length == 2) {
+ if (arguments[0].y > arguments[1].y) {
+ this.q = arguments[0];
+ this.p = arguments[1];
+ } else if (arguments[0].y == arguments[1].y) {
+ if (arguments[0].x > arguments[1].x) {
+ this.q = arguments[0];
+ this.p = arguments[1];
+ } else if (arguments[0].x == arguments[1].x) {
+ alert('Invalid poly2tri.edge constructor call: repeated points!');
+ } else {
+ this.p = arguments[0];
+ this.q = arguments[1];
+ }
+ } else {
+ this.p = arguments[0];
+ this.q = arguments[1];
+ }
+ } else {
+ alert('Invalid poly2tri.Edge constructor call!');
+ }
+
+ this.q.edge_list.push(this);
+}
+
+// ---------------------------------------------------------------------Triangle
+/**
+ * Triangle class.<br>
+ * Triangle-based data structures are known to have better performance than
+ * quad-edge structures.
+ * See: J. Shewchuk, "Triangle: Engineering a 2D Quality Mesh Generator and
+ * Delaunay Triangulator", "Triangulations in CGAL"
+ *
+ * @param p1 Point object.
+ * @param p2 Point object.
+ * @param p3 Point object.
+ */
+poly2tri.Triangle = function(p1, p2, p3) {
+ // Triangle points
+ this.points_ = [ null, null, null ];
+ // Neighbor list
+ this.neighbors_ = [ null, null, null ];
+ // Has this triangle been marked as an interior triangle?
+ this.interior_ = false;
+ // Flags to determine if an edge is a Constrained edge
+ this.constrained_edge = [ false, false, false ];
+ // Flags to determine if an edge is a Delauney edge
+ this.delaunay_edge = [ false, false, false ];
+
+ if (arguments.length == 3) {
+ this.points_[0] = p1;
+ this.points_[1] = p2;
+ this.points_[2] = p3;
+ }
+}
+
+poly2tri.Triangle.prototype.GetPoint = function(index) {
+ return this.points_[index];
+}
+
+poly2tri.Triangle.prototype.GetNeighbor = function(index) {
+ return this.neighbors_[index];
+}
+
+/**
+ * Test if this Triangle contains the Point objects given as parameters as its
+ * vertices.
+ * @return <code>True</code> if the Point objects are of the Triangle's vertices,
+ * <code>false</code> otherwise.
+ */
+poly2tri.Triangle.prototype.ContainsP = function() {
+ var back = true;
+ for (var aidx=0; aidx < arguments.length; ++aidx) {
+ back = back && (arguments[aidx].equals(this.points_[0]) ||
+ arguments[aidx].equals(this.points_[1]) ||
+ arguments[aidx].equals(this.points_[2])
+ );
+ }
+ return back;
+}
+
+/**
+ * Test if this Triangle contains the Edge objects given as parameters as its
+ * bounding edges.
+ * @return <code>True</code> if the Edge objects are of the Triangle's bounding
+ * edges, <code>false</code> otherwise.
+ */
+poly2tri.Triangle.prototype.ContainsE = function() {
+ var back = true;
+ for (var aidx=0; aidx < arguments.length; ++aidx) {
+ back = back && this.ContainsP(arguments[aidx].p, arguments[aidx].q);
+ }
+ return back;
+}
+
+poly2tri.Triangle.prototype.IsInterior = function() {
+ if (arguments.length == 0) {
+ return this.interior_;
+ } else {
+ this.interior_ = arguments[0];
+ return this.interior_;
+ }
+}
+
+/**
+ * Update neighbor pointers.<br>
+ * This method takes either 3 parameters (<code>p1</code>, <code>p2</code> and
+ * <code>t</code>) or 1 parameter (<code>t</code>).
+ * @param p1 Point object.
+ * @param p2 Point object.
+ * @param t Triangle object.
+ */
+poly2tri.Triangle.prototype.MarkNeighbor = function() {
+ var t;
+ if (arguments.length == 3) {
+ var p1 = arguments[0];
+ var p2 = arguments[1];
+ t = arguments[2];
+
+ if ((p1.equals(this.points_[2]) && p2.equals(this.points_[1])) || (p1.equals(this.points_[1]) && p2.equals(this.points_[2]))) this.neighbors_[0] = t;
+ else if ((p1.equals(this.points_[0]) && p2.equals(this.points_[2])) || (p1.equals(this.points_[2]) && p2.equals(this.points_[0]))) this.neighbors_[1] = t;
+ else if ((p1.equals(this.points_[0]) && p2.equals(this.points_[1])) || (p1.equals(this.points_[1]) && p2.equals(this.points_[0]))) this.neighbors_[2] = t;
+ else alert('Invalid poly2tri.Triangle.MarkNeighbor call (1)!');
+ } else if (arguments.length == 1) {
+ // exhaustive search to update neighbor pointers
+ t = arguments[0];
+ if (t.ContainsP(this.points_[1], this.points_[2])) {
+ this.neighbors_[0] = t;
+ t.MarkNeighbor(this.points_[1], this.points_[2], this);
+ } else if (t.ContainsP(this.points_[0], this.points_[2])) {
+ this.neighbors_[1] = t;
+ t.MarkNeighbor(this.points_[0], this.points_[2], this);
+ } else if (t.ContainsP(this.points_[0], this.points_[1])) {
+ this.neighbors_[2] = t;
+ t.MarkNeighbor(this.points_[0], this.points_[1], this);
+ }
+ } else {
+ alert('Invalid poly2tri.Triangle.MarkNeighbor call! (2)');
+ }
+}
+
+poly2tri.Triangle.prototype.ClearNeigbors = function() {
+ this.neighbors_[0] = null;
+ this.neighbors_[1] = null;
+ this.neighbors_[2] = null;
+}
+
+poly2tri.Triangle.prototype.ClearDelunayEdges = function() {
+ this.delaunay_edge[0] = false;
+ this.delaunay_edge[1] = false;
+ this.delaunay_edge[2] = false;
+}
+
+/**
+ * Return the point clockwise to the given point.
+ */
+poly2tri.Triangle.prototype.PointCW = function(p) {
+ if (p.equals(this.points_[0])) {
+ return this.points_[2];
+ } else if (p.equals(this.points_[1])) {
+ return this.points_[0];
+ } else if (p.equals(this.points_[2])) {
+ return this.points_[1];
+ } else {
+ return null;
+ }
+}
+
+/**
+ * Return the point counter-clockwise to the given point.
+ */
+poly2tri.Triangle.prototype.PointCCW = function(p) {
+ if (p.equals(this.points_[0])) {
+ return this.points_[1];
+ } else if (p.equals(this.points_[1])) {
+ return this.points_[2];
+ } else if (p.equals(this.points_[2])) {
+ return this.points_[0];
+ } else {
+ return null;
+ }
+}
+
+/**
+ * Return the neighbor clockwise to given point.
+ */
+poly2tri.Triangle.prototype.NeighborCW = function(p) {
+ if (p.equals(this.points_[0])) {
+ return this.neighbors_[1];
+ } else if (p.equals(this.points_[1])) {
+ return this.neighbors_[2];
+ } else {
+ return this.neighbors_[0];
+ }
+}
+
+/**
+ * Return the neighbor counter-clockwise to given point.
+ */
+poly2tri.Triangle.prototype.NeighborCCW = function(p) {
+ if (p.equals(this.points_[0])) {
+ return this.neighbors_[2];
+ } else if (p.equals(this.points_[1])) {
+ return this.neighbors_[0];
+ } else {
+ return this.neighbors_[1];
+ }
+}
+
+poly2tri.Triangle.prototype.GetConstrainedEdgeCW = function(p) {
+ if (p.equals(this.points_[0])) {
+ return this.constrained_edge[1];
+ } else if (p.equals(this.points_[1])) {
+ return this.constrained_edge[2];
+ } else {
+ return this.constrained_edge[0];
+ }
+}
+
+poly2tri.Triangle.prototype.GetConstrainedEdgeCCW = function(p) {
+ if (p.equals(this.points_[0])) {
+ return this.constrained_edge[2];
+ } else if (p.equals(this.points_[1])) {
+ return this.constrained_edge[0];
+ } else {
+ return this.constrained_edge[1];
+ }
+}
+
+poly2tri.Triangle.prototype.SetConstrainedEdgeCW = function(p, ce) {
+ if (p.equals(this.points_[0])) {
+ this.constrained_edge[1] = ce;
+ } else if (p.equals(this.points_[1])) {
+ this.constrained_edge[2] = ce;
+ } else {
+ this.constrained_edge[0] = ce;
+ }
+}
+
+poly2tri.Triangle.prototype.SetConstrainedEdgeCCW = function(p, ce) {
+ if (p.equals(this.points_[0])) {
+ this.constrained_edge[2] = ce;
+ } else if (p.equals(this.points_[1])) {
+ this.constrained_edge[0] = ce;
+ } else {
+ this.constrained_edge[1] = ce;
+ }
+}
+
+poly2tri.Triangle.prototype.GetDelaunayEdgeCW = function(p) {
+ if (p.equals(this.points_[0])) {
+ return this.delaunay_edge[1];
+ } else if (p.equals(this.points_[1])) {
+ return this.delaunay_edge[2];
+ } else {
+ return this.delaunay_edge[0];
+ }
+}
+
+poly2tri.Triangle.prototype.GetDelaunayEdgeCCW = function(p) {
+ if (p.equals(this.points_[0])) {
+ return this.delaunay_edge[2];
+ } else if (p.equals(this.points_[1])) {
+ return this.delaunay_edge[0];
+ } else {
+ return this.delaunay_edge[1];
+ }
+}
+
+poly2tri.Triangle.prototype.SetDelaunayEdgeCW = function(p, e) {
+ if (p.equals(this.points_[0])) {
+ this.delaunay_edge[1] = e;
+ } else if (p.equals(this.points_[1])) {
+ this.delaunay_edge[2] = e;
+ } else {
+ this.delaunay_edge[0] = e;
+ }
+}
+
+poly2tri.Triangle.prototype.SetDelaunayEdgeCCW = function(p, e) {
+ if (p.equals(this.points_[0])) {
+ this.delaunay_edge[2] = e;
+ } else if (p.equals(this.points_[1])) {
+ this.delaunay_edge[0] = e;
+ } else {
+ this.delaunay_edge[1] = e;
+ }
+}
+
+/**
+ * The neighbor across to given point.
+ */
+poly2tri.Triangle.prototype.NeighborAcross = function(p) {
+ if (p.equals(this.points_[0])) {
+ return this.neighbors_[0];
+ } else if (p.equals(this.points_[1])) {
+ return this.neighbors_[1];
+ } else {
+ return this.neighbors_[2];
+ }
+}
+
+poly2tri.Triangle.prototype.OppositePoint = function(t, p) {
+ var cw = t.PointCW(p);
+ return this.PointCW(cw);
+}
+
+/**
+ * Legalize triangle by rotating clockwise.<br>
+ * This method takes either 1 parameter (then the triangle is rotated around
+ * points(0)) or 2 parameters (then the triangle is rotated around the first
+ * parameter).
+ */
+poly2tri.Triangle.prototype.Legalize = function() {
+ if (arguments.length == 1) {
+ this.Legalize(this.points_[0], arguments[0]);
+ } else if (arguments.length == 2) {
+ var opoint = arguments[0];
+ var npoint = arguments[1];
+
+ if (opoint.equals(this.points_[0])) {
+ this.points_[1] = this.points_[0];
+ this.points_[0] = this.points_[2];
+ this.points_[2] = npoint;
+ } else if (opoint.equals(this.points_[1])) {
+ this.points_[2] = this.points_[1];
+ this.points_[1] = this.points_[0];
+ this.points_[0] = npoint;
+ ...
[truncated message content] |
|
From: <ma...@us...> - 2011-12-16 14:24:18
|
Revision: 578
http://openautomation.svn.sourceforge.net/openautomation/?rev=578&view=rev
Author: mayerch
Date: 2011-12-16 14:24:07 +0000 (Fri, 16 Dec 2011)
Log Message:
-----------
Add UV coordinates to the triangulated version. This allows to enable textures again.
Modified Paths:
--------------
JSFloorPlan/trunk/jsfloorplan.js
JSFloorPlan/trunk/jsfloorplan_example_helper.js
Modified: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-15 18:31:12 UTC (rev 577)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-16 14:24:07 UTC (rev 578)
@@ -333,7 +333,7 @@
{
// not a hole, the sourrounding goes to the groud...
- if( lintel == 1 ) continue; // FIXME: Assume lintel != 1 - otherwise it should be two walls...
+ // lintel == 1 can't happen, it's checked in the if clause above
sourrounding.splice( 0, 0, new poly2tri.Point(fRight,0), new poly2tri.Point(fRight,lintel), new poly2tri.Point(fLeft,lintel), new poly2tri.Point(fLeft,0) );
continue;
@@ -398,10 +398,16 @@
//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 );
+
// wall side 1
geometry.faces.push( Tfaces[f] );
+ geometry.faceVertexUvs[0].push([ uv_a, uv_b, uv_c ]);
// 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 ]);
}
// wall top
var mId = geometry.vertices.length;
@@ -413,10 +419,6 @@
geometry.faces.push(new THREE.Face3(s2id, s1id, e1id ) );
geometry.faces.push(new THREE.Face3(e2id, s2id, e1id ) );
geometry.faces.push(new THREE.Face3(e2id, e1id, mId+3) );
- /*
- * geometry.faces.push(new THREE.Face3( 2, 3, 0 ));
- * geometry.faceVertexUvs[0].push([ new THREE.UV(1,1), new THREE.UV(1,0), new THREE.UV(0,1) ]);
- */
//console.log(geometry, cubeMaterial);
geometry.computeFaceNormals();
var mesh = new THREE.Mesh(geometry, cubeMaterial);
Modified: JSFloorPlan/trunk/jsfloorplan_example_helper.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan_example_helper.js 2011-12-15 18:31:12 UTC (rev 577)
+++ JSFloorPlan/trunk/jsfloorplan_example_helper.js 2011-12-16 14:24:07 UTC (rev 578)
@@ -113,7 +113,7 @@
cube.position = new THREE.Vector3(50,50,50);
//scene.add( cube );
-//cubeMaterial = new THREE.MeshBasicMaterial({ map: THREE.ImageUtils.loadTexture( 'media/demo_texture_512x512.png' ) });
+cubeMaterial = new THREE.MeshBasicMaterial({ map: THREE.ImageUtils.loadTexture( 'media/demo_texture_512x512.png' ) });
var lineMaterial = new THREE.LineBasicMaterial( { color: 0x0099ff, linewidth: 2 } );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-16 22:44:09
|
Revision: 581
http://openautomation.svn.sourceforge.net/openautomation/?rev=581&view=rev
Author: mayerch
Date: 2011-12-16 22:44:03 +0000 (Fri, 16 Dec 2011)
Log Message:
-----------
Lighting and finally add the faces in the wall holes
Modified Paths:
--------------
JSFloorPlan/trunk/index.html
JSFloorPlan/trunk/jsfloorplan.js
Modified: JSFloorPlan/trunk/index.html
===================================================================
--- JSFloorPlan/trunk/index.html 2011-12-16 22:43:35 UTC (rev 580)
+++ JSFloorPlan/trunk/index.html 2011-12-16 22:44:03 UTC (rev 581)
@@ -39,7 +39,24 @@
</td>
<td>
Entfernung</td><td><div style="width:150px;" height="100" id="distSlider"></div>
- </td></tr>
+ </td>
+ <td>
+ </td>
+ </tr>
+ <tr style="border: 1px black;">
+ <td>
+ Licht Richtung</td><td><div style="width:150px;" height="100" id="lightDirectionSlider"></div>
+ </td>
+ <td>
+ Licht Höhe</td><td><div style="width:150px;" height="100" id="lightHeightSlider"></div>
+ </td>
+ <td>
+ Licht Stärke</td><td><div style="width:150px;" height="100" id="lightStrengthSlider"></div>
+ </td>
+ <td>
+ Licht Entfernung</td><td><div style="width:150px;" height="100" id="lightDistanceSlider"></div>
+ </td>
+ </tr>
</table>
<hr />
<h2>Status Infos:</h2>
@@ -90,6 +107,7 @@
</td><td>
Zeige Wireframe: <input type="checkbox" name="showWireframe" />
</td><td>
+ Licht-Sicht: <input type="checkbox" name="showLightView" />
</td><td>
</td><td>
</td>
Modified: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-16 22:43:35 UTC (rev 580)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-16 22:44:03 UTC (rev 581)
@@ -313,8 +313,8 @@
var wallLength = calcLength2D( sm, em );
var fLeft = holes[h].distance / wallLength;
var fRight = (holes[h].distance + holes[h].width) / wallLength;
- if( fLeft < 0.0 ) fLeft = 0.01; //// FIXME
- if( fRight > 1.0 ) fRight = 0.99; //// FIXME
+ if( fLeft <= 0.0 ) fLeft = 0.001; //// FIXME - actually the config file is bad. Leave at least 1mm wall
+ if( fRight >= 1.0 ) fRight = 0.999; //// FIXME - actually the config file is bad. Leave at least 1mm wall
var lintel = (sh - holes[h].lintel) / sh;
var paparet = holes[h].paparet / sh;
if( 1 == lintel )
@@ -323,12 +323,9 @@
if( paparet == 0 ) continue; // FIXME: Assume paparet != 0 - otherwise it should be two walls...
- console.log( sourrounding );
sourrounding.splice( -2, 0, new poly2tri.Point(fLeft,1), new poly2tri.Point(fLeft,paparet), new poly2tri.Point(fRight,paparet), new poly2tri.Point(fRight,1) );
- console.log( sourrounding );
continue;
}
- //if( 0 == paparet ) paparet = 0.01; //// FIXME
if( 0 == paparet )
{
// not a hole, the sourrounding goes to the groud...
@@ -342,7 +339,7 @@
holesToAdd.push( [new poly2tri.Point(fLeft,paparet), new poly2tri.Point(fRight,paparet), new poly2tri.Point(fRight,lintel), new poly2tri.Point(fLeft,lintel)] );
}
} // if( floorWalls[j].holes.length )
- var swctx = new poly2tri.SweepContext( sourrounding );
+ var swctx = new poly2tri.SweepContext( sourrounding.slice(0) ); // pass a copy of sourrounding
for( var htA = 0; htA < holesToAdd.length; htA++ )
swctx.AddHole( holesToAdd[htA] );
@@ -416,10 +413,28 @@
geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(em.x,em.y,heightOfGround )));
geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(em.x,em.y,heightOfGround+eh)));
geometry.faces.push(new THREE.Face3(s1id, s2id, mId+1) );
- geometry.faces.push(new THREE.Face3(s2id, s1id, e1id ) );
- geometry.faces.push(new THREE.Face3(e2id, s2id, e1id ) );
geometry.faces.push(new THREE.Face3(e2id, e1id, mId+3) );
- //console.log(geometry, cubeMaterial);
+
+ for( var e = 0; e < sourrounding.length; e++ )
+ {
+ var id1 = sourrounding[e ].id;
+ var id2 = sourrounding[(e+1)%sourrounding.length].id;
+ geometry.faces.push(new THREE.Face3( id1, id2 , id1 + wall1verticesLength) );
+ geometry.faces.push(new THREE.Face3( id2, id2 + wall1verticesLength, id1 + wall1verticesLength) );
+ }
+
+ // hole sides
+ for( var hta = 0; hta < holesToAdd.length; hta++ )
+ {
+ for( var e = 0; e < holesToAdd[hta].length; e++ )
+ {
+ var id1 = holesToAdd[hta][e ].id;
+ var id2 = holesToAdd[hta][(e+1)%sourrounding.length].id;
+ geometry.faces.push(new THREE.Face3( id1, id2 , id1 + wall1verticesLength) );
+ geometry.faces.push(new THREE.Face3( id2, id2 + wall1verticesLength, id1 + wall1verticesLength) );
+ }
+ }
+
geometry.computeFaceNormals();
var mesh = new THREE.Mesh(geometry, cubeMaterial);
mesh.castShadow = true;
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:23:17
|
Revision: 586
http://openautomation.svn.sourceforge.net/openautomation/?rev=586&view=rev
Author: mayerch
Date: 2011-12-18 13:23:11 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
Prepare for restructuring
Added Paths:
-----------
JSFloorPlan/trunk/build/
JSFloorPlan/trunk/docs/
JSFloorPlan/trunk/release/
JSFloorPlan/trunk/src/
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:27:46
|
Revision: 588
http://openautomation.svn.sourceforge.net/openautomation/?rev=588&view=rev
Author: mayerch
Date: 2011-12-18 13:27:38 +0000 (Sun, 18 Dec 2011)
Log Message:
-----------
Clean up structure by moving source to src
Modified Paths:
--------------
JSFloorPlan/trunk/index.html
Added Paths:
-----------
JSFloorPlan/trunk/src/jsfloorplan.js
JSFloorPlan/trunk/src/jsfloorplan_example_helper.js
Removed Paths:
-------------
JSFloorPlan/trunk/jsfloorplan.js
JSFloorPlan/trunk/jsfloorplan_example_helper.js
Modified: JSFloorPlan/trunk/index.html
===================================================================
--- JSFloorPlan/trunk/index.html 2011-12-18 13:24:06 UTC (rev 587)
+++ JSFloorPlan/trunk/index.html 2011-12-18 13:27:38 UTC (rev 588)
@@ -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="jsfloorplan_example_helper.js" type="text/javascript"></script>
-<script 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" />
<!-- -->
Deleted: JSFloorPlan/trunk/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan.js 2011-12-18 13:24:06 UTC (rev 587)
+++ JSFloorPlan/trunk/jsfloorplan.js 2011-12-18 13:27:38 UTC (rev 588)
@@ -1,684 +0,0 @@
-/***************************************************************************
- * *
- * JavaScript FloorPlan 3D *
- * *
- * Copyright (C) 2009, 2010 by Christian Mayer *
- * jsfloorplan (at) ChristianMayer.de *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- * *
- ***************************************************************************/
-
-// setup script here:
-
-// don't change anything below:
-var ELEMENT_NODE = 1;
-
-// calculate the distance between two cartesian 2D points
-function calcLength2D( start, end )
-{
- return Math.sqrt( (end.x-start.x)*(end.x-start.x) +
- (end.y-start.y)*(end.y-start.y) );
-}
-
-// calculate the rotation of a cartesian 2D point around the center
-function rotate2D( angle, point, center )
-{
- var s = Math.sin( angle );
- var c = Math.cos( angle );
- var ret = new Object;
- ret.x = center.x + c * (point.x-center.x) - s * (point.y-center.y);
- ret.y = center.y + s * (point.x-center.x) + c * (point.y-center.y);
- return ret;
-}
-
-// calculate the rotation of a cartesian 2D point around the center
-// but with given sin and cos of the angle
-function rotate2D( s, c, point, center )
-{
- var ret = new Object;
- ret.x = center.x + c * (point.x-center.x) - s * (point.y-center.y);
- ret.y = center.y + s * (point.x-center.x) + c * (point.y-center.y);
- return ret;
-}
-
-// calculate the translation of a cartesian 2D point
-function translate2D( point, translation )
-{
- var ret = new Object;
- ret.x = point.x + translation.x;
- ret.y = point.y + translation.y;
- return ret;
-}
-
-// sort two 2D unit(!) vectors clockwise
-function vecSort( a, b )
-{
- var pseudoangle_a = a.y>=0 ? (1-a.x) : (a.x+3);
- var pseudoangle_b = b.y>=0 ? (1-b.x) : (b.x+3);
- return pseudoangle_a - pseudoangle_b;
-}
-
-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() };
-var imageCenter = new Object;
-
-var noFloorplan = true;
-function parseXMLFloorPlan( xmlDoc )
-{
- noFloorplan = false;
-
- var floorCount = -1;
- var heightOfGround = 0; // the base level of the current floor
-
- // basic check if the document seems right
- // this could be avoided if the XML file would be validated
- // with a DTD
- var building;
- if( 'building' == xmlDoc.documentElement.tagName )
- building = xmlDoc.documentElement;
- else
- return alert( "ERROR: Not a valid floor plan! " +
- "Expected: 'building', found '" + xmlDoc.documentElement.tagName + "'" );
-
- // now we are sure to have a sensible file
- // => iterate over all floors
- for( var i=0; i < building.childNodes.length; i++ )
- {
- floor = building.childNodes[i];
- if (floor.nodeType != ELEMENT_NODE) continue;
-
- if( floor.tagName == 'textures' )
- {
- parseTextures( floor );
- continue;
- }
-
- if( floor.tagName != 'floor' )
- return alert( "ERROR: Not a valid floor plan! " +
- "Expected: 'floor', found '" + floor.tagName + "'" );
-
- floorCount++;
- buildingProperties.floor[floorCount] = {};
-
- var floorName = floor.getAttribute('name');
- buildingProperties.floor[floorCount].name = floorName;
-
- var floorheight = Number( floor.getAttribute('height') );
- buildingProperties.floor[floorCount].height = floorheight;
- buildingProperties.floor[floorCount].heightOfGround = heightOfGround;
-
- var floorWallsStart = floorWalls.length;
-
- // iterate over the content of this floor
- for( var j=0; j < floor.childNodes.length; j++ )
- {
- floorNode = floor.childNodes[j];
- if (floorNode.nodeType != ELEMENT_NODE) continue;
-
- switch( floorNode.tagName )
- {
- case 'nodes':
- parseFloorNodes( floorNode, floorheight );
- break;
-
- case 'walls':
- parseFloorWalls( floorNode );
- break;
-
- case 'rooms':
- parseFloorRooms( floorNode, floorCount );
- break;
- }
- }
-
- // now the content of the floor is stored in easily
- // accessable objects
- // => derive the necessary information
-
- // group all elements on this floor
- var Object3D = new THREE.Object3D();
-
- // add the information to each node to which nodes it's connected to
- for( var j = floorWallsStart; j < floorWalls.length; j++ )
- {
- // note: the ID is shifted by one to avoid an ID of zero
- // as that wouldn't allow me anymore to distinguish
- // start and stop
- floorNodes[ floorWalls[j].start ].neighbour.push( j+1 );
- floorNodes[ floorWalls[j].end ].neighbour.push( -j-1 );
- }
-
- var nodeGroup = new THREE.Object3D(); nodeGroup.name = 'nodeGroup';
- for( var id in floorNodes )
- {
- // calculate the vectors showing to the neighbours
- var vectors = new Array();
- var start = floorNodes[id];
-
- // show them on request as spheres
- var sphere = new THREE.Mesh( new THREE.SphereGeometry(0.1, 4, 4), sphereMaterial);
- sphere.position = new THREE.Vector3( start.x, start.y, heightOfGround );
- nodeGroup.add(sphere);
-
- for( var j=0; j<floorNodes[id].neighbour.length; j++ )
- {
- var vec = new Object;
- vec.id = floorNodes[id].neighbour[j];
- var end;
- if( vec.id < 0 )
- end = floorNodes[ floorWalls[ -vec.id-1 ].start ];
- else
- end = floorNodes[ floorWalls[ vec.id-1 ].end ];
-
- length = calcLength2D( start, end );
- vec.x = (end.x - start.x) / length;
- vec.y = (end.y - start.y) / length;
- vectors.push( vec );
- }
-
- // sort them clockwise
- vectors.sort( vecSort );
-
- // calculate the cutting points of the walls at this node id
- for( var j=0; j<vectors.length; j++ )
- {
- var jj = (j+1) % vectors.length;
- var wj = Math.abs(vectors[j ].id)-1;
- var wjj = Math.abs(vectors[jj].id)-1;
- var dj = floorWalls[wj ].thickness/2;
- var djj = floorWalls[wjj].thickness/2;
- if( floorWalls[wj ].startOffset && vectors[j ].id > 0 )
- dj += floorWalls[wj].startOffset;
- if( floorWalls[wj ].endOffset && vectors[j ].id < 0 )
- dj += floorWalls[wj].endOffset;
- if( floorWalls[wjj].startOffset && vectors[jj].id > 0 )
- djj += -floorWalls[wjj].startOffset;
- if( floorWalls[wjj].endOffset && vectors[jj].id < 0 )
- djj += -floorWalls[wjj].endOffset;
-
- vertex = new Object;
- vertex.x = vectors[j].x*djj + vectors[jj].x*dj;
- vertex.y = vectors[j].y*djj + vectors[jj].y*dj;
- var l = vectors[j].x*vectors[jj].y - vectors[j].y*vectors[jj].x;
- if( Math.abs( l ) < 1e-5 )
- { // the angle between the two vectors is exactly 180°
- // i.e. a straight wall...
- if( Math.abs( dj - djj ) < 1e-5 )
- { // at least the walls have the same thickness...
- vertex.x = start.x - vectors[j].y*dj;
- vertex.y = start.y + vectors[j].x*dj;
- } else {
- alert( "ERROR: A straight wall with different thicknesses " +
- "is currently not supported!" );
- // but we still try our best...
- vertex.x = start.x - vectors[j].y*(dj+djj)/2;
- vertex.y = start.y + vectors[j].x*(dj+djj)/2;
- }
- } else {
- vertex.x = start.x + vertex.x / l;
- vertex.y = start.y + vertex.y / l;
- }
-
- if( vectors[j ].id < 0 )
- floorWalls[wj ].startVertex.push( vertices.length );
- else
- floorWalls[wj ].endVertex.push( vertices.length );
-
- if( 1 == vectors.length )
- {
- var additional = new Object;
- additional.x = 2 * start.x - vertex.x;
- additional.y = 2 * start.y - vertex.y;
- vertices.push( additional );
- }
-
- if( vectors[jj].id < 0 )
- floorWalls[wjj].startVertex.push( vertices.length );
- else
- floorWalls[wjj].endVertex.push( vertices.length );
-
- vertices.push( vertex );
- }
- } // end for( var id in floorNodes )
- Object3D.add( nodeGroup );
-
- // show walls
- var lineGroup = new THREE.Object3D(); lineGroup.name = 'lineGroup';
- var wallGroup = new THREE.Object3D(); wallGroup.name = 'wallGroup';
- for( var j = floorWallsStart; j<floorWalls.length; j++ )
- {
- var vs = floorNodes[ floorWalls[j].start ];
- var ve = floorNodes[ floorWalls[j].end ];
- var lineGeo = new THREE.Geometry();
- lineGeo.vertices.push( new THREE.Vertex( new THREE.Vector3( vs.x, vs.y, heightOfGround ) ) );
- lineGeo.vertices.push( new THREE.Vertex( new THREE.Vector3( ve.x, ve.y, heightOfGround ) ) );
- lineGroup.add( new THREE.Line( lineGeo, lineMaterial ) );
-
- var s1 = vertices[ floorWalls[j].startVertex[0] ];
- var e1 = vertices[ floorWalls[j].endVertex [0] ];
- var s2 = vertices[ floorWalls[j].startVertex[1] ];
- var e2 = vertices[ floorWalls[j].endVertex [1] ];
-
- // check that the start and end points aren't twisted
- 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] ];
- }
- 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 wallSideOrder = (s2.x-s1.x)*(e1.y-s1.y) - (s2.y-s1.y)*(e1.x-s1.x);
- var geometry = new THREE.Geometry();
-
- var normal1 = new THREE.Vector3(sm.y-em.y,-sm.x+em.x,0); // fixme? normalize
- var normal2 = new THREE.Vector3(1,0,0);
-
- var sourrounding = [ new poly2tri.Point(0,0), new poly2tri.Point(0,1), new poly2tri.Point(1,1), new poly2tri.Point(1,0) ];
- sourrounding[1].startEndMarker = 'start';
- sourrounding[2].startEndMarker = 'end';
- var holesToAdd = [];
-
- if( floorWalls[j].holes.length )
- {
- var holes = floorWalls[j].holes;
- for( var h = 0; h < holes.length; h++ )
- {
- var wallLength = calcLength2D( sm, em );
- var fLeft = holes[h].distance / wallLength;
- var fRight = (holes[h].distance + holes[h].width) / wallLength;
- if( fLeft <= 0.0 ) fLeft = 0.001; //// FIXME - actually the config file is bad. Leave at least 1mm wall
- if( fRight >= 1.0 ) fRight = 0.999; //// FIXME - actually the config file is bad. Leave at least 1mm wall
- var lintel = (sh - holes[h].lintel) / sh;
- var paparet = holes[h].paparet / sh;
- if( 1 == lintel )
- {
- // not a hole, the sourrounding goes to the groud...
-
- if( paparet == 0 ) continue; // FIXME: Assume paparet != 0 - otherwise it should be two walls...
-
- sourrounding.splice( -2, 0, new poly2tri.Point(fLeft,1), new poly2tri.Point(fLeft,paparet), new poly2tri.Point(fRight,paparet), new poly2tri.Point(fRight,1) );
- continue;
- }
- if( 0 == paparet )
- {
- // not a hole, the sourrounding goes to the groud...
-
- // lintel == 1 can't happen, it's checked in the if clause above
-
- sourrounding.splice( 0, 0, new poly2tri.Point(fRight,0), new poly2tri.Point(fRight,lintel), new poly2tri.Point(fLeft,lintel), new poly2tri.Point(fLeft,0) );
- continue;
- }
-
- holesToAdd.push( [new poly2tri.Point(fLeft,paparet), new poly2tri.Point(fRight,paparet), new poly2tri.Point(fRight,lintel), new poly2tri.Point(fLeft,lintel)] );
- }
- } // if( floorWalls[j].holes.length )
- var swctx = new poly2tri.SweepContext( sourrounding.slice(0) ); // pass a copy of sourrounding
- for( var htA = 0; htA < holesToAdd.length; htA++ )
- swctx.AddHole( holesToAdd[htA] );
-
- // Do the triangulation - FIXME: handle exceptions, don't ignore them...
- try {
- poly2tri.sweep.Triangulate(swctx);
- }catch(err){}
-
- // mark all points to make sure that we don't need to double vertices
- for( var tp = 0; tp < swctx.point_count(); tp++ )
- swctx.GetPoint( tp ).id = tp;
-
- // translate poly2tri triangles to THREE.js faces:
- var p2tF = [];
- $.each(swctx.GetTriangles(), function(idx, val) {
- p2tF.push(new THREE.Face3(val.GetPoint(0).id, val.GetPoint(1).id, val.GetPoint(2).id));
- });
-
- Tvertices = swctx.points_;
- Tfaces = p2tF;
- var wall1vertices = [];
- var wall2vertices = [];
- 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 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 )
- {
- wall1vertices.push(new THREE.Vertex(new THREE.Vector3(x1,y1,z), normal1));
- wall2vertices.push(new THREE.Vertex(new THREE.Vector3(x2,y2,z), normal1));
- } else {
- wall1vertices.push(new THREE.Vertex(new THREE.Vector3(x2,y2,z), normal1));
- wall2vertices.push(new THREE.Vertex(new THREE.Vector3(x1,y1,z), normal1));
- }
- if( 'startEndMarker' in tv )
- {
- if( 'start' == tv.startEndMarker )
- {
- sId = wall1vertices.length - 1;
- } else {
- eId = wall1vertices.length - 1;
- }
- }
- }
- var wall1verticesLength = wall1vertices.length;
- geometry.vertices = wall1vertices.concat( wall2vertices );
- var s1id = sId, s2id = sId + wall1verticesLength, e1id = eId, e2id = eId + wall1verticesLength;
- //geometry.faces = Tfaces;
- for( var f = 0; f < Tfaces.length; f++ )
- {
- 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_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_a2, uv_b2, uv_c2 ]);
- }
- // wall top
- var mId = geometry.vertices.length;
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(sm.x,sm.y,heightOfGround )));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(sm.x,sm.y,heightOfGround+sh)));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(em.x,em.y,heightOfGround )));
- geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(em.x,em.y,heightOfGround+eh)));
- geometry.faces.push(new THREE.Face3(s1id, s2id, mId+1) );
- geometry.faces.push(new THREE.Face3(e2id, e1id, mId+3) );
-
- for( var e = 0; e < sourrounding.length; e++ )
- {
- var id1 = sourrounding[e ].id;
- var id2 = sourrounding[(e+1)%sourrounding.length].id;
- geometry.faces.push(new THREE.Face3( id1, id2 , id1 + wall1verticesLength) );
- geometry.faces.push(new THREE.Face3( id2, id2 + wall1verticesLength, id1 + wall1verticesLength) );
- }
-
- // hole sides
- for( var hta = 0; hta < holesToAdd.length; hta++ )
- {
- for( var e = 0; e < holesToAdd[hta].length; e++ )
- {
- var id1 = holesToAdd[hta][e ].id;
- var id2 = holesToAdd[hta][(e+1)%sourrounding.length].id;
- geometry.faces.push(new THREE.Face3( id1, id2 , id1 + wall1verticesLength) );
- geometry.faces.push(new THREE.Face3( id2, id2 + wall1verticesLength, id1 + wall1verticesLength) );
- }
- }
-
- 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 );
- 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!
-
- 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;
-
- show3D( 35*Math.PI/180, 30*Math.PI/180 );
-}
-
-var floorNodes = new Object();
-function parseFloorNodes( nodes, floorheight )
-{
- for( var i=0; i < nodes.childNodes.length; i++ )
- {
- node = nodes.childNodes[i];
- if (node.nodeType != ELEMENT_NODE) continue;
-
- var id = node.getAttribute('id');
- var point = new Object;
- point.x = Number( node.getAttribute('x') );
- point.y = Number( node.getAttribute('y') );
- point.z = Number( node.hasAttribute('z') ? node.getAttribute('z') : floorheight );
- point.neighbour = new Array;
-
- floorNodes[id] = point;
-
- if( undefined == 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;
- } 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;
- }
- }
-}
-
-var floorWalls = new Array();
-function parseFloorWalls( nodes )
-{
- for( var i=0; i < nodes.childNodes.length; i++ )
- {
- node = nodes.childNodes[i];
- if (node.nodeType != ELEMENT_NODE) continue;
-
- var wall = new Object;
- wall.start = node.getAttribute('start' );
- wall.startVertex = new Array;
- wall.startOffset = Number( node.getAttribute('startoffset') );
- wall.end = node.getAttribute('end' );
- wall.endVertex = new Array;
- wall.endOffset = Number( node.getAttribute('endoffset' ) );
- wall.thickness = Number( node.getAttribute('thickness' ) );
- wall.texture = node.getAttribute('texture' );
- if( !wall.texture ) wall.texture = 0;
-
- wall.holes = new Array;
- for( var j=0; j < node.childNodes.length; j++ )
- {
- var hole = node.childNodes[j];
- if (hole.nodeType != ELEMENT_NODE) continue;
-
- var thishole = new Object;
- thishole.id = hole.getAttribute('id');
- thishole.distance = Number( hole.getAttribute('distance') );
- thishole.width = Number( hole.getAttribute('width' ) );
- thishole.paparet = Number( hole.getAttribute('paparet' ) );
- thishole.lintel = Number( hole.getAttribute('lintel' ) );
- wall.holes.push( thishole );
- }
-
- floorWalls[floorWalls.length] = wall;
- }
-}
-
-var rooms = new Array;
-function parseFloorRooms( nodes, floor )
-{
- rooms[floor] = new Array;
- for( var i=0; i < nodes.childNodes.length; i++ )
- {
- var node = nodes.childNodes[i];
- if (node.nodeType != ELEMENT_NODE) continue;
-
- var room = new Object;
- room.name = node.getAttribute('name');
- room.zones = new Array;
-
- for( var j=0; j < node.childNodes.length; j++ )
- {
- var zone = node.childNodes[j];
- if (zone.nodeType != ELEMENT_NODE) continue;
-
- var thiszone = new Object;
- thiszone.onclick = zone.getAttribute('onclick');
- thiszone.name = zone.getAttribute('name' );
- thiszone.corners = new Array;
-
- for( var k=0; k < zone.childNodes.length; k++ )
- {
- var corner = zone.childNodes[k];
- if (corner.nodeType != ELEMENT_NODE) continue;
- thiszone.corners.push( corner.getAttribute('nodeid') );
- }
- room.zones.push( thiszone );
- }
- rooms[floor].push( room );
- }
-}
-
-//var textures = new Object();
-function parseTextures( nodes )
-{
- return;
- for( var i=0; i < nodes.childNodes.length; i++ )
- {
- node = nodes.childNodes[i];
- if (node.nodeType != ELEMENT_NODE) continue;
- }
-}
-
-var noSetup = true;
-function setup3D()
-{
- if( noFloorplan ) return;
- noSetup = false;
-
- scene.add( buildingProperties.Object3D );
-
- var showFloor = showStates.showFloor;
-
- ///////////
- scene.add(sunLight);
- //scene.add(pointLight);
- scene.add(ambientLight);
- //scene.add( camera );
- var $container = $('#top_level');
- // attach the render-supplied DOM element
- $container.append(renderer.domElement);
-
- // Init after the scene was set up
- selectChange( 'showNodes' );
- selectChange( 'showWallLines' );
- selectChange( 'showFloor' );
-}
-
-function show3D( rotation, tilt )
-{
- if( noSetup ) setup3D();
-
- // set up camera
- 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);
- 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( 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;
-
- // update color
- switch( showStates.fillColor )
- {
- case 'black':
- cubeMaterial.color.setRGB( 0.1, 0.1, 0.1 );
- break;
- case 'grey':
- cubeMaterial.color.setRGB( 0.5, 0.5, 0.5 );
- break;
- case 'white':
- cubeMaterial.color.setRGB( 1.0, 1.0, 1.0 );
- break;
- case 'blue':
- cubeMaterial.color.setRGB( 0.0, 0.0, 0.8 );
- break;
- case 'red':
- cubeMaterial.color.setRGB( 0.8, 0.0, 0.0 );
- break;
- case 'green':
- cubeMaterial.color.setRGB( 0.0, 0.8, 0.0 );
- break;
- };
-
- render();
-}
\ No newline at end of file
Deleted: JSFloorPlan/trunk/jsfloorplan_example_helper.js
===================================================================
--- JSFloorPlan/trunk/jsfloorplan_example_helper.js 2011-12-18 13:24:06 UTC (rev 587)
+++ JSFloorPlan/trunk/jsfloorplan_example_helper.js 2011-12-18 13:27:38 UTC (rev 588)
@@ -1,510 +0,0 @@
-/***************************************************************************
- * *
- * JavaScript FloorPlan 3D - helper functions for the example *
- * *
- * Copyright (C) 2009 by Christian Mayer *
- * jsfloorplan (at) ChristianMayer.de *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the ...
[truncated message content] |
|
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.
|
|
From: <ma...@us...> - 2011-12-20 21:20:45
|
Revision: 606
http://openautomation.svn.sourceforge.net/openautomation/?rev=606&view=rev
Author: mayerch
Date: 2011-12-20 21:20:36 +0000 (Tue, 20 Dec 2011)
Log Message:
-----------
add relevant parts for a YUI Doc documentation
Added Paths:
-----------
JSFloorPlan/trunk/build/template/
JSFloorPlan/trunk/build/template/assets/
JSFloorPlan/trunk/build/template/assets/ac-js
JSFloorPlan/trunk/build/template/assets/api-js
JSFloorPlan/trunk/build/template/assets/api.css
JSFloorPlan/trunk/build/template/assets/bg_hd.gif
JSFloorPlan/trunk/build/template/assets/coordinate_system.png
JSFloorPlan/trunk/build/template/assets/reset-fonts-grids-min.css
JSFloorPlan/trunk/build/template/classmap.tmpl
JSFloorPlan/trunk/build/template/index.tmpl
JSFloorPlan/trunk/build/template/main.tmpl
Property Changed:
----------------
JSFloorPlan/trunk/
Property changes on: JSFloorPlan/trunk
___________________________________________________________________
Added: svn:ignore
+ parser
Added: JSFloorPlan/trunk/build/template/assets/ac-js
===================================================================
--- JSFloorPlan/trunk/build/template/assets/ac-js (rev 0)
+++ JSFloorPlan/trunk/build/template/assets/ac-js 2011-12-20 21:20:36 UTC (rev 606)
@@ -0,0 +1,178 @@
+(function() {
+
+ var Event=YAHOO.util.Event,
+ Dom=YAHOO.util.Dom,
+ oACDS, oAutoComp,
+ show = {
+ 'private': false,
+ 'protected': false,
+ 'deprecated': false
+ },
+
+ ITEM_TEMPLATE = '<em>{host}</em> <span>{name}</span>',
+ // ITEM_TEMPLATE = '<em>{host}</em> <span>{params}</span> <span>{name}</span>',
+ // ITEM_TEMPLATE = '<em>{host}</em> <span>{params}</span> <span>{name}</span><div>{description}</div>',
+ yuidoc = YAHOO.namespace('yuidoc'),
+ propdata,
+ initialized = false;
+
+yuidoc.init = function(altdata) {
+ yuidoc.initUI(altdata);
+};
+
+yuidoc.initUI = function(altdata) {
+
+ if (initialized) {
+ return;
+ }
+
+ propdata = ALL_YUI_PROPS || altdata;
+
+ //Checkboxes are available..
+ var handleClick = function(e) {
+ var id, checked = false;
+ if (YAHOO.lang.isString(e)) {
+ id = e;
+ } else {
+ var tar = Event.getTarget(e);
+ id = tar.id;
+ }
+ var el = Dom.get(id);
+ checked = el.checked;
+
+ var className = id;
+ if (checked) {
+ show[id.replace('show_', '')] = true;
+ Dom.addClass(document.body, className);
+ YAHOO.util.Cookie.setSub('yuidoc', id, 'checked');
+ } else {
+ show[id.replace('show_', '')] = false;
+ Dom.removeClass(document.body, className);
+ YAHOO.util.Cookie.setSub('yuidoc', id, '');
+ }
+ };
+
+ var checkCookie = function(id) {
+ var value = YAHOO.util.Cookie.getSub('yuidoc', id),
+ el = Dom.get(id), checked = (value === 'checked');;
+
+ el.checked = checked;
+ return checked;
+ };
+
+ var els = ['show_deprecated', 'show_protected', 'show_private'],
+ reapplyHash = false;
+
+ for (var i = 0; i < els.length; i++) {
+ Event.on(els[i], 'click', handleClick);
+ reapplyHash = checkCookie(els[i]) || reapplyHash;
+ handleClick(els[i]);
+ }
+
+ // If we dynamically show private/protected/etc items during
+ // load, we need to reapply anchors so that the search feature
+ // works correctly for items that are initially hidden.
+ if (reapplyHash) {
+ var dl = document.location, hash = dl.hash;
+ if (hash) {
+ dl.hash = hash;
+ }
+ }
+
+};
+
+//Starting the AutoComplete code
+ var getResults = function(query) {
+ var results = [];
+ if (query && query.length > 0) {
+ var q = query.toLowerCase();
+ for (var i=0, len=propdata.length; i<len; ++i) {
+ var prop = propdata[i];
+ if (!show['protected'] && prop.access == "protected") {
+ // skip
+ } else if (!show['private'] && prop.access == "private") {
+ // skip
+ } else if (!show['deprecated'] && prop.deprecated) {
+ // skip
+ } else {
+ var s = (prop.host + "." + prop.name).toLowerCase();
+ if (s.indexOf(q) > -1 ) {
+ results.push([query, prop]);
+ }
+ }
+ }
+ }
+
+ return results;
+ };
+
+ // Define Custom Event handlers
+ var myOnDataReturn = function(sType, aArgs) {
+ var oAutoComp = aArgs[0];
+ var query = aArgs[1];
+ var aResults = aArgs[2];
+
+ if(aResults.length == 0) {
+ if (query.length > 0) {
+ oAutoComp.setBody("<div id=\"resultsdefault\">Not found</div>");
+ }
+ }
+ };
+
+ var myOnItemSelect = function(sType, aArgs) {
+ var ac = aArgs[0];
+ var item = aArgs[2];
+ location.href = item[1].url;
+ };
+
+
+ Event.onAvailable("searchresults", function() {
+
+ // Instantiate JS Function DataSource
+ oACDS = new YAHOO.widget.DS_JSFunction(getResults);
+ oACDS.maxCacheEntries = 30;
+
+ // Instantiate AutoComplete
+ oAutoComp = new YAHOO.widget.AutoComplete('searchinput','searchresults', oACDS);
+ //oAutoComp.alwaysShowContainer = true;
+ oAutoComp.queryDelay = 0.2;
+ oAutoComp.maxResultsDisplayed = 200;
+ oAutoComp.minQueryLength = 0;
+ oAutoComp.formatResult = function(oResultItem, query) {
+ // var sMarkup = "<em>" + oResultItem[1].host + '</em> <span>' + oResultItem[1].name + '</span>';
+ // return sMarkup;
+ // return "<em>" + oResultItem[1].host + '</em> <span>' + oResultItem[1].name + '</span>';
+ return YAHOO.lang.substitute(ITEM_TEMPLATE, oResultItem[1]);
+ };
+
+ // Subscribe to Custom Events
+ oAutoComp.dataReturnEvent.subscribe(myOnDataReturn);
+ oAutoComp.itemSelectEvent.subscribe(myOnItemSelect);
+
+ // Set initial content in the container
+ oAutoComp.sendQuery(Dom.get("searchinput").value);
+
+ });
+
+ var validateForm = function() {
+ return false;
+ };
+
+ YAHOO.util.Event.onAvailable('classTab', function() {
+ var tabs = new YAHOO.widget.TabView('classTab');
+ });
+
+ /*
+ YAHOO.util.Event.onAvailable('codeTree', function() {
+ var tree1 = new YAHOO.widget.TreeView('codeTree');
+ tree1.render();
+ });
+ */
+
+ YAHOO.util.Event.onDOMReady(function() {
+ if (typeof ALL_YUI_PROPS != "undefined") {
+ YAHOO.yuidoc.initUI();
+ }
+ });
+
+})();
Added: JSFloorPlan/trunk/build/template/assets/api-js
===================================================================
--- JSFloorPlan/trunk/build/template/assets/api-js (rev 0)
+++ JSFloorPlan/trunk/build/template/assets/api-js 2011-12-20 21:20:36 UTC (rev 606)
@@ -0,0 +1,42 @@
+/*
+Copyright (c) 2009, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 2.7.0
+*/
+if(typeof YAHOO=="undefined"||!YAHOO){var YAHOO={};}YAHOO.namespace=function(){var A=arguments,E=null,C,B,D;for(C=0;C<A.length;C=C+1){D=(""+A[C]).split(".");E=YAHOO;for(B=(D[0]=="YAHOO")?1:0;B<D.length;B=B+1){E[D[B]]=E[D[B]]||{};E=E[D[B]];}}return E;};YAHOO.log=function(D,A,C){var B=YAHOO.widget.Logger;if(B&&B.log){return B.log(D,A,C);}else{return false;}};YAHOO.register=function(A,E,D){var I=YAHOO.env.modules,B,H,G,F,C;if(!I[A]){I[A]={versions:[],builds:[]};}B=I[A];H=D.version;G=D.build;F=YAHOO.env.listeners;B.name=A;B.version=H;B.build=G;B.versions.push(H);B.builds.push(G);B.mainClass=E;for(C=0;C<F.length;C=C+1){F[C](B);}if(E){E.VERSION=H;E.BUILD=G;}else{YAHOO.log("mainClass is undefined for module "+A,"warn");}};YAHOO.env=YAHOO.env||{modules:[],listeners:[]};YAHOO.env.getVersion=function(A){return YAHOO.env.modules[A]||null;};YAHOO.env.ua=function(){var C={ie:0,opera:0,gecko:0,webkit:0,mobile:null,air:0,caja:0},B=navigator.userAgent,A;if((/KHTML/).test(B)){C.webkit=1;}A=B.match(/AppleWebKit\/([^\s]*)/);if(A&&A[1]){C.webkit=parseFloat(A[1]);if(/ Mobile\//.test(B)){C.mobile="Apple";}else{A=B.match(/NokiaN[^\/]*/);if(A){C.mobile=A[0];}}A=B.match(/AdobeAIR\/([^\s]*)/);if(A){C.air=A[0];}}if(!C.webkit){A=B.match(/Opera[\s\/]([^\s]*)/);if(A&&A[1]){C.opera=parseFloat(A[1]);A=B.match(/Opera Mini[^;]*/);if(A){C.mobile=A[0];}}else{A=B.match(/MSIE\s([^;]*)/);if(A&&A[1]){C.ie=parseFloat(A[1]);}else{A=B.match(/Gecko\/([^\s]*)/);if(A){C.gecko=1;A=B.match(/rv:([^\s\)]*)/);if(A&&A[1]){C.gecko=parseFloat(A[1]);}}}}}A=B.match(/Caja\/([^\s]*)/);if(A&&A[1]){C.caja=parseFloat(A[1]);}return C;}();(function(){YAHOO.namespace("util","widget","example");if("undefined"!==typeof YAHOO_config){var B=YAHOO_config.listener,A=YAHOO.env.listeners,D=true,C;if(B){for(C=0;C<A.length;C=C+1){if(A[C]==B){D=false;break;}}if(D){A.push(B);}}}})();YAHOO.lang=YAHOO.lang||{};(function(){var B=YAHOO.lang,F="[object Array]",C="[object Function]",A=Object.prototype,E=["toString","valueOf"],D={isArray:function(G){return A.toString.apply(G)===F;},isBoolean:function(G){return typeof G==="boolean";},isFunction:function(G){return A.toString.apply(G)===C;},isNull:function(G){return G===null;},isNumber:function(G){return typeof G==="number"&&isFinite(G);},isObject:function(G){return(G&&(typeof G==="object"||B.isFunction(G)))||false;},isString:function(G){return typeof G==="string";},isUndefined:function(G){return typeof G==="undefined";},_IEEnumFix:(YAHOO.env.ua.ie)?function(I,H){var G,K,J;for(G=0;G<E.length;G=G+1){K=E[G];J=H[K];if(B.isFunction(J)&&J!=A[K]){I[K]=J;}}}:function(){},extend:function(J,K,I){if(!K||!J){throw new Error("extend failed, please check that "+"all dependencies are included.");}var H=function(){},G;H.prototype=K.prototype;J.prototype=new H();J.prototype.constructor=J;J.superclass=K.prototype;if(K.prototype.constructor==A.constructor){K.prototype.constructor=K;}if(I){for(G in I){if(B.hasOwnProperty(I,G)){J.prototype[G]=I[G];}}B._IEEnumFix(J.prototype,I);}},augmentObject:function(K,J){if(!J||!K){throw new Error("Absorb failed, verify dependencies.");}var G=arguments,I,L,H=G[2];if(H&&H!==true){for(I=2;I<G.length;I=I+1){K[G[I]]=J[G[I]];}}else{for(L in J){if(H||!(L in K)){K[L]=J[L];}}B._IEEnumFix(K,J);}},augmentProto:function(J,I){if(!I||!J){throw new Error("Augment failed, verify dependencies.");}var G=[J.prototype,I.prototype],H;for(H=2;H<arguments.length;H=H+1){G.push(arguments[H]);}B.augmentObject.apply(this,G);},dump:function(G,L){var I,K,N=[],O="{...}",H="f(){...}",M=", ",J=" => ";if(!B.isObject(G)){return G+"";}else{if(G instanceof Date||("nodeType" in G&&"tagName" in G)){return G;}else{if(B.isFunction(G)){return H;}}}L=(B.isNumber(L))?L:3;if(B.isArray(G)){N.push("[");for(I=0,K=G.length;I<K;I=I+1){if(B.isObject(G[I])){N.push((L>0)?B.dump(G[I],L-1):O);}else{N.push(G[I]);}N.push(M);}if(N.length>1){N.pop();}N.push("]");}else{N.push("{");for(I in G){if(B.hasOwnProperty(G,I)){N.push(I+J);if(B.isObject(G[I])){N.push((L>0)?B.dump(G[I],L-1):O);}else{N.push(G[I]);}N.push(M);}}if(N.length>1){N.pop();}N.push("}");}return N.join("");},substitute:function(V,H,O){var L,K,J,R,S,U,Q=[],I,M="dump",P=" ",G="{",T="}",N;for(;;){L=V.lastIndexOf(G);if(L<0){break;}K=V.indexOf(T,L);if(L+1>=K){break;}I=V.substring(L+1,K);R=I;U=null;J=R.indexOf(P);if(J>-1){U=R.substring(J+1);R=R.substring(0,J);}S=H[R];if(O){S=O(R,S,U);}if(B.isObject(S)){if(B.isArray(S)){S=B.dump(S,parseInt(U,10));}else{U=U||"";N=U.indexOf(M);if(N>-1){U=U.substring(4);}if(S.toString===A.toString||N>-1){S=B.dump(S,parseInt(U,10));}else{S=S.toString();}}}else{if(!B.isString(S)&&!B.isNumber(S)){S="~-"+Q.length+"-~";Q[Q.length]=I;}}V=V.substring(0,L)+S+V.substring(K+1);}for(L=Q.length-1;L>=0;L=L-1){V=V.replace(new RegExp("~-"+L+"-~"),"{"+Q[L]+"}","g");}return V;},trim:function(G){try{return G.replace(/^\s+|\s+$/g,"");}catch(H){return G;}},merge:function(){var J={},H=arguments,G=H.length,I;for(I=0;I<G;I=I+1){B.augmentObject(J,H[I],true);}return J;},later:function(N,H,O,J,K){N=N||0;H=H||{};var I=O,M=J,L,G;if(B.isString(O)){I=H[O];}if(!I){throw new TypeError("method undefined");}if(!B.isArray(M)){M=[J];}L=function(){I.apply(H,M);};G=(K)?setInterval(L,N):setTimeout(L,N);return{interval:K,cancel:function(){if(this.interval){clearInterval(G);}else{clearTimeout(G);}}};},isValue:function(G){return(B.isObject(G)||B.isString(G)||B.isNumber(G)||B.isBoolean(G));}};B.hasOwnProperty=(A.hasOwnProperty)?function(G,H){return G&&G.hasOwnProperty(H);}:function(G,H){return !B.isUndefined(G[H])&&G.constructor.prototype[H]!==G[H];};D.augmentObject(B,D,true);YAHOO.util.Lang=B;B.augment=B.augmentProto;YAHOO.augment=B.augmentProto;YAHOO.extend=B.extend;})();YAHOO.register("yahoo",YAHOO,{version:"2.7.0",build:"1796"});(function(){YAHOO.env._id_counter=YAHOO.env._id_counter||0;var E=YAHOO.util,L=YAHOO.lang,m=YAHOO.env.ua,A=YAHOO.lang.trim,d={},h={},N=/^t(?:able|d|h)$/i,X=/color$/i,K=window.document,W=K.documentElement,e="ownerDocument",n="defaultView",v="documentElement",t="compatMode",b="offsetLeft",P="offsetTop",u="offsetParent",Z="parentNode",l="nodeType",C="tagName",O="scrollLeft",i="scrollTop",Q="getBoundingClientRect",w="getComputedStyle",a="currentStyle",M="CSS1Compat",c="BackCompat",g="class",F="className",J="",B=" ",s="(?:^|\\s)",k="(?= |$)",U="g",p="position",f="fixed",V="relative",j="left",o="top",r="medium",q="borderLeftWidth",R="borderTopWidth",D=m.opera,I=m.webkit,H=m.gecko,T=m.ie;E.Dom={CUSTOM_ATTRIBUTES:(!W.hasAttribute)?{"for":"htmlFor","class":F}:{"htmlFor":"for","className":g},get:function(y){var AA,Y,z,x,G;if(y){if(y[l]||y.item){return y;}if(typeof y==="string"){AA=y;y=K.getElementById(y);if(y&&y.id===AA){return y;}else{if(y&&K.all){y=null;Y=K.all[AA];for(x=0,G=Y.length;x<G;++x){if(Y[x].id===AA){return Y[x];}}}}return y;}if(y.DOM_EVENTS){y=y.get("element");}if("length" in y){z=[];for(x=0,G=y.length;x<G;++x){z[z.length]=E.Dom.get(y[x]);}return z;}return y;}return null;},getComputedStyle:function(G,Y){if(window[w]){return G[e][n][w](G,null)[Y];}else{if(G[a]){return E.Dom.IE_ComputedStyle.get(G,Y);}}},getStyle:function(G,Y){return E.Dom.batch(G,E.Dom._getStyle,Y);},_getStyle:function(){if(window[w]){return function(G,y){y=(y==="float")?y="cssFloat":E.Dom._toCamel(y);var x=G.style[y],Y;if(!x){Y=G[e][n][w](G,null);if(Y){x=Y[y];}}return x;};}else{if(W[a]){return function(G,y){var x;switch(y){case"opacity":x=100;try{x=G.filters["DXImageTransform.Microsoft.Alpha"].opacity;}catch(z){try{x=G.filters("alpha").opacity;}catch(Y){}}return x/100;case"float":y="styleFloat";default:y=E.Dom._toCamel(y);x=G[a]?G[a][y]:null;return(G.style[y]||x);}};}}}(),setStyle:function(G,Y,x){E.Dom.batch(G,E.Dom._setStyle,{prop:Y,val:x});},_setStyle:function(){if(T){return function(Y,G){var x=E.Dom._toCamel(G.prop),y=G.val;if(Y){switch(x){case"opacity":if(L.isString(Y.style.filter)){Y.style.filter="alpha(opacity="+y*100+")";if(!Y[a]||!Y[a].hasLayout){Y.style.zoom=1;}}break;case"float":x="styleFloat";default:Y.style[x]=y;}}else{}};}else{return function(Y,G){var x=E.Dom._toCamel(G.prop),y=G.val;if(Y){if(x=="float"){x="cssFloat";}Y.style[x]=y;}else{}};}}(),getXY:function(G){return E.Dom.batch(G,E.Dom._getXY);},_canPosition:function(G){return(E.Dom._getStyle(G,"display")!=="none"&&E.Dom._inDoc(G));},_getXY:function(){if(K[v][Q]){return function(y){var z,Y,AA,AF,AE,AD,AC,G,x,AB=Math.floor,AG=false;if(E.Dom._canPosition(y)){AA=y[Q]();AF=y[e];z=E.Dom.getDocumentScrollLeft(AF);Y=E.Dom.getDocumentScrollTop(AF);AG=[AB(AA[j]),AB(AA[o])];if(T&&m.ie<8){AE=2;AD=2;AC=AF[t];G=S(AF[v],q);x=S(AF[v],R);if(m.ie===6){if(AC!==c){AE=0;AD=0;}}if((AC==c)){if(G!==r){AE=parseInt(G,10);}if(x!==r){AD=parseInt(x,10);}}AG[0]-=AE;AG[1]-=AD;}if((Y||z)){AG[0]+=z;AG[1]+=Y;}AG[0]=AB(AG[0]);AG[1]=AB(AG[1]);}else{}return AG;};}else{return function(y){var x,Y,AA,AB,AC,z=false,G=y;if(E.Dom._canPosition(y)){z=[y[b],y[P]];x=E.Dom.getDocumentScrollLeft(y[e]);Y=E.Dom.getDocumentScrollTop(y[e]);AC=((H||m.webkit>519)?true:false);while((G=G[u])){z[0]+=G[b];z[1]+=G[P];if(AC){z=E.Dom._calcBorders(G,z);}}if(E.Dom._getStyle(y,p)!==f){G=y;while((G=G[Z])&&G[C]){AA=G[i];AB=G[O];if(H&&(E.Dom._getStyle(G,"overflow")!=="visible")){z=E.Dom._calcBorders(G,z);}if(AA||AB){z[0]-=AB;z[1]-=AA;}}z[0]+=x;z[1]+=Y;}else{if(D){z[0]-=x;z[1]-=Y;}else{if(I||H){z[0]+=x;z[1]+=Y;}}}z[0]=Math.floor(z[0]);z[1]=Math.floor(z[1]);}else{}return z;};}}(),getX:function(G){var Y=function(x){return E.Dom.getXY(x)[0];};return E.Dom.batch(G,Y,E.Dom,true);},getY:function(G){var Y=function(x){return E.Dom.getXY(x)[1];};return E.Dom.batch(G,Y,E.Dom,true);},setXY:function(G,x,Y){E.Dom.batch(G,E.Dom._setXY,{pos:x,noRetry:Y});},_setXY:function(G,z){var AA=E.Dom._getStyle(G,p),y=E.Dom.setStyle,AD=z.pos,Y=z.noRetry,AB=[parseInt(E.Dom.getComputedStyle(G,j),10),parseInt(E.Dom.getComputedStyle(G,o),10)],AC,x;if(AA=="static"){AA=V;y(G,p,AA);}AC=E.Dom._getXY(G);if(!AD||AC===false){return false;}if(isNaN(AB[0])){AB[0]=(AA==V)?0:G[b];}if(isNaN(AB[1])){AB[1]=(AA==V)?0:G[P];}if(AD[0]!==null){y(G,j,AD[0]-AC[0]+AB[0]+"px");}if(AD[1]!==null){y(G,o,AD[1]-AC[1]+AB[1]+"px");}if(!Y){x=E.Dom._getXY(G);if((AD[0]!==null&&x[0]!=AD[0])||(AD[1]!==null&&x[1]!=AD[1])){E.Dom._setXY(G,{pos:AD,noRetry:true});}}},setX:function(Y,G){E.Dom.setXY(Y,[G,null]);},setY:function(G,Y){E.Dom.setXY(G,[null,Y]);},getRegion:function(G){var Y=function(x){var y=false;if(E.Dom._canPosition(x)){y=E.Region.getRegion(x);}else{}return y;};return E.Dom.batch(G,Y,E.Dom,true);},getClientWidth:function(){return E.Dom.getViewportWidth();},getClientHeight:function(){return E.Dom.getViewportHeight();},getElementsByClassName:function(AB,AF,AC,AE,x,AD){AB=L.trim(AB);AF=AF||"*";AC=(AC)?E.Dom.get(AC):null||K;if(!AC){return[];}var Y=[],G=AC.getElementsByTagName(AF),z=E.Dom.hasClass;for(var y=0,AA=G.length;y<AA;++y){if(z(G[y],AB)){Y[Y.length]=G[y];}}if(AE){E.Dom.batch(Y,AE,x,AD);}return Y;},hasClass:function(Y,G){return E.Dom.batch(Y,E.Dom._hasClass,G);},_hasClass:function(x,Y){var G=false,y;if(x&&Y){y=E.Dom.getAttribute(x,F)||J;if(Y.exec){G=Y.test(y);}else{G=Y&&(B+y+B).indexOf(B+Y+B)>-1;}}else{}return G;},addClass:function(Y,G){return E.Dom.batch(Y,E.Dom._addClass,G);},_addClass:function(x,Y){var G=false,y;if(x&&Y){y=E.Dom.getAttribute(x,F)||J;if(!E.Dom._hasClass(x,Y)){E.Dom.setAttribute(x,F,A(y+B+Y));G=true;}}else{}return G;},removeClass:function(Y,G){return E.Dom.batch(Y,E.Dom._removeClass,G);},_removeClass:function(y,x){var Y=false,AA,z,G;if(y&&x){AA=E.Dom.getAttribute(y,F)||J;E.Dom.setAttribute(y,F,AA.replace(E.Dom._getClassRegex(x),J));z=E.Dom.getAttribute(y,F);if(AA!==z){E.Dom.setAttribute(y,F,A(z));Y=true;if(E.Dom.getAttribute(y,F)===""){G=(y.hasAttribute&&y.hasAttribute(g))?g:F;y.removeAttribute(G);}}}else{}return Y;},replaceClass:function(x,Y,G){return E.Dom.batch(x,E.Dom._replaceClass,{from:Y,to:G});
+},_replaceClass:function(y,x){var Y,AB,AA,G=false,z;if(y&&x){AB=x.from;AA=x.to;if(!AA){G=false;}else{if(!AB){G=E.Dom._addClass(y,x.to);}else{if(AB!==AA){z=E.Dom.getAttribute(y,F)||J;Y=(B+z.replace(E.Dom._getClassRegex(AB),B+AA)).split(E.Dom._getClassRegex(AA));Y.splice(1,0,B+AA);E.Dom.setAttribute(y,F,A(Y.join(J)));G=true;}}}}else{}return G;},generateId:function(G,x){x=x||"yui-gen";var Y=function(y){if(y&&y.id){return y.id;}var z=x+YAHOO.env._id_counter++;if(y){if(y[e].getElementById(z)){return E.Dom.generateId(y,z+x);}y.id=z;}return z;};return E.Dom.batch(G,Y,E.Dom,true)||Y.apply(E.Dom,arguments);},isAncestor:function(Y,x){Y=E.Dom.get(Y);x=E.Dom.get(x);var G=false;if((Y&&x)&&(Y[l]&&x[l])){if(Y.contains&&Y!==x){G=Y.contains(x);}else{if(Y.compareDocumentPosition){G=!!(Y.compareDocumentPosition(x)&16);}}}else{}return G;},inDocument:function(G,Y){return E.Dom._inDoc(E.Dom.get(G),Y);},_inDoc:function(Y,x){var G=false;if(Y&&Y[C]){x=x||Y[e];G=E.Dom.isAncestor(x[v],Y);}else{}return G;},getElementsBy:function(Y,AF,AB,AD,y,AC,AE){AF=AF||"*";AB=(AB)?E.Dom.get(AB):null||K;if(!AB){return[];}var x=[],G=AB.getElementsByTagName(AF);for(var z=0,AA=G.length;z<AA;++z){if(Y(G[z])){if(AE){x=G[z];break;}else{x[x.length]=G[z];}}}if(AD){E.Dom.batch(x,AD,y,AC);}return x;},getElementBy:function(x,G,Y){return E.Dom.getElementsBy(x,G,Y,null,null,null,true);},batch:function(x,AB,AA,z){var y=[],Y=(z)?AA:window;x=(x&&(x[C]||x.item))?x:E.Dom.get(x);if(x&&AB){if(x[C]||x.length===undefined){return AB.call(Y,x,AA);}for(var G=0;G<x.length;++G){y[y.length]=AB.call(Y,x[G],AA);}}else{return false;}return y;},getDocumentHeight:function(){var Y=(K[t]!=M||I)?K.body.scrollHeight:W.scrollHeight,G=Math.max(Y,E.Dom.getViewportHeight());return G;},getDocumentWidth:function(){var Y=(K[t]!=M||I)?K.body.scrollWidth:W.scrollWidth,G=Math.max(Y,E.Dom.getViewportWidth());return G;},getViewportHeight:function(){var G=self.innerHeight,Y=K[t];if((Y||T)&&!D){G=(Y==M)?W.clientHeight:K.body.clientHeight;}return G;},getViewportWidth:function(){var G=self.innerWidth,Y=K[t];if(Y||T){G=(Y==M)?W.clientWidth:K.body.clientWidth;}return G;},getAncestorBy:function(G,Y){while((G=G[Z])){if(E.Dom._testElement(G,Y)){return G;}}return null;},getAncestorByClassName:function(Y,G){Y=E.Dom.get(Y);if(!Y){return null;}var x=function(y){return E.Dom.hasClass(y,G);};return E.Dom.getAncestorBy(Y,x);},getAncestorByTagName:function(Y,G){Y=E.Dom.get(Y);if(!Y){return null;}var x=function(y){return y[C]&&y[C].toUpperCase()==G.toUpperCase();};return E.Dom.getAncestorBy(Y,x);},getPreviousSiblingBy:function(G,Y){while(G){G=G.previousSibling;if(E.Dom._testElement(G,Y)){return G;}}return null;},getPreviousSibling:function(G){G=E.Dom.get(G);if(!G){return null;}return E.Dom.getPreviousSiblingBy(G);},getNextSiblingBy:function(G,Y){while(G){G=G.nextSibling;if(E.Dom._testElement(G,Y)){return G;}}return null;},getNextSibling:function(G){G=E.Dom.get(G);if(!G){return null;}return E.Dom.getNextSiblingBy(G);},getFirstChildBy:function(G,x){var Y=(E.Dom._testElement(G.firstChild,x))?G.firstChild:null;return Y||E.Dom.getNextSiblingBy(G.firstChild,x);},getFirstChild:function(G,Y){G=E.Dom.get(G);if(!G){return null;}return E.Dom.getFirstChildBy(G);},getLastChildBy:function(G,x){if(!G){return null;}var Y=(E.Dom._testElement(G.lastChild,x))?G.lastChild:null;return Y||E.Dom.getPreviousSiblingBy(G.lastChild,x);},getLastChild:function(G){G=E.Dom.get(G);return E.Dom.getLastChildBy(G);},getChildrenBy:function(Y,y){var x=E.Dom.getFirstChildBy(Y,y),G=x?[x]:[];E.Dom.getNextSiblingBy(x,function(z){if(!y||y(z)){G[G.length]=z;}return false;});return G;},getChildren:function(G){G=E.Dom.get(G);if(!G){}return E.Dom.getChildrenBy(G);},getDocumentScrollLeft:function(G){G=G||K;return Math.max(G[v].scrollLeft,G.body.scrollLeft);},getDocumentScrollTop:function(G){G=G||K;return Math.max(G[v].scrollTop,G.body.scrollTop);},insertBefore:function(Y,G){Y=E.Dom.get(Y);G=E.Dom.get(G);if(!Y||!G||!G[Z]){return null;}return G[Z].insertBefore(Y,G);},insertAfter:function(Y,G){Y=E.Dom.get(Y);G=E.Dom.get(G);if(!Y||!G||!G[Z]){return null;}if(G.nextSibling){return G[Z].insertBefore(Y,G.nextSibling);}else{return G[Z].appendChild(Y);}},getClientRegion:function(){var x=E.Dom.getDocumentScrollTop(),Y=E.Dom.getDocumentScrollLeft(),y=E.Dom.getViewportWidth()+Y,G=E.Dom.getViewportHeight()+x;return new E.Region(x,y,G,Y);},setAttribute:function(Y,G,x){G=E.Dom.CUSTOM_ATTRIBUTES[G]||G;Y.setAttribute(G,x);},getAttribute:function(Y,G){G=E.Dom.CUSTOM_ATTRIBUTES[G]||G;return Y.getAttribute(G);},_toCamel:function(Y){var x=d;function G(y,z){return z.toUpperCase();}return x[Y]||(x[Y]=Y.indexOf("-")===-1?Y:Y.replace(/-([a-z])/gi,G));},_getClassRegex:function(Y){var G;if(Y!==undefined){if(Y.exec){G=Y;}else{G=h[Y];if(!G){Y=Y.replace(E.Dom._patterns.CLASS_RE_TOKENS,"\\$1");G=h[Y]=new RegExp(s+Y+k,U);}}}return G;},_patterns:{ROOT_TAG:/^body|html$/i,CLASS_RE_TOKENS:/([\.\(\)\^\$\*\+\?\|\[\]\{\}])/g},_testElement:function(G,Y){return G&&G[l]==1&&(!Y||Y(G));},_calcBorders:function(x,y){var Y=parseInt(E.Dom[w](x,R),10)||0,G=parseInt(E.Dom[w](x,q),10)||0;if(H){if(N.test(x[C])){Y=0;G=0;}}y[0]+=G;y[1]+=Y;return y;}};var S=E.Dom[w];if(m.opera){E.Dom[w]=function(Y,G){var x=S(Y,G);if(X.test(G)){x=E.Dom.Color.toRGB(x);}return x;};}if(m.webkit){E.Dom[w]=function(Y,G){var x=S(Y,G);if(x==="rgba(0, 0, 0, 0)"){x="transparent";}return x;};}})();YAHOO.util.Region=function(C,D,A,B){this.top=C;this.y=C;this[1]=C;this.right=D;this.bottom=A;this.left=B;this.x=B;this[0]=B;this.width=this.right-this.left;this.height=this.bottom-this.top;};YAHOO.util.Region.prototype.contains=function(A){return(A.left>=this.left&&A.right<=this.right&&A.top>=this.top&&A.bottom<=this.bottom);};YAHOO.util.Region.prototype.getArea=function(){return((this.bottom-this.top)*(this.right-this.left));};YAHOO.util.Region.prototype.intersect=function(E){var C=Math.max(this.top,E.top),D=Math.min(this.right,E.right),A=Math.min(this.bottom,E.bottom),B=Math.max(this.left,E.left);if(A>=C&&D>=B){return new YAHOO.util.Region(C,D,A,B);
+}else{return null;}};YAHOO.util.Region.prototype.union=function(E){var C=Math.min(this.top,E.top),D=Math.max(this.right,E.right),A=Math.max(this.bottom,E.bottom),B=Math.min(this.left,E.left);return new YAHOO.util.Region(C,D,A,B);};YAHOO.util.Region.prototype.toString=function(){return("Region {"+"top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+", left: "+this.left+", height: "+this.height+", width: "+this.width+"}");};YAHOO.util.Region.getRegion=function(D){var F=YAHOO.util.Dom.getXY(D),C=F[1],E=F[0]+D.offsetWidth,A=F[1]+D.offsetHeight,B=F[0];return new YAHOO.util.Region(C,E,A,B);};YAHOO.util.Point=function(A,B){if(YAHOO.lang.isArray(A)){B=A[1];A=A[0];}YAHOO.util.Point.superclass.constructor.call(this,B,A,B,A);};YAHOO.extend(YAHOO.util.Point,YAHOO.util.Region);(function(){var B=YAHOO.util,A="clientTop",F="clientLeft",J="parentNode",K="right",W="hasLayout",I="px",U="opacity",L="auto",D="borderLeftWidth",G="borderTopWidth",P="borderRightWidth",V="borderBottomWidth",S="visible",Q="transparent",N="height",E="width",H="style",T="currentStyle",R=/^width|height$/,O=/^(\d[.\d]*)+(em|ex|px|gd|rem|vw|vh|vm|ch|mm|cm|in|pt|pc|deg|rad|ms|s|hz|khz|%){1}?/i,M={get:function(X,Z){var Y="",a=X[T][Z];if(Z===U){Y=B.Dom.getStyle(X,U);}else{if(!a||(a.indexOf&&a.indexOf(I)>-1)){Y=a;}else{if(B.Dom.IE_COMPUTED[Z]){Y=B.Dom.IE_COMPUTED[Z](X,Z);}else{if(O.test(a)){Y=B.Dom.IE.ComputedStyle.getPixel(X,Z);}else{Y=a;}}}}return Y;},getOffset:function(Z,e){var b=Z[T][e],X=e.charAt(0).toUpperCase()+e.substr(1),c="offset"+X,Y="pixel"+X,a="",d;if(b==L){d=Z[c];if(d===undefined){a=0;}a=d;if(R.test(e)){Z[H][e]=d;if(Z[c]>d){a=d-(Z[c]-d);}Z[H][e]=L;}}else{if(!Z[H][Y]&&!Z[H][e]){Z[H][e]=b;}a=Z[H][Y];}return a+I;},getBorderWidth:function(X,Z){var Y=null;if(!X[T][W]){X[H].zoom=1;}switch(Z){case G:Y=X[A];break;case V:Y=X.offsetHeight-X.clientHeight-X[A];break;case D:Y=X[F];break;case P:Y=X.offsetWidth-X.clientWidth-X[F];break;}return Y+I;},getPixel:function(Y,X){var a=null,b=Y[T][K],Z=Y[T][X];Y[H][K]=Z;a=Y[H].pixelRight;Y[H][K]=b;return a+I;},getMargin:function(Y,X){var Z;if(Y[T][X]==L){Z=0+I;}else{Z=B.Dom.IE.ComputedStyle.getPixel(Y,X);}return Z;},getVisibility:function(Y,X){var Z;while((Z=Y[T])&&Z[X]=="inherit"){Y=Y[J];}return(Z)?Z[X]:S;},getColor:function(Y,X){return B.Dom.Color.toRGB(Y[T][X])||Q;},getBorderColor:function(Y,X){var Z=Y[T],a=Z[X]||Z.color;return B.Dom.Color.toRGB(B.Dom.Color.toHex(a));}},C={};C.top=C.right=C.bottom=C.left=C[E]=C[N]=M.getOffset;C.color=M.getColor;C[G]=C[P]=C[V]=C[D]=M.getBorderWidth;C.marginTop=C.marginRight=C.marginBottom=C.marginLeft=M.getMargin;C.visibility=M.getVisibility;C.borderColor=C.borderTopColor=C.borderRightColor=C.borderBottomColor=C.borderLeftColor=M.getBorderColor;B.Dom.IE_COMPUTED=C;B.Dom.IE_ComputedStyle=M;})();(function(){var C="toString",A=parseInt,B=RegExp,D=YAHOO.util;D.Dom.Color={KEYWORDS:{black:"000",silver:"c0c0c0",gray:"808080",white:"fff",maroon:"800000",red:"f00",purple:"800080",fuchsia:"f0f",green:"008000",lime:"0f0",olive:"808000",yellow:"ff0",navy:"000080",blue:"00f",teal:"008080",aqua:"0ff"},re_RGB:/^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i,re_hex:/^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i,re_hex3:/([0-9A-F])/gi,toRGB:function(E){if(!D.Dom.Color.re_RGB.test(E)){E=D.Dom.Color.toHex(E);}if(D.Dom.Color.re_hex.exec(E)){E="rgb("+[A(B.$1,16),A(B.$2,16),A(B.$3,16)].join(", ")+")";}return E;},toHex:function(H){H=D.Dom.Color.KEYWORDS[H]||H;if(D.Dom.Color.re_RGB.exec(H)){var G=(B.$1.length===1)?"0"+B.$1:Number(B.$1),F=(B.$2.length===1)?"0"+B.$2:Number(B.$2),E=(B.$3.length===1)?"0"+B.$3:Number(B.$3);H=[G[C](16),F[C](16),E[C](16)].join("");}if(H.length<6){H=H.replace(D.Dom.Color.re_hex3,"$1$1");}if(H!=="transparent"&&H.indexOf("#")<0){H="#"+H;}return H.toLowerCase();}};}());YAHOO.register("dom",YAHOO.util.Dom,{version:"2.7.0",build:"1796"});YAHOO.util.CustomEvent=function(D,C,B,A){this.type=D;this.scope=C||window;this.silent=B;this.signature=A||YAHOO.util.CustomEvent.LIST;this.subscribers=[];if(!this.silent){}var E="_YUICEOnSubscribe";if(D!==E){this.subscribeEvent=new YAHOO.util.CustomEvent(E,this,true);}this.lastError=null;};YAHOO.util.CustomEvent.LIST=0;YAHOO.util.CustomEvent.FLAT=1;YAHOO.util.CustomEvent.prototype={subscribe:function(A,B,C){if(!A){throw new Error("Invalid callback for subscriber to '"+this.type+"'");}if(this.subscribeEvent){this.subscribeEvent.fire(A,B,C);}this.subscribers.push(new YAHOO.util.Subscriber(A,B,C));},unsubscribe:function(D,F){if(!D){return this.unsubscribeAll();}var E=false;for(var B=0,A=this.subscribers.length;B<A;++B){var C=this.subscribers[B];if(C&&C.contains(D,F)){this._delete(B);E=true;}}return E;},fire:function(){this.lastError=null;var K=[],E=this.subscribers.length;if(!E&&this.silent){return true;}var I=[].slice.call(arguments,0),G=true,D,J=false;if(!this.silent){}var C=this.subscribers.slice(),A=YAHOO.util.Event.throwErrors;for(D=0;D<E;++D){var M=C[D];if(!M){J=true;}else{if(!this.silent){}var L=M.getScope(this.scope);if(this.signature==YAHOO.util.CustomEvent.FLAT){var B=null;if(I.length>0){B=I[0];}try{G=M.fn.call(L,B,M.obj);}catch(F){this.lastError=F;if(A){throw F;}}}else{try{G=M.f...
[truncated message content] |
|
From: <ma...@us...> - 2012-03-03 20:51:36
|
Revision: 717
http://openautomation.svn.sourceforge.net/openautomation/?rev=717&view=rev
Author: mayerch
Date: 2012-03-03 20:51:28 +0000 (Sat, 03 Mar 2012)
Log Message:
-----------
Make lib much more self contained
(Propper sorting, commenting and indentation still missing, though)
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 2012-02-29 19:33:36 UTC (rev 716)
+++ JSFloorPlan/trunk/index.html 2012-03-03 20:51:28 UTC (rev 717)
@@ -10,10 +10,10 @@
-->
<title>JS Floor Plan</title>
<!-- -->
-<script src="lib/jquery-1.7.1.min.js" type="text/javascript"></script>
+<script src="lib/jquery-1.7.1.js" type="text/javascript"></script>
<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="lib/Three.max.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>
<link rel="stylesheet" type="text/css" href="css/ui-lightness/jquery-ui-1.8.16.custom.css" />
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2012-02-29 19:33:36 UTC (rev 716)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-03 20:51:28 UTC (rev 717)
@@ -142,10 +142,10 @@
*/
(function( window, undefined ){
// the constructor
- var JSFloorPlan3D = function( floorPlan ){
+ var JSFloorPlan3D = function( container, floorPlan ){
if (!(this instanceof JSFloorPlan3D))
{
- return new JSFloorPlan3D( floorPlan );
+ return new JSFloorPlan3D( container, floorPlan );
}
if (typeof floorPlan === "string")
@@ -159,10 +159,29 @@
// private variables of this object instance will follow
var that = this;
+ var thatObject = {that: this};
+ this.thisThatObject = {that: this};
+ this.thisThat = this;
////////////////////////////////////////////////////////////////////////////
// Definition of the private variables
+ // create the materials - sphere for the nodes, cube for the walls and line for the lines
+ var sphereMaterial = new THREE.MeshLambertMaterial( { color: 0xCC0000 });
+ //var cubeMaterial = new THREE.MeshLambertMaterial( { color: 0x0000CC });
+ var cubeMaterial = new THREE.MeshBasicMaterial({ map: THREE.ImageUtils.loadTexture( 'media/demo_texture_512x512.png' ) });
+ //var cubeMaterial = new THREE.MeshPhongMaterial( { color: 0xff0000, specular: 0xffffff, ambient: 0xaa0000 } );
+ var lineMaterial = new THREE.LineBasicMaterial( { color: 0x0099ff, linewidth: 2 } );
+
+ var scene, camera, renderer, pointLight, sunLight, ambientLight, sunLightViewLine;
+ // set up the sphere vars
+
+ //var lightAzimut, lightElevation, lightStrength, lightDistanceŷ;
+ this.lightAzimut = {foo:'bar'};
+ this.lightElevation;
+ this.lightStrength;
+ this.lightDistanceŷ;
+
var floor;
// this array will contain all vertices to show in the svg
@@ -367,7 +386,7 @@
// iterate over the content of this floor
for( var j=0; j < floor.childNodes.length; j++ )
{
- floorNode = floor.childNodes[j];
+ var floorNode = floor.childNodes[j];
if (floorNode.nodeType != ELEMENT_NODE) continue;
switch( floorNode.tagName )
@@ -451,7 +470,7 @@
if( floorWalls[wjj].endOffset && vectors[jj].id < 0 )
djj += -floorWalls[wjj].endOffset;
- vertex = new Object;
+ var vertex = new Object;
vertex.x = vectors[j].x*djj + vectors[jj].x*dj;
vertex.y = vectors[j].y*djj + vectors[jj].y*dj;
var l = vectors[j].x*vectors[jj].y - vectors[j].y*vectors[jj].x;
@@ -592,8 +611,8 @@
p2tF.push(new THREE.Face3(val.GetPoint(0).id, val.GetPoint(1).id, val.GetPoint(2).id));
});
- Tvertices = swctx.points_;
- Tfaces = p2tF;
+ var Tvertices = swctx.points_;
+ var Tfaces = p2tF;
var wall1vertices = [];
var wall2vertices = [];
var sId, eId;
@@ -732,7 +751,7 @@
{
for( var i=0; i < nodes.childNodes.length; i++ )
{
- node = nodes.childNodes[i];
+ var node = nodes.childNodes[i];
if (node.nodeType != ELEMENT_NODE) continue;
var id = node.getAttribute('id');
@@ -774,7 +793,7 @@
{
for( var i=0; i < nodes.childNodes.length; i++ )
{
- node = nodes.childNodes[i];
+ var node = nodes.childNodes[i];
if (node.nodeType != ELEMENT_NODE) continue;
/**
@@ -932,11 +951,78 @@
* @method setup3D
* @private
*/
- function setup3D( thisObject3D )
- {
+ function setup3D( currentThis, thisObject3D )
+ {
if( noFloorplan ) return;
noSetup = false;
+ ///////////////////////////////////////////////////////////////////////////
+ // set the scene size
+ var WIDTH = 800,
+ HEIGHT = 400;
+
+ // set some camera attributes
+ var VIEW_ANGLE = 45,
+ ASPECT = WIDTH / HEIGHT,
+ NEAR = 0.1,
+ FAR = 10000;
+
+
+ renderer = new THREE.WebGLRenderer({antialias: true});
+ camera = new THREE.PerspectiveCamera(
+ VIEW_ANGLE,
+ ASPECT,
+ NEAR,
+ FAR );
+ scene = new THREE.Scene();
+ scene.add( camera );
+ // the camera starts at 0,0,0 so pull it back
+ camera.position.z = 300;
+
+ // start the renderer
+ renderer.setSize(WIDTH, HEIGHT);
+
+ // enable shadows
+ var SHADOW_MAP_WIDTH = 2048, SHADOW_MAP_HEIGHT = 1024;
+ renderer.shadowCameraNear = 0.1;
+ renderer.shadowCameraFar = 100;
+ renderer.shadowCameraFov = 45;
+
+ renderer.shadowMapBias = 0.0039;
+ renderer.shadowMapDarkness = 0.5;
+ renderer.shadowMapWidth = SHADOW_MAP_WIDTH;
+ renderer.shadowMapHeight = SHADOW_MAP_HEIGHT;
+ renderer.shadowMapEnabled = true;
+ //renderer.shadowMapSoft = true;
+ var projector = new THREE.Projector();
+
+ // create a point light
+ pointLight = new THREE.PointLight( 0xFFFFFF );
+
+ ambientLight = new THREE.AmbientLight( 0xFFFFFF );
+ // set its position
+ pointLight.position.x = 10;
+ pointLight.position.y = 50;
+ pointLight.position.z = 130;
+
+ // add to the scene
+ //scene.add(pointLight);
+
+ currentThis.lightAzimut = 3.9;
+ currentThis.lightElevation = 0.25;
+ currentThis.lightStrength = 80;
+ currentThis.lightDistance = 50;
+ sunLight = new THREE.SpotLight( 0xffffff );
+ sunLight.position.set( 0, 1500, 1000 );
+ sunLight.target.position.set( 0, 0, 0 );
+ sunLight.castShadow = true;
+ var sunLightView = new THREE.Geometry();
+ sunLightView.vertices.push( new THREE.Vertex( sunLight.position ) );
+ sunLightView.vertices.push( new THREE.Vertex( sunLight.target.position ) );
+ sunLightViewLine = new THREE.Line( sunLightView, lineMaterial );
+ scene.add( sunLightViewLine );
+ ///////////////////////////////////////////////////////////////////////////
+
scene.add( thisObject3D );
var showFloor = showStates.showFloor;
@@ -946,14 +1032,9 @@
//scene.add(pointLight);
scene.add(ambientLight);
//scene.add( camera );
- var $container = $('#top_level');
+ var $container = $(container);
// attach the render-supplied DOM element
$container.append(renderer.domElement);
-
- // Init after the scene was set up
- selectChange( 'showNodes' , 0, true );
- selectChange( 'showWallLines' , 0, true );
- selectChange( 'showFloor' , 0, true );
}
function setupCamera( azimut, elevation, distance, target )
@@ -967,6 +1048,16 @@
pointLight.position = camera.position;
}
+ JSFloorPlan3D.prototype.render = function()
+ {
+ renderer.render( scene, camera );
+ }
+
+ JSFloorPlan3D.prototype.showWireframe = function( doShowWireframe )
+ {
+ cubeMaterial.wireframe = doShowWireframe;
+ }
+
/**
* Show the floor plan by updating the relevant view parameters and calling
* the render() method
@@ -985,18 +1076,18 @@
showStates.currentDistance = distance;
showStates.currentTarget = target.clone(); //JSFloorPlan3D.buildingProperties.x_center;
- if( noSetup ) setup3D( this.buildingProperties.Object3D );
+ if( noSetup ) setup3D( this, this.buildingProperties.Object3D );
// set up camera
setupCamera( azimut, elevation, distance, target );
// set up sun
- var sx = Math.sin(lightAzimut) * Math.cos(lightElevation);
- var sy = Math.cos(lightAzimut) * Math.cos(lightElevation);
- var sz = Math.sin(lightElevation);
+ var sx = Math.sin(this.lightAzimut) * Math.cos(this.lightElevation);
+ var sy = Math.cos(this.lightAzimut) * Math.cos(this.lightElevation);
+ var sz = Math.sin(this.lightElevation);
sunLight.target.position = target;
- sunLight.position = new THREE.Vector3( sx * lightDistance, sy * lightDistance, sz * lightDistance + target.z );
- sunLight.intensity = lightStrength / 100.0;
+ sunLight.position = new THREE.Vector3( sx * this.lightDistance, sy * this.lightDistance, sz * this.lightDistance + target.z );
+ sunLight.intensity = this.lightStrength / 100.0;
sunLightViewLine.geometry.vertices[0].position = sunLight.position;
sunLightViewLine.geometry.vertices[1].position = sunLight.target.position;
sunLightViewLine.geometry.__dirtyVertices = true;
@@ -1041,7 +1132,8 @@
break;
};
- render();
+ //this.render();
+ renderer.render( scene, camera );
}
/**
@@ -1132,7 +1224,7 @@
}
setupCamera( showStates.currentAzimut, showStates.currentElevation, showStates.currentDistance, showStates.currentTarget );
- render();
+ renderer.render( scene, camera );
if( !done )
window.requestAnimationFrame( doMove );
Modified: JSFloorPlan/trunk/src/jsfloorplan_example_helper.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan_example_helper.js 2012-02-29 19:33:36 UTC (rev 716)
+++ JSFloorPlan/trunk/src/jsfloorplan_example_helper.js 2012-03-03 20:51:28 UTC (rev 717)
@@ -27,146 +27,6 @@
* @module JS FloorPlan 3D Example
*/
-function three_init()
-{
- return;
- // get the DOM element to attach to
- // - assume we've got jQuery to hand
- //var $container = $('#container');
- var $container = $('#top_level');
- // attach the render-supplied DOM element
- $container.append(renderer.domElement);
- // draw!
- //scene.add( camera );
- //renderer.render(scene, camera);
- //render();
- animate();
-}
-// set the scene size
-var WIDTH = 800,
- HEIGHT = 400;
-
-// set some camera attributes
-var VIEW_ANGLE = 45,
- ASPECT = WIDTH / HEIGHT,
- NEAR = 0.1,
- FAR = 10000;
-
-
-// create a WebGL renderer, camera
-// and a scene
-var renderer = new THREE.WebGLRenderer({antialias: true});
-var camera = new THREE.PerspectiveCamera(
- VIEW_ANGLE,
- ASPECT,
- NEAR,
- FAR );
-/*
-var controls = new THREE.TrackballControls( camera );
-//controls.rotateSpeed = 1.0;
-//controls.zoomSpeed = 1.2;
-//controls.panSpeed = 0.8;
-
-controls.noZoom = false;
-controls.noPan = false;
-
-controls.staticMoving = true;
-controls.dynamicDampingFactor = 0.3;
-
-controls.keys = [ 65, 83, 68 ];
-*/
-var scene = new THREE.Scene();
-scene.add( camera );
-// the camera starts at 0,0,0 so pull it back
-camera.position.z = 300;
-
-// start the renderer
-renderer.setSize(WIDTH, HEIGHT);
-
-// enable shadows
-var SHADOW_MAP_WIDTH = 2048, SHADOW_MAP_HEIGHT = 1024;
-renderer.shadowCameraNear = 0.1;
-renderer.shadowCameraFar = 100;
-renderer.shadowCameraFov = 45;
-
-renderer.shadowMapBias = 0.0039;
-renderer.shadowMapDarkness = 0.5;
-renderer.shadowMapWidth = SHADOW_MAP_WIDTH;
-renderer.shadowMapHeight = SHADOW_MAP_HEIGHT;
-renderer.shadowMapEnabled = true;
-//renderer.shadowMapSoft = true;
-var projector = new THREE.Projector();
-
-// set up the sphere vars
-var radius = 50, segments = 16, rings = 16;
-
-// create the sphere's material
-var sphereMaterial = new THREE.MeshLambertMaterial(
-{
- color: 0xCC0000
-});
-// create a new mesh with sphere geometry -
-// we will cover the sphereMaterial next!
-var sphere = new THREE.Mesh(
- new THREE.SphereGeometry(radius,
- segments,
- rings),
-
- sphereMaterial);
-
-// add the sphere to the scene
-//scene.add(sphere);
-
-var cubeMaterial = new THREE.MeshLambertMaterial(
-{
- color: 0x0000CC
-});
-var cube = new THREE.Mesh(
- new THREE.CubeGeometry(
- 10, 20, 30,
- 2, 2),
- cubeMaterial
-);
-cube.position = new THREE.Vector3(50,50,50);
-//scene.add( cube );
-
-cubeMaterial = new THREE.MeshBasicMaterial({ map: THREE.ImageUtils.loadTexture( 'media/demo_texture_512x512.png' ) });
-//cubeMaterial = new THREE.MeshPhongMaterial( { color: 0xff0000, specular: 0xffffff, ambient: 0xaa0000 } );
-
-var lineMaterial = new THREE.LineBasicMaterial( { color: 0x0099ff, linewidth: 2 } );
-
-// create a point light
-var pointLight = new THREE.PointLight( 0xFFFFFF );
-
-var ambientLight = new THREE.AmbientLight( 0xFFFFFF );
-// set its position
-pointLight.position.x = 10;
-pointLight.position.y = 50;
-pointLight.position.z = 130;
-
-// add to the scene
-//scene.add(pointLight);
-
-var lightAzimut = 3.9;
-var lightElevation = 0.25;
-var lightStrength = 80;
-var lightDistance = 50;
-//var sunLight = new THREE.PointLight( 0xFFFFFF );
-//var sunLight = new THREE.DirectionalLight( 0xFFFFFF );
-var sunLight = new THREE.SpotLight( 0xffffff );
-sunLight.position.set( 0, 1500, 1000 );
-sunLight.target.position.set( 0, 0, 0 );
-sunLight.castShadow = true;
-var sunLightView = new THREE.Geometry();
-sunLightView.vertices.push( new THREE.Vertex( sunLight.position ) );
-sunLightView.vertices.push( new THREE.Vertex( sunLight.target.position ) );
-var sunLightViewLine = new THREE.Line( sunLightView, lineMaterial );
-scene.add( sunLightViewLine );
-//var dlight = new THREE.DirectionalLight( 0xffffff, 0.1 );
-// dlight.position.set( 0.5, -1, 0 ).normalize();
-// scene.add( dlight );
-
-
/**
* Provides requestAnimationFrame in a cross browser way.
* http://paulirish.com/2011/requestanimationframe-for-smart-animating/
@@ -192,13 +52,6 @@
//stats.update();
}
-function render() {
- //controls.update();
- renderer.render( scene, camera );
-}
-
-//}
-
function handleMouseClickEvent( event )
{
if( event.room.room )
@@ -221,20 +74,6 @@
// setup script here:
var sc = 40; // overall scaling
var showStates = {};
-/*
-var showWallSides = true;
-var showWallTop = true;
-var showSideLines = true;
-var showTopLines = true;
-var showBackside = true;
-var showHoles = true;
-var showZones = true;
-var showVisibleZones = false;
-var showFloor = 1;
-var wallMouseOver = true;
-var fillOpacity = 0.5;
-var fillColor = 'black';
-*/
var redrawInterval = 50; // in milliseconds; = 20 fps
var roll = 35*Math.PI/180;
@@ -253,7 +92,7 @@
var t_25d_after_sort;
var t_25d_end;
-j = new JSFloorPlan3D();
+j = new JSFloorPlan3D('#top_level');
function init()
{
@@ -278,12 +117,16 @@
showStates[ this.name ] = this.value; // init
});
- //loadFloorplan();
j.loadFloorPlan('floorplan_demo.xml');
target.x = j.buildingProperties.x_center;
target.y = j.buildingProperties.y_center;
createSlider();
- render();
+ j.render();
+
+ // Init after the scene was set up
+ selectChange( 'showNodes' , 0, true );
+ selectChange( 'showWallLines' , 0, true );
+ selectChange( 'showFloor' , 0, true );
}
function selectChange( name, old, onlyInit )
@@ -340,7 +183,7 @@
break;
case 'showWireframe':
- cubeMaterial.wireframe = showStates['showWireframe'];
+ j.showWireframe( showStates['showWireframe'] );
break;
}
return true;
@@ -420,70 +263,6 @@
document.getElementById('status').firstChild.data = text;
}
-/*
-function set_color( event )
-{
- if( 'blue' != fillColor )
- event.setAttribute( 'fill', 'blue' );
- else
- event.setAttribute( 'fill', 'red' );
-}
-
-function unset_color( event )
-{
- event.setAttribute( 'fill', fillColor );
-}
-*/
-/*
-function check( what, redraw )
-{
- eval( what +' = document.forms[0].elements[what].checked' );
-
- switch( what )
- {
- case 'wallMouseOver':
- if( wallMouseOver )
- {
- wrapper.setAttribute( "onmouseover", 'set_color(this);' );
- wrapper.setAttribute( "onmouseout", 'unset_color(this);' );
- } else {
- wrapper.setAttribute( "onmouseover", '' );
- wrapper.setAttribute( "onmouseout", '' );
- }
- break;
- }
-
- if( redraw )
- {
- j.show3D( roll, tilt, dist, plan );
- }
-}
-*/
-
-/*
-function selectValue( what, redraw )
-{
- var val = document.forms[0].elements[what].options[ document.forms[0].elements[what].selectedIndex ].value;
- eval( what + ' = val' );
-
- switch( what )
- {
- case 'fillOpacity':
- wrapper.setAttribute( "fill-opacity", fillOpacity );
- break;
-
- case 'fillColor':
- wrapper.setAttribute( "fill", fillColor );
- break;
- }
-
- if( redraw )
- {
- j.show3D( roll, tilt, dist, plan );
- }
-}
-*/
-
// Create the little graphics for the roll and the tilt angle
// as well as the buttons to manipulate them
function createSlider()
@@ -504,15 +283,15 @@
globalInUpdateSlider = true;
var rollAngle = (roll * 180/Math.PI);
var tiltAngle = (tilt * 180/Math.PI);
- var lightDirectionAngle = (lightAzimut * 180/Math.PI);
- var lightHeightAngle = (lightElevation * 180/Math.PI);
+ var lightDirectionAngle = (j.lightAzimut * 180/Math.PI);
+ var lightHeightAngle = (j.lightElevation * 180/Math.PI);
$( "#rollSlider" ).slider( "option", "value", rollAngle );
$( "#tiltSlider" ).slider( "option", "value", tiltAngle );
$( "#distSlider" ).slider( "option", "value", dist );
$( "#lightDirectionSlider" ).slider( "option", "value", lightDirectionAngle );
$( "#lightHeightSlider" ).slider( "option", "value", lightHeightAngle );
- $( "#lightStrengthSlider" ).slider( "option", "value", lightStrength );
- $( "#lightDistanceSlider" ).slider( "option", "value", lightDistance );
+ $( "#lightStrengthSlider" ).slider( "option", "value", j.lightStrength );
+ $( "#lightDistanceSlider" ).slider( "option", "value", j.lightDistance );
globalInUpdateSlider = false;
}
@@ -540,28 +319,28 @@
function lightDirectionChange( event, ui )
{
if( globalInUpdateSlider ) return true;
- lightAzimut = ui.value * Math.PI / 180;
+ j.lightAzimut = ui.value * Math.PI / 180;
j.show3D( roll, tilt, dist, target );
}
function lightHeightChange( event, ui )
{
if( globalInUpdateSlider ) return true;
- lightElevation = ui.value * Math.PI / 180;
+ j.lightElevation = ui.value * Math.PI / 180;
j.show3D( roll, tilt, dist, target );
}
function lightStrengthChange( event, ui )
{
if( globalInUpdateSlider ) return true;
- lightStrength = ui.value;
+ j.lightStrength = ui.value;
j.show3D( roll, tilt, dist, target );
}
function lightDistanceChange( event, ui )
{
if( globalInUpdateSlider ) return true;
- lightDistance = ui.value;
+ j.lightDistance = ui.value;
j.show3D( roll, tilt, dist, target );
}
@@ -626,6 +405,5 @@
}
$(function() {
- three_init();
$('#top_level').css('border','1px solid black').click( {callback:handleMouseClickEvent,JSFloorPlan3D:j}, j.translateMouseEvent );
});
\ 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...> - 2012-03-04 19:56:04
|
Revision: 720
http://openautomation.svn.sourceforge.net/openautomation/?rev=720&view=rev
Author: mayerch
Date: 2012-03-04 19:55:57 +0000 (Sun, 04 Mar 2012)
Log Message:
-----------
Clean up the API (i.e. public methods) of the lib as well as general stuff
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 2012-03-04 18:48:31 UTC (rev 719)
+++ JSFloorPlan/trunk/index.html 2012-03-04 19:55:57 UTC (rev 720)
@@ -77,30 +77,6 @@
</tr>
<tr>
<td>
- Zeige Wände: <input type="checkbox" name="showWallSides" checked="checked" />
- </td><td>
- Zeige Deckel: <input type="checkbox" name="showWallTop" checked="checked" />
- </td><td>
- Zeige Rückseite: <input type="checkbox" name="showBackside" checked="checked" />
- </td><td>
- Zeige MouseOver: <input type="checkbox" name="wallMouseOver" />
- </td>
- </tr>
- <tr>
- <td>
- Wand-Umrandung: <input type="checkbox" name="showSideLines" checked="checked" />
- </td><td>
- Deckel-Umrandung: <input type="checkbox" name="showTopLines" checked="checked" />
- </td><td>
- Zeige "Löcher": <input type="checkbox" name="showHoles" checked="checked" />
- </td><td>
- Erzeuge Zonen: <input type="checkbox" name="showZones" checked="checked" />
- </td><td>
- Zeige Zonen: <input type="checkbox" name="showVisibleZones" checked="checked" />
- </td>
- </tr>
- <tr>
- <td>
Zeige Nodes: <input type="checkbox" name="showNodes" />
</td><td>
Zeige Walls: <input type="checkbox" name="showWallLines" />
@@ -128,12 +104,12 @@
</select>
</td><td>
Farbe: <select size="1" name="fillColor">
-<option value="black">Schwarz</option>
-<option value="grey" selected="selected">Grau</option>
-<option value="white">Weiß</option>
-<option value="blue">Blau</option>
-<option value="red">Rot</option>
-<option value="green">Grün</option>
+<option value="000000">Schwarz</option>
+<option value="808080" selected="selected">Grau</option>
+<option value="ffffff">Weiß</option>
+<option value="0000a0">Blau</option>
+<option value="a00000">Rot</option>
+<option value="00a000">Grün</option>
</select>
</td><td>
Stockwerk: <select size="1" name="showFloor">
@@ -145,23 +121,6 @@
</table>
</form>
<!-- -->
-<hr />
-<h2>Hinweise:</h2>
-<p>
-Sollte oben kein Plan zu sehen sein, so müssen die Dateinen noch an
-den jeweiligen Browser angepasst werden: beim IE einfach diese Datei von
-<em>index.xhtml</em> in <em>index.html</em> umbenennen - nähere Infos
-gibt es beim <a href="http://wiki.svg.org/Inline_SVG">SVG Wiki</a>.<br />
-Gerade in der Entwicklung ist noch mit solchen Kleinigkeiten zu rechnen,
-bei der finalen Version wird es passende Einstellungen geben.
-</p>
-<p>
-Nutzer des Internet Explorers müssen - da dieser im Gegensatz zu anderen
-modernen Browsern von sich aus noch kein SVG unterstützt - das passende
-PlugIn, den <a href="http://www.adobe.com/svg/viewer/install/main.html">Adobe SVG Viewer</a> installieren.<br />
-Problemlos und ohne PlugIn sollte es ab FireFox 1.5, Opera 9, Safari 3
-und Camino 1.0 funktionieren.
-</p>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
</body>
</html>
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-04 18:48:31 UTC (rev 719)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-04 19:55:57 UTC (rev 720)
@@ -141,13 +141,30 @@
* @constructor FOO
*/
(function( window, undefined ){
- // the constructor
- var JSFloorPlan3D = function( container, floorPlan ){
+ ////////////////////////////////////////////////////////////////////////////
+ // private static variables and methods:
+
+ /**
+ * Constant representing the ID of an ELEMENT_NODE
+ * @property ELEMENT_NODE
+ * @private
+ * @static
+ * @final
+ * @type Enum
+ */
+ var ELEMENT_NODE = 1;
+
+ ////////////////////////////////////////////////////////////////////////////
+ // the library
+ var JSFloorPlan3D = function( container, floorPlan ){
+ // check and fix if the user forgot the "new" keyword
if (!(this instanceof JSFloorPlan3D))
{
return new JSFloorPlan3D( container, floorPlan );
}
+ var self = this;
+
if (typeof floorPlan === "string")
{
this.loadFloorPlan( floorPlan );
@@ -158,14 +175,13 @@
// private variables of this object instance will follow
- var that = this;
- var thatObject = {that: this};
- this.thisThatObject = {that: this};
- this.thisThat = this;
-
////////////////////////////////////////////////////////////////////////////
// Definition of the private variables
+ var WIDTH = 800,
+ HEIGHT = 400;
+ var VIEW_ANGLE = 45;
+ var projector = new THREE.Projector();
// create the materials - sphere for the nodes, cube for the walls and line for the lines
var sphereMaterial = new THREE.MeshLambertMaterial( { color: 0xCC0000 });
//var cubeMaterial = new THREE.MeshLambertMaterial( { color: 0x0000CC });
@@ -175,13 +191,28 @@
var scene, camera, renderer, pointLight, sunLight, ambientLight, sunLightViewLine;
// set up the sphere vars
-
- //var lightAzimut, lightElevation, lightStrength, lightDistanceŷ;
- this.lightAzimut = {foo:'bar'};
- this.lightElevation;
- this.lightStrength;
- this.lightDistanceŷ;
+ /**
+ * Set states that define how the floor plan is drawn
+ */
+ var showStates = {
+ currentAzimut: 1, // North up
+ currentElevation: Math.PI/2, // top view
+ currentDistance: 10,
+ // currentTarget: new THREE.Vector3, // will be defined later
+ lightAzimut: 3.9,
+ lightElevation: 0.25,
+ lightStrength: 80,
+ lightDistance: 50,
+ fillOpacity: 1, // solid
+ fillColor: new THREE.Color(0x000000), // black
+ showNodes: false, // only for debug purposes
+ showWallLines: false, // only for debug purposes
+ showWireframe: false, //
+ showLightView: false, // only for debug purposes
+ showFloor: undefined
+ };
+
var floor;
// this array will contain all vertices to show in the svg
@@ -230,15 +261,6 @@
*/
JSFloorPlan3D.inAnimation = false;
- /**
- * Constant representing the ID of an ELEMENT_NODE
- * @property ELEMENT_NODE
- * @private
- * @static
- * @final
- * @type Enum
- */
- var ELEMENT_NODE = 1;
////////////////////////////////////////////////////////////////////////////
// Definition of the private methods
@@ -317,27 +339,11 @@
}
/**
- * Get the URL url and set up this object by its content
- * @param {String} url
- */
- JSFloorPlan3D.prototype.loadFloorPlan = function( url )
- {
- var outerThis = this;
- $.ajax({
- url: url,
- context: outerThis,
- success: function( xmlDoc ){ outerThis.parseXMLFloorPlan( xmlDoc ); },
- dataType: 'xml',
- async: false
- });
- }
-
- /**
* Parse and create internal structure for the floor plan.
* @method parseXMLFloorPlan
* @param {XMLDom} xmlDoc
*/
- JSFloorPlan3D.prototype.parseXMLFloorPlan = function( xmlDoc )
+ var parseXMLFloorPlan = function( xmlDoc )
{
noFloorplan = false;
@@ -363,7 +369,7 @@
if( floor.tagName == 'textures' )
{
- this.parseTextures( floor );
+ parseTextures( floor );
continue;
}
@@ -372,14 +378,14 @@
"Expected: 'floor', found '" + floor.tagName + "'" );
floorCount++;
- this.buildingProperties.floor[floorCount] = {};
+ self.buildingProperties.floor[floorCount] = {};
var floorName = floor.getAttribute('name');
- this.buildingProperties.floor[floorCount].name = floorName;
+ self.buildingProperties.floor[floorCount].name = floorName;
var floorheight = Number( floor.getAttribute('height') );
- this.buildingProperties.floor[floorCount].height = floorheight;
- this.buildingProperties.floor[floorCount].heightOfGround = heightOfGround;
+ self.buildingProperties.floor[floorCount].height = floorheight;
+ self.buildingProperties.floor[floorCount].heightOfGround = heightOfGround;
var floorWallsStart = floorWalls.length;
@@ -392,15 +398,15 @@
switch( floorNode.tagName )
{
case 'nodes':
- this.parseFloorNodes( floorNode, floorheight );
+ parseFloorNodes( floorNode, floorheight );
break;
case 'walls':
- this.parseFloorWalls( floorNode );
+ parseFloorWalls( floorNode );
break;
case 'rooms':
- this.parseFloorRooms( floorNode, floorCount );
+ parseFloorRooms( floorNode, floorCount );
break;
}
}
@@ -718,27 +724,45 @@
Object3D.add( lineGroup );
Object3D.add( wallGroup );
- this.buildingProperties.floor[floorCount].Object3D = Object3D;
- this.buildingProperties.floor[floorCount].nodeGroup = nodeGroup;
- this.buildingProperties.floor[floorCount].lineGroup = lineGroup;
- this.buildingProperties.floor[floorCount].wallGroup = wallGroup;
- this.buildingProperties.Object3D.add( Object3D ); // add / link; note: we use that JavaScript is not copying objects but uses ref counting on them here!
+ self.buildingProperties.floor[floorCount].Object3D = Object3D;
+ self.buildingProperties.floor[floorCount].nodeGroup = nodeGroup;
+ self.buildingProperties.floor[floorCount].lineGroup = lineGroup;
+ self.buildingProperties.floor[floorCount].wallGroup = wallGroup;
+ self.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
- this.buildingProperties.x_center = (this.buildingProperties.x_max - this.buildingProperties.x_min) / 2;
- this.buildingProperties.y_center = (this.buildingProperties.y_max - this.buildingProperties.y_min) / 2;
- this.buildingProperties.size = Math.max( this.buildingProperties.x_center, this.buildingProperties.y_center );
- imageCenter.x = this.buildingProperties.x_center;
- imageCenter.y = this.buildingProperties.y_center;
- imageCenter.z = this.buildingProperties.z_max / 2;
+ self.buildingProperties.x_center = (self.buildingProperties.x_max - self.buildingProperties.x_min) / 2;
+ self.buildingProperties.y_center = (self.buildingProperties.y_max - self.buildingProperties.y_min) / 2;
+ self.buildingProperties.size = Math.max( self.buildingProperties.x_center, self.buildingProperties.y_center );
+ imageCenter.x = self.buildingProperties.x_center;
+ imageCenter.y = self.buildingProperties.y_center;
+ imageCenter.z = self.buildingProperties.z_max / 2;
- this.show3D( 35*Math.PI/180, 30*Math.PI/180, 10, new THREE.Vector3( imageCenter.x, imageCenter.y, imageCenter.z ) );
+ self.show3D( 35*Math.PI/180, 30*Math.PI/180, 10, new THREE.Vector3( imageCenter.x, imageCenter.y, imageCenter.z ) );
//}
};
/**
+ * Get the URL url and set up this object by its content
+ * @param {String} url
+ */
+ this.loadFloorPlan = function( url )
+ {
+ $.ajax({
+ url: url,
+ context: self,
+ success: function( xmlDoc ){
+ parseXMLFloorPlan( xmlDoc );
+
+ },
+ dataType: 'xml',
+ async: false
+ });
+ }
+
+ /**
* Fill the <code>floorNodes</code> structure with the nodes from the
* config file.
* @method parseFloorNodes
@@ -747,7 +771,7 @@
* @param {Float} floorheight The generic height of this floor that might be
* overwritten by individual nodes.
*/
- JSFloorPlan3D.prototype.parseFloorNodes = function( nodes, floorheight )
+ var parseFloorNodes = function( nodes, floorheight )
{
for( var i=0; i < nodes.childNodes.length; i++ )
{
@@ -763,21 +787,21 @@
floorNodes[id] = point;
- if( undefined == this.buildingProperties.x_min )
+ if( undefined == self.buildingProperties.x_min )
{
- this.buildingProperties.x_min = point.x;
- this.buildingProperties.x_max = point.x;
- this.buildingProperties.y_min = point.y;
- this.buildingProperties.y_max = point.y;
- this.buildingProperties.z_min = point.z;
- this.buildingProperties.z_max = point.z;
+ self.buildingProperties.x_min = point.x;
+ self.buildingProperties.x_max = point.x;
+ self.buildingProperties.y_min = point.y;
+ self.buildingProperties.y_max = point.y;
+ self.buildingProperties.z_min = point.z;
+ self.buildingProperties.z_max = point.z;
} else {
- if( this.buildingProperties.x_min > point.x ) this.buildingProperties.x_min = point.x;
- if( this.buildingProperties.x_max < point.x ) this.buildingProperties.x_max = point.x;
- if( this.buildingProperties.y_min > point.y ) this.buildingProperties.y_min = point.y;
- if( this.buildingProperties.y_max < point.y ) this.buildingProperties.y_max = point.y;
- if( this.buildingProperties.z_min > point.z ) this.buildingProperties.z_min = point.z;
- if( this.buildingProperties.z_max < point.z ) this.buildingProperties.z_max = point.z;
+ if( self.buildingProperties.x_min > point.x ) self.buildingProperties.x_min = point.x;
+ if( self.buildingProperties.x_max < point.x ) self.buildingProperties.x_max = point.x;
+ if( self.buildingProperties.y_min > point.y ) self.buildingProperties.y_min = point.y;
+ if( self.buildingProperties.y_max < point.y ) self.buildingProperties.y_max = point.y;
+ if( self.buildingProperties.z_min > point.z ) self.buildingProperties.z_min = point.z;
+ if( self.buildingProperties.z_max < point.z ) self.buildingProperties.z_max = point.z;
}
}
}
@@ -789,7 +813,7 @@
* @private
* @param {XMLDom} nodeGroup
*/
- JSFloorPlan3D.prototype.parseFloorWalls = function( nodes )
+ var parseFloorWalls = function( nodes )
{
for( var i=0; i < nodes.childNodes.length; i++ )
{
@@ -876,7 +900,7 @@
* @param {XMLDom} nodeGroup
* @param {Integer} floor The floor number.
*/
- JSFloorPlan3D.prototype.parseFloorRooms = function( nodes, floor )
+ var parseFloorRooms = function( nodes, floor )
{
rooms[floor] = new Array;
for( var i=0; i < nodes.childNodes.length; i++ )
@@ -936,7 +960,7 @@
* @private
* @param {XMLDom} nodes
*/
- JSFloorPlan3D.prototype.parseTextures = function( nodes )
+ var parseTextures = function( nodes )
{
return;
for( var i=0; i < nodes.childNodes.length; i++ )
@@ -958,12 +982,9 @@
///////////////////////////////////////////////////////////////////////////
// set the scene size
- var WIDTH = 800,
- HEIGHT = 400;
// set some camera attributes
- var VIEW_ANGLE = 45,
- ASPECT = WIDTH / HEIGHT,
+ var ASPECT = WIDTH / HEIGHT,
NEAR = 0.1,
FAR = 10000;
@@ -994,7 +1015,6 @@
renderer.shadowMapHeight = SHADOW_MAP_HEIGHT;
renderer.shadowMapEnabled = true;
//renderer.shadowMapSoft = true;
- var projector = new THREE.Projector();
// create a point light
pointLight = new THREE.PointLight( 0xFFFFFF );
@@ -1008,10 +1028,6 @@
// add to the scene
//scene.add(pointLight);
- currentThis.lightAzimut = 3.9;
- currentThis.lightElevation = 0.25;
- currentThis.lightStrength = 80;
- currentThis.lightDistance = 50;
sunLight = new THREE.SpotLight( 0xffffff );
sunLight.position.set( 0, 1500, 1000 );
sunLight.target.position.set( 0, 0, 0 );
@@ -1025,7 +1041,6 @@
scene.add( thisObject3D );
- var showFloor = showStates.showFloor;
///////////
scene.add(sunLight);
@@ -1048,16 +1063,46 @@
pointLight.position = camera.position;
}
- JSFloorPlan3D.prototype.render = function()
+ this.render = function()
{
renderer.render( scene, camera );
}
- JSFloorPlan3D.prototype.showWireframe = function( doShowWireframe )
+ this.setState = function( property, value, redraw )
{
- cubeMaterial.wireframe = doShowWireframe;
+ switch( property )
+ {
+ case 'showWireframe':
+ cubeMaterial.wireframe = value;
+ break;
+
+ case 'fillColor':
+ cubeMaterial.color.setHex( parseInt( value, 16 ) );
+ break;
+
+ case 'showFloor':
+ value = parseInt( value );
+ }
+
+ showStates[ property ] = value;
+
+ if( redraw ) // is set and true
+ {
+ update3D();
+ }
}
+ this.getState = function( property )
+ {
+ return showStates[ property ];
+ }
+ this.hideFloor = function( floorNr, doShow )
+ {
+ THREE.SceneUtils.traverseHierarchy( self.buildingProperties.floor[floorNr].wallGroup, function( object ) {
+ object.visible = doShow;
+ });
+ }
+
/**
* Show the floor plan by updating the relevant view parameters and calling
* the render() method
@@ -1069,7 +1114,7 @@
* @param {Number} distnce Distance between camera and <code>target</code>
* @param {THREE.Vector3} target The point to look at
*/
- JSFloorPlan3D.prototype.show3D = function( azimut, elevation, distance, target )
+ this.show3D = function( azimut, elevation, distance, target )
{
showStates.currentAzimut = azimut;
showStates.currentElevation = elevation;
@@ -1078,16 +1123,21 @@
if( noSetup ) setup3D( this, this.buildingProperties.Object3D );
+ update3D();
+ }
+
+ function update3D()
+ {
// set up camera
- setupCamera( azimut, elevation, distance, target );
+ setupCamera( showStates.currentAzimut, showStates.currentElevation, showStates.currentDistance, showStates.currentTarget );
// set up sun
- var sx = Math.sin(this.lightAzimut) * Math.cos(this.lightElevation);
- var sy = Math.cos(this.lightAzimut) * Math.cos(this.lightElevation);
- var sz = Math.sin(this.lightElevation);
+ var sx = Math.sin(showStates.lightAzimut) * Math.cos(showStates.lightElevation);
+ var sy = Math.cos(showStates.lightAzimut) * Math.cos(showStates.lightElevation);
+ var sz = Math.sin(showStates.lightElevation);
sunLight.target.position = target;
- sunLight.position = new THREE.Vector3( sx * this.lightDistance, sy * this.lightDistance, sz * this.lightDistance + target.z );
- sunLight.intensity = this.lightStrength / 100.0;
+ sunLight.position = new THREE.Vector3( sx * showStates.lightDistance, sy * showStates.lightDistance, sz * showStates.lightDistance + target.z );
+ sunLight.intensity = showStates.lightStrength / 100.0;
sunLightViewLine.geometry.vertices[0].position = sunLight.position;
sunLightViewLine.geometry.vertices[1].position = sunLight.target.position;
sunLightViewLine.geometry.__dirtyVertices = true;
@@ -1104,36 +1154,12 @@
cubeMaterial.opacity = showStates.fillOpacity;
cubeMaterial.transparent = showStates.fillOpacity < 1.0;
cubeMaterial.depthTest = !cubeMaterial.transparent;
- THREE.SceneUtils.traverseHierarchy( JSFloorPlan3D.buildingProperties.Object3D, function( object ) {
+ THREE.SceneUtils.traverseHierarchy( self.buildingProperties.Object3D, function( object ) {
object.doubleSided = cubeMaterial.transparent;
});
}
- // update color
- switch( showStates.fillColor )
- {
- case 'black':
- cubeMaterial.color.setRGB( 0.1, 0.1, 0.1 );
- break;
- case 'grey':
- cubeMaterial.color.setRGB( 0.5, 0.5, 0.5 );
- break;
- case 'white':
- cubeMaterial.color.setRGB( 1.0, 1.0, 1.0 );
- break;
- case 'blue':
- cubeMaterial.color.setRGB( 0.0, 0.0, 0.8 );
- break;
- case 'red':
- cubeMaterial.color.setRGB( 0.8, 0.0, 0.0 );
- break;
- case 'green':
- cubeMaterial.color.setRGB( 0.0, 0.8, 0.0 );
- break;
- };
-
- //this.render();
- renderer.render( scene, camera );
+ self.render();
}
/**
@@ -1151,7 +1177,7 @@
* @param {Function} delayedFn (optional) Function to call after animation is
* finished
*/
- JSFloorPlan3D.prototype.moveTo = function( floor, azimut, elevation, distance, target, delayedFn )
+ this.moveTo = function( floor, azimut, elevation, distance, target, delayedFn )
{
if( noSetup ) setup3D( this.buildingProperties.Object3D );
@@ -1192,7 +1218,7 @@
showStates.currentElevation += rate.elevation;
done = false;
} else {
- showStates.currenteElevation = elevation;
+ showStates.currentElevation = elevation;
}
if( (showStates.currentDistance + rate.distance) * rate.distance < distance * rate.distance )
{
@@ -1241,6 +1267,29 @@
}
/**
+ * @method moveToRoom
+ */
+ this.moveToRoom = function( floor, room )
+ {
+ var target = new THREE.Vector3();
+ var dist;
+ if( room ) // use room if defined
+ {
+ target.x = room.center.x;
+ target.y = room.center.y;
+ dist = room.size / Math.tan( VIEW_ANGLE * Math.PI/180 / 2 );
+ } else { // use whole floor otherwise
+ target.x = this.buildingProperties.x_center;
+ target.y = this.buildingProperties.y_center;
+ dist = this.buildingProperties.size / Math.tan( VIEW_ANGLE * Math.PI/180 / 2 );
+ }
+ target.z = this.buildingProperties.floor[ floor ].heightOfGround +
+ this.buildingProperties.floor[ floor ].height / 2;
+ this.moveTo( floor, showStates.currentAzimut, showStates.currentElevation, dist, target );
+ return target;
+ }
+
+ /**
* Check if point <code>p</code> is in the zone <code>zone</code>. It's
* basically a point-in-polygon test using a ray casting from left infinity to
* the point <code>p</code>.
@@ -1283,7 +1332,7 @@
* @return {Object} If a zone / room was found a hash with the keys "room" and
* "zone" will be returned otherwise an empty Object.
*/
- JSFloorPlan3D.prototype.selectRoom = function( p, floor )
+ this.selectRoom = function( p, floor )
{
var thisFloor = rooms[floor];
for( var room in thisFloor )
@@ -1308,7 +1357,7 @@
* @param {Number} h Height in building space used for mapping
* @return {THREE.Vector3} Point in building space
*/
- JSFloorPlan3D.prototype.sceen2building = function( x, y, h )
+ this.sceen2building = function( x, y, h )
{
var vector = new THREE.Vector3( (x / WIDTH)*2-1, -(y / HEIGHT)*2+1, 0.5 );
projector.unprojectVector( vector, camera );
@@ -1324,7 +1373,7 @@
* @return {Object} Hash with keys <code>x</code> and <code>y</code> in screen
* coordinates
*/
- JSFloorPlan3D.prototype.building2screen = function( p )
+ this.building2screen = function( p )
{
var screen = p.clone();
projector.projectVector( screen, camera );
@@ -1338,7 +1387,7 @@
* @param {Function} event.data.callback This callback function will be called
* after the mouse event was translated
*/
- JSFloorPlan3D.prototype.translateMouseEvent = function( event )
+ this.translateMouseEvent = function( event )
{
var tJSFloorPlan3D = event.data.JSFloorPlan3D;
var thisFloor = tJSFloorPlan3D.buildingProperties.floor[showStates.showFloor];
@@ -1353,4 +1402,22 @@
//Expose dQuery object to window as dQuery or JSlib
window.JSFloorPlan3D = JSFloorPlan3D;
-})(window);
\ No newline at end of file
+})(window);
+
+/**
+ * Provides requestAnimationFrame in a cross browser way.
+ * http://paulirish.com/2011/requestanimationframe-for-smart-animating/
+ * @class requestAnimationFrame
+ */
+
+if ( !window.requestAnimationFrame ) {
+ window.requestAnimationFrame = ( function() {
+ return window.webkitRequestAnimationFrame ||
+ window.mozRequestAnimationFrame ||
+ window.oRequestAnimationFrame ||
+ window.msRequestAnimationFrame ||
+ function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element ) {
+ window.setTimeout( callback, 1000 / 60 );
+ };
+ } )();
+}
\ No newline at end of file
Modified: JSFloorPlan/trunk/src/jsfloorplan_example_helper.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan_example_helper.js 2012-03-04 18:48:31 UTC (rev 719)
+++ JSFloorPlan/trunk/src/jsfloorplan_example_helper.js 2012-03-04 19:55:57 UTC (rev 720)
@@ -27,53 +27,15 @@
* @module JS FloorPlan 3D Example
*/
-/**
- * Provides requestAnimationFrame in a cross browser way.
- * http://paulirish.com/2011/requestanimationframe-for-smart-animating/
- * @class requestAnimationFrame
- */
-
-if ( !window.requestAnimationFrame ) {
- window.requestAnimationFrame = ( function() {
- return window.webkitRequestAnimationFrame ||
- window.mozRequestAnimationFrame ||
- window.oRequestAnimationFrame ||
- window.msRequestAnimationFrame ||
- function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element ) {
- window.setTimeout( callback, 1000 / 60 );
- };
-} )();
-
-}
-function animate() {
- requestAnimationFrame( animate );
- //render();
- j.show3D( roll, tilt, dist, target );
- //stats.update();
-}
-
function handleMouseClickEvent( event )
{
- if( event.room.room )
- {
- var room = event.room.room;
- var zone = event.room.zone;
- target.x = room.center.x;
- target.y = room.center.y;
- dist = room.size / Math.tan( VIEW_ANGLE * Math.PI/180 / 2 );
- } else {
- target.x = j.buildingProperties.x_center;
- target.y = j.buildingProperties.y_center;
- dist = j.buildingProperties.size / Math.tan( VIEW_ANGLE * Math.PI/180 / 2 );
- }
+ target = j.moveToRoom( j.getState('showFloor'), event.room.room );
updateSlider();
- j.moveTo( showStates['showFloor'], roll, tilt, dist, target );
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// setup script here:
var sc = 40; // overall scaling
-var showStates = {};
var redrawInterval = 50; // in milliseconds; = 20 fps
var roll = 35*Math.PI/180;
@@ -97,36 +59,37 @@
function init()
{
$('input').change(function(e){
- var old = showStates[ e.target.name ];
- showStates[ e.target.name ] = e.target.checked;
+ var old = j.getState( e.target.name );
+ j.setState( e.target.name, e.target.checked );
if( selectChange( e.target.name, old ) )
{
j.show3D( roll, tilt, dist, target );
}
}).each(function(){
- showStates[ this.name ] = this.checked; // init
+ j.setState( this.name, this.checked ); // init
});
$('select').change(function(e){
- var old = showStates[ e.target.name ];
- showStates[ e.target.name ] = e.target.value;
+ var old = j.getState( e.target.name );
+ j.setState( e.target.name, e.target.value );
if( selectChange( e.target.name, old ) )
{
j.show3D( roll, tilt, dist, target );
}
}).each(function(){
- showStates[ this.name ] = this.value; // init
+ j.setState( this.name, this.value ); // init
});
j.loadFloorPlan('floorplan_demo.xml');
target.x = j.buildingProperties.x_center;
target.y = j.buildingProperties.y_center;
createSlider();
- j.render();
// Init after the scene was set up
selectChange( 'showNodes' , 0, true );
selectChange( 'showWallLines' , 0, true );
selectChange( 'showFloor' , 0, true );
+
+ j.render();
}
function selectChange( name, old, onlyInit )
@@ -136,7 +99,7 @@
case 'showNodes':
$( j.buildingProperties.floor ).each( function(){
THREE.SceneUtils.traverseHierarchy( this.nodeGroup, function( object ) {
- object.visible = showStates['showNodes'];
+ object.visible = j.getState( 'showNodes' );
});
});
break;
@@ -144,47 +107,36 @@
case 'showWallLines':
$( j.buildingProperties.floor ).each( function(){
THREE.SceneUtils.traverseHierarchy( this.lineGroup, function( object ) {
- object.visible = showStates['showWallLines'];
+ object.visible = j.getState( 'showWallLines' );
});
});
break;
case 'showFloor':
- //showStates['showFloor'] = Number( showStates['showFloor'] );
if( onlyInit )
{
$( j.buildingProperties.floor ).each( function( number ){
- THREE.SceneUtils.traverseHierarchy( this.wallGroup, function( object ) {
- object.visible = ( showStates['showFloor'] == number );
- });
+ j.hideFloor( number, j.getState( 'showFloor' ) == number );
});
- target.z = j.buildingProperties.floor[ showStates['showFloor'] ].heightOfGround +
- j.buildingProperties.floor[ showStates['showFloor'] ].height / 2;
+ target.z = j.buildingProperties.floor[ j.getState( 'showFloor' ) ].heightOfGround +
+ j.buildingProperties.floor[ j.getState( 'showFloor' ) ].height / 2;
return false;
}
- var min = old < showStates['showFloor'] ? old : showStates['showFloor'];
- var max = old > showStates['showFloor'] ? old : showStates['showFloor'];
+ var min = old < j.getState( 'showFloor' ) ? old : j.getState( 'showFloor' );
+ var max = old > j.getState( 'showFloor' ) ? old : j.getState( 'showFloor' );
$( j.buildingProperties.floor ).each( function( number ){
- THREE.SceneUtils.traverseHierarchy( this.wallGroup, function( object ) {
- object.visible = ( (min <= number) && (number <= max) );
- });
+ j.hideFloor( number, (min <= number) && (number <= max) );
...
[truncated message content] |