Members

(constant) colorSpace

Texture encoding used to have the right color of the .glb model + have an alpha channel

(constant) createLocalStorageCheckbox

(constant) createLocalStorageDetails

(constant) createLocalStorageNumberInput

(constant) createLocalStorageSlider

(constant) defaultConfigScene :SceneConfig

Default scene 3D config

Methods

RequestService()

Used by Widget.WebService Service used to make authentificate HTTP requests (with a token) Wiki : https://github.com/MEPP-team/UD-Viz/wiki/Request-Service#request-service

URLSetCameraMatrix(camera) → {boolean}

Initialize camera matrix with url search params produced by appendCameraMatrixToURL

Parameters:
NameTypeDescription
cameraTHREE.PerspectiveCamera

camera to initialize with url

Returns:

true if a camera matrix has been found in url

Type: 
boolean

addCubeTexture(paths, scene)

Parameters:
NameTypeDescription
pathsArray.<string>

paths of cube texture order should be negX posX negY posY posZ negZ

sceneTHREE.Scene

3d scene

addLights(scene) → {Object}

Add default lights to a scene 3D one directional and one ambient

Parameters:
NameTypeDescription
sceneTHREE.Scene

the scene where to add lights

Returns:
  • lights added
Type: 
Object

appendCameraMatrixToURL(url, camera) → {URL}

Append in search params of an url the camera matrix

Parameters:
NameTypeDescription
urlURL

url to append the camera matrix

cameraTHREE.PerspectiveCamera

camera to read the matrix from

Returns:
  • url to append the camera matrix
Type: 
URL

appendWireframeByGeometryAttributeToObject3D(object3D, nameOfGeometryAttribute, threshOldAngle)

Traverse a THREE.Object3D and append in each Object3D children a THREE.LineSegment geometry representing its wireframe. Each wireframe geometry will keep the associated attribute value.

Parameters:
NameTypeDescription
object3DTHREE.Object3D

An Object3D from three

nameOfGeometryAttributestring

The attribute used to split each geometry of the BufferGeometry

threshOldAnglenumber

An edge is only rendered if the angle (in degrees) between the face normals of the adjoining faces exceeds this value. default = 1 degree.

appendWireframeToObject3D(object3D, threshOldAngle)

Traverse a THREE.Object3D and append in each Object3D children a THREE.LineSegment geometry representing its wireframe

Parameters:
NameTypeDescription
object3DTHREE.Object3D

An Object3D from three

threshOldAnglenumber

An edge is only rendered if the angle (in degrees) between the face normals of the adjoining faces exceeds this value. default = 1 degree.

autoDurationTravel(controls, targetPos) → {number}

Compute a distance automatically for travel features of itowns Planar View

Note: Code retrieve itowns - https://github.com/iTowns/itowns/blob/1bad0d627764c73b606179c636ad7b70105dd633/src/Controls/PlanarControls.js#L712

Parameters:
NameTypeDescription
controlsitowns.PlanarControls

planar controls of itownsView

targetPosTHREE.Vector3

position of our target

Returns:

the duration of travel to focus a targetPosition

Type: 
number

bindLightTransform(offset, phi, theta, obj, dirLight)

Place the directional light in order its shadow camera fit the object

Parameters:
NameTypeDescription
offsetnumber

distance from the bounding sphere of the object to the light

phinumber

phi of spherical coord in radian

thetanumber

theta of spherical coord in radian

objTHREE.Object3D

the object to fit inside the projection plane of the shadow camera

dirLightTHREE.DirectionalLight

the light with the shadow camera

cameraFitRectangle(camera, min, max, altitude)

Move camera transform so the rectangle define by min & max (in the xy plane) fit the entire screen

Parameters:
NameTypeDescription
cameraTHREE.PerspectiveCamera

camera to update

minTHREE.Vector2

min coord of the rectangle

maxTHREE.Vector2

max coord of the rectangle

altitudenumber

altitude of the rectangle

To Do
  • rectangle is not force to be in xy plane

checkParentChild(child, parent) → {boolean}

Check if an html element belong to another one recursively

Parameters:
NameTypeDescription
childHTMLElement

html child

parentHTMLElement

html parent

Returns:
  • true if child belong to parent
Type: 
boolean

computeFileNameFromPath(path) → {string}

Parameters:
NameTypeDescription
pathstring

path of file

Returns:
  • name of file
Type: 
string
Example
console.log(computeFilename("./some_folder/another_folder/filename.whatever"))// log filename

computeNearFarCamera(camera, min, max)

Compute near and far of camera in order to wrap a box define by a min and max value

Parameters:
NameTypeDescription
cameraTHREE.PerspectiveCamera

camera to compute near and far

minTHREE.Vector3

min coord of box

maxTHREE.Vector3

max coord of box

createDateIntervalInput(labelText) → {Object}

Parameters:
NameTypeDescription
labelTextstring

text of the label

Returns:
  • date interval object
Type: 
Object

createDisplayable(label) → {Object}

Create a button to toggle visibility of the content in a container

Parameters:
NameTypeDescription
labelstring

label of the container

Returns:
  • parent is the element to add container is the element to fill
Type: 
Object

createLabelInput(labelText, inputType) → {Object}

Parameters:
NameTypeDescription
labelTextstring

label text

inputTypestring

input type

Returns:
  • parent is the element to add input is the input element
Type: 
Object

createSpriteFromString(string, optionsopt) → {THREE.Sprite}

Generates a sprite with text from a given string

Parameters:
NameTypeAttributesDescription
stringstring

The string displayed in the sprite

optionsSpriteStringOptions<optional>

Options of generation

Returns:

three's Sprite

Type: 
THREE.Sprite

downloadImageOnDisk(url, filename)

Download an image on the local disk

Parameters:
NameTypeDescription
urlstring

url of the image to download

filenamestring

name of the file on disk

downloadObjectAsJson(exportObj, exportName)

Download on the local disk an object as .json

Parameters:
NameTypeDescription
exportObjobject

object to download

exportNamestring

name of file

fetchC3DTileFeatureWithNodeText(itownsView, batchTableKey, batchTableValue) → {object}

fetchC3DTileFeatureWithNodeText takes a parameter batchTableKey and returns a feature from a 3DTileslayer if the batch table content of the feature contains a given batchTableValue string in the given key. Returns an object containing the first matching feature and its layer.

Parameters:
NameTypeDescription
itownsViewitowns.PlanarView

view

batchTableKeystring

a given batch table key

batchTableValuestring

a given batch table value

Returns:

containting the feature and the layer containing the feature

Type: 
object

focusC3DTilesLayer(itownsView, layer) → {Promise|null}

Focus a C3DTiles Layer

Parameters:
NameTypeDescription
itownsViewitowns.PlanarView

view

layeritowns.C3DTilesLayer

layer to focus

To Do
  • this function is used by widget should be contributed or removed
Returns:

Promise of the camera focusing on C3DTiles

Type: 
Promise | null

focusCameraOn(view, controls, targetPos, optionsopt) → {Promise}

Makes the camera move to focus on the target position.

Parameters:
NameTypeAttributesDescription
viewitowns.PlanarView

The iTowns view.

controlsitowns.PlanarControls

The camera controls.

targetPosTHREE.Vector3

The target position.

options*<optional>

Optional parameters for the travel. Accepted entries are :

  • duration : the duration of the movement, in seconds. The promise will resolve after this value. If not specified, the value auto is used for the movement (see the PlanarControls.initateTravel method), and the promise resolves imediatly.
  • verticalDistance : Desired height of the camera relative to the target position.
  • horizontalDistance : Desired distance of the camera from the target position.
To Do
  • this function is used by widget should be contributed or removed
Returns:

Promise of the camera focusing on target

Type: 
Promise

getUriLocalname(uri) → {string}

Return the localname of a URI

Parameters:
NameTypeDescription
uristring

The URI

Returns:

the localname of the URI

Type: 
string

getUriNamespace(uri) → {string}

Return the namespace of a URI

Parameters:
NameTypeDescription
uristring

The URI

Returns:

the namespace of the URI

Type: 
string

initRenderer(renderer, skyColor, clear)

Initialize the webgl renderer with default values

Parameters:
NameTypeDescription
rendererTHREE.WebGLRenderer

the renderer to init

skyColorTHREE.Color

clear color of the scene

clearboolean

autoclear, default is false

initScene(camera, renderer, scene, config, object3D) → {THREE.DirectionalLight}

Init scene 3D with SceneConfig

Parameters:
NameTypeDescription
cameraTHREE.PerspectiveCamera

camera rendering scene

rendererTHREE.WebGLRenderer

webgl renderer

sceneTHREE.Scene

scene

configSceneConfig | null

config

object3DTHREE.Object3D | null

object to focus with shadow map

Returns:
  • directional light created
Type: 
THREE.DirectionalLight

loadJSON(url) → {Promise}

Request a json file on a distant server

Parameters:
NameTypeDescription
urlstring

on the distant server

Returns:
  • promise resolving when .json loaded and pass it as first param
Type: 
Promise

loadMultipleJSON(urlArray) → {Promise}

Load multiples .json files

Parameters:
NameTypeDescription
urlArrayArray.<string>

path of .json files to loaded

Returns:
  • promise reolving when .json files loaded, each .json file can be access by the filename
Type: 
Promise
Example
loadMultipleJSON(["./some_folder/filename1.json","./another_folder/filename2.json"])
 .then((configs)=>{
   const contentFilename1 = configs["filename1"]
   const contentFilename2 = configs["filename2"]
})

loadTextFile(url) → {Promise}

Request a text file on a distant server

Parameters:
NameTypeDescription
urlstring

on the distant server

Returns:
  • promise resolving when file loaded and pass it as first param
Type: 
Promise

localStorageSetMatrix4(matrix4, key) → {boolean}

If there was a matrix4 recorded in localStorage restore it matrix4 + when tab is closing record current matrix4 /!\ calling this function make window reference the matrix4 avoiding it to be GC and could cause memory leak

Parameters:
NameTypeDescription
matrix4THREE.Matrix4

matrix4 to track

keystring

key of the item in localstorage

Returns:

true if matrix4 has been setted with localStorage

Type: 
boolean

localStorageSetVector3(vector3, key) → {boolean}

If there was a vector 3 recorded in localStorage within the key passed copy values in vector3 + when tab is closing record current vector3 values /!\ calling this function make window reference the vector3 avoiding it to be GC and could cause memory leak

Parameters:
NameTypeDescription
vector3THREE.Vector3

vector 3 to track

keystring

key of the item in localstorage

Returns:

true if vector3 has been setted with localStorage

Type: 
boolean

readFileAsGltf(e) → {Promise}

change callback of an input file reading gltf

Parameters:
NameTypeDescription
eobject

input of type file argument when 'change'

Returns:

promise resolving with the gltf loaded

Type: 
Promise

readSingleFileAsDataUrl(e, onLoad)

To be used with an input of type file

Parameters:
NameTypeDescription
eobject

input of type file argument when 'change'

onLoadFileReaderCallback

callback when file loaded

readSingleFileAsText(e, onLoad)

To be used with an input of type file

Parameters:
NameTypeDescription
eobject

input of type file argument when 'change'

onLoadFileReaderCallback | null

callback when file loaded

tokenizeURI(uri) → {Object}

Tokenize a URI into a namespace and localname A uri is typically composed of a [namespace]#[localname] e.g. http://site.io/test#example_1 here the namespace is 'http://site.io/test#' and the localname is 'example_1'

Parameters:
NameTypeDescription
uristring

The URI to be tokenized

Returns:

object of the URI tokenized

Type: 
Object

Type Definitions

FileReaderCallback(event)

Parameters:
NameTypeDescription
eventProgressEvent.<FileReader>

file reader event

SceneConfig

Properties
NameTypeDescription
cameraFovnumber

default camera fov

shadowMapSizenumber

size of shadow map

skyobject

sky property

Properties
NameTypeDescription
colorObject

rgb color (value are between [0,1])

sun_positionObject

position of the sun in sheprical coord (phi theta) + an offset THREEUtil.bindLightTransform

SpriteStringOptions

Type:
  • object
Properties
NameTypeDescription
baseHeightnumber

height of the canvas and the the font size

baseWidthnumber

width of the canvas

borderSizenumber

border size of the canvas

fontstring

string of font description css style-like

cbTickAnimationFrame(dt)

Parameters:
NameTypeDescription
dtnumber

Delta time between ticks