Browse Source

Fix tiny bugs

David Catuhe 6 năm trước cách đây
mục cha
commit
07fa9aa037

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 10027 - 10026
Playground/babylon.d.txt


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 10038 - 10037
dist/preview release/babylon.d.ts


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
dist/preview release/babylon.js


+ 7 - 3
dist/preview release/babylon.max.js

@@ -18670,9 +18670,11 @@ var BABYLON;
          * Creates a new Node
          * @param name the name and id to be given to this node
          * @param scene the scene this node will be added to
+         * @param addToRootNodes the node will be added to scene.rootNodes
          */
-        function Node(name, scene) {
+        function Node(name, scene, addToRootNodes) {
             if (scene === void 0) { scene = null; }
+            if (addToRootNodes === void 0) { addToRootNodes = true; }
             /**
              * Gets or sets a string used to store user defined state for the node
              */
@@ -18717,7 +18719,9 @@ var BABYLON;
             this._scene = (scene || BABYLON.Engine.LastCreatedScene);
             this.uniqueId = this._scene.getUniqueId();
             this._initCache();
-            this.addToSceneRootNodes();
+            if (addToRootNodes) {
+                this.addToSceneRootNodes();
+            }
         }
         /**
          * Add a new node constructor
@@ -92231,7 +92235,7 @@ var BABYLON;
             if (restPose === void 0) { restPose = null; }
             if (baseMatrix === void 0) { baseMatrix = null; }
             if (index === void 0) { index = null; }
-            var _this = _super.call(this, name, skeleton.getScene()) || this;
+            var _this = _super.call(this, name, skeleton.getScene(), false) || this;
             _this.name = name;
             /**
              * Gets the list of child bones

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

@@ -18637,9 +18637,11 @@ var BABYLON;
          * Creates a new Node
          * @param name the name and id to be given to this node
          * @param scene the scene this node will be added to
+         * @param addToRootNodes the node will be added to scene.rootNodes
          */
-        function Node(name, scene) {
+        function Node(name, scene, addToRootNodes) {
             if (scene === void 0) { scene = null; }
+            if (addToRootNodes === void 0) { addToRootNodes = true; }
             /**
              * Gets or sets a string used to store user defined state for the node
              */
@@ -18684,7 +18686,9 @@ var BABYLON;
             this._scene = (scene || BABYLON.Engine.LastCreatedScene);
             this.uniqueId = this._scene.getUniqueId();
             this._initCache();
-            this.addToSceneRootNodes();
+            if (addToRootNodes) {
+                this.addToSceneRootNodes();
+            }
         }
         /**
          * Add a new node constructor
@@ -92198,7 +92202,7 @@ var BABYLON;
             if (restPose === void 0) { restPose = null; }
             if (baseMatrix === void 0) { baseMatrix = null; }
             if (index === void 0) { index = null; }
-            var _this = _super.call(this, name, skeleton.getScene()) || this;
+            var _this = _super.call(this, name, skeleton.getScene(), false) || this;
             _this.name = name;
             /**
              * Gets the list of child bones

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
dist/preview release/babylon.worker.js


+ 7 - 3
dist/preview release/es6.js

@@ -18637,9 +18637,11 @@ var BABYLON;
          * Creates a new Node
          * @param name the name and id to be given to this node
          * @param scene the scene this node will be added to
+         * @param addToRootNodes the node will be added to scene.rootNodes
          */
-        function Node(name, scene) {
+        function Node(name, scene, addToRootNodes) {
             if (scene === void 0) { scene = null; }
+            if (addToRootNodes === void 0) { addToRootNodes = true; }
             /**
              * Gets or sets a string used to store user defined state for the node
              */
@@ -18684,7 +18686,9 @@ var BABYLON;
             this._scene = (scene || BABYLON.Engine.LastCreatedScene);
             this.uniqueId = this._scene.getUniqueId();
             this._initCache();
-            this.addToSceneRootNodes();
+            if (addToRootNodes) {
+                this.addToSceneRootNodes();
+            }
         }
         /**
          * Add a new node constructor
@@ -92198,7 +92202,7 @@ var BABYLON;
             if (restPose === void 0) { restPose = null; }
             if (baseMatrix === void 0) { baseMatrix = null; }
             if (index === void 0) { index = null; }
-            var _this = _super.call(this, name, skeleton.getScene()) || this;
+            var _this = _super.call(this, name, skeleton.getScene(), false) || this;
             _this.name = name;
             /**
              * Gets the list of child bones

+ 15 - 1
dist/preview release/viewer/babylon.viewer.d.ts

@@ -924,7 +924,7 @@ declare module BabylonViewer {
       * @param name the name of the custom optimizer configuration
       * @param upgrade set to true if you want to upgrade optimizer and false if you want to degrade
       */
-    export function getCustomOptimizerByName(name: string, upgrade?: boolean): (sceneManager: SceneManager) => boolean;
+    export function getCustomOptimizerByName(name: string, upgrade?: boolean): typeof extendedUpgrade;
     export function registerCustomOptimizer(name: string, optimizer: (sceneManager: SceneManager) => boolean): void;
 }
 declare module BabylonViewer {
@@ -1558,6 +1558,20 @@ declare module BabylonViewer {
     export function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
 }
 declare module BabylonViewer {
+    /**
+        * A custom upgrade-oriented function configuration for the scene optimizer.
+        *
+        * @param viewer the viewer to optimize
+        */
+    export function extendedUpgrade(sceneManager: SceneManager): boolean;
+    /**
+        * A custom degrade-oriented function configuration for the scene optimizer.
+        *
+        * @param viewer the viewer to optimize
+        */
+    export function extendedDegrade(sceneManager: SceneManager): boolean;
+}
+declare module BabylonViewer {
 }
 declare module BabylonViewer {
     export interface IEnvironmentMapConfiguration {

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
dist/preview release/viewer/babylon.viewer.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


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

@@ -985,13 +985,14 @@ declare module 'babylonjs-viewer/templating/viewerTemplatePlugin' {
 }
 
 declare module 'babylonjs-viewer/optimizer/custom' {
+    import { extendedUpgrade } from "babylonjs-viewer/optimizer/custom/extended";
     import { SceneManager } from "babylonjs-viewer/managers/sceneManager";
     /**
       *
       * @param name the name of the custom optimizer configuration
       * @param upgrade set to true if you want to upgrade optimizer and false if you want to degrade
       */
-    export function getCustomOptimizerByName(name: string, upgrade?: boolean): (sceneManager: SceneManager) => boolean;
+    export function getCustomOptimizerByName(name: string, upgrade?: boolean): typeof extendedUpgrade;
     export function registerCustomOptimizer(name: string, optimizer: (sceneManager: SceneManager) => boolean): void;
 }
 
@@ -1662,6 +1663,22 @@ declare module 'babylonjs-viewer/loader/plugins' {
     export function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
 }
 
+declare module 'babylonjs-viewer/optimizer/custom/extended' {
+    import { SceneManager } from 'babylonjs-viewer/managers/sceneManager';
+    /**
+        * A custom upgrade-oriented function configuration for the scene optimizer.
+        *
+        * @param viewer the viewer to optimize
+        */
+    export function extendedUpgrade(sceneManager: SceneManager): boolean;
+    /**
+        * A custom degrade-oriented function configuration for the scene optimizer.
+        *
+        * @param viewer the viewer to optimize
+        */
+    export function extendedDegrade(sceneManager: SceneManager): boolean;
+}
+
 declare module 'babylonjs-viewer/configuration/interfaces' {
     export * from 'babylonjs-viewer/configuration/interfaces/cameraConfiguration';
     export * from 'babylonjs-viewer/configuration/interfaces/colorGradingConfiguration';

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

@@ -58,6 +58,7 @@
 ### Materials Library
 
 ## Bug fixes
+- Removed bones from rootNodes where they should never have been ([Deltakosh](https://github.com/deltakosh))
 - Refocusing on input gui with pointer events ([TrevorDev](https://github.com/TrevorDev))
 - Gizmo scaling not consistent when camera is parented ([TrevorDev](https://github.com/TrevorDev))
 - Context loss causing unexpected results with dynamic textures ([TrevorDev](https://github.com/TrevorDev))

+ 1 - 1
src/Bones/babylon.bone.ts

@@ -73,7 +73,7 @@ module BABYLON {
              */
             public name: string, skeleton: Skeleton, parentBone: Nullable<Bone> = null, localMatrix: Nullable<Matrix> = null,
             restPose: Nullable<Matrix> = null, baseMatrix: Nullable<Matrix> = null, index: Nullable<number> = null) {
-            super(name, skeleton.getScene());
+            super(name, skeleton.getScene(), false);
             this._skeleton = skeleton;
             this._localMatrix = localMatrix ? localMatrix.clone() : Matrix.Identity();
             this._restPose = restPose ? restPose : this._localMatrix.clone();

+ 7 - 4
src/babylon.node.ts

@@ -9,7 +9,7 @@ module BABYLON {
      * Node is the basic class for all scene objects (Mesh, Light, Camera.)
      */
     export class Node implements IBehaviorAware<Node> {
-        private static _NodeConstructors: {[key: string]: any} = {};
+        private static _NodeConstructors: { [key: string]: any } = {};
 
         /**
          * Add a new node constructor
@@ -228,15 +228,18 @@ module BABYLON {
          * Creates a new Node
          * @param name the name and id to be given to this node
          * @param scene the scene this node will be added to
+         * @param addToRootNodes the node will be added to scene.rootNodes
          */
-        constructor(name: string, scene: Nullable<Scene> = null) {
+        constructor(name: string, scene: Nullable<Scene> = null, addToRootNodes = true) {
             this.name = name;
             this.id = name;
             this._scene = <Scene>(scene || Engine.LastCreatedScene);
             this.uniqueId = this._scene.getUniqueId();
             this._initCache();
 
-            this.addToSceneRootNodes();
+            if (addToRootNodes) {
+                this.addToSceneRootNodes();
+            }
         }
 
         /**
@@ -364,7 +367,7 @@ module BABYLON {
         /** @hidden */
         public updateCache(force?: boolean): void {
             if (!force && this.isSynchronized()) {
-                return;
+                return;
             }
 
             this._cache.parent = this.parent;