Преглед изворни кода

Merge remote-tracking branch 'remotes/origin/master' into pgMonaco

David `Deltakosh` Catuhe пре 5 година
родитељ
комит
7ff12f1693

+ 6 - 0
dist/preview release/what's new.md

@@ -25,14 +25,17 @@
 - Added initial code for DeviceInputSystem ([PolygonalSun](https://github.com/PolygonalSun))
 - Added support for `material.disableColorWrite` ([Deltakosh](https://github.com/deltakosh))
 - The Mesh Asset Task also accepts File as sceneInput ([RaananW](https://github.com/RaananW))
+- Gizmo axis thickness ([cedricguillemet](https://github.com/cedricguillemet))
 - Added support preserving vert colors for CSG objects ([PirateJC](https://github.com/PirateJC))
 - Added `boundingBoxRenderer.onBeforeBoxRenderingObservable` and `boundingBoxRenderer.onAfterBoxRenderingObservable` ([Deltakosh](https://github.com/deltakosh))
+- Better plane handling for PointerDragBehavior when camera direction colinear to axis ([cedricguillemet](https://github.com/cedricguillemet))
 - Added initial code for user facing DeviceSourceManager ([PolygonalSun](https://github.com/PolygonalSun))
 - Added a Simple and advanced timer, based on observables ([RaananW](https://github.com/RaananW))
 - Don't log a message in `CustomProceduralTexture` if the `texturePath` is not a JSON path ([Popov72](https://github.com/Popov72))
 - Added an alternate option to the mesh edge renderer to generate edges faster / more accurately for unusual geometries (like the ones generated by CSG) ([Popov72](https://github.com/Popov72))
 - Added an option when creating the engine to switch matrix computation to 64 bits ([Popov72](https://github.com/Popov72))
 - Added support for the alpha component to the SSR post-process ([Popov72](https://github.com/Popov72))
+- Force compute world matrix of the newly-attached mesh of a ray helper ([RaananW](https://github.com/RaananW))
 
 ### Engine
 
@@ -132,6 +135,7 @@
 - Allow using the single comment syntax `// comment` in a `#if` construct in shader code ([Popov72](https://github.com/Popov72))
 - Added the possibility to update the shader code before being compiled ([Popov72](https://github.com/Popov72))
 - Added the `shadowOnly` property to the `BackgroundMaterial` class ([Popov72](https://github.com/Popov72))
+- Added support for lightmaps in unlit PBR materials ([Popov72](https://github.com/Popov72))
 
 ### WebXR
 
@@ -201,6 +205,7 @@
 - Fix infinite loop in `GlowLayer.unReferenceMeshFromUsingItsOwnMaterial` ([Popov72](https://github.com/Popov72))
 - Fix picking issue in the Solid Particle System when MultiMaterial is enabled ([jerome](https://github.com/jbousquie))
 - Fix picking issue in the Solid Particle System when expandable ([jerome](https://github.com/jbousquie))
+- Fix use of skeleton override matrix in mesh ray intersection ([cedricguillemet](https://github.com/cedricguillemet))
 - `QuadraticErrorSimplification` was not exported ([RaananW](https://github.com/Raananw))
 - Fix NME Frames bug where collapsing and moving a frame removed the nodes inside ([belfortk](https://github.com/belfortk))
 - Fix moving / disappearing controls when freezing/unfreezing the ScrollViewer ([Popov72](https://github.com/Popov72))
@@ -258,6 +263,7 @@
 - Fix skeleton viewer still visible when `isEnabled = false` ([Popov72](https://github.com/Popov72))
 - Fix crash with CSG when no uvs defined ([Popov72](https://github.com/Popov72))
 - Fix an issue causing views to render blank when scene rendering is skipped for a given iteration of the render loop ([elInfidel](https://github.com/elInfidel))
+- Fix docs Matrix.RotationYawPitchRoll and Matrix.RotationYawPitchRollToRef ([VSerain](https://github.com/VSerain))
 
 ## Breaking changes
 

+ 18 - 13
src/Behaviors/Meshes/pointerDragBehavior.ts

@@ -398,10 +398,7 @@ export class PointerDragBehavior implements Behavior<AbstractMesh> {
 
     // Variables to avoid instantiation in the below method
     private _pointA = new Vector3(0, 0, 0);
-    private _pointB = new Vector3(0, 0, 0);
     private _pointC = new Vector3(0, 0, 0);
-    private _lineA = new Vector3(0, 0, 0);
-    private _lineB = new Vector3(0, 0, 0);
     private _localAxis = new Vector3(0, 0, 0);
     private _lookAt = new Vector3(0, 0, 0);
     // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera
@@ -410,17 +407,25 @@ export class PointerDragBehavior implements Behavior<AbstractMesh> {
         if (this._options.dragAxis) {
             this.useObjectOrientationForDragging ? Vector3.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragAxis);
 
-            // Calculate plane normal in direction of camera but perpendicular to drag axis
-            this._pointA.addToRef(this._localAxis, this._pointB); // towards drag axis
+            // Calculate plane normal that is the cross product of local axis and (eye-dragPlanePosition)
             ray.origin.subtractToRef(this._pointA, this._pointC);
-            this._pointA.addToRef(this._pointC.normalize(), this._pointC); // towards camera
-            // Get perpendicular line from direction to camera and drag axis
-            this._pointB.subtractToRef(this._pointA, this._lineA);
-            this._pointC.subtractToRef(this._pointA, this._lineB);
-            Vector3.CrossToRef(this._lineA, this._lineB, this._lookAt);
-            // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
-            Vector3.CrossToRef(this._lineA, this._lookAt, this._lookAt);
-            this._lookAt.normalize();
+            this._pointC.normalize();
+            if (Math.abs(Vector3.Dot(this._localAxis, this._pointC)) > 0.999)
+            {
+                // the drag axis is colinear with the (eye to position) ray. The cross product will give jittered values.
+                // A new axis vector need to be computed
+                if (Math.abs(Vector3.Dot(Vector3.UpReadOnly, this._pointC)) > 0.999)
+                {
+                    this._lookAt.copyFrom(Vector3.Right());
+                } else {
+                    this._lookAt.copyFrom(Vector3.UpReadOnly);
+                }
+            } else {
+                Vector3.CrossToRef(this._localAxis, this._pointC, this._lookAt);
+                // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
+                Vector3.CrossToRef(this._localAxis, this._lookAt, this._lookAt);
+                this._lookAt.normalize();
+            }
 
             this._dragPlane.position.copyFrom(this._pointA);
             this._pointA.addToRef(this._lookAt, this._lookAt);

+ 7 - 1
src/Bones/bone.ts

@@ -437,6 +437,8 @@ export class Bone extends Node {
                 } else {
                     tmat.copyFrom(this._parent.getAbsoluteTransform());
                 }
+            } else {
+                Matrix.IdentityToRef(tmat);
             }
 
             tmat.setTranslationFromFloats(0, 0, 0);
@@ -482,9 +484,11 @@ export class Bone extends Node {
                 } else {
                     tmat.copyFrom(this._parent.getAbsoluteTransform());
                 }
+                tmat.invert();
+            } else {
+                Matrix.IdentityToRef(tmat);
             }
 
-            tmat.invert();
             Vector3.TransformCoordinatesToRef(position, tmat, vec);
             lm.setTranslationFromFloats(vec.x, vec.y, vec.z);
         }
@@ -859,6 +863,8 @@ export class Bone extends Node {
             }
         }
 
+        this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);
+
         var children = this.children;
         var len = children.length;
 

+ 3 - 0
src/Debug/rayHelper.ts

@@ -173,6 +173,9 @@ export class RayHelper {
             this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction);
         }
 
+        // force world matrix computation before the first ray helper computation
+        this._attachedToMesh.computeWorldMatrix(true);
+
         this._updateToMesh();
     }
 

+ 6 - 5
src/Gizmos/axisDragGizmo.ts

@@ -41,10 +41,10 @@ export class AxisDragGizmo extends Gizmo {
     private _hoverMaterial: StandardMaterial;
 
     /** @hidden */
-    public static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode {
+    public static _CreateArrow(scene: Scene, material: StandardMaterial, thickness: number = 1): TransformNode {
         var arrow = new TransformNode("arrow", scene);
-        var cylinder = CylinderBuilder.CreateCylinder("cylinder", { diameterTop: 0, height: 0.075, diameterBottom: 0.0375, tessellation: 96 }, scene);
-        var line = CylinderBuilder.CreateCylinder("cylinder", { diameterTop: 0.005, height: 0.275, diameterBottom: 0.005, tessellation: 96 }, scene);
+        var cylinder = CylinderBuilder.CreateCylinder("cylinder", { diameterTop: 0, height: 0.075, diameterBottom: 0.0375 * (1 + (thickness - 1) / 4), tessellation: 96 }, scene);
+        var line = CylinderBuilder.CreateCylinder("cylinder", { diameterTop: 0.005 * thickness, height: 0.275, diameterBottom: 0.005 * thickness, tessellation: 96 }, scene);
         line.material = material;
         cylinder.parent = arrow;
         line.parent = arrow;
@@ -73,8 +73,9 @@ export class AxisDragGizmo extends Gizmo {
      * @param gizmoLayer The utility layer the gizmo will be added to
      * @param dragAxis The axis which the gizmo will be able to drag on
      * @param color The color of the gizmo
+     * @param thickness display gizmo axis thickness
      */
-    constructor(dragAxis: Vector3, color: Color3 = Color3.Gray(), gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer, parent: Nullable<PositionGizmo> = null) {
+    constructor(dragAxis: Vector3, color: Color3 = Color3.Gray(), gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer, parent: Nullable<PositionGizmo> = null, thickness: number = 1) {
         super(gizmoLayer);
         this._parent = parent;
         // Create Material
@@ -86,7 +87,7 @@ export class AxisDragGizmo extends Gizmo {
         this._hoverMaterial.diffuseColor = color.add(new Color3(0.3, 0.3, 0.3));
 
         // Build mesh on root node
-        this._arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, this._coloredMaterial);
+        this._arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, this._coloredMaterial, thickness);
 
         this._arrow.lookAt(this._rootMesh.position.add(dragAxis));
         this._arrow.scaling.scaleInPlace(1 / 3);

+ 4 - 3
src/Gizmos/axisScaleGizmo.ts

@@ -54,8 +54,9 @@ export class AxisScaleGizmo extends Gizmo {
      * @param gizmoLayer The utility layer the gizmo will be added to
      * @param dragAxis The axis which the gizmo will be able to scale on
      * @param color The color of the gizmo
+     * @param thickness display gizmo axis thickness
      */
-    constructor(dragAxis: Vector3, color: Color3 = Color3.Gray(), gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer, parent: Nullable<ScaleGizmo> = null) {
+    constructor(dragAxis: Vector3, color: Color3 = Color3.Gray(), gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer, parent: Nullable<ScaleGizmo> = null, thickness: number = 1) {
         super(gizmoLayer);
         this._parent = parent;
         // Create Material
@@ -68,8 +69,8 @@ export class AxisScaleGizmo extends Gizmo {
 
         // Build mesh on root node
         this._arrow = new AbstractMesh("", gizmoLayer.utilityLayerScene);
-        var arrowMesh = BoxBuilder.CreateBox("yPosMesh", { size: 0.4 }, gizmoLayer.utilityLayerScene);
-        var arrowTail = CylinderBuilder.CreateCylinder("cylinder", { diameterTop: 0.005, height: 0.275, diameterBottom: 0.005, tessellation: 96 }, gizmoLayer.utilityLayerScene);
+        var arrowMesh = BoxBuilder.CreateBox("yPosMesh", { size: 0.4 * (1 + (thickness - 1) / 4) }, gizmoLayer.utilityLayerScene);
+        var arrowTail = CylinderBuilder.CreateCylinder("cylinder", { diameterTop: 0.005 * thickness, height: 0.275, diameterBottom: 0.005 * thickness, tessellation: 96 }, gizmoLayer.utilityLayerScene);
         arrowTail.material = this._coloredMaterial;
         this._arrow.addChild(arrowMesh);
         this._arrow.addChild(arrowTail);

+ 1 - 1
src/Gizmos/gizmo.ts

@@ -161,7 +161,7 @@ export class Gizmo implements IDisposable {
         if (!this._attachedNode) {
             return;
         }
-        if (this._attachedNode.getClassName() === "Mesh" || this._attachedNode.getClassName() === "TransformNode") {
+        if (this._attachedNode.getClassName() === "Mesh" || this._attachedNode.getClassName() === "AbstractMesh" || this._attachedNode.getClassName() === "TransformNode") {
             var transform = this._attachedNode as TransformNode;
             var transformQuaternion = new Quaternion(0, 0, 0, 1);
             if (transform.parent) {

+ 7 - 5
src/Gizmos/gizmoManager.ts

@@ -32,6 +32,7 @@ export class GizmoManager implements IDisposable {
     private _boundingBoxColor = Color3.FromHexString("#0984e3");
     private _defaultUtilityLayer: UtilityLayerRenderer;
     private _defaultKeepDepthUtilityLayer: UtilityLayerRenderer;
+    private _thickness: number = 1;
     /**
      * When bounding box gizmo is enabled, this can be used to track drag/end events
      */
@@ -62,12 +63,13 @@ export class GizmoManager implements IDisposable {
     /**
      * Instatiates a gizmo manager
      * @param scene the scene to overlay the gizmos on top of
+     * @param thickness display gizmo axis thickness
      */
-    constructor(private scene: Scene) {
+    constructor(private scene: Scene, thickness: number = 1) {
         this._defaultKeepDepthUtilityLayer = new UtilityLayerRenderer(scene);
         this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
         this._defaultUtilityLayer = new UtilityLayerRenderer(scene);
-
+        this._thickness = thickness;
         this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
 
         // Instatiate/dispose gizmos based on pointer actions
@@ -141,7 +143,7 @@ export class GizmoManager implements IDisposable {
     public set positionGizmoEnabled(value: boolean) {
         if (value) {
             if (!this.gizmos.positionGizmo) {
-                this.gizmos.positionGizmo = new PositionGizmo(this._defaultUtilityLayer);
+                this.gizmos.positionGizmo = new PositionGizmo(this._defaultUtilityLayer, this._thickness);
             }
             this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
         } else if (this.gizmos.positionGizmo) {
@@ -158,7 +160,7 @@ export class GizmoManager implements IDisposable {
     public set rotationGizmoEnabled(value: boolean) {
         if (value) {
             if (!this.gizmos.rotationGizmo) {
-                this.gizmos.rotationGizmo = new RotationGizmo(this._defaultUtilityLayer);
+                this.gizmos.rotationGizmo = new RotationGizmo(this._defaultUtilityLayer, 32, false, this._thickness);
             }
             this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
         } else if (this.gizmos.rotationGizmo) {
@@ -174,7 +176,7 @@ export class GizmoManager implements IDisposable {
      */
     public set scaleGizmoEnabled(value: boolean) {
         if (value) {
-            this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new ScaleGizmo(this._defaultUtilityLayer);
+            this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new ScaleGizmo(this._defaultUtilityLayer, this._thickness);
             this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
         } else if (this.gizmos.scaleGizmo) {
             this.gizmos.scaleGizmo.attachedMesh = null;

+ 4 - 3
src/Gizmos/planeRotationGizmo.ts

@@ -45,8 +45,9 @@ export class PlaneRotationGizmo extends Gizmo {
      * @param color The color of the gizmo
      * @param tessellation Amount of tessellation to be used when creating rotation circles
      * @param useEulerRotation Use and update Euler angle instead of quaternion
+     * @param thickness display gizmo axis thickness
      */
-    constructor(planeNormal: Vector3, color: Color3 = Color3.Gray(), gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer, tessellation = 32, parent: Nullable<RotationGizmo> = null, useEulerRotation = false) {
+    constructor(planeNormal: Vector3, color: Color3 = Color3.Gray(), gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer, tessellation = 32, parent: Nullable<RotationGizmo> = null, useEulerRotation = false, thickness: number = 1) {
         super(gizmoLayer);
         this._parent = parent;
         // Create Material
@@ -60,9 +61,9 @@ export class PlaneRotationGizmo extends Gizmo {
         // Build mesh on root node
         var parentMesh = new AbstractMesh("", gizmoLayer.utilityLayerScene);
 
-        let drag = Mesh.CreateTorus("", 0.6, 0.03, tessellation, gizmoLayer.utilityLayerScene);
+        let drag = Mesh.CreateTorus("", 0.6, 0.03 * thickness, tessellation, gizmoLayer.utilityLayerScene);
         drag.visibility = 0;
-        let rotationMesh = Mesh.CreateTorus("", 0.6, 0.005, tessellation, gizmoLayer.utilityLayerScene);
+        let rotationMesh = Mesh.CreateTorus("", 0.6, 0.005 * thickness, tessellation, gizmoLayer.utilityLayerScene);
         rotationMesh.material = coloredMaterial;
 
         // Position arrow pointing in its drag axis

+ 5 - 4
src/Gizmos/positionGizmo.ts

@@ -92,12 +92,13 @@ export class PositionGizmo extends Gizmo {
     /**
      * Creates a PositionGizmo
      * @param gizmoLayer The utility layer the gizmo will be added to
+      @param thickness display gizmo axis thickness
      */
-    constructor(gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer) {
+    constructor(gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer, thickness: number = 1) {
         super(gizmoLayer);
-        this.xGizmo = new AxisDragGizmo(new Vector3(1, 0, 0), Color3.Red().scale(0.5), gizmoLayer, this);
-        this.yGizmo = new AxisDragGizmo(new Vector3(0, 1, 0), Color3.Green().scale(0.5), gizmoLayer, this);
-        this.zGizmo = new AxisDragGizmo(new Vector3(0, 0, 1), Color3.Blue().scale(0.5), gizmoLayer, this);
+        this.xGizmo = new AxisDragGizmo(new Vector3(1, 0, 0), Color3.Red().scale(0.5), gizmoLayer, this, thickness);
+        this.yGizmo = new AxisDragGizmo(new Vector3(0, 1, 0), Color3.Green().scale(0.5), gizmoLayer, this, thickness);
+        this.zGizmo = new AxisDragGizmo(new Vector3(0, 0, 1), Color3.Blue().scale(0.5), gizmoLayer, this, thickness);
 
         this.xPlaneGizmo = new PlaneDragGizmo(new Vector3(1, 0, 0), Color3.Red().scale(0.5), this.gizmoLayer, this);
         this.yPlaneGizmo = new PlaneDragGizmo(new Vector3(0, 1, 0), Color3.Green().scale(0.5), this.gizmoLayer, this);

+ 5 - 4
src/Gizmos/rotationGizmo.ts

@@ -70,12 +70,13 @@ export class RotationGizmo extends Gizmo {
      * @param gizmoLayer The utility layer the gizmo will be added to
      * @param tessellation Amount of tessellation to be used when creating rotation circles
      * @param useEulerRotation Use and update Euler angle instead of quaternion
+     * @param thickness display gizmo axis thickness
      */
-    constructor(gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer, tessellation = 32, useEulerRotation = false) {
+    constructor(gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer, tessellation = 32, useEulerRotation = false, thickness: number = 1) {
         super(gizmoLayer);
-        this.xGizmo = new PlaneRotationGizmo(new Vector3(1, 0, 0), Color3.Red().scale(0.5), gizmoLayer, tessellation, this, useEulerRotation);
-        this.yGizmo = new PlaneRotationGizmo(new Vector3(0, 1, 0), Color3.Green().scale(0.5), gizmoLayer, tessellation, this, useEulerRotation);
-        this.zGizmo = new PlaneRotationGizmo(new Vector3(0, 0, 1), Color3.Blue().scale(0.5), gizmoLayer, tessellation, this, useEulerRotation);
+        this.xGizmo = new PlaneRotationGizmo(new Vector3(1, 0, 0), Color3.Red().scale(0.5), gizmoLayer, tessellation, this, useEulerRotation, thickness);
+        this.yGizmo = new PlaneRotationGizmo(new Vector3(0, 1, 0), Color3.Green().scale(0.5), gizmoLayer, tessellation, this, useEulerRotation, thickness);
+        this.zGizmo = new PlaneRotationGizmo(new Vector3(0, 0, 1), Color3.Blue().scale(0.5), gizmoLayer, tessellation, this, useEulerRotation, thickness);
 
         // Relay drag events
         [this.xGizmo, this.yGizmo, this.zGizmo].forEach((gizmo) => {

+ 5 - 4
src/Gizmos/scaleGizmo.ts

@@ -81,12 +81,13 @@ export class ScaleGizmo extends Gizmo {
     /**
      * Creates a ScaleGizmo
      * @param gizmoLayer The utility layer the gizmo will be added to
+     * @param thickness display gizmo axis thickness
      */
-    constructor(gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer) {
+    constructor(gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer, thickness: number = 1) {
         super(gizmoLayer);
-        this.xGizmo = new AxisScaleGizmo(new Vector3(1, 0, 0), Color3.Red().scale(0.5), gizmoLayer, this);
-        this.yGizmo = new AxisScaleGizmo(new Vector3(0, 1, 0), Color3.Green().scale(0.5), gizmoLayer, this);
-        this.zGizmo = new AxisScaleGizmo(new Vector3(0, 0, 1), Color3.Blue().scale(0.5), gizmoLayer, this);
+        this.xGizmo = new AxisScaleGizmo(new Vector3(1, 0, 0), Color3.Red().scale(0.5), gizmoLayer, this, thickness);
+        this.yGizmo = new AxisScaleGizmo(new Vector3(0, 1, 0), Color3.Green().scale(0.5), gizmoLayer, this, thickness);
+        this.zGizmo = new AxisScaleGizmo(new Vector3(0, 0, 1), Color3.Blue().scale(0.5), gizmoLayer, this, thickness);
 
         // Create uniform scale gizmo
         this.uniformScaleGizmo = new AxisScaleGizmo(new Vector3(0, 1, 0), Color3.Yellow().scale(0.5), gizmoLayer, this);

+ 2 - 0
src/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.ts

@@ -921,6 +921,8 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
 
         state.compilationString += AmbientOcclusionBlock.GetCode(aoBlock);
 
+        state.compilationString += state._emitCodeFromInclude("pbrBlockLightmapInit", comments);
+
         // _____________________________ UNLIT  _______________________________
 
         state.compilationString += `#ifdef UNLIT

+ 2 - 2
src/Maths/math.vector.ts

@@ -4749,7 +4749,7 @@ export class Matrix {
      * Creates a rotation matrix
      * @param yaw defines the yaw angle in radians (Y axis)
      * @param pitch defines the pitch angle in radians (X axis)
-     * @param roll defines the roll angle in radians (X axis)
+     * @param roll defines the roll angle in radians (Z axis)
      * @returns the new rotation matrix
      */
     public static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix {
@@ -4762,7 +4762,7 @@ export class Matrix {
      * Creates a rotation matrix and stores it in a given matrix
      * @param yaw defines the yaw angle in radians (Y axis)
      * @param pitch defines the pitch angle in radians (X axis)
-     * @param roll defines the roll angle in radians (X axis)
+     * @param roll defines the roll angle in radians (Z axis)
      * @param result defines the target matrix
      */
     public static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void {

+ 1 - 1
src/Meshes/abstractMesh.ts

@@ -1538,7 +1538,7 @@ export class AbstractMesh extends TransformNode implements IDisposable, ICullabl
 
         if (intersectInfo) {
             // Get picked point
-            const world = this.getWorldMatrix();
+            const world = this.skeleton && this.skeleton.overrideMesh ? this.skeleton.overrideMesh.getWorldMatrix() : this.getWorldMatrix();
             const worldOrigin = TmpVectors.Vector3[0];
             const direction = TmpVectors.Vector3[1];
             Vector3.TransformCoordinatesToRef(ray.origin, world, worldOrigin);

+ 0 - 13
src/Shaders/ShadersInclude/pbrBlockDirectLighting.fx

@@ -9,19 +9,6 @@ vec3 diffuseBase = vec3(0., 0., 0.);
     vec3 sheenBase = vec3(0., 0., 0.);
 #endif
 
-#ifdef LIGHTMAP
-    vec4 lightmapColor = texture2D(lightmapSampler, vLightmapUV + uvOffset);
-
-    #ifdef RGBDLIGHTMAP
-        lightmapColor.rgb = fromRGBD(lightmapColor);
-    #endif
-
-    #ifdef GAMMALIGHTMAP
-        lightmapColor.rgb = toLinearSpace(lightmapColor.rgb);
-    #endif
-    lightmapColor.rgb *= vLightmapInfos.y;
-#endif
-
 // Direct Lighting Variables
 preLightingInfo preInfo;
 lightingInfo info;

+ 12 - 0
src/Shaders/ShadersInclude/pbrBlockLightmapInit.fx

@@ -0,0 +1,12 @@
+#ifdef LIGHTMAP
+    vec4 lightmapColor = texture2D(lightmapSampler, vLightmapUV + uvOffset);
+
+    #ifdef RGBDLIGHTMAP
+        lightmapColor.rgb = fromRGBD(lightmapColor);
+    #endif
+
+    #ifdef GAMMALIGHTMAP
+        lightmapColor.rgb = toLinearSpace(lightmapColor.rgb);
+    #endif
+    lightmapColor.rgb *= vLightmapInfos.y;
+#endif

+ 2 - 0
src/Shaders/pbr.fragment.fx

@@ -130,6 +130,8 @@ void main(void) {
         aoOut
     );
 
+    #include<pbrBlockLightmapInit>
+
 #ifdef UNLIT
     vec3 diffuseBase = vec3(1., 1., 1.);
 #else