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:
-
arrayArray -
itemItemitem 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:
-
objectTHREE.Object3D -
cameraTHREE.Camera
Returns:
distance
computeBoundingBoxRecursive
-
node
Recursively computes the bounding box of a scenegraph
Parameters:
-
nodeTHREE.Object3D
Returns:
The united bounding box of the node and all its descendants
computeVertexMeanRecursive
-
node
Parameters:
-
nodeTHREE.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:
-
objectTHREE.Object3Dthe object to be disposed
-
deleteGeometryBooleanshould the geometry of the object be disposed
-
deleteMaterialBooleanshould the material of the object be disposed also? Set to false if material is shared by other objects
-
deleteTexturesBooleanshould the textures of the object be disposed also? Set to false if textures are shared by other objects
-
recursiveBooleanshould 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:
-
rootObjectTHREE.Object3D -
callbackFunction
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:
-
canvasHTMLCanvasElement -
perspectiveCamTHREE.PerspectiveCamera -
focusDistanceNumber
Returns:
parameters for THREE.OrthographicCamera
getOrthoSizeFromFovDistanceAspect
-
fov -
distance -
aspect
function to calculate the size parameters for an orthographic camera
Parameters:
-
fovNumberin degrees
-
distanceNumberat which size is to be computed according to fov
-
aspectNumberratio 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:
-
fovNumberfield of view in degrees
-
halfHeightNumberhalf 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:
-
domElementDOMElementUsually the canvas Element
-
eventDOMEvente.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:
-
domElementDOMElementUsually the canvas Element
-
eventDOMEvente.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:
-
typeOrClassNameString
mergeObjects
-
base -
extending
Merges object properties from a abse object with properties of an extending object.
Parameters:
-
baseObject -
extendingObject
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:
-
centerTHREE.Vector3center of rotation
-
pointTHREE.Vector3point to rotate around center
-
deltaThetaNumberhorizontal angle in degrees to be rotated
-
deltaPhiNumbervertical angle in degrees to be rotated
Returns:
rotatedPoint
removeDuplicatesFromArray
-
array
Removes duplicates from an array, even different objects with equal properties
Parameters:
-
arrayArray
Returns:
filteredArray new filtered array
setFaceCulling
-
faceCullingMode
Sets the face culling mode for an object
Parameters:
-
faceCullingModeTHREE.FrontSide | | THREE.BackSide | | THREE.DoubleSide | | 'default'
setVertexColors
-
vertexColorMode
Sets the vertex color mode for an object
Parameters:
-
vertexColorModeTHREE.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:
-
relativeScreenCoordsTHREE.Vector2 -
widthNumber -
heightNumber
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:
-
viewPortCoordsTHREE.Vector2 -
widthNumber -
heightNumber
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:
-
objectTHREE.Object3D
vector2ToVector3
-
v2 -
y
Transform a Vector2 to Vector3 by adding a y component
Parameters:
-
v2THREE.Vector2represents horizontal points
-
yNumberheight 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:
-
v3THREE.Vector3
