jscastro76 / threebox

A Three.js plugin for Mapbox GL JS, with support for animations and advanced 3D rendering.
Other
549 stars 145 forks source link

Modified scale resets after dragging/rotating model #427

Open dariuslung opened 1 month ago

dariuslung commented 1 month ago

Describe the bug I am trying to modify the scale of a model in realtime, so I resorted to obj.set({scale: [x, y, z]}) and it does work as long as I don't drag or rotate the model. Otherwise it gets reset to the original value.

To Reproduce Steps to reproduce the behavior:

  1. Add a model to threebox
  2. Manually override the scale with obj.set() or obj.scale.set()
  3. Drag or rotate the model
  4. Scale gets reset

Expected behavior Scale should stay as set?

Relevant Code

const step = 0.1;
window.addEventListener('keydown', function (event) {
    switch (event.key) {
        case '+':
        case '=':
            // PROBLEM Resets upon moving/rotating
            curScale.x += step;
            curScale.y += step;
            curScale.z += step;
            myModel.set({ scale: [curScale.x, curScale.y, curScale.z]});
            console.log(curScale);
            tb.map.repaint = true;
            break;
        case '-':
        case '_':
            curScale.x -= step;
            curScale.y -= step;
            curScale.z -= step;
            myModel.set({ scale: [curScale.x, curScale.y, curScale.z]});
            console.log(curScale);
            tb.map.repaint = true;
            break;
    }
});