Forum

User posts Wole
01 November 2015 05:49
Hello,

Here's one I've been scratching my head on.

Can I get the distance from camera to object (in the running web app) and use that value to scale an object. For example, if the camera is 100 feet from the object, the scale of the object is 100, but if the camera is zoomed in to 10 feet from the object the object scale dynamically decreases to 10 also.

An simple example file would very helpful from anyone out here. I find I can learn best with the source coding to pick apart. And I am definitely a beginner so seeing simple full code helps.

Thanks in advance!

18 October 2015 04:47
Please disregard last message. I just watched Will W tutorial and he explained it in the first 5 minutes! Thanks Will if you're out there.
18 October 2015 04:39
Hello, don't know if anyone will look at this older post. If I download the example zip file and extract the folder, I can open the html file and see the two buttons but clicking them does nothing. Is there a protocol on how to open a functioning version of these examples? (Sorry if this is a basic question but I'm still just learning)

Thanks in advance!
12 October 2015 05:38
Awesome. Thanks Will. Looking forward to the video!
12 October 2015 03:39
Thanks Will. I should amend my statement…I am more of a Blender National Guard than a hardcore vet. I'm a civil engineer who has been producing project videos using CAD 3d models and Blender for a few years but I was a hobbyist before that.

So I've downloaded your zip and ran the index.html. I see in the text description on the page that there is supposed to be something in the background but all I see is the colored block. There is no blend4web viewer there. Is this still in development or have I mucked it up again?

11 October 2015 06:37
Thanks Will. BTW, your videos have been a great help! I've watched and learned a lot from them all. Looking forward to following you as far down the rabbit hole as I can. Also as an 8 year Blender vet, I 100% percent agree with your statement that figuring out how to make something work is the majority of the battle. Glad to have guys like you helping demystify this new frontier.
11 October 2015 04:58
Thanks for the input! I'm still trying to get over the hump and I'm sorry if I'm asking for someone to hold my hand too much. Here's what I did as a test.

1. Took the new project .blend with the cube selected and checked "Selectable" and "Enable Outlining", resaved
2. Exported to .html
3. Changed the code to read as below - added var m_mouse = require("mouse"); and m_mouse.enable_mouse_hover_outline();
4. Loaded the .html into Chrome to no avail

I also tried the .json export option to no avail. I combed through the new years example and the interactive example. Maybe I'm missing a key point here about where these addons are coming from. Any help would be appreciated!

"use strict"

// register the application module
b4w.register("glow-test", function(exports, require) {

// import modules used by the app
var m_app       = require("app");
var m_data      = require("data");
var m_cfg       = require("config");
var m_mouse		= require("mouse");

/**
 * 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: true,
        autoresize: true
    });
}

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

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

    load();
}

/**
 * load the scene data
 */
function load() {
    m_data.load("glow-test.json", load_cb);
}

/**
 * callback executed when the scene is loaded
 */
function load_cb(data_id) {
    m_app.enable_controls();
    m_app.enable_camera_controls();
	m_mouse.enable_mouse_hover_outline();

    // place your code here

}


});

// import the app module and start the app by calling the init method
b4w.require("glow-test").init();"use strict"

// register the application module
b4w.register("glow-test", function(exports, require) {

// import modules used by the app
var m_app       = require("app");
var m_data      = require("data");
var m_cfg       = require("config");
var m_mouse		= require("mouse");

/**
 * 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: true,
        autoresize: true
    });
}

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

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

    load();
}

/**
 * load the scene data
 */
function load() {
    m_data.load("glow-test.json", load_cb);
}

/**
 * callback executed when the scene is loaded
 */
function load_cb(data_id) {
    m_app.enable_controls();
    m_app.enable_camera_controls();
	m_mouse.enable_mouse_hover_outline();

    // place your code here

}


});

// import the app module and start the app by calling the init method
b4w.require("glow-test").init();
10 October 2015 17:47
Hi everyone, great tool you have here!

So, I was wondering what is the best starting point for learning how to use javascript and how to take the code given and put it into my scene. For example, I want to put the mouse hover over glow into my existing project. Very basic, I know, but what I've found seems to be more advanced and I need an "absolute beginner" version.

I'm a quick learner if I can get going in the right direction. I've done some basic python coding for Blender.

Thanks!