论坛

由用户创建的信息 JPfeP
03 January 2016 05:51
Well, after some substantial searching on the net, the answer was relatively simple. At least, it works rather well right now for my project. I don't know if there are better ways to do that and hope it won't lead to any potential problems, but adding "bind(this)" to the callback function did the trick.

this.b4w_obj_cb = function (obj, id, pulse){
       console.log(this.prop1);
   }.bind(this);


(end of noob alert)
31 December 2015 02:22
Hi,

I don't know if it is the good way, but I am trying to encapsulate some B4W code inside a JS object that I am going to instantiate later.

This object has some properties reflecting its state and some B4W properties and API functions to get a related blender object and bind some sensors to it.

function ModelOBJ() {
    // some props
    this.prop1 = true;
    this.prop2 = 0 ;
    ...   

    // some classic JS methods
    this.func = function(){
    ...
    }

   // some B4W code
   this.b4w_obj = m_scs.get_object_by_name('a_blender_obj');
   this.b4w_selector = m_ctl.create_selection_sensor(this.b4w_obj)

   this.b4w_obj_cb = function (obj, id, pulse){
       console.log(this.prop1);
   }

   m_ctl.create_sensor_manifold(this.b4w_obj, "OK", m_ctl.CT_SHOT,[this.b4w_selector], function(s){return s[0]}, this.b4w_obj_cb);

}

var object1 = new ModelOBJ();


Unfortunately, in the callback function this.prop1 cannot be accessed, and the result is undefined if you click on the object in the 3D scene. Is there a workaround to get the context of "this" instance so that we can r/w the properties of the instance and use its methods in the callback function ?

19 December 2015 07:01
Hi,

Recently I have been able to recreate the LCD display of an industrial machine using a canvas texture and B4W to project it on the 3D model screen. The resulting image of the display is composed of several layers of 'png' images using the drawImage() method. It works well with Chrome albeit some slowness during the refresh, but with IE11 and even Firefox there are some troubles.

With Firefox, the console reports: NS_ERROR_NOT_AVAILABLE (seemingly on the first drawImage call) and consequently the LCD display remains black. IE11 has a different error message (from memory: bad property value on the "src" argument of the image), but with the same unsuccessful result.

Are there some notorious problem with theses browsers ? From where could come the trouble ? Is it purely a problem of a too heavy calculation for real time use ?

24 November 2015 18:47
Hi,

I am observing that when you copy a parented object (here to the camera) using the API, the newly created object doesn't behave as the source object, as if the parenting relation was lost.

Yet the get_parent() method from the objects module still reports it is.

But another troubling thing is that the vector yielded by get_translation_rel() used on the new object now adopts the value of get_translation(). Like if the world space coordinates are now the relative coordinates.

04 November 2015 03:25
Hi,

We are exploring the possibilities of the new logic nodes system (thanks for this awesome improvement). It is indeed quite tempting to use it in our project for the menus instead of icons in HTML+CSS+JS (cf. the "Furnishing a room" example).

Albeit it is wonderful for simple tasks, to trigger animations and such, we would like for instance to pass the result of a "Conditional Jump" node to the usual JS code written for the rest of the project.

Is there a dedicated way to do that or even a little trick ?
31 October 2015 23:50
OK, thanks for the answers. BTW, is there anything that would prevent the use of normal HTML5 audio features at the same time than the B4W JS engine ? We won't have to do much on the audio side. Just play some alarm signals without positioning. I hope it wouldn't lead to a stuttering sound. But basically it's just playing a .wav or a mp3.

29 October 2015 15:09
Hello,

A client want we do a B4W project but a condition is it can work under IE 11. I am a little surprised but the workers who will use the project have sometimes no right to install something on the computer.

I read the documentation and it is said that IE 11 support is experimental. I read the forums a little bit and found that for instance there is not webaudio under IE 11. But the posts were 1 year old.

Nowadays, how is the support of B4W under IE 11 ? Is it a little better ? Are there some limitations that will remain forever ?


08 February 2015 18:42
Hi, I use the pointerlock mode in my project with a Static camera and it works well but unfortunately, despite the instructions here, I haven't be able to modify FPS_MOUSE_MULT. Are there some news about the new API function to modify it (I tried "set_velocity_params()" but it seems without effect) ? Or could you indicate me where in the blender interface we can change it ?

The last resort would be to modify manually b4w.full.min.js but the code is obfuscated.
05 February 2015 17:15
Glad you have found the root of the problem. May be a warning could be helpful too during export. I want to stress on the fact that the documentation you refer to doesn't say explicitly that you have the choice between the 2 options. On the contrary it presents the two ways sequentially and each time says that the given option has to be enabled. The result is that someone inexperienced may think that both options need to be enabled. It is, at least, what probably happened to me.

But, now, it does make sense, I was in fact a little puzzled why there were two fields for the ID collision in different panels.

A little question, BTW, when you go for a material with "Special :collision", does this bypass the "Collisions bounds" setting like capsule, box or cone ? Does it force physics calculation to be mesh accurate like Triangle Mesh in the BGE ?
03 February 2015 17:57
It is true that before sending the zip I reorganized the scene a little and put in my hurry the character capsule inside the ground. But before that the object was way above the ground and the problem was already present. For a new test I just put the character again well above the ground and still got the problem. I am sending you another zip file with everything set up. Just open the html file, and of course you can control the height of the character in the blendfile. You will see that there is no contact with the collision mesh and yet the bug happens.

Moreover If you hit O you will trigger a camera animation and see that the character is standing still in the air and is not stuck in the ground. Yet it can not move.

I totally agree with you with the mesh density of the rocky cube. This model is not mine, as I am into a collaboration work with someone else. In fact I think that the problem may well reside in the mesh of this big cube. As a matter of fact, in another test I applied a Remesh modifier on it and everything went back to normal. So I don't know yet the true reason, it is not strictly the mesh density since I was able to subdivide it after that quite a lot without having the problem back. However you may have some more clues about the whole subject. It may be worthy to find the true reason, if it is a bug it can bite again.