Skip to content

Instantly share code, notes, and snippets.

@thw0rted
thw0rted / index.d.ts
Created Jul 27, 2017
Library Typing for milsymbol
View index.d.ts
type SymbolOptions = {
additionalInformation?: String,
altitudeDepth?: String,
combatEffectiveness?: String,
commonIdentifier?: String,
direction?: Number,
dtg?: String,
equipmentTeardownTime?: String,
evaluationRating?: String,
headquartersElement?: String,
@thw0rted
thw0rted / cesium.d.ts
Last active May 27, 2020
Updated typings file for Cesium v1.69 (I think?)
View cesium.d.ts
/**
* 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 / relativeOrientation.ts
Created May 4, 2018
Cesium function to transform relative heading-pitch-roll to absolute rotation Quaternion
View relativeOrientation.ts
import {
Cartesian3,
HeadingPitchRoll,
Matrix3,
Matrix4,
Quaternion,
Transforms,
} from "cesium";
/**
@thw0rted
thw0rted / ISO8601TimeIntervalCollection.ts
Created Dec 13, 2018
Cesium TimeIntervalColleciton that doesn't need individual instances of TimeInterval
View ISO8601TimeIntervalCollection.ts
import {
Event as CesiumEvent,
GregorianDate,
JulianDate,
RuntimeError,
TimeInterval,
TimeIntervalCollection,
} from "cesium";
export interface ConstructorOptions {
@thw0rted
thw0rted / banner.component.css
Created Jun 18, 2019
Material Banner component
View banner.component.css
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 / gist:ce452c3d6089d7bc391afff890e0f425
Created May 14, 2020
First test run errors - html-webpack-plugin
View gist:ce452c3d6089d7bc391afff890e0f425
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 / gist:e616537c31cf26331912f44a815fe029
Created May 14, 2020
Second test run errors -- html-webpack-plugin
View gist:e616537c31cf26331912f44a815fe029
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 / bounds.ts
Created Jan 4, 2021
Cesium entity bounds checking function
View bounds.ts
// 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 / viewport.ts
Created Jan 4, 2021
Computing visibility of Cesium entities
View viewport.ts
// 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]: [],
};