Browse Source

better colors

master
Victor Giers 4 years ago
parent
commit
9be2be456d
3 changed files with 1160 additions and 1079 deletions
  1. BIN
      qubeenee.blend
  2. 151
    143
      visual_logic.js
  3. 1009
    936
      visual_logic.xml

BIN
qubeenee.blend View File


+ 151
- 143
visual_logic.js View File

@@ -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,64 +786,21 @@ function registerOnClick(objNames, cbDo, cbIfMissedDo) {



// setInterval puzzle
function registerInterval(timeout, callback) {
window.setInterval(callback, 1000 * timeout);
}



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'];
// callJSFunction puzzle
function getJSFunction(funcName) {
var jsFunc = appInstance.ExternalInterface[funcName];
if (typeof jsFunc == "function")
return jsFunc;
else
return []
return function() {};
}


// 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();
// setInterval puzzle
function registerInterval(timeout, callback) {
window.setInterval(callback, 1000 * timeout);
}
appInstance.ExternalInterface["setRGB"] = setRGB;



@@ -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) {

+ 1009
- 936
visual_logic.xml
File diff suppressed because it is too large
View File


Loading…
Cancel
Save