onclick="addHotspot()" #1890
Replies: 19 comments
-
@JonasBlazin It looks like you copied from our interactive example page which is not the simplest version of model-viewer to get started with. It also uses extra dependencies for functions like addHotspot(). If you want to get started with hotspots, I'd recommend you start from the annotations page of our docs. Our interactive example page is there to help you find the right values for your |
Beta Was this translation helpful? Give feedback.
-
But I am specifically after addHotspot() functionality as is in the interactive example. As I want people to be able to dynamically add hotspots with a click of a button. Is there a way to gain access to these dependencies? |
Beta Was this translation helpful? Give feedback.
-
@JonasBlazin Ah, then you'll want to copy the relevant parts of that function, including the onClick method a few lines down. |
Beta Was this translation helpful? Give feedback.
-
I am still highly confused as to how to get this to work. I had followed the instructions on github on how to install all dependencies: git clone git@github.com:google/model-viewer.git What am I doing wrong? Apologies about dumb questions but this is my first go in more complex issues past html/css. |
Beta Was this translation helpful? Give feedback.
-
@JonasBlazin No problem, we're here to help. And no need to close the issue; others will probably have similar questions down the road. You look to be following the developer instructions, but that shouldn't be necessary unless you want to contribute to model-viewer. Instead of serving locally, I'd recommend building a Glitch, perhaps remixing our example. That way it's easy to share here and I can see all the files involved. You'll want to add a bit of script to handle your button's click event. You can see small script examples toward the bottom of our animations example, but you'll want a function more along the lines of the link I gave you above. The key is calling the |
Beta Was this translation helpful? Give feedback.
-
Ok here is a "remix" that I made. I have added the button with addHotspot() and removeHotspot(). And I have trimmed down tester.ts to what I think is relevant for the add/removeHotspot() which I called hotspot.ts. and on html I called it with <script> src="hotspot.ts"</script> not sure if it being on the very end of the html is working against me or not. And I'll shoot in the dark here with the level of knowledge I have. But I will make a learning guess and say that the initial part of hotspot.ts is the problem where it is importing some sort of dependencies?
Let me know if I am heading in the right direction, what mistakes am I making and what should be my next step https://glitch.com/edit/#!/join/80207261-0bbb-4e71-bfb6-95f4862b522e Thank you for your help so much! I was starting to lose hope today, so the help is greatly appreciated. |
Beta Was this translation helpful? Give feedback.
-
Just realised that I need to add id="loading-demo" to the mode;-viewer as it is being called in the hotspot.ts |
Beta Was this translation helpful? Give feedback.
-
The first step is you're not using TypeScript like we do internally, so you'll want to change |
Beta Was this translation helpful? Give feedback.
-
Make sure to check the JS console in Chrome dev tools; that should help you work through errors you encounter. |
Beta Was this translation helpful? Give feedback.
-
Out of curiosity how come you guys use .ts ? |
Beta Was this translation helpful? Give feedback.
-
We build our project internally using TypeScript, which is very similar to JavaScript, but requires a compilation step to output true js. It is helpful for a large project like this because it gives us strong type-safety, allowing its compiler to catch a lot of errors before we even get to testing. |
Beta Was this translation helpful? Give feedback.
-
Does it mean that the whole hotspot.ts needs to re-written in a syntax closer to .js or is it just export functions? If so could one use a compiler to turn it into .js? |
Beta Was this translation helpful? Give feedback.
-
Ts and js syntax are nearly identical, so start with just copying. The
console should help if there are any remaining issues. If you’re new to js,
you may want to start by modifying one of our simpler script examples to
get comfortable.
…On Tue, Jun 2, 2020 at 12:27 PM JonasBlazin ***@***.***> wrote:
Does it mean that the whole hotspot.ts needs to re-written in a syntax
closer to .js or is it just export functions? If so could one use a
compiler to turn it into .js?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1233 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMS2LCGVBJRSND3SEVHTQ3RUVHCDANCNFSM4NNI5FKQ>
.
|
Beta Was this translation helpful? Give feedback.
-
has there been any more information on how to add annotations on click since then, because i am stuck at the same problem where there are some file imported like Is there any link where i can find some more information on how to do this? i have been searching but haven't found anything usefull. |
Beta Was this translation helpful? Give feedback.
-
@sietsenefs We haven't made an example of this yet because we didn't think it was a common use case, and requires a bit more JS knowledge than many of our users care to deal with. May I ask what you're using this for? The trouble is you're trying to use our Github sources as examples, but they are compiled differently. You'll want to use our actual API documentation, connecting our annotations example to our |
Beta Was this translation helpful? Give feedback.
-
@elalish we want to use this so the 3d models we make can be uploaded to our site then clients would be able to create annotations on the models with feedback (which would be extremely helpful to actually be on the piece of the model that it corresponds with) I then want those annotations to be permanently there (with php) so our 3d designers can go to the site see what feedback got added where and they can change the models. This is a feature that would be really helpful for us so I will try to do some more research on the |
Beta Was this translation helpful? Give feedback.
-
I think you're basically looking for a function like this:
where |
Beta Was this translation helpful? Give feedback.
-
@sietsenefs If you can share your project when it's working, I'd love to see it. Feel free to @modelviewer on Twitter and we can help spread the word. |
Beta Was this translation helpful? Give feedback.
-
@elalish The whole project is not nearly done but for some other people maybe trying to get the same thing working I made a git repository with this functionality add annotations in model viewer (one with and one without custom text you can put in) thanks for helping me with it! |
Beta Was this translation helpful? Give feedback.
-
<button onclick="addHotspot()">Add Hotspot</button><br>
I can't seem to get this to work, is there a specific .js script that it needs? I seem to have copied all of the js scripts with in the example model.
Beta Was this translation helpful? Give feedback.
All reactions