Transcript
Page 1: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 DocumentationRelease 01

uinnova inc

May 10 2017

Table of Contents

1 Concept Guide 311 model and Scene 312 Model Library 413 Scene Levels 414 API Developement 6

2 Overview 9

3 API Referance 1131 camera 1132 object 1533 gui 1834 BaseObject 2135 ScriptObject 3636 util 3737 input 4438 console 4739 Data Interface 49

4 Try API Online 59

5 Deploy 61

6 Q amp A 63

7 Revise History 65

i

ii

uBudiler API 20 Documentation Release 01

uBuilder API is a set of javascript-like executed-at-runtime scripts runs inside Momoda system uBuilder API providesoperations on object UI behavior and effect in 3D scene uBuilder API could be used to make customized industriesspecific apps such as storage management emergency drilling archive management intelligent buildings etc

uBuilder API supports fetch and interact with external data source Through uBuilder APIrsquos data interface 3rd partysystem could push realtime data to 3D scene to drive realtime object behavior andor information display

Table of Contents 1

uBudiler API 20 Documentation Release 01

2 Table of Contents

CHAPTER 1

Concept Guide

model and Scene

There are two basic and import concepts in Momoda model and scene

Model

Model is polygon representation of object 3D object could presents something from real world concept or just yourimagination

Model in Momoda shares the same of idea of 3D object in general those 3D object could be organized and put into3D scene like Lego

Momoda also provides lsquoofficialrsquo model library and could be used for free during 3D scene creation User could alsoleverage uinnovarsquos profession service to create customized models Besides Momoda also provide a 3DSMax pluginwhich could upload 3D object created in 3DSMax to Momodarsquos model library and user could create and use their ownmodel using this plugin which make Momoda very extensible in term of model creation

Scene

Scene this one of the basic concept in Momoda By use momodarsquos free drawing studio user can place combine andlayout 3D modelsobjects into a scene in drag and drop fashion Typical scene could be campus a factory a harborand any another things you may think of We call them ldquoMomoda Scenerdquo

Momoda scene are stored in Momoda Cloud which could be opened by own later on for editing preview or API de-bugging Momoda scene can also be download and running locally as ldquoMomoda Offline Editionrdquo (may need purchaselicense issued by uinnova inc)

3

uBudiler API 20 Documentation Release 01

Model Library

There are three common objects in right navigation bar of momoda studio model texture and function

bull Model

Objects like building car people desk etc User could also upload their custom objects through Momoda 3DSMaxplugin

bull Texture

Textures to cover the surface of object also supports use custom texture upload by user

bull Function

Effects such as fire rain flash or assistant function such as drawing line pipeline or text Function are system build-inand do not supports user upload at this time

Scene Levels

There are four level in Momoda scene campus building stories and rooms

bull Campus

Upmost level of a scene

4 Chapter 1 Concept Guide

uBudiler API 20 Documentation Release 01

bull Building

Buildings (do not includes building facade)

bull Stories

13 Scene Levels 5

uBudiler API 20 Documentation Release 01

bull Room

API Developement

Momoda supports online development via uBuilder API developing web page

6 Chapter 1 Concept Guide

uBudiler API 20 Documentation Release 01

Create New API Project

There a two pane in developing web page left pane is for script editing right pane is for running scripts in 3D sceneTo begin a new API development project visit the uBuilder API developing web page input the ID of target 3D scenethen click New button

Deploy API Project to Scene

To includes API script into your own scene simply copy all the script source code and paste to the text box of MyProjects mdashgt Target Scene mdashgt Configure Scene

Keyboard Shortcuts

Below are keyboard shortcuts in uBuilder API debug page

bull Ctrl+Enter Run Script

bull Ctrl+R Reset Scene

bull Ctrl+ CommentUncomment source code

API Namespace

uBuilder API functions are grouped in following namespaces

Namespace Descriptioncamera camera controlobject create search or modify objects in 3D scenegui manage user interface in 3D sceneBaseObject control existing objectsScriptObject associate scripts on existing objectutil common functionsinput keyboard and mouse eventsconsole management console

14 API Developement 7

uBudiler API 20 Documentation Release 01

8 Chapter 1 Concept Guide

CHAPTER 2

Overview

uBuilder API provides following functions

9

uBudiler API 20 Documentation Release 01

10 Chapter 2 Overview

CHAPTER 3

API Referance

camera

Controls camera objects within a scene

Overview

Name Description Re-turns

Parameters

changeTo2DChange scene mode to 2D none camerachangeTo2D()

changeTo3DChange the Scene mode to 3D none camerachangeTo3D()

getEye-Pos

Get positions of all camera Vec-tor3

cameragetEyePos()

getTar-getPos

Get the position of the fixation point of the camera(s) Vec-tor3

cameragetTargetPos()

fit Focus all cameras on specified object none camerafit(obj)flyTo Move the camera to new position specified by the function none camera

flyTo(json)lookAt Set the Point of view of a camera none camera

lookAt(pos)setPosi-tion

Set the position of a camera none camerasetPosition(pos)

stopFly-ing

Stops the camera at the position specified by the function Oftenused with the function FlyTo

none camerastopFlying()

11

uBudiler API 20 Documentation Release 01

camerachangeTo2D

Change scene mode to 2D

Parameters

none

Example

1 Changes the scene mode to 2D2 If the current scene mode is already in 2D the scene does not change3 camerachangeTo2D()

camerachangeTo3D

Change scene mode to 3D

Parameters

none

Example

1 Changes the scene mode to 3D2 If the current scene mode is already in 3D the scene does not change3 camerachangeTo3D()

cameragetEyePos

Get the current position of the camera

Parameters

none

12 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 print the position of the camera2 print(cameragetEyePos())

cameragetTargetPos

Get the fixation point position of the camera

Parameters

none

Example

1 print fixation point position of the camera2 print(cameragetTargetPos())

camerafit

Focus camera on specified object

Parameters

Name Descriptionobj object referance which will be focued by camera

Example

1 create box object and have the camera focus on the object2 The focus point is the center point of the object3 The position of the camera is based on size of the object 4

5 var objectcreate(AB052B5B646E4A48B9C045096FF9B088)6 camerafit(obj)

31 camera 13

uBudiler API 20 Documentation Release 01

cameraflyTo

Move the position and the fixation point of the camera within a certain time then execute a function

Parameters

Name Descriptionjson json message including position fixation point time execute function

Example

1 move camera to position (234) and change the fixation point to (345 )2 within 2 seconds then print ldquoOKrdquo3

4 cameraflyTo(5 eyeVector3(234)6 targetVector3(345)7 time208 completefunction()print(OK)9 )

cameralookAt

Set camerarsquos fixation point as given Vector

Parameters

Name Descriptionpos Vector3 variable camerarsquos fixation point

Example

1 set cameras fixation point to be the center point of the object obj2 cameralookAt(objcenter)

camerasetPosition

Set camerarsquos position as given Vector

14 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 camerarsquos position

Example

1 set cameras position to (012)2 camerasetPosition(Vector3(012))

camerastopFlying

Set camerarsquos position as given Vector

Parameters

none

Example

1 Create a button namedExecute2 Clicking on the button will stop moving the position or fixation point of the

rarr˓camera3

4 camerasetPosition(Vector3(012))5

6 cameraflyTo(7

8 eyeVector3(234)9

10 targetVector3(345)11

12 time2013

14 completefunction()print(OK))15

16 guicreateButton(Execute Rect(10 50 200 50) function() camerastopFlying())

object

Overview

Control the objects within the scene

32 object 15

uBudiler API 20 Documentation Release 01

Name Description Returnscreate Create an object Returns the object type of the created objectcreateArrowLine Create an arrow line Returns the object type of the created arrow linecreateCurveLine Create a curved line Returns the object type of the curved linedestroyAll Delete all the objects created by a script none

objectcreate

Create object

Parameters

Name DescriptionbundleId string the id of the objectparentObj BaseObject parent of the objectcallback function Callback function After loading the object execute this callbackpos Vector3 the position of the objectscale Vector3 the size of the object

Example

1 Create objectobj1and set its position to (101)2 Create a second object obj2and set its parent to be obj1 and its position to (201)3 scale (123) after loading obj2 execute callback rotate the obj1 45 degree of Y

rarr˓(this time obj1 is obj2s parent4 so obj1 and obj2 will rotate together) 5

6 var obj1 = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(101))7 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1function()obj1

rarr˓yaw(45)Vector3(201)Vector3(123))

objectcreateArrowLine

Create arrowed line

Parameters

Name Descriptionvertices array or vector3List the set of points on the arrowed linejson json message includes the color of the arrow and the color of the line

Example

16 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 define a Vector array2 var vecArray2 = [Vector3(0 1 20) Vector3(10 1 20)]3

4

5 Create an arrowed line Set the start position to (0120) and the end position torarr˓(10120)

6 The color of the line is set to red the color of the arrow is set to green7

8 objectcreateArrowLine(vecArray2 9

10 color Colorred11

12 arrowColor Colorgreen)

objectcreateCurveLine

Create curve line

Parameters

Name Descriptionvertices array or Vector3ListThe set of the points on the curve linebundleOrColorOrMat string or colorparentObj BaseObject the parent of the curve linewidth float the width of the curve linetextiling repeatability of the materialtexOffSet the offset of the material

Example

1 create a curve line named curveLine12 var vecList = Vector3List()3

4 vecListAdd(Vector3(010))5

6 vecListAdd(Vector3(1010))7

8 vecListAdd(Vector3(1015))9

10 var curveLine1=objectcreateCurveLine(vecList Colorgreen)11

12

13 Create a curve line named curveLine2 Set the material of the curve line torarr˓specified material

14 Set the parent ofcurveLine2tocurveLine115 Set the repeatability ofcurveLine2s material to (12) and the offset of its

rarr˓material to (00)16

17 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]18

19 var curveLine2 = objectcreateCurveLine(vecArray 1D2702801708453680664DCABE70890Brarr˓curveLine12Vector2(12)Vector2(00))

32 object 17

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 2: uBudiler API 2.0 Documentation - readthedocs.org

Table of Contents

1 Concept Guide 311 model and Scene 312 Model Library 413 Scene Levels 414 API Developement 6

2 Overview 9

3 API Referance 1131 camera 1132 object 1533 gui 1834 BaseObject 2135 ScriptObject 3636 util 3737 input 4438 console 4739 Data Interface 49

4 Try API Online 59

5 Deploy 61

6 Q amp A 63

7 Revise History 65

i

ii

uBudiler API 20 Documentation Release 01

uBuilder API is a set of javascript-like executed-at-runtime scripts runs inside Momoda system uBuilder API providesoperations on object UI behavior and effect in 3D scene uBuilder API could be used to make customized industriesspecific apps such as storage management emergency drilling archive management intelligent buildings etc

uBuilder API supports fetch and interact with external data source Through uBuilder APIrsquos data interface 3rd partysystem could push realtime data to 3D scene to drive realtime object behavior andor information display

Table of Contents 1

uBudiler API 20 Documentation Release 01

2 Table of Contents

CHAPTER 1

Concept Guide

model and Scene

There are two basic and import concepts in Momoda model and scene

Model

Model is polygon representation of object 3D object could presents something from real world concept or just yourimagination

Model in Momoda shares the same of idea of 3D object in general those 3D object could be organized and put into3D scene like Lego

Momoda also provides lsquoofficialrsquo model library and could be used for free during 3D scene creation User could alsoleverage uinnovarsquos profession service to create customized models Besides Momoda also provide a 3DSMax pluginwhich could upload 3D object created in 3DSMax to Momodarsquos model library and user could create and use their ownmodel using this plugin which make Momoda very extensible in term of model creation

Scene

Scene this one of the basic concept in Momoda By use momodarsquos free drawing studio user can place combine andlayout 3D modelsobjects into a scene in drag and drop fashion Typical scene could be campus a factory a harborand any another things you may think of We call them ldquoMomoda Scenerdquo

Momoda scene are stored in Momoda Cloud which could be opened by own later on for editing preview or API de-bugging Momoda scene can also be download and running locally as ldquoMomoda Offline Editionrdquo (may need purchaselicense issued by uinnova inc)

3

uBudiler API 20 Documentation Release 01

Model Library

There are three common objects in right navigation bar of momoda studio model texture and function

bull Model

Objects like building car people desk etc User could also upload their custom objects through Momoda 3DSMaxplugin

bull Texture

Textures to cover the surface of object also supports use custom texture upload by user

bull Function

Effects such as fire rain flash or assistant function such as drawing line pipeline or text Function are system build-inand do not supports user upload at this time

Scene Levels

There are four level in Momoda scene campus building stories and rooms

bull Campus

Upmost level of a scene

4 Chapter 1 Concept Guide

uBudiler API 20 Documentation Release 01

bull Building

Buildings (do not includes building facade)

bull Stories

13 Scene Levels 5

uBudiler API 20 Documentation Release 01

bull Room

API Developement

Momoda supports online development via uBuilder API developing web page

6 Chapter 1 Concept Guide

uBudiler API 20 Documentation Release 01

Create New API Project

There a two pane in developing web page left pane is for script editing right pane is for running scripts in 3D sceneTo begin a new API development project visit the uBuilder API developing web page input the ID of target 3D scenethen click New button

Deploy API Project to Scene

To includes API script into your own scene simply copy all the script source code and paste to the text box of MyProjects mdashgt Target Scene mdashgt Configure Scene

Keyboard Shortcuts

Below are keyboard shortcuts in uBuilder API debug page

bull Ctrl+Enter Run Script

bull Ctrl+R Reset Scene

bull Ctrl+ CommentUncomment source code

API Namespace

uBuilder API functions are grouped in following namespaces

Namespace Descriptioncamera camera controlobject create search or modify objects in 3D scenegui manage user interface in 3D sceneBaseObject control existing objectsScriptObject associate scripts on existing objectutil common functionsinput keyboard and mouse eventsconsole management console

14 API Developement 7

uBudiler API 20 Documentation Release 01

8 Chapter 1 Concept Guide

CHAPTER 2

Overview

uBuilder API provides following functions

9

uBudiler API 20 Documentation Release 01

10 Chapter 2 Overview

CHAPTER 3

API Referance

camera

Controls camera objects within a scene

Overview

Name Description Re-turns

Parameters

changeTo2DChange scene mode to 2D none camerachangeTo2D()

changeTo3DChange the Scene mode to 3D none camerachangeTo3D()

getEye-Pos

Get positions of all camera Vec-tor3

cameragetEyePos()

getTar-getPos

Get the position of the fixation point of the camera(s) Vec-tor3

cameragetTargetPos()

fit Focus all cameras on specified object none camerafit(obj)flyTo Move the camera to new position specified by the function none camera

flyTo(json)lookAt Set the Point of view of a camera none camera

lookAt(pos)setPosi-tion

Set the position of a camera none camerasetPosition(pos)

stopFly-ing

Stops the camera at the position specified by the function Oftenused with the function FlyTo

none camerastopFlying()

11

uBudiler API 20 Documentation Release 01

camerachangeTo2D

Change scene mode to 2D

Parameters

none

Example

1 Changes the scene mode to 2D2 If the current scene mode is already in 2D the scene does not change3 camerachangeTo2D()

camerachangeTo3D

Change scene mode to 3D

Parameters

none

Example

1 Changes the scene mode to 3D2 If the current scene mode is already in 3D the scene does not change3 camerachangeTo3D()

cameragetEyePos

Get the current position of the camera

Parameters

none

12 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 print the position of the camera2 print(cameragetEyePos())

cameragetTargetPos

Get the fixation point position of the camera

Parameters

none

Example

1 print fixation point position of the camera2 print(cameragetTargetPos())

camerafit

Focus camera on specified object

Parameters

Name Descriptionobj object referance which will be focued by camera

Example

1 create box object and have the camera focus on the object2 The focus point is the center point of the object3 The position of the camera is based on size of the object 4

5 var objectcreate(AB052B5B646E4A48B9C045096FF9B088)6 camerafit(obj)

31 camera 13

uBudiler API 20 Documentation Release 01

cameraflyTo

Move the position and the fixation point of the camera within a certain time then execute a function

Parameters

Name Descriptionjson json message including position fixation point time execute function

Example

1 move camera to position (234) and change the fixation point to (345 )2 within 2 seconds then print ldquoOKrdquo3

4 cameraflyTo(5 eyeVector3(234)6 targetVector3(345)7 time208 completefunction()print(OK)9 )

cameralookAt

Set camerarsquos fixation point as given Vector

Parameters

Name Descriptionpos Vector3 variable camerarsquos fixation point

Example

1 set cameras fixation point to be the center point of the object obj2 cameralookAt(objcenter)

camerasetPosition

Set camerarsquos position as given Vector

14 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 camerarsquos position

Example

1 set cameras position to (012)2 camerasetPosition(Vector3(012))

camerastopFlying

Set camerarsquos position as given Vector

Parameters

none

Example

1 Create a button namedExecute2 Clicking on the button will stop moving the position or fixation point of the

rarr˓camera3

4 camerasetPosition(Vector3(012))5

6 cameraflyTo(7

8 eyeVector3(234)9

10 targetVector3(345)11

12 time2013

14 completefunction()print(OK))15

16 guicreateButton(Execute Rect(10 50 200 50) function() camerastopFlying())

object

Overview

Control the objects within the scene

32 object 15

uBudiler API 20 Documentation Release 01

Name Description Returnscreate Create an object Returns the object type of the created objectcreateArrowLine Create an arrow line Returns the object type of the created arrow linecreateCurveLine Create a curved line Returns the object type of the curved linedestroyAll Delete all the objects created by a script none

objectcreate

Create object

Parameters

Name DescriptionbundleId string the id of the objectparentObj BaseObject parent of the objectcallback function Callback function After loading the object execute this callbackpos Vector3 the position of the objectscale Vector3 the size of the object

Example

1 Create objectobj1and set its position to (101)2 Create a second object obj2and set its parent to be obj1 and its position to (201)3 scale (123) after loading obj2 execute callback rotate the obj1 45 degree of Y

rarr˓(this time obj1 is obj2s parent4 so obj1 and obj2 will rotate together) 5

6 var obj1 = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(101))7 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1function()obj1

rarr˓yaw(45)Vector3(201)Vector3(123))

objectcreateArrowLine

Create arrowed line

Parameters

Name Descriptionvertices array or vector3List the set of points on the arrowed linejson json message includes the color of the arrow and the color of the line

Example

16 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 define a Vector array2 var vecArray2 = [Vector3(0 1 20) Vector3(10 1 20)]3

4

5 Create an arrowed line Set the start position to (0120) and the end position torarr˓(10120)

6 The color of the line is set to red the color of the arrow is set to green7

8 objectcreateArrowLine(vecArray2 9

10 color Colorred11

12 arrowColor Colorgreen)

objectcreateCurveLine

Create curve line

Parameters

Name Descriptionvertices array or Vector3ListThe set of the points on the curve linebundleOrColorOrMat string or colorparentObj BaseObject the parent of the curve linewidth float the width of the curve linetextiling repeatability of the materialtexOffSet the offset of the material

Example

1 create a curve line named curveLine12 var vecList = Vector3List()3

4 vecListAdd(Vector3(010))5

6 vecListAdd(Vector3(1010))7

8 vecListAdd(Vector3(1015))9

10 var curveLine1=objectcreateCurveLine(vecList Colorgreen)11

12

13 Create a curve line named curveLine2 Set the material of the curve line torarr˓specified material

14 Set the parent ofcurveLine2tocurveLine115 Set the repeatability ofcurveLine2s material to (12) and the offset of its

rarr˓material to (00)16

17 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]18

19 var curveLine2 = objectcreateCurveLine(vecArray 1D2702801708453680664DCABE70890Brarr˓curveLine12Vector2(12)Vector2(00))

32 object 17

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 3: uBudiler API 2.0 Documentation - readthedocs.org

ii

uBudiler API 20 Documentation Release 01

uBuilder API is a set of javascript-like executed-at-runtime scripts runs inside Momoda system uBuilder API providesoperations on object UI behavior and effect in 3D scene uBuilder API could be used to make customized industriesspecific apps such as storage management emergency drilling archive management intelligent buildings etc

uBuilder API supports fetch and interact with external data source Through uBuilder APIrsquos data interface 3rd partysystem could push realtime data to 3D scene to drive realtime object behavior andor information display

Table of Contents 1

uBudiler API 20 Documentation Release 01

2 Table of Contents

CHAPTER 1

Concept Guide

model and Scene

There are two basic and import concepts in Momoda model and scene

Model

Model is polygon representation of object 3D object could presents something from real world concept or just yourimagination

Model in Momoda shares the same of idea of 3D object in general those 3D object could be organized and put into3D scene like Lego

Momoda also provides lsquoofficialrsquo model library and could be used for free during 3D scene creation User could alsoleverage uinnovarsquos profession service to create customized models Besides Momoda also provide a 3DSMax pluginwhich could upload 3D object created in 3DSMax to Momodarsquos model library and user could create and use their ownmodel using this plugin which make Momoda very extensible in term of model creation

Scene

Scene this one of the basic concept in Momoda By use momodarsquos free drawing studio user can place combine andlayout 3D modelsobjects into a scene in drag and drop fashion Typical scene could be campus a factory a harborand any another things you may think of We call them ldquoMomoda Scenerdquo

Momoda scene are stored in Momoda Cloud which could be opened by own later on for editing preview or API de-bugging Momoda scene can also be download and running locally as ldquoMomoda Offline Editionrdquo (may need purchaselicense issued by uinnova inc)

3

uBudiler API 20 Documentation Release 01

Model Library

There are three common objects in right navigation bar of momoda studio model texture and function

bull Model

Objects like building car people desk etc User could also upload their custom objects through Momoda 3DSMaxplugin

bull Texture

Textures to cover the surface of object also supports use custom texture upload by user

bull Function

Effects such as fire rain flash or assistant function such as drawing line pipeline or text Function are system build-inand do not supports user upload at this time

Scene Levels

There are four level in Momoda scene campus building stories and rooms

bull Campus

Upmost level of a scene

4 Chapter 1 Concept Guide

uBudiler API 20 Documentation Release 01

bull Building

Buildings (do not includes building facade)

bull Stories

13 Scene Levels 5

uBudiler API 20 Documentation Release 01

bull Room

API Developement

Momoda supports online development via uBuilder API developing web page

6 Chapter 1 Concept Guide

uBudiler API 20 Documentation Release 01

Create New API Project

There a two pane in developing web page left pane is for script editing right pane is for running scripts in 3D sceneTo begin a new API development project visit the uBuilder API developing web page input the ID of target 3D scenethen click New button

Deploy API Project to Scene

To includes API script into your own scene simply copy all the script source code and paste to the text box of MyProjects mdashgt Target Scene mdashgt Configure Scene

Keyboard Shortcuts

Below are keyboard shortcuts in uBuilder API debug page

bull Ctrl+Enter Run Script

bull Ctrl+R Reset Scene

bull Ctrl+ CommentUncomment source code

API Namespace

uBuilder API functions are grouped in following namespaces

Namespace Descriptioncamera camera controlobject create search or modify objects in 3D scenegui manage user interface in 3D sceneBaseObject control existing objectsScriptObject associate scripts on existing objectutil common functionsinput keyboard and mouse eventsconsole management console

14 API Developement 7

uBudiler API 20 Documentation Release 01

8 Chapter 1 Concept Guide

CHAPTER 2

Overview

uBuilder API provides following functions

9

uBudiler API 20 Documentation Release 01

10 Chapter 2 Overview

CHAPTER 3

API Referance

camera

Controls camera objects within a scene

Overview

Name Description Re-turns

Parameters

changeTo2DChange scene mode to 2D none camerachangeTo2D()

changeTo3DChange the Scene mode to 3D none camerachangeTo3D()

getEye-Pos

Get positions of all camera Vec-tor3

cameragetEyePos()

getTar-getPos

Get the position of the fixation point of the camera(s) Vec-tor3

cameragetTargetPos()

fit Focus all cameras on specified object none camerafit(obj)flyTo Move the camera to new position specified by the function none camera

flyTo(json)lookAt Set the Point of view of a camera none camera

lookAt(pos)setPosi-tion

Set the position of a camera none camerasetPosition(pos)

stopFly-ing

Stops the camera at the position specified by the function Oftenused with the function FlyTo

none camerastopFlying()

11

uBudiler API 20 Documentation Release 01

camerachangeTo2D

Change scene mode to 2D

Parameters

none

Example

1 Changes the scene mode to 2D2 If the current scene mode is already in 2D the scene does not change3 camerachangeTo2D()

camerachangeTo3D

Change scene mode to 3D

Parameters

none

Example

1 Changes the scene mode to 3D2 If the current scene mode is already in 3D the scene does not change3 camerachangeTo3D()

cameragetEyePos

Get the current position of the camera

Parameters

none

12 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 print the position of the camera2 print(cameragetEyePos())

cameragetTargetPos

Get the fixation point position of the camera

Parameters

none

Example

1 print fixation point position of the camera2 print(cameragetTargetPos())

camerafit

Focus camera on specified object

Parameters

Name Descriptionobj object referance which will be focued by camera

Example

1 create box object and have the camera focus on the object2 The focus point is the center point of the object3 The position of the camera is based on size of the object 4

5 var objectcreate(AB052B5B646E4A48B9C045096FF9B088)6 camerafit(obj)

31 camera 13

uBudiler API 20 Documentation Release 01

cameraflyTo

Move the position and the fixation point of the camera within a certain time then execute a function

Parameters

Name Descriptionjson json message including position fixation point time execute function

Example

1 move camera to position (234) and change the fixation point to (345 )2 within 2 seconds then print ldquoOKrdquo3

4 cameraflyTo(5 eyeVector3(234)6 targetVector3(345)7 time208 completefunction()print(OK)9 )

cameralookAt

Set camerarsquos fixation point as given Vector

Parameters

Name Descriptionpos Vector3 variable camerarsquos fixation point

Example

1 set cameras fixation point to be the center point of the object obj2 cameralookAt(objcenter)

camerasetPosition

Set camerarsquos position as given Vector

14 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 camerarsquos position

Example

1 set cameras position to (012)2 camerasetPosition(Vector3(012))

camerastopFlying

Set camerarsquos position as given Vector

Parameters

none

Example

1 Create a button namedExecute2 Clicking on the button will stop moving the position or fixation point of the

rarr˓camera3

4 camerasetPosition(Vector3(012))5

6 cameraflyTo(7

8 eyeVector3(234)9

10 targetVector3(345)11

12 time2013

14 completefunction()print(OK))15

16 guicreateButton(Execute Rect(10 50 200 50) function() camerastopFlying())

object

Overview

Control the objects within the scene

32 object 15

uBudiler API 20 Documentation Release 01

Name Description Returnscreate Create an object Returns the object type of the created objectcreateArrowLine Create an arrow line Returns the object type of the created arrow linecreateCurveLine Create a curved line Returns the object type of the curved linedestroyAll Delete all the objects created by a script none

objectcreate

Create object

Parameters

Name DescriptionbundleId string the id of the objectparentObj BaseObject parent of the objectcallback function Callback function After loading the object execute this callbackpos Vector3 the position of the objectscale Vector3 the size of the object

Example

1 Create objectobj1and set its position to (101)2 Create a second object obj2and set its parent to be obj1 and its position to (201)3 scale (123) after loading obj2 execute callback rotate the obj1 45 degree of Y

rarr˓(this time obj1 is obj2s parent4 so obj1 and obj2 will rotate together) 5

6 var obj1 = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(101))7 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1function()obj1

rarr˓yaw(45)Vector3(201)Vector3(123))

objectcreateArrowLine

Create arrowed line

Parameters

Name Descriptionvertices array or vector3List the set of points on the arrowed linejson json message includes the color of the arrow and the color of the line

Example

16 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 define a Vector array2 var vecArray2 = [Vector3(0 1 20) Vector3(10 1 20)]3

4

5 Create an arrowed line Set the start position to (0120) and the end position torarr˓(10120)

6 The color of the line is set to red the color of the arrow is set to green7

8 objectcreateArrowLine(vecArray2 9

10 color Colorred11

12 arrowColor Colorgreen)

objectcreateCurveLine

Create curve line

Parameters

Name Descriptionvertices array or Vector3ListThe set of the points on the curve linebundleOrColorOrMat string or colorparentObj BaseObject the parent of the curve linewidth float the width of the curve linetextiling repeatability of the materialtexOffSet the offset of the material

Example

1 create a curve line named curveLine12 var vecList = Vector3List()3

4 vecListAdd(Vector3(010))5

6 vecListAdd(Vector3(1010))7

8 vecListAdd(Vector3(1015))9

10 var curveLine1=objectcreateCurveLine(vecList Colorgreen)11

12

13 Create a curve line named curveLine2 Set the material of the curve line torarr˓specified material

14 Set the parent ofcurveLine2tocurveLine115 Set the repeatability ofcurveLine2s material to (12) and the offset of its

rarr˓material to (00)16

17 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]18

19 var curveLine2 = objectcreateCurveLine(vecArray 1D2702801708453680664DCABE70890Brarr˓curveLine12Vector2(12)Vector2(00))

32 object 17

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 4: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

uBuilder API is a set of javascript-like executed-at-runtime scripts runs inside Momoda system uBuilder API providesoperations on object UI behavior and effect in 3D scene uBuilder API could be used to make customized industriesspecific apps such as storage management emergency drilling archive management intelligent buildings etc

uBuilder API supports fetch and interact with external data source Through uBuilder APIrsquos data interface 3rd partysystem could push realtime data to 3D scene to drive realtime object behavior andor information display

Table of Contents 1

uBudiler API 20 Documentation Release 01

2 Table of Contents

CHAPTER 1

Concept Guide

model and Scene

There are two basic and import concepts in Momoda model and scene

Model

Model is polygon representation of object 3D object could presents something from real world concept or just yourimagination

Model in Momoda shares the same of idea of 3D object in general those 3D object could be organized and put into3D scene like Lego

Momoda also provides lsquoofficialrsquo model library and could be used for free during 3D scene creation User could alsoleverage uinnovarsquos profession service to create customized models Besides Momoda also provide a 3DSMax pluginwhich could upload 3D object created in 3DSMax to Momodarsquos model library and user could create and use their ownmodel using this plugin which make Momoda very extensible in term of model creation

Scene

Scene this one of the basic concept in Momoda By use momodarsquos free drawing studio user can place combine andlayout 3D modelsobjects into a scene in drag and drop fashion Typical scene could be campus a factory a harborand any another things you may think of We call them ldquoMomoda Scenerdquo

Momoda scene are stored in Momoda Cloud which could be opened by own later on for editing preview or API de-bugging Momoda scene can also be download and running locally as ldquoMomoda Offline Editionrdquo (may need purchaselicense issued by uinnova inc)

3

uBudiler API 20 Documentation Release 01

Model Library

There are three common objects in right navigation bar of momoda studio model texture and function

bull Model

Objects like building car people desk etc User could also upload their custom objects through Momoda 3DSMaxplugin

bull Texture

Textures to cover the surface of object also supports use custom texture upload by user

bull Function

Effects such as fire rain flash or assistant function such as drawing line pipeline or text Function are system build-inand do not supports user upload at this time

Scene Levels

There are four level in Momoda scene campus building stories and rooms

bull Campus

Upmost level of a scene

4 Chapter 1 Concept Guide

uBudiler API 20 Documentation Release 01

bull Building

Buildings (do not includes building facade)

bull Stories

13 Scene Levels 5

uBudiler API 20 Documentation Release 01

bull Room

API Developement

Momoda supports online development via uBuilder API developing web page

6 Chapter 1 Concept Guide

uBudiler API 20 Documentation Release 01

Create New API Project

There a two pane in developing web page left pane is for script editing right pane is for running scripts in 3D sceneTo begin a new API development project visit the uBuilder API developing web page input the ID of target 3D scenethen click New button

Deploy API Project to Scene

To includes API script into your own scene simply copy all the script source code and paste to the text box of MyProjects mdashgt Target Scene mdashgt Configure Scene

Keyboard Shortcuts

Below are keyboard shortcuts in uBuilder API debug page

bull Ctrl+Enter Run Script

bull Ctrl+R Reset Scene

bull Ctrl+ CommentUncomment source code

API Namespace

uBuilder API functions are grouped in following namespaces

Namespace Descriptioncamera camera controlobject create search or modify objects in 3D scenegui manage user interface in 3D sceneBaseObject control existing objectsScriptObject associate scripts on existing objectutil common functionsinput keyboard and mouse eventsconsole management console

14 API Developement 7

uBudiler API 20 Documentation Release 01

8 Chapter 1 Concept Guide

CHAPTER 2

Overview

uBuilder API provides following functions

9

uBudiler API 20 Documentation Release 01

10 Chapter 2 Overview

CHAPTER 3

API Referance

camera

Controls camera objects within a scene

Overview

Name Description Re-turns

Parameters

changeTo2DChange scene mode to 2D none camerachangeTo2D()

changeTo3DChange the Scene mode to 3D none camerachangeTo3D()

getEye-Pos

Get positions of all camera Vec-tor3

cameragetEyePos()

getTar-getPos

Get the position of the fixation point of the camera(s) Vec-tor3

cameragetTargetPos()

fit Focus all cameras on specified object none camerafit(obj)flyTo Move the camera to new position specified by the function none camera

flyTo(json)lookAt Set the Point of view of a camera none camera

lookAt(pos)setPosi-tion

Set the position of a camera none camerasetPosition(pos)

stopFly-ing

Stops the camera at the position specified by the function Oftenused with the function FlyTo

none camerastopFlying()

11

uBudiler API 20 Documentation Release 01

camerachangeTo2D

Change scene mode to 2D

Parameters

none

Example

1 Changes the scene mode to 2D2 If the current scene mode is already in 2D the scene does not change3 camerachangeTo2D()

camerachangeTo3D

Change scene mode to 3D

Parameters

none

Example

1 Changes the scene mode to 3D2 If the current scene mode is already in 3D the scene does not change3 camerachangeTo3D()

cameragetEyePos

Get the current position of the camera

Parameters

none

12 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 print the position of the camera2 print(cameragetEyePos())

cameragetTargetPos

Get the fixation point position of the camera

Parameters

none

Example

1 print fixation point position of the camera2 print(cameragetTargetPos())

camerafit

Focus camera on specified object

Parameters

Name Descriptionobj object referance which will be focued by camera

Example

1 create box object and have the camera focus on the object2 The focus point is the center point of the object3 The position of the camera is based on size of the object 4

5 var objectcreate(AB052B5B646E4A48B9C045096FF9B088)6 camerafit(obj)

31 camera 13

uBudiler API 20 Documentation Release 01

cameraflyTo

Move the position and the fixation point of the camera within a certain time then execute a function

Parameters

Name Descriptionjson json message including position fixation point time execute function

Example

1 move camera to position (234) and change the fixation point to (345 )2 within 2 seconds then print ldquoOKrdquo3

4 cameraflyTo(5 eyeVector3(234)6 targetVector3(345)7 time208 completefunction()print(OK)9 )

cameralookAt

Set camerarsquos fixation point as given Vector

Parameters

Name Descriptionpos Vector3 variable camerarsquos fixation point

Example

1 set cameras fixation point to be the center point of the object obj2 cameralookAt(objcenter)

camerasetPosition

Set camerarsquos position as given Vector

14 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 camerarsquos position

Example

1 set cameras position to (012)2 camerasetPosition(Vector3(012))

camerastopFlying

Set camerarsquos position as given Vector

Parameters

none

Example

1 Create a button namedExecute2 Clicking on the button will stop moving the position or fixation point of the

rarr˓camera3

4 camerasetPosition(Vector3(012))5

6 cameraflyTo(7

8 eyeVector3(234)9

10 targetVector3(345)11

12 time2013

14 completefunction()print(OK))15

16 guicreateButton(Execute Rect(10 50 200 50) function() camerastopFlying())

object

Overview

Control the objects within the scene

32 object 15

uBudiler API 20 Documentation Release 01

Name Description Returnscreate Create an object Returns the object type of the created objectcreateArrowLine Create an arrow line Returns the object type of the created arrow linecreateCurveLine Create a curved line Returns the object type of the curved linedestroyAll Delete all the objects created by a script none

objectcreate

Create object

Parameters

Name DescriptionbundleId string the id of the objectparentObj BaseObject parent of the objectcallback function Callback function After loading the object execute this callbackpos Vector3 the position of the objectscale Vector3 the size of the object

Example

1 Create objectobj1and set its position to (101)2 Create a second object obj2and set its parent to be obj1 and its position to (201)3 scale (123) after loading obj2 execute callback rotate the obj1 45 degree of Y

rarr˓(this time obj1 is obj2s parent4 so obj1 and obj2 will rotate together) 5

6 var obj1 = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(101))7 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1function()obj1

rarr˓yaw(45)Vector3(201)Vector3(123))

objectcreateArrowLine

Create arrowed line

Parameters

Name Descriptionvertices array or vector3List the set of points on the arrowed linejson json message includes the color of the arrow and the color of the line

Example

16 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 define a Vector array2 var vecArray2 = [Vector3(0 1 20) Vector3(10 1 20)]3

4

5 Create an arrowed line Set the start position to (0120) and the end position torarr˓(10120)

6 The color of the line is set to red the color of the arrow is set to green7

8 objectcreateArrowLine(vecArray2 9

10 color Colorred11

12 arrowColor Colorgreen)

objectcreateCurveLine

Create curve line

Parameters

Name Descriptionvertices array or Vector3ListThe set of the points on the curve linebundleOrColorOrMat string or colorparentObj BaseObject the parent of the curve linewidth float the width of the curve linetextiling repeatability of the materialtexOffSet the offset of the material

Example

1 create a curve line named curveLine12 var vecList = Vector3List()3

4 vecListAdd(Vector3(010))5

6 vecListAdd(Vector3(1010))7

8 vecListAdd(Vector3(1015))9

10 var curveLine1=objectcreateCurveLine(vecList Colorgreen)11

12

13 Create a curve line named curveLine2 Set the material of the curve line torarr˓specified material

14 Set the parent ofcurveLine2tocurveLine115 Set the repeatability ofcurveLine2s material to (12) and the offset of its

rarr˓material to (00)16

17 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]18

19 var curveLine2 = objectcreateCurveLine(vecArray 1D2702801708453680664DCABE70890Brarr˓curveLine12Vector2(12)Vector2(00))

32 object 17

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 5: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

2 Table of Contents

CHAPTER 1

Concept Guide

model and Scene

There are two basic and import concepts in Momoda model and scene

Model

Model is polygon representation of object 3D object could presents something from real world concept or just yourimagination

Model in Momoda shares the same of idea of 3D object in general those 3D object could be organized and put into3D scene like Lego

Momoda also provides lsquoofficialrsquo model library and could be used for free during 3D scene creation User could alsoleverage uinnovarsquos profession service to create customized models Besides Momoda also provide a 3DSMax pluginwhich could upload 3D object created in 3DSMax to Momodarsquos model library and user could create and use their ownmodel using this plugin which make Momoda very extensible in term of model creation

Scene

Scene this one of the basic concept in Momoda By use momodarsquos free drawing studio user can place combine andlayout 3D modelsobjects into a scene in drag and drop fashion Typical scene could be campus a factory a harborand any another things you may think of We call them ldquoMomoda Scenerdquo

Momoda scene are stored in Momoda Cloud which could be opened by own later on for editing preview or API de-bugging Momoda scene can also be download and running locally as ldquoMomoda Offline Editionrdquo (may need purchaselicense issued by uinnova inc)

3

uBudiler API 20 Documentation Release 01

Model Library

There are three common objects in right navigation bar of momoda studio model texture and function

bull Model

Objects like building car people desk etc User could also upload their custom objects through Momoda 3DSMaxplugin

bull Texture

Textures to cover the surface of object also supports use custom texture upload by user

bull Function

Effects such as fire rain flash or assistant function such as drawing line pipeline or text Function are system build-inand do not supports user upload at this time

Scene Levels

There are four level in Momoda scene campus building stories and rooms

bull Campus

Upmost level of a scene

4 Chapter 1 Concept Guide

uBudiler API 20 Documentation Release 01

bull Building

Buildings (do not includes building facade)

bull Stories

13 Scene Levels 5

uBudiler API 20 Documentation Release 01

bull Room

API Developement

Momoda supports online development via uBuilder API developing web page

6 Chapter 1 Concept Guide

uBudiler API 20 Documentation Release 01

Create New API Project

There a two pane in developing web page left pane is for script editing right pane is for running scripts in 3D sceneTo begin a new API development project visit the uBuilder API developing web page input the ID of target 3D scenethen click New button

Deploy API Project to Scene

To includes API script into your own scene simply copy all the script source code and paste to the text box of MyProjects mdashgt Target Scene mdashgt Configure Scene

Keyboard Shortcuts

Below are keyboard shortcuts in uBuilder API debug page

bull Ctrl+Enter Run Script

bull Ctrl+R Reset Scene

bull Ctrl+ CommentUncomment source code

API Namespace

uBuilder API functions are grouped in following namespaces

Namespace Descriptioncamera camera controlobject create search or modify objects in 3D scenegui manage user interface in 3D sceneBaseObject control existing objectsScriptObject associate scripts on existing objectutil common functionsinput keyboard and mouse eventsconsole management console

14 API Developement 7

uBudiler API 20 Documentation Release 01

8 Chapter 1 Concept Guide

CHAPTER 2

Overview

uBuilder API provides following functions

9

uBudiler API 20 Documentation Release 01

10 Chapter 2 Overview

CHAPTER 3

API Referance

camera

Controls camera objects within a scene

Overview

Name Description Re-turns

Parameters

changeTo2DChange scene mode to 2D none camerachangeTo2D()

changeTo3DChange the Scene mode to 3D none camerachangeTo3D()

getEye-Pos

Get positions of all camera Vec-tor3

cameragetEyePos()

getTar-getPos

Get the position of the fixation point of the camera(s) Vec-tor3

cameragetTargetPos()

fit Focus all cameras on specified object none camerafit(obj)flyTo Move the camera to new position specified by the function none camera

flyTo(json)lookAt Set the Point of view of a camera none camera

lookAt(pos)setPosi-tion

Set the position of a camera none camerasetPosition(pos)

stopFly-ing

Stops the camera at the position specified by the function Oftenused with the function FlyTo

none camerastopFlying()

11

uBudiler API 20 Documentation Release 01

camerachangeTo2D

Change scene mode to 2D

Parameters

none

Example

1 Changes the scene mode to 2D2 If the current scene mode is already in 2D the scene does not change3 camerachangeTo2D()

camerachangeTo3D

Change scene mode to 3D

Parameters

none

Example

1 Changes the scene mode to 3D2 If the current scene mode is already in 3D the scene does not change3 camerachangeTo3D()

cameragetEyePos

Get the current position of the camera

Parameters

none

12 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 print the position of the camera2 print(cameragetEyePos())

cameragetTargetPos

Get the fixation point position of the camera

Parameters

none

Example

1 print fixation point position of the camera2 print(cameragetTargetPos())

camerafit

Focus camera on specified object

Parameters

Name Descriptionobj object referance which will be focued by camera

Example

1 create box object and have the camera focus on the object2 The focus point is the center point of the object3 The position of the camera is based on size of the object 4

5 var objectcreate(AB052B5B646E4A48B9C045096FF9B088)6 camerafit(obj)

31 camera 13

uBudiler API 20 Documentation Release 01

cameraflyTo

Move the position and the fixation point of the camera within a certain time then execute a function

Parameters

Name Descriptionjson json message including position fixation point time execute function

Example

1 move camera to position (234) and change the fixation point to (345 )2 within 2 seconds then print ldquoOKrdquo3

4 cameraflyTo(5 eyeVector3(234)6 targetVector3(345)7 time208 completefunction()print(OK)9 )

cameralookAt

Set camerarsquos fixation point as given Vector

Parameters

Name Descriptionpos Vector3 variable camerarsquos fixation point

Example

1 set cameras fixation point to be the center point of the object obj2 cameralookAt(objcenter)

camerasetPosition

Set camerarsquos position as given Vector

14 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 camerarsquos position

Example

1 set cameras position to (012)2 camerasetPosition(Vector3(012))

camerastopFlying

Set camerarsquos position as given Vector

Parameters

none

Example

1 Create a button namedExecute2 Clicking on the button will stop moving the position or fixation point of the

rarr˓camera3

4 camerasetPosition(Vector3(012))5

6 cameraflyTo(7

8 eyeVector3(234)9

10 targetVector3(345)11

12 time2013

14 completefunction()print(OK))15

16 guicreateButton(Execute Rect(10 50 200 50) function() camerastopFlying())

object

Overview

Control the objects within the scene

32 object 15

uBudiler API 20 Documentation Release 01

Name Description Returnscreate Create an object Returns the object type of the created objectcreateArrowLine Create an arrow line Returns the object type of the created arrow linecreateCurveLine Create a curved line Returns the object type of the curved linedestroyAll Delete all the objects created by a script none

objectcreate

Create object

Parameters

Name DescriptionbundleId string the id of the objectparentObj BaseObject parent of the objectcallback function Callback function After loading the object execute this callbackpos Vector3 the position of the objectscale Vector3 the size of the object

Example

1 Create objectobj1and set its position to (101)2 Create a second object obj2and set its parent to be obj1 and its position to (201)3 scale (123) after loading obj2 execute callback rotate the obj1 45 degree of Y

rarr˓(this time obj1 is obj2s parent4 so obj1 and obj2 will rotate together) 5

6 var obj1 = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(101))7 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1function()obj1

rarr˓yaw(45)Vector3(201)Vector3(123))

objectcreateArrowLine

Create arrowed line

Parameters

Name Descriptionvertices array or vector3List the set of points on the arrowed linejson json message includes the color of the arrow and the color of the line

Example

16 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 define a Vector array2 var vecArray2 = [Vector3(0 1 20) Vector3(10 1 20)]3

4

5 Create an arrowed line Set the start position to (0120) and the end position torarr˓(10120)

6 The color of the line is set to red the color of the arrow is set to green7

8 objectcreateArrowLine(vecArray2 9

10 color Colorred11

12 arrowColor Colorgreen)

objectcreateCurveLine

Create curve line

Parameters

Name Descriptionvertices array or Vector3ListThe set of the points on the curve linebundleOrColorOrMat string or colorparentObj BaseObject the parent of the curve linewidth float the width of the curve linetextiling repeatability of the materialtexOffSet the offset of the material

Example

1 create a curve line named curveLine12 var vecList = Vector3List()3

4 vecListAdd(Vector3(010))5

6 vecListAdd(Vector3(1010))7

8 vecListAdd(Vector3(1015))9

10 var curveLine1=objectcreateCurveLine(vecList Colorgreen)11

12

13 Create a curve line named curveLine2 Set the material of the curve line torarr˓specified material

14 Set the parent ofcurveLine2tocurveLine115 Set the repeatability ofcurveLine2s material to (12) and the offset of its

rarr˓material to (00)16

17 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]18

19 var curveLine2 = objectcreateCurveLine(vecArray 1D2702801708453680664DCABE70890Brarr˓curveLine12Vector2(12)Vector2(00))

32 object 17

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 6: uBudiler API 2.0 Documentation - readthedocs.org

CHAPTER 1

Concept Guide

model and Scene

There are two basic and import concepts in Momoda model and scene

Model

Model is polygon representation of object 3D object could presents something from real world concept or just yourimagination

Model in Momoda shares the same of idea of 3D object in general those 3D object could be organized and put into3D scene like Lego

Momoda also provides lsquoofficialrsquo model library and could be used for free during 3D scene creation User could alsoleverage uinnovarsquos profession service to create customized models Besides Momoda also provide a 3DSMax pluginwhich could upload 3D object created in 3DSMax to Momodarsquos model library and user could create and use their ownmodel using this plugin which make Momoda very extensible in term of model creation

Scene

Scene this one of the basic concept in Momoda By use momodarsquos free drawing studio user can place combine andlayout 3D modelsobjects into a scene in drag and drop fashion Typical scene could be campus a factory a harborand any another things you may think of We call them ldquoMomoda Scenerdquo

Momoda scene are stored in Momoda Cloud which could be opened by own later on for editing preview or API de-bugging Momoda scene can also be download and running locally as ldquoMomoda Offline Editionrdquo (may need purchaselicense issued by uinnova inc)

3

uBudiler API 20 Documentation Release 01

Model Library

There are three common objects in right navigation bar of momoda studio model texture and function

bull Model

Objects like building car people desk etc User could also upload their custom objects through Momoda 3DSMaxplugin

bull Texture

Textures to cover the surface of object also supports use custom texture upload by user

bull Function

Effects such as fire rain flash or assistant function such as drawing line pipeline or text Function are system build-inand do not supports user upload at this time

Scene Levels

There are four level in Momoda scene campus building stories and rooms

bull Campus

Upmost level of a scene

4 Chapter 1 Concept Guide

uBudiler API 20 Documentation Release 01

bull Building

Buildings (do not includes building facade)

bull Stories

13 Scene Levels 5

uBudiler API 20 Documentation Release 01

bull Room

API Developement

Momoda supports online development via uBuilder API developing web page

6 Chapter 1 Concept Guide

uBudiler API 20 Documentation Release 01

Create New API Project

There a two pane in developing web page left pane is for script editing right pane is for running scripts in 3D sceneTo begin a new API development project visit the uBuilder API developing web page input the ID of target 3D scenethen click New button

Deploy API Project to Scene

To includes API script into your own scene simply copy all the script source code and paste to the text box of MyProjects mdashgt Target Scene mdashgt Configure Scene

Keyboard Shortcuts

Below are keyboard shortcuts in uBuilder API debug page

bull Ctrl+Enter Run Script

bull Ctrl+R Reset Scene

bull Ctrl+ CommentUncomment source code

API Namespace

uBuilder API functions are grouped in following namespaces

Namespace Descriptioncamera camera controlobject create search or modify objects in 3D scenegui manage user interface in 3D sceneBaseObject control existing objectsScriptObject associate scripts on existing objectutil common functionsinput keyboard and mouse eventsconsole management console

14 API Developement 7

uBudiler API 20 Documentation Release 01

8 Chapter 1 Concept Guide

CHAPTER 2

Overview

uBuilder API provides following functions

9

uBudiler API 20 Documentation Release 01

10 Chapter 2 Overview

CHAPTER 3

API Referance

camera

Controls camera objects within a scene

Overview

Name Description Re-turns

Parameters

changeTo2DChange scene mode to 2D none camerachangeTo2D()

changeTo3DChange the Scene mode to 3D none camerachangeTo3D()

getEye-Pos

Get positions of all camera Vec-tor3

cameragetEyePos()

getTar-getPos

Get the position of the fixation point of the camera(s) Vec-tor3

cameragetTargetPos()

fit Focus all cameras on specified object none camerafit(obj)flyTo Move the camera to new position specified by the function none camera

flyTo(json)lookAt Set the Point of view of a camera none camera

lookAt(pos)setPosi-tion

Set the position of a camera none camerasetPosition(pos)

stopFly-ing

Stops the camera at the position specified by the function Oftenused with the function FlyTo

none camerastopFlying()

11

uBudiler API 20 Documentation Release 01

camerachangeTo2D

Change scene mode to 2D

Parameters

none

Example

1 Changes the scene mode to 2D2 If the current scene mode is already in 2D the scene does not change3 camerachangeTo2D()

camerachangeTo3D

Change scene mode to 3D

Parameters

none

Example

1 Changes the scene mode to 3D2 If the current scene mode is already in 3D the scene does not change3 camerachangeTo3D()

cameragetEyePos

Get the current position of the camera

Parameters

none

12 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 print the position of the camera2 print(cameragetEyePos())

cameragetTargetPos

Get the fixation point position of the camera

Parameters

none

Example

1 print fixation point position of the camera2 print(cameragetTargetPos())

camerafit

Focus camera on specified object

Parameters

Name Descriptionobj object referance which will be focued by camera

Example

1 create box object and have the camera focus on the object2 The focus point is the center point of the object3 The position of the camera is based on size of the object 4

5 var objectcreate(AB052B5B646E4A48B9C045096FF9B088)6 camerafit(obj)

31 camera 13

uBudiler API 20 Documentation Release 01

cameraflyTo

Move the position and the fixation point of the camera within a certain time then execute a function

Parameters

Name Descriptionjson json message including position fixation point time execute function

Example

1 move camera to position (234) and change the fixation point to (345 )2 within 2 seconds then print ldquoOKrdquo3

4 cameraflyTo(5 eyeVector3(234)6 targetVector3(345)7 time208 completefunction()print(OK)9 )

cameralookAt

Set camerarsquos fixation point as given Vector

Parameters

Name Descriptionpos Vector3 variable camerarsquos fixation point

Example

1 set cameras fixation point to be the center point of the object obj2 cameralookAt(objcenter)

camerasetPosition

Set camerarsquos position as given Vector

14 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 camerarsquos position

Example

1 set cameras position to (012)2 camerasetPosition(Vector3(012))

camerastopFlying

Set camerarsquos position as given Vector

Parameters

none

Example

1 Create a button namedExecute2 Clicking on the button will stop moving the position or fixation point of the

rarr˓camera3

4 camerasetPosition(Vector3(012))5

6 cameraflyTo(7

8 eyeVector3(234)9

10 targetVector3(345)11

12 time2013

14 completefunction()print(OK))15

16 guicreateButton(Execute Rect(10 50 200 50) function() camerastopFlying())

object

Overview

Control the objects within the scene

32 object 15

uBudiler API 20 Documentation Release 01

Name Description Returnscreate Create an object Returns the object type of the created objectcreateArrowLine Create an arrow line Returns the object type of the created arrow linecreateCurveLine Create a curved line Returns the object type of the curved linedestroyAll Delete all the objects created by a script none

objectcreate

Create object

Parameters

Name DescriptionbundleId string the id of the objectparentObj BaseObject parent of the objectcallback function Callback function After loading the object execute this callbackpos Vector3 the position of the objectscale Vector3 the size of the object

Example

1 Create objectobj1and set its position to (101)2 Create a second object obj2and set its parent to be obj1 and its position to (201)3 scale (123) after loading obj2 execute callback rotate the obj1 45 degree of Y

rarr˓(this time obj1 is obj2s parent4 so obj1 and obj2 will rotate together) 5

6 var obj1 = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(101))7 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1function()obj1

rarr˓yaw(45)Vector3(201)Vector3(123))

objectcreateArrowLine

Create arrowed line

Parameters

Name Descriptionvertices array or vector3List the set of points on the arrowed linejson json message includes the color of the arrow and the color of the line

Example

16 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 define a Vector array2 var vecArray2 = [Vector3(0 1 20) Vector3(10 1 20)]3

4

5 Create an arrowed line Set the start position to (0120) and the end position torarr˓(10120)

6 The color of the line is set to red the color of the arrow is set to green7

8 objectcreateArrowLine(vecArray2 9

10 color Colorred11

12 arrowColor Colorgreen)

objectcreateCurveLine

Create curve line

Parameters

Name Descriptionvertices array or Vector3ListThe set of the points on the curve linebundleOrColorOrMat string or colorparentObj BaseObject the parent of the curve linewidth float the width of the curve linetextiling repeatability of the materialtexOffSet the offset of the material

Example

1 create a curve line named curveLine12 var vecList = Vector3List()3

4 vecListAdd(Vector3(010))5

6 vecListAdd(Vector3(1010))7

8 vecListAdd(Vector3(1015))9

10 var curveLine1=objectcreateCurveLine(vecList Colorgreen)11

12

13 Create a curve line named curveLine2 Set the material of the curve line torarr˓specified material

14 Set the parent ofcurveLine2tocurveLine115 Set the repeatability ofcurveLine2s material to (12) and the offset of its

rarr˓material to (00)16

17 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]18

19 var curveLine2 = objectcreateCurveLine(vecArray 1D2702801708453680664DCABE70890Brarr˓curveLine12Vector2(12)Vector2(00))

32 object 17

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 7: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

Model Library

There are three common objects in right navigation bar of momoda studio model texture and function

bull Model

Objects like building car people desk etc User could also upload their custom objects through Momoda 3DSMaxplugin

bull Texture

Textures to cover the surface of object also supports use custom texture upload by user

bull Function

Effects such as fire rain flash or assistant function such as drawing line pipeline or text Function are system build-inand do not supports user upload at this time

Scene Levels

There are four level in Momoda scene campus building stories and rooms

bull Campus

Upmost level of a scene

4 Chapter 1 Concept Guide

uBudiler API 20 Documentation Release 01

bull Building

Buildings (do not includes building facade)

bull Stories

13 Scene Levels 5

uBudiler API 20 Documentation Release 01

bull Room

API Developement

Momoda supports online development via uBuilder API developing web page

6 Chapter 1 Concept Guide

uBudiler API 20 Documentation Release 01

Create New API Project

There a two pane in developing web page left pane is for script editing right pane is for running scripts in 3D sceneTo begin a new API development project visit the uBuilder API developing web page input the ID of target 3D scenethen click New button

Deploy API Project to Scene

To includes API script into your own scene simply copy all the script source code and paste to the text box of MyProjects mdashgt Target Scene mdashgt Configure Scene

Keyboard Shortcuts

Below are keyboard shortcuts in uBuilder API debug page

bull Ctrl+Enter Run Script

bull Ctrl+R Reset Scene

bull Ctrl+ CommentUncomment source code

API Namespace

uBuilder API functions are grouped in following namespaces

Namespace Descriptioncamera camera controlobject create search or modify objects in 3D scenegui manage user interface in 3D sceneBaseObject control existing objectsScriptObject associate scripts on existing objectutil common functionsinput keyboard and mouse eventsconsole management console

14 API Developement 7

uBudiler API 20 Documentation Release 01

8 Chapter 1 Concept Guide

CHAPTER 2

Overview

uBuilder API provides following functions

9

uBudiler API 20 Documentation Release 01

10 Chapter 2 Overview

CHAPTER 3

API Referance

camera

Controls camera objects within a scene

Overview

Name Description Re-turns

Parameters

changeTo2DChange scene mode to 2D none camerachangeTo2D()

changeTo3DChange the Scene mode to 3D none camerachangeTo3D()

getEye-Pos

Get positions of all camera Vec-tor3

cameragetEyePos()

getTar-getPos

Get the position of the fixation point of the camera(s) Vec-tor3

cameragetTargetPos()

fit Focus all cameras on specified object none camerafit(obj)flyTo Move the camera to new position specified by the function none camera

flyTo(json)lookAt Set the Point of view of a camera none camera

lookAt(pos)setPosi-tion

Set the position of a camera none camerasetPosition(pos)

stopFly-ing

Stops the camera at the position specified by the function Oftenused with the function FlyTo

none camerastopFlying()

11

uBudiler API 20 Documentation Release 01

camerachangeTo2D

Change scene mode to 2D

Parameters

none

Example

1 Changes the scene mode to 2D2 If the current scene mode is already in 2D the scene does not change3 camerachangeTo2D()

camerachangeTo3D

Change scene mode to 3D

Parameters

none

Example

1 Changes the scene mode to 3D2 If the current scene mode is already in 3D the scene does not change3 camerachangeTo3D()

cameragetEyePos

Get the current position of the camera

Parameters

none

12 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 print the position of the camera2 print(cameragetEyePos())

cameragetTargetPos

Get the fixation point position of the camera

Parameters

none

Example

1 print fixation point position of the camera2 print(cameragetTargetPos())

camerafit

Focus camera on specified object

Parameters

Name Descriptionobj object referance which will be focued by camera

Example

1 create box object and have the camera focus on the object2 The focus point is the center point of the object3 The position of the camera is based on size of the object 4

5 var objectcreate(AB052B5B646E4A48B9C045096FF9B088)6 camerafit(obj)

31 camera 13

uBudiler API 20 Documentation Release 01

cameraflyTo

Move the position and the fixation point of the camera within a certain time then execute a function

Parameters

Name Descriptionjson json message including position fixation point time execute function

Example

1 move camera to position (234) and change the fixation point to (345 )2 within 2 seconds then print ldquoOKrdquo3

4 cameraflyTo(5 eyeVector3(234)6 targetVector3(345)7 time208 completefunction()print(OK)9 )

cameralookAt

Set camerarsquos fixation point as given Vector

Parameters

Name Descriptionpos Vector3 variable camerarsquos fixation point

Example

1 set cameras fixation point to be the center point of the object obj2 cameralookAt(objcenter)

camerasetPosition

Set camerarsquos position as given Vector

14 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 camerarsquos position

Example

1 set cameras position to (012)2 camerasetPosition(Vector3(012))

camerastopFlying

Set camerarsquos position as given Vector

Parameters

none

Example

1 Create a button namedExecute2 Clicking on the button will stop moving the position or fixation point of the

rarr˓camera3

4 camerasetPosition(Vector3(012))5

6 cameraflyTo(7

8 eyeVector3(234)9

10 targetVector3(345)11

12 time2013

14 completefunction()print(OK))15

16 guicreateButton(Execute Rect(10 50 200 50) function() camerastopFlying())

object

Overview

Control the objects within the scene

32 object 15

uBudiler API 20 Documentation Release 01

Name Description Returnscreate Create an object Returns the object type of the created objectcreateArrowLine Create an arrow line Returns the object type of the created arrow linecreateCurveLine Create a curved line Returns the object type of the curved linedestroyAll Delete all the objects created by a script none

objectcreate

Create object

Parameters

Name DescriptionbundleId string the id of the objectparentObj BaseObject parent of the objectcallback function Callback function After loading the object execute this callbackpos Vector3 the position of the objectscale Vector3 the size of the object

Example

1 Create objectobj1and set its position to (101)2 Create a second object obj2and set its parent to be obj1 and its position to (201)3 scale (123) after loading obj2 execute callback rotate the obj1 45 degree of Y

rarr˓(this time obj1 is obj2s parent4 so obj1 and obj2 will rotate together) 5

6 var obj1 = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(101))7 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1function()obj1

rarr˓yaw(45)Vector3(201)Vector3(123))

objectcreateArrowLine

Create arrowed line

Parameters

Name Descriptionvertices array or vector3List the set of points on the arrowed linejson json message includes the color of the arrow and the color of the line

Example

16 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 define a Vector array2 var vecArray2 = [Vector3(0 1 20) Vector3(10 1 20)]3

4

5 Create an arrowed line Set the start position to (0120) and the end position torarr˓(10120)

6 The color of the line is set to red the color of the arrow is set to green7

8 objectcreateArrowLine(vecArray2 9

10 color Colorred11

12 arrowColor Colorgreen)

objectcreateCurveLine

Create curve line

Parameters

Name Descriptionvertices array or Vector3ListThe set of the points on the curve linebundleOrColorOrMat string or colorparentObj BaseObject the parent of the curve linewidth float the width of the curve linetextiling repeatability of the materialtexOffSet the offset of the material

Example

1 create a curve line named curveLine12 var vecList = Vector3List()3

4 vecListAdd(Vector3(010))5

6 vecListAdd(Vector3(1010))7

8 vecListAdd(Vector3(1015))9

10 var curveLine1=objectcreateCurveLine(vecList Colorgreen)11

12

13 Create a curve line named curveLine2 Set the material of the curve line torarr˓specified material

14 Set the parent ofcurveLine2tocurveLine115 Set the repeatability ofcurveLine2s material to (12) and the offset of its

rarr˓material to (00)16

17 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]18

19 var curveLine2 = objectcreateCurveLine(vecArray 1D2702801708453680664DCABE70890Brarr˓curveLine12Vector2(12)Vector2(00))

32 object 17

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 8: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

bull Building

Buildings (do not includes building facade)

bull Stories

13 Scene Levels 5

uBudiler API 20 Documentation Release 01

bull Room

API Developement

Momoda supports online development via uBuilder API developing web page

6 Chapter 1 Concept Guide

uBudiler API 20 Documentation Release 01

Create New API Project

There a two pane in developing web page left pane is for script editing right pane is for running scripts in 3D sceneTo begin a new API development project visit the uBuilder API developing web page input the ID of target 3D scenethen click New button

Deploy API Project to Scene

To includes API script into your own scene simply copy all the script source code and paste to the text box of MyProjects mdashgt Target Scene mdashgt Configure Scene

Keyboard Shortcuts

Below are keyboard shortcuts in uBuilder API debug page

bull Ctrl+Enter Run Script

bull Ctrl+R Reset Scene

bull Ctrl+ CommentUncomment source code

API Namespace

uBuilder API functions are grouped in following namespaces

Namespace Descriptioncamera camera controlobject create search or modify objects in 3D scenegui manage user interface in 3D sceneBaseObject control existing objectsScriptObject associate scripts on existing objectutil common functionsinput keyboard and mouse eventsconsole management console

14 API Developement 7

uBudiler API 20 Documentation Release 01

8 Chapter 1 Concept Guide

CHAPTER 2

Overview

uBuilder API provides following functions

9

uBudiler API 20 Documentation Release 01

10 Chapter 2 Overview

CHAPTER 3

API Referance

camera

Controls camera objects within a scene

Overview

Name Description Re-turns

Parameters

changeTo2DChange scene mode to 2D none camerachangeTo2D()

changeTo3DChange the Scene mode to 3D none camerachangeTo3D()

getEye-Pos

Get positions of all camera Vec-tor3

cameragetEyePos()

getTar-getPos

Get the position of the fixation point of the camera(s) Vec-tor3

cameragetTargetPos()

fit Focus all cameras on specified object none camerafit(obj)flyTo Move the camera to new position specified by the function none camera

flyTo(json)lookAt Set the Point of view of a camera none camera

lookAt(pos)setPosi-tion

Set the position of a camera none camerasetPosition(pos)

stopFly-ing

Stops the camera at the position specified by the function Oftenused with the function FlyTo

none camerastopFlying()

11

uBudiler API 20 Documentation Release 01

camerachangeTo2D

Change scene mode to 2D

Parameters

none

Example

1 Changes the scene mode to 2D2 If the current scene mode is already in 2D the scene does not change3 camerachangeTo2D()

camerachangeTo3D

Change scene mode to 3D

Parameters

none

Example

1 Changes the scene mode to 3D2 If the current scene mode is already in 3D the scene does not change3 camerachangeTo3D()

cameragetEyePos

Get the current position of the camera

Parameters

none

12 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 print the position of the camera2 print(cameragetEyePos())

cameragetTargetPos

Get the fixation point position of the camera

Parameters

none

Example

1 print fixation point position of the camera2 print(cameragetTargetPos())

camerafit

Focus camera on specified object

Parameters

Name Descriptionobj object referance which will be focued by camera

Example

1 create box object and have the camera focus on the object2 The focus point is the center point of the object3 The position of the camera is based on size of the object 4

5 var objectcreate(AB052B5B646E4A48B9C045096FF9B088)6 camerafit(obj)

31 camera 13

uBudiler API 20 Documentation Release 01

cameraflyTo

Move the position and the fixation point of the camera within a certain time then execute a function

Parameters

Name Descriptionjson json message including position fixation point time execute function

Example

1 move camera to position (234) and change the fixation point to (345 )2 within 2 seconds then print ldquoOKrdquo3

4 cameraflyTo(5 eyeVector3(234)6 targetVector3(345)7 time208 completefunction()print(OK)9 )

cameralookAt

Set camerarsquos fixation point as given Vector

Parameters

Name Descriptionpos Vector3 variable camerarsquos fixation point

Example

1 set cameras fixation point to be the center point of the object obj2 cameralookAt(objcenter)

camerasetPosition

Set camerarsquos position as given Vector

14 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 camerarsquos position

Example

1 set cameras position to (012)2 camerasetPosition(Vector3(012))

camerastopFlying

Set camerarsquos position as given Vector

Parameters

none

Example

1 Create a button namedExecute2 Clicking on the button will stop moving the position or fixation point of the

rarr˓camera3

4 camerasetPosition(Vector3(012))5

6 cameraflyTo(7

8 eyeVector3(234)9

10 targetVector3(345)11

12 time2013

14 completefunction()print(OK))15

16 guicreateButton(Execute Rect(10 50 200 50) function() camerastopFlying())

object

Overview

Control the objects within the scene

32 object 15

uBudiler API 20 Documentation Release 01

Name Description Returnscreate Create an object Returns the object type of the created objectcreateArrowLine Create an arrow line Returns the object type of the created arrow linecreateCurveLine Create a curved line Returns the object type of the curved linedestroyAll Delete all the objects created by a script none

objectcreate

Create object

Parameters

Name DescriptionbundleId string the id of the objectparentObj BaseObject parent of the objectcallback function Callback function After loading the object execute this callbackpos Vector3 the position of the objectscale Vector3 the size of the object

Example

1 Create objectobj1and set its position to (101)2 Create a second object obj2and set its parent to be obj1 and its position to (201)3 scale (123) after loading obj2 execute callback rotate the obj1 45 degree of Y

rarr˓(this time obj1 is obj2s parent4 so obj1 and obj2 will rotate together) 5

6 var obj1 = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(101))7 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1function()obj1

rarr˓yaw(45)Vector3(201)Vector3(123))

objectcreateArrowLine

Create arrowed line

Parameters

Name Descriptionvertices array or vector3List the set of points on the arrowed linejson json message includes the color of the arrow and the color of the line

Example

16 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 define a Vector array2 var vecArray2 = [Vector3(0 1 20) Vector3(10 1 20)]3

4

5 Create an arrowed line Set the start position to (0120) and the end position torarr˓(10120)

6 The color of the line is set to red the color of the arrow is set to green7

8 objectcreateArrowLine(vecArray2 9

10 color Colorred11

12 arrowColor Colorgreen)

objectcreateCurveLine

Create curve line

Parameters

Name Descriptionvertices array or Vector3ListThe set of the points on the curve linebundleOrColorOrMat string or colorparentObj BaseObject the parent of the curve linewidth float the width of the curve linetextiling repeatability of the materialtexOffSet the offset of the material

Example

1 create a curve line named curveLine12 var vecList = Vector3List()3

4 vecListAdd(Vector3(010))5

6 vecListAdd(Vector3(1010))7

8 vecListAdd(Vector3(1015))9

10 var curveLine1=objectcreateCurveLine(vecList Colorgreen)11

12

13 Create a curve line named curveLine2 Set the material of the curve line torarr˓specified material

14 Set the parent ofcurveLine2tocurveLine115 Set the repeatability ofcurveLine2s material to (12) and the offset of its

rarr˓material to (00)16

17 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]18

19 var curveLine2 = objectcreateCurveLine(vecArray 1D2702801708453680664DCABE70890Brarr˓curveLine12Vector2(12)Vector2(00))

32 object 17

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 9: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

bull Room

API Developement

Momoda supports online development via uBuilder API developing web page

6 Chapter 1 Concept Guide

uBudiler API 20 Documentation Release 01

Create New API Project

There a two pane in developing web page left pane is for script editing right pane is for running scripts in 3D sceneTo begin a new API development project visit the uBuilder API developing web page input the ID of target 3D scenethen click New button

Deploy API Project to Scene

To includes API script into your own scene simply copy all the script source code and paste to the text box of MyProjects mdashgt Target Scene mdashgt Configure Scene

Keyboard Shortcuts

Below are keyboard shortcuts in uBuilder API debug page

bull Ctrl+Enter Run Script

bull Ctrl+R Reset Scene

bull Ctrl+ CommentUncomment source code

API Namespace

uBuilder API functions are grouped in following namespaces

Namespace Descriptioncamera camera controlobject create search or modify objects in 3D scenegui manage user interface in 3D sceneBaseObject control existing objectsScriptObject associate scripts on existing objectutil common functionsinput keyboard and mouse eventsconsole management console

14 API Developement 7

uBudiler API 20 Documentation Release 01

8 Chapter 1 Concept Guide

CHAPTER 2

Overview

uBuilder API provides following functions

9

uBudiler API 20 Documentation Release 01

10 Chapter 2 Overview

CHAPTER 3

API Referance

camera

Controls camera objects within a scene

Overview

Name Description Re-turns

Parameters

changeTo2DChange scene mode to 2D none camerachangeTo2D()

changeTo3DChange the Scene mode to 3D none camerachangeTo3D()

getEye-Pos

Get positions of all camera Vec-tor3

cameragetEyePos()

getTar-getPos

Get the position of the fixation point of the camera(s) Vec-tor3

cameragetTargetPos()

fit Focus all cameras on specified object none camerafit(obj)flyTo Move the camera to new position specified by the function none camera

flyTo(json)lookAt Set the Point of view of a camera none camera

lookAt(pos)setPosi-tion

Set the position of a camera none camerasetPosition(pos)

stopFly-ing

Stops the camera at the position specified by the function Oftenused with the function FlyTo

none camerastopFlying()

11

uBudiler API 20 Documentation Release 01

camerachangeTo2D

Change scene mode to 2D

Parameters

none

Example

1 Changes the scene mode to 2D2 If the current scene mode is already in 2D the scene does not change3 camerachangeTo2D()

camerachangeTo3D

Change scene mode to 3D

Parameters

none

Example

1 Changes the scene mode to 3D2 If the current scene mode is already in 3D the scene does not change3 camerachangeTo3D()

cameragetEyePos

Get the current position of the camera

Parameters

none

12 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 print the position of the camera2 print(cameragetEyePos())

cameragetTargetPos

Get the fixation point position of the camera

Parameters

none

Example

1 print fixation point position of the camera2 print(cameragetTargetPos())

camerafit

Focus camera on specified object

Parameters

Name Descriptionobj object referance which will be focued by camera

Example

1 create box object and have the camera focus on the object2 The focus point is the center point of the object3 The position of the camera is based on size of the object 4

5 var objectcreate(AB052B5B646E4A48B9C045096FF9B088)6 camerafit(obj)

31 camera 13

uBudiler API 20 Documentation Release 01

cameraflyTo

Move the position and the fixation point of the camera within a certain time then execute a function

Parameters

Name Descriptionjson json message including position fixation point time execute function

Example

1 move camera to position (234) and change the fixation point to (345 )2 within 2 seconds then print ldquoOKrdquo3

4 cameraflyTo(5 eyeVector3(234)6 targetVector3(345)7 time208 completefunction()print(OK)9 )

cameralookAt

Set camerarsquos fixation point as given Vector

Parameters

Name Descriptionpos Vector3 variable camerarsquos fixation point

Example

1 set cameras fixation point to be the center point of the object obj2 cameralookAt(objcenter)

camerasetPosition

Set camerarsquos position as given Vector

14 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 camerarsquos position

Example

1 set cameras position to (012)2 camerasetPosition(Vector3(012))

camerastopFlying

Set camerarsquos position as given Vector

Parameters

none

Example

1 Create a button namedExecute2 Clicking on the button will stop moving the position or fixation point of the

rarr˓camera3

4 camerasetPosition(Vector3(012))5

6 cameraflyTo(7

8 eyeVector3(234)9

10 targetVector3(345)11

12 time2013

14 completefunction()print(OK))15

16 guicreateButton(Execute Rect(10 50 200 50) function() camerastopFlying())

object

Overview

Control the objects within the scene

32 object 15

uBudiler API 20 Documentation Release 01

Name Description Returnscreate Create an object Returns the object type of the created objectcreateArrowLine Create an arrow line Returns the object type of the created arrow linecreateCurveLine Create a curved line Returns the object type of the curved linedestroyAll Delete all the objects created by a script none

objectcreate

Create object

Parameters

Name DescriptionbundleId string the id of the objectparentObj BaseObject parent of the objectcallback function Callback function After loading the object execute this callbackpos Vector3 the position of the objectscale Vector3 the size of the object

Example

1 Create objectobj1and set its position to (101)2 Create a second object obj2and set its parent to be obj1 and its position to (201)3 scale (123) after loading obj2 execute callback rotate the obj1 45 degree of Y

rarr˓(this time obj1 is obj2s parent4 so obj1 and obj2 will rotate together) 5

6 var obj1 = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(101))7 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1function()obj1

rarr˓yaw(45)Vector3(201)Vector3(123))

objectcreateArrowLine

Create arrowed line

Parameters

Name Descriptionvertices array or vector3List the set of points on the arrowed linejson json message includes the color of the arrow and the color of the line

Example

16 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 define a Vector array2 var vecArray2 = [Vector3(0 1 20) Vector3(10 1 20)]3

4

5 Create an arrowed line Set the start position to (0120) and the end position torarr˓(10120)

6 The color of the line is set to red the color of the arrow is set to green7

8 objectcreateArrowLine(vecArray2 9

10 color Colorred11

12 arrowColor Colorgreen)

objectcreateCurveLine

Create curve line

Parameters

Name Descriptionvertices array or Vector3ListThe set of the points on the curve linebundleOrColorOrMat string or colorparentObj BaseObject the parent of the curve linewidth float the width of the curve linetextiling repeatability of the materialtexOffSet the offset of the material

Example

1 create a curve line named curveLine12 var vecList = Vector3List()3

4 vecListAdd(Vector3(010))5

6 vecListAdd(Vector3(1010))7

8 vecListAdd(Vector3(1015))9

10 var curveLine1=objectcreateCurveLine(vecList Colorgreen)11

12

13 Create a curve line named curveLine2 Set the material of the curve line torarr˓specified material

14 Set the parent ofcurveLine2tocurveLine115 Set the repeatability ofcurveLine2s material to (12) and the offset of its

rarr˓material to (00)16

17 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]18

19 var curveLine2 = objectcreateCurveLine(vecArray 1D2702801708453680664DCABE70890Brarr˓curveLine12Vector2(12)Vector2(00))

32 object 17

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 10: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

Create New API Project

There a two pane in developing web page left pane is for script editing right pane is for running scripts in 3D sceneTo begin a new API development project visit the uBuilder API developing web page input the ID of target 3D scenethen click New button

Deploy API Project to Scene

To includes API script into your own scene simply copy all the script source code and paste to the text box of MyProjects mdashgt Target Scene mdashgt Configure Scene

Keyboard Shortcuts

Below are keyboard shortcuts in uBuilder API debug page

bull Ctrl+Enter Run Script

bull Ctrl+R Reset Scene

bull Ctrl+ CommentUncomment source code

API Namespace

uBuilder API functions are grouped in following namespaces

Namespace Descriptioncamera camera controlobject create search or modify objects in 3D scenegui manage user interface in 3D sceneBaseObject control existing objectsScriptObject associate scripts on existing objectutil common functionsinput keyboard and mouse eventsconsole management console

14 API Developement 7

uBudiler API 20 Documentation Release 01

8 Chapter 1 Concept Guide

CHAPTER 2

Overview

uBuilder API provides following functions

9

uBudiler API 20 Documentation Release 01

10 Chapter 2 Overview

CHAPTER 3

API Referance

camera

Controls camera objects within a scene

Overview

Name Description Re-turns

Parameters

changeTo2DChange scene mode to 2D none camerachangeTo2D()

changeTo3DChange the Scene mode to 3D none camerachangeTo3D()

getEye-Pos

Get positions of all camera Vec-tor3

cameragetEyePos()

getTar-getPos

Get the position of the fixation point of the camera(s) Vec-tor3

cameragetTargetPos()

fit Focus all cameras on specified object none camerafit(obj)flyTo Move the camera to new position specified by the function none camera

flyTo(json)lookAt Set the Point of view of a camera none camera

lookAt(pos)setPosi-tion

Set the position of a camera none camerasetPosition(pos)

stopFly-ing

Stops the camera at the position specified by the function Oftenused with the function FlyTo

none camerastopFlying()

11

uBudiler API 20 Documentation Release 01

camerachangeTo2D

Change scene mode to 2D

Parameters

none

Example

1 Changes the scene mode to 2D2 If the current scene mode is already in 2D the scene does not change3 camerachangeTo2D()

camerachangeTo3D

Change scene mode to 3D

Parameters

none

Example

1 Changes the scene mode to 3D2 If the current scene mode is already in 3D the scene does not change3 camerachangeTo3D()

cameragetEyePos

Get the current position of the camera

Parameters

none

12 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 print the position of the camera2 print(cameragetEyePos())

cameragetTargetPos

Get the fixation point position of the camera

Parameters

none

Example

1 print fixation point position of the camera2 print(cameragetTargetPos())

camerafit

Focus camera on specified object

Parameters

Name Descriptionobj object referance which will be focued by camera

Example

1 create box object and have the camera focus on the object2 The focus point is the center point of the object3 The position of the camera is based on size of the object 4

5 var objectcreate(AB052B5B646E4A48B9C045096FF9B088)6 camerafit(obj)

31 camera 13

uBudiler API 20 Documentation Release 01

cameraflyTo

Move the position and the fixation point of the camera within a certain time then execute a function

Parameters

Name Descriptionjson json message including position fixation point time execute function

Example

1 move camera to position (234) and change the fixation point to (345 )2 within 2 seconds then print ldquoOKrdquo3

4 cameraflyTo(5 eyeVector3(234)6 targetVector3(345)7 time208 completefunction()print(OK)9 )

cameralookAt

Set camerarsquos fixation point as given Vector

Parameters

Name Descriptionpos Vector3 variable camerarsquos fixation point

Example

1 set cameras fixation point to be the center point of the object obj2 cameralookAt(objcenter)

camerasetPosition

Set camerarsquos position as given Vector

14 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 camerarsquos position

Example

1 set cameras position to (012)2 camerasetPosition(Vector3(012))

camerastopFlying

Set camerarsquos position as given Vector

Parameters

none

Example

1 Create a button namedExecute2 Clicking on the button will stop moving the position or fixation point of the

rarr˓camera3

4 camerasetPosition(Vector3(012))5

6 cameraflyTo(7

8 eyeVector3(234)9

10 targetVector3(345)11

12 time2013

14 completefunction()print(OK))15

16 guicreateButton(Execute Rect(10 50 200 50) function() camerastopFlying())

object

Overview

Control the objects within the scene

32 object 15

uBudiler API 20 Documentation Release 01

Name Description Returnscreate Create an object Returns the object type of the created objectcreateArrowLine Create an arrow line Returns the object type of the created arrow linecreateCurveLine Create a curved line Returns the object type of the curved linedestroyAll Delete all the objects created by a script none

objectcreate

Create object

Parameters

Name DescriptionbundleId string the id of the objectparentObj BaseObject parent of the objectcallback function Callback function After loading the object execute this callbackpos Vector3 the position of the objectscale Vector3 the size of the object

Example

1 Create objectobj1and set its position to (101)2 Create a second object obj2and set its parent to be obj1 and its position to (201)3 scale (123) after loading obj2 execute callback rotate the obj1 45 degree of Y

rarr˓(this time obj1 is obj2s parent4 so obj1 and obj2 will rotate together) 5

6 var obj1 = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(101))7 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1function()obj1

rarr˓yaw(45)Vector3(201)Vector3(123))

objectcreateArrowLine

Create arrowed line

Parameters

Name Descriptionvertices array or vector3List the set of points on the arrowed linejson json message includes the color of the arrow and the color of the line

Example

16 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 define a Vector array2 var vecArray2 = [Vector3(0 1 20) Vector3(10 1 20)]3

4

5 Create an arrowed line Set the start position to (0120) and the end position torarr˓(10120)

6 The color of the line is set to red the color of the arrow is set to green7

8 objectcreateArrowLine(vecArray2 9

10 color Colorred11

12 arrowColor Colorgreen)

objectcreateCurveLine

Create curve line

Parameters

Name Descriptionvertices array or Vector3ListThe set of the points on the curve linebundleOrColorOrMat string or colorparentObj BaseObject the parent of the curve linewidth float the width of the curve linetextiling repeatability of the materialtexOffSet the offset of the material

Example

1 create a curve line named curveLine12 var vecList = Vector3List()3

4 vecListAdd(Vector3(010))5

6 vecListAdd(Vector3(1010))7

8 vecListAdd(Vector3(1015))9

10 var curveLine1=objectcreateCurveLine(vecList Colorgreen)11

12

13 Create a curve line named curveLine2 Set the material of the curve line torarr˓specified material

14 Set the parent ofcurveLine2tocurveLine115 Set the repeatability ofcurveLine2s material to (12) and the offset of its

rarr˓material to (00)16

17 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]18

19 var curveLine2 = objectcreateCurveLine(vecArray 1D2702801708453680664DCABE70890Brarr˓curveLine12Vector2(12)Vector2(00))

32 object 17

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 11: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

8 Chapter 1 Concept Guide

CHAPTER 2

Overview

uBuilder API provides following functions

9

uBudiler API 20 Documentation Release 01

10 Chapter 2 Overview

CHAPTER 3

API Referance

camera

Controls camera objects within a scene

Overview

Name Description Re-turns

Parameters

changeTo2DChange scene mode to 2D none camerachangeTo2D()

changeTo3DChange the Scene mode to 3D none camerachangeTo3D()

getEye-Pos

Get positions of all camera Vec-tor3

cameragetEyePos()

getTar-getPos

Get the position of the fixation point of the camera(s) Vec-tor3

cameragetTargetPos()

fit Focus all cameras on specified object none camerafit(obj)flyTo Move the camera to new position specified by the function none camera

flyTo(json)lookAt Set the Point of view of a camera none camera

lookAt(pos)setPosi-tion

Set the position of a camera none camerasetPosition(pos)

stopFly-ing

Stops the camera at the position specified by the function Oftenused with the function FlyTo

none camerastopFlying()

11

uBudiler API 20 Documentation Release 01

camerachangeTo2D

Change scene mode to 2D

Parameters

none

Example

1 Changes the scene mode to 2D2 If the current scene mode is already in 2D the scene does not change3 camerachangeTo2D()

camerachangeTo3D

Change scene mode to 3D

Parameters

none

Example

1 Changes the scene mode to 3D2 If the current scene mode is already in 3D the scene does not change3 camerachangeTo3D()

cameragetEyePos

Get the current position of the camera

Parameters

none

12 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 print the position of the camera2 print(cameragetEyePos())

cameragetTargetPos

Get the fixation point position of the camera

Parameters

none

Example

1 print fixation point position of the camera2 print(cameragetTargetPos())

camerafit

Focus camera on specified object

Parameters

Name Descriptionobj object referance which will be focued by camera

Example

1 create box object and have the camera focus on the object2 The focus point is the center point of the object3 The position of the camera is based on size of the object 4

5 var objectcreate(AB052B5B646E4A48B9C045096FF9B088)6 camerafit(obj)

31 camera 13

uBudiler API 20 Documentation Release 01

cameraflyTo

Move the position and the fixation point of the camera within a certain time then execute a function

Parameters

Name Descriptionjson json message including position fixation point time execute function

Example

1 move camera to position (234) and change the fixation point to (345 )2 within 2 seconds then print ldquoOKrdquo3

4 cameraflyTo(5 eyeVector3(234)6 targetVector3(345)7 time208 completefunction()print(OK)9 )

cameralookAt

Set camerarsquos fixation point as given Vector

Parameters

Name Descriptionpos Vector3 variable camerarsquos fixation point

Example

1 set cameras fixation point to be the center point of the object obj2 cameralookAt(objcenter)

camerasetPosition

Set camerarsquos position as given Vector

14 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 camerarsquos position

Example

1 set cameras position to (012)2 camerasetPosition(Vector3(012))

camerastopFlying

Set camerarsquos position as given Vector

Parameters

none

Example

1 Create a button namedExecute2 Clicking on the button will stop moving the position or fixation point of the

rarr˓camera3

4 camerasetPosition(Vector3(012))5

6 cameraflyTo(7

8 eyeVector3(234)9

10 targetVector3(345)11

12 time2013

14 completefunction()print(OK))15

16 guicreateButton(Execute Rect(10 50 200 50) function() camerastopFlying())

object

Overview

Control the objects within the scene

32 object 15

uBudiler API 20 Documentation Release 01

Name Description Returnscreate Create an object Returns the object type of the created objectcreateArrowLine Create an arrow line Returns the object type of the created arrow linecreateCurveLine Create a curved line Returns the object type of the curved linedestroyAll Delete all the objects created by a script none

objectcreate

Create object

Parameters

Name DescriptionbundleId string the id of the objectparentObj BaseObject parent of the objectcallback function Callback function After loading the object execute this callbackpos Vector3 the position of the objectscale Vector3 the size of the object

Example

1 Create objectobj1and set its position to (101)2 Create a second object obj2and set its parent to be obj1 and its position to (201)3 scale (123) after loading obj2 execute callback rotate the obj1 45 degree of Y

rarr˓(this time obj1 is obj2s parent4 so obj1 and obj2 will rotate together) 5

6 var obj1 = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(101))7 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1function()obj1

rarr˓yaw(45)Vector3(201)Vector3(123))

objectcreateArrowLine

Create arrowed line

Parameters

Name Descriptionvertices array or vector3List the set of points on the arrowed linejson json message includes the color of the arrow and the color of the line

Example

16 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 define a Vector array2 var vecArray2 = [Vector3(0 1 20) Vector3(10 1 20)]3

4

5 Create an arrowed line Set the start position to (0120) and the end position torarr˓(10120)

6 The color of the line is set to red the color of the arrow is set to green7

8 objectcreateArrowLine(vecArray2 9

10 color Colorred11

12 arrowColor Colorgreen)

objectcreateCurveLine

Create curve line

Parameters

Name Descriptionvertices array or Vector3ListThe set of the points on the curve linebundleOrColorOrMat string or colorparentObj BaseObject the parent of the curve linewidth float the width of the curve linetextiling repeatability of the materialtexOffSet the offset of the material

Example

1 create a curve line named curveLine12 var vecList = Vector3List()3

4 vecListAdd(Vector3(010))5

6 vecListAdd(Vector3(1010))7

8 vecListAdd(Vector3(1015))9

10 var curveLine1=objectcreateCurveLine(vecList Colorgreen)11

12

13 Create a curve line named curveLine2 Set the material of the curve line torarr˓specified material

14 Set the parent ofcurveLine2tocurveLine115 Set the repeatability ofcurveLine2s material to (12) and the offset of its

rarr˓material to (00)16

17 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]18

19 var curveLine2 = objectcreateCurveLine(vecArray 1D2702801708453680664DCABE70890Brarr˓curveLine12Vector2(12)Vector2(00))

32 object 17

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 12: uBudiler API 2.0 Documentation - readthedocs.org

CHAPTER 2

Overview

uBuilder API provides following functions

9

uBudiler API 20 Documentation Release 01

10 Chapter 2 Overview

CHAPTER 3

API Referance

camera

Controls camera objects within a scene

Overview

Name Description Re-turns

Parameters

changeTo2DChange scene mode to 2D none camerachangeTo2D()

changeTo3DChange the Scene mode to 3D none camerachangeTo3D()

getEye-Pos

Get positions of all camera Vec-tor3

cameragetEyePos()

getTar-getPos

Get the position of the fixation point of the camera(s) Vec-tor3

cameragetTargetPos()

fit Focus all cameras on specified object none camerafit(obj)flyTo Move the camera to new position specified by the function none camera

flyTo(json)lookAt Set the Point of view of a camera none camera

lookAt(pos)setPosi-tion

Set the position of a camera none camerasetPosition(pos)

stopFly-ing

Stops the camera at the position specified by the function Oftenused with the function FlyTo

none camerastopFlying()

11

uBudiler API 20 Documentation Release 01

camerachangeTo2D

Change scene mode to 2D

Parameters

none

Example

1 Changes the scene mode to 2D2 If the current scene mode is already in 2D the scene does not change3 camerachangeTo2D()

camerachangeTo3D

Change scene mode to 3D

Parameters

none

Example

1 Changes the scene mode to 3D2 If the current scene mode is already in 3D the scene does not change3 camerachangeTo3D()

cameragetEyePos

Get the current position of the camera

Parameters

none

12 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 print the position of the camera2 print(cameragetEyePos())

cameragetTargetPos

Get the fixation point position of the camera

Parameters

none

Example

1 print fixation point position of the camera2 print(cameragetTargetPos())

camerafit

Focus camera on specified object

Parameters

Name Descriptionobj object referance which will be focued by camera

Example

1 create box object and have the camera focus on the object2 The focus point is the center point of the object3 The position of the camera is based on size of the object 4

5 var objectcreate(AB052B5B646E4A48B9C045096FF9B088)6 camerafit(obj)

31 camera 13

uBudiler API 20 Documentation Release 01

cameraflyTo

Move the position and the fixation point of the camera within a certain time then execute a function

Parameters

Name Descriptionjson json message including position fixation point time execute function

Example

1 move camera to position (234) and change the fixation point to (345 )2 within 2 seconds then print ldquoOKrdquo3

4 cameraflyTo(5 eyeVector3(234)6 targetVector3(345)7 time208 completefunction()print(OK)9 )

cameralookAt

Set camerarsquos fixation point as given Vector

Parameters

Name Descriptionpos Vector3 variable camerarsquos fixation point

Example

1 set cameras fixation point to be the center point of the object obj2 cameralookAt(objcenter)

camerasetPosition

Set camerarsquos position as given Vector

14 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 camerarsquos position

Example

1 set cameras position to (012)2 camerasetPosition(Vector3(012))

camerastopFlying

Set camerarsquos position as given Vector

Parameters

none

Example

1 Create a button namedExecute2 Clicking on the button will stop moving the position or fixation point of the

rarr˓camera3

4 camerasetPosition(Vector3(012))5

6 cameraflyTo(7

8 eyeVector3(234)9

10 targetVector3(345)11

12 time2013

14 completefunction()print(OK))15

16 guicreateButton(Execute Rect(10 50 200 50) function() camerastopFlying())

object

Overview

Control the objects within the scene

32 object 15

uBudiler API 20 Documentation Release 01

Name Description Returnscreate Create an object Returns the object type of the created objectcreateArrowLine Create an arrow line Returns the object type of the created arrow linecreateCurveLine Create a curved line Returns the object type of the curved linedestroyAll Delete all the objects created by a script none

objectcreate

Create object

Parameters

Name DescriptionbundleId string the id of the objectparentObj BaseObject parent of the objectcallback function Callback function After loading the object execute this callbackpos Vector3 the position of the objectscale Vector3 the size of the object

Example

1 Create objectobj1and set its position to (101)2 Create a second object obj2and set its parent to be obj1 and its position to (201)3 scale (123) after loading obj2 execute callback rotate the obj1 45 degree of Y

rarr˓(this time obj1 is obj2s parent4 so obj1 and obj2 will rotate together) 5

6 var obj1 = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(101))7 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1function()obj1

rarr˓yaw(45)Vector3(201)Vector3(123))

objectcreateArrowLine

Create arrowed line

Parameters

Name Descriptionvertices array or vector3List the set of points on the arrowed linejson json message includes the color of the arrow and the color of the line

Example

16 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 define a Vector array2 var vecArray2 = [Vector3(0 1 20) Vector3(10 1 20)]3

4

5 Create an arrowed line Set the start position to (0120) and the end position torarr˓(10120)

6 The color of the line is set to red the color of the arrow is set to green7

8 objectcreateArrowLine(vecArray2 9

10 color Colorred11

12 arrowColor Colorgreen)

objectcreateCurveLine

Create curve line

Parameters

Name Descriptionvertices array or Vector3ListThe set of the points on the curve linebundleOrColorOrMat string or colorparentObj BaseObject the parent of the curve linewidth float the width of the curve linetextiling repeatability of the materialtexOffSet the offset of the material

Example

1 create a curve line named curveLine12 var vecList = Vector3List()3

4 vecListAdd(Vector3(010))5

6 vecListAdd(Vector3(1010))7

8 vecListAdd(Vector3(1015))9

10 var curveLine1=objectcreateCurveLine(vecList Colorgreen)11

12

13 Create a curve line named curveLine2 Set the material of the curve line torarr˓specified material

14 Set the parent ofcurveLine2tocurveLine115 Set the repeatability ofcurveLine2s material to (12) and the offset of its

rarr˓material to (00)16

17 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]18

19 var curveLine2 = objectcreateCurveLine(vecArray 1D2702801708453680664DCABE70890Brarr˓curveLine12Vector2(12)Vector2(00))

32 object 17

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 13: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

10 Chapter 2 Overview

CHAPTER 3

API Referance

camera

Controls camera objects within a scene

Overview

Name Description Re-turns

Parameters

changeTo2DChange scene mode to 2D none camerachangeTo2D()

changeTo3DChange the Scene mode to 3D none camerachangeTo3D()

getEye-Pos

Get positions of all camera Vec-tor3

cameragetEyePos()

getTar-getPos

Get the position of the fixation point of the camera(s) Vec-tor3

cameragetTargetPos()

fit Focus all cameras on specified object none camerafit(obj)flyTo Move the camera to new position specified by the function none camera

flyTo(json)lookAt Set the Point of view of a camera none camera

lookAt(pos)setPosi-tion

Set the position of a camera none camerasetPosition(pos)

stopFly-ing

Stops the camera at the position specified by the function Oftenused with the function FlyTo

none camerastopFlying()

11

uBudiler API 20 Documentation Release 01

camerachangeTo2D

Change scene mode to 2D

Parameters

none

Example

1 Changes the scene mode to 2D2 If the current scene mode is already in 2D the scene does not change3 camerachangeTo2D()

camerachangeTo3D

Change scene mode to 3D

Parameters

none

Example

1 Changes the scene mode to 3D2 If the current scene mode is already in 3D the scene does not change3 camerachangeTo3D()

cameragetEyePos

Get the current position of the camera

Parameters

none

12 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 print the position of the camera2 print(cameragetEyePos())

cameragetTargetPos

Get the fixation point position of the camera

Parameters

none

Example

1 print fixation point position of the camera2 print(cameragetTargetPos())

camerafit

Focus camera on specified object

Parameters

Name Descriptionobj object referance which will be focued by camera

Example

1 create box object and have the camera focus on the object2 The focus point is the center point of the object3 The position of the camera is based on size of the object 4

5 var objectcreate(AB052B5B646E4A48B9C045096FF9B088)6 camerafit(obj)

31 camera 13

uBudiler API 20 Documentation Release 01

cameraflyTo

Move the position and the fixation point of the camera within a certain time then execute a function

Parameters

Name Descriptionjson json message including position fixation point time execute function

Example

1 move camera to position (234) and change the fixation point to (345 )2 within 2 seconds then print ldquoOKrdquo3

4 cameraflyTo(5 eyeVector3(234)6 targetVector3(345)7 time208 completefunction()print(OK)9 )

cameralookAt

Set camerarsquos fixation point as given Vector

Parameters

Name Descriptionpos Vector3 variable camerarsquos fixation point

Example

1 set cameras fixation point to be the center point of the object obj2 cameralookAt(objcenter)

camerasetPosition

Set camerarsquos position as given Vector

14 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 camerarsquos position

Example

1 set cameras position to (012)2 camerasetPosition(Vector3(012))

camerastopFlying

Set camerarsquos position as given Vector

Parameters

none

Example

1 Create a button namedExecute2 Clicking on the button will stop moving the position or fixation point of the

rarr˓camera3

4 camerasetPosition(Vector3(012))5

6 cameraflyTo(7

8 eyeVector3(234)9

10 targetVector3(345)11

12 time2013

14 completefunction()print(OK))15

16 guicreateButton(Execute Rect(10 50 200 50) function() camerastopFlying())

object

Overview

Control the objects within the scene

32 object 15

uBudiler API 20 Documentation Release 01

Name Description Returnscreate Create an object Returns the object type of the created objectcreateArrowLine Create an arrow line Returns the object type of the created arrow linecreateCurveLine Create a curved line Returns the object type of the curved linedestroyAll Delete all the objects created by a script none

objectcreate

Create object

Parameters

Name DescriptionbundleId string the id of the objectparentObj BaseObject parent of the objectcallback function Callback function After loading the object execute this callbackpos Vector3 the position of the objectscale Vector3 the size of the object

Example

1 Create objectobj1and set its position to (101)2 Create a second object obj2and set its parent to be obj1 and its position to (201)3 scale (123) after loading obj2 execute callback rotate the obj1 45 degree of Y

rarr˓(this time obj1 is obj2s parent4 so obj1 and obj2 will rotate together) 5

6 var obj1 = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(101))7 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1function()obj1

rarr˓yaw(45)Vector3(201)Vector3(123))

objectcreateArrowLine

Create arrowed line

Parameters

Name Descriptionvertices array or vector3List the set of points on the arrowed linejson json message includes the color of the arrow and the color of the line

Example

16 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 define a Vector array2 var vecArray2 = [Vector3(0 1 20) Vector3(10 1 20)]3

4

5 Create an arrowed line Set the start position to (0120) and the end position torarr˓(10120)

6 The color of the line is set to red the color of the arrow is set to green7

8 objectcreateArrowLine(vecArray2 9

10 color Colorred11

12 arrowColor Colorgreen)

objectcreateCurveLine

Create curve line

Parameters

Name Descriptionvertices array or Vector3ListThe set of the points on the curve linebundleOrColorOrMat string or colorparentObj BaseObject the parent of the curve linewidth float the width of the curve linetextiling repeatability of the materialtexOffSet the offset of the material

Example

1 create a curve line named curveLine12 var vecList = Vector3List()3

4 vecListAdd(Vector3(010))5

6 vecListAdd(Vector3(1010))7

8 vecListAdd(Vector3(1015))9

10 var curveLine1=objectcreateCurveLine(vecList Colorgreen)11

12

13 Create a curve line named curveLine2 Set the material of the curve line torarr˓specified material

14 Set the parent ofcurveLine2tocurveLine115 Set the repeatability ofcurveLine2s material to (12) and the offset of its

rarr˓material to (00)16

17 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]18

19 var curveLine2 = objectcreateCurveLine(vecArray 1D2702801708453680664DCABE70890Brarr˓curveLine12Vector2(12)Vector2(00))

32 object 17

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 14: uBudiler API 2.0 Documentation - readthedocs.org

CHAPTER 3

API Referance

camera

Controls camera objects within a scene

Overview

Name Description Re-turns

Parameters

changeTo2DChange scene mode to 2D none camerachangeTo2D()

changeTo3DChange the Scene mode to 3D none camerachangeTo3D()

getEye-Pos

Get positions of all camera Vec-tor3

cameragetEyePos()

getTar-getPos

Get the position of the fixation point of the camera(s) Vec-tor3

cameragetTargetPos()

fit Focus all cameras on specified object none camerafit(obj)flyTo Move the camera to new position specified by the function none camera

flyTo(json)lookAt Set the Point of view of a camera none camera

lookAt(pos)setPosi-tion

Set the position of a camera none camerasetPosition(pos)

stopFly-ing

Stops the camera at the position specified by the function Oftenused with the function FlyTo

none camerastopFlying()

11

uBudiler API 20 Documentation Release 01

camerachangeTo2D

Change scene mode to 2D

Parameters

none

Example

1 Changes the scene mode to 2D2 If the current scene mode is already in 2D the scene does not change3 camerachangeTo2D()

camerachangeTo3D

Change scene mode to 3D

Parameters

none

Example

1 Changes the scene mode to 3D2 If the current scene mode is already in 3D the scene does not change3 camerachangeTo3D()

cameragetEyePos

Get the current position of the camera

Parameters

none

12 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 print the position of the camera2 print(cameragetEyePos())

cameragetTargetPos

Get the fixation point position of the camera

Parameters

none

Example

1 print fixation point position of the camera2 print(cameragetTargetPos())

camerafit

Focus camera on specified object

Parameters

Name Descriptionobj object referance which will be focued by camera

Example

1 create box object and have the camera focus on the object2 The focus point is the center point of the object3 The position of the camera is based on size of the object 4

5 var objectcreate(AB052B5B646E4A48B9C045096FF9B088)6 camerafit(obj)

31 camera 13

uBudiler API 20 Documentation Release 01

cameraflyTo

Move the position and the fixation point of the camera within a certain time then execute a function

Parameters

Name Descriptionjson json message including position fixation point time execute function

Example

1 move camera to position (234) and change the fixation point to (345 )2 within 2 seconds then print ldquoOKrdquo3

4 cameraflyTo(5 eyeVector3(234)6 targetVector3(345)7 time208 completefunction()print(OK)9 )

cameralookAt

Set camerarsquos fixation point as given Vector

Parameters

Name Descriptionpos Vector3 variable camerarsquos fixation point

Example

1 set cameras fixation point to be the center point of the object obj2 cameralookAt(objcenter)

camerasetPosition

Set camerarsquos position as given Vector

14 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 camerarsquos position

Example

1 set cameras position to (012)2 camerasetPosition(Vector3(012))

camerastopFlying

Set camerarsquos position as given Vector

Parameters

none

Example

1 Create a button namedExecute2 Clicking on the button will stop moving the position or fixation point of the

rarr˓camera3

4 camerasetPosition(Vector3(012))5

6 cameraflyTo(7

8 eyeVector3(234)9

10 targetVector3(345)11

12 time2013

14 completefunction()print(OK))15

16 guicreateButton(Execute Rect(10 50 200 50) function() camerastopFlying())

object

Overview

Control the objects within the scene

32 object 15

uBudiler API 20 Documentation Release 01

Name Description Returnscreate Create an object Returns the object type of the created objectcreateArrowLine Create an arrow line Returns the object type of the created arrow linecreateCurveLine Create a curved line Returns the object type of the curved linedestroyAll Delete all the objects created by a script none

objectcreate

Create object

Parameters

Name DescriptionbundleId string the id of the objectparentObj BaseObject parent of the objectcallback function Callback function After loading the object execute this callbackpos Vector3 the position of the objectscale Vector3 the size of the object

Example

1 Create objectobj1and set its position to (101)2 Create a second object obj2and set its parent to be obj1 and its position to (201)3 scale (123) after loading obj2 execute callback rotate the obj1 45 degree of Y

rarr˓(this time obj1 is obj2s parent4 so obj1 and obj2 will rotate together) 5

6 var obj1 = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(101))7 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1function()obj1

rarr˓yaw(45)Vector3(201)Vector3(123))

objectcreateArrowLine

Create arrowed line

Parameters

Name Descriptionvertices array or vector3List the set of points on the arrowed linejson json message includes the color of the arrow and the color of the line

Example

16 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 define a Vector array2 var vecArray2 = [Vector3(0 1 20) Vector3(10 1 20)]3

4

5 Create an arrowed line Set the start position to (0120) and the end position torarr˓(10120)

6 The color of the line is set to red the color of the arrow is set to green7

8 objectcreateArrowLine(vecArray2 9

10 color Colorred11

12 arrowColor Colorgreen)

objectcreateCurveLine

Create curve line

Parameters

Name Descriptionvertices array or Vector3ListThe set of the points on the curve linebundleOrColorOrMat string or colorparentObj BaseObject the parent of the curve linewidth float the width of the curve linetextiling repeatability of the materialtexOffSet the offset of the material

Example

1 create a curve line named curveLine12 var vecList = Vector3List()3

4 vecListAdd(Vector3(010))5

6 vecListAdd(Vector3(1010))7

8 vecListAdd(Vector3(1015))9

10 var curveLine1=objectcreateCurveLine(vecList Colorgreen)11

12

13 Create a curve line named curveLine2 Set the material of the curve line torarr˓specified material

14 Set the parent ofcurveLine2tocurveLine115 Set the repeatability ofcurveLine2s material to (12) and the offset of its

rarr˓material to (00)16

17 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]18

19 var curveLine2 = objectcreateCurveLine(vecArray 1D2702801708453680664DCABE70890Brarr˓curveLine12Vector2(12)Vector2(00))

32 object 17

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 15: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

camerachangeTo2D

Change scene mode to 2D

Parameters

none

Example

1 Changes the scene mode to 2D2 If the current scene mode is already in 2D the scene does not change3 camerachangeTo2D()

camerachangeTo3D

Change scene mode to 3D

Parameters

none

Example

1 Changes the scene mode to 3D2 If the current scene mode is already in 3D the scene does not change3 camerachangeTo3D()

cameragetEyePos

Get the current position of the camera

Parameters

none

12 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 print the position of the camera2 print(cameragetEyePos())

cameragetTargetPos

Get the fixation point position of the camera

Parameters

none

Example

1 print fixation point position of the camera2 print(cameragetTargetPos())

camerafit

Focus camera on specified object

Parameters

Name Descriptionobj object referance which will be focued by camera

Example

1 create box object and have the camera focus on the object2 The focus point is the center point of the object3 The position of the camera is based on size of the object 4

5 var objectcreate(AB052B5B646E4A48B9C045096FF9B088)6 camerafit(obj)

31 camera 13

uBudiler API 20 Documentation Release 01

cameraflyTo

Move the position and the fixation point of the camera within a certain time then execute a function

Parameters

Name Descriptionjson json message including position fixation point time execute function

Example

1 move camera to position (234) and change the fixation point to (345 )2 within 2 seconds then print ldquoOKrdquo3

4 cameraflyTo(5 eyeVector3(234)6 targetVector3(345)7 time208 completefunction()print(OK)9 )

cameralookAt

Set camerarsquos fixation point as given Vector

Parameters

Name Descriptionpos Vector3 variable camerarsquos fixation point

Example

1 set cameras fixation point to be the center point of the object obj2 cameralookAt(objcenter)

camerasetPosition

Set camerarsquos position as given Vector

14 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 camerarsquos position

Example

1 set cameras position to (012)2 camerasetPosition(Vector3(012))

camerastopFlying

Set camerarsquos position as given Vector

Parameters

none

Example

1 Create a button namedExecute2 Clicking on the button will stop moving the position or fixation point of the

rarr˓camera3

4 camerasetPosition(Vector3(012))5

6 cameraflyTo(7

8 eyeVector3(234)9

10 targetVector3(345)11

12 time2013

14 completefunction()print(OK))15

16 guicreateButton(Execute Rect(10 50 200 50) function() camerastopFlying())

object

Overview

Control the objects within the scene

32 object 15

uBudiler API 20 Documentation Release 01

Name Description Returnscreate Create an object Returns the object type of the created objectcreateArrowLine Create an arrow line Returns the object type of the created arrow linecreateCurveLine Create a curved line Returns the object type of the curved linedestroyAll Delete all the objects created by a script none

objectcreate

Create object

Parameters

Name DescriptionbundleId string the id of the objectparentObj BaseObject parent of the objectcallback function Callback function After loading the object execute this callbackpos Vector3 the position of the objectscale Vector3 the size of the object

Example

1 Create objectobj1and set its position to (101)2 Create a second object obj2and set its parent to be obj1 and its position to (201)3 scale (123) after loading obj2 execute callback rotate the obj1 45 degree of Y

rarr˓(this time obj1 is obj2s parent4 so obj1 and obj2 will rotate together) 5

6 var obj1 = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(101))7 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1function()obj1

rarr˓yaw(45)Vector3(201)Vector3(123))

objectcreateArrowLine

Create arrowed line

Parameters

Name Descriptionvertices array or vector3List the set of points on the arrowed linejson json message includes the color of the arrow and the color of the line

Example

16 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 define a Vector array2 var vecArray2 = [Vector3(0 1 20) Vector3(10 1 20)]3

4

5 Create an arrowed line Set the start position to (0120) and the end position torarr˓(10120)

6 The color of the line is set to red the color of the arrow is set to green7

8 objectcreateArrowLine(vecArray2 9

10 color Colorred11

12 arrowColor Colorgreen)

objectcreateCurveLine

Create curve line

Parameters

Name Descriptionvertices array or Vector3ListThe set of the points on the curve linebundleOrColorOrMat string or colorparentObj BaseObject the parent of the curve linewidth float the width of the curve linetextiling repeatability of the materialtexOffSet the offset of the material

Example

1 create a curve line named curveLine12 var vecList = Vector3List()3

4 vecListAdd(Vector3(010))5

6 vecListAdd(Vector3(1010))7

8 vecListAdd(Vector3(1015))9

10 var curveLine1=objectcreateCurveLine(vecList Colorgreen)11

12

13 Create a curve line named curveLine2 Set the material of the curve line torarr˓specified material

14 Set the parent ofcurveLine2tocurveLine115 Set the repeatability ofcurveLine2s material to (12) and the offset of its

rarr˓material to (00)16

17 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]18

19 var curveLine2 = objectcreateCurveLine(vecArray 1D2702801708453680664DCABE70890Brarr˓curveLine12Vector2(12)Vector2(00))

32 object 17

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 16: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

Example

1 print the position of the camera2 print(cameragetEyePos())

cameragetTargetPos

Get the fixation point position of the camera

Parameters

none

Example

1 print fixation point position of the camera2 print(cameragetTargetPos())

camerafit

Focus camera on specified object

Parameters

Name Descriptionobj object referance which will be focued by camera

Example

1 create box object and have the camera focus on the object2 The focus point is the center point of the object3 The position of the camera is based on size of the object 4

5 var objectcreate(AB052B5B646E4A48B9C045096FF9B088)6 camerafit(obj)

31 camera 13

uBudiler API 20 Documentation Release 01

cameraflyTo

Move the position and the fixation point of the camera within a certain time then execute a function

Parameters

Name Descriptionjson json message including position fixation point time execute function

Example

1 move camera to position (234) and change the fixation point to (345 )2 within 2 seconds then print ldquoOKrdquo3

4 cameraflyTo(5 eyeVector3(234)6 targetVector3(345)7 time208 completefunction()print(OK)9 )

cameralookAt

Set camerarsquos fixation point as given Vector

Parameters

Name Descriptionpos Vector3 variable camerarsquos fixation point

Example

1 set cameras fixation point to be the center point of the object obj2 cameralookAt(objcenter)

camerasetPosition

Set camerarsquos position as given Vector

14 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 camerarsquos position

Example

1 set cameras position to (012)2 camerasetPosition(Vector3(012))

camerastopFlying

Set camerarsquos position as given Vector

Parameters

none

Example

1 Create a button namedExecute2 Clicking on the button will stop moving the position or fixation point of the

rarr˓camera3

4 camerasetPosition(Vector3(012))5

6 cameraflyTo(7

8 eyeVector3(234)9

10 targetVector3(345)11

12 time2013

14 completefunction()print(OK))15

16 guicreateButton(Execute Rect(10 50 200 50) function() camerastopFlying())

object

Overview

Control the objects within the scene

32 object 15

uBudiler API 20 Documentation Release 01

Name Description Returnscreate Create an object Returns the object type of the created objectcreateArrowLine Create an arrow line Returns the object type of the created arrow linecreateCurveLine Create a curved line Returns the object type of the curved linedestroyAll Delete all the objects created by a script none

objectcreate

Create object

Parameters

Name DescriptionbundleId string the id of the objectparentObj BaseObject parent of the objectcallback function Callback function After loading the object execute this callbackpos Vector3 the position of the objectscale Vector3 the size of the object

Example

1 Create objectobj1and set its position to (101)2 Create a second object obj2and set its parent to be obj1 and its position to (201)3 scale (123) after loading obj2 execute callback rotate the obj1 45 degree of Y

rarr˓(this time obj1 is obj2s parent4 so obj1 and obj2 will rotate together) 5

6 var obj1 = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(101))7 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1function()obj1

rarr˓yaw(45)Vector3(201)Vector3(123))

objectcreateArrowLine

Create arrowed line

Parameters

Name Descriptionvertices array or vector3List the set of points on the arrowed linejson json message includes the color of the arrow and the color of the line

Example

16 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 define a Vector array2 var vecArray2 = [Vector3(0 1 20) Vector3(10 1 20)]3

4

5 Create an arrowed line Set the start position to (0120) and the end position torarr˓(10120)

6 The color of the line is set to red the color of the arrow is set to green7

8 objectcreateArrowLine(vecArray2 9

10 color Colorred11

12 arrowColor Colorgreen)

objectcreateCurveLine

Create curve line

Parameters

Name Descriptionvertices array or Vector3ListThe set of the points on the curve linebundleOrColorOrMat string or colorparentObj BaseObject the parent of the curve linewidth float the width of the curve linetextiling repeatability of the materialtexOffSet the offset of the material

Example

1 create a curve line named curveLine12 var vecList = Vector3List()3

4 vecListAdd(Vector3(010))5

6 vecListAdd(Vector3(1010))7

8 vecListAdd(Vector3(1015))9

10 var curveLine1=objectcreateCurveLine(vecList Colorgreen)11

12

13 Create a curve line named curveLine2 Set the material of the curve line torarr˓specified material

14 Set the parent ofcurveLine2tocurveLine115 Set the repeatability ofcurveLine2s material to (12) and the offset of its

rarr˓material to (00)16

17 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]18

19 var curveLine2 = objectcreateCurveLine(vecArray 1D2702801708453680664DCABE70890Brarr˓curveLine12Vector2(12)Vector2(00))

32 object 17

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 17: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

cameraflyTo

Move the position and the fixation point of the camera within a certain time then execute a function

Parameters

Name Descriptionjson json message including position fixation point time execute function

Example

1 move camera to position (234) and change the fixation point to (345 )2 within 2 seconds then print ldquoOKrdquo3

4 cameraflyTo(5 eyeVector3(234)6 targetVector3(345)7 time208 completefunction()print(OK)9 )

cameralookAt

Set camerarsquos fixation point as given Vector

Parameters

Name Descriptionpos Vector3 variable camerarsquos fixation point

Example

1 set cameras fixation point to be the center point of the object obj2 cameralookAt(objcenter)

camerasetPosition

Set camerarsquos position as given Vector

14 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 camerarsquos position

Example

1 set cameras position to (012)2 camerasetPosition(Vector3(012))

camerastopFlying

Set camerarsquos position as given Vector

Parameters

none

Example

1 Create a button namedExecute2 Clicking on the button will stop moving the position or fixation point of the

rarr˓camera3

4 camerasetPosition(Vector3(012))5

6 cameraflyTo(7

8 eyeVector3(234)9

10 targetVector3(345)11

12 time2013

14 completefunction()print(OK))15

16 guicreateButton(Execute Rect(10 50 200 50) function() camerastopFlying())

object

Overview

Control the objects within the scene

32 object 15

uBudiler API 20 Documentation Release 01

Name Description Returnscreate Create an object Returns the object type of the created objectcreateArrowLine Create an arrow line Returns the object type of the created arrow linecreateCurveLine Create a curved line Returns the object type of the curved linedestroyAll Delete all the objects created by a script none

objectcreate

Create object

Parameters

Name DescriptionbundleId string the id of the objectparentObj BaseObject parent of the objectcallback function Callback function After loading the object execute this callbackpos Vector3 the position of the objectscale Vector3 the size of the object

Example

1 Create objectobj1and set its position to (101)2 Create a second object obj2and set its parent to be obj1 and its position to (201)3 scale (123) after loading obj2 execute callback rotate the obj1 45 degree of Y

rarr˓(this time obj1 is obj2s parent4 so obj1 and obj2 will rotate together) 5

6 var obj1 = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(101))7 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1function()obj1

rarr˓yaw(45)Vector3(201)Vector3(123))

objectcreateArrowLine

Create arrowed line

Parameters

Name Descriptionvertices array or vector3List the set of points on the arrowed linejson json message includes the color of the arrow and the color of the line

Example

16 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 define a Vector array2 var vecArray2 = [Vector3(0 1 20) Vector3(10 1 20)]3

4

5 Create an arrowed line Set the start position to (0120) and the end position torarr˓(10120)

6 The color of the line is set to red the color of the arrow is set to green7

8 objectcreateArrowLine(vecArray2 9

10 color Colorred11

12 arrowColor Colorgreen)

objectcreateCurveLine

Create curve line

Parameters

Name Descriptionvertices array or Vector3ListThe set of the points on the curve linebundleOrColorOrMat string or colorparentObj BaseObject the parent of the curve linewidth float the width of the curve linetextiling repeatability of the materialtexOffSet the offset of the material

Example

1 create a curve line named curveLine12 var vecList = Vector3List()3

4 vecListAdd(Vector3(010))5

6 vecListAdd(Vector3(1010))7

8 vecListAdd(Vector3(1015))9

10 var curveLine1=objectcreateCurveLine(vecList Colorgreen)11

12

13 Create a curve line named curveLine2 Set the material of the curve line torarr˓specified material

14 Set the parent ofcurveLine2tocurveLine115 Set the repeatability ofcurveLine2s material to (12) and the offset of its

rarr˓material to (00)16

17 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]18

19 var curveLine2 = objectcreateCurveLine(vecArray 1D2702801708453680664DCABE70890Brarr˓curveLine12Vector2(12)Vector2(00))

32 object 17

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 18: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 camerarsquos position

Example

1 set cameras position to (012)2 camerasetPosition(Vector3(012))

camerastopFlying

Set camerarsquos position as given Vector

Parameters

none

Example

1 Create a button namedExecute2 Clicking on the button will stop moving the position or fixation point of the

rarr˓camera3

4 camerasetPosition(Vector3(012))5

6 cameraflyTo(7

8 eyeVector3(234)9

10 targetVector3(345)11

12 time2013

14 completefunction()print(OK))15

16 guicreateButton(Execute Rect(10 50 200 50) function() camerastopFlying())

object

Overview

Control the objects within the scene

32 object 15

uBudiler API 20 Documentation Release 01

Name Description Returnscreate Create an object Returns the object type of the created objectcreateArrowLine Create an arrow line Returns the object type of the created arrow linecreateCurveLine Create a curved line Returns the object type of the curved linedestroyAll Delete all the objects created by a script none

objectcreate

Create object

Parameters

Name DescriptionbundleId string the id of the objectparentObj BaseObject parent of the objectcallback function Callback function After loading the object execute this callbackpos Vector3 the position of the objectscale Vector3 the size of the object

Example

1 Create objectobj1and set its position to (101)2 Create a second object obj2and set its parent to be obj1 and its position to (201)3 scale (123) after loading obj2 execute callback rotate the obj1 45 degree of Y

rarr˓(this time obj1 is obj2s parent4 so obj1 and obj2 will rotate together) 5

6 var obj1 = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(101))7 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1function()obj1

rarr˓yaw(45)Vector3(201)Vector3(123))

objectcreateArrowLine

Create arrowed line

Parameters

Name Descriptionvertices array or vector3List the set of points on the arrowed linejson json message includes the color of the arrow and the color of the line

Example

16 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 define a Vector array2 var vecArray2 = [Vector3(0 1 20) Vector3(10 1 20)]3

4

5 Create an arrowed line Set the start position to (0120) and the end position torarr˓(10120)

6 The color of the line is set to red the color of the arrow is set to green7

8 objectcreateArrowLine(vecArray2 9

10 color Colorred11

12 arrowColor Colorgreen)

objectcreateCurveLine

Create curve line

Parameters

Name Descriptionvertices array or Vector3ListThe set of the points on the curve linebundleOrColorOrMat string or colorparentObj BaseObject the parent of the curve linewidth float the width of the curve linetextiling repeatability of the materialtexOffSet the offset of the material

Example

1 create a curve line named curveLine12 var vecList = Vector3List()3

4 vecListAdd(Vector3(010))5

6 vecListAdd(Vector3(1010))7

8 vecListAdd(Vector3(1015))9

10 var curveLine1=objectcreateCurveLine(vecList Colorgreen)11

12

13 Create a curve line named curveLine2 Set the material of the curve line torarr˓specified material

14 Set the parent ofcurveLine2tocurveLine115 Set the repeatability ofcurveLine2s material to (12) and the offset of its

rarr˓material to (00)16

17 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]18

19 var curveLine2 = objectcreateCurveLine(vecArray 1D2702801708453680664DCABE70890Brarr˓curveLine12Vector2(12)Vector2(00))

32 object 17

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 19: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

Name Description Returnscreate Create an object Returns the object type of the created objectcreateArrowLine Create an arrow line Returns the object type of the created arrow linecreateCurveLine Create a curved line Returns the object type of the curved linedestroyAll Delete all the objects created by a script none

objectcreate

Create object

Parameters

Name DescriptionbundleId string the id of the objectparentObj BaseObject parent of the objectcallback function Callback function After loading the object execute this callbackpos Vector3 the position of the objectscale Vector3 the size of the object

Example

1 Create objectobj1and set its position to (101)2 Create a second object obj2and set its parent to be obj1 and its position to (201)3 scale (123) after loading obj2 execute callback rotate the obj1 45 degree of Y

rarr˓(this time obj1 is obj2s parent4 so obj1 and obj2 will rotate together) 5

6 var obj1 = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(101))7 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1function()obj1

rarr˓yaw(45)Vector3(201)Vector3(123))

objectcreateArrowLine

Create arrowed line

Parameters

Name Descriptionvertices array or vector3List the set of points on the arrowed linejson json message includes the color of the arrow and the color of the line

Example

16 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 define a Vector array2 var vecArray2 = [Vector3(0 1 20) Vector3(10 1 20)]3

4

5 Create an arrowed line Set the start position to (0120) and the end position torarr˓(10120)

6 The color of the line is set to red the color of the arrow is set to green7

8 objectcreateArrowLine(vecArray2 9

10 color Colorred11

12 arrowColor Colorgreen)

objectcreateCurveLine

Create curve line

Parameters

Name Descriptionvertices array or Vector3ListThe set of the points on the curve linebundleOrColorOrMat string or colorparentObj BaseObject the parent of the curve linewidth float the width of the curve linetextiling repeatability of the materialtexOffSet the offset of the material

Example

1 create a curve line named curveLine12 var vecList = Vector3List()3

4 vecListAdd(Vector3(010))5

6 vecListAdd(Vector3(1010))7

8 vecListAdd(Vector3(1015))9

10 var curveLine1=objectcreateCurveLine(vecList Colorgreen)11

12

13 Create a curve line named curveLine2 Set the material of the curve line torarr˓specified material

14 Set the parent ofcurveLine2tocurveLine115 Set the repeatability ofcurveLine2s material to (12) and the offset of its

rarr˓material to (00)16

17 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]18

19 var curveLine2 = objectcreateCurveLine(vecArray 1D2702801708453680664DCABE70890Brarr˓curveLine12Vector2(12)Vector2(00))

32 object 17

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 20: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

1 define a Vector array2 var vecArray2 = [Vector3(0 1 20) Vector3(10 1 20)]3

4

5 Create an arrowed line Set the start position to (0120) and the end position torarr˓(10120)

6 The color of the line is set to red the color of the arrow is set to green7

8 objectcreateArrowLine(vecArray2 9

10 color Colorred11

12 arrowColor Colorgreen)

objectcreateCurveLine

Create curve line

Parameters

Name Descriptionvertices array or Vector3ListThe set of the points on the curve linebundleOrColorOrMat string or colorparentObj BaseObject the parent of the curve linewidth float the width of the curve linetextiling repeatability of the materialtexOffSet the offset of the material

Example

1 create a curve line named curveLine12 var vecList = Vector3List()3

4 vecListAdd(Vector3(010))5

6 vecListAdd(Vector3(1010))7

8 vecListAdd(Vector3(1015))9

10 var curveLine1=objectcreateCurveLine(vecList Colorgreen)11

12

13 Create a curve line named curveLine2 Set the material of the curve line torarr˓specified material

14 Set the parent ofcurveLine2tocurveLine115 Set the repeatability ofcurveLine2s material to (12) and the offset of its

rarr˓material to (00)16

17 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]18

19 var curveLine2 = objectcreateCurveLine(vecArray 1D2702801708453680664DCABE70890Brarr˓curveLine12Vector2(12)Vector2(00))

32 object 17

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 21: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

objectdestroyAll

Destoy all the objects created by a script

Parameters

None

Example

1 create obj2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4

5 create curveLine6 var vecArray = [Vector3(015) Vector3(0215) Vector3(10415) Vector3(1065)]7

8 var curveLine1=objectcreateCurveLine(vecArray Colorgreen)9

10

11 Create a button called Delete Clicking on the buttonDeletewill destroy allrarr˓objects created by this script

12 guicreateButton(Delete Rect(100 100 100 30) function() objectdestroyAll())

objectfind

Find object by object ID

Parameters

Name Descriptionuid string object uid

Example

1 Find Object with an Uid equal toObject012 then rotate this object around the Y-axis at a 45 degree angle3 objectfind(Object01)4 objyaw(-45)

gui

Overview

Control graphical user interface within the scene

18 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 22: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

createBox Create a box object guicreatebox(textrect)createBut-ton

Create a button object guicreateButton(textrectcallback)

createLa-bel

Create a label object guicreateLabel(text rect)

createTog-gle

Create a toggle button object guicreateToggle(checkedtextrectcallback)

load Load an external GUIresource

none guiload(urlcallback)

guicreateBox

Creat a button

Parameters

Name Descriptiontext string text to display on the buttonrect rect a rectangle on the screen to use as the buttoncallback function callback function on mouse click

Example

1 Create a button Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the button is set to 80 pixels and 50 pixels respectively3 Clicking on this button will print the stringYou Clicked Button 1 4

5 var buttont1 = guicreateButton(Button 1 Rect(100 200 80 50) function() 6 print (You clicked Button 1))

guicreateLabel

Make a text or texture label

Parameters

Name Descriptiontext string text to display on the labelrect rect a rectangle on the screen to use as the label

33 gui 19

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 23: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

Example

1 Create a Label Set the left coordinate to 100 pixels and the top coordinate torarr˓200 pixels

2 The width and height of the label is set to 80 pixels and 50 pixels respectively3

4 guicreateLabel(Label 1 Rect(100 200 80 50))

guicreateToggle

Make an onoff toggle button

Parameters

Name Descriptionchecked Boolean set initial status to lsquoOnrsquo or lsquoOffrsquotext string text to display on the togglerect rect a rectangle on the screen to use as the toggle buttoncallback function callback function on mouse click

Example

1 Create a Toggle Button Set the left coordinate to 100 pixels and the toprarr˓coordinate to 200 pixels

2 The width and height of the GUI Box is set to 80 pixels and 50 pixels respectively3 If the value of the Toggle Button is changed print the stringYou clicked Toggle 1

rarr˓4

5 guicreateToggle (Toggle 1 Rect(100 200 80 50) function() 6 print(You changed the state of Toggle 1)7 )

guiload

Load GUI resource

Parameters

Name Descriptionurl string resource urlcallback function callback function on mouse click

20 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 24: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

Example

1 GUI resource from the specified URL After the GUI has loaded2 print Successfully loading resource from url 3

4 var url = httpwww3dmomodacommmdclientscriptexamplesdemosscifi_uibundle5 guiload(url function()print(Successfully loading resource from url))

BaseObject

Overview

Provides actions on object

Name Description ReturnsaddGravity Add a gravity value to a specified object noneaddScript Add a script to a specified objectReturns the type of script added to the object scriptaddTail Add a tail to a specified object Commonly used with the function movePath noneclone Copy an existing object BaseObjectdestroy Remove an existing object BaseObjectgetPosition Acquire the position of a specified object Vector3getScale Acquire the scale of a specified objectlsquolsquoVector3lsquolsquo movePathMove object by a

specified parameternone

moveTo Move object to a position within a given time nonepitch Angel of rotation(in degree) of the object around its pivot point along X axis noneremove-Script

Remove a script from the specified object none

roll Angel of rotation (in degree) of the object around its pivot point along the Z axis nonesetAnim-Speed

Set the animation speed of a specified object none

setColor Set the color of a specified object nonesetColor-Flash

Set the flash state flash color and flash time of a specified object none

setPickEn-abled

Set the selectable state of the specified object Commonly used with mouse eventfunctions

none

setPosition Set the objectrsquos position nonesetPosi-tionXZ

Set the objectrsquos horizontal position none

setPositionY Set the objectrsquos position along the Y axis nonesetScale Set the scale of the object nonesetTranspar-ent

Set the transparency of a specified object none

stopAnim Stop a specified objectrsquos animation nonestopMoving Stop the object moving nonetransform-Point

Change specified coordinates of object from relative coordinates to absolutecoordinates

Vector3

translate Move a specified object in a specified direction and distance Vector3yaw Angel of rotation (in degree) of the object around its pivot point along the Y axis none

34 BaseObject 21

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 25: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

BaseObjectaddGravity

Add gravitational value to a object

Parameters

Name Descriptionmass float the weight of the object

Example

1 add gravity to a 35 KG weight object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objaddGravity(35)

BaseObjectaddScript

Add script to a object

Parameters

Name Descriptionscript script to associate with the objectname string name of the script

Example

1 Create a script namedAutoRtateused to define the speed of objectobjOption2 A script may include aStartandUpdate function which is automatically recognized

rarr˓by the system3 TheStartfunction will be called only once while theUpdatefunction will be called

rarr˓on repeatedly 4

5 AutoRotate = 6

7 speed 08

9 objOption null10

11 function Start() thisspeed = utilrandomFloat(1 8)12

13 function Update() thisobjOptionyaw(thisspeed) 14

15 16

17 create object18 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))

22 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 26: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

19

20 add script ldquorotationrdquo to object21 var script = objaddScript(AutoRtaterotation)22

23 set scripts attribute objOption to be object now function Update can rotate objrarr˓by its Y axis in a random speed

24 scriptobjOption = obj

BaseObjectaddTail

Add trail to a specified object Most Commonly used with the function movePath Often used to increase the visualeffects of an object

Parameters

Name Descriptionjson json format includes start width end width end color and time

Example

1 create object2 var obj =objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 var path = Vector3List()4

5 generate 36 vector3 point add them to a Vector3List this could be seen as ararr˓circle its radius is 10

6 for (var degree = 0 degree lt 360 degree += 10)7 8 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMath

rarr˓Deg2Rad)10))9

10

11 move an object along the path in 10 seconds repeatly whilst moving12 the object will always look at (000)13 objmovePath(14

15 path path16

17 time 1018

19 lookPos Vector3zero20

21 loopType loop22

23 )24

25

26 add a tail start width 06 end width 0 color is red lasting 5 seconds27 objaddTail(28

34 BaseObject 23

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 27: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

29 startWidth 0630

31 endWidth032

33 colorColorred34

35 time 536

37 )

BaseObjectclone

Clone a object

Parameters

None

Example

1 Create an object copy it and name isobj2 Then rotateobj2along the Y-Axis at ararr˓45 degree angle

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 var obj2=objclone()6

7 obj2yaw(45)

BaseObjectdestroy

Remove a object

Parameters

None

Example

24 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 28: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

1 Create an object named Obj Create a button namedDeletewith the size (10100rarr˓10020)

2 click on this button to remove objectobjfrom the scene3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 guicreateButton(DeleteRect(1010010020)function()objdestroy())

BaseObjectgetPosition

Get position of a object

Parameters

None

Example

1 Create an object and print its position2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetPosition())

BaseObjectgetScale

Get scale information of a object

Parameters

None

Example

1 Create an object and print its scale2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 print(objgetScale())

34 BaseObject 25

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 29: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

BaseObjectmovePath

Move object along pre-defined path

Parameters

Name Descriptionjson json format specify path time target point if loop etc

Example

1 Create object2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3

4 Generate 36 Vector3 point add them in a Vector3List you could see thisrarr˓Vector3List as a circle

5

6 var path = Vector3List()7

8 for (var degree = 0 degree lt 360 degree += 10)9

10 pathAdd(Vec3(MathCos(degreeMathDeg2Rad)1005MathSin(degreeMathrarr˓Deg2Rad)10))

11

12

13 Move an object along a path in 10 seconds whilst moving the object will alwaysrarr˓face the vector (000)

14 after the object completes the movement loop this function15

16 objmovePath(17

18 path path19

20 time 1021

22 lookPos Vector3zero23

24 loopType loop25

26 )

BaseObjectmoveTo

Move object to target position within a certain time

26 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 30: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptionpos Vector3 destination positiontime float moving time

Example

1 Create object move it to (1000) in 5 seconds2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objmoveTo(Vector3(10 0 0) 50)

BaseObjectpitch

Rotate object on the X-axis by degree

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objpitch(45)

BaseObjectplayAnim

Play objectrsquos animation

Parameters

Name DescriptionanimName string name of the animation

Example

34 BaseObject 27

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 31: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

1 Create an object namedobj Create a button with size (10010010030)2 Pressing on this button will execute the ldquoRunrdquo animation of the object3 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)4 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))

BaseObjectremoveScript

Move script associate with object

Parameters

Name Descriptionname string name of the script

Example

1 AutoRtate = 2

3 speed 04

5 objOption null6

7 function Start() thisspeed = utilrandomFloat(1 8)8

9 function Update() thisobjOptionyaw(thisspeed) 10

11 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))12

13 var script = objaddScript(AutoRtaterotation)14

15 scriptobjOption = obj16

17 Create a button Pressing on this button will remove the ldquorotationrdquo script fromrarr˓the objectobj

18

19 guicreateButton(Remove Script Rect(100 100 100 30)function()objrarr˓removeScript(rotation))

BaseObjectroll

Rotate object a specified degree around the Z-axis (clockwise)

28 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 32: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

Parameters

Name Descriptiondegree float degree of rotation

Example

1 Create an object and rotate the object on the X-axis at a 45 degree angle2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 objroll(45)

BaseObjectsetAnimSpeed

Set the animation speed of a specified object

Parameters

Name Descriptionspeed float speed of animation playing

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button Pressing on this button will set the objects animation speed to4rarr˓5

6 guicreateButton(Accelerate Rect(100 150 100 30) function() objrarr˓setAnimSpeed(45))

BaseObjectsetColor

Set object color

Parameters

Name Descriptioncolor color

34 BaseObject 29

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 33: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

Example

1 Set the object color to blue2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(0 0 0))4

5 objsetColor(Colorblue)

BaseObjectsetColorFlash

Set flash state flash color and flash interval of a specified object

Parameters

Name Descriptionenable boolen turn flash lsquoOnrsquo orrsquo Offrsquocolor color flash colortime float flash interval

Example

1 Create object and set flash toOn flash color to Green and Flash interval torarr˓25 seconds

2

3 var obj = objectcreate(FF2A3E364B1E4B928891E05A9279C7A7 Vector3(4 0 0))4

5 objsetColorFlash(true Colorgreen25)

BaseObjectsetPickEnabled

Set selectable state of the specified object Commonly use with the lsquoMouse eventrsquo functions

Parameters

Name Descriptionenable boolen turn pickable lsquoOnrsquo orrsquo Offrsquo

Example

30 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 34: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

1 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 var dragObj = null4

5 utiladdEventListener(dragstart function(event) 6

7 if (eventobj ampamp eventbutton == 0) 8

9 dragObj = eventobj10

11 dragObjsetPickEnabled(false)12

13 cameraenableRot = false )14

15 Add a ldquodragstartrdquo event to an object namedobj16 Left clicking and dragging objectobjwill change the selectable state to false

rarr˓(Prevents object from being repeatedly dragged)17

18 utiladdEventListener(drag function(event) 19

20 if (dragObj ampamp eventbutton == 0)21

22 dragObjpos = eventpos)23

24 utiladdEventListener(dragend function(event) 25

26 if (dragObj ampamp eventbutton == 0) 27

28 dragObjsetPickEnabled(true)29

30 dragObj = null31

32 cameraenableRot = true)

BaseObjectsetPosition

Set object position

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the objects position to (050)2

34 BaseObject 31

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 35: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPosition(0 5 0)

BaseObjectsetPositionXZ

Set object horizontal position

Parameters

Name Descriptionx float X-Axis valuez float Z-Axis value

Example

1 Set the objects horizontal position to (11)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionXZ(11)

BaseObjectsetPositionY

Set object Y-Axis coordinate position

Parameters

Name Descriptiony float Y-Axis value

Example

1 Set the Y-Axis coordinate of the object to 52

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetPositionY(5)

32 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 36: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

BaseObjectsetScale

Set object scale

Parameters

Name Descriptionx float X-Axis valuey float Y-Axis valuez float Z-Axis value

Example

1 Set the scale of the object to be (123)2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetScale(123)

BaseObjectsetTransparent

Set object transparency

Parameters

Name Descriptiontrans float transparency value range 0~1

Example

1 Set the objects transparency to052

3 objectcreate(AB052B5B646E4A48B9C045096FF9B088)4

5 objsetTransparent(05)

BaseObjectstopAnim

Stop play object animation

34 BaseObject 33

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 37: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

Parameters

None

Example

1 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)2

3 guicreateButton(Run Rect(100 100 100 30) function() objplayAnim(Run))4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom playing the animationRun7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopAnim())

BaseObjectstopMoving

Stop object moving

Parameters

None

Example

1 var obj = = objectcreate(AB052B5B646E4A48B9C045096FF9B088)2

3 objmoveTo(Vector3(10 0 0) 50)4

5 Create a button named Stopand set its size to (10015010030)6 Pressing this button will stop objectobjfrom moving7

8 guicreateButton(Stop Rect(100 150 100 30) function() objstopMoving())

BaseObjecttransformPoint

Convert coordinates of object from relative coordinates to absolute coordinates

Parameters

Name Descriptionpos Vector3 relative coordinates of the object

34 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 38: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088Vector3(123))3

4 Create a second object namedobj2whose parent isobj15 var obj2 = objectcreate(AB052B5B646E4A48B9C045096FF9B088obj1Vector3(456))6

7 print(obj2transformPoint(Vector3(789)))

Note

bull The relative coordinates ofrsquoobj2rsquois (456)Thus the absolute coordinates ofrsquoobj2rsquois (123)+(456)=(579)

bull Printing the transformPoint of Vector3(789) will show the value (121518) (Converting the relative coordinatesof Vector3 to absolute coordinates is (579)+(789)=(121518))

BaseObjecttranslate

Move a specified object to a specified direction and distance

Parameters

Name Descriptionpos Vector3

Example

1 Create objectobj1 set its position (123)2 var obj = objectcreate(81807868C78141BFB2E93275AC3ABB39)3

4 Create button Button1 If press this button object objs position addrarr˓Vector3(101)

5

6 var Button1= guicreateButton(translate Rect(100 200 80 50) function() 7

8 objtranslate(Vector3(1 0 1)))9

10

11

12 Create a button named Button2 Pressing on this button will move objectobjrarr˓position by a vector of (101)

13

14 var Button2= guicreateButton(setPosition Rect(100 300 80 50) function() 15

16 objsetPosition(Vector3(1 0 1)))

34 BaseObject 35

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 39: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

BaseObjectyaw

Rotate an object a specified degree around the Y-axis (clockwise)

Parameters

Name Descriptiondegree float rotation degree

Example

1 Create an object namedobjand rotate objectobja 45 degree angle around the Y-rarr˓axis(clockwise)

2

3 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)4 objyaw(45)

ScriptObject

Overview

Control all the scripts associated with objects script may implements two object interface Start andor Update

Name Description Returns ParametersStart called before any object updates just once none Start(script)Update called per frame none Update(script)

Start

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11

36 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 40: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

Update

Parameters

None

Exmaple

1 Create a Start function this function defines the initial speed of an object2 to a random float between 1 to 83 AutoRtate = 4 speed 05 objOption null6 function Start() thisspeed = utilrandomFloat(1 8)7

8 Create an Update function9 this function rotates the object a random degree along the Y-Axis every frame

10 function Update() thisobjOptionyaw(thisspeed) 11 12

13 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088 Vector3(25 0 0))14

15 var script = objaddScript(AutoRtaterotation)16

17 scriptobjOption = obj

util

Overview

Common functions

36 util 37

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 41: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

Name Description Re-turns

Parameters

addE-ventLis-tener

Add an event none utiladdEventListener(eventType

callback)clearAl-lEvents

Clear all events none utilclearAllEvents()

clearAll-Timers

Clear all timers and unnecessary Timer IDs none utilclearAllTimers()

clearInter-val

Clear the timer generated by setInterval needtimerID

none utilrdquoutilclearInterval(intervalID)ldquo

clearScrip-tObjects

Clear all objects created by scripts includingobjects and GUIs

none utilclearScriptObjects()

clearTime-out

Clear timers generated by setTimeout TheTimerrsquos ID needs to be provided

none utilclearTimeout(timeoutID)

download-Texture

Download a texture from an external URL none utildownloadTexture(json

download-Textures

Download multiple textures form an externalURL

none utildownloadTextures(json

random-Color

Generate a random RGBA type color RGBA utilrandomColor()

random-Float

Generate a random float number between twospecified values

float utilrandomFloat(ab)

randomInt Generate a random integer between twospecified values

int utilrandomInt(ab)

ran-domVec-tor3

Generate a random Vector 3 Vec-tor3

utilrandomVector3(randius)

setInterval Call a function after a defined time Int utilsetInterval(callbacktickTime)

setRender-Callback

Call a callback function every frame none utilsetRenderCallback(callback)

setTimeout call a callback function when timeout returntimer ID

int utilsetTimeout(callbackdelayTime)

utiladdEventListener

Add event listener

Parameters

Name Descriptionevent-Type

string event type egclickdbclickmouseupmousedownmousemovedragdragstartdragendkeydownkeyupresize

callback function callback function

38 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 42: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

Example

1 Add a listener to the eventclick this will create an object on a mouse click2 utiladdEventListener(click function(event) objectcreate(

rarr˓FF2A3E364B1E4B928891E05A9279C7A7 eventpos))

utilclearAllEvents

Parameters

None

Example

1 Clear all the events within the scene2 utilclearAllEvents()

utilclearAllTimers

Parameters

None

Example

1 Clear all the timers within the scene2 utilclearAllTimers()

utilclearInterval

Remove timer created by setInterval

Parameters

Name DescriptiontimerID number timer ID

36 util 39

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 43: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

Example

1 remove timer with ID 22 utilclearInterval(2)

utilclearScriptObjects

Parameters

None

Example

1 Clear all the script associate with object2 utilclearScriptObjects()

utildownloadTexture

Download texture from an external URL

Parameters

Table 31 header Name Description widths 5 15

json json message including url callback function

Example

1 Create a cube download a texture from url2 if the download is successful set the cubes texture to earMat and earMat to be

rarr˓earths material3 (the texture is provided by uinnova details on creating and using custom texture 4 please contact uinnova inc) 5

6 var earth = objectcreate(B723E9E1B279467EBC9433D30D35F683 Vec3(0 5 0))7

8 utildownloadTexture(9

10 url httpimg1juimgcom141102330507-141102164G965jpg 11

12 success function(texture) 13

40 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 44: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

14 var earthMat = utilcreateMaterial(texture)15

16 earthsetMaterial(earthMat) )

utilclearTimeout

Remove timer created by setTimeout

Parameters

Name DescriptiontimerID number timer ID

Example

1 remove timer with ID 22 utilclearTimeout(2)

utildownloadTextures

Download multiple texture from an external URL

Parameters

Table 32 header Name Description widths 5 15

json json message including url callback function

Example

1 Download textures from an external URL if the download issuccessful 2 set ldquoEarthjpgrdquo to earthMat and earthMat to be earths material3 set texture ldquoMoonjpgrdquo to moonMat and MoonMat to be moons material4 (the texture is provided by uinnova details on creating and using custom texture 5 please contact uinnova inc) 6

7 var earth = objectcreate(9f5681fe55674ce9b617f9fa23d9729b Vec3(0 5 0))8

9 var moon = objectcreate(9f5681fe55674ce9b617f9fa23d9729bVec3(0 7 0)Vec3(02rarr˓02 02))

10

36 util 41

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 45: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

11 utildownloadTextures(12

13 url httpwww3dmomodacommmdclientscriptexamplesdemosearth_moonzip14

15 success function(textures) 16

17 var earthMat = utilcreateMaterial(textures[Earthjpg])18

19 earthsetMaterial(earthMat)20

21 var moonMat = utilcreateMaterial(textures[Moonjpg])22

23 moonsetMaterial(moonMat))

utilrandomColor

Generate a random RGHA color

Parameters

None

Example

1 Generate a random RGBA type color and apply it as the color of the objectobj2 objsetColor(utilrandomColor())

utilrandomFloat

Generate a random float number between two specified values

Parameters

Name Descriptiona float upper bound valueb float lower bound value

Example

1 Generate a random number between 1(included) and 3(included)2 var d = utilrandomFloat(1030)

42 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 46: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

utilrandomInt

Generate a random integer number between two specified values

Parameters

Name Descriptiona int upper bound valueb in lower bound value

Example

1 Generate a random number between 1(included) and 10(included)2 var d = utilrandomInt(110)

utilrandomVector3

Generate a random Vector3

Parameters

Name Descriptionradius number vector radius

Example

1 Generate a random vector between ([1 -1] 1 -1])2 var d = utilrandomVector3(1)

utilsetRenderCallback

Create callback function run every frame

Parameters

Name Descriptioncallback function

36 util 43

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 47: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

Example

1 Create an object and add a gravitational weight of 3KG every frame2 utilsetRenderCallback(function()3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 objaddGravity(3)7

8 )

utilsetTimeout

Create a callback function with timeout return the timerrsquos ID

Parameters

Name Descriptioncallback functiontimeout number

Example

1 Printtime overwhen timer is equal to 32 var a=utilsetTimeout(function() print(time over) 3000)

input

Overview

Inputs from keyboards and mouses

Name Description Re-turns

Parameters

getKey Get statue of holding downappointed ke

boolen getKey(keyCode)

getKeyDown Get statue of pressing appointed key boolen getKeyDown(keyCode)getKeyUp Get statue of releasing appointed key boolen getKeyUp(keyCode)getMouseButton Get statue of pressing a mouse

buttonboolen getMouseButton(MouseCode)

getMouseButton-Down

Get statue of pressing a mousebutton

boolen getMouseButtonDown(MouseCode)

getMouseButtonUp Get statue of releasing the mousebutton

boolen getMouseButtonUp(MouseCode)

44 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 48: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

inputgetKey

Check if user press and holds specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

1 Player = 2 obj null3 function Update() 4 if user holds down key A rotate obj -5 degree around its Y axis5 if (inputgetKey(KeyCodeA)) thisobjyaw(-5)6

7 if user holds down key D rotate obj 5 degree around its Y axis8 if (inputgetKey(KeyCodeD)) thisobjyaw(5)9

10 if user holds down key R move obj to Vector3(303) in 2 seconds11 if (inputgetKeyDown(KeyCodeR)) thisobjmoveTo(Vector3(303)2)12

13

14 if user holds down key R move obj to Vector3(-30-3) in 2 second15 if (inputgetKeyUp(KeyCodeR)) thisobjmoveTo(Vector3(-30-3)2)16

17

18 if user clicks the left mouse button print Pressed left click19 if (inputgetMouseButtonDown(0)) print(Pressed left click )20

21 if user clicks the right mouse buttonprintPressed right click22 if (inputgetMouseButtonDown(1)) print(Pressed right click )23 24 25

26 var obj = objectcreate(0bcba8ca78734b64a3dae3eb699a913c)27

28 var script = objaddScript(Player)29

30 scriptobj = obj31

32 cameraenableMove = falseinputgetKeyDown(keyCode)

inputgetKeyDown

Check if user press specific key

37 input 45

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 49: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetKeyUp

Check if user release specific key

Parameters

Name DescriptionkeyCode KeyCode raw key code for keyboard events

Example

See getKey

inputgetMouseButton

Check if user click and hold mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

46 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 50: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

inputgetMouseButtonDown

Check if user click mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

inputgetMouseButtonUp

Check if user release mouse button

Parameters

Name DescriptionMouseCode int raw key code for mouse events

Example

See getKey

console

Overview

Manage control panel

Name Description Returns Parametersclear Clear text content none consoleclear()log Print message on console platform none consolelog(obj)show Hide or show console platform none consoleshow(show)

consoleclear

Parameters

None

38 console 47

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 51: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

Example

1 Clear all text content on the console platform2 Clear all text content on the control panel3

4 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)5

6 consolelog(obj)7

8 consoleclear()

consolelog

Print output on Control Panel

Parameters

Name Descriptionobj object

Example

1 Print the scale of the objectobjon the control panel2 var obj = objectcreate(AB052B5B646E4A48B9C045096FF9B088)3 consolelog(objgetScale())

consoleshow

Show or hide Control Panel

Parameters

Name Descriptionshow boolean

Example

1 print(showhide control panel)2

3 guicreateButton(Platform shows Rect(100 100 200 50) function() consolerarr˓show(true))

48 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 52: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

4

5 guicreateButton(Close platform Rect(100 200 200 50) function() consolerarr˓show(false))

Data Interface

Summary

Momoda data infterface connect Momoda to third party systems it can be used to scene initialization push alarmcontrol objects such as create move transform remove etc in realtime

There are three catelogies in Momoda data infterface namely

bull I Interface

bull M Interface

bull R Interface

I Interface

I (short for Initialize) interface is used for scene initialization Data push through I Interface will loaded by Momodaclient automatically

Usage

url httpYour Momoda Server IP8080goodssavehttp method GET or POSTparameters

bull gsid scene IDbull goid object IDbull gprops object initialization data

HTTP GET

bull request

1 http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1ampgrarr˓props=Initialized DataInitialized Data

Note request will push init data in JSON data ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 in scene20170320095733039126770

39 Data Interface 49

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 53: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodssavegsid=20170320095733039126770ampgoid=cabinet1amprarr˓gprops=Initialized DataInitialized Data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

50 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 54: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080goodssave

ndash POST message

1 2

3 gsid201703200957330391267704

5 goidcabinet16

7 gpropsInitialized DataInitialized Data8

9

Note request will push init data in JSON format ldquoInitialized DatardquordquoInitialized Datardquo to object cabinet1 inscene 20170320095733039126770

bull server response

bull sample request in htmljavascript

39 Data Interface 51

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 55: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080goodssave18

19 20

21 gsid2017032009573303912677022

23 goidcabinet124

25 gpropsInitialized DataInitialized Data 26

27 function(data) alert(Data + data)28

29 )30

31 )32

33 )34

35 ltscriptgt36

37 ltheadgt38

39 ltbodygt40

41 ltbuttongtSubmit dataltbuttongt42

43 ltbodygt44

45 lthtmlgt

M Interface

use thersquoM interfacersquoto push realtime data to the scene typical user case could be showing realtime information uponsensor objects For instance shows realtime alarms of firegas sensor realtime location of cargo current reading oftemperature etc

52 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 56: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

Warning Data pushed to M Interface is stored in Momoda serverrsquos message queue and there are no messagereplay for the queue so if a Momoda client is newly connected to server it only shows the current messagedatain queue

Usage

url httpYour Momoda Server IP8080dataputdatahttp method GET or POSTparameters JSON Message

HTTP GET

bull request

1 http1270018080dataputdataparam=20170320095733039126770cabinet1 rarr˓monitoring datamonitoring data

Note request will push init data in JSON data ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 in scene20170320095733039126770

bull server response

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

39 Data Interface 53

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 57: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

15 $(button)click(function()16

17 $get(http1270018080dataputdataparam=20170320095733039126770rarr˓cabinet1 monitoring datamonitoring data

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

HTTP POST

bull request

ndash url httpYour Momoda Server IP8080dataputdata

ndash POST message

1 2

3 param20170320095733039126770cabinet1monitoring datararr˓monitoring data

4

Note request will push init data in JSON format ldquomonitoring datardquordquomonitoring datardquo to object cabinet1 inscene 20170320095733039126770

bull sample request

54 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 58: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $post(http1270018080dataputdata18

19 20

21 param20170320095733039126770cabinet1monitoring datamonitoring datararr˓

22

23 function(data) alert(Data + data)24

25 )26

27 )28

29 )30

31 ltscriptgt32

33 ltheadgt34

35 ltbodygt36

37 ltbuttongtSubmit dataltbuttongt

39 Data Interface 55

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 59: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

38

39 ltbodygt40

41 lthtmlgt

R Interface

Remove any initialization data in a scene

Usage

url httpYour Momoda Server IP8080goodsremovehttp method GETparameters

bull sid scene ID

HTTP GET

bull request

1 http1270018080goodsremovesid=20170320095733039126770ampoid=cabinet1

Note request will remove all initialization data from object cabinet1 in scene 20170320095733039126770

bull server response

56 Chapter 3 API Referance

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 60: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

bull sample request in htmljavascript

1 ltDOCTYPE htmlgt2

3 lthtmlgt4

5 ltheadgt6

7 ltscript src=jquery-1111minjsgt8

9 ltscriptgt10

11 ltscriptgt12

13 $(document)ready(function()14

15 $(button)click(function()16

17 $get(http1270018080goodsremovesid=20170320095733039126770amprarr˓oid=cabinet1

18

19 function(data) alert(Data + data)20

21 )22

23 )24

25 )26

27 ltscriptgt28

29 ltheadgt30

31 ltbodygt

39 Data Interface 57

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 61: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

32

33 ltbuttongtSubmit dataltbuttongt34

35 ltbodygt36

37 lthtmlgt

58 Chapter 3 API Referance

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 62: uBudiler API 2.0 Documentation - readthedocs.org

CHAPTER 4

Try API Online

You can try uBuilder API online by click httpuinnovacom9010mmdapi

Warning The online API debugger supports Internet Explorer 11 ONLY

59

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 63: uBudiler API 2.0 Documentation - readthedocs.org

uBudiler API 20 Documentation Release 01

60 Chapter 4 Try API Online

CHAPTER 5

Deploy

Step 1 Click ont the button shown below to download scene and API code to your PC

Step 2 Decompress the zip file

Step 3 Run startbat

Step 4 Apply for license if needed

61

uBudiler API 20 Documentation Release 01

62 Chapter 5 Deploy

CHAPTER 6

Q amp A

bull Does uBuilder API using the same syntaxlibrary as Javascript

uBuilder API use javascript-like syntax which is NOT exactly the same as javascript For instance there is nodocument object or windows object in uBuilder API

bull How to load my 3D scene into API developing UI

In uBuilder API online development page input your scene ID then click ldquoNEWrdquo button

bull How to associate my API scripts to existing scene

Locate your scene in Momoda click [Configure] then paste script source code into popup text box

bull Why I cannot play animation on custom object

Object animation is created during the model process so object do not support play animation function if it do notassociate any animation during the model process

bull Why browser do not response during API debugging

uBuilder API debugging requires 3D scene which is resource consuming Open more than one scenes at the samemay slow the computer or even crash your browser it is recommended that simultaneously opened 3D scene is lessthan 3

bull Why some object do not response to click event

While creating the scene make sure to ldquoselectablerdquo checkbox is in checked status in object property settings

63

uBudiler API 20 Documentation Release 01

64 Chapter 6 Q amp A

CHAPTER 7

Revise History

2017-4-1API20 Release

bull Total 72 API20 functionsbull 99 parameters in those functionsbull Offline version supports data initial interface as well as realtime alarm interfacebull Support api call to data interface Developer can save custom scene settingsbull Bug fixes

65

  • Concept Guide
    • model and Scene
    • Model Library
    • Scene Levels
    • API Developement
      • Overview
      • API Referance
        • camera
        • object
        • gui
        • BaseObject
        • ScriptObject
        • util
        • input
        • console
        • Data Interface
          • Try API Online
          • Deploy
          • Q amp A
          • Revise History
Page 64: uBudiler API 2.0 Documentation - readthedocs.org
Page 65: uBudiler API 2.0 Documentation - readthedocs.org
Page 66: uBudiler API 2.0 Documentation - readthedocs.org
Page 67: uBudiler API 2.0 Documentation - readthedocs.org
Page 68: uBudiler API 2.0 Documentation - readthedocs.org

Top Related