API.e3D
Summary
API for wanaplan's 3D engine.
Constructor
API.e3D
Syntax
API.e3D
()
Summary
Item Index
Methods
- addProgrammable
- addToGroup
- addWidget
- castShadows
- deselectObject
- getCamera
- getCameraFeatures
- getCameraId
- getCanvas
- getGround
- getInstance
- getMaterialFromMousePosition
- getMeshByName
- getMeshes
- getObjects
- getPickingInfo
- getRoomMesh
- getScene
- getSelectedObject
- getSkySphere
- getSunlight
- getTopLevelMeshes
- import3DModel
- lock
- projectOnPlane
- selectObject
- setCameraById
- setMaterialFromMousePosition
- setRoomCeilingMaterial
- setRoomFloorMaterial
- switchCamera
- uncastShadows
- unlock
Methods
addProgrammable
Syntax
Summary
Builds a 3D programmable object on the scene.
Parameters:
-
filename
StringThe file name of the programmable.
-
[params]
Object optionalA set of parameters for this programmable
-
[materials]
Object optionalA set of serialized materials for this programmable object, that will override default materials.
SeegetDefaultMaterials
documentation in theProgrammable
class. -
[params]
Object optionalA set of serialized parameters to build the geometry of this programmable object, that will override default params. See
getDefaultParams
documentation in theProgrammable
class. -
[floor]
FloorStructure optionalFloor that will contain the object. Default is the current floor.
-
[position]
BABYLON.Vector3 optionalPosition of the object. Default is the avatar position.
-
[rotation]
BABYLON.Vector3 optionalRotation of the object. Default is none.
-
[customData]
Object optionalCustom data that will be serialized along with the programmable.
-
Returns:
The resulting object structure, watch for the ready
flag.
addToGroup
Syntax
addToGroup
-
object
-
group
-
[isHistoryAction]
Summary
Adds an object to a group.
Parameters:
-
object
BABYLON.MeshA group or an object.
-
group
BABYLON.MeshA group, an object or null.
-
[isHistoryAction]
Boolean optionalAdd to the history or not.
Returns:
The new group.
addWidget
Syntax
addWidget
-
path
-
widgetName
Summary
Adds a widget with the url and the name of the widget. Important widget function.
castShadows
Syntax
castShadows
-
mesh
Summary
Casts the shadows induced by the given mesh. Beware, this is an expensive feature, performance may be altered.
Parameters:
-
mesh
BABYLON.MeshThe mesh
deselectObject
Syntax
deselectObject
()
Summary
Deselects any selected object and sets the currently selected object to null.
getCamera
Syntax
getCamera
()
BABYLON.Camera
Summary
Returns the active camera of the 3D scene
Returns:
The active camera
getCameraFeatures
Syntax
Summary
Returns an object containing some useful features to interact with the camera. See wnp.CameraFeatures documentation for a detailed review of all features.
Returns:
The camera features
getCanvas
Syntax
getCanvas
()
HTMLCanvasElement
Summary
Gets the 3D render canvas
used by the 3D view.
Returns:
the 3D canvas.
getGround
Syntax
getGround
()
BABYLON.Mesh
Summary
Returns the cubic mesh acting as the ground.
Returns:
The ground
getInstance
Syntax
getInstance
-
mousePos
Summary
Gets the instance of the object picked by the given mouse position.
Parameters:
-
mousePos
BABYLON.Vector2The mouse position on the screen.
Returns:
The instance of the mesh.
getMaterialFromMousePosition
Syntax
getMaterialFromMousePosition
-
mousePos
Summary
Gets the material of the object picked by the given mouse position.
Parameters:
-
mousePos
BABYLON.Vector2The mouse position on the screen.
Returns:
The material of the selected mesh.
getMeshByName
Syntax
getMeshByName
()
BABYLON.Mesh
Summary
Searches for a mesh by its name.
Returns:
The mesh if found, null if not.
getMeshes
Syntax
getMeshes
()
BABYLON.Mesh
Summary
Gets all meshes in the scene
Returns:
An array of all meshes.
getObjects
Syntax
getObjects
()
BABYLON.Mesh
Summary
Gets all handleable objects in the scene
Returns:
An array of all 3D handleable meshes.
getPickingInfo
Syntax
getPickingInfo
-
mousePos
Summary
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.Vector2The mouse position on the screen.
Returns:
The collision information.
getRoomMesh
Syntax
getRoomMesh
()
BABYLON.Mesh
Summary
Gets the mesh of the room for the active floor.
Returns:
The room as a 3D mesh.
getScene
Syntax
getScene
()
BABYLON.Scene
Summary
Returns the current scene
Returns:
The current 3D scene
getSelectedObject
Syntax
getSelectedObject
()
BABYLON.Mesh
Summary
Gets the currently selected object
Returns:
The currently selected object.
getSkySphere
Syntax
getSkySphere
()
BABYLON.Mesh
Summary
Returns the spheric mesh acting as the sky
Returns:
The sky
getSunlight
Syntax
getSunlight
()
BABYLON.DirectionalLight
Summary
Returns the directional light acting as the sun
Returns:
The sun
getTopLevelMeshes
Syntax
getTopLevelMeshes
()
BABYLON.Mesh
Summary
Gets all top-level meshes of the scene (the parent of which is directly the floor, or a group)
Returns:
An array of all top-level 3D meshes.
import3DModel
Syntax
import3DModel
-
url
-
[params]
-
successCallback
-
errorCallback
Summary
Imports a 3D model from an URL, using ASSIMP library.
For supported formats, see .
Parameters:
-
url
StringThe 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 optionalA set of parameters for this programmable. See addProgrammable For the available nested parameters.
-
[ext]
String optionalIf 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
FunctionA function called when the structure is ready. This function will take one parameter, which is the created
ObjectStructure
. -
errorCallback
FunctionA function called if the process fail.
lock
Syntax
lock
-
key
-
[flags]
Summary
Disables behaviors.
projectOnPlane
Syntax
projectOnPlane
-
plane
-
[x]
-
[y]
Summary
Projects a screen position (by default the mouse position) on a 3D plane.
Parameters:
Returns:
The projected point
selectObject
Syntax
selectObject
-
object
Summary
Sets an object as the currently selected object.
Parameters:
-
object
BABYLON.MeshThe object to select.
setCameraById
Syntax
setCameraById
-
cameraId
Summary
Switches the type of the camera according to a given Id.
Parameters:
-
cameraId
NumberMust be API.e3D.ORBITCAMERA or API.e3D.FPSCAMERA, depending on the desired camera
setMaterialFromMousePosition
Syntax
setMaterialFromMousePosition
-
mousePos
-
material
Summary
Sets the material of the object picked by the given mouse position.
Parameters:
-
mousePos
BABYLON.Vector2The mouse position on the screen.
-
material
BABYLON.MaterialThe new material.
setRoomCeilingMaterial
Syntax
setRoomCeilingMaterial
-
material
Summary
Sets the default material for the ceiling of the room
Parameters:
-
material
BABYLON.MaterialThe new material.
setRoomFloorMaterial
Syntax
setRoomFloorMaterial
-
material
Summary
Sets the default material for the floor of the room
Parameters:
-
material
BABYLON.MaterialThe new material.
switchCamera
Syntax
switchCamera
()
Summary
Switches camera (between first person and orbit)
uncastShadows
Syntax
uncastShadows
-
mesh
Summary
Disables the casting of shadows by this mesh
Parameters:
-
mesh
BABYLON.MeshThe mesh
Properties
Events
wnp.engine3D.cameraChanged
Syntax
wnp.engine3D.cameraChanged
Summary
Fired when the user changes the camera.
wnp.request.historyAction
Syntax
wnp.request.historyAction
Summary
Fired when an object is refreshed and if the history is needed.
Event Payload:
-
component
BaseComponent3DThe component of the action
-
object
BABYLON.MeshThe target.
-
params
ObjectParams of the history.
-
action
StringThe type of action done.