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

/** /**
* Generated by Verge3D Puzzles v.2.12.5 * 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. * 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 * 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. * for information on how to add your own JavaScript to Verge3D apps.
preloaderEndCb: function() {}, preloaderEndCb: function() {},
} }
} }
var cinitx, cinity, cinitz;


// utility functions envoked by the HTML puzzles // utility functions envoked by the HTML puzzles
function getElements(ids, isParent) { function getElements(ids, isParent) {
var elems = []; var elems = [];
_initGlob.output.initOptions.useFullscreen = false; _initGlob.output.initOptions.useFullscreen = false;


setHTMLElemStyle('backgroundColor', 'rgb(127,127,127)', ["BODY"], false); setHTMLElemStyle('backgroundColor', 'rgb(127,127,127)', ["BODY"], false);
cinitx = 0;
cinity = 0;
cinitz = 0;


return _initGlob.output; return _initGlob.output;
} }
if ('fadeAnnotations' in initOptions) { if ('fadeAnnotations' in initOptions) {
_pGlob.fadeAnnotations = initOptions.fadeAnnotations; _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 // utility function envoked by almost all V3D-specific puzzles
} }




// 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) { function intersectPlaneCSS(plane, cssX, cssY, dest) {
var coords = _pGlob.vec2Tmp; var coords = _pGlob.vec2Tmp;
var rc = _pGlob.raycasterTmp; var rc = _pGlob.raycasterTmp;






// 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 // distanceBetweenObjects puzzle
function getDistanceBetweenObjects(objName1, objName2) { function getDistanceBetweenObjects(objName1, objName2) {
if (!objName1 || !objName2) if (!objName1 || !objName2)






// 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 // utility function used by the whenClicked, whenHovered and whenDraggedOver puzzles
function initObjectPicking(callback, eventType, mouseDownUseTouchStart) { function initObjectPicking(callback, eventType, mouseDownUseTouchStart) {


} }




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;












// 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 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;












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 // toFixedPoint puzzle
function toNumber(num, prec) { function toNumber(num, prec) {
prec = Math.pow(10, prec); prec = Math.pow(10, prec);
console.log(['Bit [',bitstate,'] Qubit: [',toNumber(r_, 3),'] [',toNumber(g_, 3),'] [',toNumber(b_, 3),']'].join('')); 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() { registerOnDrag(["GROUP", "qubit_grp"], function() {
dragging = true; dragging = true;
} }
distZ = getObjTransform("qubit", "position", "y") - getObjTransform("qubit_controller", "position", "y"); distZ = getObjTransform("qubit", "position", "y") - getObjTransform("qubit_controller", "position", "y");
distX = getObjTransform("qubit", "position", "x") - getObjTransform("qubit_controller", "position", "x"); 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() { function() {
dragging = false; dragging = false;
}, "x7;j`9Tr6$fIW]tXfLwm"); }, "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() { registerOnClick("recordqubit", function() {
if (getObjectMaterial("recordqubit") == "on") { if (getObjectMaterial("recordqubit") == "on") {
} }
}, 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() { registerInterval(1, function() {
if (recordbitstate == 1) { if (recordbitstate == 1) {
} }
}); });


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) { eventHTMLElem('wheel', ["DOCUMENT"], false, function(event) {
if (getEventProperty('deltaY', event) < 0) { if (getEventProperty('deltaY', event) < 0) {
} }
} }
distY = getObjTransform("qubit", "position", "z") - getObjTransform("qubit_controller", "position", "z"); 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 } // end of PL.init function


if (window.v3dApp) { if (window.v3dApp) {

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


Loading…
Cancel
Save