Scripted & node.hide Responding Slowly

Hello - I have a scene that is responding slowly to scripted actions (which is a series of timed “” and “node.hide” to make it look animated in the scene.

I’ve done this exact script in other models (much larger ones) and it’s very smooth, but this one will stop and jump during its progression.

Scene detail:

  • 1.8M Triangles
  • 2.1k Objects
  • 111 Materials
  • 0 Lightmaps
  • 0 Reflection probes

This is significantly less than my other scene which loads and progresses fine (12M Triangles, 3k Objects, 200 Materials).

Any ideas on what could be causing performance to ‘jump’ or ‘skip’ and respond slow in a scene?

Thanks in advance!!

So far, I’ve tried the following but still get jumps/glitches:

  • Shortening the javascript to only the functions.
  • Reduced the number of objects by half.
  • Checked that every model group is ‘editable’ in javascript.
  • No other concurrently running functions.
  • Tried creating a new scene straight from the imported model.
  • Loading and testing the scene online.
  • Tried testing the other bigger model again (still see smooth animation there).

Hi, you’re not using viewer.requestFrame(). The animateOSY method, once I added the viewer.requestFrame() like this:

const currentStep = steps[step];
nodes[currentStep.hide].forEach(node => node.hide());
nodes[].forEach(node =>;
lastTimestamp = timestamp;

stopped having the unpleasant effect of ghosting of the valve.

You need to do this, because Shapespark won’t re-render frame if not needed, so if you’re not moving the camera the animation may get stuck or be very laggy. The animation of the valve looks good if you constantly move the camera while the animation is supposed to play, the problem arises when you just look at it without any movement. The requestFrame tells Shapespark that it needs to render a new Frame where the state of visibility of some nodes may be different.

Alternatively, you could have somewhere a rotating object or animated material like water. That would force Shapespark to re-render frames as their state may change in time. Quite possibly, the reason you didn’t encounter this issue you are now facing is that the previous scene has an animated object and was forcing the constant re-rendering of frames. An object that can be rotated without any noticeable differences can be **{Epoxy}Sleeve - 12 inch - Adaptive : Sleeve - 12 inch - Adaptive**. If you set the object rotation for it then the requestFrame shouldn’t be necessary.

I hope this solves your issue!

1 Like

It does, amazing! Thank you so much. I’m extremely impressed.

Thank you for your help!