API.e3D Class
API for wanaplan's 3D engine.
Constructor
API.e3D
()
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
-
filename
-
[params]
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
-
object
-
group
-
[isHistoryAction]
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
-
path
-
widgetName
Adds a widget with the url and the name of the widget. Important widget function.
castShadows
-
mesh
Casts the shadows induced by the given mesh. Beware, this is an expensive feature, performance may be altered.
Parameters:
-
mesh
BABYLON.MeshThe 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:
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:
The camera features
getCanvas
()
HTMLCanvasElement
Gets the 3D render canvas
used by the 3D view.
Returns:
the 3D canvas.
getGround
()
BABYLON.Mesh
Returns the cubic mesh acting as the ground.
Returns:
The ground
getInstance
-
mousePos
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
-
mousePos
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
()
BABYLON.Mesh
Searches for a mesh by its name.
Returns:
The mesh if found, null if not.
getMeshes
()
BABYLON.Mesh
Gets all meshes in the scene
Returns:
An array of all meshes.
getObjects
()
BABYLON.Mesh
Gets all handleable objects in the scene
Returns:
An array of all 3D handleable meshes.
getPickingInfo
-
mousePos
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
()
BABYLON.Mesh
Gets the mesh of the room for the active floor.
Returns:
The room as a 3D mesh.
getScene
()
BABYLON.Scene
Returns the current scene
Returns:
The current 3D scene
getSelectedObject
()
BABYLON.Mesh
Gets the currently selected object
Returns:
The currently selected object.
getSkySphere
()
BABYLON.Mesh
Returns the spheric mesh acting as the sky
Returns:
The sky
getSunlight
()
BABYLON.DirectionalLight
Returns the directional light acting as the sun
Returns:
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:
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 .
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
-
key
-
[flags]
Disables behaviors.
projectOnPlane
-
plane
-
[x]
-
[y]
Projects a screen position (by default the mouse position) on a 3D plane.
Parameters:
Returns:
The projected point
selectObject
-
object
Sets an object as the currently selected object.
Parameters:
-
object
BABYLON.MeshThe object to select.
setCameraById
-
cameraId
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
-
mousePos
-
material
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
-
material
Sets the default material for the ceiling of the room
Parameters:
-
material
BABYLON.MaterialThe new material.
setRoomFloorMaterial
-
material
Sets the default material for the floor of the room
Parameters:
-
material
BABYLON.MaterialThe new material.
switchCamera
()
Switches camera (between first person and orbit)
uncastShadows
-
mesh
Disables the casting of shadows by this mesh
Parameters:
-
mesh
BABYLON.MeshThe mesh
Properties
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
BaseComponent3DThe component of the action
-
object
BABYLON.MeshThe target.
-
params
ObjectParams of the history.
-
action
StringThe type of action done.