I need to use the Texture.ForceSerializeBuffers flag for serializing RawTextures and then want to use
SceneSerializer.SerializeAsync as it is recommended. However, for other, regular url textures I get the exception below in the console, probably because the texture is not ready, and texture.getSize() returns 0,0. Here is a PG:
SceneSerializer.Serialize generates the same error.
I actually would not need the base64 encoded texture for those but I do not know how to avoid generating those, per texture.
How would one use SerializeAsync properly ?
babylon.js:16 Uncaught (in promise) DOMException: Failed to execute 'createImageData' on 'CanvasRenderingContext2D': The source width is zero or not a number.
at r (https://preview.babylonjs.com/babylon.js:16:942395)
at o (https://preview.babylonjs.com/babylon.js:16:942805)
at t.serialize (https://preview.babylonjs.com/babylon.js:16:107944)
at Function.e.Serialize (https://preview.babylonjs.com/babylon.js:16:5044)
at t.serialize (https://preview.babylonjs.com/babylon.js:16:495268)
at Function.e._Serialize (https://preview.babylonjs.com/babylon.js:16:3773858)
at Function.e.SerializeAsync (https://preview.babylonjs.com/babylon.js:16:3775326)
at createScene (<anonymous>:38:45)
at window.initFunction (<anonymous>:58:16)
I think I understand what I was missing. The SerializeAsync function is probably not intended to wait for the scene to become ready before serializing although I thought that would be the main reason why serializing should be done asynchronously. Is that about right ? I can use scene.whenReadyAsync() instead before serializing.
( What is the reasoning that _forceSerialize is marked with an underscore (‘private’) ? )