David `Deltakosh` Catuhe 5 роки тому
батько
коміт
c8442d75fc

+ 5 - 0
dist/preview release/babylon.d.ts

@@ -50126,7 +50126,9 @@ declare module BABYLON {
         protected _interactionsEnabled: boolean;
         protected _attachedNodeChanged(value: Nullable<Node>): void;
         private _beforeRenderObserver;
+        private _tempQuaternion;
         private _tempVector;
+        private _tempVector2;
         /**
          * Creates a gizmo
          * @param gizmoLayer The utility layer the gizmo will be added to
@@ -52419,6 +52421,9 @@ declare module BABYLON {
         clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
         createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
         createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
+        bindBuffers(vertexBuffers: {
+            [key: string]: VertexBuffer;
+        }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
         recordVertexArrayObject(vertexBuffers: {
             [key: string]: VertexBuffer;
         }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;

Різницю між файлами не показано, бо вона завелика
+ 1 - 1
dist/preview release/babylon.js


+ 72 - 15
dist/preview release/babylon.max.js

@@ -37085,9 +37085,14 @@ var NativeEngine = /** @class */ (function (_super) {
         var buffer = new NativeDataBuffer();
         buffer.references = 1;
         buffer.is32Bits = (data.BYTES_PER_ELEMENT === 4);
-        buffer.nativeIndexBuffer = this._native.createIndexBuffer(data, updateable !== null && updateable !== void 0 ? updateable : false);
-        if (buffer.nativeVertexBuffer === this.INVALID_HANDLE) {
-            throw new Error("Could not create a native index buffer.");
+        if (data.length) {
+            buffer.nativeIndexBuffer = this._native.createIndexBuffer(data, updateable !== null && updateable !== void 0 ? updateable : false);
+            if (buffer.nativeVertexBuffer === this.INVALID_HANDLE) {
+                throw new Error("Could not create a native index buffer.");
+            }
+        }
+        else {
+            buffer.nativeVertexBuffer = this.INVALID_HANDLE;
         }
         return buffer;
     };
@@ -37100,6 +37105,23 @@ var NativeEngine = /** @class */ (function (_super) {
         }
         return buffer;
     };
+    NativeEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
+        // TODO : support index buffer
+        var attributes = effect.getAttributesNames();
+        for (var index = 0; index < attributes.length; index++) {
+            var location_1 = effect.getAttributeLocation(index);
+            if (location_1 >= 0) {
+                var kind = attributes[index];
+                var vertexBuffer = vertexBuffers[kind];
+                if (vertexBuffer) {
+                    var buffer = vertexBuffer.getBuffer();
+                    if (buffer) {
+                        this._native.bindBuffer(buffer.nativeVertexBuffer, location_1, vertexBuffer.byteOffset, vertexBuffer.byteStride, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized);
+                    }
+                }
+            }
+        }
+    };
     NativeEngine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
         var vertexArray = this._native.createVertexArray();
         if (indexBuffer) {
@@ -37107,14 +37129,14 @@ var NativeEngine = /** @class */ (function (_super) {
         }
         var attributes = effect.getAttributesNames();
         for (var index = 0; index < attributes.length; index++) {
-            var location_1 = effect.getAttributeLocation(index);
-            if (location_1 >= 0) {
+            var location_2 = effect.getAttributeLocation(index);
+            if (location_2 >= 0) {
                 var kind = attributes[index];
                 var vertexBuffer = vertexBuffers[kind];
                 if (vertexBuffer) {
                     var buffer = vertexBuffer.getBuffer();
                     if (buffer) {
-                        this._native.recordVertexBuffer(vertexArray, buffer.nativeVertexBuffer, location_1, vertexBuffer.byteOffset, vertexBuffer.byteStride, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized);
+                        this._native.recordVertexBuffer(vertexArray, buffer.nativeVertexBuffer, location_2, vertexBuffer.byteOffset, vertexBuffer.byteStride, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized);
                     }
                 }
             }
@@ -39079,9 +39101,9 @@ var ThinEngine = /** @class */ (function () {
                             var capture = exception.capture;
                             var constraint = exception.captureConstraint;
                             var regex = new RegExp(capture);
-                            var matches = regex.exec(ua);
-                            if (matches && matches.length > 0) {
-                                var capturedValue = parseInt(matches[matches.length - 1]);
+                            var matches_1 = regex.exec(ua);
+                            if (matches_1 && matches_1.length > 0) {
+                                var capturedValue = parseInt(matches_1[matches_1.length - 1]);
                                 if (capturedValue >= constraint) {
                                     continue;
                                 }
@@ -39195,6 +39217,13 @@ var ThinEngine = /** @class */ (function () {
         }
         // Detect if we are running on a faulty buggy OS.
         this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
+        // Starting with iOS 14, we can trust the browser
+        var matches = navigator.userAgent.match(/Version\/(\d+)/);
+        if (matches && matches.length === 2) {
+            if (parseInt(matches[1]) >= 14) {
+                this._badOS = false;
+            }
+        }
         // Detect if we are running on a faulty buggy desktop OS.
         this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
         this._creationOptions = options;
@@ -47544,7 +47573,9 @@ var Gizmo = /** @class */ (function () {
          */
         this.updateScale = true;
         this._interactionsEnabled = true;
+        this._tempQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 1);
         this._tempVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
+        this._tempVector2 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
         this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
         this._rootMesh.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
         this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
@@ -47653,22 +47684,48 @@ var Gizmo = /** @class */ (function () {
         if (!this._attachedNode) {
             return;
         }
-        if (this._attachedNode.getClassName() === "Mesh" || this._attachedNode.getClassName() === "AbstractMesh" || this._attachedNode.getClassName() === "TransformNode") {
+        if (this._attachedNode._isCamera) {
+            var camera = this._attachedNode;
+            if (camera.parent) {
+                var parentInv = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
+                var localMat = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
+                camera.parent.getWorldMatrix().invertToRef(parentInv);
+                this._attachedNode.getWorldMatrix().multiplyToRef(parentInv, localMat);
+                localMat.decompose(this._tempVector2, this._tempQuaternion, this._tempVector);
+            }
+            else {
+                this._attachedNode.getWorldMatrix().decompose(this._tempVector2, this._tempQuaternion, this._tempVector);
+            }
+            var inheritsTargetCamera = this._attachedNode.getClassName() === "FreeCamera"
+                || this._attachedNode.getClassName() === "FlyCamera"
+                || this._attachedNode.getClassName() === "ArcFollowCamera"
+                || this._attachedNode.getClassName() === "TargetCamera"
+                || this._attachedNode.getClassName() === "TouchCamera"
+                || this._attachedNode.getClassName() === "UniversalCamera";
+            if (inheritsTargetCamera) {
+                var targetCamera = this._attachedNode;
+                targetCamera.rotation = this._tempQuaternion.toEulerAngles();
+                if (targetCamera.rotationQuaternion) {
+                    targetCamera.rotationQuaternion.copyFrom(this._tempQuaternion);
+                }
+            }
+            camera.position.copyFrom(this._tempVector);
+        }
+        else if (this._attachedNode.getClassName() === "Mesh" || this._attachedNode.getClassName() === "AbstractMesh" || this._attachedNode.getClassName() === "TransformNode") {
             var transform = this._attachedNode;
-            var transformQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 1);
             if (transform.parent) {
                 var parentInv = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
                 var localMat = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
                 transform.parent.getWorldMatrix().invertToRef(parentInv);
                 this._attachedNode._worldMatrix.multiplyToRef(parentInv, localMat);
-                localMat.decompose(transform.scaling, transformQuaternion, transform.position);
+                localMat.decompose(transform.scaling, this._tempQuaternion, transform.position);
             }
             else {
-                this._attachedNode._worldMatrix.decompose(transform.scaling, transformQuaternion, transform.position);
+                this._attachedNode._worldMatrix.decompose(transform.scaling, this._tempQuaternion, transform.position);
             }
-            transform.rotation = transformQuaternion.toEulerAngles();
+            transform.rotation = this._tempQuaternion.toEulerAngles();
             if (transform.rotationQuaternion) {
-                transform.rotationQuaternion = transformQuaternion;
+                transform.rotationQuaternion.copyFrom(this._tempQuaternion);
             }
         }
         else if (this._attachedNode.getClassName() === "Bone") {

Різницю між файлами не показано, бо вона завелика
+ 1 - 1
dist/preview release/babylon.max.js.map


+ 10 - 0
dist/preview release/babylon.module.d.ts

@@ -52081,7 +52081,9 @@ declare module "babylonjs/Gizmos/gizmo" {
         protected _interactionsEnabled: boolean;
         protected _attachedNodeChanged(value: Nullable<Node>): void;
         private _beforeRenderObserver;
+        private _tempQuaternion;
         private _tempVector;
+        private _tempVector2;
         /**
          * Creates a gizmo
          * @param gizmoLayer The utility layer the gizmo will be added to
@@ -54564,6 +54566,9 @@ declare module "babylonjs/Engines/nativeEngine" {
         clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
         createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
         createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
+        bindBuffers(vertexBuffers: {
+            [key: string]: VertexBuffer;
+        }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
         recordVertexArrayObject(vertexBuffers: {
             [key: string]: VertexBuffer;
         }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
@@ -128992,7 +128997,9 @@ declare module BABYLON {
         protected _interactionsEnabled: boolean;
         protected _attachedNodeChanged(value: Nullable<Node>): void;
         private _beforeRenderObserver;
+        private _tempQuaternion;
         private _tempVector;
+        private _tempVector2;
         /**
          * Creates a gizmo
          * @param gizmoLayer The utility layer the gizmo will be added to
@@ -131285,6 +131292,9 @@ declare module BABYLON {
         clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
         createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
         createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
+        bindBuffers(vertexBuffers: {
+            [key: string]: VertexBuffer;
+        }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
         recordVertexArrayObject(vertexBuffers: {
             [key: string]: VertexBuffer;
         }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;

+ 5 - 0
dist/preview release/documentation.d.ts

@@ -50126,7 +50126,9 @@ declare module BABYLON {
         protected _interactionsEnabled: boolean;
         protected _attachedNodeChanged(value: Nullable<Node>): void;
         private _beforeRenderObserver;
+        private _tempQuaternion;
         private _tempVector;
+        private _tempVector2;
         /**
          * Creates a gizmo
          * @param gizmoLayer The utility layer the gizmo will be added to
@@ -52419,6 +52421,9 @@ declare module BABYLON {
         clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
         createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
         createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
+        bindBuffers(vertexBuffers: {
+            [key: string]: VertexBuffer;
+        }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
         recordVertexArrayObject(vertexBuffers: {
             [key: string]: VertexBuffer;
         }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;

+ 1 - 1
dist/preview release/packagesSizeBaseLine.json

@@ -1 +1 @@
-{"thinEngineOnly":116998,"engineOnly":153434,"sceneOnly":517371,"minGridMaterial":655350,"minStandardMaterial":804758}
+{"thinEngineOnly":117102,"engineOnly":153538,"sceneOnly":517475,"minGridMaterial":655454,"minStandardMaterial":804862}

+ 10 - 0
dist/preview release/viewer/babylon.module.d.ts

@@ -52081,7 +52081,9 @@ declare module "babylonjs/Gizmos/gizmo" {
         protected _interactionsEnabled: boolean;
         protected _attachedNodeChanged(value: Nullable<Node>): void;
         private _beforeRenderObserver;
+        private _tempQuaternion;
         private _tempVector;
+        private _tempVector2;
         /**
          * Creates a gizmo
          * @param gizmoLayer The utility layer the gizmo will be added to
@@ -54564,6 +54566,9 @@ declare module "babylonjs/Engines/nativeEngine" {
         clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
         createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
         createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
+        bindBuffers(vertexBuffers: {
+            [key: string]: VertexBuffer;
+        }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
         recordVertexArrayObject(vertexBuffers: {
             [key: string]: VertexBuffer;
         }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
@@ -128992,7 +128997,9 @@ declare module BABYLON {
         protected _interactionsEnabled: boolean;
         protected _attachedNodeChanged(value: Nullable<Node>): void;
         private _beforeRenderObserver;
+        private _tempQuaternion;
         private _tempVector;
+        private _tempVector2;
         /**
          * Creates a gizmo
          * @param gizmoLayer The utility layer the gizmo will be added to
@@ -131285,6 +131292,9 @@ declare module BABYLON {
         clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
         createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
         createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
+        bindBuffers(vertexBuffers: {
+            [key: string]: VertexBuffer;
+        }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
         recordVertexArrayObject(vertexBuffers: {
             [key: string]: VertexBuffer;
         }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;

Різницю між файлами не показано, бо вона завелика
+ 3 - 3
dist/preview release/viewer/babylon.viewer.js


Різницю між файлами не показано, бо вона завелика
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


+ 1 - 1
src/Engines/thinEngine.ts

@@ -684,7 +684,7 @@ export class ThinEngine {
         this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
 
         // Starting with iOS 14, we can trust the browser
-        let matches = navigator.userAgent.match(/Version\/(\d+)/)
+        let matches = navigator.userAgent.match(/Version\/(\d+)/);
 
         if (matches && matches.length === 2) {
             if (parseInt(matches[1]) >= 14) {