diff --git a/qubeenee.blend b/qubeenee.blend index 94e4c00..869fbd8 100644 Binary files a/qubeenee.blend and b/qubeenee.blend differ diff --git a/visual_logic.js b/visual_logic.js index 33f3e5b..e0e89b4 100644 --- a/visual_logic.js +++ b/visual_logic.js @@ -1,6 +1,6 @@ /** * Generated by Verge3D Puzzles v.2.12.5 - * Sat Jun 08 2019 17:55:33 GMT+0200 (Mitteleuropäische Sommerzeit) + * Sat Jun 08 2019 21:51:22 GMT+0200 (Mitteleuropäische Sommerzeit) * Do not edit this file - your changes may get overridden when Puzzles are saved. * Refer to https://www.soft8soft.com/docs/manual/en/introduction/Using-JavaScript.html * for information on how to add your own JavaScript to Verge3D apps. @@ -91,9 +91,7 @@ PL.execInitPuzzles = function() { preloaderEndCb: function() {}, } } - var cinitx, cinity, cinitz; - - + // utility functions envoked by the HTML puzzles function getElements(ids, isParent) { var elems = []; @@ -156,9 +154,6 @@ _initGlob.output.initOptions.useCompAssets = false; _initGlob.output.initOptions.useFullscreen = false; setHTMLElemStyle('backgroundColor', 'rgb(127,127,127)', ["BODY"], false); -cinitx = 0; -cinity = 0; -cinitz = 0; return _initGlob.output; } @@ -170,7 +165,7 @@ initOptions = initOptions || {}; if ('fadeAnnotations' in initOptions) { _pGlob.fadeAnnotations = initOptions.fadeAnnotations; } -var distZ, r, g, b, distY, dragging, distX, inboundStepper, r_, maxDist, bitstate, recordqubitstate, recordbitstate, g_, stepY, hue, b_, sat, value; +var distZ, R, G, B, hue, dragging, distY, distX, inboundStepper, r_, maxDist, recordqubitstate, recordbitstate, bitstate, stepY, g_, sat, b_, value; // utility function envoked by almost all V3D-specific puzzles @@ -281,35 +276,6 @@ function swizzleVec3(vec, isScale) { } -// getObjTransform puzzle -function getObjTransform(objName, mode, coord) { - if (!objName) - return; - var obj = getObjectByName(objName); - if (!obj) - return; - if (mode == "rotation") - return swizzleValueSign(coord, obj[mode][coord] * 180/Math.PI); - else if (mode == 'position') - return swizzleValueSign(coord, obj[mode][coord]); - else - return obj[mode][coord]; -} - - - -// ssao puzzle -function ssao(radius, aoClamp, lumInfluence) { - appInstance.enablePostprocessing([{ - type: 'ssao', - radius: radius, - aoClamp: aoClamp, - lumInfluence: lumInfluence - }]); -} - - - function intersectPlaneCSS(plane, cssX, cssY, dest) { var coords = _pGlob.vec2Tmp; var rc = _pGlob.raycasterTmp; @@ -394,6 +360,23 @@ function dragMove(objNames, mode, blockId, parentDragOverBlockId) { +// getObjTransform puzzle +function getObjTransform(objName, mode, coord) { + if (!objName) + return; + var obj = getObjectByName(objName); + if (!obj) + return; + if (mode == "rotation") + return swizzleValueSign(coord, obj[mode][coord] * 180/Math.PI); + else if (mode == 'position') + return swizzleValueSign(coord, obj[mode][coord]); + else + return obj[mode][coord]; +} + + + // distanceBetweenObjects puzzle function getDistanceBetweenObjects(objName1, objName2) { if (!objName1 || !objName2) @@ -471,17 +454,6 @@ function applyObjLocalTransform(objNames, mode, x, y, z) { -// callJSFunction puzzle -function getJSFunction(funcName) { - var jsFunc = appInstance.ExternalInterface[funcName]; - if (typeof jsFunc == "function") - return jsFunc; - else - return function() {}; -} - - - // utility function used by the whenClicked, whenHovered and whenDraggedOver puzzles function initObjectPicking(callback, eventType, mouseDownUseTouchStart) { @@ -733,11 +705,16 @@ function registerOnDrag(objNames, callback_start, callback_move, callback_drop, } -function rs() { - console.log('I\'m here!!!'); - getJSFunction('setDivWidth')(String(getDistanceBetweenObjects("div-left", "div-right"))); + +// ssao puzzle +function ssao(radius, aoClamp, lumInfluence) { + appInstance.enablePostprocessing([{ + type: 'ssao', + radius: radius, + aoClamp: aoClamp, + lumInfluence: lumInfluence + }]); } -appInstance.ExternalInterface["rs"] = rs; @@ -809,6 +786,17 @@ function registerOnClick(objNames, cbDo, cbIfMissedDo) { +// callJSFunction puzzle +function getJSFunction(funcName) { + var jsFunc = appInstance.ExternalInterface[funcName]; + if (typeof jsFunc == "function") + return jsFunc; + else + return function() {}; +} + + + // setInterval puzzle function registerInterval(timeout, callback) { window.setInterval(callback, 1000 * timeout); @@ -816,60 +804,6 @@ function registerInterval(timeout, callback) { -function matGetColors(matName) { - - var mat = v3d.SceneUtils.getMaterialByName(appInstance, matName); - if (!mat) return []; - - if (mat.isMeshNodeMaterial) - return Object.keys(mat.nodeRGBMap); - else if (mat.isMeshStandardMaterial) - return ['color', 'emissive']; - else - return [] -} - - -// setMaterialColor puzzle -function setMaterialColor(matName, colName, r, g, b) { - var colors = matGetColors(matName); - - if (colors.indexOf(colName) < 0) return; - - var mats = v3d.SceneUtils.getMaterialsByName(appInstance, matName); - - for (var i = 0; i < mats.length; i++) { - var mat = mats[i]; - - if (mat.isMeshNodeMaterial) { - var rgbIdx = mat.nodeRGBMap[colName]; - mat.nodeRGB[rgbIdx].x = r; - mat.nodeRGB[rgbIdx].y = g; - mat.nodeRGB[rgbIdx].z = b; - } else { - mat[colName].r = r; - mat[colName].g = g; - mat[colName].b = b; - } - mat.needsUpdate = true; - - if (mat === appInstance.worldMaterial) - appInstance.updateEnvironment(mat); - } -} - - -function setRGB(r, g, b) { - setMaterialColor("transparent", "Principled BSDF Color", r, g, b); - r_ = r; - g_ = g; - b_ = b; - printStates(); -} -appInstance.ExternalInterface["setRGB"] = setRGB; - - - // getEventProperty puzzle function getEventProperty(prop, event) { if (typeof event != "undefined") { @@ -935,6 +869,60 @@ function eventHTMLElem(eventType, ids, isParent, callback) { +function matGetColors(matName) { + + var mat = v3d.SceneUtils.getMaterialByName(appInstance, matName); + if (!mat) return []; + + if (mat.isMeshNodeMaterial) + return Object.keys(mat.nodeRGBMap); + else if (mat.isMeshStandardMaterial) + return ['color', 'emissive']; + else + return [] +} + + +// setMaterialColor puzzle +function setMaterialColor(matName, colName, r, g, b) { + var colors = matGetColors(matName); + + if (colors.indexOf(colName) < 0) return; + + var mats = v3d.SceneUtils.getMaterialsByName(appInstance, matName); + + for (var i = 0; i < mats.length; i++) { + var mat = mats[i]; + + if (mat.isMeshNodeMaterial) { + var rgbIdx = mat.nodeRGBMap[colName]; + mat.nodeRGB[rgbIdx].x = r; + mat.nodeRGB[rgbIdx].y = g; + mat.nodeRGB[rgbIdx].z = b; + } else { + mat[colName].r = r; + mat[colName].g = g; + mat[colName].b = b; + } + mat.needsUpdate = true; + + if (mat === appInstance.worldMaterial) + appInstance.updateEnvironment(mat); + } +} + + +function setRGB(R, G, B) { + setMaterialColor("transparent", "Principled BSDF Color", R, G, B); + r_ = R; + g_ = G; + b_ = B; + printStates(); +} +appInstance.ExternalInterface["setRGB"] = setRGB; + + + // toFixedPoint puzzle function toNumber(num, prec) { prec = Math.pow(10, prec); @@ -949,17 +937,17 @@ function printStates() { console.log(['Bit [',bitstate,'] Qubit: [',toNumber(r_, 3),'] [',toNumber(g_, 3),'] [',toNumber(b_, 3),']'].join('')); } +/** + * Describe this function... + */ +function setHSV() { + hue = Math.atan(Math.min(Math.max(distX / (distY + 1), Math.PI * -2), Math.PI * 2) + Math.PI * 2) / Math.PI * 180; + hue = hue / (Math.PI * 4); + sat = Math.sqrt(distX * distX + distY * distY) / maxDist; + value = ((distZ - maxDist) / (2 * maxDist)) * -1; + getJSFunction('HSVtoRGB')(hue, sat, value); +} -distZ = getObjTransform("qubit", "position", "y") - getObjTransform("qubit_controller", "position", "y"); -distY = getObjTransform("qubit", "position", "z") - getObjTransform("qubit_controller", "position", "z"); -distX = getObjTransform("qubit", "position", "x") - getObjTransform("qubit_controller", "position", "x"); -maxDist = 2.3; -stepY = 0.1; -bitstate = 0; -r_ = 0; -g_ = 0; -b_ = 0; -ssao(1, 0.01, 0.3); registerOnDrag(["GROUP", "qubit_grp"], function() { dragging = true; @@ -975,25 +963,24 @@ registerOnDrag(["GROUP", "qubit_grp"], function() { } distZ = getObjTransform("qubit", "position", "y") - getObjTransform("qubit_controller", "position", "y"); distX = getObjTransform("qubit", "position", "x") - getObjTransform("qubit_controller", "position", "x"); - hue = Math.atan(Math.abs(distY / distX)) / Math.PI * 180; - sat = Math.sqrt(distX * distX + distY * distY) / maxDist; - value = ((distZ - maxDist) / (2 * maxDist)) * -1; - getJSFunction('HSVtoRGB')(hue / 180, sat, value); + setHSV(); }, function() { dragging = false; }, "x7;j`9Tr6$fIW]tXfLwm"); -registerOnClick("bit", function() { - if (getObjectMaterial("bit") == "white") { - assignMat("bit", "black"); - bitstate = 0; - } else { - assignMat("bit", "white"); - bitstate = 1; - } - printStates(); -}, function() {}); +distZ = getObjTransform("qubit", "position", "y") - getObjTransform("qubit_controller", "position", "y"); +distY = getObjTransform("qubit", "position", "z") - getObjTransform("qubit_controller", "position", "z"); +distX = getObjTransform("qubit", "position", "x") - getObjTransform("qubit_controller", "position", "x"); +maxDist = 2.3; +stepY = 0.1; +bitstate = 0; +r_ = 0.5; +g_ = 0.5; +b_ = 0.5; +ssao(1, 0.01, 0.3); + +distX / distY; registerOnClick("recordqubit", function() { if (getObjectMaterial("recordqubit") == "on") { @@ -1005,15 +992,7 @@ registerOnClick("recordqubit", function() { } }, function() {}); -registerOnClick("recordbit", function() { - if (getObjectMaterial("recordbit") == "on") { - assignMat("recordbit", "black"); - recordbitstate = 0; - } else { - assignMat("recordbit", "on"); - recordbitstate = 1; - } -}, function() {}); +2 / 10; registerInterval(1, function() { if (recordbitstate == 1) { @@ -1024,9 +1003,21 @@ registerInterval(1, function() { } }); -printStates(); +Math.atan(45) / Math.PI * 180; -printStates(); +console.log(distX); +console.log(distY); + +registerOnClick("bit", function() { + if (getObjectMaterial("bit") == "white") { + assignMat("bit", "black"); + bitstate = 0; + } else { + assignMat("bit", "white"); + bitstate = 1; + } + printStates(); +}, function() {}); eventHTMLElem('wheel', ["DOCUMENT"], false, function(event) { if (getEventProperty('deltaY', event) < 0) { @@ -1041,12 +1032,29 @@ eventHTMLElem('wheel', ["DOCUMENT"], false, function(event) { } } distY = getObjTransform("qubit", "position", "z") - getObjTransform("qubit_controller", "position", "z"); - hue = Math.atan(Math.abs(distY / distX)) / Math.PI * 180; - sat = Math.sqrt(distX * distX + distY * distY) / maxDist; - value = ((distZ - maxDist) / (2 * maxDist)) * -1; - getJSFunction('HSVtoRGB')(hue / 180, sat, value); + setHSV(); }); +Math.abs(4); + +8; + +registerOnClick("recordbit", function() { + if (getObjectMaterial("recordbit") == "on") { + assignMat("recordbit", "black"); + recordbitstate = 0; + } else { + assignMat("recordbit", "on"); + recordbitstate = 1; + } +}, function() {}); + +Math.sqrt(4); + +hue = Math.acos(distX / Math.sqrt(distX * distX + distY * distY + distZ * distZ)) / Math.PI * 180; + +hue = (Math.atan(Math.abs(distX / distY)) / Math.PI * 180) / 45 - 1; + } // end of PL.init function if (window.v3dApp) { diff --git a/visual_logic.xml b/visual_logic.xml index 71295ad..259bb0d 100644 --- a/visual_logic.xml +++ b/visual_logic.xml @@ -1,10 +1,5 @@ - - - cinitx - cinity - cinitz - + FALSE FALSE @@ -23,250 +18,31 @@ - - - cinitx - - - cinity - - - cinitz - - - - - - - + distZ - r - g - b - distY + R + G + B + hue dragging + distY distX inboundStepper r_ maxDist - bitstate recordqubitstate recordbitstate - g_ + bitstate stepY - hue - b_ + g_ sat + b_ value - - distZ - - - MINUS - - - 2 - - - position - z - - - qubit - - - - - - - 2 - - - position - z - - - qubit_controller - - - - - - - - - distY - - - MINUS - - - 2 - - - position - y - - - qubit - - - - - - - 2 - - - position - y - - - qubit_controller - - - - - - - - - distX - - - MINUS - - - 2 - - - position - x - - - qubit - - - - - - - 2 - - - position - x - - - qubit_controller - - - - - - - - - maxDist - - - 2.3 - - - - - stepY - - - 0.1 - - - - - bitstate - - - 0 - - - - - r_ - - - 0 - - - - - g_ - - - 0 - - - - - b_ - - - 0 - - - - - - - 1 - - - - - 0.01 - - - - - 0.3 - - - - - - - - - - - - - - - - - - - - - - - TRUE - - - lochkarte - - - - - div-left - - - - + @@ -532,233 +308,8 @@ - - hue - - - ATAN - - - 45 - - - ABS - - - 4 - - - DIVIDE - - - 2 - - - distY - - - - - 2 - - - distX - - - - - - - - - - - sat - - - DIVIDE - - - 2 - - - ROOT - - - 4 - - - ADD - - - 2 - - - MULTIPLY - - - 2 - - - distX - - - - - 2 - - - distX - - - - - - - 2 - - - MULTIPLY - - - 2 - - - distY - - - - - 2 - - - distY - - - - - - - - - - - 2 - - - maxDist - - - - - - - value - - - MULTIPLY - - - 2 - - - DIVIDE - - - 2 - - - MINUS - - - 2 - - - distZ - - - - - 2 - - - maxDist - - - - - - - 2 - - - MULTIPLY - - - 2 - - - - - 2 - - - maxDist - - - - - - - - - -1 - - - - - - - - - - - - HSVtoRGB - - - DIVIDE - - - 2 - - - hue - - - - - 180 - - - - - - - sat - - - - - value - - - - - - - - + + @@ -786,46 +337,423 @@ - - rs - - - - - I'm here!!! + + distZ + + + MINUS + + + 2 + + position + z + + + qubit + + + + + + + 2 + + + position + z + + + qubit_controller + + + + + + + + + distY + + + MINUS + + + 2 + + + position + y + + + qubit + + + + + + + 2 + + + position + y + + + qubit_controller + + + + + - - - - - setDivWidth - - - - - - - - div-left + + distX + + + MINUS + + + 2 + + + position + x + + + qubit - - - div-right + + + + + 2 + + + position + x + + + qubit_controller + + + maxDist + + + 2.3 + + + + + stepY + + + 0.1 + + + + + bitstate + + + 0 + + + + + r_ + + + 0.5 + + + + + g_ + + + 0.5 + + + + + b_ + + + 0.5 + + + + + + + 1 + + + + + 0.01 + + + + + 0.3 + + + + + + + + + + + + + + + + + + + + + + + DIVIDE + + + 2 + + + distX + + + + + 2 + + + distY + + + + + + + + recordqubit + + + + + + + + EQ + + + + + recordqubit + + + + + + + on + + + + + + + + + black + + + + + recordqubit + + + + + recordqubitstate + + + 0 + + + + + + + + + + + on + + + + + recordqubit + + + + + recordqubitstate + + + 1 + + + + + + + + + + + DIVIDE + + + 2 + + + + + 10 + + + + + + + 1 + + + + + + + EQ + + + recordbitstate + + + + + 1 + + + + + + + + + + addBit + + + bitstate + + + + + + + + + EQ + + + recordqubitstate + + + + + 1 + + + + + + + + + + + + addQubit + + + r_ + + + + + g_ + + + + + b_ + + + + - + + ATAN + + + 45 + + + + + + + I'm here!!! + + + distX + + + + + + + I'm here!!! + + + distY + + + + + + @@ -910,333 +838,7 @@ - - - - - recordqubit - - - - - - - - EQ - - - - - recordqubit - - - - - - - on - - - - - - - - - black - - - - - recordqubit - - - - - recordqubitstate - - - 0 - - - - - - - - - - - on - - - - - recordqubit - - - - - recordqubitstate - - - 1 - - - - - - - - - - - - - - recordbit - - - - - - - - EQ - - - - - recordbit - - - - - - - on - - - - - - - - - black - - - - - recordbit - - - - - recordbitstate - - - 0 - - - - - - - - - - - on - - - - - recordbit - - - - - recordbitstate - - - 1 - - - - - - - - - - - - - 1 - - - - - - - EQ - - - recordbitstate - - - - - 1 - - - - - - - - - - addBit - - - bitstate - - - - - - - - - EQ - - - recordqubitstate - - - - - 1 - - - - - - - - - - - - addQubit - - - r_ - - - - - g_ - - - - - b_ - - - - - - - - - - - - - - - - - - - - - - setRGB - - - Principled BSDF Color - - - transparent - - - - - 0.5 - - - r - - - - - 0.5 - - - g - - - - - 0.5 - - - b - - - - - r_ - - - r - - - - - g_ - - - g - - - - - b_ - - - b - - - - - - - - - - - - - - - - - + wheel FALSE @@ -1494,229 +1096,89 @@ - - hue + + + + + + + + + + + ABS + + + 4 + + + + + + + + + + setRGB + + + Principled BSDF Color + + + transparent + + + + + 0.5 + + + R + + + + + 0.5 + + + G + + + + + 0.5 + + + B + + + + + r_ + + + R + + + + + g_ - - ATAN - - - 45 - - - ABS - - - 4 - - - DIVIDE - - - 2 - - - distY - - - - - 2 - - - distX - - - - - - + + G - - sat + + b_ - - DIVIDE - - - 2 - - - ROOT - - - 4 - - - ADD - - - 2 - - - MULTIPLY - - - 2 - - - distX - - - - - 2 - - - distX - - - - - - - 2 - - - MULTIPLY - - - 2 - - - distY - - - - - 2 - - - distY - - - - - - - - - - - 2 - - - maxDist - - + + B - - value - - - MULTIPLY - - - 2 - - - DIVIDE - - - 2 - - - MINUS - - - 2 - - - distZ - - - - - 2 - - - maxDist - - - - - - - 2 - - - MULTIPLY - - - 2 - - - - - 2 - - - maxDist - - - - - - - - - -1 - - - - - - - - - - - - HSVtoRGB - - - DIVIDE - - - 2 - - - hue - - - - - 180 - - - - - - - sat - - - - - value - - - - + + @@ -1728,7 +1190,98 @@ - + + 8 + + + + + + recordbit + + + + + + + + EQ + + + + + recordbit + + + + + + + on + + + + + + + + + black + + + + + recordbit + + + + + recordbitstate + + + 0 + + + + + + + + + + + on + + + + + recordbit + + + + + recordbitstate + + + 1 + + + + + + + + + + + ROOT + + + 4 + + + + printStates Describe this function... @@ -1816,6 +1369,526 @@ + + setHSV + Describe this function... + + + hue + + + ATAN + + + 45 + + + ADD + + + 2 + + + + + DIVIDE + + + 2 + + + distX + + + + + 2 + + + ADD + + + 2 + + + distY + + + + + 1 + + + + + + + + + MULTIPLY + + + 2 + + + PI + + + + + -2 + + + + + + + MULTIPLY + + + 2 + + + PI + + + + + 2 + + + + + + + + + 12 + + + MULTIPLY + + + 2 + + + PI + + + + + 2 + + + + + + + + + + + hue + + + DIVIDE + + + 2 + + + hue + + + + + 9.2 + + + MULTIPLY + + + 2 + + + PI + + + + + 4 + + + + + + + + + sat + + + DIVIDE + + + 2 + + + ROOT + + + 4 + + + ADD + + + 2 + + + MULTIPLY + + + 2 + + + distX + + + + + 2 + + + distX + + + + + + + 2 + + + MULTIPLY + + + 2 + + + distY + + + + + 2 + + + distY + + + + + + + + + + + 2 + + + maxDist + + + + + + + value + + + MULTIPLY + + + 2 + + + DIVIDE + + + 2 + + + MINUS + + + 2 + + + distZ + + + + + 2 + + + maxDist + + + + + + + 2 + + + MULTIPLY + + + 2 + + + + + 2 + + + maxDist + + + + + + + + + -1 + + + + + + + + + + + + HSVtoRGB + + + hue + + + + + sat + + + + + value + + + + + + + + + + + + + + + hue + + + ACOS + + + 45 + + + DIVIDE + + + 2 + + + distX + + + + + 9.2 + + + ROOT + + + 4 + + + ADD + + + 2 + + + ADD + + + 2 + + + MULTIPLY + + + 2 + + + distX + + + + + 9.2 + + + distX + + + + + + + 9.2 + + + MULTIPLY + + + 2 + + + distY + + + + + 9.2 + + + distY + + + + + + + + + 9.2 + + + MULTIPLY + + + 2 + + + distZ + + + + + 9.2 + + + distZ + + + + + + + + + + + + + + + hue + + + MINUS + + + 2 + + + DIVIDE + + + 2 + + + ATAN + + + 45 + + + ABS + + + 4 + + + DIVIDE + + + 2 + + + distX + + + + + 2 + + + distY + + + + + + + + + + + 45 + + + + + + + 1 + + + + + - + \ No newline at end of file