Skip to content

Instantly share code, notes, and snippets.

View thw0rted's full-sized avatar

James Bromwell thw0rted

  • Baltimore
View GitHub Profile
@thw0rted
thw0rted / relativeOrientation.ts
Created May 4, 2018 12:25
Cesium function to transform relative heading-pitch-roll to absolute rotation Quaternion
import {
Cartesian3,
HeadingPitchRoll,
Matrix3,
Matrix4,
Quaternion,
Transforms,
} from "cesium";
/**
@thw0rted
thw0rted / viewport.ts
Created January 4, 2021 12:56
Computing visibility of Cesium entities
// Which entities are in/out of the current viewport? Returns an object where
// the passed items are binned according to whether their location(s) can be
// seen in the current viewport. The object keys are determined by the Cesium
// `Intersect` enum.
public findVisibility<T>(coll: T[], getBounds: BoundsFunction<T>, time?: JulianDate): VisibilityBins<T> {
const ret: VisibilityBins<T> = {
[Intersect.INSIDE]: [],
[Intersect.OUTSIDE]: [],
[Intersect.INTERSECTING]: [],
};
@thw0rted
thw0rted / bounds.ts
Created January 4, 2021 12:45
Cesium entity bounds checking function
// Check some commonly-used shapes and compute a bounding rectangle that
// encloses all the various graphics the Entity might be showing.
// NB: Remember to update this function if we start using more graphics
export function entityBounds(ent: Entity, time: JulianDate): Cartesian3 | Rectangle | undefined {
// Start with all position-independent graphics types
const corr: Cartesian3[] = ent.corridor?.positions?.getValue(time) || [];
const line: Cartesian3[] = ent.polyline?.positions?.getValue(time) || [];
const lineVol: Cartesian3[] = ent.polylineVolume?.positions?.getValue(time) || [];
const poly: Cartesian3[] = ent.polygon?.hierarchy?.getValue(time)?.positions || [];
const wall: Cartesian3[] = ent.wall?.positions?.getValue(time) || [];
@thw0rted
thw0rted / cesium.d.ts
Last active May 27, 2020 08:10
Updated typings file for Cesium v1.69 (I think?)
/**
* Cesium type definitions
* For use with Cesium v1.66
* Created by Aigars Zeiza <https://github.com/Zuzon>
* Modified by Harry Nicholls <harry@northstar-robotics.com>
* Updated for v1.66.0 by James Bromwell <https://github.com/Thw0rted>
*/
declare module "cesium"{
type RenderState = any;
@thw0rted
thw0rted / gist:e616537c31cf26331912f44a815fe029
Created May 14, 2020 12:06
Second test run errors -- html-webpack-plugin
FAIL spec/basic.spec.js (50.953s)
HtmlWebpackPlugin
√ generates a default index.html file for a single entry point (2901ms)
√ properly encodes file names in emitted URIs (104ms)
× properly encodes file names in emitted URIs but keeps the querystring (30018ms)
√ generates a default index.html file with multiple entry points (114ms)
× allows you to specify a custom loader without injection (45ms)
√ should pass through loader errors (1356ms)
× uses a custom loader from webpacks config (47ms)
√ works when using html-loader (535ms)
@thw0rted
thw0rted / gist:ce452c3d6089d7bc391afff890e0f425
Created May 14, 2020 12:05
First test run errors - html-webpack-plugin
FAIL spec/basic.spec.js (56.793s)
HtmlWebpackPlugin
√ generates a default index.html file for a single entry point (2298ms)
√ properly encodes file names in emitted URIs (598ms)
× properly encodes file names in emitted URIs but keeps the querystring (30018ms)
× generates a default index.html file with multiple entry points (44ms)
√ allows you to specify a custom loader without injection (1199ms)
√ should pass through loader errors (148ms)
√ uses a custom loader from webpacks config (102ms)
√ works when using html-loader (262ms)
@thw0rted
thw0rted / banner.component.css
Created June 18, 2019 07:52
Material Banner component
div.container {
width: 100%;
box-sizing: border-box;
/* Per Banner spec, with bigger left gutter to account for menu button */
padding: 8px 8px 8px 72px;
display: flex;
flex-direction: row;
align-items: flex-end;
overflow: hidden;
}
@thw0rted
thw0rted / ISO8601TimeIntervalCollection.ts
Created December 13, 2018 13:05
Cesium TimeIntervalColleciton that doesn't need individual instances of TimeInterval
import {
Event as CesiumEvent,
GregorianDate,
JulianDate,
RuntimeError,
TimeInterval,
TimeIntervalCollection,
} from "cesium";
export interface ConstructorOptions {
@thw0rted
thw0rted / index.d.ts
Created July 27, 2017 12:06
Library Typing for milsymbol
type SymbolOptions = {
additionalInformation?: String,
altitudeDepth?: String,
combatEffectiveness?: String,
commonIdentifier?: String,
direction?: Number,
dtg?: String,
equipmentTeardownTime?: String,
evaluationRating?: String,
headquartersElement?: String,