|
Sweet Home 3D Forum » List all forums » » Forum: Developers » » » Thread: Export HTML5 plug-in |
|
| Print at Dec 16, 2025, 2:27:00 PM | |
| Posted by industria at Sep 22, 2016, 3:01:38 PM |
|
Export HTML5 plug-in How to click in a furniture (door, window etc) and open a Javascript alert contaign the CatalogID of the furniture clicked? |
| Posted by Puybaret at Sep 22, 2016, 4:04:27 PM |
|
Re: Export HTML5 plug-in You should call the method getClosestItemAt available in HomeComponent3D class in a listener added to the displayed canvas. If the returned object is an instance of HomePieceOfFurniture, then you may call its getCatalogId method to get its catalog ID and do whatever you want. The HomeComponent3D instance is returned by the getComponent3D method available on the object returned by viewHome function. ---------------------------------------- Emmanuel Puybaret, Sweet Home 3D creator |
| Posted by boe666 at Nov 21, 2018, 6:04:34 PM |
|
Re: Export HTML5 plug-in Please check my code. Why It not working well ? Initialisation: And console has this after click on the furniture (i have only one): mouseup { target: canvas#viewerCanvas.viewerComponent , buttons: 0, clientX: 390, clientY: 233, layerX: 390, layerY: 233 } viewHome.html:114:8 mouse:390, 233 viewHome.html:118:8 null always is NULL! Can somebody explain why ? What do i wrong ? |
| Posted by boe666 at Nov 28, 2018, 8:32:53 AM |
|
Re: Export HTML5 plug-in Can anyone help ? |
| Posted by boe666 at Nov 28, 2018, 1:28:57 PM |
|
Re: Export HTML5 plug-in You should call the method getClosestItemAt available in HomeComponent3D class in a listener added to the displayed canvas. If the returned object is an instance of HomePieceOfFurniture, then you may call its getCatalogId method to get its catalog ID and do whatever you want. The HomeComponent3D instance is returned by the getComponent3D method available on the object returned by viewHome function. I tried to do it according this post but it is not working at all. I have access to Object'd list, to every variables and function, i studdy the JS API but i can't select any items my mouse, even set getHome().setSelectedItems(["number"]) do nothing (camera not move). I have set setAerialViewCenteredOnSelectionEnabled(true). Can somebody help me to understand what do I wrong ? |
| Posted by Puybaret at Nov 28, 2018, 6:42:55 PM |
|
Re: Export HTML5 plug-in It's difficult to say without a real example. Can't you share a sample page? ---------------------------------------- Emmanuel Puybaret, Sweet Home 3D creator |
| Posted by boe666 at Nov 29, 2018, 9:35:24 AM |
Re: Export HTML5 plug-in<html> |
| Posted by boe666 at Dec 3, 2018, 8:32:24 AM |
|
Re: Export HTML5 plug-in my real example is ok or somebody see there errors. What do I wrong ? |
| Posted by boe666 at Dec 3, 2018, 1:44:47 PM |
|
Re: Export HTML5 plug-in My changed code: var HPC = viewHome("viewerCanvas",I can select item by "finger" (in code), but still i can;t do it by mouse. Please help. |
| Posted by boe666 at Dec 5, 2018, 10:43:28 AM |
|
Re: Export HTML5 plug-in Can sombody Help ? I check the source. Method getClosestItemAt use the canvas3D.getClosestShapeAt. I don't know why it is't working - this object (HPC) has all furniture, selectable from code. |
| Posted by dorin at Dec 5, 2018, 6:46:31 PM |
|
Re: Export HTML5 plug-in I'am not sure but could be a problem of browser rather than coding. Look at this answer ---------------------------------------- A computer program does what you tell it to do, not what you want it to do. Murphy's Law When all else fails, read the instructions. Murphy's Law If you don't like "AS IS", DIY. Dorin's law |
| Posted by Puybaret at Dec 5, 2018, 8:51:56 PM |
|
Re: Export HTML5 plug-in Thanks for trying to help Dorin, but your link points to problems in the Online version, not with the HTML5 viewer version. Anyway, you're not wrong when your speak about browsers, because the viewer could also not work correctly on some browsers (even if I don't hope so). boe666, the most helpful code is the one tested on a real web server with a real SH3D file. So please, upload your failing HTML5 code on a public web server with a SH3D file. You could also use the very good JavaScript debuggers available in all modern browsers, and find what's wrong by yourself. ---------------------------------------- Emmanuel Puybaret, Sweet Home 3D creator |
| Posted by boe666 at Dec 6, 2018, 9:28:20 AM |
|
Re: Export HTML5 plug-in ok. So I clean the code, and put all on this link: http://smarted.pl/sh3d/viewHome.html# As You can see - all object are selectable by code. But not by the mouse. Please check console. Code below: |
| Posted by boe666 at Dec 10, 2018, 10:03:48 AM |
|
Re: Export HTML5 plug-in Can somebody help ? |
| Posted by boe666 at Dec 11, 2018, 8:02:47 AM |
|
Re: Export HTML5 plug-in Ok, so if nobody can help in this situation, maybe sombody can help - how to calculate z dimention and z,y depend of actual camera's position ? Where can I find proper values? |
| Posted by Puybaret at Dec 11, 2018, 10:16:41 AM |
|
Re: Export HTML5 plug-in I tried your program in Safari debugger and the object returned at the line var obj = HPC.getComponent3D().getClosestItemAt(x, y);You should really learn how to use a JavaScript debugger. ---------------------------------------- Emmanuel Puybaret, Sweet Home 3D creator |
| Posted by boe666 at Dec 11, 2018, 11:31:56 AM |
|
Re: Export HTML5 plug-in I understand my mistake, but can You show me how i can translate them in canvas space ? Maybe some links ? |
| Posted by boe666 at Dec 11, 2018, 12:45:08 PM |
|
Re: Export HTML5 plug-in I'm trying to understand this, i think it's depend on camera position (before i think the getClosestItemAt calculate this automaticaly) but without any examples i don't know how to start. |
| Posted by Puybaret at Dec 11, 2018, 1:04:07 PM |
|
Re: Export HTML5 plug-in I wrote you how to fix your issue. Sorry, I can't help you more, it's really basic JavaScript. ---------------------------------------- Emmanuel Puybaret, Sweet Home 3D creator |
| Posted by boe666 at Dec 11, 2018, 1:24:46 PM |
|
Re: Export HTML5 plug-in so, if I understand this proper. I have to translate x,y coordinates (given from flat rectangle) to coordinates in the actual perspective of my model's floor. After this, method getClosestItemAt fill return objects. Am I Correct ? |
| Posted by boe666 at Dec 11, 2018, 2:35:58 PM |
|
Re: Export HTML5 plug-in Can I check this getClosestItemAt method ? Where is object's coordinates ? If I write x an y direct in code - this method still return null. I take x y coordinates from js console after selected object by code. i.e.: selecting object: and I take x y from itemSel[0].x and itemSel[0].y I write this to my listener (from now always return this coordinates), and still i have null after use getClosestItemAt(x,y). I thought i have to translate x,y from mouse, to have always the same coordinates, independed from actual view of camera, coresponding with object's x and y. |
| Posted by boe666 at Dec 11, 2018, 3:00:19 PM |
|
Re: Export HTML5 plug-in Or maybe this is the problem. Shown after click on canvas. |
| Posted by Puybaret at Dec 11, 2018, 4:00:59 PM |
|
Re: Export HTML5 plug-in The problem is that you read too quickly the setSelectedItems jsdoc ![]() ---------------------------------------- Emmanuel Puybaret, Sweet Home 3D creator |
| Posted by boe666 at Dec 11, 2018, 5:13:27 PM |
|
Re: Export HTML5 plug-in I don't understand. First of all I read all furnitures to table (FURNITURES[]). After this i print the links to select every funriture ( from this table). After click i do this: every furniture has his own x and y coordinates. In console I have all object (with many data) in room (every furniture) after console.log(FURNITURES); This is not problem with to fast reading. How can I read proper x and y for one furniture ? (to check getClosestItemsAt) |
| Posted by boe666 at Dec 12, 2018, 8:17:16 AM |
|
Re: Export HTML5 plug-in Maybe my questions are stupid and for many of You - "groundless", but I realy want understand structure of sweethome3d (in HTML5). Most (in my opinion - almost all) posts on this forum concerns on java version and problems with aplication ( directly on "painting" models). Can you show me the way to do this ? For example - if I confirm what x,y coordinates work with getClosestItemsAt, I will find the way how to calculate x,y depend of actual camera view. I want to eliminate errors before I started, I want to be sure I'm not making a simple mistake. |
| Posted by Puybaret at Dec 12, 2018, 6:16:00 PM |
|
Re: Export HTML5 plug-in Your questions are not stupid, but most contributors in the forum are Sweet Home 3D users, not programmers (and even less JavaScript programmers). If you want to understand how to use Sweet Home 3D JS, learn how to use the debugger in your browser, this will help you in many cases. By the way, getClosestItemsAt method takes in parameter 2D coordinates, so translating to canvas space just consist of substracting rect.x and rect.y from e.clientX and e.clientY. Measuring pixel locations at screen with your mouse pointer would have given you the solution... ---------------------------------------- Emmanuel Puybaret, Sweet Home 3D creator |
| Posted by boe666 at Dec 12, 2018, 7:43:57 PM |
|
Re: Export HTML5 plug-in Before I ask and write more question - i checked this - it's not working. I thought i have to recalculate x,y from plain rec to virtual canvas (2d to 3d coordinates - x,y only of course). I was ready to check every x,y combination to check proper work getClosestItemsAt function. I change my code, this part: console after loading: Error: WebGL warning: drawArrays: Drawing to a destination rect smaller than the viewport rect. (This warning will only be given once) viewmodel.min.js:20:53017console after click on canvas: make this errors problem? code is ok ? http://smarted.pl/sh3d/viewHome.html# |
| Posted by boe666 at Dec 15, 2018, 3:28:29 PM |
|
Re: Export HTML5 plug-in somebody can can check the code ? Now it's ok ? If ok, why it not working ? Maybe the errors are the problem ? Ho to eliminate this errors ? |
| Posted by boe666 at Dec 18, 2018, 9:48:14 AM |
|
Re: Export HTML5 plug-in Somebody ???? |
| Posted by boe666 at Jan 3, 2019, 2:07:31 PM |
|
Re: Export HTML5 plug-in Maybe, in first days of new year, somebody show my indolence.. I realy don't know why .getClosestItemAt(x, y) doesn't work.... |
| Posted by Puybaret at Jan 3, 2019, 4:24:38 PM |
|
Re: Export HTML5 plug-in Maybe try another browser, because it seems to work on my side. The console doesn't display null for the obj returned by getClosestItem. ---------------------------------------- Emmanuel Puybaret, Sweet Home 3D creator |
|
|
Current timezone is GMT Dec 16, 2025, 2:27:00 PM |