API Docs for: 2.7.3
Show:

wnp.Programmable Class

Module: Programmable
Parent Module: Wanaplan

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

(
  • object3d
)

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

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

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

(
  • material
  • collisionInfo
)
BABYLON.Material

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

(
  • hybrid
)
Object static

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

(
  • hybrid
)
Object private

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

(
  • param
  • instance
)
String

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

() 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:

String:

The menu, as an HTML form.

getDefaultMaterials

(
  • scene
)
Object

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

() Object

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

() private

Get the depth parameter.

getHeightParam

() private

Get the height parameter.

getParamType

(
  • name
)
String

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

() private

Get the width parameter.

importBabylon

(
  • filePath
  • callback
)
Babylon.Mesh private

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

(
  • params
)
private

Merge the parameters, private function.

Parameters:

  • params Object

    The params to merge with the current instance.

serialize

() Object

Serializes the object (to JSON).

Returns:

Object:

The serialization result, null if nothing is serialized.

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

id

Number

The id of the object.

materials

BABYLON.Material

Materials are stored here.

notEditable

Boolean

Flag to disable edition.

Default: false

structure

ObjectStructure

The associated object structure of the programmable.