|
@@ -112,7 +112,7 @@
|
|
* Represents a scene to be rendered by the engine.
|
|
* Represents a scene to be rendered by the engine.
|
|
* @see http://doc.babylonjs.com/features/scene
|
|
* @see http://doc.babylonjs.com/features/scene
|
|
*/
|
|
*/
|
|
- export class Scene implements IAnimatable {
|
|
|
|
|
|
+ export class Scene extends AbstractScene implements IAnimatable {
|
|
// Statics
|
|
// Statics
|
|
private static _FOGMODE_NONE = 0;
|
|
private static _FOGMODE_NONE = 0;
|
|
private static _FOGMODE_EXP = 1;
|
|
private static _FOGMODE_EXP = 1;
|
|
@@ -544,10 +544,6 @@
|
|
public onRenderingGroupObservable = new Observable<RenderingGroupInfo>();
|
|
public onRenderingGroupObservable = new Observable<RenderingGroupInfo>();
|
|
|
|
|
|
// Animations
|
|
// Animations
|
|
- /**
|
|
|
|
- * Gets a list of Animations associated with the scene
|
|
|
|
- */
|
|
|
|
- public animations: Animation[] = [];
|
|
|
|
private _registeredForLateAnimationBindings = new SmartArrayNoDuplicate<any>(256);
|
|
private _registeredForLateAnimationBindings = new SmartArrayNoDuplicate<any>(256);
|
|
|
|
|
|
// Pointers
|
|
// Pointers
|
|
@@ -800,53 +796,11 @@
|
|
return this._lightsEnabled;
|
|
return this._lightsEnabled;
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * All of the lights added to this scene
|
|
|
|
- * @see http://doc.babylonjs.com/babylon101/lights
|
|
|
|
- */
|
|
|
|
- public lights = new Array<Light>();
|
|
|
|
-
|
|
|
|
- // Cameras
|
|
|
|
- /** All of the cameras added to this scene.
|
|
|
|
- * @see http://doc.babylonjs.com/babylon101/cameras
|
|
|
|
- */
|
|
|
|
- public cameras = new Array<Camera>();
|
|
|
|
/** All of the active cameras added to this scene. */
|
|
/** All of the active cameras added to this scene. */
|
|
public activeCameras = new Array<Camera>();
|
|
public activeCameras = new Array<Camera>();
|
|
/** The current active camera */
|
|
/** The current active camera */
|
|
public activeCamera: Nullable<Camera>;
|
|
public activeCamera: Nullable<Camera>;
|
|
|
|
|
|
- // Meshes
|
|
|
|
- /**
|
|
|
|
- * All of the tranform nodes added to this scene
|
|
|
|
- * @see http://doc.babylonjs.com/how_to/transformnode
|
|
|
|
- */
|
|
|
|
- public transformNodes = new Array<TransformNode>();
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * All of the (abstract) meshes added to this scene
|
|
|
|
- */
|
|
|
|
- public meshes = new Array<AbstractMesh>();
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * All of the animation groups added to this scene
|
|
|
|
- * @see http://doc.babylonjs.com/how_to/group
|
|
|
|
- */
|
|
|
|
- public animationGroups = new Array<AnimationGroup>();
|
|
|
|
-
|
|
|
|
- // Geometries
|
|
|
|
- private _geometries = new Array<Geometry>();
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * All of the materials added to this scene
|
|
|
|
- * @see http://doc.babylonjs.com/babylon101/materials
|
|
|
|
- */
|
|
|
|
- public materials = new Array<Material>();
|
|
|
|
- /**
|
|
|
|
- * All of the multi-materials added to this scene
|
|
|
|
- * @see http://doc.babylonjs.com/how_to/multi_materials
|
|
|
|
- */
|
|
|
|
- public multiMaterials = new Array<MultiMaterial>();
|
|
|
|
private _defaultMaterial: Material;
|
|
private _defaultMaterial: Material;
|
|
|
|
|
|
/** The default material used on meshes when no material is affected */
|
|
/** The default material used on meshes when no material is affected */
|
|
@@ -880,23 +834,12 @@
|
|
return this._texturesEnabled;
|
|
return this._texturesEnabled;
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * All of the textures added to this scene
|
|
|
|
- */
|
|
|
|
- public textures = new Array<BaseTexture>();
|
|
|
|
-
|
|
|
|
// Particles
|
|
// Particles
|
|
/**
|
|
/**
|
|
* Gets or sets a boolean indicating if particles are enabled on this scene
|
|
* Gets or sets a boolean indicating if particles are enabled on this scene
|
|
*/
|
|
*/
|
|
public particlesEnabled = true;
|
|
public particlesEnabled = true;
|
|
|
|
|
|
- /**
|
|
|
|
- * All of the particle systems added to this scene
|
|
|
|
- * @see http://doc.babylonjs.com/babylon101/particles
|
|
|
|
- */
|
|
|
|
- public particleSystems = new Array<IParticleSystem>();
|
|
|
|
-
|
|
|
|
// Sprites
|
|
// Sprites
|
|
/**
|
|
/**
|
|
* Gets or sets a boolean indicating if sprites are enabled on this scene
|
|
* Gets or sets a boolean indicating if sprites are enabled on this scene
|
|
@@ -908,18 +851,6 @@
|
|
*/
|
|
*/
|
|
public spriteManagers = new Array<SpriteManager>();
|
|
public spriteManagers = new Array<SpriteManager>();
|
|
|
|
|
|
- /**
|
|
|
|
- * The list of layers (background and foreground) of the scene
|
|
|
|
- */
|
|
|
|
- public layers = new Array<Layer>();
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * The list of effect layers (highlights/glow) added to the scene
|
|
|
|
- * @see http://doc.babylonjs.com/how_to/highlight_layer
|
|
|
|
- * @see http://doc.babylonjs.com/how_to/glow_layer
|
|
|
|
- */
|
|
|
|
- public effectLayers = new Array<EffectLayer>();
|
|
|
|
-
|
|
|
|
// Skeletons
|
|
// Skeletons
|
|
private _skeletonsEnabled = true;
|
|
private _skeletonsEnabled = true;
|
|
/**
|
|
/**
|
|
@@ -937,29 +868,11 @@
|
|
return this._skeletonsEnabled;
|
|
return this._skeletonsEnabled;
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * The list of skeletons added to the scene
|
|
|
|
- * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
|
|
|
|
- */
|
|
|
|
- public skeletons = new Array<Skeleton>();
|
|
|
|
-
|
|
|
|
- // Morph targets
|
|
|
|
- /**
|
|
|
|
- * The list of morph target managers added to the scene
|
|
|
|
- * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
|
|
|
|
- */
|
|
|
|
- public morphTargetManagers = new Array<MorphTargetManager>();
|
|
|
|
-
|
|
|
|
// Lens flares
|
|
// Lens flares
|
|
/**
|
|
/**
|
|
* Gets or sets a boolean indicating if lens flares are enabled on this scene
|
|
* Gets or sets a boolean indicating if lens flares are enabled on this scene
|
|
*/
|
|
*/
|
|
public lensFlaresEnabled = true;
|
|
public lensFlaresEnabled = true;
|
|
- /**
|
|
|
|
- * The list of lens flare system added to the scene
|
|
|
|
- * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
|
|
|
|
- */
|
|
|
|
- public lensFlareSystems = new Array<LensFlareSystem>();
|
|
|
|
|
|
|
|
// Collisions
|
|
// Collisions
|
|
/**
|
|
/**
|
|
@@ -1052,8 +965,6 @@
|
|
*/
|
|
*/
|
|
public actionManager: ActionManager;
|
|
public actionManager: ActionManager;
|
|
|
|
|
|
- /** @hidden */
|
|
|
|
- public _actionManagers = new Array<ActionManager>();
|
|
|
|
private _meshesForIntersections = new SmartArrayNoDuplicate<AbstractMesh>(256);
|
|
private _meshesForIntersections = new SmartArrayNoDuplicate<AbstractMesh>(256);
|
|
|
|
|
|
// Procedural textures
|
|
// Procedural textures
|
|
@@ -1234,10 +1145,76 @@
|
|
private _uid: Nullable<string>;
|
|
private _uid: Nullable<string>;
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * Backing store of defined scene components.
|
|
|
|
+ */
|
|
|
|
+ public _components: ISceneComponent[] = [];
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * List of components to register on the next registration step.
|
|
|
|
+ */
|
|
|
|
+ private _transientComponents: ISceneComponent[] = [];
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Registers the transient components if needed.
|
|
|
|
+ */
|
|
|
|
+ private _registerTransientComponents(): void {
|
|
|
|
+ // Register components that have been associated lately to the scene.
|
|
|
|
+ if (this._transientComponents.length > 0) {
|
|
|
|
+ for (let component of this._transientComponents) {
|
|
|
|
+ component.register();
|
|
|
|
+ }
|
|
|
|
+ this._transientComponents = [];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Add a component to the scene.
|
|
|
|
+ * Note that the ccomponent could be registered on th next frame if this is called after
|
|
|
|
+ * the register component stage.
|
|
|
|
+ * @param component Defines the component to add to the scene
|
|
|
|
+ */
|
|
|
|
+ public _addComponent(component: ISceneComponent) {
|
|
|
|
+ this._components.push(component);
|
|
|
|
+ this._transientComponents.push(component);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets a component from the scene.
|
|
|
|
+ * @param name defines the name of the component to retrieve
|
|
|
|
+ * @returns the component or null if not present
|
|
|
|
+ */
|
|
|
|
+ public _getComponent(name: string): Nullable<ISceneComponent> {
|
|
|
|
+ for (let component of this._components) {
|
|
|
|
+ if (component.name === name) {
|
|
|
|
+ return component;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Defines the actions happening during the per mesh ready checks.
|
|
|
|
+ */
|
|
|
|
+ public _isReadyForMeshStage = Stage.Create<MeshStageAction>();
|
|
|
|
+ /**
|
|
|
|
+ * Defines the actions happening during the per camera render target step.
|
|
|
|
+ */
|
|
|
|
+ public _cameraDrawRenderTargetStage = Stage.Create<CameraStageAction>();
|
|
|
|
+ /**
|
|
|
|
+ * Defines the actions happening just before the active camera is drawing.
|
|
|
|
+ */
|
|
|
|
+ public _beforeCameraDrawStage = Stage.Create<CameraStageAction>();
|
|
|
|
+ /**
|
|
|
|
+ * Defines the actions happening just after the active camera is drawing.
|
|
|
|
+ */
|
|
|
|
+ public _afterCameraDrawStage = Stage.Create<CameraStageAction>();
|
|
|
|
+
|
|
|
|
+ /**
|
|
* Creates a new Scene
|
|
* Creates a new Scene
|
|
* @param engine defines the engine to use to render this scene
|
|
* @param engine defines the engine to use to render this scene
|
|
*/
|
|
*/
|
|
constructor(engine: Engine) {
|
|
constructor(engine: Engine) {
|
|
|
|
+ super();
|
|
this._engine = engine || Engine.LastCreatedEngine;
|
|
this._engine = engine || Engine.LastCreatedEngine;
|
|
|
|
|
|
this._engine.scenes.push(this);
|
|
this._engine.scenes.push(this);
|
|
@@ -2322,8 +2299,8 @@
|
|
let engine = this.getEngine();
|
|
let engine = this.getEngine();
|
|
|
|
|
|
// Geometries
|
|
// Geometries
|
|
- for (index = 0; index < this._geometries.length; index++) {
|
|
|
|
- var geometry = this._geometries[index];
|
|
|
|
|
|
+ for (index = 0; index < this.geometries.length; index++) {
|
|
|
|
+ var geometry = this.geometries[index];
|
|
|
|
|
|
if (geometry.delayLoadState === Engine.DELAYLOADSTATE_LOADING) {
|
|
if (geometry.delayLoadState === Engine.DELAYLOADSTATE_LOADING) {
|
|
return false;
|
|
return false;
|
|
@@ -2346,17 +2323,11 @@
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- // Effect layers
|
|
|
|
let hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || engine.getCaps().instancedArrays && (<Mesh>mesh).instances.length > 0;
|
|
let hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || engine.getCaps().instancedArrays && (<Mesh>mesh).instances.length > 0;
|
|
- for (var layer of this.effectLayers) {
|
|
|
|
- if (!layer.hasMesh(mesh)) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (var subMesh of mesh.subMeshes) {
|
|
|
|
- if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
|
|
+ // Is Ready For Mesh
|
|
|
|
+ for (let step of this._isReadyForMeshStage) {
|
|
|
|
+ if (!step.action(mesh, hardwareInstancedRendering)) {
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2514,6 +2485,8 @@
|
|
|
|
|
|
/** @hidden */
|
|
/** @hidden */
|
|
public _checkIsReady() {
|
|
public _checkIsReady() {
|
|
|
|
+ this._registerTransientComponents();
|
|
|
|
+
|
|
if (this.isReady()) {
|
|
if (this.isReady()) {
|
|
this.onReadyObservable.notifyObservers(this);
|
|
this.onReadyObservable.notifyObservers(this);
|
|
|
|
|
|
@@ -3258,46 +3231,18 @@
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Removes the given lens flare system from this scene.
|
|
|
|
- * @param toRemove The lens flare system to remove
|
|
|
|
- * @returns The index of the removed lens flare system
|
|
|
|
- */
|
|
|
|
- public removeLensFlareSystem(toRemove: LensFlareSystem): number {
|
|
|
|
- var index = this.lensFlareSystems.indexOf(toRemove);
|
|
|
|
- if (index !== -1) {
|
|
|
|
- this.lensFlareSystems.splice(index, 1);
|
|
|
|
- }
|
|
|
|
- return index;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
* Removes the given action manager from this scene.
|
|
* Removes the given action manager from this scene.
|
|
* @param toRemove The action manager to remove
|
|
* @param toRemove The action manager to remove
|
|
* @returns The index of the removed action manager
|
|
* @returns The index of the removed action manager
|
|
*/
|
|
*/
|
|
public removeActionManager(toRemove: ActionManager): number {
|
|
public removeActionManager(toRemove: ActionManager): number {
|
|
- var index = this._actionManagers.indexOf(toRemove);
|
|
|
|
|
|
+ var index = this.actionManagers.indexOf(toRemove);
|
|
if (index !== -1) {
|
|
if (index !== -1) {
|
|
- this._actionManagers.splice(index, 1);
|
|
|
|
|
|
+ this.actionManagers.splice(index, 1);
|
|
}
|
|
}
|
|
return index;
|
|
return index;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Removes the given effect layer from this scene.
|
|
|
|
- * @param toRemove defines the effect layer to remove
|
|
|
|
- * @returns the index of the removed effect layer
|
|
|
|
- */
|
|
|
|
- public removeEffectLayer(toRemove: EffectLayer): number {
|
|
|
|
- var index = this.effectLayers.indexOf(toRemove);
|
|
|
|
- if (index !== -1) {
|
|
|
|
- this.effectLayers.splice(index, 1);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return index;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Removes the given texture from this scene.
|
|
* Removes the given texture from this scene.
|
|
* @param toRemove The texture to remove
|
|
* @param toRemove The texture to remove
|
|
@@ -3409,23 +3354,7 @@
|
|
* @param newGeometry The geometry to add
|
|
* @param newGeometry The geometry to add
|
|
*/
|
|
*/
|
|
public addGeometry(newGeometry: Geometry): void {
|
|
public addGeometry(newGeometry: Geometry): void {
|
|
- this._geometries.push(newGeometry);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Adds the given lens flare system to this scene
|
|
|
|
- * @param newLensFlareSystem The lens flare system to add
|
|
|
|
- */
|
|
|
|
- public addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void {
|
|
|
|
- this.lensFlareSystems.push(newLensFlareSystem);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Adds the given effect layer to this scene
|
|
|
|
- * @param newEffectLayer defines the effect layer to add
|
|
|
|
- */
|
|
|
|
- public addEffectLayer(newEffectLayer: EffectLayer): void {
|
|
|
|
- this.effectLayers.push(newEffectLayer);
|
|
|
|
|
|
+ this.geometries.push(newGeometry);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -3433,7 +3362,7 @@
|
|
* @param newActionManager The action manager to add
|
|
* @param newActionManager The action manager to add
|
|
*/
|
|
*/
|
|
public addActionManager(newActionManager: ActionManager): void {
|
|
public addActionManager(newActionManager: ActionManager): void {
|
|
- this._actionManagers.push(newActionManager);
|
|
|
|
|
|
+ this.actionManagers.push(newActionManager);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -3543,36 +3472,6 @@
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Gets a lens flare system using its name
|
|
|
|
- * @param name defines the name to look for
|
|
|
|
- * @returns the lens flare system or null if not found
|
|
|
|
- */
|
|
|
|
- public getLensFlareSystemByName(name: string): Nullable<LensFlareSystem> {
|
|
|
|
- for (var index = 0; index < this.lensFlareSystems.length; index++) {
|
|
|
|
- if (this.lensFlareSystems[index].name === name) {
|
|
|
|
- return this.lensFlareSystems[index];
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Gets a lens flare system using its id
|
|
|
|
- * @param id defines the id to look for
|
|
|
|
- * @returns the lens flare system or null if not found
|
|
|
|
- */
|
|
|
|
- public getLensFlareSystemByID(id: string): Nullable<LensFlareSystem> {
|
|
|
|
- for (var index = 0; index < this.lensFlareSystems.length; index++) {
|
|
|
|
- if (this.lensFlareSystems[index].id === id) {
|
|
|
|
- return this.lensFlareSystems[index];
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
* Gets a camera using its id
|
|
* Gets a camera using its id
|
|
* @param id defines the id to look for
|
|
* @param id defines the id to look for
|
|
* @returns the camera or null if not found
|
|
* @returns the camera or null if not found
|
|
@@ -3720,9 +3619,9 @@
|
|
* @return the geometry or null if none found.
|
|
* @return the geometry or null if none found.
|
|
*/
|
|
*/
|
|
public getGeometryByID(id: string): Nullable<Geometry> {
|
|
public getGeometryByID(id: string): Nullable<Geometry> {
|
|
- for (var index = 0; index < this._geometries.length; index++) {
|
|
|
|
- if (this._geometries[index].id === id) {
|
|
|
|
- return this._geometries[index];
|
|
|
|
|
|
+ for (var index = 0; index < this.geometries.length; index++) {
|
|
|
|
+ if (this.geometries[index].id === id) {
|
|
|
|
+ return this.geometries[index];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3740,7 +3639,7 @@
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- this._geometries.push(geometry);
|
|
|
|
|
|
+ this.geometries.push(geometry);
|
|
|
|
|
|
//notify the collision coordinator
|
|
//notify the collision coordinator
|
|
if (this.collisionCoordinator) {
|
|
if (this.collisionCoordinator) {
|
|
@@ -3758,10 +3657,10 @@
|
|
* @return a boolean defining if the geometry was removed or not
|
|
* @return a boolean defining if the geometry was removed or not
|
|
*/
|
|
*/
|
|
public removeGeometry(geometry: Geometry): boolean {
|
|
public removeGeometry(geometry: Geometry): boolean {
|
|
- var index = this._geometries.indexOf(geometry);
|
|
|
|
|
|
+ var index = this.geometries.indexOf(geometry);
|
|
|
|
|
|
if (index > -1) {
|
|
if (index > -1) {
|
|
- this._geometries.splice(index, 1);
|
|
|
|
|
|
+ this.geometries.splice(index, 1);
|
|
|
|
|
|
//notify the collision coordinator
|
|
//notify the collision coordinator
|
|
if (this.collisionCoordinator) {
|
|
if (this.collisionCoordinator) {
|
|
@@ -3779,7 +3678,7 @@
|
|
* @returns an array of Geometry
|
|
* @returns an array of Geometry
|
|
*/
|
|
*/
|
|
public getGeometries(): Geometry[] {
|
|
public getGeometries(): Geometry[] {
|
|
- return this._geometries;
|
|
|
|
|
|
+ return this.geometries;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -4082,36 +3981,6 @@
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Return a the first highlight layer of the scene with a given name.
|
|
|
|
- * @param name The name of the highlight layer to look for.
|
|
|
|
- * @return The highlight layer if found otherwise null.
|
|
|
|
- */
|
|
|
|
- public getHighlightLayerByName(name: string): Nullable<HighlightLayer> {
|
|
|
|
- for (var index = 0; index < this.effectLayers.length; index++) {
|
|
|
|
- if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
|
|
|
|
- return (<any>this.effectLayers[index]) as HighlightLayer;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Return a the first highlight layer of the scene with a given name.
|
|
|
|
- * @param name The name of the highlight layer to look for.
|
|
|
|
- * @return The highlight layer if found otherwise null.
|
|
|
|
- */
|
|
|
|
- public getGlowLayerByName(name: string): Nullable<GlowLayer> {
|
|
|
|
- for (var index = 0; index < this.effectLayers.length; index++) {
|
|
|
|
- if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
|
|
|
|
- return (<any>this.effectLayers[index]) as GlowLayer;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
* Return a unique id as a string which can serve as an identifier for the scene
|
|
* Return a unique id as a string which can serve as an identifier for the scene
|
|
*/
|
|
*/
|
|
public get uid(): string {
|
|
public get uid(): string {
|
|
@@ -4504,7 +4373,6 @@
|
|
|
|
|
|
// Render targets
|
|
// Render targets
|
|
this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
|
|
this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
|
|
- var needsRestoreFrameBuffer = false;
|
|
|
|
|
|
|
|
if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
|
|
if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
|
|
this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
|
|
this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
|
|
@@ -4514,57 +4382,31 @@
|
|
this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
|
|
this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
|
|
}
|
|
}
|
|
|
|
|
|
- if (this.renderTargetsEnabled && this._renderTargets.length > 0) {
|
|
|
|
- this._intermediateRendering = true;
|
|
|
|
- Tools.StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
|
|
|
|
- for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
|
|
|
|
- let renderTarget = this._renderTargets.data[renderIndex];
|
|
|
|
- if (renderTarget._shouldRender()) {
|
|
|
|
- this._renderId++;
|
|
|
|
- var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
|
|
|
|
- renderTarget.render((<boolean>hasSpecialRenderTargetCamera), this.dumpNextRenderTargets);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- Tools.EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
|
|
|
|
-
|
|
|
|
- this._intermediateRendering = false;
|
|
|
|
- this._renderId++;
|
|
|
|
-
|
|
|
|
- needsRestoreFrameBuffer = true; // Restore back buffer
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Render EffectLayer Texture
|
|
|
|
- var stencilState = this._engine.getStencilBuffer();
|
|
|
|
- var renderEffects = false;
|
|
|
|
- var needStencil = false;
|
|
|
|
- if (this.renderTargetsEnabled && this.effectLayers && this.effectLayers.length > 0) {
|
|
|
|
|
|
+ if (this.renderTargetsEnabled) {
|
|
this._intermediateRendering = true;
|
|
this._intermediateRendering = true;
|
|
- for (let i = 0; i < this.effectLayers.length; i++) {
|
|
|
|
- let effectLayer = this.effectLayers[i];
|
|
|
|
-
|
|
|
|
- if (effectLayer.shouldRender() &&
|
|
|
|
- (!effectLayer.camera ||
|
|
|
|
- (effectLayer.camera.cameraRigMode === Camera.RIG_MODE_NONE && camera === effectLayer.camera) ||
|
|
|
|
- (effectLayer.camera.cameraRigMode !== Camera.RIG_MODE_NONE && effectLayer.camera._rigCameras.indexOf(camera) > -1))) {
|
|
|
|
-
|
|
|
|
- renderEffects = true;
|
|
|
|
- needStencil = needStencil || effectLayer.needStencil();
|
|
|
|
-
|
|
|
|
- let renderTarget = (<RenderTargetTexture>(<any>effectLayer)._mainTexture);
|
|
|
|
|
|
+
|
|
|
|
+ if (this._renderTargets.length > 0) {
|
|
|
|
+ Tools.StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
|
|
|
|
+ for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
|
|
|
|
+ let renderTarget = this._renderTargets.data[renderIndex];
|
|
if (renderTarget._shouldRender()) {
|
|
if (renderTarget._shouldRender()) {
|
|
this._renderId++;
|
|
this._renderId++;
|
|
- renderTarget.render(false, false);
|
|
|
|
- needsRestoreFrameBuffer = true;
|
|
|
|
|
|
+ var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
|
|
|
|
+ renderTarget.render((<boolean>hasSpecialRenderTargetCamera), this.dumpNextRenderTargets);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ Tools.EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
|
|
|
|
+
|
|
|
|
+ this._renderId++;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (let step of this._cameraDrawRenderTargetStage) {
|
|
|
|
+ step.action(this.activeCamera);
|
|
}
|
|
}
|
|
|
|
|
|
this._intermediateRendering = false;
|
|
this._intermediateRendering = false;
|
|
- this._renderId++;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- if (needsRestoreFrameBuffer) {
|
|
|
|
- engine.restoreDefaultFramebuffer(); // Restore back buffer
|
|
|
|
|
|
+ engine.restoreDefaultFramebuffer(); // Restore back buffer if needed
|
|
}
|
|
}
|
|
|
|
|
|
this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
|
|
this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
|
|
@@ -4574,23 +4416,9 @@
|
|
this.postProcessManager._prepareFrame();
|
|
this.postProcessManager._prepareFrame();
|
|
}
|
|
}
|
|
|
|
|
|
- // Backgrounds
|
|
|
|
- var layerIndex;
|
|
|
|
- var layer;
|
|
|
|
- if (this.layers.length) {
|
|
|
|
- engine.setDepthBuffer(false);
|
|
|
|
- for (layerIndex = 0; layerIndex < this.layers.length; layerIndex++) {
|
|
|
|
- layer = this.layers[layerIndex];
|
|
|
|
- if (layer.isBackground && ((layer.layerMask & this.activeCamera.layerMask) !== 0)) {
|
|
|
|
- layer.render();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- engine.setDepthBuffer(true);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Activate effect Layer stencil
|
|
|
|
- if (needStencil) {
|
|
|
|
- this._engine.setStencilBuffer(true);
|
|
|
|
|
|
+ // Before Camera Draw
|
|
|
|
+ for (let step of this._beforeCameraDrawStage) {
|
|
|
|
+ step.action(this.activeCamera);
|
|
}
|
|
}
|
|
|
|
|
|
// Render
|
|
// Render
|
|
@@ -4598,51 +4426,15 @@
|
|
this._renderingManager.render(null, null, true, true);
|
|
this._renderingManager.render(null, null, true, true);
|
|
this.onAfterDrawPhaseObservable.notifyObservers(this);
|
|
this.onAfterDrawPhaseObservable.notifyObservers(this);
|
|
|
|
|
|
- // Restore effect Layer stencil
|
|
|
|
- if (needStencil) {
|
|
|
|
- this._engine.setStencilBuffer(stencilState);
|
|
|
|
|
|
+ // After Camera Draw
|
|
|
|
+ for (let step of this._afterCameraDrawStage) {
|
|
|
|
+ step.action(this.activeCamera);
|
|
}
|
|
}
|
|
|
|
|
|
// Bounding boxes
|
|
// Bounding boxes
|
|
if (this._boundingBoxRenderer) {
|
|
if (this._boundingBoxRenderer) {
|
|
this._boundingBoxRenderer.render();
|
|
this._boundingBoxRenderer.render();
|
|
}
|
|
}
|
|
-
|
|
|
|
- // Lens flares
|
|
|
|
- if (this.lensFlaresEnabled) {
|
|
|
|
- Tools.StartPerformanceCounter("Lens flares", this.lensFlareSystems.length > 0);
|
|
|
|
- for (var lensFlareSystemIndex = 0; lensFlareSystemIndex < this.lensFlareSystems.length; lensFlareSystemIndex++) {
|
|
|
|
-
|
|
|
|
- var lensFlareSystem = this.lensFlareSystems[lensFlareSystemIndex];
|
|
|
|
- if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {
|
|
|
|
- lensFlareSystem.render();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- Tools.EndPerformanceCounter("Lens flares", this.lensFlareSystems.length > 0);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Effect Layer
|
|
|
|
- if (renderEffects) {
|
|
|
|
- engine.setDepthBuffer(false);
|
|
|
|
- for (let i = 0; i < this.effectLayers.length; i++) {
|
|
|
|
- if (this.effectLayers[i].shouldRender()) {
|
|
|
|
- this.effectLayers[i].render();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- engine.setDepthBuffer(true);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Foregrounds
|
|
|
|
- if (this.layers.length) {
|
|
|
|
- engine.setDepthBuffer(false);
|
|
|
|
- for (layerIndex = 0; layerIndex < this.layers.length; layerIndex++) {
|
|
|
|
- layer = this.layers[layerIndex];
|
|
|
|
- if (!layer.isBackground && ((layer.layerMask & this.activeCamera.layerMask) !== 0)) {
|
|
|
|
- layer.render();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- engine.setDepthBuffer(true);
|
|
|
|
- }
|
|
|
|
|
|
|
|
// Finalize frame
|
|
// Finalize frame
|
|
if (this.postProcessManager) {
|
|
if (this.postProcessManager) {
|
|
@@ -4727,6 +4519,9 @@
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Register components that have been associated lately to the scene.
|
|
|
|
+ this._registerTransientComponents();
|
|
|
|
+
|
|
this._activeParticles.fetchNewFrame();
|
|
this._activeParticles.fetchNewFrame();
|
|
this._totalVertices.fetchNewFrame();
|
|
this._totalVertices.fetchNewFrame();
|
|
this._activeIndices.fetchNewFrame();
|
|
this._activeIndices.fetchNewFrame();
|
|
@@ -5203,6 +4998,14 @@
|
|
|
|
|
|
this.skeletons = [];
|
|
this.skeletons = [];
|
|
this.morphTargetManagers = [];
|
|
this.morphTargetManagers = [];
|
|
|
|
+ this._transientComponents = [];
|
|
|
|
+ this._isReadyForMeshStage.clear();
|
|
|
|
+ this._cameraDrawRenderTargetStage.clear();
|
|
|
|
+ this._beforeCameraDrawStage.clear();
|
|
|
|
+ this._afterCameraDrawStage.clear();
|
|
|
|
+ for (let component of this._components) {
|
|
|
|
+ component.dispose();
|
|
|
|
+ }
|
|
|
|
|
|
this.importedMeshesFiles = new Array<string>();
|
|
this.importedMeshesFiles = new Array<string>();
|
|
|
|
|
|
@@ -5344,14 +5147,6 @@
|
|
this.postProcesses[0].dispose();
|
|
this.postProcesses[0].dispose();
|
|
}
|
|
}
|
|
|
|
|
|
- // Release layers
|
|
|
|
- while (this.layers.length) {
|
|
|
|
- this.layers[0].dispose();
|
|
|
|
- }
|
|
|
|
- while (this.effectLayers.length) {
|
|
|
|
- this.effectLayers[0].dispose();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// Release textures
|
|
// Release textures
|
|
while (this.textures.length) {
|
|
while (this.textures.length) {
|
|
this.textures[0].dispose();
|
|
this.textures[0].dispose();
|
|
@@ -5927,7 +5722,7 @@
|
|
// Misc.
|
|
// Misc.
|
|
/** @hidden */
|
|
/** @hidden */
|
|
public _rebuildGeometries(): void {
|
|
public _rebuildGeometries(): void {
|
|
- for (var geometry of this._geometries) {
|
|
|
|
|
|
+ for (var geometry of this.geometries) {
|
|
geometry._rebuild();
|
|
geometry._rebuild();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -5939,12 +5734,8 @@
|
|
this.postProcessManager._rebuild();
|
|
this.postProcessManager._rebuild();
|
|
}
|
|
}
|
|
|
|
|
|
- for (var layer of this.layers) {
|
|
|
|
- layer._rebuild();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (var effectLayer of this.effectLayers) {
|
|
|
|
- effectLayer._rebuild();
|
|
|
|
|
|
+ for (let component of this._components) {
|
|
|
|
+ component.rebuild();
|
|
}
|
|
}
|
|
|
|
|
|
if (this._boundingBoxRenderer) {
|
|
if (this._boundingBoxRenderer) {
|