WanaPlan

API Docs for: 2.7.0
Show:

wnp.Programmable

Module: Programmable
Parent Module: Wanaplan

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.Engine

    The BABYLON engine.

  • structure ObjectStructure

    An object structure to embed the programmable in.

  • [params={}] Object optional

    Optionnal parameters to build the object.

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.Mesh

    The mesh that must be animated in this context.

createInstance

Syntax

createInstance

(
  • filename
  • [params]
  • [materials]
  • structure
  • [callback]
  • customPath
  • engine
)
static

Summary

Creation of a programmable, using a file.

Parameters:

  • filename String

    The name of the file to load. E.g : Folder.Object.js.

  • [params] Object optional

    The parameters to apply, will mask the default.

  • [materials] Object optional

    The materials of the object, will mask the default.

  • structure ObjectStructure

    The object structure instance, that will embed the programmable file on the scene.

  • [callback] Function optional

    Called when the programmable instance has been built.

  • customPath String

    The path of the object.

  • engine BABYLON.Engine

    The engine.

decorate

Syntax

decorate

(
  • material
  • collisionInfo
)
BABYLON.Material

Summary

Programmable decoration function. This method applies the given material to the targeted part of the object.

Parameters:

  • material BABYLON.Material

    The material.

  • collisionInfo BABYLON.PickingInfo

    Picking info about the target, see BABYLON.PickingInfo documentation.

Returns:

BABYLON.Material:

The previous material.

Deserialize

Syntax

Deserialize

(
  • hybrid
)
Object static

Summary

Deserializes the object (from JSON).

Parameters:

  • hybrid Object

    JSON describing the object, built with the method serialize.

Returns:

Object:

The Structure object built from the deserialization

deserialize

Syntax

deserialize

(
  • hybrid
)
Object private

Summary

Deserializes the object (from JSON).

Parameters:

  • hybrid Object

    JSON describing the object, built with the method serialize.

Returns:

Object:

The Structure object built from the deserialization

generateFormForObject

Syntax

generateFormForObject

(
  • param
  • instance
)
String

Summary

Generates a HTML form for the provided parameters.

Parameters:

  • param Object

    The parameters to show in the menu.

  • instance ObjectStructure

    The instance of the programmmable.

Returns:

String:

HTML code.

getAvailableProperties

Syntax

getAvailableProperties

() String

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:

String:

The menu, as an HTML form.

getDefaultMaterials

Syntax

getDefaultMaterials

(
  • scene
)
Object

Summary

Returns a hashmap which associates a default material for each mesh.
Virtual function

Parameters:

  • scene BABYLON.Scene

    The scene.

Returns:

Object:

Hashmap of materials, one for each mesh.

getDefaultParams

Syntax

getDefaultParams

() Object

Summary

Returns all the parameters needed to build the 3D object, along with their default value.
Virtual function.

Returns:

Object:

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

getParamType

(
  • name
)
String

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 String

    The name of the parameter.

Returns:

String:

The type.

getWidthParam

Syntax

getWidthParam

() private

Summary

Get the width parameter.

importBabylon

Syntax

importBabylon

(
  • filePath
  • callback
)
Babylon.Mesh private

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:

  • filePath String

    The path to the .babylon file.

  • callback Function

    A function called when the file is loaded, this function will receive the mesh as parameter.

Returns:

Babylon.Mesh:

The mesh which will contains the mesh once the file is loaded.

mergeParams

Syntax

mergeParams

(
  • params
)
private

Summary

Merge the parameters, private function.

Parameters:

  • params Object

    The params to merge with the current instance.

serialize

Syntax

serialize

() Object

Summary

Serializes the object (to JSON).

Returns:

Object:

The serialization result, null if nothing is serialized.

Properties

async

Syntax

async

Boolean private

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

id

Syntax

id

Number

Summary

The id of the object.

materials

Syntax

materials

BABYLON.Material

Summary

Materials are stored here.

structure

Syntax

structure

ObjectStructure

Summary

The associated object structure of the programmable.