Bläddra i källkod

hsv to rgb

master
Victor Giers 5 år sedan
förälder
incheckning
3d2366f11a
6 ändrade filer med 337 tillägg och 101 borttagningar
  1. Binär
      qubeenee.blend
  2. 101
    39
      qubeenee.gltf
  3. Binär
      qubeenee.gltf.xz
  4. 44
    20
      qubeenee.js
  5. 91
    7
      visual_logic.js
  6. 101
    35
      visual_logic.xml

Binär
qubeenee.blend Visa fil


+ 101
- 39
qubeenee.gltf Visa fil

@@ -662,7 +662,7 @@
"nodeGraph" : {
"edges" : [
{
"fromNode" : 1,
"fromNode" : 2,
"fromOutput" : 0,
"toInput" : 0,
"toNode" : 0
@@ -736,10 +736,10 @@
0.800000011920929,
1.0
],
0.44545453786849976,
0.26363635063171387,
0.0,
0.0,
0.0,
1.0,
0.09545457363128662,
0.0,
0.0,
0.0,
@@ -795,21 +795,21 @@
"nodeGraph" : {
"edges" : [
{
"fromNode" : 1,
"fromNode" : 0,
"fromOutput" : 0,
"toInput" : 1,
"toNode" : 2
"toNode" : 3
},
{
"fromNode" : 2,
"fromNode" : 1,
"fromOutput" : 0,
"toInput" : 0,
"toNode" : 0
"toInput" : 2,
"toNode" : 3
},
{
"fromNode" : 3,
"fromNode" : 4,
"fromOutput" : 0,
"toInput" : 2,
"toInput" : 0,
"toNode" : 2
}
],
@@ -817,27 +817,30 @@
{
"inputs" : [
[
0,
0,
0,
0
1.0,
1.0,
1.0,
1.0
],
0.5,
1.4500000476837158,
[
0.0,
0.0,
0.0
]
],
"is_active_output" : false,
"name" : "Glass BSDF",
"outputs" : [
[
0,
0,
0,
0
],
[
0.0,
0.0,
0.0
]
],
"is_active_output" : true,
"name" : "Material Output",
"outputs" : [],
"type" : "OUTPUT_MATERIAL"
"type" : "BSDF_GLASS"
},
{
"inputs" : [
@@ -847,16 +850,10 @@
1.0,
1.0
],
0.5,
1.4500000476837158,
[
0.0,
0.0,
0.0
]
1.0
],
"is_active_output" : false,
"name" : "Glass BSDF",
"name" : "Emission",
"outputs" : [
[
0,
@@ -865,7 +862,32 @@
0
]
],
"type" : "BSDF_GLASS"
"type" : "EMISSION"
},
{
"inputs" : [
[
0,
0,
0,
0
],
[
0,
0,
0,
0
],
[
0.0,
0.0,
0.0
]
],
"is_active_output" : true,
"name" : "Material Output",
"outputs" : [],
"type" : "OUTPUT_MATERIAL"
},
{
"inputs" : [
@@ -897,16 +919,55 @@
},
{
"inputs" : [
[
0.800000011920929,
0.800000011920929,
0.800000011920929,
1.0
],
0.0,
[
1.0,
1.0,
1.0,
0.20000000298023224,
0.10000000149011612
],
[
0.800000011920929,
0.800000011920929,
0.800000011920929,
1.0
],
1.0
0.0,
0.5,
0.0,
0.5,
0.0,
0.0,
0.0,
0.5,
0.0,
0.029999999329447746,
1.4500000476837158,
0.7862595319747925,
0.0,
[
0.0,
0.0,
0.0
],
[
0.0,
0.0,
0.0
],
[
0.0,
0.0,
0.0
]
],
"is_active_output" : false,
"name" : "Emission",
"name" : "Principled BSDF",
"outputs" : [
[
0,
@@ -915,7 +976,7 @@
0
]
],
"type" : "EMISSION"
"type" : "BSDF_PRINCIPLED"
}
]
}
@@ -1301,9 +1362,10 @@
{
"extensions" : {
"S8S_v3d_scene_data" : {
"aaMethod" : "AUTO",
"aaMethod" : "MSAA8",
"light" : 0,
"physicallyCorrectLights" : true,
"useHDR" : true,
"worldMaterial" : 4
}
},

Binär
qubeenee.gltf.xz Visa fil


+ 44
- 20
qubeenee.js Visa fil

@@ -21,16 +21,16 @@ window.addEventListener('load', function() {

if (v3d.AppUtils.isXML(logicURL)) {
var logicURLJS = logicURL.match(/(.*)\.xml$/)[1] + '.js';
new v3d.PuzzlesLoader().loadEditorWithLogic(PUZZLES_DIR, logicURLJS,
new v3d.PuzzlesLoader().loadEditorWithLogic(PUZZLES_DIR, logicURLJS,
function() {
var initOptions = v3d.PL ? v3d.PL.execInitPuzzles().initOptions
var initOptions = v3d.PL ? v3d.PL.execInitPuzzles().initOptions
: { useFullscreen: true };
loadScene(sceneURL, initOptions);
}
);
} else if (v3d.AppUtils.isJS(logicURL)) {
new v3d.PuzzlesLoader().loadLogic(logicURL, function() {
var initOptions = v3d.PL ? v3d.PL.execInitPuzzles().initOptions
var initOptions = v3d.PL ? v3d.PL.execInitPuzzles().initOptions
: { useFullscreen: true };
loadScene(sceneURL, initOptions);
});
@@ -47,21 +47,21 @@ function loadScene(sceneURL, initOptions) {
if (initOptions.useBkgTransp) ctxSettings.alpha = true;
if (initOptions.preserveDrawBuf) ctxSettings.preserveDrawingBuffer = true;

var preloader = initOptions.useCustomPreloader
? createCustomPreloader(initOptions.preloaderProgressCb,
initOptions.preloaderEndCb)
var preloader = initOptions.useCustomPreloader
? createCustomPreloader(initOptions.preloaderProgressCb,
initOptions.preloaderEndCb)
: new v3d.SimplePreloader({ container: 'container' });
var app = new v3d.App('container', ctxSettings, preloader);
if (initOptions.useBkgTransp) {
app.clearBkgOnLoad = true;
app.renderer.setClearColor(0x000000, 0);
}

// namespace for communicating with code generated by Puzzles
// namespace for communicating with code generated by Puzzles
app.ExternalInterface = {};
prepareExternalInterface(app);
if (initOptions.preloaderStartCb) initOptions.preloaderStartCb();
if (initOptions.useFullscreen) {
initFullScreen();
@@ -87,12 +87,12 @@ function loadScene(sceneURL, initOptions) {
}

function createCustomPreloader(updateCb, finishCb) {
function CustomPreloader() {
v3d.Preloader.call(this);
function CustomPreloader() {
v3d.Preloader.call(this);
}

CustomPreloader.prototype = Object.assign(Object.create(v3d.Preloader.prototype), {
onUpdate: function(percentage) {
onUpdate: function(percentage) {
v3d.Preloader.prototype.onUpdate.call(this, percentage);
if (updateCb) updateCb(percentage);
},
@@ -101,7 +101,7 @@ function createCustomPreloader(updateCb, finishCb) {
if (finishCb) finishCb();
}
});
return new CustomPreloader();
}

@@ -110,7 +110,7 @@ function initFullScreen() {
var fsButton = document.getElementById('fullscreen_button');
if (!fsButton) return;

if (document.fullscreenEnabled ||
if (document.fullscreenEnabled ||
document.webkitFullscreenEnabled ||
document.mozFullScreenEnabled ||
document.msFullscreenEnabled)
@@ -118,7 +118,7 @@ function initFullScreen() {

fullscreen_button.addEventListener('click', function(event) {
event.stopPropagation();
if (document.fullscreenElement ||
if (document.fullscreenElement ||
document.webkitFullscreenElement ||
document.mozFullScreenElement ||
document.msFullscreenElement) {
@@ -128,7 +128,7 @@ function initFullScreen() {
});

function changeFullscreen() {
if (document.fullscreenElement ||
if (document.fullscreenElement ||
document.webkitFullscreenElement ||
document.mozFullScreenElement ||
document.msFullscreenElement)
@@ -147,12 +147,12 @@ function initFullScreen() {
elem.requestFullscreen();
else if (elem.mozRequestFullScreen)
elem.mozRequestFullScreen();
else if (elem.webkitRequestFullscreen)
else if (elem.webkitRequestFullscreen)
elem.webkitRequestFullscreen();
else if (elem.msRequestFullscreen)
elem.msRequestFullscreen();
}
function exitFullscreen() {
if (document.exitFullscreen)
document.exitFullscreen();
@@ -170,12 +170,36 @@ function prepareExternalInterface(app) {
// app.ExternalInterface.myJSFunction = function() {
// console.log('Hello, World!');
// }

app.ExternalInterface.HSVtoRGB = function(h, s, v) {
var r, g, b, i, f, p, q, t;
if (arguments.length === 1) {
s = h.s, v = h.v, h = h.h;
}
i = Math.floor(h * 6);
f = h * 6 - i;
p = v * (1 - s);
q = v * (1 - f * s);
t = v * (1 - (1 - f) * s);
switch (i % 6) {
case 0: r = v, g = t, b = p; break;
case 1: r = q, g = v, b = p; break;
case 2: r = p, g = v, b = t; break;
case 3: r = p, g = q, b = v; break;
case 4: r = t, g = p, b = v; break;
case 5: r = v, g = p, b = q; break;
}
console.log(r,g,b);
app.ExternalInterface.setRGB(r, g, b);
return {
r: Math.round(r * 255),
g: Math.round(g * 255),
b: Math.round(b * 255)
};
}
}

function runCode(app) {
// add your code here, e.g. console.log('Hello, World!');

}

});

+ 91
- 7
visual_logic.js Visa fil

@@ -1,6 +1,6 @@
/**
* Generated by Verge3D Puzzles v.2.12.5
* Fri Jun 07 2019 23:17:23 GMT+0200 (Mitteleuropäische Sommerzeit)
* Sat Jun 08 2019 00:30:36 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,7 +204,7 @@ initOptions = initOptions || {};
if ('fadeAnnotations' in initOptions) {
_pGlob.fadeAnnotations = initOptions.fadeAnnotations;
}
var distZ, light, stepY, distY, dragging, distX, inboundStepper, maxDist, sat, hue, value;
var distZ, r, g, b, stepY, distY, dragging, distX, inboundStepper, maxDist, sat, hue, value;


// utility function envoked by almost all V3D-specific puzzles
@@ -643,6 +643,17 @@ 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() {};
}



function eventGetOffsetCoords(e, touchId, dest) {
if (e instanceof MouseEvent) {
dest.set(e.offsetX, e.offsetY);
@@ -813,6 +824,80 @@ function registerOnDrag(objNames, callback_start, callback_move, callback_drop,



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);
}
appInstance.ExternalInterface["setRGB"] = setRGB;



// bloom puzzle
function bloom(threshold, strength, radius) {
appInstance.enablePostprocessing([{
type: 'bloom',
threshold: threshold,
strength: strength,
radius: radius
}]);
}



// ssao puzzle
function ssao(radius, aoClamp, lumInfluence) {
appInstance.enablePostprocessing([{
type: 'ssao',
radius: radius,
aoClamp: aoClamp,
lumInfluence: lumInfluence
}]);
}



// getEventProperty puzzle
function getEventProperty(prop, event) {
if (typeof event != "undefined") {
@@ -892,8 +977,6 @@ registerOnClick("bit", function() {
}
}, function() {});

light;

registerOnDrag(["GROUP", "qubit_grp"], function() {
dragging = true;
},
@@ -909,14 +992,15 @@ registerOnDrag(["GROUP", "qubit_grp"], function() {
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);
getJSFunction('HSVtoRGB')(hue, sat, value);
},
function() {
dragging = false;
}, "x7;j`9Tr6$fIW]tXfLwm");

bloom(0.5, 0.2, 0.15);
ssao(2, 0.25, 0.7);

eventHTMLElem('wheel', ["DOCUMENT"], false, function(event) {
if (dragging == true) {
if (getEventProperty('deltaY', event) < 0) {

+ 101
- 35
visual_logic.xml Visa fil

@@ -1,5 +1,5 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<tab name="Init" type="InitTab" active="false" scrollx="326.8509198386643" scrolly="291.0316409522357" scale="0.7462349768006044">
<tab name="Init" type="InitTab" active="false" scrollx="326.8509198386647" scrolly="291.0316409522357" scale="0.7462349768006044">
<variables>
<variable type="" id="U?SMwCJdbQuF-Xah3ja#">ctrlInit</variable>
<variable type="" id=";D?T^;K0%2HHlr__^(^G">cinitx</variable>
@@ -116,10 +116,12 @@
</next>
</block>
</tab>
<tab name="Main" type="MainTab" active="true" scrollx="232.04986572265625" scrolly="254.50326538085938" scale="0.5226292566934678">
<tab name="Main" type="MainTab" active="true" scrollx="102.93374633789062" scrolly="7.967080593109017" scale="0.7211790326162258">
<variables>
<variable type="" id="JjHAX,fgz)6.fPl8`pav">distZ</variable>
<variable type="" id="APc5)WJ[Hf2IW+7hrxsN">light</variable>
<variable type="" id="OZm(1S+UK~jxq[i=;gvy">r</variable>
<variable type="" id="3;f(l#V],jaRVr+m[?9;">g</variable>
<variable type="" id="~hN.qKKnh]5^GXCD=Ln5">b</variable>
<variable type="" id="GKERIN}`~rk0$MWnY3aS">stepY</variable>
<variable type="" id="vpri#?vQ7`ZyX.tU55{Z">distY</variable>
<variable type="" id="vG99U|`lU,3SOsjwD]~h">dragging</variable>
@@ -322,9 +324,6 @@
</block>
</statement>
</block>
<block type="variables_get" id="H4]N(O5pLY;L0jVF{}NC" x="-670" y="-250">
<field name="VAR" id="APc5)WJ[Hf2IW+7hrxsN" variabletype="">light</field>
</block>
<block type="whenDraggedOver" id="x7;j`9Tr6$fIW]tXfLwm" x="-230" y="-230">
<mutation do_start="true" do_drop="true"></mutation>
<value name="VALUE">
@@ -700,39 +699,28 @@
</block>
</value>
<next>
<block type="console.log" id="CSz~#m-=cKJ+IThK8A1T">
<value name="VALUE">
<shadow type="text" id="a]UNhQ)g?NDLjQ9L~ZBN">
<field name="TEXT">I'm here!!!</field>
</shadow>
<block type="callJSFunction" id="Ht=-UqmBfQXS$VYiv9;5">
<mutation name="HSVtoRGB">
<arg name="h"></arg>
<arg name="s"></arg>
<arg name="v"></arg>
</mutation>
<field name="NAME">HSVtoRGB</field>
<value name="ARG0">
<block type="variables_get" id="$3OIc0O#E7j~cJ,R`-?e">
<field name="VAR" id="S`ib|8a9}oYR22qe`UUI" variabletype="">hue</field>
</block>
</value>
<next>
<block type="console.log" id="upJ:FgyxTuO(6`0:FHlM">
<value name="VALUE">
<shadow type="text" id="a]UNhQ)g?NDLjQ9L~ZBN">
<field name="TEXT">I'm here!!!</field>
</shadow>
<block type="variables_get" id="fmN^BQWJ}iRc265bH#RM">
<field name="VAR" id="YfcA/U/M4Db,!/u8lx*r" variabletype="">sat</field>
</block>
</value>
<next>
<block type="console.log" id="A1s~7jbj`yz@j/+Q$2RU">
<value name="VALUE">
<shadow type="text" id="a]UNhQ)g?NDLjQ9L~ZBN">
<field name="TEXT">I'm here!!!</field>
</shadow>
<block type="variables_get" id="B=0NOM]eM`n,Ws`rlPbn">
<field name="VAR" id="rAlwiT?%pA#CG+i+x-1G" variabletype="">value</field>
</block>
</value>
</block>
</next>
<value name="ARG1">
<block type="variables_get" id="fmN^BQWJ}iRc265bH#RM">
<field name="VAR" id="YfcA/U/M4Db,!/u8lx*r" variabletype="">sat</field>
</block>
</value>
<value name="ARG2">
<block type="variables_get" id="B=0NOM]eM`n,Ws`rlPbn">
<field name="VAR" id="rAlwiT?%pA#CG+i+x-1G" variabletype="">value</field>
</block>
</next>
</value>
</block>
</next>
</block>
@@ -762,6 +750,84 @@
</block>
</statement>
</block>
<block type="externalCall" id="Vpc9v!mZHQ0;V(+:ON#u" x="-150" y="430">
<mutation>
<arg name="r" varid="OZm(1S+UK~jxq[i=;gvy"></arg>
<arg name="g" varid="3;f(l#V],jaRVr+m[?9;"></arg>
<arg name="b" varid="~hN.qKKnh]5^GXCD=Ln5"></arg>
</mutation>
<field name="NAME">setRGB</field>
<statement name="STACK">
<block type="setMaterialColor" id="|eRH_j=aRD}WiOkXzv}i">
<field name="MAT_COL_NAME">Principled BSDF Color</field>
<value name="MATERIAL">
<block type="materialList" id="RK`ToB})CECw8{IJ*7xU">
<field name="FIELDNAME">transparent</field>
</block>
</value>
<value name="R">
<shadow type="math_number" id="uMTNnOn`F[3nF/|A_FRa">
<field name="NUM">0.5</field>
</shadow>
<block type="variables_get" id="EhrBCPmUJ|?8?5%MWD|i">
<field name="VAR" id="OZm(1S+UK~jxq[i=;gvy" variabletype="">r</field>
</block>
</value>
<value name="G">
<shadow type="math_number" id="VfDW%w^e94)Xh9HL:@XN">
<field name="NUM">0.5</field>
</shadow>
<block type="variables_get" id="N:6Uy_BVf#OVcig)AwX:">
<field name="VAR" id="3;f(l#V],jaRVr+m[?9;" variabletype="">g</field>
</block>
</value>
<value name="B">
<shadow type="math_number" id="9n(`|;7_R}POn4hpJ-f7">
<field name="NUM">0.5</field>
</shadow>
<block type="variables_get" id="?Wd^ql:F{H_D.,}@(Yy~">
<field name="VAR" id="~hN.qKKnh]5^GXCD=Ln5" variabletype="">b</field>
</block>
</value>
</block>
</statement>
</block>
<block type="bloom" id="^pL/J.Y%ueuCO%}B=ezi" x="-270" y="510">
<value name="THRESHOLD">
<shadow type="math_number" id="S@oN@`tJye!`*)7Zy5[t">
<field name="NUM">0.5</field>
</shadow>
</value>
<value name="STRENGTH">
<shadow type="math_number" id="d8cSN{Dk`y3(fSC9MYZw">
<field name="NUM">0.2</field>
</shadow>
</value>
<value name="RADIUS">
<shadow type="math_number" id="].|hcK5O#zQt/ct[zjFu">
<field name="NUM">0.15</field>
</shadow>
</value>
<next>
<block type="ssao" id="~*s;Bv.,8e9lnec_53cA">
<value name="RADIUS">
<shadow type="math_number" id="$(Oy{xY[,33N8Md?1IMo">
<field name="NUM">2</field>
</shadow>
</value>
<value name="AO_CLAMP">
<shadow type="math_number" id="[4s+GMZ3J0/ev7LINj6k">
<field name="NUM">0.25</field>
</shadow>
</value>
<value name="LUM_INFLUENCE">
<shadow type="math_number" id="6aPQ:c6{M?|=/F-E~Gis">
<field name="NUM">0.7</field>
</shadow>
</value>
</block>
</next>
</block>
<block type="eventHTMLElem" id="fTN5K]$,(lHQ5YaPZx[f" x="-210" y="610">
<field name="EVENT">wheel</field>
<field name="PARENT">FALSE</field>
@@ -1129,5 +1195,5 @@
<field name="VAR" id="GKERIN}`~rk0$MWnY3aS" variabletype="">stepY</field>
</block>
</tab>
<editorsettings width="1087" height="614"></editorsettings>
<editorsettings width="918" height="396"></editorsettings>
</xml>

Laddar…
Avbryt
Spara