Explorar o código

Remove circular dependency

Popov72 %!s(int64=4) %!d(string=hai) anos
pai
achega
fe0b0ecbf2
Modificáronse 2 ficheiros con 20 adicións e 20 borrados
  1. 20 1
      src/Materials/material.ts
  2. 0 19
      src/scene.ts

+ 20 - 1
src/Materials/material.ts

@@ -933,6 +933,25 @@ export class Material implements IAnimatable {
     }
 
     /**
+     * Update the scene ubo before it can be used in rendering processing
+     * @param scene the scene to retrieve the ubo from
+     * @returns the scene UniformBuffer
+     */
+    public finalizeSceneUbo(scene: Scene): UniformBuffer {
+        const ubo = scene.getSceneUniformBuffer();
+        const eyePosition = MaterialHelper.BindEyePosition(null, scene);
+        ubo.updateFloat4("vEyePosition",
+            eyePosition.x,
+            eyePosition.y,
+            eyePosition.z,
+            eyePosition.w);
+
+        ubo.update();
+
+        return ubo;
+    }
+
+    /**
      * Binds the scene's uniform buffer to the effect.
      * @param effect defines the effect to bind to the scene uniform buffer
      * @param sceneUbo defines the uniform buffer storing scene data
@@ -988,7 +1007,7 @@ export class Material implements IAnimatable {
         if (this._needToBindSceneUbo) {
             if (effect) {
                 this._needToBindSceneUbo = false;
-                this.getScene().finalizeSceneUbo();
+                this.finalizeSceneUbo(this.getScene());
                 this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
             }
         }

+ 0 - 19
src/scene.ts

@@ -55,7 +55,6 @@ import { Frustum } from './Maths/math.frustum';
 import { UniqueIdGenerator } from './Misc/uniqueIdGenerator';
 import { FileTools, LoadFileError, RequestFileError, ReadFileError } from './Misc/fileTools';
 import { IClipPlanesHolder } from './Misc/interfaces/iClipPlanesHolder';
-import { MaterialHelper } from './Materials/materialHelper';
 
 declare type Ray = import("./Culling/ray").Ray;
 declare type TrianglePickingPredicate = import("./Culling/ray").TrianglePickingPredicate;
@@ -2043,24 +2042,6 @@ export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHold
     }
 
     /**
-     * Update the scene ubo before it can be used in rendering processing
-     * @returns the scene UniformBuffer
-     */
-    public finalizeSceneUbo(): UniformBuffer {
-        const ubo = this.getSceneUniformBuffer();
-        const eyePosition = MaterialHelper.BindEyePosition(null, this);
-        ubo.updateFloat4("vEyePosition",
-            eyePosition.x,
-            eyePosition.y,
-            eyePosition.z,
-            eyePosition.w);
-
-        ubo.update();
-
-        return ubo;
-    }
-
-    /**
      * Gets the uniform buffer used to store scene data
      * @returns a UniformBuffer
      */