Prototypes for simple building construction: Floor, Wall, Level and Building.
X3D-Edit 3.2, https://www.web3d.org/x3d/tools/X3D-Edit
Each Floor cantains the current floor surface plus a ceiling surface for the floor immediately underneath. A Floor does not include exterior or interior wall polygons.
single-value Coordinate node with dimension x=width y=height z=depth in meters
Appearance node with Material colors ImageTexture etc. for this construction.
width of front side of floor aligned with local X axis.
height of vertical distance between floor and ceiling directly underneath aligned with local Y axis.
depth of horizontal side of floor aligned with local -Z axis.
Indicate whether initialization complete.
ecmascript: function tracePrint (outputString) { if (traceEnabled) Browser.println ('[Floor' + name + ']' + outputString); } function alwaysPrint (outputString) { Browser.println ('[Floor' + name + ']' + outputString); } function initialize () { built = false; tracePrint ('description=' + description); tracePrint ('showSides=' + showSides); if (showSides == true) wallsVisible = 0; // goes to Switch whichChoice tracePrint ('wallsVisible=' + wallsVisible); if ((size.point.length == 0) || (size.point.length > 1)) alwaysPrint ('** warning, size.point.length =' + size.point.length + ' rather than 1'); width = size.point[0].x; height = size.point[0].y; depth = size.point[0].z; tracePrint ('(width, height, depth)=(' + width + ',' + height + ',' + depth + ')'); // floor is immediately above ceiling floorPoints = new MFVec3f ( new SFVec3f (0, 0, 0), new SFVec3f (width, 0, 0), new SFVec3f (width, 0, -depth), new SFVec3f (0, 0, -depth), new SFVec3f (0, -height, 0), new SFVec3f (width, -height, 0), new SFVec3f (width, -height, -depth), new SFVec3f (0, -height, -depth)); tracePrint ('floorPoints=' + floorPoints); built = true; tracePrint ('built=' + built); }
Each Wall contains exterior and interior walls.
width of horizontal side of wall aligned with local X axis.
height of Wall aligned with local Y axis.
depth of horizontal thickness of Wall aligned with local -Z axis.
ecmascript: function tracePrint (outputString) { if (traceEnabled) Browser.println ('[Wall' + name + ']' + outputString); } function alwaysPrint (outputString) { Browser.println ('[Wall' + name + ']' + outputString); } function initialize () { built = false; tracePrint ('description=' + description); tracePrint ('showSides=' + showSides); if (showSides == true) wallsVisible = 0; // goes to Switch whichChoice tracePrint ('wallsVisible=' + wallsVisible); if ((size.point.length == 0) || (size.point.length > 1)) alwaysPrint ('** warning, size.point.length =' + size.point.length + ' rather than 1'); width = size.point[0].x; height = size.point[0].y; depth = size.point[0].z; tracePrint ('(width, height, depth)=(' + width + ',' + height + ',' + depth + ')'); coordinatePoints = new MFVec3f ( new SFVec3f (0, 0, 0), new SFVec3f (width, 0, 0), new SFVec3f (width, height, 0), new SFVec3f (0, height, 0), new SFVec3f (0, 0, -depth), new SFVec3f (width, 0, -depth), new SFVec3f (width, height, -depth), new SFVec3f (0, height, -depth)); tracePrint ('coordinatePoints=' + coordinatePoints); built = true; tracePrint ('built=' + built); }
collection of a Floor and four Walls working in order up from lowest level (i.e. story) of the Building
Calculated width of horizontal side of Level aligned with local X axis.
Calculated height of Level aligned with local Y axis.
Calculated depth of horizontal thickness of Level aligned with local -Z axis.
ecmascript: var firstLoopWhileTrueCompleted; function tracePrint (outputString) { if (traceEnabled) Browser.println ('[Level' + name + ']' + outputString); } function alwaysPrint (outputString) { Browser.println ('[Level' + name + ']' + outputString); } function initialize () { built = false; firstLoopWhileTrueCompleted = false; alwaysPrint ('initialize, built=' + built); } function recheckUntilBuilt (value) { if (built == true) { built = true; // resend to trigger cancellation event for TimeSensor if (firstLoopWhileTrueCompleted) alwaysPrint ('recheckUntilBuilt() continuous built=true indicates internal error'); else firstLoopWhileTrueCompleted = true; return; // done } alwaysPrint ('recheckUntilBuilt testing...'); // following are single nodes, cast as MFNode type for IS/connect matchups if (floor[0].built == false) return; // not yet ready else if (frontWall[0].built == false) return; else if (rightWall[0].built == false) return; else if (rearWall[0].built == false) return; else if (leftWall[0].built == false) return; alwaysPrint ('recheckUntilBuilt ready, initializing Level...'); alwaysPrint ('description=' + description); if (floor) { // tracePrint ('floor found'); if (floor.length > 1) alwaysPrint ('** warning, more than one floor found (' + floor.length + ' nodes total)'); tracePrint ('floor (width, height, depth)=(' + floor[0].width + ',' + floor[0].height + ',' + floor[0].depth + ')'); } else tracePrint ('floor not found'); if (frontWall) { // tracePrint ('frontWall found'); if (frontWall > 1) alwaysPrint ('** warning, more than one frontWall found (' + frontWall.length + ' nodes total)'); tracePrint ('frontWall (width, height, depth)=(' + frontWall[0].width + ',' + frontWall[0].height + ',' + frontWall[0].depth + ')'); } else tracePrint ('frontWall not found'); if (rightWall) { // tracePrint ('rightWall found'); if (rightWall > 1) alwaysPrint ('** warning, more than one rightWall found (' + frontWall.length + ' nodes total)'); tracePrint ('rightWall (width, height, depth)=(' + rightWall[0].width + ',' + rightWall[0].height + ',' + rightWall[0].depth + ')'); } else tracePrint ('rightWall not found'); if (rearWall) { // tracePrint ('rearWall found'); if (frontWall > 1) alwaysPrint ('** warning, more than one rearWall found (' + rearWall + ' nodes total)'); tracePrint ('rearWall (width, height, depth)=(' + rearWall[0].width + ',' + rearWall[0].height + ',' + rearWall[0].depth + ')'); } else tracePrint ('rearWall not found'); if (leftWall) { // tracePrint ('leftWall found'); if (frontWall > 1) alwaysPrint ('** warning, more than one leftWall found (' + leftWall.length + ' nodes total)'); tracePrint ('leftWall (width, height, depth)=(' + leftWall[0].width + ',' + leftWall[0].height + ',' + leftWall[0].depth + ')'); } else tracePrint ('leftWall not found'); if (floor && frontWall) { if ((floor[0].width != frontWall[0].width) && (floor[0].width != 0) && (frontWall[0].width != 0)) alwaysPrint ('** warning, floor/frontWall width mismatch'); } if (floor && rearWall) { if ((floor[0].width != rearWall[0].width) && (floor[0].width != 0) && (rearWall[0].width != 0)) alwaysPrint ('** warning, floor/rearWall width mismatch'); } if (floor && rightWall) { if ((floor[0].depth != rightWall[0].width) && (floor[0].depth != 0) && (rightWall[0].width != 0)) alwaysPrint ('** warning, floor.depth/rightWall.width mismatch'); } if (floor && leftWall) { if ((floor[0].depth != leftWall[0].width) && (floor[0].depth != 0) && (leftWall[0].width != 0)) alwaysPrint ('** warning, floor.depth/leftWall.width mismatch'); } if (frontWall && rearWall) { if ((frontWall[0].width != rearWall[0].width) && (frontWall[0].width != 0) && (rearWall[0].width != 0)) alwaysPrint ('** warning, frontWall/rearWall width mismatch'); } if (leftWall && rightWall) { if ((leftWall[0].width != rightWall[0].width) && (leftWall[0].width != 0) && (rightWall[0].width != 0)) alwaysPrint ('** warning, leftWall/rightWall width mismatch'); } // find first nonzero values width = 0; if (floor) width = floor[0].width; if (frontWall && (width == 0)) width = frontWall[0].width; if (rearWall && (width == 0)) width = rearWall[0].width; height = 0; if (frontWall) height = frontWall[0].height; if (rightWall && (height == 0)) height = rightWall[0].height; else if (rearWall && (height == 0)) height = rearWall[0].height; else if (leftWall && (height == 0)) height = leftWall[0].height; depth = 0; if (floor) depth = floor[0].depth; if (rightWall && (depth == 0)) depth = rightWall[0].depth; if (leftWall && (depth == 0)) depth = leftWall[0].depth; tracePrint ('(width, height, depth)=(' + width + ',' + height + ',' + depth + ')'); // translate wall centers (not corners) rightTranslation = new SFVec3f (width, 0, 0); tracePrint ('rightTranslation=' + rightTranslation); rearTranslation = new SFVec3f (width, 0, -depth); tracePrint ('rearTranslation=' + rearTranslation); leftTranslation = new SFVec3f (0, 0, -width/2); tracePrint ('leftTranslation=' + leftTranslation); built = true; tracePrint ('built=' + built); }
New floor or wall initialization may be complete check and recalculate until built
Collect prototypes for levels floors and walls to create a simple Building.
whether or not to display author assist tools such as coordinate axes measuring grids etc.
compass direction in degrees of building X axis as seen when regarding front face of building pointing from left side to right side.
output rotation value calculated from xHeading as (0 1 0 xHeading * 2pi / 360)
Geometry for Roof positioned above topmost Level
height value for provided Roof geometry.
Calculated width of horizontal side of Building aligned with local X axis.
Calculated height of Building aligned with local Y axis.
Calculated depth of horizontal thickness of Building aligned with local -Z axis.
"../../X3dForWebAuthors/Chapter03Grouping/CoordinateAxes.x3d" "https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter03Grouping/CoordinateAxes.x3d" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/CoordinateAxes.x3d" "../../X3dForWebAuthors/Chapter03Grouping/CoordinateAxes.wrl" "https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter03Grouping/CoordinateAxes.wrl" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/CoordinateAxes.wrl"
"GridXY_20x20Movable.wrl" "https://www.web3d.org/x3d/content/examples/Basic/course/GridXY_20x20Movable.wrl" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/GridXY_20x20Movable.wrl" "GridXY_20x20Movable.x3d" "https://www.web3d.org/x3d/content/examples/Basic/course/GridXY_20x20Movable.x3d" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/GridXY_20x20Movable.x3d"
"GridXZ_20x20Movable.wrl" "https://www.web3d.org/x3d/content/examples/Basic/course/GridXZ_20x20Movable.wrl" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/GridXZ_20x20Movable.wrl" "GridXZ_20x20Movable.x3d" "https://www.web3d.org/x3d/content/examples/Basic/course/GridXZ_20x20Movable.x3d" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/GridXZ_20x20Movable.x3d"
"GridYZ_20x20Movable.wrl" "https://www.web3d.org/x3d/content/examples/Basic/course/GridYZ_20x20Movable.wrl" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/GridYZ_20x20Movable.wrl" "GridYZ_20x20Movable.x3d" "https://www.web3d.org/x3d/content/examples/Basic/course/GridYZ_20x20Movable.x3d" "https://www.web3d.org/x3d/content/examples/Savage/Tools/Authoring/GridYZ_20x20Movable.x3d"
ecmascript: var firstLoopWhileTrueCompleted; function tracePrint (outputString) { if (traceEnabled) Browser.println ('[Building' + name + ']' + outputString); } function alwaysPrint (outputString) { Browser.println ('[Building' + name + ']' + outputString); } function initialize () { built = false; firstLoopWhileTrueCompleted = false; alwaysPrint ('initialize, built=' + built); } function recheckUntilBuilt (value) { if (built == true) { built = true; // resend to trigger cancellation event for TimeSensor if (firstLoopWhileTrueCompleted) alwaysPrint ('recheckUntilBuilt() continuous built=true indicates internal error'); else firstLoopWhileTrueCompleted = true; return; // done } tracePrint ('recheckUntilBuilt testing...'); if (built == true) return; // done for (i=0; i < levels.length; i++) { if (levels[i].built == false) return; // not yet ready } tracePrint ('recheckUntilBuilt ready!'); alwaysPrint ('description=' + description); if (levels.length == 0) { alwaysPrint ('** warning, no levels found'); return; } orientation = new SFRotation (0, 1, 0, -xHeading * 3.14159 / 180.0); LevelsRoot.rotation = orientation; tracePrint ('xHeading=' + xHeading + ' degrees,' + 'orientation=' + orientation); width = 0; depth = 0; incrementalHeight = 0; // first child of LevelsRoot is oriented AuthorAssist2 Switch for (i=0; i < levels.length; i++) { tracePrint ('level[' + i + ']'); // compute max values for width, height, depth if (width < levels[i].width) width = levels[i].width; if (depth < levels[i].depth) depth = levels[i].depth; newTransform ='Transform {' + 'translation 0' + incrementalHeight + ' 0' + '}'; tracePrint ('newTransform=' + newTransform); newTransformNode = Browser.createVrmlFromString (newTransform); // returns MFNode // append newTransformNode to LevelsRoot.children LevelsRoot.children[i+1] = newTransformNode[0]; // append current Level to current newTransformNode newTransformNode[0].children[0] = levels[i]; incrementalHeight += levels[i].height; tracePrint ('incrementalHeight=' + incrementalHeight); } childCount = levels.length + 1; if (roof) { tracePrint ('roof'); newTransform ='Transform {' + 'translation 0' + incrementalHeight + ' 0' + '}'; tracePrint ('newTransform=' + newTransform); newTransformNode = Browser.createVrmlFromString (newTransform); // returns MFNode // append newTransformNode to LevelsRoot.children LevelsRoot.children[childCount] = newTransformNode[0]; childCount++; // append roof to current newTransformNode newTransformNode[0].children[0] = roof; incrementalHeight += roofHeight; } else alwaysPrint ('** warning, no roof found'); height = incrementalHeight; tracePrint ('(width, height, depth)=(' + width + ',' + height + ',' + depth + ')'); maxDimension = width; if (maxDimension < height) maxDimension = height; if (maxDimension < depth) maxDimension = depth; scale = new SFVec3f (maxDimension * 1.1, maxDimension * 1.1, maxDimension * 1.1); newView ='Viewpoint {' + 'description "' + name + ' (' + latitude + ',' + longitude + ')"' + 'position' + (width/2) + ' ' + (height*2.0/3.0) + ' ' + (depth*3) + ' ' + '}'; tracePrint ('newView=' + newView); newViewNode = Browser.createVrmlFromString (newView); // returns MFNode // append newViewNode to LevelsRoot.children LevelsRoot.children[childCount] = newViewNode[0]; childCount++; newView ='Viewpoint {' + 'description "' + name + ' (above)"' + 'position' + (width/2) + ' ' + (height*3.0) + ' ' + (-depth/2) + ' ' + 'orientation 1 0 0 -1.57' + '}'; tracePrint ('newView=' + newView); newViewNode = Browser.createVrmlFromString (newView); // returns MFNode // append newViewNode to LevelsRoot.children LevelsRoot.children[childCount] = newViewNode[0]; childCount++; if (authorAssist) { tracePrint ('authorAssist'); authorAssistChoice = 0; } else authorAssistChoice = -1; tracePrint ('LevelsRoot childCount=' + childCount + ' (Switch + # levels + [roof] + Viewpoint*2)'); built = true; tracePrint ('built=' + built); }
"SimpleBuildingConstructionExample.wrl" "https://www.web3d.org/x3d/content/examples/Savage/Buildings/UHRB/SimpleBuildingConstructionExample.wrl" "SimpleBuildingConstructionExample.x3d" "https://www.web3d.org/x3d/content/examples/Savage/Buildings/UHRB/SimpleBuildingConstructionExample.x3d"
"SimpleBuildingConstructionPrototypes" "is a prototype definition file" "" "Click this text to see" "SimpleBuildingConstructionExample"