Skip to content

Commit

Permalink
Adding lots of new tests for geometry types.
Browse files Browse the repository at this point in the history
  • Loading branch information
ikeough committed Jan 28, 2020
1 parent bad388b commit 3dab658
Show file tree
Hide file tree
Showing 61 changed files with 1,569 additions and 574 deletions.
2 changes: 1 addition & 1 deletion build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ echo 'Deleting the existing docs.'
rm -rf ./docs

echo 'Running example tests to generate updated sample data.'
dotnet test --filter "FullyQualifiedName~Elements.Tests.Examples"
dotnet test --filter Category=Examples

echo 'Building the Elements docs.'
docfx ./doc/docfx.json -f --serve
10 changes: 9 additions & 1 deletion doc/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,15 @@
{
"src": "../test/Elements.Tests/bin/debug/netcoreapp2.1/models/",
"files": [
"Elements_**.glb"
"Elements_**.glb",
"Elements_Geometry_Arc.glb",
"Elements_Geometry_Bezier.glb",
"Elements_Geometry_Line.glb",
"Elements_Geometry_Polygon.glb",
"Elements_Geometry_Polyline.glb",
"Elements_Geometry_Transform.glb",
"Elements_ModelCurve.glb",
"Elements_ModelPoints.glb"
],
"dest": "models"
}
Expand Down
2 changes: 1 addition & 1 deletion doc/template/hypar/partials/class.header.tmpl.partial
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="markdown level0 conceptual">{{{conceptual}}}</div>
{{#example.0}}
{{>partials/view3D}}
<h5 id="{{id}}_examples"><strong>{{__global.examples}}</strong></h5>
<h5 id="{{id}}"><strong>{{__global.examples}}</strong></h5>
{{/example.0}}
{{#example}}
{{{.}}}
Expand Down
1 change: 1 addition & 0 deletions doc/template/hypar/partials/view3D.tmpl.partial
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
window.addEventListener( 'resize', onWindowResize, false );

camera.position.z = 5;
camera.position.y = 5;

// Instantiate a loader
var loader = new THREE.GLTFLoader();
Expand Down
16 changes: 8 additions & 8 deletions doc/template/hypar/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ a {
}

body {
background-color: var(--hy-co-pale-green)
background-color: white;
}

body .toc {
background-color: var(--hy-co-pale-green)
background-color: white;
}

h1,h2,h3,h4,h5,h6 {
Expand Down Expand Up @@ -52,7 +52,7 @@ li {
}

.navbar {
background: var(--hy-co-dark-blue);
background: var(--hy-co-pink);
min-height: 40px;
}

Expand All @@ -66,7 +66,7 @@ li {
}

#navbar > ul > li > a {
color: var(--hy-co-pink)
color: var(--hy-co-pale-green);
}

p {
Expand All @@ -78,12 +78,12 @@ pre {
}

.sidefilter {
background: var(--hy-co-pale-green);
background: white;
border: none
}

.sidetoc {
background: var(--hy-co-pale-green);
background: white;
border: none
}

Expand All @@ -103,11 +103,11 @@ th {
.title {
margin: 0px;
padding: 15px;
color: var(--hy-co-pale-green)
color: var(--hy-co-pink)
}

.toc {
background: var(--hy-co-pale-green)
background: white;
}

#toc > ul > li.active.in > a{
Expand Down
3 changes: 3 additions & 0 deletions docs/Elements/toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@
<li>
<a href="../api/Elements.Geometry.Curve.html" name="" title="Curve">Curve</a>
</li>
<li>
<a href="../api/Elements.Geometry.EndType.html" name="" title="EndType">EndType</a>
</li>
<li>
<a href="../api/Elements.Geometry.FrameType.html" name="" title="FrameType">FrameType</a>
</li>
Expand Down
3 changes: 2 additions & 1 deletion docs/api/Elements.Beam.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ <h1 id="Elements_Beam" data-uid="Elements.Beam" class="text-break">Class Beam
window.addEventListener( 'resize', onWindowResize, false );

camera.position.z = 5;
camera.position.y = 5;

// Instantiate a loader
var loader = new THREE.GLTFLoader();
Expand Down Expand Up @@ -199,7 +200,7 @@ <h1 id="Elements_Beam" data-uid="Elements.Beam" class="text-break">Class Beam
};

animate();
</script><h5 id="Elements_Beam_examples"><strong>Examples</strong></h5>
</script><h5 id="Elements_Beam"><strong>Examples</strong></h5>
<pre><code class="lang-csharp" name="Main">// Create a framing type.
var profile = WideFlangeProfileServer.Instance.GetProfileByType(WideFlangeProfileType.W10x100);

Expand Down
3 changes: 2 additions & 1 deletion docs/api/Elements.Column.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ <h1 id="Elements_Column" data-uid="Elements.Column" class="text-break">Class Col
window.addEventListener( 'resize', onWindowResize, false );

camera.position.z = 5;
camera.position.y = 5;

// Instantiate a loader
var loader = new THREE.GLTFLoader();
Expand Down Expand Up @@ -199,7 +200,7 @@ <h1 id="Elements_Column" data-uid="Elements.Column" class="text-break">Class Col
};

animate();
</script><h5 id="Elements_Column_examples"><strong>Examples</strong></h5>
</script><h5 id="Elements_Column"><strong>Examples</strong></h5>
<pre><code class="lang-csharp" name="Main">// Create a framing type.
var profile = WideFlangeProfileServer.Instance.GetProfileByType(WideFlangeProfileType.W10x100);

Expand Down
3 changes: 2 additions & 1 deletion docs/api/Elements.Floor.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ <h1 id="Elements_Floor" data-uid="Elements.Floor" class="text-break">Class Floor
window.addEventListener( 'resize', onWindowResize, false );

camera.position.z = 5;
camera.position.y = 5;

// Instantiate a loader
var loader = new THREE.GLTFLoader();
Expand Down Expand Up @@ -199,7 +200,7 @@ <h1 id="Elements_Floor" data-uid="Elements.Floor" class="text-break">Class Floor
};

animate();
</script><h5 id="Elements_Floor_examples"><strong>Examples</strong></h5>
</script><h5 id="Elements_Floor"><strong>Examples</strong></h5>
<pre><code class="lang-csharp" name="Main">// Create a floor with no elevation.
var p = Polygon.L(10, 20, 5);
var floor1 = new Floor(p, 0.1);
Expand Down
130 changes: 130 additions & 0 deletions docs/api/Elements.Geometry.Arc.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,136 @@ <h1 id="Elements_Geometry_Arc" data-uid="Elements.Geometry.Arc" class="text-brea
<div class="markdown level0 summary"><p>An arc defined by a CCW rotation around a center between a start angle and an end angle.</p>
</div>
<div class="markdown level0 conceptual"></div>
<div id="model"></div>
<script type="text/javascript" src="../js/three.js"></script>
<script type="text/javascript" src="../js/GLTFLoader.js"></script>
<script type="text/javascript" src="../js/OrbitControls.js"></script>
<script>
var scene = new THREE.Scene();
var div = document.getElementById("model")
var camera = new THREE.PerspectiveCamera( 75, div.clientWidth/div.clientHeight, 0.1, 1000 );

var renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
renderer.setSize( div.clientWidth, div.clientHeight );
renderer.setClearColor( 0x000000, 0 );
div.appendChild( renderer.domElement );

var controls = new THREE.OrbitControls( camera, renderer.domElement );

var light = new THREE.HemisphereLight( 0xffffbb, 0x080820, 1 );
scene.add( light );

var axesHelper = new THREE.AxesHelper( 2 );
scene.add( axesHelper );

var size = 100;
var divisions = 100;
var colorCenterLine = new THREE.Color( 0xa0a0a0 );
var colorGrid = new THREE.Color( 0xdbdbdb );
var gridHelper = new THREE.GridHelper( size, divisions, colorCenterLine, colorGrid);
scene.add( gridHelper );

window.addEventListener( 'resize', onWindowResize, false );

camera.position.z = 5;
camera.position.y = 5;

// Instantiate a loader
var loader = new THREE.GLTFLoader();

// Load a glTF resource
loader.load(
// resource URL
'../models/Elements_Geometry_Arc.glb',
// called when the resource is loaded
function ( gltf ) {

scene.add( gltf.scene );

gltf.animations; // Array<THREE.AnimationClip>
gltf.scene; // THREE.Scene
gltf.scenes; // Array<THREE.Scene>
gltf.cameras; // Array<THREE.Camera>
gltf.asset; // Object

fitCameraToObject(gltf.scene, 2.0, controls)
},
// called while loading is progressing
function ( xhr ) {

console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );

},
// called when loading has errors
function ( error ) {

console.log( 'An error happened' );

}
);

var animate = function () {
requestAnimationFrame( animate );

// cube.rotation.x += 0.01;
// cube.rotation.y += 0.01;

renderer.render( scene, camera );
};

function onWindowResize(){
var div = document.getElementById("model");
camera.aspect = div.clientWidth / div.clientHeight;
camera.updateProjectionMatrix();
renderer.setSize( div.clientWidth, div.clientHeight );
};

const fitCameraToObject = function ( object, offset, orbitControls ) {

const boundingBox = new THREE.Box3();
boundingBox.setFromObject( object );

const center = boundingBox.getCenter();
const size = boundingBox.getSize();

// get the max side of the bounding box
const maxDim = Math.max( size.x, size.y, size.z ) * 3;
const fov = this.camera.fov * ( Math.PI / 180 );
let cameraZ = Math.abs( maxDim / 4 * Math.tan( fov * 2 ) );

// offset the camera as desired - usually a value of ~ 1.25 is good to prevent
// object filling the whole canvas
if( offset !== undefined && offset !== 0 ) cameraZ *= offset;

camera.position.set( center.x, center.y, cameraZ );

// set the far plane of the camera so that it easily encompasses the whole object
const minZ = boundingBox.min.z;
const cameraToFarEdge = ( minZ < 0 ) ? -minZ + cameraZ : cameraZ - minZ;

this.camera.far = cameraToFarEdge * 3;
this.camera.updateProjectionMatrix();

if ( orbitControls !== undefined ) {

// set camera to rotate around center of loaded object
orbitControls.target = center;

// prevent camera from zooming out far enough to create far plane cutoff
orbitControls.maxDistance = cameraToFarEdge * 2;
}
};

animate();
</script><h5 id="Elements_Geometry_Arc"><strong>Examples</strong></h5>
<pre><code class="lang-csharp" name="Main">var arc = new Arc(Vector3.Origin, 2.0, 0.0, 90.0);
Assert.True(new Vector3(2, 0, 0).IsAlmostEqualTo(arc.Start));
Assert.True(new Vector3(0, 2, 0).IsAlmostEqualTo(arc.End));

var arc1 = new Arc(Vector3.Origin, 2.0, 0.0, -90.0);
Assert.True(new Vector3(2, 0, 0).IsAlmostEqualTo(arc1.Start));
Assert.True(new Vector3(0, -2, 0).IsAlmostEqualTo(arc1.End));
</code></pre>
<div class="inheritance">
<h5>Inheritance</h5>
<div class="level0"><span class="xref">System.Object</span></div>
Expand Down
Loading

0 comments on commit 3dab658

Please sign in to comment.