# Babylon Playground strange behavior

**URL:** <https://forum.babylonjs.com/t/babylon-playground-strange-behavior/25157>\
**Category:** Questions\
**Tags:** playground\
**Created:** [November 10, 2021, 4:59pm UTC](https://forum.babylonjs.com/t/babylon-playground-strange-behavior/25157 "2021-11-10T16:59:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Clement](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/clement/32/19707_2.png) [@Clement](https://forum.babylonjs.com/u/Clement)\
**Post date:** [November 10, 2021, 4:59pm UTC](https://forum.babylonjs.com/t/babylon-playground-strange-behavior/25157/1 "2021-11-10T16:59:19Z")

</div>

Hi guys,

I’m very new to BabylonJS, and I’ve been experimenting since a few days… this is my first post here 🙂

I have a problem with animations, and tried to make a Babylon Playground demo to explain what I’m trying to do to you guys, and ask for enlightment.

But I’m having problems on the Playground wayyyyyy before having finished my demo and being able to ask for help about animations ☹

The playground is here : [https://playground.babylonjs.com/#WGZLGJ#3897](https://playground.babylonjs.com/#WGZLGJ#3897)

It seems to be working in the state I put it, BUT, if you uncomment any of the following lines :

- anim\_sticker\_come = animationGroups[0];
- anim\_sticker\_go = animationGroups[1];
- skeleton = skeletons[0];

It will stop working… It’s working locally though, so I don’t really understand what happens.  
Any idea ? I think I’m missing something pretty big for my very basic demo to fail so early ?

And other questions related to this basic example :

- locally, I used “ImportMesh” instead of “Append”, and it works. In the playground, it doesn’t. Know why ?
- how come I get a message “You must at least create a camera” when there’s already a camera in the scene ?
- if I add “const scene = createScene();” below my current code, I get an error “r.initFunction is not a function”

I really think I misunderstood something big, it seems a lot of things are working locally, but not on the playground 😕

Thanks for your help guys !

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [November 10, 2021, 7:16pm UTC](https://forum.babylonjs.com/t/babylon-playground-strange-behavior/25157/2 "2021-11-10T19:16:25Z")

</div>

importMesh and Append do not have the same callback one will have meshes in it and the other a scene object.

I d advise not indexing in the result but using scene.getMeshById(…) in your callback so no more issues 🙂

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [November 10, 2021, 8:12pm UTC](https://forum.babylonjs.com/t/babylon-playground-strange-behavior/25157/3 "2021-11-10T20:12:05Z")

</div>

ImportMesh callback [SceneLoader | Babylon.js Documentation (babylonjs.com)](https://doc.babylonjs.com/typedoc/classes/babylon.sceneloader#importmesh): its arguments are meshes, particleSystems, animationGroups, etc…  
Append callback [SceneLoader | Babylon.js Documentation (babylonjs.com)](https://doc.babylonjs.com/typedoc/classes/babylon.sceneloader#append) only has the scene as argument.

As Seb mentioned, to access the objects from the scene, you can use getYYYbyId series of functions.

For the camera bit, you have to keep in mind that the function called on ImportMesh/Append is a _callback_, which means it will only execute once the model is loaded. That means that the scene returned by createScene doesn’t have a camera at its moment of creation, only a while after once the mesh is loaded. A solution in this case would be to move the `createDefaultCameraOrLight` to outside the callback.

And for the last point, it’s not needed to call the `createScene` function on the playground, only define it. The playground takes care of the rest. 🙂

Here’s a fixed version of the playground (noticed the variables didn’t have keywords also, don’t forget this part!): [glTF Loader Demo | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#WGZLGJ#3899)

If you have any other questions, don’t hesitate to ask. 😃

---

<div class="post-metadata">

**Author:** ![Clement](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/clement/32/19707_2.png) [@Clement](https://forum.babylonjs.com/u/Clement)\
**Post date:** [November 15, 2021, 12:11pm UTC](https://forum.babylonjs.com/t/babylon-playground-strange-behavior/25157/4 "2021-11-15T12:11:14Z")

</div>

Understood ! Thanks for your help 🙂  
The question I was initially here for was about animations (more precisely : how to play only a small part of an imported skeleton animation), but I think I figured it out ! I just didn’t understand at first that the range of the animation wasn’t the same in the gbl file than in my 3Ds max scene, I was trying to play frames 75 → 100, because the animation is 100 frames long in 3ds max, but I then noticed when opening my file in the sandbox, that the animation was only 1.6 frames long here 🙂

My final goal is to control animation with the page scroll, and not time, I’ll let you know (in an other thread) if I bump in other issues in the journey 😉

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [November 16, 2021, 1:11pm UTC](https://forum.babylonjs.com/t/babylon-playground-strange-behavior/25157/5 "2021-11-16T13:11:30Z")

</div>

That’s a pretty interesting project, do keep us updated with any questions and cool results! 😃

---

<div class="post-metadata">

**Author:** ![Clement](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/clement/32/19707_2.png) [@Clement](https://forum.babylonjs.com/u/Clement)\
**Post date:** [February 21, 2022, 9:14am UTC](https://forum.babylonjs.com/t/babylon-playground-strange-behavior/25157/6 "2022-02-21T09:14:34Z")

</div>

Hi ! I just came accross this post while browsing my babylonjs activity and remembered you asked for update, soooo…

The website is now online, I made a post last week in the Projects category 🙂

[https://forum.babylonjs.com/t/website-with-babylon-animation-on-scroll/27748](https://forum.babylonjs.com/t/website-with-babylon-animation-on-scroll/27748)

Or the website directly : [https://larouget.com/](https://larouget.com/)

Thanks for the help back then 🙂

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [February 21, 2022, 11:19am UTC](https://forum.babylonjs.com/t/babylon-playground-strange-behavior/25157/7 "2022-02-21T11:19:01Z")

</div>

Aaaah it makes me INSANELY HAPPY to see a beautiful finished project like this! 😍

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [February 21, 2022, 9:45pm UTC](https://forum.babylonjs.com/t/babylon-playground-strange-behavior/25157/8 "2022-02-21T21:45:52Z")

</div>

Niceeee and cause I am in France it is mandatory I taste it 🙂

---

<div class="post-metadata">

**Author:** ![Clement](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/clement/32/19707_2.png) [@Clement](https://forum.babylonjs.com/u/Clement)\
**Post date:** [February 22, 2022, 9:13am UTC](https://forum.babylonjs.com/t/babylon-playground-strange-behavior/25157/9 "2022-02-22T09:13:19Z")

</div>

Hehe, good idea 🙂 They’ve got some pretty good beers !  
The common ones, like the blond, are good but not exceptionnal.  
But the uncommon ones are very interesting 🙂
