@gov.nasa.jpl.honeycomb/three-extensions
v0.0.6
Published
Set of three.js math extensions and utilities.
Downloads
5
Readme
Three.js Math Extensions
Set of three.js math extensions and utilities.
Use
TODO
API
CircleArc
Mathematical description of an arc on the edge of a circle.
startPoint
startPoint : Vector2 = (0,0)The start point along the arc.
endPoint
endPoint : Vector2 = (0,0)The end point along the arc.
deltaHeading
deltaHeading : Number = 0The change in heading along the arc.
startHeading
startHeading : Number = 0The initial heading of the arc. This is only used for cases where the initial heading cannot be inferred, such as when the arc length are 0.
toShortestArc
toShortestArc( ) : voidConverts this arc to the shortest variant to get to the same point. If the arc sweeps larger than PI / 2 then we invert the delta heading.
getCircleCenter
getCircleCenter( target : Vector2 ) : Vector2Gets the center of the circle that this arc is on.
getCircleRadius
getCircleRadius( ) : NumberGets the radius of the circle that this arc is on.
getChordLength
getChordLength( ) : NumberGet the chord length from the start point to the end point of the arc.
getArcLength
getArcLength( ) : NumberGet the length of the arc.
closestPointToPoint
closestPointToPoint( point : Vector2, target : Vector2 ) : Vector2Sets target to the point on the arc that is closest to the given point. Returns the target vector.
at
at( t : Number, target : Vector2 ) : Vector2Sets the target vector to the point t along the arc where t is between 0 and 1.
Returns the target vector.
forEachPoint
forEachPoint(
steps : Number,
cb : ( point : Vector2, tangent : Vector2, index : Number ) => void
) : voidFires the callback for every steps + 1 points along the arc. Callback takes
the point, the tangent, and the step index.
generatePoints
generatePoints( steps : Number, target : Array ) : ArrayGenerate an array of x, y, z points along the the arc with z at 0.
copy
copy( source : CircleArc ) : voidSets this CircleArc to have the same properties as source.
clone
clone( ) : CircleArcCreates a clone of this object.
OptimizedPlaneBufferGeometry
A copy of three.js' PlaneBufferGeometry modified to immediately write to 32 bit buffers and excludes uv and normal attributes to save build and run time memory.
extends BufferGeometry
constructor
constructor(
width : Number = 1,
height : Number = 1,
widthSegments : Number = 1,
heightSegments : Number = 1
) : voidSpecifies the spatial width and height as well as the number of grid segments in the plane on the x and y axis.
InfiniteGrid
Mesh to render an infinite grid in size with grid lines every 10m and 1m by default and thicker lines at 0.
extends Mesh
constructor
constructor(
size1 : Number = 1,
size2 : Number = 10,
color : Color = 0xffffff,
distance : Number = 2000
) : voidParameters for setting the grid line stride, color, and distance the grid will fade out at.
DisposableEventListeners
Class for registering and tracking events on an EventListener
so they can be easily disposed of and removed.
addEventListener
addEventListener( target : EventDispatcher, name : String, callback : Function ) : voidAdd an event listener on target for event name
dispose
dispose( ) : voidRemove all event listeners that have been registered with this instance.
ObjectPool
Class for dynamically growing and shrinking a pool of objects based on a dataset and addin them to a three.js object.
disposeImmediately
disposeImmediately : Boolean = falseWhether the created pool objects should be deleted immediately when
shrinking the pool or if they should just be removed and disposed
when calling dispose.
constructor
constructor( parent : Object3D ) : voidTakes the Object3D to add all created pool objects to.
updateData
updateData( data : Array ) : voidUpdate the pool of objects based on the given data.
dispose
dispose( ) : voidDisposes of all objects created in the pool.
createObject
createObject( ) : Object3DCalled to create a new instance of the object to display when growing the pool.
Must be implemented.
updateObject
updateObject( object : Object3D, data : any ) : voidCalled to update object object based on the given data from the data array.
Must be implemented.
disposeObject
disposeObject( object : Object3D ) : voidFully dispose of the object that was created for the pool.
Must be implemented.
ExtMathUtils
Set of extended math utility functions.
fitPlaneFromPoints
static fitPlaneFromPoints(
points : Array<Vector3>,
targetPos : Vector3,
targetDir : Vector3
) : voidTakes a set of points and derives a best fit plane from them. Puts the plane origin in targetPos and the direction in targetDir.
FlyOrbitControls
An extension of three.js' OrbitControls that allow for flying with the WASD keys.
WASD are used to move the camera forward, back, left, and right. QE are used to move the camera up and down. And shift can be used to fly the camera faster.
extends OrbitControls
enableFlight
enableFlight : Boolean = trueWhether to enable flight controls.
baseSpeed
baseSpeed : Number = 0.1The base speed to fly at when shift is not held. Specified in units per second.
fastSpeed
fastSpeed : Number = 0.1The fast speed to fly at when shift is held. Specified in units per second.
constructor
constructor( camera : Camera, domElement : Element ) : voidTakes the camera and renderer.domElement that would normally be passed to OrbitControls.
MaterialReducer
Utility class for sharing equivelant textures and materials between objects in a hierarchy of objects.
ignoreKeys
ignoreKeys : Set = ['uuid']A set of keys to ignore when comparing materials and textures. Defaults to just include "uuid".
shareTextures
shareTextures : Boolean = trueWhether to share texture instances between the final materials.
process
process( object : Object3D ) : NumberProcess the given hierarchy of objects to reduce the number of materials and textures. Returns the number of materials removed. Materials and textures are shared over subsequent runs of the function.
GPUTimeSampler
Class for easily measuring the amount of time the GPU is taking to do work.
extends EventDispatcher
Events
query-complete
Fired whenever new GPU timing data is available. Provides the latest time and average/ time over the max number of sample frames.
isSupported
isSupported : BooleanWhether the required extension to use the class is supported.
constructor
constructor( context : WebGL2RenderingContext ) : voidstartQuery
startQuery( ) : voidShould be called at the beginning of the rendering work to be measured.
endQuery
endQuery( ) : voidShould be called at the end of the rendering work to be measured. Once the
query finishes the query-complete event will fire.
