API Docs for: 2.7.3
Show:

API.e3D Class

Module: API
Parent Module: Wanaplan

API for wanaplan's 3D engine.

Constructor

API.e3D

()

Methods

addProgrammable

(
  • filename
  • [params]
)
ObjectStructure

Builds a 3D programmable object on the scene.

Parameters:

  • filename String

    The file name of the programmable.

  • [params] Object optional

    A set of parameters for this programmable

    • [materials] Object optional

      A set of serialized materials for this programmable object, that will override default materials.
      See getDefaultMaterials documentation in the Programmable class.

    • [params] Object optional

      A set of serialized parameters to build the geometry of this programmable object, that will override default params. See getDefaultParams documentation in the Programmable class.

    • [floor] FloorStructure optional

      Floor that will contain the object. Default is the current floor.

    • [position] BABYLON.Vector3 optional

      Position of the object. Default is the avatar position.

    • [rotation] BABYLON.Vector3 optional

      Rotation of the object. Default is none.

    • [customData] Object optional

      Custom data that will be serialized along with the programmable.

Returns:

ObjectStructure:

The resulting object structure, watch for the ready flag.

addToGroup

(
  • object
  • group
  • [isHistoryAction]
)
BABYLON.Mesh

Adds an object to a group.

Parameters:

  • object BABYLON.Mesh

    A group or an object.

  • group BABYLON.Mesh

    A group, an object or null.

  • [isHistoryAction] Boolean optional

    Add to the history or not.

Returns:

BABYLON.Mesh:

The new group.

addWidget

(
  • path
  • widgetName
)

Adds a widget with the url and the name of the widget. Important widget function.

Parameters:

  • path String

    The url of the widget.

  • widgetName String

    The name of widget.

castShadows

(
  • mesh
)

Casts the shadows induced by the given mesh. Beware, this is an expensive feature, performance may be altered.

Parameters:

  • mesh BABYLON.Mesh

    The mesh

deselectObject

()

Deselects any selected object and sets the currently selected object to null.

getCamera

() BABYLON.Camera

Returns the active camera of the 3D scene

Returns:

BABYLON.Camera:

The active camera

getCameraFeatures

() wnp.CameraFeatures

Returns an object containing some useful features to interact with the camera. See wnp.CameraFeatures documentation for a detailed review of all features.

Returns:

wnp.CameraFeatures:

The camera features

getCameraId

() Number

Gets the active camera's Id.

Returns:

Number:

The current camera Id

getCanvas

() HTMLCanvasElement

Gets the 3D render canvas used by the 3D view.

Returns:

HTMLCanvasElement:

the 3D canvas.

getGround

() BABYLON.Mesh

Returns the cubic mesh acting as the ground.

Returns:

BABYLON.Mesh:

The ground

getInstance

(
  • mousePos
)
wnp.BaseStructure

Gets the instance of the object picked by the given mouse position.

Parameters:

  • mousePos BABYLON.Vector2

    The mouse position on the screen.

Returns:

wnp.BaseStructure:

The instance of the mesh.

getMaterialFromMousePosition

(
  • mousePos
)
BABYLON.Material

Gets the material of the object picked by the given mouse position.

Parameters:

  • mousePos BABYLON.Vector2

    The mouse position on the screen.

Returns:

BABYLON.Material:

The material of the selected mesh.

getMeshByName

() BABYLON.Mesh

Searches for a mesh by its name.

Returns:

BABYLON.Mesh:

The mesh if found, null if not.

getMeshes

() BABYLON.Mesh

Gets all meshes in the scene

Returns:

BABYLON.Mesh:

An array of all meshes.

getObjects

() BABYLON.Mesh

Gets all handleable objects in the scene

Returns:

BABYLON.Mesh:

An array of all 3D handleable meshes.

getPickingInfo

(
  • mousePos
)
BABYLON.PickingInfo

Gets information on the mesh picked by the given mouse position. The picking information contains :

  • bu, bv : Information on the uv of the picked mesh
  • distance : The distance from the camera to the picked point
  • faceId : The face id of the mesh
  • hit : If it hit a mesh or not
  • pickedMesh : The collided mesh
  • pickedPoint : The point on the collided mesh
  • pickedSubMeshIndex : The index of the submesh

Parameters:

  • mousePos BABYLON.Vector2

    The mouse position on the screen.

Returns:

BABYLON.PickingInfo:

The collision information.

getRoomMesh

() BABYLON.Mesh

Gets the mesh of the room for the active floor.

Returns:

BABYLON.Mesh:

The room as a 3D mesh.

getScene

() BABYLON.Scene

Returns the current scene

Returns:

BABYLON.Scene:

The current 3D scene

getSelectedObject

() BABYLON.Mesh

Gets the currently selected object

Returns:

BABYLON.Mesh:

The currently selected object.

getSkySphere

() BABYLON.Mesh

Returns the spheric mesh acting as the sky

Returns:

BABYLON.Mesh:

The sky

getSunlight

() BABYLON.DirectionalLight

Returns the directional light acting as the sun

Returns:

BABYLON.DirectionalLight:

The sun

getTopLevelMeshes

() BABYLON.Mesh

Gets all top-level meshes of the scene (the parent of which is directly the floor, or a group)

Returns:

BABYLON.Mesh:

An array of all top-level 3D meshes.

import3DModel

(
  • url
  • [params]
  • successCallback
  • errorCallback
)

Imports a 3D model from an URL, using ASSIMP library. For supported formats, see assimp project.

Parameters:

  • url String

    The URL where the 3D model can be found, it can be an URL to a raw model or an URL to a zip file. Notice that if you use a zip file, the model and the textures must be added to the root of the archive. You can specify a string from a model (DAE, OBJ, STL, or JSON) as URL but you need to set the value of params.ext with the correct extension (ex. params.ext = "dae").

  • [params] Object optional

    A set of parameters for this programmable. See addProgrammable For the available nested parameters.

    • [ext] String optional

      If specified, it means the url parameter is a string decribing the model, and this parameter indicates its extension. Can be "dae", "obj", "stl" or "json".

  • successCallback Function

    A function called when the structure is ready. This function will take one parameter, which is the created ObjectStructure.

  • errorCallback Function

    A function called if the process fail.

lock

(
  • key
  • [flags]
)

Disables behaviors.

Parameters:

  • key Object

    Can be anything, is registered as key for the lock, the action will be unlocked only with the same key

  • [flags] Number optional

    Actions to lock among : CAMERALOCK = 1; DRAGLOCK = 2; KEYBOARDLOCK = 4; CAMERATRANSLATIONLOCK = 8; Default is all flags on.

projectOnPlane

(
  • plane
  • [x]
  • [y]
)
BABYLON.Vector3

Projects a screen position (by default the mouse position) on a 3D plane.

Parameters:

  • plane BABYLON.Plane

    The 3D plane

  • [x] Number optional

    The x coordinate

  • [y] Number optional

    The y coordinate

Returns:

BABYLON.Vector3:

The projected point

selectObject

(
  • object
)

Sets an object as the currently selected object.

Parameters:

  • object BABYLON.Mesh

    The object to select.

setCameraById

(
  • cameraId
)

Switches the type of the camera according to a given Id.

Parameters:

  • cameraId Number

    Must be API.e3D.ORBITCAMERA or API.e3D.FPSCAMERA, depending on the desired camera

setMaterialFromMousePosition

(
  • mousePos
  • material
)

Sets the material of the object picked by the given mouse position.

Parameters:

  • mousePos BABYLON.Vector2

    The mouse position on the screen.

  • material BABYLON.Material

    The new material.

setRoomCeilingMaterial

(
  • material
)

Sets the default material for the ceiling of the room

Parameters:

  • material BABYLON.Material

    The new material.

setRoomFloorMaterial

(
  • material
)

Sets the default material for the floor of the room

Parameters:

  • material BABYLON.Material

    The new material.

switchCamera

()

Switches camera (between first person and orbit)

uncastShadows

(
  • mesh
)

Disables the casting of shadows by this mesh

Parameters:

  • mesh BABYLON.Mesh

    The mesh

unlock

(
  • key
  • [flags]
)

Re-enables locked behaviors.

Parameters:

  • key Object

    Key that was used to lock actions

  • [flags] Number optional

    Actions to unlock among: CAMERALOCK = 1; DRAGLOCK = 2; KEYBOARDLOCK = 4; CAMERATRANSLATIONLOCK = 8; Default is all flags on.

Properties

CAMERALOCK

Number

CAMERATRANSLATIONLOCK

Number

DRAGLOCK

Number

FPSCAMERA

Number

KEYBOARDLOCK

Number

ORBITCAMERA

Number

Events

wnp.engine3D.cameraChanged

Fired when the user changes the camera.

wnp.request.historyAction

Fired when an object is refreshed and if the history is needed.

Event Payload:

  • component BaseComponent3D

    The component of the action

  • object BABYLON.Mesh

    The target.

  • params Object

    Params of the history.

  • action String

    The type of action done.