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