override camera
parent
43b7be5e37
commit
99cef0a288
|
@ -8,6 +8,7 @@
|
|||
* @param materials [GameLib.D3.API.Material]
|
||||
* @param images
|
||||
* @param fog
|
||||
* @param renderCamera - this is a camera which takes precedence over the renderer camera at time of render
|
||||
* @param parentEntity
|
||||
* @constructor
|
||||
*/
|
||||
|
@ -20,6 +21,7 @@ GameLib.D3.API.Scene = function(
|
|||
materials,
|
||||
images,
|
||||
fog,
|
||||
renderCamera,
|
||||
parentEntity
|
||||
) {
|
||||
|
||||
|
@ -63,6 +65,11 @@ GameLib.D3.API.Scene = function(
|
|||
}
|
||||
this.fog = fog;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(renderCamera)) {
|
||||
renderCamera = null;
|
||||
}
|
||||
this.renderCamera = renderCamera;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||
parentEntity = null;
|
||||
}
|
||||
|
@ -155,6 +162,7 @@ GameLib.D3.API.Scene.FromObject = function(objectScene) {
|
|||
apiMaterials,
|
||||
apiImages,
|
||||
objectScene.fog,
|
||||
objectScene.renderCamera,
|
||||
objectScene.parentEntity
|
||||
);
|
||||
|
||||
|
|
|
@ -368,14 +368,24 @@ GameLib.D3.Renderer.prototype.render = function(delta, scenes) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!this.camera.instance) {
|
||||
if (!this.camera.instance && !(scene.renderCamera || scene.renderCamera.instance)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.instance.render(
|
||||
scene.instance,
|
||||
this.camera.instance
|
||||
)
|
||||
/**
|
||||
* A scene's renderCamera instance overrides the default renderer camera
|
||||
*/
|
||||
if (scene.renderCamera && scene.renderCamera.instance) {
|
||||
this.instance.render(
|
||||
scene.instance,
|
||||
scene.renderCamera.instance
|
||||
)
|
||||
} else {
|
||||
this.instance.render(
|
||||
scene.instance,
|
||||
this.camera.instance
|
||||
)
|
||||
}
|
||||
|
||||
}.bind(this));
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ GameLib.D3.Scene = function (
|
|||
apiScene.materials,
|
||||
apiScene.images,
|
||||
apiScene.fog,
|
||||
apiScene.renderCamera,
|
||||
apiScene.parentEntity
|
||||
);
|
||||
|
||||
|
@ -131,6 +132,13 @@ GameLib.D3.Scene = function (
|
|||
)
|
||||
}
|
||||
|
||||
if (this.renderCamera instanceof GameLib.D3.API.Camera) {
|
||||
this.renderCamera = new GameLib.D3.Camera(
|
||||
this.graphics,
|
||||
this.renderCamera
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Runtime scenes have helpers (just used to store which helper belongs to which scene)
|
||||
* @type {Array}
|
||||
|
@ -146,7 +154,8 @@ GameLib.D3.Scene = function (
|
|||
'textures' : [GameLib.D3.Texture],
|
||||
'materials' : [GameLib.D3.Material],
|
||||
'images' : [GameLib.D3.Image],
|
||||
'fog' : GameLib.D3.Fog
|
||||
'fog' : GameLib.D3.Fog,
|
||||
'renderCamera' : GameLib.D3.Camera
|
||||
}
|
||||
);
|
||||
};
|
||||
|
@ -315,6 +324,7 @@ GameLib.D3.Scene.prototype.toApiObject = function() {
|
|||
apiMaterials,
|
||||
apiImages,
|
||||
GameLib.Utils.IdOrNull(this.fog),
|
||||
GameLib.Utils.IdOrNull(this.renderCamera),
|
||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue