needs hue
This commit is contained in:
122
visual_logic.js
122
visual_logic.js
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Generated by Verge3D Puzzles v.2.12.5
|
||||
* Fri Jun 07 2019 19:29:14 GMT+0200 (Mitteleuropäische Sommerzeit)
|
||||
* Fri Jun 07 2019 23:17:23 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.
|
||||
@@ -204,27 +204,7 @@ initOptions = initOptions || {};
|
||||
if ('fadeAnnotations' in initOptions) {
|
||||
_pGlob.fadeAnnotations = initOptions.fadeAnnotations;
|
||||
}
|
||||
var maxDist, dragging, inboundStepper, distZ, distY, distX;
|
||||
|
||||
|
||||
// getObjectMaterial puzzle
|
||||
function getObjectMaterial(objNames) {
|
||||
objNames = retrieveObjectNames(objNames);
|
||||
if (!objNames)
|
||||
return '';
|
||||
for (var i = 0; i < objNames.length; i++) {
|
||||
var objName = objNames[i]
|
||||
if (!objName)
|
||||
continue;
|
||||
var obj = getObjectByName(objName);
|
||||
if (!obj)
|
||||
continue;
|
||||
if (obj.material && typeof obj.material.name == "string")
|
||||
return obj.material.name;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
var distZ, light, stepY, distY, dragging, distX, inboundStepper, maxDist, sat, hue, value;
|
||||
|
||||
|
||||
// utility function envoked by almost all V3D-specific puzzles
|
||||
@@ -335,6 +315,43 @@ 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];
|
||||
}
|
||||
|
||||
|
||||
|
||||
// getObjectMaterial puzzle
|
||||
function getObjectMaterial(objNames) {
|
||||
objNames = retrieveObjectNames(objNames);
|
||||
if (!objNames)
|
||||
return '';
|
||||
for (var i = 0; i < objNames.length; i++) {
|
||||
var objName = objNames[i]
|
||||
if (!objName)
|
||||
continue;
|
||||
var obj = getObjectByName(objName);
|
||||
if (!obj)
|
||||
continue;
|
||||
if (obj.material && typeof obj.material.name == "string")
|
||||
return obj.material.name;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
// assignMaterial puzzle
|
||||
function assignMat(objNames, matName) {
|
||||
objNames = retrieveObjectNames(objNames);
|
||||
@@ -465,19 +482,6 @@ function registerOnClick(objNames, cbDo, cbIfMissedDo) {
|
||||
|
||||
|
||||
|
||||
// distanceBetweenObjects puzzle
|
||||
function getDistanceBetweenObjects(objName1, objName2) {
|
||||
if (!objName1 || !objName2)
|
||||
return;
|
||||
var obj1 = getObjectByName(objName1);
|
||||
var obj2 = getObjectByName(objName2);
|
||||
if (!obj1 || !obj2)
|
||||
return;
|
||||
return obj1.getWorldPosition(_pGlob.vec3Tmp).distanceTo(obj2.getWorldPosition(_pGlob.vec3Tmp2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
function intersectPlaneCSS(plane, cssX, cssY, dest) {
|
||||
var coords = _pGlob.vec2Tmp;
|
||||
var rc = _pGlob.raycasterTmp;
|
||||
@@ -562,19 +566,15 @@ function dragMove(objNames, mode, blockId, parentDragOverBlockId) {
|
||||
|
||||
|
||||
|
||||
// getObjTransform puzzle
|
||||
function getObjTransform(objName, mode, coord) {
|
||||
if (!objName)
|
||||
// distanceBetweenObjects puzzle
|
||||
function getDistanceBetweenObjects(objName1, objName2) {
|
||||
if (!objName1 || !objName2)
|
||||
return;
|
||||
var obj = getObjectByName(objName);
|
||||
if (!obj)
|
||||
var obj1 = getObjectByName(objName1);
|
||||
var obj2 = getObjectByName(objName2);
|
||||
if (!obj1 || !obj2)
|
||||
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];
|
||||
return obj1.getWorldPosition(_pGlob.vec3Tmp).distanceTo(obj2.getWorldPosition(_pGlob.vec3Tmp2));
|
||||
}
|
||||
|
||||
|
||||
@@ -878,11 +878,11 @@ function eventHTMLElem(eventType, ids, isParent, callback) {
|
||||
|
||||
|
||||
|
||||
2 + 2;
|
||||
|
||||
Math.sqrt(4);
|
||||
|
||||
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;
|
||||
stepY = 0.1;
|
||||
|
||||
registerOnClick("bit", function() {
|
||||
if (getObjectMaterial("bit") == "white") {
|
||||
@@ -892,20 +892,26 @@ registerOnClick("bit", function() {
|
||||
}
|
||||
}, function() {});
|
||||
|
||||
light;
|
||||
|
||||
registerOnDrag(["GROUP", "qubit_grp"], function() {
|
||||
dragging = true;
|
||||
},
|
||||
function() {
|
||||
console.log(getDistanceBetweenObjects("qubit_controller", "qubit"));
|
||||
dragMove("qubit_controller", "XY", "5{hamS]l^diNZ_?={UNM", "x7;j`9Tr6$fIW]tXfLwm");
|
||||
inboundStepper = 0;
|
||||
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");
|
||||
while (getDistanceBetweenObjects("qubit_controller", "qubit") > maxDist) {
|
||||
inboundStepper = (typeof inboundStepper == 'number' ? inboundStepper : 0) + 1;
|
||||
applyObjLocalTransform("qubit_controller", "position", (distX / 50) * inboundStepper, 0, (distZ / 50) * inboundStepper);
|
||||
}
|
||||
hue = 0;
|
||||
sat = Math.sqrt(distX * distX + distY * distY) / maxDist;
|
||||
value = ((distZ - maxDist) / (2 * maxDist)) * -1;
|
||||
console.log(hue);
|
||||
console.log(sat);
|
||||
console.log(value);
|
||||
},
|
||||
function() {
|
||||
dragging = false;
|
||||
@@ -914,19 +920,23 @@ registerOnDrag(["GROUP", "qubit_grp"], function() {
|
||||
eventHTMLElem('wheel', ["DOCUMENT"], false, function(event) {
|
||||
if (dragging == true) {
|
||||
if (getEventProperty('deltaY', event) < 0) {
|
||||
applyObjLocalTransform("qubit_controller", "position", 0, 0.1, 0);
|
||||
applyObjLocalTransform("qubit_controller", "position", 0, stepY, 0);
|
||||
if (getDistanceBetweenObjects("qubit_controller", "qubit") >= maxDist) {
|
||||
applyObjLocalTransform("qubit_controller", "position", 0, -0.1, 0);
|
||||
applyObjLocalTransform("qubit_controller", "position", 0, stepY * -1, 0);
|
||||
}
|
||||
} else if (getEventProperty('deltaY', event) > 0) {
|
||||
applyObjLocalTransform("qubit_controller", "position", 0, -0.1, 0);
|
||||
applyObjLocalTransform("qubit_controller", "position", 0, stepY * -1, 0);
|
||||
if (getDistanceBetweenObjects("qubit_controller", "qubit") >= maxDist) {
|
||||
applyObjLocalTransform("qubit_controller", "position", 0, 0.1, 0);
|
||||
applyObjLocalTransform("qubit_controller", "position", 0, stepY, 0);
|
||||
}
|
||||
}
|
||||
distY = getObjTransform("qubit", "position", "z") - getObjTransform("qubit_controller", "position", "z");
|
||||
sat = Math.sqrt(distX * distX + distY * distY) / maxDist;
|
||||
}
|
||||
});
|
||||
|
||||
stepY;
|
||||
|
||||
} // end of PL.init function
|
||||
|
||||
if (window.v3dApp) {
|
||||
|
||||
Reference in New Issue
Block a user