wnp.Programmable
Summary
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
Syntax
wnp.Programmable
-
engine
-
structure
-
[params={}]
Summary
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
Methods
animate
Syntax
animate
-
object3d
Summary
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
Syntax
createInstance
-
filename
-
[params]
-
[materials]
-
structure
-
[callback]
-
customPath
-
engine
Summary
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
Syntax
decorate
-
material
-
collisionInfo
Summary
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
Syntax
Summary
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
Syntax
Summary
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
Syntax
Summary
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
Syntax
Summary
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
Syntax
Summary
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
Syntax
Summary
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
Syntax
getDepthParam
()
private
Summary
Get the depth parameter.
getHeightParam
Syntax
getHeightParam
()
private
Summary
Get the height parameter.
getParamType
Syntax
Summary
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
Syntax
getWidthParam
()
private
Summary
Get the width parameter.
importBabylon
Syntax
importBabylon
-
filePath
-
callback
Summary
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
Syntax
mergeParams
-
params
Summary
Merge the parameters, private function.
Parameters:
-
params
ObjectThe params to merge with the current instance.
Properties
async
Syntax
Summary
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
Syntax
materials
BABYLON.Material
Summary
Materials are stored here.
structure
Syntax
structure
ObjectStructure
Summary
The associated object structure of the programmable.