wnp.Programmable Class
Abstract class from which all the programmables inherit.
A programmable is responsible for exposing the parameters of an object and building the associated mesh.
A programmable life cycle follows a strict process. See the wiki for more informations.
Constructor
wnp.Programmable
-
engine
-
structure
-
[params={}]
Parameters:
-
engine
BABYLON.EngineThe BABYLON engine.
-
structure
ObjectStructureAn object structure to embed the programmable in.
-
[params={}]
Object optionalOptionnal parameters to build the object.
Item Index
Methods
Properties
Methods
animate
-
object3d
Programmable animation function This method is called when requesting an animation on the object. Virtual function
Parameters:
-
object3d
BABYLON.MeshThe mesh that must be animated in this context.
createInstance
-
filename
-
[params]
-
[materials]
-
structure
-
[callback]
-
customPath
-
engine
Creation of a programmable, using a file.
Parameters:
-
filename
StringThe name of the file to load. E.g :
Folder.Object.js
. -
[params]
Object optionalThe parameters to apply, will mask the default.
-
[materials]
Object optionalThe materials of the object, will mask the default.
-
structure
ObjectStructureThe object structure instance, that will embed the programmable file on the scene.
-
[callback]
Function optionalCalled when the programmable instance has been built.
-
customPath
StringThe path of the object.
-
engine
BABYLON.EngineThe engine.
decorate
-
material
-
collisionInfo
Programmable decoration function. This method applies the given material to the targeted part of the object.
Parameters:
-
material
BABYLON.MaterialThe material.
-
collisionInfo
BABYLON.PickingInfoPicking info about the target, see
BABYLON.PickingInfo
documentation.
Returns:
The previous material.
Deserialize
-
hybrid
Deserializes the object (from JSON).
Parameters:
-
hybrid
ObjectJSON describing the object, built with the method serialize.
Returns:
The Structure object built from the deserialization
deserialize
-
hybrid
Deserializes the object (from JSON).
Parameters:
-
hybrid
ObjectJSON describing the object, built with the method serialize.
Returns:
The Structure object built from the deserialization
generateFormForObject
-
param
-
instance
Generates a HTML form for the provided parameters.
Parameters:
-
param
ObjectThe parameters to show in the menu.
-
instance
ObjectStructureThe instance of the programmmable.
Returns:
HTML code.
getAvailableProperties
()
String
Returns the user-customizable properties for this programmable.
As of version 2.3, these properties are shown in a form when clicking on the object in the scene.
If not overriden, all default parameters are available for user customization.
If you want to override this behavior, you can use the method generateFormForObject
to quickly generate the HTML code.
Returns:
The menu, as an HTML form.
getDefaultMaterials
-
scene
Returns a hashmap which associates a default material for each mesh.
Virtual function
Parameters:
-
scene
BABYLON.SceneThe scene.
Returns:
Hashmap of materials, one for each mesh.
getDefaultParams
()
Object
Returns all the parameters needed to build the 3D object, along with their default value.
Virtual function.
Returns:
Hashmap, keys = parameters, values = default values.
getDepthParam
()
private
Get the depth parameter.
getHeightParam
()
private
Get the height parameter.
getParamType
-
name
Returns the type of the paramaters. This is used for the form in the programmable editor. By default, all params are strings.
Parameters:
-
name
StringThe name of the parameter.
Returns:
The type.
getWidthParam
()
private
Get the width parameter.
importBabylon
-
filePath
-
callback
Import a mesh to the babylon format in a programmable. The file babylon must have the extension .babylon. Import a mesh in .babylon format. This method is asynchronous.
Parameters:
Returns:
The mesh which will contains the mesh once the file is loaded.
mergeParams
-
params
Merge the parameters, private function.
Parameters:
-
params
ObjectThe params to merge with the current instance.
Properties
async
Boolean
private
Must be set to true
if you have to load something asynchronously
when building the 3D object (like a 3D model file import).
_/!\ only works with BABYLON importer /!_
Default: false
materials
BABYLON.Material
Materials are stored here.