Форум

Сообщения, созданные пользователем Will Welker
07 июня 2017 15:15
Question for one of the Blen4Web team if you have time:
m_math.line_plane_intersect(FLOOR_PLANE_NORMAL, 0, _pline_tmp, _vec3_tmp3);

Is there any code like line_plane_intersect that will intersect an object like a plane object in the scene?
07 июня 2017 15:08
I think I understand. I believe we need to make the FLOOR_PLANE_NORMAL follow the cameras movement. So every time you start dragging an object it will follow a flat plane that is parented to the camera.
Right now it is positioned as the floor but we need to do some math so it is vertical like a wall and always faces the camera.
This is a fun puzzle but I may have to get back to it later. I need to get my kids to school.
Maybe one of the nice devs will give us a hint.
07 июня 2017 14:21
The 1 is how far away from the origin or center.
So if it is 0, the FLOOR_PLANE_NORMAL will be located at the center of origin,

https://www.blend4web.com/api_doc/module-math.html#.line_plane_intersect

In your project, do you want to move objects around a room? Or do you want to move objects on a wall?
07 июня 2017 12:53
Yes, try changing it to [0.5, 0.5, 0] then try it out.
07 июня 2017 12:12
I think there are two solutions. Depending on what you want your project to do. I will give you the easy one first while I work on the other one LOL.
var FLOOR_PLANE_NORMAL = [0, 0, 1];

This variable decides what plane you object moves on. so 0, 0, 1 is the floor (Z plane).
0, 1, 0 is the wall (Y plane).
1, 0, 0 is the wall (X plane)
0.5, 0.5, 0 is a diagonal wall.

In this line:
var point = m_math.line_plane_intersect(FLOOR_PLANE_NORMAL, 0,
                        _pline_tmp, _vec3_tmp3);

The 0 is distance, plus or minus, the plane will be from the center of origin. So if you changed it to -1, the furniture will be moving around 1 unit above the floor. Chang it to 1 and the furniture will move around down below the floor.

So the second solution is just to make the object fallow your mouse X,Y position on the canvas… Still working on that…
07 июня 2017 11:01
I think I understand you want the object to follow your mouse (X and Y from the camera perspective). And you do not want your object to move farther or nearer to the camera. I will look at your code. I am still learning this API my self so I might be slow
07 июня 2017 10:36
Okay, I have your code. One more question: For X and Y do you mean world space? Like in this example:
https://www.blend4web.com/apps/tutorials/cartoon_interior/cartoon_interior.html
Or do you mean X and Y on you screen like a normal 2D website?
07 июня 2017 10:27
Hi Indan,
Are you opening the project from your Project Manager?
It won't work if you try to open the HTML file directly. So if you place the project inside your SDK then open Blender so your local server is running, you can open your project with a URL like this:
http://localhost:6687/projects/html3d/apps_dev/html3d/html3d.html
Make sure the file path matches what you have.
So for me, I opened my SDK Index from within Blender. That took me to http://localhost:6687 in my browser. I then pasted the rest of the address on: /projects/html3d/apps_dev/html3d/html3d.html
My zip attached.
07 июня 2017 09:09
Are you able to export a good animation from the character file?
I wonder if you can reproduce the problem in a blank .blend file without your scenery.
If you can reproduce the problem in a file that you can upload, maybe we could get a better look at it.
07 июня 2017 09:00
Hi alpatel2008,
Can you attach the whole JS file? There is an 'Attach' button at the lower right when you write your post.