Ver código fonte

Merge pull request #8282 from BabylonJS/master

Nightly
mergify[bot] 5 anos atrás
pai
commit
1fee42b3e2

+ 6 - 6
dist/preview release/babylon.d.ts

@@ -32647,18 +32647,18 @@ declare module BABYLON {
          */
         static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
         /**
-         * Creates a new animation from a snippet saved in a remote file
+         * Creates a new animation or an array of animations from a snippet saved in a remote file
          * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
          * @param url defines the url to load from
-         * @returns a promise that will resolve to the new animation
+         * @returns a promise that will resolve to the new animation or an array of animations
          */
-        static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation>;
+        static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
         /**
-         * Creates an animation from a snippet saved by the Inspector
+         * Creates an animation or an array of animations from a snippet saved by the Inspector
          * @param snippetId defines the snippet to load
-         * @returns a promise that will resolve to the new animation
+         * @returns a promise that will resolve to the new animation or a new array of animations
          */
-        static CreateFromSnippetAsync(snippetId: string): Promise<Animation>;
+        static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
     }
 }
 declare module BABYLON {

Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
dist/preview release/babylon.js


+ 54 - 26
dist/preview release/babylon.max.js

@@ -4371,10 +4371,10 @@ var Animation = /** @class */ (function () {
         _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"].AppendSerializedAnimations(source, destination);
     };
     /**
-     * Creates a new animation from a snippet saved in a remote file
+     * Creates a new animation or an array of animations from a snippet saved in a remote file
      * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
      * @param url defines the url to load from
-     * @returns a promise that will resolve to the new animation
+     * @returns a promise that will resolve to the new animation or an array of animations
      */
     Animation.ParseFromFileAsync = function (name, url) {
         var _this = this;
@@ -4384,11 +4384,21 @@ var Animation = /** @class */ (function () {
                 if (request.readyState == 4) {
                     if (request.status == 200) {
                         var serializationObject = JSON.parse(request.responseText);
-                        var output = _this.Parse(serializationObject);
-                        if (name) {
-                            output.name = name;
+                        if (serializationObject.length) {
+                            var output = new Array();
+                            for (var _i = 0, serializationObject_1 = serializationObject; _i < serializationObject_1.length; _i++) {
+                                var serializedAnimation = serializationObject_1[_i];
+                                output.push(_this.Parse(serializedAnimation));
+                            }
+                            resolve(output);
+                        }
+                        else {
+                            var output = _this.Parse(serializationObject);
+                            if (name) {
+                                output.name = name;
+                            }
+                            resolve(output);
                         }
-                        resolve(output);
                     }
                     else {
                         reject("Unable to load the animation");
@@ -4400,9 +4410,9 @@ var Animation = /** @class */ (function () {
         });
     };
     /**
-     * Creates an animation from a snippet saved by the Inspector
+     * Creates an animation or an array of animations from a snippet saved by the Inspector
      * @param snippetId defines the snippet to load
-     * @returns a promise that will resolve to the new animation
+     * @returns a promise that will resolve to the new animation or a new array of animations
      */
     Animation.CreateFromSnippetAsync = function (snippetId) {
         var _this = this;
@@ -4412,10 +4422,21 @@ var Animation = /** @class */ (function () {
                 if (request.readyState == 4) {
                     if (request.status == 200) {
                         var snippet = JSON.parse(JSON.parse(request.responseText).jsonPayload);
-                        var serializationObject = JSON.parse(snippet.animation);
-                        var output = _this.Parse(serializationObject);
-                        output.snippetId = snippetId;
-                        resolve(output);
+                        if (snippet.animations) {
+                            var serializationObject = JSON.parse(snippet.animations);
+                            var output = new Array();
+                            for (var _i = 0, serializationObject_2 = serializationObject; _i < serializationObject_2.length; _i++) {
+                                var serializedAnimation = serializationObject_2[_i];
+                                output.push(_this.Parse(serializedAnimation));
+                            }
+                            resolve(output);
+                        }
+                        else {
+                            var serializationObject = JSON.parse(snippet.animation);
+                            var output = _this.Parse(serializationObject);
+                            output.snippetId = snippetId;
+                            resolve(output);
+                        }
                     }
                     else {
                         reject("Unable to load the snippet " + snippetId);
@@ -117011,22 +117032,24 @@ function decodeMesh(decoderModule, dataView, attributes, onIndicesData, onAttrib
             try {
                 decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
                 var numComponents = attribute.num_components();
-                if (kind === "color" && numComponents === 3) {
-                    var babylonData = new Float32Array(numPoints_1 * 4);
-                    for (var i = 0, j = 0; i < babylonData.length; i += 4, j += numComponents) {
-                        babylonData[i + 0] = dracoData.GetValue(j + 0);
-                        babylonData[i + 1] = dracoData.GetValue(j + 1);
-                        babylonData[i + 2] = dracoData.GetValue(j + 2);
-                        babylonData[i + 3] = 1;
+                if (numComponents) {
+                    if (kind === "color" && numComponents === 3) {
+                        var babylonData = new Float32Array(numPoints_1 * 4);
+                        for (var i = 0, j = 0; i < babylonData.length; i += 4, j += numComponents) {
+                            babylonData[i + 0] = dracoData.GetValue(j + 0);
+                            babylonData[i + 1] = dracoData.GetValue(j + 1);
+                            babylonData[i + 2] = dracoData.GetValue(j + 2);
+                            babylonData[i + 3] = 1;
+                        }
+                        onAttributeData(kind, babylonData);
                     }
-                    onAttributeData(kind, babylonData);
-                }
-                else {
-                    var babylonData = new Float32Array(numPoints_1 * numComponents);
-                    for (var i = 0; i < babylonData.length; i++) {
-                        babylonData[i] = dracoData.GetValue(i);
+                    else {
+                        var babylonData = new Float32Array(numPoints_1 * numComponents);
+                        for (var i = 0; i < babylonData.length; i++) {
+                            babylonData[i] = dracoData.GetValue(i);
+                        }
+                        onAttributeData(kind, babylonData);
                     }
-                    onAttributeData(kind, babylonData);
                 }
             }
             finally {
@@ -127318,6 +127341,8 @@ __webpack_require__.r(__webpack_exports__);
 /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
 /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
 /* harmony import */ var _Maths_math_color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math.color */ "./Maths/math.color.ts");
+/* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
+
 
 
 
@@ -127334,6 +127359,9 @@ var VertexData = /** @class */ (function () {
      * @param kind the type of data that is being set, eg positions, colors etc
      */
     VertexData.prototype.set = function (data, kind) {
+        if (!data.length) {
+            _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Setting vertex data kind '" + kind + "' with an empty array");
+        }
         switch (kind) {
             case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind:
                 this.positions = data;

Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
dist/preview release/babylon.max.js.map


+ 12 - 12
dist/preview release/babylon.module.d.ts

@@ -33764,18 +33764,18 @@ declare module "babylonjs/Animations/animation" {
          */
         static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
         /**
-         * Creates a new animation from a snippet saved in a remote file
+         * Creates a new animation or an array of animations from a snippet saved in a remote file
          * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
          * @param url defines the url to load from
-         * @returns a promise that will resolve to the new animation
+         * @returns a promise that will resolve to the new animation or an array of animations
          */
-        static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation>;
+        static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
         /**
-         * Creates an animation from a snippet saved by the Inspector
+         * Creates an animation or an array of animations from a snippet saved by the Inspector
          * @param snippetId defines the snippet to load
-         * @returns a promise that will resolve to the new animation
+         * @returns a promise that will resolve to the new animation or a new array of animations
          */
-        static CreateFromSnippetAsync(snippetId: string): Promise<Animation>;
+        static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
     }
 }
 declare module "babylonjs/Animations/animatable.interface" {
@@ -110163,18 +110163,18 @@ declare module BABYLON {
          */
         static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
         /**
-         * Creates a new animation from a snippet saved in a remote file
+         * Creates a new animation or an array of animations from a snippet saved in a remote file
          * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
          * @param url defines the url to load from
-         * @returns a promise that will resolve to the new animation
+         * @returns a promise that will resolve to the new animation or an array of animations
          */
-        static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation>;
+        static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
         /**
-         * Creates an animation from a snippet saved by the Inspector
+         * Creates an animation or an array of animations from a snippet saved by the Inspector
          * @param snippetId defines the snippet to load
-         * @returns a promise that will resolve to the new animation
+         * @returns a promise that will resolve to the new animation or a new array of animations
          */
-        static CreateFromSnippetAsync(snippetId: string): Promise<Animation>;
+        static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
     }
 }
 declare module BABYLON {

+ 6 - 6
dist/preview release/documentation.d.ts

@@ -32647,18 +32647,18 @@ declare module BABYLON {
          */
         static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
         /**
-         * Creates a new animation from a snippet saved in a remote file
+         * Creates a new animation or an array of animations from a snippet saved in a remote file
          * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
          * @param url defines the url to load from
-         * @returns a promise that will resolve to the new animation
+         * @returns a promise that will resolve to the new animation or an array of animations
          */
-        static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation>;
+        static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
         /**
-         * Creates an animation from a snippet saved by the Inspector
+         * Creates an animation or an array of animations from a snippet saved by the Inspector
          * @param snippetId defines the snippet to load
-         * @returns a promise that will resolve to the new animation
+         * @returns a promise that will resolve to the new animation or a new array of animations
          */
-        static CreateFromSnippetAsync(snippetId: string): Promise<Animation>;
+        static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
     }
 }
 declare module BABYLON {

+ 1 - 1
dist/preview release/packagesSizeBaseLine.json

@@ -1 +1 @@
-{"thinEngineOnly":116011,"engineOnly":152414,"sceneOnly":505526,"minGridMaterial":648479,"minStandardMaterial":791757}
+{"thinEngineOnly":116011,"engineOnly":152414,"sceneOnly":505608,"minGridMaterial":648561,"minStandardMaterial":791839}

+ 12 - 12
dist/preview release/viewer/babylon.module.d.ts

@@ -33764,18 +33764,18 @@ declare module "babylonjs/Animations/animation" {
          */
         static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
         /**
-         * Creates a new animation from a snippet saved in a remote file
+         * Creates a new animation or an array of animations from a snippet saved in a remote file
          * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
          * @param url defines the url to load from
-         * @returns a promise that will resolve to the new animation
+         * @returns a promise that will resolve to the new animation or an array of animations
          */
-        static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation>;
+        static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
         /**
-         * Creates an animation from a snippet saved by the Inspector
+         * Creates an animation or an array of animations from a snippet saved by the Inspector
          * @param snippetId defines the snippet to load
-         * @returns a promise that will resolve to the new animation
+         * @returns a promise that will resolve to the new animation or a new array of animations
          */
-        static CreateFromSnippetAsync(snippetId: string): Promise<Animation>;
+        static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
     }
 }
 declare module "babylonjs/Animations/animatable.interface" {
@@ -110163,18 +110163,18 @@ declare module BABYLON {
          */
         static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
         /**
-         * Creates a new animation from a snippet saved in a remote file
+         * Creates a new animation or an array of animations from a snippet saved in a remote file
          * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
          * @param url defines the url to load from
-         * @returns a promise that will resolve to the new animation
+         * @returns a promise that will resolve to the new animation or an array of animations
          */
-        static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation>;
+        static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
         /**
-         * Creates an animation from a snippet saved by the Inspector
+         * Creates an animation or an array of animations from a snippet saved by the Inspector
          * @param snippetId defines the snippet to load
-         * @returns a promise that will resolve to the new animation
+         * @returns a promise that will resolve to the new animation or a new array of animations
          */
-        static CreateFromSnippetAsync(snippetId: string): Promise<Animation>;
+        static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
     }
 }
 declare module BABYLON {

Diferenças do arquivo suprimidas por serem muito extensas
+ 3 - 3
dist/preview release/viewer/babylon.viewer.js


Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


+ 2 - 1
dist/preview release/what's new.md

@@ -213,7 +213,8 @@
 - Fix bug when using `ShadowOnlyMaterial` with Cascaded Shadow Map and `autoCalcDepthBounds` is `true` ([Popov72](https://github.com/Popov72))
 - Fix OBJ serializer default scene scene handedness causing [OBJ Mirror export](https://forum.babylonjs.com/t/obj-export-mirrored/10835/10)
 - Fix bug when using shadows + instances + transparent meshes + `transparencyShadow = false` ([Popov72](https://github.com/Popov72))
-- Incorrect initialization when reattaching XR pointer selection ([#8227](https://github.com/BabylonJS/Babylon.js/issues/8227)) ([RaananW](https://github.com/RaananW))
+- Incorrect initialization when reattaching XR pointer selection  ([#8227](https://github.com/BabylonJS/Babylon.js/issues/8227)) ([RaananW](https://github.com/RaananW))
+- Fixed `DracoCompression` to not load empty data into attributes ([bghgary](https://github.com/bghgary))
 
 ## Breaking changes
 

+ 36 - 15
src/Animations/animation.ts

@@ -1219,12 +1219,12 @@ export class Animation {
     }
 
     /**
-     * Creates a new animation from a snippet saved in a remote file
+     * Creates a new animation or an array of animations from a snippet saved in a remote file
      * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
      * @param url defines the url to load from
-     * @returns a promise that will resolve to the new animation
+     * @returns a promise that will resolve to the new animation or an array of animations
      */
-    public static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation> {
+    public static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>> {
 
         return new Promise((resolve, reject) => {
             var request = new WebRequest();
@@ -1232,13 +1232,23 @@ export class Animation {
                 if (request.readyState == 4) {
                     if (request.status == 200) {
                         let serializationObject = JSON.parse(request.responseText);
-                        let output = this.Parse(serializationObject);
 
-                        if (name) {
-                            output.name = name;
-                        }
+                        if (serializationObject.length) {
+                            let output = new Array<Animation>();
+                            for (var serializedAnimation of serializationObject) {
+                                output.push(this.Parse(serializedAnimation));
+                            }
+
+                            resolve(output);
+                        } else {
+                            let output = this.Parse(serializationObject);
 
-                        resolve(output);
+                            if (name) {
+                                output.name = name;
+                            }
+
+                            resolve(output);
+                        }
                     } else {
                         reject("Unable to load the animation");
                     }
@@ -1251,23 +1261,34 @@ export class Animation {
     }
 
     /**
-     * Creates an animation from a snippet saved by the Inspector
+     * Creates an animation or an array of animations from a snippet saved by the Inspector
      * @param snippetId defines the snippet to load
-     * @returns a promise that will resolve to the new animation
+     * @returns a promise that will resolve to the new animation or a new array of animations
      */
-    public static CreateFromSnippetAsync(snippetId: string): Promise<Animation> {
+    public static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>> {
         return new Promise((resolve, reject) => {
             var request = new WebRequest();
             request.addEventListener("readystatechange", () => {
                 if (request.readyState == 4) {
                     if (request.status == 200) {
                         var snippet = JSON.parse(JSON.parse(request.responseText).jsonPayload);
-                        let serializationObject = JSON.parse(snippet.animation);
-                        let output = this.Parse(serializationObject);
 
-                        output.snippetId = snippetId;
+                        if (snippet.animations) {
+                            let serializationObject = JSON.parse(snippet.animations);
+                            let output = new Array<Animation>();
+                            for (var serializedAnimation of serializationObject) {
+                                output.push(this.Parse(serializedAnimation));
+                            }
 
-                        resolve(output);
+                            resolve(output);
+                        } else {
+                            let serializationObject = JSON.parse(snippet.animation);
+                            let output = this.Parse(serializationObject);
+
+                            output.snippetId = snippetId;
+
+                            resolve(output);
+                        }
                     } else {
                         reject("Unable to load the snippet " + snippetId);
                     }

+ 16 - 14
src/Meshes/Compression/dracoCompression.ts

@@ -72,22 +72,24 @@ function decodeMesh(decoderModule: any, dataView: ArrayBufferView, attributes: {
             try {
                 decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
                 const numComponents = attribute.num_components();
-                if (kind === "color" && numComponents === 3) {
-                    const babylonData = new Float32Array(numPoints * 4);
-                    for (let i = 0, j = 0; i < babylonData.length; i += 4, j += numComponents) {
-                        babylonData[i + 0] = dracoData.GetValue(j + 0);
-                        babylonData[i + 1] = dracoData.GetValue(j + 1);
-                        babylonData[i + 2] = dracoData.GetValue(j + 2);
-                        babylonData[i + 3] = 1;
+                if (numComponents) {
+                    if (kind === "color" && numComponents === 3) {
+                        const babylonData = new Float32Array(numPoints * 4);
+                        for (let i = 0, j = 0; i < babylonData.length; i += 4, j += numComponents) {
+                            babylonData[i + 0] = dracoData.GetValue(j + 0);
+                            babylonData[i + 1] = dracoData.GetValue(j + 1);
+                            babylonData[i + 2] = dracoData.GetValue(j + 2);
+                            babylonData[i + 3] = 1;
+                        }
+                        onAttributeData(kind, babylonData);
                     }
-                    onAttributeData(kind, babylonData);
-                }
-                else {
-                    const babylonData = new Float32Array(numPoints * numComponents);
-                    for (let i = 0; i < babylonData.length; i++) {
-                        babylonData[i] = dracoData.GetValue(i);
+                    else {
+                        const babylonData = new Float32Array(numPoints * numComponents);
+                        for (let i = 0; i < babylonData.length; i++) {
+                            babylonData[i] = dracoData.GetValue(i);
+                        }
+                        onAttributeData(kind, babylonData);
                     }
-                    onAttributeData(kind, babylonData);
                 }
             }
             finally {

+ 5 - 0
src/Meshes/mesh.vertexData.ts

@@ -3,6 +3,7 @@ import { Matrix, Vector3, Vector2, Vector4 } from "../Maths/math.vector";
 import { VertexBuffer } from "../Meshes/buffer";
 import { _DevTools } from '../Misc/devTools';
 import { Color4, Color3 } from '../Maths/math.color';
+import { Logger } from '../Misc/logger';
 
 declare type Geometry = import("../Meshes/geometry").Geometry;
 declare type Mesh = import("../Meshes/mesh").Mesh;
@@ -171,6 +172,10 @@ export class VertexData {
      * @param kind the type of data that is being set, eg positions, colors etc
      */
     public set(data: FloatArray, kind: string) {
+        if (!data.length) {
+            Logger.Warn(`Setting vertex data kind '${kind}' with an empty array`);
+        }
+
         switch (kind) {
             case VertexBuffer.PositionKind:
                 this.positions = data;