GIScene.Utils Class
Utility Class with convenience functions stored in a central place.
Item Index
Methods
- arrayContains
- calcRenderDepthMinusBSphereRadius
- computeBoundingBoxRecursive
- computeVertexMeanRecursive
- disposeObject
- getObjectsBy
- getOrthoParamsFromPerspectiveCam
- getOrthoSizeFromFovDistanceAspect
- getPerspectiveDistanceFromFovHalfHeight
- getRelativeScreenCoordsFromDOMEvent
- getViewportCoordsFromDOMEvent
- isTypeOrClass
- mergeObjects
- polarTransformationAddAngle
- removeDuplicatesFromArray
- setFaceCulling
- setVertexColors
- transformRelativeScreenCoordsToViewportCoords
- transformViewportCoordsToRelativeScreenCoords
- translatePositionToBBoxCenter
- vector2ToVector3
- vector3ToVector2
Methods
arrayContains
-
array
-
item
check for item in array
Parameters:
-
array
Array -
item
Itemitem to check for in array
calcRenderDepthMinusBSphereRadius
-
object
-
camera
function to sort objects by object.renderDepth property. Calculates distance from camera to object.position and subtracts the boundingSphere.radius. Helps to obtain a better sorting of small objects inside bigger ones.
Parameters:
-
object
THREE.Object3D -
camera
THREE.Camera
Returns:
distance
computeBoundingBoxRecursive
-
node
Recursively computes the bounding box of a scenegraph
Parameters:
-
node
THREE.Object3D
Returns:
The united bounding box of the node and all its descendants
computeVertexMeanRecursive
-
node
Parameters:
-
node
THREE.Object3Dnode from which mean will be computed recursively including itself
Returns:
the point which represents the computed mean
disposeObject
-
object
-
deleteGeometry
-
deleteMaterial
-
deleteTextures
-
recursive
Delete an object properly
Parameters:
-
object
THREE.Object3Dthe object to be disposed
-
deleteGeometry
Booleanshould the geometry of the object be disposed
-
deleteMaterial
Booleanshould the material of the object be disposed also? Set to false if material is shared by other objects
-
deleteTextures
Booleanshould the textures of the object be disposed also? Set to false if textures are shared by other objects
-
recursive
Booleanshould all descendants of the object be disposed by the same criteria aswell?
getObjectsBy
-
rootObject
-
callback
get Objects by recursively calling a callback function which should return true or false to all children
Parameters:
-
rootObject
THREE.Object3D -
callback
Function
getOrthoParamsFromPerspectiveCam
-
canvas
-
perspectiveCam
-
focusDistance
function to calculate parameter for orthographic cameras based on params from a perspective camera and a distance at which the visible size of an object should be maintained
Parameters:
-
canvas
HTMLCanvasElement -
perspectiveCam
THREE.PerspectiveCamera -
focusDistance
Number
Returns:
parameters for THREE.OrthographicCamera
getOrthoSizeFromFovDistanceAspect
-
fov
-
distance
-
aspect
function to calculate the size parameters for an orthographic camera
Parameters:
-
fov
Numberin degrees
-
distance
Numberat which size is to be computed according to fov
-
aspect
Numberratio of canvas with / height
Returns:
orthosize Object which contains (top, bottom, left, right)-values for orthographic Cameras
getPerspectiveDistanceFromFovHalfHeight
-
fov
-
halfHeight
function to calculate the distance a perspective camera needs from a target to maintain the visual size of objects
Parameters:
-
fov
Numberfield of view in degrees
-
halfHeight
Numberhalf of the orthographic camera height or height at distance to be visible in camera in scene units
Returns:
distance a perspective camera with the given field of view (fov) should be placed from a target to completly see the given (half-)height
getRelativeScreenCoordsFromDOMEvent
-
domElement
-
event
Transforms absolute screencoordinates from DOMEvents to relative screencoordinates inside a DOMElement
Parameters:
-
domElement
DOMElementUsually the canvas Element
-
event
DOMEvente.g. a mouse event
Returns:
A Vector which contains the event coordinates transformed into coordinates relative to the upper left corner of the DOMElement
getViewportCoordsFromDOMEvent
-
domElement
-
event
Transforms screencoordinates from DOMEvents
Parameters:
-
domElement
DOMElementUsually the canvas Element
-
event
DOMEvente.g. a mouse event
Returns:
A Vector which contains the event coordinates transformed into viewport coordinates (x and y are between -1 and 1)
isTypeOrClass
-
typeOrClassName
isTypeOrClass
Parameters:
-
typeOrClassName
String
mergeObjects
-
base
-
extending
Merges object properties from a abse object with properties of an extending object.
Parameters:
-
base
Object -
extending
Object
Returns:
merged object with base properties extended/overwritten by extending object.
polarTransformationAddAngle
-
center
-
point
-
deltaTheta
-
deltaPhi
Performs a rotation of a point around a center
Parameters:
-
center
THREE.Vector3center of rotation
-
point
THREE.Vector3point to rotate around center
-
deltaTheta
Numberhorizontal angle in degrees to be rotated
-
deltaPhi
Numbervertical angle in degrees to be rotated
Returns:
rotatedPoint
removeDuplicatesFromArray
-
array
Removes duplicates from an array, even different objects with equal properties
Parameters:
-
array
Array
Returns:
filteredArray new filtered array
setFaceCulling
-
faceCullingMode
Sets the face culling mode for an object
Parameters:
-
faceCullingMode
THREE.FrontSide | | THREE.BackSide | | THREE.DoubleSide | | 'default'
setVertexColors
-
vertexColorMode
Sets the vertex color mode for an object
Parameters:
-
vertexColorMode
THREE.NoColors | | THREE.FaceColors | | THREE.VertexColors | | 'default'
transformRelativeScreenCoordsToViewportCoords
-
relativeScreenCoords
-
width
-
height
Transforms relative screen coordinates (e.g.from a canvas element) to normalized viewport coordinates
Parameters:
-
relativeScreenCoords
THREE.Vector2 -
width
Number -
height
Number
Returns:
A Vector which contains the relative screen coordinates transformed into viewport coordinates (x and y are between -1 and 1)
transformViewportCoordsToRelativeScreenCoords
-
viewPortCoords
-
width
-
height
Transforms viewport coordinates to relative screen coordinates (e.g.from a canvas element)
Parameters:
-
viewPortCoords
THREE.Vector2 -
width
Number -
height
Number
Returns:
A Vector which contains the viewport coordinates transformed into relative screen coordinates (x and y are between width and height)
translatePositionToBBoxCenter
-
object
sets the position property of an object to its boundingBoxCenter and changes vertex coordinates accordingly
Parameters:
-
object
THREE.Object3D
vector2ToVector3
-
v2
-
y
Transform a Vector2 to Vector3 by adding a y component
Parameters:
-
v2
THREE.Vector2represents horizontal points
-
y
Numberheight to add to horizontal point
Returns:
vector3ToVector2
-
v3
Flatten 3D Vectors horizontally to 2D Removes y from vector3 and puts z as y of vector2.
Parameters:
-
v3
THREE.Vector3