Skip to content

Making Hotspots adapt to scale #4988

Closed Answered by ewajs
ewajs asked this question in Q&A
Discussion options

You must be logged in to vote

Ok, I've solved it. As always the issue was behind the keyboard.

I'll share my approach here in case it is useful for someone, assume the model-viewer starts without any scale (1 1 1):

  1. On load, store the models original dimensions: modelViewer.getDimensions()
const originalDimensions = modelViewer.getDimensions();
  1. Add a hotspot using positionAndNormalFromPoint.
// e is a click event of a click handler
const {position, normal} = modelViewer.positionAndNormalFromPoint(e.clientX, e.clientY);
  1. Store it's position relative to the original dimensions and current scale:
function getScale(modelViewer) {
        const scaleArray = modelViewer.scale.split(' ').map(parseFloat);
        return { x

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ewajs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant