Форум

Сообщения, созданные пользователем Charlie
13 июля 2017 05:35
I'll test now. Back in mo'.
13 июля 2017 05:17
Hi all,

apologies for absolutely bashing this forum over the last couple days, but I can get a bit obsessed and I like to learn stuff really, really fast.

However, it seems the more 'aggressively' I use B4W, the more I seem to break it… This always the way with me.

OK, so I'm working on a mini-project to help me learn the API, and it looks great in fast preview, but when I hit the dev.html link in project manager, after compiling my build, the objects are not showing their textures.

…They're showing the material characteristics just fine (specular, alpha, diffuse properties etc etc), but the textures are just gone!

I've tried lots of different methods of compiling, including straight to web-players, but nope. Gone.

It only seems to have started doing it today, so have I 'switched something off' by accident? I dunno, this is strange one.

Any help gratefully appreciated.

All the very best

Charlie
13 июля 2017 05:11
Yeah, I actually figured this one out on my own. Declaring the variable within the function worked a treat. Thanks again.

C
13 июля 2017 05:08
You're a star, thanks.

I was starting to think my install was full of glitches.


C
12 июля 2017 04:47
Hi Guys,

I've got two iFrames in my parent HTML page; One contains the B4W app and the other contains HTML content that I'd like to affect from the JS.

I've seen a topic on here about iFrame communication, but I can't seem to find it.

My function looks like this:

var loc = "Menu1.html";
   }
    
    function changeFrame_cb(in_params, out_params) {

        console.log("changeFrame_cb was called!");
        parent.document.getElementById('myFrame').setAttribute('src', loc);
    }


The console reports 'Can't find variable: loc'

The 'loc' is in the same directory as the B4W HTML aswell as the parent (index.html)

Any ideas?

Thanks
12 июля 2017 02:57
After a whole day on this I've discovered the problem, but I have to say, I have no idea what's causing it. Here's my autopsy.

When I add a new node tree, I for some reason, don't have 'B4WLogicNode' in the drop down, so I made my own and named it 'myNode' (for example). I make sure the little 'F' button is clicked, and then build my tree. THIS DOES NOT WORK!

I downloaded a source file (from the welsh guy on Youtube). His file already had the 'B4WLogicNodeTree' in the list, so I worked with that as a starting point. Everything works perfectly.

It seems to be a local issue when my scenes are initiated, but I don't know what the cause of the problem is. Here's a link to one of the 'failed' blend files:
link


And here's a link to the one that works
link

Even if I save my node tree as 'B4WLogicNodeTree', which I have done (even though my source file omits the word 'tree'), it still fails.


I don't even know what to look out for, so your astute observations are, as usual, more than welcome.

It's a total mystery to me and has cost me hours :-(

Kind regards
12 июля 2017 01:45
Should've looked harder, before posting. Sorry guys.
12 июля 2017 01:40
That's a nope… Something to remember for the future.

To be honest, I'm having a complete nightmare. I decided to uninstall and reinstall EVERYTHING, including blender. Guess what? when I try to boot the new install of B4W in User preferences, B4W is nowhere to be seen in the add ons list. Done everything right. I pointed the scripts (in user pref) to the SDK root, saved, restarted… It's nowhere. I'm starting to think it's got it in for me.

I'll have to post it in the noob section, as I moved the Blend4web app in the add-ons, using the remove button.

I'm losing so much time on this, it's stressing me out :-)

C
11 июля 2017 23:15
I think you might be onto something.

I've just tried to use a basic in-scene (no external JS) inherit material logic node, and nothing's working.

I used the technique in my very first B4W test last week link
and it all worked fine. I'm just wondering if there's an issue with the node setup because when I go to open the b4wNodeTree from the 'browse node tree menu', it isn't there any more.

I did replace my first B4W installation (exactly the same location), so perhaps that has something to do with it. I might try a fresh install. If it's still not working, I'll send my blend file for you to have a look at.

Thanks again
11 июля 2017 19:47
Wow, thanks… I didn't realise i'd included in the onLoad function.

Starting to make good progress, but as you'll probably know, when you open one door, another closes in your face.

I'm struggling getting the click event to register now (face palm)

I changed the project slightly, so I'm not changing a dynamic div in the HTML (which requires IDs etc). I'm now generating the div within the JS, which works fine.

Now, when I click the cube, I want to change the inner HTML (it's closer to the video you pointed me to, rather than the example on the forum).

When I run the dev.html, the click (or hit) event isn't working… I'm wondering if I've now got node problems, as there's no console errors.

My node goes like:

Entry point >> Switch Select >> JS Callback. ID (string)

Switch select 'miss' and JS Callback 'next' both loop to switch select 'previous'. I have not used any 'in' or 'out' perams in JS callback.

So close, but still not quite there!

Here's my new JS:

"use strict"

// register the application module
b4w.register("showDiv_main", function (exports, require) {

    // import modules used by the app
    var m_app = require("app");
    var m_cfg = require("config");
    var m_data = require("data");
    var m_preloader = require("preloader");
    var m_ver = require("version");
    var m_logn = require("logic_nodes");

    // detect application mode
    var DEBUG = (m_ver.type() == "DEBUG");

    // automatically detect assets path
    var APP_ASSETS_PATH = m_cfg.get_assets_path("showDiv");

    /**
     * export the method to initialize the app (called at the bottom of this file)
     */
    exports.init = function () {
        m_app.init({
            canvas_container_id: "main_canvas_container",
            callback: init_cb,
            show_fps: DEBUG,
            console_verbose: DEBUG,
            autoresize: true
        });
    }

    /**
     * callback executed when the app is initialized 
     */
    function init_cb(canvas_elem, success) {

        if (!success) {
            console.log("b4w init failure");
            return;
        }

        m_preloader.create_preloader();

        // ignore right-click on the canvas element
        canvas_elem.oncontextmenu = function (e) {
            e.preventDefault();
            e.stopPropagation();
            return false;
        };

        console.log("showDiv_cb will be append");
        console.log(showDiv_cb);

        m_logn.append_custom_callback("showDiv", showDiv_cb);


        load();
    }

    /**
     * load the scene data
     */
    function load() {
        m_data.load(APP_ASSETS_PATH + "showDiv.json", load_cb, preloader_cb);
    }

    /**
     * update the app's preloader
     */
    function preloader_cb(percentage) {
        m_preloader.update_preloader(percentage);
    }

    /**
     * callback executed when the scene data is loaded
     */
    function load_cb(data_id, success) {

        if (!success) {
            console.log("b4w load failure");
            return;
        }

        m_app.enable_camera_controls();

       var display_div = document.createElement("div");
    display_div.id = "display_div_id";
    display_div.style.position = "relative";
	display_div.style.color = "green";
	display_div.style.fontSize = "30px";
	display_div.style.fontFamily = "sans-serif";
	display_div.style.fontWeight = "900";
    display_div.innerHTML = "Click the cube to change inner HTML of this div";
    document.body.appendChild(display_div);

    }

    function showDiv_cb(in_params, out_params) {
        console.log("showDiv_cb was called!");
var anchor_elem = document.getElementById("display_div_id");
	anchor_elem.innerHTML = "It worked";
    }

});

// import the app module and start the app by calling the init method
b4w.require("showDiv_main").init();