Bläddra i källkod

Standard Material to scene dependency

sebavan 6 år sedan
förälder
incheckning
65c7654851
3 ändrade filer med 16 tillägg och 13 borttagningar
  1. 1 11
      Tools/Config/tempCircularValidation/core.json
  2. 4 0
      src/Materials/standardMaterial.ts
  3. 11 2
      src/scene.ts

+ 1 - 11
Tools/Config/tempCircularValidation/core.json

@@ -26,13 +26,6 @@
     "../../src/Materials/material.ts": [
         "../../src/Meshes/subMesh.ts"
     ],
-    "../../src/Materials/materialHelper.ts": [
-        "../../src/scene.ts"
-    ],
-    "../../src/Materials/standardMaterial.ts": [
-        "../../src/Materials/materialHelper.ts",
-        "../../src/scene.ts"
-    ],
     "../../src/Meshes/geometry.ts": [
         "../../src/Meshes/mesh.ts"
     ],
@@ -72,8 +65,5 @@
     "../../src/Rendering/geometryBufferRendererSceneComponent.ts": [
         "../../src/Rendering/geometryBufferRenderer.ts"
     ],
-    "../../src/scene.ts": [
-        "../../src/Materials/standardMaterial.ts"
-    ],
-    "errorCount": 26
+    "errorCount": 22
 }

+ 4 - 0
src/Materials/standardMaterial.ts

@@ -1893,3 +1893,7 @@ import { Constants } from "../Engines/constants";
     }
 
     _TypeStore.RegisteredTypes["BABYLON.StandardMaterial"] = StandardMaterial;
+
+    Scene.DefaultMaterialFactory = (scene: Scene) => {
+        return new StandardMaterial("default material", scene);
+    };

+ 11 - 2
src/scene.ts

@@ -22,7 +22,6 @@ import { Texture } from "./Materials/Textures/texture";
 import { RenderTargetTexture } from "./Materials/Textures/renderTargetTexture";
 import { Material } from "./Materials/material";
 import { ImageProcessingConfiguration } from "./Materials/imageProcessingConfiguration";
-import { StandardMaterial } from "./Materials/standardMaterial";
 import { Effect } from "./Materials/effect";
 import { UniformBuffer } from "./Materials/uniformBuffer";
 import { MultiMaterial } from "./Materials/multiMaterial";
@@ -146,6 +145,16 @@ import { EngineStore } from "./Engines/engineStore";
          */
         public static MaxDeltaTime = 1000.0;
 
+        /**
+         * Factory used to create the default material.
+         * @param name The name of the material to create
+         * @param scene The scene to create the material for
+         * @returns The default material
+         */
+        public static DefaultMaterialFactory(scene: Scene): Material {
+            throw "Import StandardMaterial or Fill DefaultMaterialFactory static property on scene before using relying on default material creation.";
+        }
+
         // Members
 
         /** @hidden */
@@ -845,7 +854,7 @@ import { EngineStore } from "./Engines/engineStore";
         /** The default material used on meshes when no material is affected */
         public get defaultMaterial(): Material {
             if (!this._defaultMaterial) {
-                this._defaultMaterial = new StandardMaterial("default material", this);
+                this._defaultMaterial = Scene.DefaultMaterialFactory(this);
             }
 
             return this._defaultMaterial;