mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
add matrix readonly getter
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user