David Catuhe 7 年之前
父节点
当前提交
6b3ae6225d

文件差异内容过多而无法显示
+ 15395 - 15395
Playground/babylon.d.txt


文件差异内容过多而无法显示
+ 15142 - 15142
dist/preview release/babylon.d.ts


文件差异内容过多而无法显示
+ 3 - 3
dist/preview release/babylon.js


+ 2 - 2
dist/preview release/babylon.max.js

@@ -51934,7 +51934,7 @@ var BABYLON;
             if (weight !== -1.0) {
                 if (!this._originalValue) {
                     var originalValue = void 0;
-                    if (destination.getRestPose) { // For bones
+                    if (destination.getRestPose && path === "_matrix") { // For bones
                         originalValue = destination.getRestPose();
                     }
                     else {
@@ -64522,7 +64522,7 @@ var BABYLON;
             }
             else {
                 _this._canvas = document.createElement("canvas");
-                if (options.width) {
+                if (options.width || options.width === 0) {
                     _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
                 }
                 else {

+ 2 - 2
dist/preview release/babylon.no-module.max.js

@@ -51901,7 +51901,7 @@ var BABYLON;
             if (weight !== -1.0) {
                 if (!this._originalValue) {
                     var originalValue = void 0;
-                    if (destination.getRestPose) { // For bones
+                    if (destination.getRestPose && path === "_matrix") { // For bones
                         originalValue = destination.getRestPose();
                     }
                     else {
@@ -64489,7 +64489,7 @@ var BABYLON;
             }
             else {
                 _this._canvas = document.createElement("canvas");
-                if (options.width) {
+                if (options.width || options.width === 0) {
                     _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
                 }
                 else {

文件差异内容过多而无法显示
+ 3 - 3
dist/preview release/babylon.worker.js


+ 2 - 2
dist/preview release/es6.js

@@ -51901,7 +51901,7 @@ var BABYLON;
             if (weight !== -1.0) {
                 if (!this._originalValue) {
                     var originalValue = void 0;
-                    if (destination.getRestPose) { // For bones
+                    if (destination.getRestPose && path === "_matrix") { // For bones
                         originalValue = destination.getRestPose();
                     }
                     else {
@@ -64489,7 +64489,7 @@ var BABYLON;
             }
             else {
                 _this._canvas = document.createElement("canvas");
-                if (options.width) {
+                if (options.width || options.width === 0) {
                     _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
                 }
                 else {

+ 3 - 1
dist/preview release/loaders/babylon.glTF2FileLoader.js

@@ -1391,7 +1391,9 @@ var BABYLON;
             GLTFLoader.prototype._loadAnimationChannelAsync = function (context, animationContext, animation, channel, babylonAnimationGroup) {
                 var _this = this;
                 var targetNode = GLTFLoader._GetProperty(context + "/target/node", this._gltf.nodes, channel.target.node);
-                if (!targetNode._babylonMesh) {
+                // Ignore animations that have no animation targets.
+                if ((channel.target.path === "weights" /* WEIGHTS */ && !targetNode._numMorphTargets) ||
+                    (channel.target.path !== "weights" /* WEIGHTS */ && !targetNode._babylonAnimationTargets)) {
                     return Promise.resolve();
                 }
                 // Ignore animations targeting TRS of skinned nodes.

文件差异内容过多而无法显示
+ 2 - 2
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


+ 3 - 1
dist/preview release/loaders/babylon.glTFFileLoader.js

@@ -3607,7 +3607,9 @@ var BABYLON;
             GLTFLoader.prototype._loadAnimationChannelAsync = function (context, animationContext, animation, channel, babylonAnimationGroup) {
                 var _this = this;
                 var targetNode = GLTFLoader._GetProperty(context + "/target/node", this._gltf.nodes, channel.target.node);
-                if (!targetNode._babylonMesh) {
+                // Ignore animations that have no animation targets.
+                if ((channel.target.path === "weights" /* WEIGHTS */ && !targetNode._numMorphTargets) ||
+                    (channel.target.path !== "weights" /* WEIGHTS */ && !targetNode._babylonAnimationTargets)) {
                     return Promise.resolve();
                 }
                 // Ignore animations targeting TRS of skinned nodes.

文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/loaders/babylon.glTFFileLoader.min.js


+ 3 - 1
dist/preview release/loaders/babylonjs.loaders.js

@@ -4589,7 +4589,9 @@ var BABYLON;
             GLTFLoader.prototype._loadAnimationChannelAsync = function (context, animationContext, animation, channel, babylonAnimationGroup) {
                 var _this = this;
                 var targetNode = GLTFLoader._GetProperty(context + "/target/node", this._gltf.nodes, channel.target.node);
-                if (!targetNode._babylonMesh) {
+                // Ignore animations that have no animation targets.
+                if ((channel.target.path === "weights" /* WEIGHTS */ && !targetNode._numMorphTargets) ||
+                    (channel.target.path !== "weights" /* WEIGHTS */ && !targetNode._babylonAnimationTargets)) {
                     return Promise.resolve();
                 }
                 // Ignore animations targeting TRS of skinned nodes.

文件差异内容过多而无法显示
+ 2 - 2
dist/preview release/loaders/babylonjs.loaders.min.js


文件差异内容过多而无法显示
+ 7 - 7
dist/preview release/viewer/babylon.viewer.js


+ 74 - 5
dist/preview release/viewer/babylon.viewer.max.js

@@ -52022,7 +52022,7 @@ var BABYLON;
             if (weight !== -1.0) {
                 if (!this._originalValue) {
                     var originalValue = void 0;
-                    if (destination.getRestPose) { // For bones
+                    if (destination.getRestPose && path === "_matrix") { // For bones
                         originalValue = destination.getRestPose();
                     }
                     else {
@@ -64610,7 +64610,7 @@ var BABYLON;
             }
             else {
                 _this._canvas = document.createElement("canvas");
-                if (options.width) {
+                if (options.width || options.width === 0) {
                     _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
                 }
                 else {
@@ -102795,6 +102795,10 @@ var BABYLON;
              */
             this.onMaterialLoadedObservable = new BABYLON.Observable();
             /**
+             * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
+             */
+            this.onCameraLoadedObservable = new BABYLON.Observable();
+            /**
              * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
              * For assets with LODs, raised when all of the LODs are complete.
              * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
@@ -102875,6 +102879,19 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(GLTFFileLoader.prototype, "onCameraLoaded", {
+            /**
+             * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
+             */
+            set: function (callback) {
+                if (this._onCameraLoadedObserver) {
+                    this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver);
+                }
+                this._onCameraLoadedObserver = this.onCameraLoadedObservable.add(callback);
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(GLTFFileLoader.prototype, "onComplete", {
             /**
              * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
@@ -102947,6 +102964,9 @@ var BABYLON;
             this.onMeshLoadedObservable.clear();
             this.onTextureLoadedObservable.clear();
             this.onMaterialLoadedObservable.clear();
+            this.onCameraLoadedObservable.clear();
+            this.onCompleteObservable.clear();
+            this.onExtensionLoadedObservable.clear();
             this.onDisposeObservable.notifyObservers(this);
             this.onDisposeObservable.clear();
         };
@@ -103071,11 +103091,16 @@ var BABYLON;
             loader.onMeshLoadedObservable.add(function (mesh) { return _this.onMeshLoadedObservable.notifyObservers(mesh); });
             loader.onTextureLoadedObservable.add(function (texture) { return _this.onTextureLoadedObservable.notifyObservers(texture); });
             loader.onMaterialLoadedObservable.add(function (material) { return _this.onMaterialLoadedObservable.notifyObservers(material); });
-            loader.onExtensionLoadedObservable.add(function (extension) { return _this.onExtensionLoadedObservable.notifyObservers(extension); });
+            loader.onCameraLoadedObservable.add(function (camera) { return _this.onCameraLoadedObservable.notifyObservers(camera); });
+            loader.onExtensionLoadedObservable.add(function (extension) {
+                _this.onExtensionLoadedObservable.notifyObservers(extension);
+                _this.onExtensionLoadedObservable.clear();
+            });
             loader.onCompleteObservable.add(function () {
                 _this.onMeshLoadedObservable.clear();
                 _this.onTextureLoadedObservable.clear();
                 _this.onMaterialLoadedObservable.clear();
+                _this.onCameraLoadedObservable.clear();
                 _this.onCompleteObservable.notifyObservers(_this);
                 _this.onCompleteObservable.clear();
             });
@@ -104080,7 +104105,7 @@ var BABYLON;
                 var camera = gltfRuntime.cameras[node.camera];
                 if (camera) {
                     if (camera.type === "orthographic") {
-                        var orthoCamera = new BABYLON.FreeCamera(node.camera, BABYLON.Vector3.Zero(), gltfRuntime.scene);
+                        var orthoCamera = new BABYLON.FreeCamera(node.camera, BABYLON.Vector3.Zero(), gltfRuntime.scene, false);
                         orthoCamera.name = node.name || "";
                         orthoCamera.mode = BABYLON.Camera.ORTHOGRAPHIC_CAMERA;
                         orthoCamera.attachControl(gltfRuntime.scene.getEngine().getRenderingCanvas());
@@ -104088,7 +104113,7 @@ var BABYLON;
                     }
                     else if (camera.type === "perspective") {
                         var perspectiveCamera = camera[camera.type];
-                        var persCamera = new BABYLON.FreeCamera(node.camera, BABYLON.Vector3.Zero(), gltfRuntime.scene);
+                        var persCamera = new BABYLON.FreeCamera(node.camera, BABYLON.Vector3.Zero(), gltfRuntime.scene, false);
                         persCamera.name = node.name || "";
                         persCamera.attachControl(gltfRuntime.scene.getEngine().getRenderingCanvas());
                         if (!perspectiveCamera.aspectRatio) {
@@ -104646,6 +104671,7 @@ var BABYLON;
                 this.onMeshLoadedObservable = new BABYLON.Observable();
                 this.onTextureLoadedObservable = new BABYLON.Observable();
                 this.onMaterialLoadedObservable = new BABYLON.Observable();
+                this.onCameraLoadedObservable = new BABYLON.Observable();
                 this.onCompleteObservable = new BABYLON.Observable();
                 this.onExtensionLoadedObservable = new BABYLON.Observable();
                 /**
@@ -105531,6 +105557,10 @@ var BABYLON;
                  */
                 this.onMaterialLoadedObservable = new BABYLON.Observable();
                 /**
+                 * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
+                 */
+                this.onCameraLoadedObservable = new BABYLON.Observable();
+                /**
                  * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
                  * For assets with LODs, raised when all of the LODs are complete.
                  * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
@@ -105904,6 +105934,10 @@ var BABYLON;
                     var mesh = GLTFLoader._GetProperty(context + "/mesh", this._gltf.meshes, node.mesh);
                     promises.push(this._loadMeshAsync("#/meshes/" + mesh._index, node, mesh, babylonMesh));
                 }
+                if (node.camera != undefined) {
+                    var camera = GLTFLoader._GetProperty(context + "/camera", this._gltf.cameras, node.camera);
+                    this._loadCamera("#/cameras/" + camera._index, camera, babylonMesh);
+                }
                 if (node.children) {
                     for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
                         var index = _a[_i];
@@ -106191,6 +106225,40 @@ var BABYLON;
                     BABYLON.Matrix.FromArray(node.matrix) :
                     BABYLON.Matrix.Compose(node.scale ? BABYLON.Vector3.FromArray(node.scale) : BABYLON.Vector3.One(), node.rotation ? BABYLON.Quaternion.FromArray(node.rotation) : BABYLON.Quaternion.Identity(), node.translation ? BABYLON.Vector3.FromArray(node.translation) : BABYLON.Vector3.Zero());
             };
+            GLTFLoader.prototype._loadCamera = function (context, camera, babylonMesh) {
+                var babylonCamera = new BABYLON.FreeCamera(camera.name || "camera" + camera._index, BABYLON.Vector3.Zero(), this._babylonScene, false);
+                babylonCamera.parent = babylonMesh;
+                babylonCamera.rotation = new BABYLON.Vector3(0, Math.PI, 0);
+                switch (camera.type) {
+                    case "perspective" /* PERSPECTIVE */: {
+                        var perspective = camera.perspective;
+                        if (!perspective) {
+                            throw new Error(context + ": Camera perspective properties are missing");
+                        }
+                        babylonCamera.fov = perspective.yfov;
+                        babylonCamera.minZ = perspective.znear;
+                        babylonCamera.maxZ = perspective.zfar || Number.MAX_VALUE;
+                        break;
+                    }
+                    case "orthographic" /* ORTHOGRAPHIC */: {
+                        if (!camera.orthographic) {
+                            throw new Error(context + ": Camera orthographic properties are missing");
+                        }
+                        babylonCamera.mode = BABYLON.Camera.ORTHOGRAPHIC_CAMERA;
+                        babylonCamera.orthoLeft = -camera.orthographic.xmag;
+                        babylonCamera.orthoRight = camera.orthographic.xmag;
+                        babylonCamera.orthoBottom = -camera.orthographic.ymag;
+                        babylonCamera.orthoTop = camera.orthographic.ymag;
+                        babylonCamera.minZ = camera.orthographic.znear;
+                        babylonCamera.maxZ = camera.orthographic.zfar;
+                        break;
+                    }
+                    default: {
+                        throw new Error(context + ": Invalid camera type (" + camera.type + ")");
+                    }
+                }
+                this.onCameraLoadedObservable.notifyObservers(babylonCamera);
+            };
             GLTFLoader.prototype._loadAnimationsAsync = function () {
                 var animations = this._gltf.animations;
                 if (!animations) {
@@ -106935,6 +107003,7 @@ var BABYLON;
                 this.onMeshLoadedObservable.clear();
                 this.onTextureLoadedObservable.clear();
                 this.onMaterialLoadedObservable.clear();
+                this.onCameraLoadedObservable.clear();
             };
             /** @hidden */
             GLTFLoader.prototype._applyExtensions = function (actionAsync) {

+ 1 - 1
src/Animations/babylon.runtimeAnimation.ts

@@ -278,7 +278,7 @@
                 if (!this._originalValue) {
                     let originalValue: any;
 
-                    if (destination.getRestPose) { // For bones
+                    if (destination.getRestPose && path === "_matrix") { // For bones
                         originalValue = destination.getRestPose();
                     } else {
                         originalValue = destination[path];