Qmaze Rules
Revision as of 10:02, 3 April 2019 by Nick Bannink (talk | contribs) (Created page with "Qmaze rules communication explenation (functions) <br> Use the following script to catch the x3d commands given in the qmaze builder rules section. <br> The rules must be writ...")
Qmaze rules communication explenation (functions)
Use the following script to catch the x3d commands given in the qmaze builder rules section.
The rules must be written as:
x3d(object).action = value
action: what action needs to be executed? e.g. changeColor.
object: what object is the subject of change?
value: what value needs to be given to the function?
$(document).ready(function(){ $(qmaze.events).on(qmaze.events.CONSTRAINT, function(e, constraints) { if (typeof constraints !== "undefined") { var res = constraints.split(";"); for (var i = 0; i < res.length; i++) { var regex = new RegExp(/(x3d\((.*?)\)\.(\w+)(\s+)?\=['"]?(.*)['"]?)/gi); while (result = regex.exec(res[i])) { var object = result[2], method = result[3], value = unescape(result[5]).replace('\, ); console.log('qmaze:'+method+'='+value); eval(method + '="' + value + '";'); window["my"+method](object, value); } } } }); var lazyLoadingConstraints = $('input[id$="hfLazyLoading"]').val(); $(qmaze.events).trigger(qmaze.events.CONSTRAINT, [lazyLoadingConstraints]); });
In your output script you need to declare all the functions called by the qmaze rules.
The functions always need to begin with ' my ' as seen below.
function mysetColor(obj, val) { obj: is the object in the qmaze rules val: is the value given in the qmaze rules the following example is for looking up an object in the scene (v3d) var obj = app.scene.getObjectByName(obj); }