API Docs for: 1.0.2
Show:

GIScene.Utils Class

Defined in: GIScene\Utils.js:1
Module: GIScene

Utility Class with convenience functions stored in a central place.

Methods

arrayContains

(
  • array
  • item
)

check for item in array

Parameters:

  • array Array
  • item Item

    item to check for in array

calcRenderDepthMinusBSphereRadius

(
  • object
  • camera
)
Number

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:

Number:

distance

computeBoundingBoxRecursive

(
  • node
)
THREE.Box3

Recursively computes the bounding box of a scenegraph

Parameters:

  • node THREE.Object3D

Returns:

THREE.Box3:

The united bounding box of the node and all its descendants

computeVertexMeanRecursive

(
  • node
)
THREE.Vector3

Parameters:

  • node THREE.Object3D

    node from which mean will be computed recursively including itself

Returns:

THREE.Vector3:

the point which represents the computed mean

disposeObject

(
  • object
  • deleteGeometry
  • deleteMaterial
  • deleteTextures
  • recursive
)

Delete an object properly

Parameters:

  • object THREE.Object3D

    the object to be disposed

  • deleteGeometry Boolean

    should the geometry of the object be disposed

  • deleteMaterial Boolean

    should the material of the object be disposed also? Set to false if material is shared by other objects

  • deleteTextures Boolean

    should the textures of the object be disposed also? Set to false if textures are shared by other objects

  • recursive Boolean

    should 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
)
Object

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:

Object:

parameters for THREE.OrthographicCamera

getOrthoSizeFromFovDistanceAspect

(
  • fov
  • distance
  • aspect
)
Object

function to calculate the size parameters for an orthographic camera

Parameters:

  • fov Number

    in degrees

  • distance Number

    at which size is to be computed according to fov

  • aspect Number

    ratio of canvas with / height

Returns:

Object:

orthosize Object which contains (top, bottom, left, right)-values for orthographic Cameras

getPerspectiveDistanceFromFovHalfHeight

(
  • fov
  • halfHeight
)
Number

function to calculate the distance a perspective camera needs from a target to maintain the visual size of objects

Parameters:

  • fov Number

    field of view in degrees

  • halfHeight Number

    half of the orthographic camera height or height at distance to be visible in camera in scene units

Returns:

Number:

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
)
THREE.Vector2

Transforms absolute screencoordinates from DOMEvents to relative screencoordinates inside a DOMElement

Parameters:

  • domElement DOMElement

    Usually the canvas Element

  • event DOMEvent

    e.g. a mouse event

Returns:

THREE.Vector2:

A Vector which contains the event coordinates transformed into coordinates relative to the upper left corner of the DOMElement

getViewportCoordsFromDOMEvent

(
  • domElement
  • event
)
THREE.Vector2

Transforms screencoordinates from DOMEvents

Parameters:

  • domElement DOMElement

    Usually the canvas Element

  • event DOMEvent

    e.g. a mouse event

Returns:

THREE.Vector2:

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
)
Object

Merges object properties from a abse object with properties of an extending object.

Parameters:

  • base Object
  • extending Object

Returns:

Object:

merged object with base properties extended/overwritten by extending object.

polarTransformationAddAngle

(
  • center
  • point
  • deltaTheta
  • deltaPhi
)
THREE.Vector3

Performs a rotation of a point around a center

Parameters:

  • center THREE.Vector3

    center of rotation

  • point THREE.Vector3

    point to rotate around center

  • deltaTheta Number

    horizontal angle in degrees to be rotated

  • deltaPhi Number

    vertical angle in degrees to be rotated

Returns:

THREE.Vector3:

rotatedPoint

removeDuplicatesFromArray

(
  • array
)
Array

Removes duplicates from an array, even different objects with equal properties

Parameters:

  • array Array

Returns:

Array:

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
)
THREE.Vector2

Transforms relative screen coordinates (e.g.from a canvas element) to normalized viewport coordinates

Parameters:

  • relativeScreenCoords THREE.Vector2
  • width Number
  • height Number

Returns:

THREE.Vector2:

A Vector which contains the relative screen coordinates transformed into viewport coordinates (x and y are between -1 and 1)

transformViewportCoordsToRelativeScreenCoords

(
  • viewPortCoords
  • width
  • height
)
THREE.Vector2

Transforms viewport coordinates to relative screen coordinates (e.g.from a canvas element)

Parameters:

  • viewPortCoords THREE.Vector2
  • width Number
  • height Number

Returns:

THREE.Vector2:

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
)
THREE.Vector3

Transform a Vector2 to Vector3 by adding a y component

Parameters:

  • v2 THREE.Vector2

    represents horizontal points

  • y Number

    height to add to horizontal point

Returns:

THREE.Vector3:

vector3ToVector2

(
  • v3
)
THREE.Vector2

Flatten 3D Vectors horizontally to 2D Removes y from vector3 and puts z as y of vector2.

Parameters:

  • v3 THREE.Vector3

Returns:

THREE.Vector2: