Namespace

simulator2D

simulator2D

A namespace.

Methods

# inner addGuiElements(params) → {json|string|string}

  • Add Gui Elements on Scene
Parameters:
Name Type Description
params object

a container with parameters.

reset- bool

Delete all Items.

items- array

Array of items to add

items.item object

item of array

items.item.file string

file of Image

items.item.width int

width of Image. 0 for auto size. Require height param

items.item.height int

height of Image. 0 for auto size. Require width param.

items.item.color object

color of element.

items.item.color.r int

define color from r value. From 0 to 255. Default value 255

items.item.color.g int

define color from g value. From 0 to 255. Default value 255

items.item.color.b int

define color from b value. From 0 to 255. Default value 255

items.item.color.a int

define alpha from a value. From 0 to 255. Default value 255

items.item.color.hex hex

define color from hex value. . Default value "#ffffff"

items.item.offset object

Define offset Position of Image from top or bottom and left or right. In pixels.

items.item.offset.top int

Top Offset in pixels. Bottom param must not be defined.

items.item.offset.bottom int

Bottom Offset in pixels. Top parammust not be defined.

items.item.offset.left int

Left Offset in pixels. Right param must not be defined.

items.item.offset.right int

Right Offset in pixels. Left param must not be defined.

items.item.pivot.x API2DMAPPWEB.simulator2D.IMAGE_PIVOT

Set Pivot point to positionate Image on X. Left - Center - Right

items.item.pivot.y API2DMAPPWEB.simulator2D.IMAGE_PIVOT

Set Pivot point to positionate Image on Y. Up - Center - Down

json - a container with parameters.

json

json.status - Status of function

string

json.statusMessage - Message of Status.

string

# inner applyColor(params-) → {json|bool|string|color}

Apply Color to Object

Parameters:
Name Type Description
params- object

a container with parameters.

params.id string

unique id that represent Object

params.r int

define color from r value. From 0 to 255. Default value 255

params.g int

define color from g value. From 0 to 255. Default value 255

params.b int

define color from b value. From 0 to 255. Default value 255

params.a int

define alpha from a value. From 0 to 255. Default value 255

params.hex hex

define color from hex value. . Default value "#ffffff"

params.resetTexture int

true to delete existing texture to see only color. Default true

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.color - Color Asigned

color

# inner applyTexture(params, callback) → {json|bool|string|array}

  • Apply texture to Object
Parameters:
Name Type Description
params object

a container with parameters.

file string

the path or URL to the file

filename string

Optional Information for base64 Images

id string

unique id that represent Object. Optional, if null: use Object under mouse

sizeTex float

Set Size of Texture. Optional

offset float

Set Offset Values of Texture. Optional

rotation float

Set Rotation of Texture. Optional

resetColor bool

true to delete existing Color. Go to White. Default true

callback object

a callback function when texture is applied

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.elements - Array of elements updated

array

# inner dispose() → {json|string|string}

  • Reset and Dispose Renderer

json - a container with parameters.

json

json.status - Status of function

string

json.statusMessage - Message of Status

string

# inner entireZoom() → {object|integer|json|bool|string|float}

  • Set Full View of Model

params - a container with parameters.

object

params.zoom - return zoom value for Full View

integer

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.zoom - Message of Status

float

# inner getAreasUserGroup(params) → {json|bool|string|int|array}

  • Get Array of index (int) of all Areas on Same User Group
Parameters:
Name Type Description
params object

a container with parameters.

id int

internal ID of model

json - a container with parameters.

json

json.status - true if no errors

bool

json.status - true if no errors

string

json.statusMessage - Error message

int

json.value - int index of Areas

array

# inner getColor(params) → {json|string|string|color}

  • Get Color from Area
Parameters:
Name Type Description
params object

a container with parameters.

id int

internal ID of model

json - a container with parameters.

json

json.status - Status of function

string

json.statusMessage - Message of Status.

string

params.color - Data of Color. r,g,b,hex

color

# inner getColorMouseOver() → {json|bool|string|color}

  • Get Color below mouse pointer without Lights and shadows

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.color

color

# inner getDataScene(params) → {json}

  • get Texture List and elements List on Scene
Parameters:
Name Type Description
params object

a container with parameters.

sortByID bool

If true, Elements List are order by specific order parameter.

Json Array of textures

json

# inner getFitTexture(params) → {json|bool|string|float}

  • Get Texture Fit Value
Parameters:
Name Type Description
params object

a container with parameters.

id string

unique id that represent Object

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.value

float

# inner getFunction() → {json|bool|API2DMAPPWEB.simulator2D.USERFUNCTIONS}

  • Returns the function value activated

json - a container with parameters.

json

json.status - true if no errors

bool

# inner getIDObjectMouseOver() → {json|bool|string|integer}

  • Get ID from element is below mouse pointer

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.id - return -1 if not element are below mouse

integer

# inner getLights() → {json|bool|string|float}

  • Get Lights value from model

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.light

float

# inner getLightsObject(params) → {json|bool|string|float}

  • Get Lights value from element.
Parameters:
Name Type Description
params object

a container with parameters.

id string

unique id that represent element

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.light - this value is independent from global Lights.

float

# inner getMirrorY() → {json|bool}

  • get Status Mirror Screen Effect

params - a container with parameters.

json

params.value - true to Activate Mirror Effect

bool

# inner getModel() → {json|string|string|string}

  • Get filename from actived model

json - a container with parameters.

json

json.status - Status of function

string

json.statusMessage - Message of Status

string

json.id - filename of model

string

# async inner getModelInfo(params) → {json}

  • Get json model's data. Important : this function is async. Use getModelInfo({}).then((json)=>{});
Parameters:
Name Type Description
params object

a container with parameters.

embedNotLocalTextureData string

Save base64Image

embedAllTextureData string
  • Save All texture like base64

represent an entire model with textures, displacement, sizes, groups, etc..

json

# inner getRotationTexture(params) → {json|string|string|int}

  • Get Rotation of Texture on Object
Parameters:
Name Type Description
params object

a container with parameters.

id int

Internal ID of model

json - a container with parameters.

json

json.status - Status of function

string

json.statusMessage - Message of Status.

string

json.rotation - Rotation of Texture

int

# inner getShadows() → {json|bool|string|float}

  • Get Shadows value from model

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.shadow

float

# inner getShadowsObject(params) → {json|bool|string|float}

  • Get Shadows value from element.
Parameters:
Name Type Description
params object

a container with parameters.

id string

unique id that represent Object

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.shadow - this value is independent from global Shadows.

float

# inner getSizeImage() → {json|string|string|int|int}

  • Set Image of the Model.

json - a container with parameters.

json

json.status - Status of function

string

json.statusMessage - Message of Status.

string

json.width - Width of Model Image in pixels.

int

json.height - Height of Model Image in pixels.

int

# inner getSizeObject(params) → {json|bool|string|int|int|int}

  • Get Size in MM of the Object
Parameters:
Name Type Description
params object

a container with parameters.

id int

internal ID of model

json - a container with parameters.

json

json.status - true if no errors

bool

json.status - true if no errors

string

json.statusMessage - Error message

int

json.width - width of Object in mm

int

json.height - height of Object in mm

int

# inner getSizeTexture(params) → {json|string|string|int|int}

  • Get Size in MM of the Texture
Parameters:
Name Type Description
params object

a container with parameters.

id int

internal ID of model

json - a container with parameters.

json

json.status - Status of function

string

json.statusMessage - Message of Status.

string

json.width - Width of Texture in mm

int

json.height - Height of Texture in mm

int

# inner getTexture() → {json|string|string|string}

  • Get filename from actived texture

json - a container with parameters.

json

json.status - Status of function

string

json.statusMessage - Message of Status

string

json.file - filename of texture

string

# inner getTextureData(params) → {json|string|string|string}

  • Get Texture's File from Area
Parameters:
Name Type Description
params object

a container with parameters.

id int

internal ID of model

json - a container with parameters.

json

json.status - Status of function

string

json.statusMessage - Message of Status.

string

json.value - Data of Texture. Null if not exits

string

# inner hasTexture(params) → {json|string|string|bool}

  • Confirm Texture is present on Area
Parameters:
Name Type Description
params object

a container with parameters.

id int

internal ID of model

json - a container with parameters.

json

json.status - Status of function

string

json.statusMessage - Message of Status.

string

json.value - Data of Texture. Null if not exits

bool

# inner loadScene(json) → {json|bool|string}

  • Load an entire model from json data
Parameters:
Name Type Description
json json

Contains all scene information

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

# inner resetJoinedGroups() → {json|bool|string}

  • Delete all join groups of objects made by user

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

# inner resetTexture(params) → {json|bool|string|int}

  • Delete texture of a element.
Parameters:
Name Type Description
params object

a container with parameters.

id string

unique id that represent Object

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.id - unique id that represent Object

int

# inner resetTexturesModel() → {json|bool|string}

  • Delete all textures mapped on model.

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

# inner saveFullImage(params-) → {json|bool|string}

  • Take an screenShot of Full view Model.
Parameters:
Name Type Description
params- object

a container with parameters.

params.mode- API2DMAPPWEB.simulator2D.EXPORTMODE

define way to obtain the image.

params.fileName- string

optional. For mode 0 and 1. Default Value: "image.jpg"

params.width- int

optional. Width in pixels of image.

params.noMapping- bool

optional. Get Image without Textures on it.

params.texture- string

optional.Iluminate Object that contains this texture.

params.elements- Array.<int>

optional.Iluminate Objects which ID is on array

params.r int

define color to Iluminate Objects from r value. From 0 to 255. Default value 255

params.g int

define color to Iluminate Objects from g value. From 0 to 255. Default value 255

params.b int

define color to Iluminate Objects from b value. From 0 to 255. Default value 255

params.a int

define alpha to Iluminate Objects from a value. From 0 to 255. Default value 255

params.hex hex

define color to Iluminate Objects from hex value. . Default value "#ffffff"

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

# inner saveImage(params-) → {json|bool|string|data}

  • Take an screenShot of simulator view and open a new web window to show the result.
Parameters:
Name Type Description
params- object

a container with parameters.

params.mode- API2DMAPPWEB.simulator2D.EXPORTMODE

define way to obtain the image

params.fileName- string

optional for mode 0 and 1. Default Value: "image.jpg"

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.data - Only on Mode 2 API2DMAPPWEB.simulator2D.EXPORTMODE.Data

data

# inner setBackGroundColor(params) → {json|bool|string|color|int}

Define background color of simulator

Parameters:
Name Type Description
params object

a container with parameters.

r int

define color from r value. From 0 to 255. Default value 255

g int

define color from g value. From 0 to 255. Default value 255

b int

define color from b value. From 0 to 255. Default value 255

a int

define alpha from a value. From 0 to 255. Default value 255

hex hex

define color from hex value. . Default value "#ffffff"

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.backgroundColor - Background Color

color

json.opacity - Opacity value

int

# inner setColor(params) → {json|bool|string|hex|bool}

  • Define actived Color to map when user use mapping function. onColorLoaded Event will be dispatch.
Parameters:
Name Type Description
params object

a container with parameters.

color object

a container with parameters.

color.r int

define color from r value. From 0 to 255. Default value 255

color.g int

define color from g value. From 0 to 255. Default value 255

color.b int

define color from b value. From 0 to 255. Default value 255

color.a int

define alpha from a value. From 0 to 255. Default value 255

color.hex hex

define color from hex value. . Default value "#ffffff"

resetTexture bool

true to delete existing texture to see only color. Default true

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.value - Color Activated

hex

json.resetTexture - Texture Will be Reset

bool

# inner setEffectApplyTexture(params) → {json|bool|string|int}

  • Define Screen effect that will show when simulator is calculating mapping process of a texture
Parameters:
Name Type Description
params object

a container with parameters.

effect int

: 0 not effect , 1 blur effect. Default 0

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.effect - Message of Status

int

# inner setFitTexture(params) → {json|bool|string}

  • Make Texture Fit Always Object If value is >0
Parameters:
Name Type Description
params object

a container with parameters.

id string

unique id that represent Object

value float

It is posible to scale Fit process using value. 1 = Same Size than object, 1.x bigger, 0.x smaller

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

# inner setFunction(params) → {json|bool|string}

  • Set function
Parameters:
Name Type Description
params object

a container with parameters.

value API2DMAPPWEB.simulator2D.USERFUNCTIONS

function to activate

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

# inner setImageModel(params) → {json|string|string}

  • Set Image of the Model.
Parameters:
Name Type Description
params object

a container with parameters.

file int

file to load the image from standard files ( jpg,png).

reset bool

Restore Model Image to Original.

json - a container with parameters.

json

json.status - Status of function

string

json.statusMessage - Message of Status.

string

# inner setLights(params) → {json|bool|string|int}

  • Define Lights values of entire model
Parameters:
Name Type Description
params object

a container with parameters.

light float

algorithm value to work bright areas of model. Default 0

relative boolean

if true light will add to current values. Default false

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.light - get Global Ligth

int

# inner setLightsObject(params) → {json|bool|string|int}

  • Define Lights values of element
Parameters:
Name Type Description
params object

a container with parameters.

id string

unique id that represent Object

light float

algorithm value to work bright areas of element.Default 0

relative boolean

if true light values will add to current values .Default false

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.light - get Light value

int

# inner setLightsShadows(params) → {json|bool|string|int|int}

  • Define Lights and Shadows values of entire model
Parameters:
Name Type Description
params object

a container with parameters.

light float

algorithm value to work bright areas of model.Default 0

shadow float

algorithm value to work shadow areas of model.Default 0

relative boolean

if true light and shadows values will add to current values .Default false

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.light - get Global Ligth

int

json.shadow - get Global Shadow

int

# inner setMirrorY(params) → {json|string|string}

  • Enable/Disable Mirror Screen on Y
Parameters:
Name Type Description
params object

a container with parameters.

value bool

true to Activate Mirror Effect

json - a container with parameters.

json

json.status - Status of function

string

json.statusMessage - Message of Status

string

# inner setModel(params, callback) → {json|bool|string}

  • Open a model
Parameters:
Name Type Description
params object

a container with parameters.

id string

item - name of model

callback object

a callback function when Model is Loaded

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

# inner setNumRepeatTexture(params) → {json|string|string}

  • Set Texture Translation
Parameters:
Name Type Description
params object

a container with parameters.

id int

Internal ID of model

x int

define number of repetions on X

y int

define number of repetions on y

render bool

Render Simulator after Translation

json - a container with parameters.

json

json.status - Status of function

string

json.statusMessage - Message of Status.

string

# inner setOriginalSizeTexture(params) → {json|string|string|int|int}

  • Set Size in MM of the Texture from original values
Parameters:
Name Type Description
params object

a container with parameters.

id int

internal ID of model

render bool

Render Simulator after Update Sizes.

json - a container with parameters.

json

json.status - Status of function

string

json.statusMessage - Message of Status.

string

json.width - width value of Texture.

int

json.height - height value of Texture.

int

# inner setPivotTexture(params) → {json|string|string}

  • Set Pivot Position to Control Texture Transforms ( Rotation, Scale )
Parameters:
Name Type Description
params object

a container with parameters.

id int

internal ID of model

x float

define x position. Default 0.5

y float

define y position Default 0.5

json - a container with parameters.

json

json.status - Status of function

string

json.statusMessage - Message of Status

string

# inner setRotationTexture(params) → {json|string|string}

  • Set Texture Rotation in Degrees
Parameters:
Name Type Description
params object

a container with parameters.

id int

internal ID of model

rotation int

define degrees rotation ( from -360 to 360 )

render bool

Render Simulator after Rotation

json - a container with parameters.

json

json.status - Status of function

string

json.statusMessage - Message of Status.

string

# inner setSelectedColor(params-) → {json|bool|string|color}

When mouse will be over element, this color will show for a while to indicate

Parameters:
Name Type Description
params- object

a container with parameters.

params.r int

define color from r value. From 0 to 255. Default value 255

params.g int

define color from g value. From 0 to 255. Default value 255

params.b int

define color from b value. From 0 to 255. Default value 255

params.a int

define alpha from a value. From 0 to 255. Default value 255

params.hex hex

define color from hex value. . Default value "#ffffff"

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.selectedColor - Color asigned

color

# inner setSelectedColorWhenMoveTexture(params) → {json|bool|string|color}

Color will be showed when user do displacement of texture

Parameters:
Name Type Description
params object

a container with parameters.

r int

define color from r value. From 0 to 255. Default value 255

g int

define color from g value. From 0 to 255. Default value 255

b int

define color from b value. From 0 to 255. Default value 255

a int

define alpha from a value. From 0 to 255. Default value 255

hex hex

define color from hex value. . Default value "#ffffff"

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.selectedColorWhenMoveTexture - Color value

color

# inner setShadows(params) → {json|bool|string|int}

  • Define Shadows values of entire model
Parameters:
Name Type Description
params object

a container with parameters.

shadow float

algorithm value to work shadow areas of model. Default 0

relative boolean

if true shadows values will add to current values . Default false

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.shadow - get Global Shadow

int

# inner setShadowsObject(params) → {json|bool|string|int}

  • Define Shadows values of element
Parameters:
Name Type Description
params object

a container with parameters.

id string

unique id that represent Object

shadow float

algorithm value to work shadow areas of element. Default 0

relative boolean

if true shadows values will add to current values. Default false

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.shadow - get Shadow value

int

# inner setSizeTexture(params) → {json|string|string}

  • Define Size in MM of the Texture
Parameters:
Name Type Description
params object

a container with parameters.

id int

internal ID of model

width int

width value of Texture. Default 1

height int

height value of Texture. Default 1

render bool

Render Simulator after Update Sizes.

json - a container with parameters.

json

json.status - Status of function

string

json.statusMessage - Message of Status.

string

# inner setTexture(params) → {json|bool|string}

  • Define actived texture to map when user use mapping function
Parameters:
Name Type Description
params object

a container with parameters.

file string

the path or URL to the file

width float

the width in mm of texture rapport

height float

the height in mm of texture rapport

resetColor bool

true to delete existing Color. Go to White. Default true

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

# inner setTranslateTexture(params) → {json|string|string|int|int}

  • Set Texture Translation in mm
Parameters:
Name Type Description
params object

a container with parameters.

id int

internal ID of model

x int

define x translation in mm

y int

define y translation in mm

relative bool

define y translation in mm on relative mode

render bool

Render Simulator after Translation

json - a container with parameters.

json

json.status - Status of function

string

json.statusMessage - Message of Status

string

json.valueX - new X Translation Value

int

json.valueY - new Y Translation Value

int

# inner setTranslateTextureRelativeObject(params) → {json|string|string|int|int}

  • Set Texture Translation Relative to Object Position
Parameters:
Name Type Description
params object

a container with parameters.

id int

internal ID of model

x float

define x % translation. from 0 to 1

y float

define y % translation. from 0 to 1

json - a container with parameters.

json

json.status - Status of function

string

json.statusMessage - Message of Status

string

json.valueX - new X Translation Value

int

json.valueY - new Y Translation Value

int

# inner setZoom(params) → {json|bool|string|float}

  • Define zoom view of model
Parameters:
Name Type Description
params object

a container with parameters.

zoom float

numeric value of zoom

relative boolean

if true zoom will add to current values. Default false

json - a container with parameters.

json

json.status - true if no errors

bool

json.statusMessage - Message of Status

string

json.zoom - Zoom value

float

Type Definitions

Object

# EXPORTMODE

Enum for user functions

Properties:
Name Type Description
Download number

Download Image

NewTab number

Open New Tab onn Browser showing the image

Data number

Get Json result with data value

Object

# IMAGE_PIVOT

Enum for user functions

Properties:
Name Type Description
Left number
Center number
Right number
Down number
Up number
Object

# USERFUNCTIONS

Enum for user functions

Properties:
Name Type Description
none number

Disable User Function

applyTexture number

If texture is Active,click over element will asign the texture

moveTexture number

Texture will be translate , if mouse is pressed and moved over an element

joinObjects number

Join objects on same Group to Share Material

joinObjects number

If Color is Active,click over element will asign the Color