add matrix readonly getter

This commit is contained in:
jerrywwl
2019-04-23 10:43:49 +08:00
parent d259b23355
commit befa4a3728
3 changed files with 8 additions and 5 deletions
+2 -4
View File
@@ -174,8 +174,7 @@ export class Camera {
if (this._node) {
// view matrix
if (this._node.hasChanged) {
this.node.getWorldRT(this._matView);
mat4.invert(this._matView, this._matView);
mat4.invert(this._matView, this.node.worldMatrix);
this._forward.x = -this._matView.m02;
this._forward.y = -this._matView.m06;
@@ -214,8 +213,7 @@ export class Camera {
farClip = Math.min(farClip, this._farClip);
// view matrix
this.node.getWorldRT(this._matView);
mat4.invert(this._matView, this._matView);
mat4.invert(this._matView, this.node.worldMatrix);
// projection matrix
if (this._proj === CameraProjection.PERSPECTIVE) {
+1 -1
View File
@@ -100,7 +100,7 @@ export class RenderScene {
this._defaultMainLightNode = new Node('Main Light');
this._mainLight = new DirectionalLight(this, 'Main Light', this._defaultMainLightNode);
this._mainLight.illuminance = Ambient.SUN_ILLUM;
this._mainLight.enabled = false; // disabled by default
this._mainLight.enabled = true; // enabled by default
this._ambient = new Ambient(this);
this._skybox = new Skybox(this);
this._planarShadow = new PlanarShadow(this);
+5
View File
@@ -745,6 +745,11 @@ class Node extends BaseNode {
}
}
public get worldMatrix (): Readonly<Mat4> {
this.updateWorldTransformFull();
return this._mat;
}
/**
* get world transform matrix (with only rotation and scale)
* @param out - the receiving matrix