diff --git a/qubeenee.blend b/qubeenee.blend index 7134907..cb6bea8 100644 Binary files a/qubeenee.blend and b/qubeenee.blend differ diff --git a/qubeenee.gltf b/qubeenee.gltf index 1cc0492..bf37056 100644 --- a/qubeenee.gltf +++ b/qubeenee.gltf @@ -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,50 +795,25 @@ "nodeGraph" : { "edges" : [ { - "fromNode" : 1, + "fromNode" : 0, "fromOutput" : 0, "toInput" : 1, - "toNode" : 2 + "toNode" : 3 }, { - "fromNode" : 2, - "fromOutput" : 0, - "toInput" : 0, - "toNode" : 0 - }, - { - "fromNode" : 3, + "fromNode" : 1, "fromOutput" : 0, "toInput" : 2, + "toNode" : 3 + }, + { + "fromNode" : 4, + "fromOutput" : 0, + "toInput" : 0, "toNode" : 2 } ], "nodes" : [ - { - "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" : [ [ @@ -867,6 +842,53 @@ ], "type" : "BSDF_GLASS" }, + { + "inputs" : [ + [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + 1.0 + ], + "is_active_output" : false, + "name" : "Emission", + "outputs" : [ + [ + 0, + 0, + 0, + 0 + ] + ], + "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" : [ 0.5, @@ -898,15 +920,54 @@ { "inputs" : [ [ - 1.0, - 1.0, - 1.0, + 0.800000011920929, + 0.800000011920929, + 0.800000011920929, 1.0 ], - 1.0 + 0.0, + [ + 1.0, + 0.20000000298023224, + 0.10000000149011612 + ], + [ + 0.800000011920929, + 0.800000011920929, + 0.800000011920929, + 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 } }, diff --git a/qubeenee.gltf.xz b/qubeenee.gltf.xz index 31455a7..013eac5 100644 Binary files a/qubeenee.gltf.xz and b/qubeenee.gltf.xz differ diff --git a/qubeenee.js b/qubeenee.js index 770de0e..ead5c9f 100644 --- a/qubeenee.js +++ b/qubeenee.js @@ -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!'); - } }); diff --git a/visual_logic.js b/visual_logic.js index 0523048..2c0fe55 100644 --- a/visual_logic.js +++ b/visual_logic.js @@ -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) { diff --git a/visual_logic.xml b/visual_logic.xml index 8b2ec5f..ce20934 100644 --- a/visual_logic.xml +++ b/visual_logic.xml @@ -1,5 +1,5 @@ - + ctrlInit cinitx @@ -116,10 +116,12 @@ - + distZ - light + r + g + b stepY distY dragging @@ -322,9 +324,6 @@ - - light - @@ -700,39 +699,28 @@ - - - - I'm here!!! - + + + + + + + HSVtoRGB + hue - - - - - I'm here!!! - - - sat - - - - - - - I'm here!!! - - - value - - - - + + + sat - + + + + value + + @@ -762,6 +750,84 @@ + + + + + + + setRGB + + + Principled BSDF Color + + + transparent + + + + + 0.5 + + + r + + + + + 0.5 + + + g + + + + + 0.5 + + + b + + + + + + + + + 0.5 + + + + + 0.2 + + + + + 0.15 + + + + + + + 2 + + + + + 0.25 + + + + + 0.7 + + + + + wheel FALSE @@ -1129,5 +1195,5 @@ stepY - + \ No newline at end of file