1
$\begingroup$

I have a project going and it consists of everything sitting still and two animations. I see that animated textures do not work with gltf so I decided to get each image into a separate panel and animate each one to move back to reveal the next thus giving the illusion of an animated texture. However I've been spending countless hours trying to get them to play properly when its exported as a gltf or glb. In blender I can move the timeline and the animation plays and when I do play it it works just fine. Each panel moves back like its supposed to and the animation looks right. But when exported, I'm using the standard Microsoft 3d viewer and when the animation plays, the first panel moves revealing the last panel and the rest of the animation cannot be seen. Any idea as to what I'm doing wrong or how to get this to work?

Here is a link to the blender file: https://www.mediafire.com/file/zn7ck87i0u7o18d/NOUNS.zip/file

$\endgroup$

1 Answer 1

2
$\begingroup$

When you have a stack of planes on the exact same X coordinate, apparently in Blender the first one (in outliner order) shows through, but in glTF viewers the last one seems to show through. This seems to be the reason for the difference you see.

You shouldn't put the visible planes on the same X coordinate since there's no way to really tell which one should be in front.

Instead, one plane should be in the front position and all the others should be in the back position. When it's time for the screen to change, the current plane should move to the back position, and the next screen should move to the front position.

Like this. Watch the selected plane (green border).

Selected plane is in back, then comes to front to become visible, then goes back to the back

Here's a script you can run that should fix up the .blend you attached to do this.

import bpy

# Number of frames to show each image
duration = 10

# X position of plane when it's in the front
x_front = -2.19

# X position of the plane when it's in the back
x_back = -2.33

# Fix inconsistent name for 1scr
if "1scr" in bpy.data.objects:
    bpy.data.objects["1scr"].name = "1src"

# Remove 18src, it's a copy of 1src
if "18src" in bpy.data.objects:
    bpy.data.objects.remove(bpy.data.objects["18src"])

last_n = 17
for n in range(1, last_n + 1):
    name = "%dsrc" % n
    ob = bpy.data.objects[name]
    action_name = ob.name + "Action"

    # Clear out existing animations
    ob.animation_data_clear()
    if action_name in bpy.data.actions:
        bpy.data.actions.remove(bpy.data.actions[action_name])

    action = bpy.data.actions.new(action_name)
    action.id_root = 'OBJECT'
    fc = action.fcurves.new(
        data_path="location",
        index=0,
        action_group="Location",
    )

    pts = []
    f = (n-1)*duration
    if n != 1: pts += [0, x_back]
    pts += [f, x_front]
    if n != last_n: pts += [f + duration, x_back]
    elif duration > 0: pts += [f + duration - 1, x_front]

    fc.keyframe_points.add(len(pts) // 2)
    fc.keyframe_points.foreach_set("co", pts)
    for pt in fc.keyframe_points: pt.interpolation = 'CONSTANT'

    # Push to NLA track
    ob.animation_data_create()
    track = ob.animation_data.nla_tracks.new(prev=None)
    track.name = "Bid"
    track.strips.new(action.name, 0, action)
    track.mute = True
    track.is_solo = True
$\endgroup$
1
  • $\begingroup$ Thank you so much! It helped alot! $\endgroup$
    – Walter
    Aug 26, 2021 at 17:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .