@babylonjs/core 5.8.2 → 5.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Buffers/buffer.js +2 -3
- package/Buffers/buffer.js.map +1 -1
- package/Culling/ray.js.map +1 -1
- package/Engines/IPipelineContext.d.ts +7 -1
- package/Engines/IPipelineContext.js.map +1 -1
- package/Engines/Processors/shaderCodeNode.js +3 -4
- package/Engines/Processors/shaderCodeNode.js.map +1 -1
- package/Engines/WebGL/webGLPipelineContext.d.ts +7 -1
- package/Engines/WebGL/webGLPipelineContext.js +12 -0
- package/Engines/WebGL/webGLPipelineContext.js.map +1 -1
- package/Engines/WebGPU/webgpuPipelineContext.d.ts +7 -1
- package/Engines/WebGPU/webgpuPipelineContext.js +8 -0
- package/Engines/WebGPU/webgpuPipelineContext.js.map +1 -1
- package/Engines/engine.js +1 -0
- package/Engines/engine.js.map +1 -1
- package/Engines/nativeEngine.js +12 -0
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Inputs/scene.inputManager.js +4 -8
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Lights/shadowLight.d.ts +2 -0
- package/Lights/shadowLight.js +8 -0
- package/Lights/shadowLight.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js +5 -2
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Loading/sceneLoader.js +1 -2
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.js +2 -3
- package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
- package/Materials/PBR/pbrMaterial.js +4 -0
- package/Materials/PBR/pbrMaterial.js.map +1 -1
- package/Materials/PBR/pbrMetallicRoughnessMaterial.js +4 -0
- package/Materials/PBR/pbrMetallicRoughnessMaterial.js.map +1 -1
- package/Materials/PBR/pbrSpecularGlossinessMaterial.js +4 -0
- package/Materials/PBR/pbrSpecularGlossinessMaterial.js.map +1 -1
- package/Materials/Textures/Loaders/basisTextureLoader.js +1 -2
- package/Materials/Textures/Loaders/basisTextureLoader.js.map +1 -1
- package/Materials/Textures/Loaders/ddsTextureLoader.js +1 -2
- package/Materials/Textures/Loaders/ddsTextureLoader.js.map +1 -1
- package/Materials/Textures/Loaders/envTextureLoader.js +1 -2
- package/Materials/Textures/Loaders/envTextureLoader.js.map +1 -1
- package/Materials/Textures/Loaders/hdrTextureLoader.js +1 -2
- package/Materials/Textures/Loaders/hdrTextureLoader.js.map +1 -1
- package/Materials/Textures/Loaders/ktxTextureLoader.js +1 -2
- package/Materials/Textures/Loaders/ktxTextureLoader.js.map +1 -1
- package/Materials/Textures/Loaders/tgaTextureLoader.js +1 -2
- package/Materials/Textures/Loaders/tgaTextureLoader.js.map +1 -1
- package/Materials/Textures/cubeTexture.d.ts +2 -1
- package/Materials/Textures/cubeTexture.js +2 -2
- package/Materials/Textures/cubeTexture.js.map +1 -1
- package/Materials/Textures/texture.d.ts +5 -2
- package/Materials/Textures/texture.js +15 -11
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/effect.d.ts +8 -1
- package/Materials/effect.js +10 -0
- package/Materials/effect.js.map +1 -1
- package/Maths/math.like.d.ts +6 -0
- package/Maths/math.like.js.map +1 -1
- package/Maths/math.vector.d.ts +45 -0
- package/Maths/math.vector.js +92 -7
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/abstractMesh.js +2 -3
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/geometry.js +3 -3
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/instancedMesh.js +11 -9
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/linesMesh.js +3 -0
- package/Meshes/linesMesh.js.map +1 -1
- package/Meshes/mesh.js +2 -2
- package/Meshes/mesh.js.map +1 -1
- package/Misc/computePressure.js +3 -1
- package/Misc/computePressure.js.map +1 -1
- package/Misc/deepCopier.js +1 -2
- package/Misc/deepCopier.js.map +1 -1
- package/Misc/index.d.ts +0 -1
- package/Misc/index.js +0 -1
- package/Misc/index.js.map +1 -1
- package/Misc/reflector.js +1 -2
- package/Misc/reflector.js.map +1 -1
- package/Misc/sceneSerializer.js +7 -2
- package/Misc/sceneSerializer.js.map +1 -1
- package/Misc/stringTools.d.ts +2 -0
- package/Misc/stringTools.js +4 -2
- package/Misc/stringTools.js.map +1 -1
- package/Misc/tools.d.ts +0 -17
- package/Misc/tools.js +0 -25
- package/Misc/tools.js.map +1 -1
- package/Particles/solidParticleSystem.js +6 -7
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Rendering/edgesRenderer.js +1 -2
- package/Rendering/edgesRenderer.js.map +1 -1
- package/Rendering/utilityLayerRenderer.js +0 -4
- package/Rendering/utilityLayerRenderer.js.map +1 -1
- package/Shaders/extractHighlights.fragment.js +1 -1
- package/Shaders/extractHighlights.fragment.js.map +1 -1
- package/abstractScene.d.ts +1 -0
- package/abstractScene.js +1 -0
- package/abstractScene.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +2 -0
- package/scene.js +4 -6
- package/scene.js.map +1 -1
- package/Misc/promise.d.ts +0 -11
- package/Misc/promise.js +0 -230
- package/Misc/promise.js.map +0 -1
- package/Misc/sliceTools.d.ts +0 -22
- package/Misc/sliceTools.js +0 -37
- package/Misc/sliceTools.js.map +0 -1
package/Buffers/buffer.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { DataBuffer } from "./dataBuffer.js";
|
|
2
|
-
import { SliceTools } from "../Misc/sliceTools.js";
|
|
3
2
|
/**
|
|
4
3
|
* Class used to store data that will be store in GPU memory
|
|
5
4
|
*/
|
|
@@ -344,7 +343,7 @@ var VertexBuffer = /** @class */ (function () {
|
|
|
344
343
|
if (!(data instanceof Array || data instanceof Float32Array) || this.byteOffset !== 0 || data.length !== count) {
|
|
345
344
|
if (data instanceof Array) {
|
|
346
345
|
var offset = this.byteOffset / 4;
|
|
347
|
-
return
|
|
346
|
+
return data.slice(offset, offset + count);
|
|
348
347
|
}
|
|
349
348
|
else if (data instanceof ArrayBuffer) {
|
|
350
349
|
return new Float32Array(data, this.byteOffset, count);
|
|
@@ -366,7 +365,7 @@ var VertexBuffer = /** @class */ (function () {
|
|
|
366
365
|
}
|
|
367
366
|
}
|
|
368
367
|
if (forceCopy) {
|
|
369
|
-
return
|
|
368
|
+
return data.slice();
|
|
370
369
|
}
|
|
371
370
|
return data;
|
|
372
371
|
};
|
package/Buffers/buffer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Buffers/buffer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;GAEG;AACH;IAeI;;;;;;;;;;OAUG;IACH,gBACI,MAAW,EACX,IAA4B,EAC5B,SAAkB,EAClB,MAAU,EACV,wBAAgC,EAChC,SAAiB,EACjB,QAAgB,EAChB,OAAgB;QAJhB,uBAAA,EAAA,UAAU;QACV,yCAAA,EAAA,gCAAgC;QAChC,0BAAA,EAAA,iBAAiB;QACjB,yBAAA,EAAA,gBAAgB;QAzBZ,oBAAe,GAAG,KAAK,CAAC;QA4B5B,IAAI,MAAM,CAAC,QAAQ,EAAE;YACjB,mEAAmE;YACnE,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,CAAC;SAChD;aAAM;YACH,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;SACzB;QAED,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,OAAO,IAAI,CAAC,CAAC;QAE7B,IAAI,IAAI,YAAY,UAAU,EAAE;YAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YAClB,IA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vC;;OAEG;IACoB,oBAAO,GAAG,KAAK,CAAC;IACvC;;OAEG;IACoB,oBAAO,GAAG,KAAK,CAAC;IACvC;;OAEG;IACoB,oBAAO,GAAG,KAAK,CAAC;IACvC;;OAEG;IACoB,oBAAO,GAAG,KAAK,CAAC;IACvC;;OAEG;IACoB,sBAAS,GAAG,OAAO,CAAC;IAC3C;;OAEG;IACoB,8BAAiB,GAAG,eAAe,CAAC;IAC3D;;OAEG;IACoB,gCAAmB,GAAG,iBAAiB,CAAC;IAC/D;;OAEG;IACoB,gCAAmB,GAAG,iBAAiB,CAAC;IAC/D;;OAEG;IACoB,qCAAwB,GAAG,sBAAsB,CAAC;IACzE;;OAEG;IACoB,qCAAwB,GAAG,sBAAsB,CAAC;IA8I7E,mBAAC;CAAA,AAxkBD,IAwkBC;SAxkBY,YAAY","sourcesContent":["import type { Nullable, DataArray, FloatArray } from \"../types\";\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\nimport { DataBuffer } from \"./dataBuffer\";\r\nimport { SliceTools } from \"../Misc/sliceTools\";\r\n\r\n/**\r\n * Class used to store data that will be store in GPU memory\r\n */\r\nexport class Buffer {\r\n private _engine: ThinEngine;\r\n private _buffer: Nullable<DataBuffer>;\r\n /** @hidden */\r\n public _data: Nullable<DataArray>;\r\n private _updatable: boolean;\r\n private _instanced: boolean;\r\n private _divisor: number;\r\n private _isAlreadyOwned = false;\r\n\r\n /**\r\n * Gets the byte stride.\r\n */\r\n public readonly byteStride: number;\r\n\r\n /**\r\n * Constructor\r\n * @param engine the engine\r\n * @param data the data to use for this buffer\r\n * @param updatable whether the data is updatable\r\n * @param stride the stride (optional)\r\n * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)\r\n * @param instanced whether the buffer is instanced (optional)\r\n * @param useBytes set to true if the stride in in bytes (optional)\r\n * @param divisor sets an optional divisor for instances (1 by default)\r\n */\r\n constructor(\r\n engine: any,\r\n data: DataArray | DataBuffer,\r\n updatable: boolean,\r\n stride = 0,\r\n postponeInternalCreation = false,\r\n instanced = false,\r\n useBytes = false,\r\n divisor?: number\r\n ) {\r\n if (engine.getScene) {\r\n // old versions of VertexBuffer accepted 'mesh' instead of 'engine'\r\n this._engine = engine.getScene().getEngine();\r\n } else {\r\n this._engine = engine;\r\n }\r\n\r\n this._updatable = updatable;\r\n this._instanced = instanced;\r\n this._divisor = divisor || 1;\r\n\r\n if (data instanceof DataBuffer) {\r\n this._data = null;\r\n this._buffer = data;\r\n } else {\r\n this._data = data;\r\n this._buffer = null;\r\n }\r\n\r\n this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;\r\n\r\n if (!postponeInternalCreation) {\r\n // by default\r\n this.create();\r\n }\r\n }\r\n\r\n /**\r\n * Create a new VertexBuffer based on the current buffer\r\n * @param kind defines the vertex buffer kind (position, normal, etc.)\r\n * @param offset defines offset in the buffer (0 by default)\r\n * @param size defines the size in floats of attributes (position is 3 for instance)\r\n * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)\r\n * @param instanced defines if the vertex buffer contains indexed data\r\n * @param useBytes defines if the offset and stride are in bytes *\r\n * @param divisor sets an optional divisor for instances (1 by default)\r\n * @returns the new vertex buffer\r\n */\r\n public createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes = false, divisor?: number): VertexBuffer {\r\n const byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;\r\n const byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;\r\n\r\n // a lot of these parameters are ignored as they are overridden by the buffer\r\n return new VertexBuffer(\r\n this._engine,\r\n this,\r\n kind,\r\n this._updatable,\r\n true,\r\n byteStride,\r\n instanced === undefined ? this._instanced : instanced,\r\n byteOffset,\r\n size,\r\n undefined,\r\n undefined,\r\n true,\r\n this._divisor || divisor\r\n );\r\n }\r\n\r\n // Properties\r\n\r\n /**\r\n * Gets a boolean indicating if the Buffer is updatable?\r\n * @returns true if the buffer is updatable\r\n */\r\n public isUpdatable(): boolean {\r\n return this._updatable;\r\n }\r\n\r\n /**\r\n * Gets current buffer's data\r\n * @returns a DataArray or null\r\n */\r\n public getData(): Nullable<DataArray> {\r\n return this._data;\r\n }\r\n\r\n /**\r\n * Gets underlying native buffer\r\n * @returns underlying native buffer\r\n */\r\n public getBuffer(): Nullable<DataBuffer> {\r\n return this._buffer;\r\n }\r\n\r\n /**\r\n * Gets the stride in float32 units (i.e. byte stride / 4).\r\n * May not be an integer if the byte stride is not divisible by 4.\r\n * @returns the stride in float32 units\r\n * @deprecated Please use byteStride instead.\r\n */\r\n public getStrideSize(): number {\r\n return this.byteStride / Float32Array.BYTES_PER_ELEMENT;\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Store data into the buffer. Creates the buffer if not used already.\r\n * If the buffer was already used, it will be updated only if it is updatable, otherwise it will do nothing.\r\n * @param data defines the data to store\r\n */\r\n public create(data: Nullable<DataArray> = null): void {\r\n if (!data && this._buffer) {\r\n return; // nothing to do\r\n }\r\n\r\n data = data || this._data;\r\n\r\n if (!data) {\r\n return;\r\n }\r\n\r\n if (!this._buffer) {\r\n // create buffer\r\n if (this._updatable) {\r\n this._buffer = this._engine.createDynamicVertexBuffer(data);\r\n this._data = data;\r\n } else {\r\n this._buffer = this._engine.createVertexBuffer(data);\r\n }\r\n } else if (this._updatable) {\r\n // update buffer\r\n this._engine.updateDynamicVertexBuffer(this._buffer, data);\r\n this._data = data;\r\n }\r\n }\r\n\r\n /** @hidden */\r\n public _rebuild(): void {\r\n this._buffer = null;\r\n this.create(this._data);\r\n }\r\n\r\n /**\r\n * Update current buffer data\r\n * @param data defines the data to store\r\n */\r\n public update(data: DataArray): void {\r\n this.create(data);\r\n }\r\n\r\n /**\r\n * Updates the data directly.\r\n * @param data the new data\r\n * @param offset the new offset\r\n * @param vertexCount the vertex count (optional)\r\n * @param useBytes set to true if the offset is in bytes\r\n */\r\n public updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes: boolean = false): void {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n\r\n if (this._updatable) {\r\n // update buffer\r\n this._engine.updateDynamicVertexBuffer(\r\n this._buffer,\r\n data,\r\n useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT,\r\n vertexCount ? vertexCount * this.byteStride : undefined\r\n );\r\n if (offset === 0 && vertexCount === undefined) {\r\n // Keep the data if we easily can\r\n this._data = data;\r\n } else {\r\n this._data = null;\r\n }\r\n }\r\n }\r\n\r\n /** @hidden */\r\n public _increaseReferences() {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n\r\n if (!this._isAlreadyOwned) {\r\n this._isAlreadyOwned = true;\r\n return;\r\n }\r\n\r\n this._buffer.references++;\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose(): void {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n if (this._engine._releaseBuffer(this._buffer)) {\r\n this._buffer = null;\r\n this._data = null;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Specialized buffer used to store vertex data\r\n */\r\nexport class VertexBuffer {\r\n private static _Counter = 0;\r\n\r\n /** @hidden */\r\n public _buffer: Buffer;\r\n /** @hidden */\r\n public _validOffsetRange: boolean; // used internally by the engine\r\n private _kind: string;\r\n private _size: number;\r\n private _ownsBuffer: boolean;\r\n private _instanced: boolean;\r\n private _instanceDivisor: number;\r\n\r\n /**\r\n * The byte type.\r\n */\r\n public static readonly BYTE = 5120;\r\n\r\n /**\r\n * The unsigned byte type.\r\n */\r\n public static readonly UNSIGNED_BYTE = 5121;\r\n\r\n /**\r\n * The short type.\r\n */\r\n public static readonly SHORT = 5122;\r\n\r\n /**\r\n * The unsigned short type.\r\n */\r\n public static readonly UNSIGNED_SHORT = 5123;\r\n\r\n /**\r\n * The integer type.\r\n */\r\n public static readonly INT = 5124;\r\n\r\n /**\r\n * The unsigned integer type.\r\n */\r\n public static readonly UNSIGNED_INT = 5125;\r\n\r\n /**\r\n * The float type.\r\n */\r\n public static readonly FLOAT = 5126;\r\n\r\n /**\r\n * Gets or sets the instance divisor when in instanced mode\r\n */\r\n public get instanceDivisor(): number {\r\n return this._instanceDivisor;\r\n }\r\n\r\n public set instanceDivisor(value: number) {\r\n this._instanceDivisor = value;\r\n if (value == 0) {\r\n this._instanced = false;\r\n } else {\r\n this._instanced = true;\r\n }\r\n this._computeHashCode();\r\n }\r\n\r\n /**\r\n * Gets the byte stride.\r\n */\r\n public readonly byteStride: number;\r\n\r\n /**\r\n * Gets the byte offset.\r\n */\r\n public readonly byteOffset: number;\r\n\r\n /**\r\n * Gets whether integer data values should be normalized into a certain range when being casted to a float.\r\n */\r\n public readonly normalized: boolean;\r\n\r\n /**\r\n * Gets the data type of each component in the array.\r\n */\r\n public readonly type: number;\r\n\r\n /**\r\n * Gets the unique id of this vertex buffer\r\n */\r\n public readonly uniqueId: number;\r\n\r\n /**\r\n * Gets a hash code representing the format (type, normalized, size, instanced, stride) of this buffer\r\n * All buffers with the same format will have the same hash code\r\n */\r\n public readonly hashCode: number;\r\n\r\n /**\r\n * Constructor\r\n * @param engine the engine\r\n * @param data the data to use for this vertex buffer\r\n * @param kind the vertex buffer kind\r\n * @param updatable whether the data is updatable\r\n * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)\r\n * @param stride the stride (optional)\r\n * @param instanced whether the buffer is instanced (optional)\r\n * @param offset the offset of the data (optional)\r\n * @param size the number of components (optional)\r\n * @param type the type of the component (optional)\r\n * @param normalized whether the data contains normalized data (optional)\r\n * @param useBytes set to true if stride and offset are in bytes (optional)\r\n * @param divisor defines the instance divisor to use (1 by default)\r\n * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed\r\n */\r\n constructor(\r\n engine: any,\r\n data: DataArray | Buffer | DataBuffer,\r\n kind: string,\r\n updatable: boolean,\r\n postponeInternalCreation?: boolean,\r\n stride?: number,\r\n instanced?: boolean,\r\n offset?: number,\r\n size?: number,\r\n type?: number,\r\n normalized = false,\r\n useBytes = false,\r\n divisor = 1,\r\n takeBufferOwnership = false\r\n ) {\r\n if (data instanceof Buffer) {\r\n this._buffer = data;\r\n this._ownsBuffer = takeBufferOwnership;\r\n } else {\r\n this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);\r\n this._ownsBuffer = true;\r\n }\r\n\r\n this.uniqueId = VertexBuffer._Counter++;\r\n this._kind = kind;\r\n\r\n if (type == undefined) {\r\n const data = this.getData();\r\n this.type = VertexBuffer.FLOAT;\r\n if (data instanceof Int8Array) {\r\n this.type = VertexBuffer.BYTE;\r\n } else if (data instanceof Uint8Array) {\r\n this.type = VertexBuffer.UNSIGNED_BYTE;\r\n } else if (data instanceof Int16Array) {\r\n this.type = VertexBuffer.SHORT;\r\n } else if (data instanceof Uint16Array) {\r\n this.type = VertexBuffer.UNSIGNED_SHORT;\r\n } else if (data instanceof Int32Array) {\r\n this.type = VertexBuffer.INT;\r\n } else if (data instanceof Uint32Array) {\r\n this.type = VertexBuffer.UNSIGNED_INT;\r\n }\r\n } else {\r\n this.type = type;\r\n }\r\n\r\n const typeByteLength = VertexBuffer.GetTypeByteLength(this.type);\r\n\r\n if (useBytes) {\r\n this._size = size || (stride ? stride / typeByteLength : VertexBuffer.DeduceStride(kind));\r\n this.byteStride = stride || this._buffer.byteStride || this._size * typeByteLength;\r\n this.byteOffset = offset || 0;\r\n } else {\r\n this._size = size || stride || VertexBuffer.DeduceStride(kind);\r\n this.byteStride = stride ? stride * typeByteLength : this._buffer.byteStride || this._size * typeByteLength;\r\n this.byteOffset = (offset || 0) * typeByteLength;\r\n }\r\n\r\n this.normalized = normalized;\r\n\r\n this._instanced = instanced !== undefined ? instanced : false;\r\n this._instanceDivisor = instanced ? divisor : 0;\r\n\r\n this._computeHashCode();\r\n }\r\n\r\n private _computeHashCode(): void {\r\n // note: cast to any because the property is declared readonly\r\n (this.hashCode as any) =\r\n ((this.type - 5120) << 0) +\r\n ((this.normalized ? 1 : 0) << 3) +\r\n (this._size << 4) +\r\n ((this._instanced ? 1 : 0) << 6) +\r\n /* keep 5 bits free */\r\n (this.byteStride << 12);\r\n }\r\n\r\n /** @hidden */\r\n public _rebuild(): void {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n\r\n this._buffer._rebuild();\r\n }\r\n\r\n /**\r\n * Returns the kind of the VertexBuffer (string)\r\n * @returns a string\r\n */\r\n public getKind(): string {\r\n return this._kind;\r\n }\r\n\r\n // Properties\r\n\r\n /**\r\n * Gets a boolean indicating if the VertexBuffer is updatable?\r\n * @returns true if the buffer is updatable\r\n */\r\n public isUpdatable(): boolean {\r\n return this._buffer.isUpdatable();\r\n }\r\n\r\n /**\r\n * Gets current buffer's data\r\n * @returns a DataArray or null\r\n */\r\n public getData(): Nullable<DataArray> {\r\n return this._buffer.getData();\r\n }\r\n\r\n /**\r\n * Gets current buffer's data as a float array. Float data is constructed if the vertex buffer data cannot be returned directly.\r\n * @param totalVertices number of vertices in the buffer to take into account\r\n * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it\r\n * @returns a float array containing vertex data\r\n */\r\n public getFloatData(totalVertices: number, forceCopy?: boolean): Nullable<FloatArray> {\r\n const data = this.getData();\r\n if (!data) {\r\n return null;\r\n }\r\n\r\n const tightlyPackedByteStride = this.getSize() * VertexBuffer.GetTypeByteLength(this.type);\r\n const count = totalVertices * this.getSize();\r\n\r\n if (this.type !== VertexBuffer.FLOAT || this.byteStride !== tightlyPackedByteStride) {\r\n const copy = new Float32Array(count);\r\n this.forEach(count, (value, index) => (copy[index] = value));\r\n return copy;\r\n }\r\n\r\n if (!(data instanceof Array || data instanceof Float32Array) || this.byteOffset !== 0 || data.length !== count) {\r\n if (data instanceof Array) {\r\n const offset = this.byteOffset / 4;\r\n return SliceTools.Slice(data, offset, offset + count);\r\n } else if (data instanceof ArrayBuffer) {\r\n return new Float32Array(data, this.byteOffset, count);\r\n } else {\r\n let offset = data.byteOffset + this.byteOffset;\r\n if (forceCopy) {\r\n const result = new Float32Array(count);\r\n const source = new Float32Array(data.buffer, offset, count);\r\n\r\n result.set(source);\r\n\r\n return result;\r\n }\r\n\r\n // Protect against bad data\r\n const remainder = offset % 4;\r\n\r\n if (remainder) {\r\n offset = Math.max(0, offset - remainder);\r\n }\r\n\r\n return new Float32Array(data.buffer, offset, count);\r\n }\r\n }\r\n\r\n if (forceCopy) {\r\n return SliceTools.Slice(data);\r\n }\r\n\r\n return data;\r\n }\r\n\r\n /**\r\n * Gets underlying native buffer\r\n * @returns underlying native buffer\r\n */\r\n public getBuffer(): Nullable<DataBuffer> {\r\n return this._buffer.getBuffer();\r\n }\r\n\r\n /**\r\n * Gets the stride in float32 units (i.e. byte stride / 4).\r\n * May not be an integer if the byte stride is not divisible by 4.\r\n * @returns the stride in float32 units\r\n * @deprecated Please use byteStride instead.\r\n */\r\n public getStrideSize(): number {\r\n return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);\r\n }\r\n\r\n /**\r\n * Returns the offset as a multiple of the type byte length.\r\n * @returns the offset in bytes\r\n * @deprecated Please use byteOffset instead.\r\n */\r\n public getOffset(): number {\r\n return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);\r\n }\r\n\r\n /**\r\n * Returns the number of components or the byte size per vertex attribute\r\n * @param sizeInBytes If true, returns the size in bytes or else the size in number of components of the vertex attribute (default: false)\r\n * @returns the number of components\r\n */\r\n public getSize(sizeInBytes = false): number {\r\n return sizeInBytes ? this._size * VertexBuffer.GetTypeByteLength(this.type) : this._size;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced\r\n * @returns true if this buffer is instanced\r\n */\r\n public getIsInstanced(): boolean {\r\n return this._instanced;\r\n }\r\n\r\n /**\r\n * Returns the instancing divisor, zero for non-instanced (integer).\r\n * @returns a number\r\n */\r\n public getInstanceDivisor(): number {\r\n return this._instanceDivisor;\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property\r\n * @param data defines the data to store\r\n */\r\n public create(data?: DataArray): void {\r\n this._buffer.create(data);\r\n }\r\n\r\n /**\r\n * Updates the underlying buffer according to the passed numeric array or Float32Array.\r\n * This function will create a new buffer if the current one is not updatable\r\n * @param data defines the data to store\r\n */\r\n public update(data: DataArray): void {\r\n this._buffer.update(data);\r\n }\r\n\r\n /**\r\n * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.\r\n * Returns the directly updated WebGLBuffer.\r\n * @param data the new data\r\n * @param offset the new offset\r\n * @param useBytes set to true if the offset is in bytes\r\n */\r\n public updateDirectly(data: DataArray, offset: number, useBytes: boolean = false): void {\r\n this._buffer.updateDirectly(data, offset, undefined, useBytes);\r\n }\r\n\r\n /**\r\n * Disposes the VertexBuffer and the underlying WebGLBuffer.\r\n */\r\n public dispose(): void {\r\n if (this._ownsBuffer) {\r\n this._buffer.dispose();\r\n }\r\n }\r\n\r\n /**\r\n * Enumerates each value of this vertex buffer as numbers.\r\n * @param count the number of values to enumerate\r\n * @param callback the callback function called for each value\r\n */\r\n public forEach(count: number, callback: (value: number, index: number) => void): void {\r\n VertexBuffer.ForEach(this._buffer.getData()!, this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);\r\n }\r\n\r\n // Enums\r\n /**\r\n * Positions\r\n */\r\n public static readonly PositionKind = \"position\";\r\n /**\r\n * Normals\r\n */\r\n public static readonly NormalKind = \"normal\";\r\n /**\r\n * Tangents\r\n */\r\n public static readonly TangentKind = \"tangent\";\r\n /**\r\n * Texture coordinates\r\n */\r\n public static readonly UVKind = \"uv\";\r\n /**\r\n * Texture coordinates 2\r\n */\r\n public static readonly UV2Kind = \"uv2\";\r\n /**\r\n * Texture coordinates 3\r\n */\r\n public static readonly UV3Kind = \"uv3\";\r\n /**\r\n * Texture coordinates 4\r\n */\r\n public static readonly UV4Kind = \"uv4\";\r\n /**\r\n * Texture coordinates 5\r\n */\r\n public static readonly UV5Kind = \"uv5\";\r\n /**\r\n * Texture coordinates 6\r\n */\r\n public static readonly UV6Kind = \"uv6\";\r\n /**\r\n * Colors\r\n */\r\n public static readonly ColorKind = \"color\";\r\n /**\r\n * Instance Colors\r\n */\r\n public static readonly ColorInstanceKind = \"instanceColor\";\r\n /**\r\n * Matrix indices (for bones)\r\n */\r\n public static readonly MatricesIndicesKind = \"matricesIndices\";\r\n /**\r\n * Matrix weights (for bones)\r\n */\r\n public static readonly MatricesWeightsKind = \"matricesWeights\";\r\n /**\r\n * Additional matrix indices (for bones)\r\n */\r\n public static readonly MatricesIndicesExtraKind = \"matricesIndicesExtra\";\r\n /**\r\n * Additional matrix weights (for bones)\r\n */\r\n public static readonly MatricesWeightsExtraKind = \"matricesWeightsExtra\";\r\n\r\n /**\r\n * Deduces the stride given a kind.\r\n * @param kind The kind string to deduce\r\n * @returns The deduced stride\r\n */\r\n public static DeduceStride(kind: string): number {\r\n switch (kind) {\r\n case VertexBuffer.UVKind:\r\n case VertexBuffer.UV2Kind:\r\n case VertexBuffer.UV3Kind:\r\n case VertexBuffer.UV4Kind:\r\n case VertexBuffer.UV5Kind:\r\n case VertexBuffer.UV6Kind:\r\n return 2;\r\n case VertexBuffer.NormalKind:\r\n case VertexBuffer.PositionKind:\r\n return 3;\r\n case VertexBuffer.ColorKind:\r\n case VertexBuffer.MatricesIndicesKind:\r\n case VertexBuffer.MatricesIndicesExtraKind:\r\n case VertexBuffer.MatricesWeightsKind:\r\n case VertexBuffer.MatricesWeightsExtraKind:\r\n case VertexBuffer.TangentKind:\r\n return 4;\r\n default:\r\n throw new Error(\"Invalid kind '\" + kind + \"'\");\r\n }\r\n }\r\n\r\n /**\r\n * Gets the byte length of the given type.\r\n * @param type the type\r\n * @returns the number of bytes\r\n */\r\n public static GetTypeByteLength(type: number): number {\r\n switch (type) {\r\n case VertexBuffer.BYTE:\r\n case VertexBuffer.UNSIGNED_BYTE:\r\n return 1;\r\n case VertexBuffer.SHORT:\r\n case VertexBuffer.UNSIGNED_SHORT:\r\n return 2;\r\n case VertexBuffer.INT:\r\n case VertexBuffer.UNSIGNED_INT:\r\n case VertexBuffer.FLOAT:\r\n return 4;\r\n default:\r\n throw new Error(`Invalid type '${type}'`);\r\n }\r\n }\r\n\r\n /**\r\n * Enumerates each value of the given parameters as numbers.\r\n * @param data the data to enumerate\r\n * @param byteOffset the byte offset of the data\r\n * @param byteStride the byte stride of the data\r\n * @param componentCount the number of components per element\r\n * @param componentType the type of the component\r\n * @param count the number of values to enumerate\r\n * @param normalized whether the data is normalized\r\n * @param callback the callback function called for each value\r\n */\r\n public static ForEach(\r\n data: DataArray,\r\n byteOffset: number,\r\n byteStride: number,\r\n componentCount: number,\r\n componentType: number,\r\n count: number,\r\n normalized: boolean,\r\n callback: (value: number, index: number) => void\r\n ): void {\r\n if (data instanceof Array) {\r\n let offset = byteOffset / 4;\r\n const stride = byteStride / 4;\r\n for (let index = 0; index < count; index += componentCount) {\r\n for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {\r\n callback(data[offset + componentIndex], index + componentIndex);\r\n }\r\n offset += stride;\r\n }\r\n } else {\r\n const dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);\r\n const componentByteLength = VertexBuffer.GetTypeByteLength(componentType);\r\n for (let index = 0; index < count; index += componentCount) {\r\n let componentByteOffset = byteOffset;\r\n for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {\r\n const value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);\r\n callback(value, index + componentIndex);\r\n componentByteOffset += componentByteLength;\r\n }\r\n byteOffset += byteStride;\r\n }\r\n }\r\n }\r\n\r\n private static _GetFloatValue(dataView: DataView, type: number, byteOffset: number, normalized: boolean): number {\r\n switch (type) {\r\n case VertexBuffer.BYTE: {\r\n let value = dataView.getInt8(byteOffset);\r\n if (normalized) {\r\n value = Math.max(value / 127, -1);\r\n }\r\n return value;\r\n }\r\n case VertexBuffer.UNSIGNED_BYTE: {\r\n let value = dataView.getUint8(byteOffset);\r\n if (normalized) {\r\n value = value / 255;\r\n }\r\n return value;\r\n }\r\n case VertexBuffer.SHORT: {\r\n let value = dataView.getInt16(byteOffset, true);\r\n if (normalized) {\r\n value = Math.max(value / 32767, -1);\r\n }\r\n return value;\r\n }\r\n case VertexBuffer.UNSIGNED_SHORT: {\r\n let value = dataView.getUint16(byteOffset, true);\r\n if (normalized) {\r\n value = value / 65535;\r\n }\r\n return value;\r\n }\r\n case VertexBuffer.INT: {\r\n return dataView.getInt32(byteOffset, true);\r\n }\r\n case VertexBuffer.UNSIGNED_INT: {\r\n return dataView.getUint32(byteOffset, true);\r\n }\r\n case VertexBuffer.FLOAT: {\r\n return dataView.getFloat32(byteOffset, true);\r\n }\r\n default: {\r\n throw new Error(`Invalid component type ${type}`);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"buffer.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Buffers/buffer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH;IAeI;;;;;;;;;;OAUG;IACH,gBACI,MAAW,EACX,IAA4B,EAC5B,SAAkB,EAClB,MAAU,EACV,wBAAgC,EAChC,SAAiB,EACjB,QAAgB,EAChB,OAAgB;QAJhB,uBAAA,EAAA,UAAU;QACV,yCAAA,EAAA,gCAAgC;QAChC,0BAAA,EAAA,iBAAiB;QACjB,yBAAA,EAAA,gBAAgB;QAzBZ,oBAAe,GAAG,KAAK,CAAC;QA4B5B,IAAI,MAAM,CAAC,QAAQ,EAAE;YACjB,mEAAmE;YACnE,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,CAAC;SAChD;aAAM;YACH,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;SACzB;QAED,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CA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G,SAAS,CAAC;IAC/C;;OAEG;IACoB,mBAAM,GAAG,IAAI,CAAC;IACrC;;OAEG;IACoB,oBAAO,GAAG,KAAK,CAAC;IACvC;;OAEG;IACoB,oBAAO,GAAG,KAAK,CAAC;IACvC;;OAEG;IACoB,oBAAO,GAAG,KAAK,CAAC;IACvC;;OAEG;IACoB,oBAAO,GAAG,KAAK,CAAC;IACvC;;OAEG;IACoB,oBAAO,GAAG,KAAK,CAAC;IACvC;;OAEG;IACoB,sBAAS,GAAG,OAAO,CAAC;IAC3C;;OAEG;IACoB,8BAAiB,GAAG,eAAe,CAAC;IAC3D;;OAEG;IACoB,gCAAmB,GAAG,iBAAiB,CAAC;IAC/D;;OAEG;IACoB,gCAAmB,GAAG,iBAAiB,CAAC;IAC/D;;OAEG;IACoB,qCAAwB,GAAG,sBAAsB,CAAC;IACzE;;OAEG;IACoB,qCAAwB,GAAG,sBAAsB,CAAC;IA8I7E,mBAAC;CAAA,AAxkBD,IAwkBC;SAxkBY,YAAY","sourcesContent":["import type { Nullable, DataArray, FloatArray } from \"../types\";\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\nimport { DataBuffer } from \"./dataBuffer\";\r\n\r\n/**\r\n * Class used to store data that will be store in GPU memory\r\n */\r\nexport class Buffer {\r\n private _engine: ThinEngine;\r\n private _buffer: Nullable<DataBuffer>;\r\n /** @hidden */\r\n public _data: Nullable<DataArray>;\r\n private _updatable: boolean;\r\n private _instanced: boolean;\r\n private _divisor: number;\r\n private _isAlreadyOwned = false;\r\n\r\n /**\r\n * Gets the byte stride.\r\n */\r\n public readonly byteStride: number;\r\n\r\n /**\r\n * Constructor\r\n * @param engine the engine\r\n * @param data the data to use for this buffer\r\n * @param updatable whether the data is updatable\r\n * @param stride the stride (optional)\r\n * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)\r\n * @param instanced whether the buffer is instanced (optional)\r\n * @param useBytes set to true if the stride in in bytes (optional)\r\n * @param divisor sets an optional divisor for instances (1 by default)\r\n */\r\n constructor(\r\n engine: any,\r\n data: DataArray | DataBuffer,\r\n updatable: boolean,\r\n stride = 0,\r\n postponeInternalCreation = false,\r\n instanced = false,\r\n useBytes = false,\r\n divisor?: number\r\n ) {\r\n if (engine.getScene) {\r\n // old versions of VertexBuffer accepted 'mesh' instead of 'engine'\r\n this._engine = engine.getScene().getEngine();\r\n } else {\r\n this._engine = engine;\r\n }\r\n\r\n this._updatable = updatable;\r\n this._instanced = instanced;\r\n this._divisor = divisor || 1;\r\n\r\n if (data instanceof DataBuffer) {\r\n this._data = null;\r\n this._buffer = data;\r\n } else {\r\n this._data = data;\r\n this._buffer = null;\r\n }\r\n\r\n this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;\r\n\r\n if (!postponeInternalCreation) {\r\n // by default\r\n this.create();\r\n }\r\n }\r\n\r\n /**\r\n * Create a new VertexBuffer based on the current buffer\r\n * @param kind defines the vertex buffer kind (position, normal, etc.)\r\n * @param offset defines offset in the buffer (0 by default)\r\n * @param size defines the size in floats of attributes (position is 3 for instance)\r\n * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)\r\n * @param instanced defines if the vertex buffer contains indexed data\r\n * @param useBytes defines if the offset and stride are in bytes *\r\n * @param divisor sets an optional divisor for instances (1 by default)\r\n * @returns the new vertex buffer\r\n */\r\n public createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes = false, divisor?: number): VertexBuffer {\r\n const byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;\r\n const byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;\r\n\r\n // a lot of these parameters are ignored as they are overridden by the buffer\r\n return new VertexBuffer(\r\n this._engine,\r\n this,\r\n kind,\r\n this._updatable,\r\n true,\r\n byteStride,\r\n instanced === undefined ? this._instanced : instanced,\r\n byteOffset,\r\n size,\r\n undefined,\r\n undefined,\r\n true,\r\n this._divisor || divisor\r\n );\r\n }\r\n\r\n // Properties\r\n\r\n /**\r\n * Gets a boolean indicating if the Buffer is updatable?\r\n * @returns true if the buffer is updatable\r\n */\r\n public isUpdatable(): boolean {\r\n return this._updatable;\r\n }\r\n\r\n /**\r\n * Gets current buffer's data\r\n * @returns a DataArray or null\r\n */\r\n public getData(): Nullable<DataArray> {\r\n return this._data;\r\n }\r\n\r\n /**\r\n * Gets underlying native buffer\r\n * @returns underlying native buffer\r\n */\r\n public getBuffer(): Nullable<DataBuffer> {\r\n return this._buffer;\r\n }\r\n\r\n /**\r\n * Gets the stride in float32 units (i.e. byte stride / 4).\r\n * May not be an integer if the byte stride is not divisible by 4.\r\n * @returns the stride in float32 units\r\n * @deprecated Please use byteStride instead.\r\n */\r\n public getStrideSize(): number {\r\n return this.byteStride / Float32Array.BYTES_PER_ELEMENT;\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Store data into the buffer. Creates the buffer if not used already.\r\n * If the buffer was already used, it will be updated only if it is updatable, otherwise it will do nothing.\r\n * @param data defines the data to store\r\n */\r\n public create(data: Nullable<DataArray> = null): void {\r\n if (!data && this._buffer) {\r\n return; // nothing to do\r\n }\r\n\r\n data = data || this._data;\r\n\r\n if (!data) {\r\n return;\r\n }\r\n\r\n if (!this._buffer) {\r\n // create buffer\r\n if (this._updatable) {\r\n this._buffer = this._engine.createDynamicVertexBuffer(data);\r\n this._data = data;\r\n } else {\r\n this._buffer = this._engine.createVertexBuffer(data);\r\n }\r\n } else if (this._updatable) {\r\n // update buffer\r\n this._engine.updateDynamicVertexBuffer(this._buffer, data);\r\n this._data = data;\r\n }\r\n }\r\n\r\n /** @hidden */\r\n public _rebuild(): void {\r\n this._buffer = null;\r\n this.create(this._data);\r\n }\r\n\r\n /**\r\n * Update current buffer data\r\n * @param data defines the data to store\r\n */\r\n public update(data: DataArray): void {\r\n this.create(data);\r\n }\r\n\r\n /**\r\n * Updates the data directly.\r\n * @param data the new data\r\n * @param offset the new offset\r\n * @param vertexCount the vertex count (optional)\r\n * @param useBytes set to true if the offset is in bytes\r\n */\r\n public updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes: boolean = false): void {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n\r\n if (this._updatable) {\r\n // update buffer\r\n this._engine.updateDynamicVertexBuffer(\r\n this._buffer,\r\n data,\r\n useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT,\r\n vertexCount ? vertexCount * this.byteStride : undefined\r\n );\r\n if (offset === 0 && vertexCount === undefined) {\r\n // Keep the data if we easily can\r\n this._data = data;\r\n } else {\r\n this._data = null;\r\n }\r\n }\r\n }\r\n\r\n /** @hidden */\r\n public _increaseReferences() {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n\r\n if (!this._isAlreadyOwned) {\r\n this._isAlreadyOwned = true;\r\n return;\r\n }\r\n\r\n this._buffer.references++;\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose(): void {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n if (this._engine._releaseBuffer(this._buffer)) {\r\n this._buffer = null;\r\n this._data = null;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Specialized buffer used to store vertex data\r\n */\r\nexport class VertexBuffer {\r\n private static _Counter = 0;\r\n\r\n /** @hidden */\r\n public _buffer: Buffer;\r\n /** @hidden */\r\n public _validOffsetRange: boolean; // used internally by the engine\r\n private _kind: string;\r\n private _size: number;\r\n private _ownsBuffer: boolean;\r\n private _instanced: boolean;\r\n private _instanceDivisor: number;\r\n\r\n /**\r\n * The byte type.\r\n */\r\n public static readonly BYTE = 5120;\r\n\r\n /**\r\n * The unsigned byte type.\r\n */\r\n public static readonly UNSIGNED_BYTE = 5121;\r\n\r\n /**\r\n * The short type.\r\n */\r\n public static readonly SHORT = 5122;\r\n\r\n /**\r\n * The unsigned short type.\r\n */\r\n public static readonly UNSIGNED_SHORT = 5123;\r\n\r\n /**\r\n * The integer type.\r\n */\r\n public static readonly INT = 5124;\r\n\r\n /**\r\n * The unsigned integer type.\r\n */\r\n public static readonly UNSIGNED_INT = 5125;\r\n\r\n /**\r\n * The float type.\r\n */\r\n public static readonly FLOAT = 5126;\r\n\r\n /**\r\n * Gets or sets the instance divisor when in instanced mode\r\n */\r\n public get instanceDivisor(): number {\r\n return this._instanceDivisor;\r\n }\r\n\r\n public set instanceDivisor(value: number) {\r\n this._instanceDivisor = value;\r\n if (value == 0) {\r\n this._instanced = false;\r\n } else {\r\n this._instanced = true;\r\n }\r\n this._computeHashCode();\r\n }\r\n\r\n /**\r\n * Gets the byte stride.\r\n */\r\n public readonly byteStride: number;\r\n\r\n /**\r\n * Gets the byte offset.\r\n */\r\n public readonly byteOffset: number;\r\n\r\n /**\r\n * Gets whether integer data values should be normalized into a certain range when being casted to a float.\r\n */\r\n public readonly normalized: boolean;\r\n\r\n /**\r\n * Gets the data type of each component in the array.\r\n */\r\n public readonly type: number;\r\n\r\n /**\r\n * Gets the unique id of this vertex buffer\r\n */\r\n public readonly uniqueId: number;\r\n\r\n /**\r\n * Gets a hash code representing the format (type, normalized, size, instanced, stride) of this buffer\r\n * All buffers with the same format will have the same hash code\r\n */\r\n public readonly hashCode: number;\r\n\r\n /**\r\n * Constructor\r\n * @param engine the engine\r\n * @param data the data to use for this vertex buffer\r\n * @param kind the vertex buffer kind\r\n * @param updatable whether the data is updatable\r\n * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)\r\n * @param stride the stride (optional)\r\n * @param instanced whether the buffer is instanced (optional)\r\n * @param offset the offset of the data (optional)\r\n * @param size the number of components (optional)\r\n * @param type the type of the component (optional)\r\n * @param normalized whether the data contains normalized data (optional)\r\n * @param useBytes set to true if stride and offset are in bytes (optional)\r\n * @param divisor defines the instance divisor to use (1 by default)\r\n * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed\r\n */\r\n constructor(\r\n engine: any,\r\n data: DataArray | Buffer | DataBuffer,\r\n kind: string,\r\n updatable: boolean,\r\n postponeInternalCreation?: boolean,\r\n stride?: number,\r\n instanced?: boolean,\r\n offset?: number,\r\n size?: number,\r\n type?: number,\r\n normalized = false,\r\n useBytes = false,\r\n divisor = 1,\r\n takeBufferOwnership = false\r\n ) {\r\n if (data instanceof Buffer) {\r\n this._buffer = data;\r\n this._ownsBuffer = takeBufferOwnership;\r\n } else {\r\n this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);\r\n this._ownsBuffer = true;\r\n }\r\n\r\n this.uniqueId = VertexBuffer._Counter++;\r\n this._kind = kind;\r\n\r\n if (type == undefined) {\r\n const data = this.getData();\r\n this.type = VertexBuffer.FLOAT;\r\n if (data instanceof Int8Array) {\r\n this.type = VertexBuffer.BYTE;\r\n } else if (data instanceof Uint8Array) {\r\n this.type = VertexBuffer.UNSIGNED_BYTE;\r\n } else if (data instanceof Int16Array) {\r\n this.type = VertexBuffer.SHORT;\r\n } else if (data instanceof Uint16Array) {\r\n this.type = VertexBuffer.UNSIGNED_SHORT;\r\n } else if (data instanceof Int32Array) {\r\n this.type = VertexBuffer.INT;\r\n } else if (data instanceof Uint32Array) {\r\n this.type = VertexBuffer.UNSIGNED_INT;\r\n }\r\n } else {\r\n this.type = type;\r\n }\r\n\r\n const typeByteLength = VertexBuffer.GetTypeByteLength(this.type);\r\n\r\n if (useBytes) {\r\n this._size = size || (stride ? stride / typeByteLength : VertexBuffer.DeduceStride(kind));\r\n this.byteStride = stride || this._buffer.byteStride || this._size * typeByteLength;\r\n this.byteOffset = offset || 0;\r\n } else {\r\n this._size = size || stride || VertexBuffer.DeduceStride(kind);\r\n this.byteStride = stride ? stride * typeByteLength : this._buffer.byteStride || this._size * typeByteLength;\r\n this.byteOffset = (offset || 0) * typeByteLength;\r\n }\r\n\r\n this.normalized = normalized;\r\n\r\n this._instanced = instanced !== undefined ? instanced : false;\r\n this._instanceDivisor = instanced ? divisor : 0;\r\n\r\n this._computeHashCode();\r\n }\r\n\r\n private _computeHashCode(): void {\r\n // note: cast to any because the property is declared readonly\r\n (this.hashCode as any) =\r\n ((this.type - 5120) << 0) +\r\n ((this.normalized ? 1 : 0) << 3) +\r\n (this._size << 4) +\r\n ((this._instanced ? 1 : 0) << 6) +\r\n /* keep 5 bits free */\r\n (this.byteStride << 12);\r\n }\r\n\r\n /** @hidden */\r\n public _rebuild(): void {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n\r\n this._buffer._rebuild();\r\n }\r\n\r\n /**\r\n * Returns the kind of the VertexBuffer (string)\r\n * @returns a string\r\n */\r\n public getKind(): string {\r\n return this._kind;\r\n }\r\n\r\n // Properties\r\n\r\n /**\r\n * Gets a boolean indicating if the VertexBuffer is updatable?\r\n * @returns true if the buffer is updatable\r\n */\r\n public isUpdatable(): boolean {\r\n return this._buffer.isUpdatable();\r\n }\r\n\r\n /**\r\n * Gets current buffer's data\r\n * @returns a DataArray or null\r\n */\r\n public getData(): Nullable<DataArray> {\r\n return this._buffer.getData();\r\n }\r\n\r\n /**\r\n * Gets current buffer's data as a float array. Float data is constructed if the vertex buffer data cannot be returned directly.\r\n * @param totalVertices number of vertices in the buffer to take into account\r\n * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it\r\n * @returns a float array containing vertex data\r\n */\r\n public getFloatData(totalVertices: number, forceCopy?: boolean): Nullable<FloatArray> {\r\n const data = this.getData();\r\n if (!data) {\r\n return null;\r\n }\r\n\r\n const tightlyPackedByteStride = this.getSize() * VertexBuffer.GetTypeByteLength(this.type);\r\n const count = totalVertices * this.getSize();\r\n\r\n if (this.type !== VertexBuffer.FLOAT || this.byteStride !== tightlyPackedByteStride) {\r\n const copy = new Float32Array(count);\r\n this.forEach(count, (value, index) => (copy[index] = value));\r\n return copy;\r\n }\r\n\r\n if (!(data instanceof Array || data instanceof Float32Array) || this.byteOffset !== 0 || data.length !== count) {\r\n if (data instanceof Array) {\r\n const offset = this.byteOffset / 4;\r\n return data.slice(offset, offset + count);\r\n } else if (data instanceof ArrayBuffer) {\r\n return new Float32Array(data, this.byteOffset, count);\r\n } else {\r\n let offset = data.byteOffset + this.byteOffset;\r\n if (forceCopy) {\r\n const result = new Float32Array(count);\r\n const source = new Float32Array(data.buffer, offset, count);\r\n\r\n result.set(source);\r\n\r\n return result;\r\n }\r\n\r\n // Protect against bad data\r\n const remainder = offset % 4;\r\n\r\n if (remainder) {\r\n offset = Math.max(0, offset - remainder);\r\n }\r\n\r\n return new Float32Array(data.buffer, offset, count);\r\n }\r\n }\r\n\r\n if (forceCopy) {\r\n return data.slice();\r\n }\r\n\r\n return data;\r\n }\r\n\r\n /**\r\n * Gets underlying native buffer\r\n * @returns underlying native buffer\r\n */\r\n public getBuffer(): Nullable<DataBuffer> {\r\n return this._buffer.getBuffer();\r\n }\r\n\r\n /**\r\n * Gets the stride in float32 units (i.e. byte stride / 4).\r\n * May not be an integer if the byte stride is not divisible by 4.\r\n * @returns the stride in float32 units\r\n * @deprecated Please use byteStride instead.\r\n */\r\n public getStrideSize(): number {\r\n return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);\r\n }\r\n\r\n /**\r\n * Returns the offset as a multiple of the type byte length.\r\n * @returns the offset in bytes\r\n * @deprecated Please use byteOffset instead.\r\n */\r\n public getOffset(): number {\r\n return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);\r\n }\r\n\r\n /**\r\n * Returns the number of components or the byte size per vertex attribute\r\n * @param sizeInBytes If true, returns the size in bytes or else the size in number of components of the vertex attribute (default: false)\r\n * @returns the number of components\r\n */\r\n public getSize(sizeInBytes = false): number {\r\n return sizeInBytes ? this._size * VertexBuffer.GetTypeByteLength(this.type) : this._size;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced\r\n * @returns true if this buffer is instanced\r\n */\r\n public getIsInstanced(): boolean {\r\n return this._instanced;\r\n }\r\n\r\n /**\r\n * Returns the instancing divisor, zero for non-instanced (integer).\r\n * @returns a number\r\n */\r\n public getInstanceDivisor(): number {\r\n return this._instanceDivisor;\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property\r\n * @param data defines the data to store\r\n */\r\n public create(data?: DataArray): void {\r\n this._buffer.create(data);\r\n }\r\n\r\n /**\r\n * Updates the underlying buffer according to the passed numeric array or Float32Array.\r\n * This function will create a new buffer if the current one is not updatable\r\n * @param data defines the data to store\r\n */\r\n public update(data: DataArray): void {\r\n this._buffer.update(data);\r\n }\r\n\r\n /**\r\n * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.\r\n * Returns the directly updated WebGLBuffer.\r\n * @param data the new data\r\n * @param offset the new offset\r\n * @param useBytes set to true if the offset is in bytes\r\n */\r\n public updateDirectly(data: DataArray, offset: number, useBytes: boolean = false): void {\r\n this._buffer.updateDirectly(data, offset, undefined, useBytes);\r\n }\r\n\r\n /**\r\n * Disposes the VertexBuffer and the underlying WebGLBuffer.\r\n */\r\n public dispose(): void {\r\n if (this._ownsBuffer) {\r\n this._buffer.dispose();\r\n }\r\n }\r\n\r\n /**\r\n * Enumerates each value of this vertex buffer as numbers.\r\n * @param count the number of values to enumerate\r\n * @param callback the callback function called for each value\r\n */\r\n public forEach(count: number, callback: (value: number, index: number) => void): void {\r\n VertexBuffer.ForEach(this._buffer.getData()!, this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);\r\n }\r\n\r\n // Enums\r\n /**\r\n * Positions\r\n */\r\n public static readonly PositionKind = \"position\";\r\n /**\r\n * Normals\r\n */\r\n public static readonly NormalKind = \"normal\";\r\n /**\r\n * Tangents\r\n */\r\n public static readonly TangentKind = \"tangent\";\r\n /**\r\n * Texture coordinates\r\n */\r\n public static readonly UVKind = \"uv\";\r\n /**\r\n * Texture coordinates 2\r\n */\r\n public static readonly UV2Kind = \"uv2\";\r\n /**\r\n * Texture coordinates 3\r\n */\r\n public static readonly UV3Kind = \"uv3\";\r\n /**\r\n * Texture coordinates 4\r\n */\r\n public static readonly UV4Kind = \"uv4\";\r\n /**\r\n * Texture coordinates 5\r\n */\r\n public static readonly UV5Kind = \"uv5\";\r\n /**\r\n * Texture coordinates 6\r\n */\r\n public static readonly UV6Kind = \"uv6\";\r\n /**\r\n * Colors\r\n */\r\n public static readonly ColorKind = \"color\";\r\n /**\r\n * Instance Colors\r\n */\r\n public static readonly ColorInstanceKind = \"instanceColor\";\r\n /**\r\n * Matrix indices (for bones)\r\n */\r\n public static readonly MatricesIndicesKind = \"matricesIndices\";\r\n /**\r\n * Matrix weights (for bones)\r\n */\r\n public static readonly MatricesWeightsKind = \"matricesWeights\";\r\n /**\r\n * Additional matrix indices (for bones)\r\n */\r\n public static readonly MatricesIndicesExtraKind = \"matricesIndicesExtra\";\r\n /**\r\n * Additional matrix weights (for bones)\r\n */\r\n public static readonly MatricesWeightsExtraKind = \"matricesWeightsExtra\";\r\n\r\n /**\r\n * Deduces the stride given a kind.\r\n * @param kind The kind string to deduce\r\n * @returns The deduced stride\r\n */\r\n public static DeduceStride(kind: string): number {\r\n switch (kind) {\r\n case VertexBuffer.UVKind:\r\n case VertexBuffer.UV2Kind:\r\n case VertexBuffer.UV3Kind:\r\n case VertexBuffer.UV4Kind:\r\n case VertexBuffer.UV5Kind:\r\n case VertexBuffer.UV6Kind:\r\n return 2;\r\n case VertexBuffer.NormalKind:\r\n case VertexBuffer.PositionKind:\r\n return 3;\r\n case VertexBuffer.ColorKind:\r\n case VertexBuffer.MatricesIndicesKind:\r\n case VertexBuffer.MatricesIndicesExtraKind:\r\n case VertexBuffer.MatricesWeightsKind:\r\n case VertexBuffer.MatricesWeightsExtraKind:\r\n case VertexBuffer.TangentKind:\r\n return 4;\r\n default:\r\n throw new Error(\"Invalid kind '\" + kind + \"'\");\r\n }\r\n }\r\n\r\n /**\r\n * Gets the byte length of the given type.\r\n * @param type the type\r\n * @returns the number of bytes\r\n */\r\n public static GetTypeByteLength(type: number): number {\r\n switch (type) {\r\n case VertexBuffer.BYTE:\r\n case VertexBuffer.UNSIGNED_BYTE:\r\n return 1;\r\n case VertexBuffer.SHORT:\r\n case VertexBuffer.UNSIGNED_SHORT:\r\n return 2;\r\n case VertexBuffer.INT:\r\n case VertexBuffer.UNSIGNED_INT:\r\n case VertexBuffer.FLOAT:\r\n return 4;\r\n default:\r\n throw new Error(`Invalid type '${type}'`);\r\n }\r\n }\r\n\r\n /**\r\n * Enumerates each value of the given parameters as numbers.\r\n * @param data the data to enumerate\r\n * @param byteOffset the byte offset of the data\r\n * @param byteStride the byte stride of the data\r\n * @param componentCount the number of components per element\r\n * @param componentType the type of the component\r\n * @param count the number of values to enumerate\r\n * @param normalized whether the data is normalized\r\n * @param callback the callback function called for each value\r\n */\r\n public static ForEach(\r\n data: DataArray,\r\n byteOffset: number,\r\n byteStride: number,\r\n componentCount: number,\r\n componentType: number,\r\n count: number,\r\n normalized: boolean,\r\n callback: (value: number, index: number) => void\r\n ): void {\r\n if (data instanceof Array) {\r\n let offset = byteOffset / 4;\r\n const stride = byteStride / 4;\r\n for (let index = 0; index < count; index += componentCount) {\r\n for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {\r\n callback(data[offset + componentIndex], index + componentIndex);\r\n }\r\n offset += stride;\r\n }\r\n } else {\r\n const dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);\r\n const componentByteLength = VertexBuffer.GetTypeByteLength(componentType);\r\n for (let index = 0; index < count; index += componentCount) {\r\n let componentByteOffset = byteOffset;\r\n for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {\r\n const value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);\r\n callback(value, index + componentIndex);\r\n componentByteOffset += componentByteLength;\r\n }\r\n byteOffset += byteStride;\r\n }\r\n }\r\n }\r\n\r\n private static _GetFloatValue(dataView: DataView, type: number, byteOffset: number, normalized: boolean): number {\r\n switch (type) {\r\n case VertexBuffer.BYTE: {\r\n let value = dataView.getInt8(byteOffset);\r\n if (normalized) {\r\n value = Math.max(value / 127, -1);\r\n }\r\n return value;\r\n }\r\n case VertexBuffer.UNSIGNED_BYTE: {\r\n let value = dataView.getUint8(byteOffset);\r\n if (normalized) {\r\n value = value / 255;\r\n }\r\n return value;\r\n }\r\n case VertexBuffer.SHORT: {\r\n let value = dataView.getInt16(byteOffset, true);\r\n if (normalized) {\r\n value = Math.max(value / 32767, -1);\r\n }\r\n return value;\r\n }\r\n case VertexBuffer.UNSIGNED_SHORT: {\r\n let value = dataView.getUint16(byteOffset, true);\r\n if (normalized) {\r\n value = value / 65535;\r\n }\r\n return value;\r\n }\r\n case VertexBuffer.INT: {\r\n return dataView.getInt32(byteOffset, true);\r\n }\r\n case VertexBuffer.UNSIGNED_INT: {\r\n return dataView.getUint32(byteOffset, true);\r\n }\r\n case VertexBuffer.FLOAT: {\r\n return dataView.getFloat32(byteOffset, true);\r\n }\r\n default: {\r\n throw new Error(`Invalid component type ${type}`);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
package/Culling/ray.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ray.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Culling/ray.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAIrD;;GAEG;AACH;IAKI;;;;;OAKG;IACH;IACI,mBAAmB;IACZ,MAAe;IACtB,gBAAgB;IACT,SAAkB;IACzB,wBAAwB;IACjB,MAAiC;QAAjC,uBAAA,EAAA,SAAiB,MAAM,C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nimport { ArrayTools } from \"../Misc/arrayTools\";\r\nimport { Matrix, Vector3, TmpVectors } from \"../Maths/math.vector\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { PickingInfo } from \"../Collisions/pickingInfo\";\r\nimport { IntersectionInfo } from \"../Collisions/intersectionInfo\";\r\nimport type { BoundingBox } from \"./boundingBox\";\r\nimport type { BoundingSphere } from \"./boundingSphere\";\r\nimport { Scene } from \"../scene\";\r\nimport { Camera } from \"../Cameras/camera\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\n\r\ndeclare type Mesh = import(\"../Meshes/mesh\").Mesh;\r\n\r\n/**\r\n * Class representing a ray with position and direction\r\n */\r\nexport class Ray {\r\n private static readonly _TmpVector3 = ArrayTools.BuildArray(6, Vector3.Zero);\r\n private static _RayDistant = Ray.Zero();\r\n private _tmpRay: Ray;\r\n\r\n /**\r\n * Creates a new ray\r\n * @param origin origin point\r\n * @param direction direction\r\n * @param length length of the ray\r\n */\r\n constructor(\r\n /** origin point */\r\n public origin: Vector3,\r\n /** direction */\r\n public direction: Vector3,\r\n /** length of the ray */\r\n public length: number = Number.MAX_VALUE\r\n ) {}\r\n\r\n // Methods\r\n\r\n /**\r\n * Clone the current ray\r\n * @returns a new ray\r\n */\r\n public clone(): Ray {\r\n return new Ray(this.origin.clone(), this.direction.clone(), this.length);\r\n }\r\n\r\n /**\r\n * Checks if the ray intersects a box\r\n * This does not account for the ray length by design to improve perfs.\r\n * @param minimum bound of the box\r\n * @param maximum bound of the box\r\n * @param intersectionTreshold extra extend to be added to the box in all direction\r\n * @returns if the box was hit\r\n */\r\n public intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold: number = 0): boolean {\r\n const newMinimum = Ray._TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);\r\n const newMaximum = Ray._TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);\r\n let d = 0.0;\r\n let maxValue = Number.MAX_VALUE;\r\n let inv: number;\r\n let min: number;\r\n let max: number;\r\n let temp: number;\r\n if (Math.abs(this.direction.x) < 0.0000001) {\r\n if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {\r\n return false;\r\n }\r\n } else {\r\n inv = 1.0 / this.direction.x;\r\n min = (newMinimum.x - this.origin.x) * inv;\r\n max = (newMaximum.x - this.origin.x) * inv;\r\n if (max === -Infinity) {\r\n max = Infinity;\r\n }\r\n\r\n if (min > max) {\r\n temp = min;\r\n min = max;\r\n max = temp;\r\n }\r\n\r\n d = Math.max(min, d);\r\n maxValue = Math.min(max, maxValue);\r\n\r\n if (d > maxValue) {\r\n return false;\r\n }\r\n }\r\n\r\n if (Math.abs(this.direction.y) < 0.0000001) {\r\n if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {\r\n return false;\r\n }\r\n } else {\r\n inv = 1.0 / this.direction.y;\r\n min = (newMinimum.y - this.origin.y) * inv;\r\n max = (newMaximum.y - this.origin.y) * inv;\r\n\r\n if (max === -Infinity) {\r\n max = Infinity;\r\n }\r\n\r\n if (min > max) {\r\n temp = min;\r\n min = max;\r\n max = temp;\r\n }\r\n\r\n d = Math.max(min, d);\r\n maxValue = Math.min(max, maxValue);\r\n\r\n if (d > maxValue) {\r\n return false;\r\n }\r\n }\r\n\r\n if (Math.abs(this.direction.z) < 0.0000001) {\r\n if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {\r\n return false;\r\n }\r\n } else {\r\n inv = 1.0 / this.direction.z;\r\n min = (newMinimum.z - this.origin.z) * inv;\r\n max = (newMaximum.z - this.origin.z) * inv;\r\n\r\n if (max === -Infinity) {\r\n max = Infinity;\r\n }\r\n\r\n if (min > max) {\r\n temp = min;\r\n min = max;\r\n max = temp;\r\n }\r\n\r\n d = Math.max(min, d);\r\n maxValue = Math.min(max, maxValue);\r\n\r\n if (d > maxValue) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Checks if the ray intersects a box\r\n * This does not account for the ray lenght by design to improve perfs.\r\n * @param box the bounding box to check\r\n * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction\r\n * @returns if the box was hit\r\n */\r\n public intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold: number = 0): boolean {\r\n return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);\r\n }\r\n\r\n /**\r\n * If the ray hits a sphere\r\n * @param sphere the bounding sphere to check\r\n * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction\r\n * @returns true if it hits the sphere\r\n */\r\n public intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold: number = 0): boolean {\r\n const x = sphere.center.x - this.origin.x;\r\n const y = sphere.center.y - this.origin.y;\r\n const z = sphere.center.z - this.origin.z;\r\n const pyth = x * x + y * y + z * z;\r\n const radius = sphere.radius + intersectionTreshold;\r\n const rr = radius * radius;\r\n\r\n if (pyth <= rr) {\r\n return true;\r\n }\r\n\r\n const dot = x * this.direction.x + y * this.direction.y + z * this.direction.z;\r\n if (dot < 0.0) {\r\n return false;\r\n }\r\n\r\n const temp = pyth - dot * dot;\r\n\r\n return temp <= rr;\r\n }\r\n\r\n /**\r\n * If the ray hits a triange\r\n * @param vertex0 triangle vertex\r\n * @param vertex1 triangle vertex\r\n * @param vertex2 triangle vertex\r\n * @returns intersection information if hit\r\n */\r\n public intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo> {\r\n const edge1 = Ray._TmpVector3[0];\r\n const edge2 = Ray._TmpVector3[1];\r\n const pvec = Ray._TmpVector3[2];\r\n const tvec = Ray._TmpVector3[3];\r\n const qvec = Ray._TmpVector3[4];\r\n\r\n vertex1.subtractToRef(vertex0, edge1);\r\n vertex2.subtractToRef(vertex0, edge2);\r\n Vector3.CrossToRef(this.direction, edge2, pvec);\r\n const det = Vector3.Dot(edge1, pvec);\r\n\r\n if (det === 0) {\r\n return null;\r\n }\r\n\r\n const invdet = 1 / det;\r\n\r\n this.origin.subtractToRef(vertex0, tvec);\r\n\r\n const bv = Vector3.Dot(tvec, pvec) * invdet;\r\n\r\n if (bv < 0 || bv > 1.0) {\r\n return null;\r\n }\r\n\r\n Vector3.CrossToRef(tvec, edge1, qvec);\r\n\r\n const bw = Vector3.Dot(this.direction, qvec) * invdet;\r\n\r\n if (bw < 0 || bv + bw > 1.0) {\r\n return null;\r\n }\r\n\r\n //check if the distance is longer than the predefined length.\r\n const distance = Vector3.Dot(edge2, qvec) * invdet;\r\n if (distance > this.length) {\r\n return null;\r\n }\r\n\r\n return new IntersectionInfo(1 - bv - bw, bv, distance);\r\n }\r\n\r\n /**\r\n * Checks if ray intersects a plane\r\n * @param plane the plane to check\r\n * @returns the distance away it was hit\r\n */\r\n public intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number> {\r\n let distance: number;\r\n const result1 = Vector3.Dot(plane.normal, this.direction);\r\n if (Math.abs(result1) < 9.99999997475243e-7) {\r\n return null;\r\n } else {\r\n const result2 = Vector3.Dot(plane.normal, this.origin);\r\n distance = (-plane.d - result2) / result1;\r\n if (distance < 0.0) {\r\n if (distance < -9.99999997475243e-7) {\r\n return null;\r\n } else {\r\n return 0;\r\n }\r\n }\r\n\r\n return distance;\r\n }\r\n }\r\n /**\r\n * Calculate the intercept of a ray on a given axis\r\n * @param axis to check 'x' | 'y' | 'z'\r\n * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)\r\n * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.\r\n */\r\n public intersectsAxis(axis: string, offset: number = 0): Nullable<Vector3> {\r\n switch (axis) {\r\n case \"y\": {\r\n const t = (this.origin.y - offset) / this.direction.y;\r\n if (t > 0) {\r\n return null;\r\n }\r\n return new Vector3(this.origin.x + this.direction.x * -t, offset, this.origin.z + this.direction.z * -t);\r\n }\r\n case \"x\": {\r\n const t = (this.origin.x - offset) / this.direction.x;\r\n if (t > 0) {\r\n return null;\r\n }\r\n return new Vector3(offset, this.origin.y + this.direction.y * -t, this.origin.z + this.direction.z * -t);\r\n }\r\n case \"z\": {\r\n const t = (this.origin.z - offset) / this.direction.z;\r\n if (t > 0) {\r\n return null;\r\n }\r\n return new Vector3(this.origin.x + this.direction.x * -t, this.origin.y + this.direction.y * -t, offset);\r\n }\r\n default:\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Checks if ray intersects a mesh\r\n * @param mesh the mesh to check\r\n * @param fastCheck defines if the first intersection will be used (and not the closest)\r\n * @returns picking info of the intersection\r\n */\r\n public intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo {\r\n const tm = TmpVectors.Matrix[0];\r\n\r\n mesh.getWorldMatrix().invertToRef(tm);\r\n\r\n if (this._tmpRay) {\r\n Ray.TransformToRef(this, tm, this._tmpRay);\r\n } else {\r\n this._tmpRay = Ray.Transform(this, tm);\r\n }\r\n\r\n return mesh.intersects(this._tmpRay, fastCheck);\r\n }\r\n\r\n /**\r\n * Checks if ray intersects a mesh\r\n * @param meshes the meshes to check\r\n * @param fastCheck defines if the first intersection will be used (and not the closest)\r\n * @param results array to store result in\r\n * @returns Array of picking infos\r\n */\r\n public intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo> {\r\n if (results) {\r\n results.length = 0;\r\n } else {\r\n results = [];\r\n }\r\n\r\n for (let i = 0; i < meshes.length; i++) {\r\n const pickInfo = this.intersectsMesh(meshes[i], fastCheck);\r\n\r\n if (pickInfo.hit) {\r\n results.push(pickInfo);\r\n }\r\n }\r\n\r\n results.sort(this._comparePickingInfo);\r\n\r\n return results;\r\n }\r\n\r\n private _comparePickingInfo(pickingInfoA: DeepImmutable<PickingInfo>, pickingInfoB: DeepImmutable<PickingInfo>): number {\r\n if (pickingInfoA.distance < pickingInfoB.distance) {\r\n return -1;\r\n } else if (pickingInfoA.distance > pickingInfoB.distance) {\r\n return 1;\r\n } else {\r\n return 0;\r\n }\r\n }\r\n\r\n private static _Smallnum = 0.00000001;\r\n private static _Rayl = 10e8;\r\n\r\n /**\r\n * Intersection test between the ray and a given segment within a given tolerance (threshold)\r\n * @param sega the first point of the segment to test the intersection against\r\n * @param segb the second point of the segment to test the intersection against\r\n * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful\r\n * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection\r\n */\r\n intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number {\r\n const o = this.origin;\r\n const u = TmpVectors.Vector3[0];\r\n const rsegb = TmpVectors.Vector3[1];\r\n const v = TmpVectors.Vector3[2];\r\n const w = TmpVectors.Vector3[3];\r\n\r\n segb.subtractToRef(sega, u);\r\n\r\n this.direction.scaleToRef(Ray._Rayl, v);\r\n o.addToRef(v, rsegb);\r\n\r\n sega.subtractToRef(o, w);\r\n\r\n const a = Vector3.Dot(u, u); // always >= 0\r\n const b = Vector3.Dot(u, v);\r\n const c = Vector3.Dot(v, v); // always >= 0\r\n const d = Vector3.Dot(u, w);\r\n const e = Vector3.Dot(v, w);\r\n const D = a * c - b * b; // always >= 0\r\n let sN: number,\r\n sD = D; // sc = sN / sD, default sD = D >= 0\r\n let tN: number,\r\n tD = D; // tc = tN / tD, default tD = D >= 0\r\n\r\n // compute the line parameters of the two closest points\r\n if (D < Ray._Smallnum) {\r\n // the lines are almost parallel\r\n sN = 0.0; // force using point P0 on segment S1\r\n sD = 1.0; // to prevent possible division by 0.0 later\r\n tN = e;\r\n tD = c;\r\n } else {\r\n // get the closest points on the infinite lines\r\n sN = b * e - c * d;\r\n tN = a * e - b * d;\r\n if (sN < 0.0) {\r\n // sc < 0 => the s=0 edge is visible\r\n sN = 0.0;\r\n tN = e;\r\n tD = c;\r\n } else if (sN > sD) {\r\n // sc > 1 => the s=1 edge is visible\r\n sN = sD;\r\n tN = e + b;\r\n tD = c;\r\n }\r\n }\r\n\r\n if (tN < 0.0) {\r\n // tc < 0 => the t=0 edge is visible\r\n tN = 0.0;\r\n // recompute sc for this edge\r\n if (-d < 0.0) {\r\n sN = 0.0;\r\n } else if (-d > a) {\r\n sN = sD;\r\n } else {\r\n sN = -d;\r\n sD = a;\r\n }\r\n } else if (tN > tD) {\r\n // tc > 1 => the t=1 edge is visible\r\n tN = tD;\r\n // recompute sc for this edge\r\n if (-d + b < 0.0) {\r\n sN = 0;\r\n } else if (-d + b > a) {\r\n sN = sD;\r\n } else {\r\n sN = -d + b;\r\n sD = a;\r\n }\r\n }\r\n // finally do the division to get sc and tc\r\n const sc = Math.abs(sN) < Ray._Smallnum ? 0.0 : sN / sD;\r\n const tc = Math.abs(tN) < Ray._Smallnum ? 0.0 : tN / tD;\r\n\r\n // get the difference of the two closest points\r\n const qtc = TmpVectors.Vector3[4];\r\n v.scaleToRef(tc, qtc);\r\n const qsc = TmpVectors.Vector3[5];\r\n u.scaleToRef(sc, qsc);\r\n qsc.addInPlace(w);\r\n const dP = TmpVectors.Vector3[6];\r\n qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)\r\n\r\n const isIntersected = tc > 0 && tc <= this.length && dP.lengthSquared() < threshold * threshold; // return intersection result\r\n\r\n if (isIntersected) {\r\n return qsc.length();\r\n }\r\n return -1;\r\n }\r\n\r\n /**\r\n * Update the ray from viewport position\r\n * @param x position\r\n * @param y y position\r\n * @param viewportWidth viewport width\r\n * @param viewportHeight viewport height\r\n * @param world world matrix\r\n * @param view view matrix\r\n * @param projection projection matrix\r\n * @param enableDistantPicking defines if picking should handle large values for mesh position/scaling (false by default)\r\n * @returns this ray updated\r\n */\r\n public update(\r\n x: number,\r\n y: number,\r\n viewportWidth: number,\r\n viewportHeight: number,\r\n world: DeepImmutable<Matrix>,\r\n view: DeepImmutable<Matrix>,\r\n projection: DeepImmutable<Matrix>,\r\n enableDistantPicking: boolean = false\r\n ): Ray {\r\n if (enableDistantPicking) {\r\n // With world matrices having great values (like 8000000000 on 1 or more scaling or position axis),\r\n // multiplying view/projection/world and doing invert will result in loss of float precision in the matrix.\r\n // One way to fix it is to compute the ray with world at identity then transform the ray in object space.\r\n // This is slower (2 matrix inverts instead of 1) but precision is preserved.\r\n // This is hidden behind `EnableDistantPicking` flag (default is false)\r\n if (!Ray._RayDistant) {\r\n Ray._RayDistant = Ray.Zero();\r\n }\r\n\r\n Ray._RayDistant.unprojectRayToRef(x, y, viewportWidth, viewportHeight, Matrix.IdentityReadOnly, view, projection);\r\n\r\n const tm = TmpVectors.Matrix[0];\r\n world.invertToRef(tm);\r\n Ray.TransformToRef(Ray._RayDistant, tm, this);\r\n } else {\r\n this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n // Statics\r\n /**\r\n * Creates a ray with origin and direction of 0,0,0\r\n * @returns the new ray\r\n */\r\n public static Zero(): Ray {\r\n return new Ray(Vector3.Zero(), Vector3.Zero());\r\n }\r\n\r\n /**\r\n * Creates a new ray from screen space and viewport\r\n * @param x position\r\n * @param y y position\r\n * @param viewportWidth viewport width\r\n * @param viewportHeight viewport height\r\n * @param world world matrix\r\n * @param view view matrix\r\n * @param projection projection matrix\r\n * @returns new ray\r\n */\r\n public static CreateNew(\r\n x: number,\r\n y: number,\r\n viewportWidth: number,\r\n viewportHeight: number,\r\n world: DeepImmutable<Matrix>,\r\n view: DeepImmutable<Matrix>,\r\n projection: DeepImmutable<Matrix>\r\n ): Ray {\r\n const result = Ray.Zero();\r\n\r\n return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);\r\n }\r\n\r\n /**\r\n * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be\r\n * transformed to the given world matrix.\r\n * @param origin The origin point\r\n * @param end The end point\r\n * @param world a matrix to transform the ray to. Default is the identity matrix.\r\n * @returns the new ray\r\n */\r\n public static CreateNewFromTo(origin: Vector3, end: Vector3, world: DeepImmutable<Matrix> = Matrix.IdentityReadOnly): Ray {\r\n const direction = end.subtract(origin);\r\n const length = Math.sqrt(direction.x * direction.x + direction.y * direction.y + direction.z * direction.z);\r\n direction.normalize();\r\n\r\n return Ray.Transform(new Ray(origin, direction, length), world);\r\n }\r\n\r\n /**\r\n * Transforms a ray by a matrix\r\n * @param ray ray to transform\r\n * @param matrix matrix to apply\r\n * @returns the resulting new ray\r\n */\r\n public static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray {\r\n const result = new Ray(new Vector3(0, 0, 0), new Vector3(0, 0, 0));\r\n Ray.TransformToRef(ray, matrix, result);\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Transforms a ray by a matrix\r\n * @param ray ray to transform\r\n * @param matrix matrix to apply\r\n * @param result ray to store result in\r\n */\r\n public static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void {\r\n Vector3.TransformCoordinatesToRef(ray.origin, matrix, result.origin);\r\n Vector3.TransformNormalToRef(ray.direction, matrix, result.direction);\r\n result.length = ray.length;\r\n\r\n const dir = result.direction;\r\n const len = dir.length();\r\n\r\n if (!(len === 0 || len === 1)) {\r\n const num = 1.0 / len;\r\n dir.x *= num;\r\n dir.y *= num;\r\n dir.z *= num;\r\n result.length *= len;\r\n }\r\n }\r\n\r\n /**\r\n * Unproject a ray from screen space to object space\r\n * @param sourceX defines the screen space x coordinate to use\r\n * @param sourceY defines the screen space y coordinate to use\r\n * @param viewportWidth defines the current width of the viewport\r\n * @param viewportHeight defines the current height of the viewport\r\n * @param world defines the world matrix to use (can be set to Identity to go to world space)\r\n * @param view defines the view matrix to use\r\n * @param projection defines the projection matrix to use\r\n */\r\n public unprojectRayToRef(\r\n sourceX: float,\r\n sourceY: float,\r\n viewportWidth: number,\r\n viewportHeight: number,\r\n world: DeepImmutable<Matrix>,\r\n view: DeepImmutable<Matrix>,\r\n projection: DeepImmutable<Matrix>\r\n ): void {\r\n const matrix = TmpVectors.Matrix[0];\r\n world.multiplyToRef(view, matrix);\r\n matrix.multiplyToRef(projection, matrix);\r\n matrix.invert();\r\n\r\n const nearScreenSource = TmpVectors.Vector3[0];\r\n nearScreenSource.x = (sourceX / viewportWidth) * 2 - 1;\r\n nearScreenSource.y = -((sourceY / viewportHeight) * 2 - 1);\r\n nearScreenSource.z = EngineStore.LastCreatedEngine?.isNDCHalfZRange ? 0 : -1;\r\n\r\n // far Z need to be close but < to 1 or camera projection matrix with maxZ = 0 will NaN\r\n const farScreenSource = TmpVectors.Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0 - 1e-8);\r\n const nearVec3 = TmpVectors.Vector3[2];\r\n const farVec3 = TmpVectors.Vector3[3];\r\n Vector3._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);\r\n Vector3._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);\r\n\r\n this.origin.copyFrom(nearVec3);\r\n farVec3.subtractToRef(nearVec3, this.direction);\r\n this.direction.normalize();\r\n }\r\n}\r\n\r\n// Picking\r\n/**\r\n * Type used to define predicate used to select faces when a mesh intersection is detected\r\n */\r\nexport type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;\r\n\r\ndeclare module \"../scene\" {\r\n export interface Scene {\r\n /** @hidden */\r\n _tempPickingRay: Nullable<Ray>;\r\n\r\n /** @hidden */\r\n _cachedRayForTransform: Ray;\r\n\r\n /** @hidden */\r\n _pickWithRayInverseMatrix: Matrix;\r\n\r\n /** @hidden */\r\n _internalPick(\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n fastCheck?: boolean,\r\n onlyBoundingInfo?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n ): Nullable<PickingInfo>;\r\n\r\n /** @hidden */\r\n _internalMultiPick(\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n ): Nullable<PickingInfo[]>;\r\n\r\n /** @hidden */\r\n _internalPickForMesh(\r\n pickingInfo: Nullable<PickingInfo>,\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n mesh: AbstractMesh,\r\n world: Matrix,\r\n fastCheck?: boolean,\r\n onlyBoundingInfo?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate,\r\n skipBoundingInfo?: boolean\r\n ): Nullable<PickingInfo>;\r\n }\r\n}\r\n\r\nScene.prototype.createPickingRay = function (x: number, y: number, world: Nullable<Matrix>, camera: Nullable<Camera>, cameraViewSpace = false): Ray {\r\n const result = Ray.Zero();\r\n\r\n this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);\r\n\r\n return result;\r\n};\r\n\r\nScene.prototype.createPickingRayToRef = function (\r\n x: number,\r\n y: number,\r\n world: Nullable<Matrix>,\r\n result: Ray,\r\n camera: Nullable<Camera>,\r\n cameraViewSpace = false,\r\n enableDistantPicking = false\r\n): Scene {\r\n const engine = this.getEngine();\r\n\r\n if (!camera) {\r\n if (!this.activeCamera) {\r\n return this;\r\n }\r\n\r\n camera = this.activeCamera;\r\n }\r\n\r\n const cameraViewport = camera.viewport;\r\n const viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());\r\n\r\n // Moving coordinates to local viewport world\r\n x = x / engine.getHardwareScalingLevel() - viewport.x;\r\n y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);\r\n\r\n result.update(\r\n x,\r\n y,\r\n viewport.width,\r\n viewport.height,\r\n world ? world : Matrix.IdentityReadOnly,\r\n cameraViewSpace ? Matrix.IdentityReadOnly : camera.getViewMatrix(),\r\n camera.getProjectionMatrix(),\r\n enableDistantPicking\r\n );\r\n return this;\r\n};\r\n\r\nScene.prototype.createPickingRayInCameraSpace = function (x: number, y: number, camera?: Camera): Ray {\r\n const result = Ray.Zero();\r\n\r\n this.createPickingRayInCameraSpaceToRef(x, y, result, camera);\r\n\r\n return result;\r\n};\r\n\r\nScene.prototype.createPickingRayInCameraSpaceToRef = function (x: number, y: number, result: Ray, camera?: Camera): Scene {\r\n if (!PickingInfo) {\r\n return this;\r\n }\r\n\r\n const engine = this.getEngine();\r\n\r\n if (!camera) {\r\n if (!this.activeCamera) {\r\n throw new Error(\"Active camera not set\");\r\n }\r\n\r\n camera = this.activeCamera;\r\n }\r\n\r\n const cameraViewport = camera.viewport;\r\n const viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());\r\n const identity = Matrix.Identity();\r\n\r\n // Moving coordinates to local viewport world\r\n x = x / engine.getHardwareScalingLevel() - viewport.x;\r\n y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);\r\n result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());\r\n return this;\r\n};\r\n\r\nScene.prototype._internalPickForMesh = function (\r\n pickingInfo: Nullable<PickingInfo>,\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n mesh: AbstractMesh,\r\n world: Matrix,\r\n fastCheck?: boolean,\r\n onlyBoundingInfo?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate,\r\n skipBoundingInfo?: boolean\r\n) {\r\n const ray = rayFunction(world, mesh.enableDistantPicking);\r\n\r\n const result = mesh.intersects(ray, fastCheck, trianglePredicate, onlyBoundingInfo, world, skipBoundingInfo);\r\n if (!result || !result.hit) {\r\n return null;\r\n }\r\n\r\n if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {\r\n return null;\r\n }\r\n\r\n return result;\r\n};\r\n\r\nScene.prototype._internalPick = function (\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n fastCheck?: boolean,\r\n onlyBoundingInfo?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n): Nullable<PickingInfo> {\r\n if (!PickingInfo) {\r\n return null;\r\n }\r\n\r\n let pickingInfo = null;\r\n\r\n for (let meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {\r\n const mesh = this.meshes[meshIndex];\r\n\r\n if (predicate) {\r\n if (!predicate(mesh)) {\r\n continue;\r\n }\r\n } else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {\r\n continue;\r\n }\r\n\r\n const world = mesh.getWorldMatrix();\r\n\r\n if (mesh.hasThinInstances && (mesh as Mesh).thinInstanceEnablePicking) {\r\n // first check if the ray intersects the whole bounding box/sphere of the mesh\r\n const result = this._internalPickForMesh(pickingInfo, rayFunction, mesh, world, true, true, trianglePredicate);\r\n if (result) {\r\n if (onlyBoundingInfo) {\r\n // the user only asked for a bounding info check so we can return\r\n return result;\r\n }\r\n const tmpMatrix = TmpVectors.Matrix[1];\r\n const thinMatrices = (mesh as Mesh).thinInstanceGetWorldMatrices();\r\n for (let index = 0; index < thinMatrices.length; index++) {\r\n const thinMatrix = thinMatrices[index];\r\n thinMatrix.multiplyToRef(world, tmpMatrix);\r\n const result = this._internalPickForMesh(pickingInfo, rayFunction, mesh, tmpMatrix, fastCheck, onlyBoundingInfo, trianglePredicate, true);\r\n\r\n if (result) {\r\n pickingInfo = result;\r\n pickingInfo.thinInstanceIndex = index;\r\n\r\n if (fastCheck) {\r\n return pickingInfo;\r\n }\r\n }\r\n }\r\n }\r\n } else {\r\n const result = this._internalPickForMesh(pickingInfo, rayFunction, mesh, world, fastCheck, onlyBoundingInfo, trianglePredicate);\r\n\r\n if (result) {\r\n pickingInfo = result;\r\n\r\n if (fastCheck) {\r\n return pickingInfo;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return pickingInfo || new PickingInfo();\r\n};\r\n\r\nScene.prototype._internalMultiPick = function (\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n): Nullable<PickingInfo[]> {\r\n if (!PickingInfo) {\r\n return null;\r\n }\r\n const pickingInfos = new Array<PickingInfo>();\r\n\r\n for (let meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {\r\n const mesh = this.meshes[meshIndex];\r\n\r\n if (predicate) {\r\n if (!predicate(mesh)) {\r\n continue;\r\n }\r\n } else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {\r\n continue;\r\n }\r\n\r\n const world = mesh.getWorldMatrix();\r\n\r\n if (mesh.hasThinInstances && (mesh as Mesh).thinInstanceEnablePicking) {\r\n const result = this._internalPickForMesh(null, rayFunction, mesh, world, true, true, trianglePredicate);\r\n if (result) {\r\n const tmpMatrix = TmpVectors.Matrix[1];\r\n const thinMatrices = (mesh as Mesh).thinInstanceGetWorldMatrices();\r\n for (let index = 0; index < thinMatrices.length; index++) {\r\n const thinMatrix = thinMatrices[index];\r\n thinMatrix.multiplyToRef(world, tmpMatrix);\r\n const result = this._internalPickForMesh(null, rayFunction, mesh, tmpMatrix, false, false, trianglePredicate, true);\r\n\r\n if (result) {\r\n result.thinInstanceIndex = index;\r\n pickingInfos.push(result);\r\n }\r\n }\r\n }\r\n } else {\r\n const result = this._internalPickForMesh(null, rayFunction, mesh, world, false, false, trianglePredicate);\r\n\r\n if (result) {\r\n pickingInfos.push(result);\r\n }\r\n }\r\n }\r\n\r\n return pickingInfos;\r\n};\r\n\r\nScene.prototype.pickWithBoundingInfo = function (\r\n x: number,\r\n y: number,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n fastCheck?: boolean,\r\n camera?: Nullable<Camera>\r\n): Nullable<PickingInfo> {\r\n if (!PickingInfo) {\r\n return null;\r\n }\r\n const result = this._internalPick(\r\n (world) => {\r\n if (!this._tempPickingRay) {\r\n this._tempPickingRay = Ray.Zero();\r\n }\r\n\r\n this.createPickingRayToRef(x, y, world, this._tempPickingRay, camera || null);\r\n return this._tempPickingRay;\r\n },\r\n predicate,\r\n fastCheck,\r\n true\r\n );\r\n if (result) {\r\n result.ray = this.createPickingRay(x, y, Matrix.Identity(), camera || null);\r\n }\r\n return result;\r\n};\r\n\r\nScene.prototype.pick = function (\r\n x: number,\r\n y: number,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n fastCheck?: boolean,\r\n camera?: Nullable<Camera>,\r\n trianglePredicate?: TrianglePickingPredicate,\r\n _enableDistantPicking = false\r\n): Nullable<PickingInfo> {\r\n if (!PickingInfo) {\r\n return null;\r\n }\r\n const result = this._internalPick(\r\n (world, enableDistantPicking) => {\r\n if (!this._tempPickingRay) {\r\n this._tempPickingRay = Ray.Zero();\r\n }\r\n\r\n this.createPickingRayToRef(x, y, world, this._tempPickingRay, camera || null, false, enableDistantPicking);\r\n return this._tempPickingRay;\r\n },\r\n predicate,\r\n fastCheck,\r\n false,\r\n trianglePredicate\r\n );\r\n if (result) {\r\n result.ray = this.createPickingRay(x, y, Matrix.Identity(), camera || null);\r\n }\r\n return result;\r\n};\r\n\r\nScene.prototype.pickWithRay = function (\r\n ray: Ray,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n fastCheck?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n): Nullable<PickingInfo> {\r\n const result = this._internalPick(\r\n (world) => {\r\n if (!this._pickWithRayInverseMatrix) {\r\n this._pickWithRayInverseMatrix = Matrix.Identity();\r\n }\r\n world.invertToRef(this._pickWithRayInverseMatrix);\r\n\r\n if (!this._cachedRayForTransform) {\r\n this._cachedRayForTransform = Ray.Zero();\r\n }\r\n\r\n Ray.TransformToRef(ray, this._pickWithRayInverseMatrix, this._cachedRayForTransform);\r\n return this._cachedRayForTransform;\r\n },\r\n predicate,\r\n fastCheck,\r\n false,\r\n trianglePredicate\r\n );\r\n if (result) {\r\n result.ray = ray;\r\n }\r\n return result;\r\n};\r\n\r\nScene.prototype.multiPick = function (\r\n x: number,\r\n y: number,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n camera?: Camera,\r\n trianglePredicate?: TrianglePickingPredicate\r\n): Nullable<PickingInfo[]> {\r\n return this._internalMultiPick((world) => this.createPickingRay(x, y, world, camera || null), predicate, trianglePredicate);\r\n};\r\n\r\nScene.prototype.multiPickWithRay = function (ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]> {\r\n return this._internalMultiPick(\r\n (world) => {\r\n if (!this._pickWithRayInverseMatrix) {\r\n this._pickWithRayInverseMatrix = Matrix.Identity();\r\n }\r\n world.invertToRef(this._pickWithRayInverseMatrix);\r\n\r\n if (!this._cachedRayForTransform) {\r\n this._cachedRayForTransform = Ray.Zero();\r\n }\r\n\r\n Ray.TransformToRef(ray, this._pickWithRayInverseMatrix, this._cachedRayForTransform);\r\n return this._cachedRayForTransform;\r\n },\r\n predicate,\r\n trianglePredicate\r\n );\r\n};\r\n\r\nCamera.prototype.getForwardRay = function (length = 100, transform?: Matrix, origin?: Vector3): Ray {\r\n return this.getForwardRayToRef(new Ray(Vector3.Zero(), Vector3.Zero(), length), length, transform, origin);\r\n};\r\n\r\nCamera.prototype.getForwardRayToRef = function (refRay: Ray, length = 100, transform?: Matrix, origin?: Vector3): Ray {\r\n if (!transform) {\r\n transform = this.getWorldMatrix();\r\n }\r\n refRay.length = length;\r\n\r\n if (!origin) {\r\n refRay.origin.copyFrom(this.position);\r\n } else {\r\n refRay.origin.copyFrom(origin);\r\n }\r\n TmpVectors.Vector3[2].set(0, 0, this._scene.useRightHandedSystem ? -1 : 1);\r\n Vector3.TransformNormalToRef(TmpVectors.Vector3[2], transform, TmpVectors.Vector3[3]);\r\n\r\n Vector3.NormalizeToRef(TmpVectors.Vector3[3], refRay.direction);\r\n\r\n return refRay;\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"ray.js","sourceRoot":"","sources":["../../../../../lts/core/generated/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AAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;KAClC;IACD,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3E,OAAO,CAAC,oBAAoB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAEtF,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;IAEhE,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC","sourcesContent":["import type { DeepImmutable, Nullable, float } from \"../types\";\r\nimport { ArrayTools } from \"../Misc/arrayTools\";\r\nimport { Matrix, Vector3, TmpVectors } from \"../Maths/math.vector\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { PickingInfo } from \"../Collisions/pickingInfo\";\r\nimport { IntersectionInfo } from \"../Collisions/intersectionInfo\";\r\nimport type { BoundingBox } from \"./boundingBox\";\r\nimport type { BoundingSphere } from \"./boundingSphere\";\r\nimport { Scene } from \"../scene\";\r\nimport { Camera } from \"../Cameras/camera\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\n\r\ndeclare type Mesh = import(\"../Meshes/mesh\").Mesh;\r\n\r\n/**\r\n * Class representing a ray with position and direction\r\n */\r\nexport class Ray {\r\n private static readonly _TmpVector3 = ArrayTools.BuildArray(6, Vector3.Zero);\r\n private static _RayDistant = Ray.Zero();\r\n private _tmpRay: Ray;\r\n\r\n /**\r\n * Creates a new ray\r\n * @param origin origin point\r\n * @param direction direction\r\n * @param length length of the ray\r\n */\r\n constructor(\r\n /** origin point */\r\n public origin: Vector3,\r\n /** direction */\r\n public direction: Vector3,\r\n /** length of the ray */\r\n public length: number = Number.MAX_VALUE\r\n ) {}\r\n\r\n // Methods\r\n\r\n /**\r\n * Clone the current ray\r\n * @returns a new ray\r\n */\r\n public clone(): Ray {\r\n return new Ray(this.origin.clone(), this.direction.clone(), this.length);\r\n }\r\n\r\n /**\r\n * Checks if the ray intersects a box\r\n * This does not account for the ray length by design to improve perfs.\r\n * @param minimum bound of the box\r\n * @param maximum bound of the box\r\n * @param intersectionTreshold extra extend to be added to the box in all direction\r\n * @returns if the box was hit\r\n */\r\n public intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold: number = 0): boolean {\r\n const newMinimum = Ray._TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);\r\n const newMaximum = Ray._TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);\r\n let d = 0.0;\r\n let maxValue = Number.MAX_VALUE;\r\n let inv: number;\r\n let min: number;\r\n let max: number;\r\n let temp: number;\r\n if (Math.abs(this.direction.x) < 0.0000001) {\r\n if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {\r\n return false;\r\n }\r\n } else {\r\n inv = 1.0 / this.direction.x;\r\n min = (newMinimum.x - this.origin.x) * inv;\r\n max = (newMaximum.x - this.origin.x) * inv;\r\n if (max === -Infinity) {\r\n max = Infinity;\r\n }\r\n\r\n if (min > max) {\r\n temp = min;\r\n min = max;\r\n max = temp;\r\n }\r\n\r\n d = Math.max(min, d);\r\n maxValue = Math.min(max, maxValue);\r\n\r\n if (d > maxValue) {\r\n return false;\r\n }\r\n }\r\n\r\n if (Math.abs(this.direction.y) < 0.0000001) {\r\n if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {\r\n return false;\r\n }\r\n } else {\r\n inv = 1.0 / this.direction.y;\r\n min = (newMinimum.y - this.origin.y) * inv;\r\n max = (newMaximum.y - this.origin.y) * inv;\r\n\r\n if (max === -Infinity) {\r\n max = Infinity;\r\n }\r\n\r\n if (min > max) {\r\n temp = min;\r\n min = max;\r\n max = temp;\r\n }\r\n\r\n d = Math.max(min, d);\r\n maxValue = Math.min(max, maxValue);\r\n\r\n if (d > maxValue) {\r\n return false;\r\n }\r\n }\r\n\r\n if (Math.abs(this.direction.z) < 0.0000001) {\r\n if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {\r\n return false;\r\n }\r\n } else {\r\n inv = 1.0 / this.direction.z;\r\n min = (newMinimum.z - this.origin.z) * inv;\r\n max = (newMaximum.z - this.origin.z) * inv;\r\n\r\n if (max === -Infinity) {\r\n max = Infinity;\r\n }\r\n\r\n if (min > max) {\r\n temp = min;\r\n min = max;\r\n max = temp;\r\n }\r\n\r\n d = Math.max(min, d);\r\n maxValue = Math.min(max, maxValue);\r\n\r\n if (d > maxValue) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Checks if the ray intersects a box\r\n * This does not account for the ray lenght by design to improve perfs.\r\n * @param box the bounding box to check\r\n * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction\r\n * @returns if the box was hit\r\n */\r\n public intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold: number = 0): boolean {\r\n return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);\r\n }\r\n\r\n /**\r\n * If the ray hits a sphere\r\n * @param sphere the bounding sphere to check\r\n * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction\r\n * @returns true if it hits the sphere\r\n */\r\n public intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold: number = 0): boolean {\r\n const x = sphere.center.x - this.origin.x;\r\n const y = sphere.center.y - this.origin.y;\r\n const z = sphere.center.z - this.origin.z;\r\n const pyth = x * x + y * y + z * z;\r\n const radius = sphere.radius + intersectionTreshold;\r\n const rr = radius * radius;\r\n\r\n if (pyth <= rr) {\r\n return true;\r\n }\r\n\r\n const dot = x * this.direction.x + y * this.direction.y + z * this.direction.z;\r\n if (dot < 0.0) {\r\n return false;\r\n }\r\n\r\n const temp = pyth - dot * dot;\r\n\r\n return temp <= rr;\r\n }\r\n\r\n /**\r\n * If the ray hits a triange\r\n * @param vertex0 triangle vertex\r\n * @param vertex1 triangle vertex\r\n * @param vertex2 triangle vertex\r\n * @returns intersection information if hit\r\n */\r\n public intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo> {\r\n const edge1 = Ray._TmpVector3[0];\r\n const edge2 = Ray._TmpVector3[1];\r\n const pvec = Ray._TmpVector3[2];\r\n const tvec = Ray._TmpVector3[3];\r\n const qvec = Ray._TmpVector3[4];\r\n\r\n vertex1.subtractToRef(vertex0, edge1);\r\n vertex2.subtractToRef(vertex0, edge2);\r\n Vector3.CrossToRef(this.direction, edge2, pvec);\r\n const det = Vector3.Dot(edge1, pvec);\r\n\r\n if (det === 0) {\r\n return null;\r\n }\r\n\r\n const invdet = 1 / det;\r\n\r\n this.origin.subtractToRef(vertex0, tvec);\r\n\r\n const bv = Vector3.Dot(tvec, pvec) * invdet;\r\n\r\n if (bv < 0 || bv > 1.0) {\r\n return null;\r\n }\r\n\r\n Vector3.CrossToRef(tvec, edge1, qvec);\r\n\r\n const bw = Vector3.Dot(this.direction, qvec) * invdet;\r\n\r\n if (bw < 0 || bv + bw > 1.0) {\r\n return null;\r\n }\r\n\r\n //check if the distance is longer than the predefined length.\r\n const distance = Vector3.Dot(edge2, qvec) * invdet;\r\n if (distance > this.length) {\r\n return null;\r\n }\r\n\r\n return new IntersectionInfo(1 - bv - bw, bv, distance);\r\n }\r\n\r\n /**\r\n * Checks if ray intersects a plane\r\n * @param plane the plane to check\r\n * @returns the distance away it was hit\r\n */\r\n public intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number> {\r\n let distance: number;\r\n const result1 = Vector3.Dot(plane.normal, this.direction);\r\n if (Math.abs(result1) < 9.99999997475243e-7) {\r\n return null;\r\n } else {\r\n const result2 = Vector3.Dot(plane.normal, this.origin);\r\n distance = (-plane.d - result2) / result1;\r\n if (distance < 0.0) {\r\n if (distance < -9.99999997475243e-7) {\r\n return null;\r\n } else {\r\n return 0;\r\n }\r\n }\r\n\r\n return distance;\r\n }\r\n }\r\n /**\r\n * Calculate the intercept of a ray on a given axis\r\n * @param axis to check 'x' | 'y' | 'z'\r\n * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)\r\n * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.\r\n */\r\n public intersectsAxis(axis: string, offset: number = 0): Nullable<Vector3> {\r\n switch (axis) {\r\n case \"y\": {\r\n const t = (this.origin.y - offset) / this.direction.y;\r\n if (t > 0) {\r\n return null;\r\n }\r\n return new Vector3(this.origin.x + this.direction.x * -t, offset, this.origin.z + this.direction.z * -t);\r\n }\r\n case \"x\": {\r\n const t = (this.origin.x - offset) / this.direction.x;\r\n if (t > 0) {\r\n return null;\r\n }\r\n return new Vector3(offset, this.origin.y + this.direction.y * -t, this.origin.z + this.direction.z * -t);\r\n }\r\n case \"z\": {\r\n const t = (this.origin.z - offset) / this.direction.z;\r\n if (t > 0) {\r\n return null;\r\n }\r\n return new Vector3(this.origin.x + this.direction.x * -t, this.origin.y + this.direction.y * -t, offset);\r\n }\r\n default:\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Checks if ray intersects a mesh\r\n * @param mesh the mesh to check\r\n * @param fastCheck defines if the first intersection will be used (and not the closest)\r\n * @returns picking info of the intersection\r\n */\r\n public intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo {\r\n const tm = TmpVectors.Matrix[0];\r\n\r\n mesh.getWorldMatrix().invertToRef(tm);\r\n\r\n if (this._tmpRay) {\r\n Ray.TransformToRef(this, tm, this._tmpRay);\r\n } else {\r\n this._tmpRay = Ray.Transform(this, tm);\r\n }\r\n\r\n return mesh.intersects(this._tmpRay, fastCheck);\r\n }\r\n\r\n /**\r\n * Checks if ray intersects a mesh\r\n * @param meshes the meshes to check\r\n * @param fastCheck defines if the first intersection will be used (and not the closest)\r\n * @param results array to store result in\r\n * @returns Array of picking infos\r\n */\r\n public intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo> {\r\n if (results) {\r\n results.length = 0;\r\n } else {\r\n results = [];\r\n }\r\n\r\n for (let i = 0; i < meshes.length; i++) {\r\n const pickInfo = this.intersectsMesh(meshes[i], fastCheck);\r\n\r\n if (pickInfo.hit) {\r\n results.push(pickInfo);\r\n }\r\n }\r\n\r\n results.sort(this._comparePickingInfo);\r\n\r\n return results;\r\n }\r\n\r\n private _comparePickingInfo(pickingInfoA: DeepImmutable<PickingInfo>, pickingInfoB: DeepImmutable<PickingInfo>): number {\r\n if (pickingInfoA.distance < pickingInfoB.distance) {\r\n return -1;\r\n } else if (pickingInfoA.distance > pickingInfoB.distance) {\r\n return 1;\r\n } else {\r\n return 0;\r\n }\r\n }\r\n\r\n private static _Smallnum = 0.00000001;\r\n private static _Rayl = 10e8;\r\n\r\n /**\r\n * Intersection test between the ray and a given segment within a given tolerance (threshold)\r\n * @param sega the first point of the segment to test the intersection against\r\n * @param segb the second point of the segment to test the intersection against\r\n * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful\r\n * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection\r\n */\r\n intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number {\r\n const o = this.origin;\r\n const u = TmpVectors.Vector3[0];\r\n const rsegb = TmpVectors.Vector3[1];\r\n const v = TmpVectors.Vector3[2];\r\n const w = TmpVectors.Vector3[3];\r\n\r\n segb.subtractToRef(sega, u);\r\n\r\n this.direction.scaleToRef(Ray._Rayl, v);\r\n o.addToRef(v, rsegb);\r\n\r\n sega.subtractToRef(o, w);\r\n\r\n const a = Vector3.Dot(u, u); // always >= 0\r\n const b = Vector3.Dot(u, v);\r\n const c = Vector3.Dot(v, v); // always >= 0\r\n const d = Vector3.Dot(u, w);\r\n const e = Vector3.Dot(v, w);\r\n const D = a * c - b * b; // always >= 0\r\n let sN: number,\r\n sD = D; // sc = sN / sD, default sD = D >= 0\r\n let tN: number,\r\n tD = D; // tc = tN / tD, default tD = D >= 0\r\n\r\n // compute the line parameters of the two closest points\r\n if (D < Ray._Smallnum) {\r\n // the lines are almost parallel\r\n sN = 0.0; // force using point P0 on segment S1\r\n sD = 1.0; // to prevent possible division by 0.0 later\r\n tN = e;\r\n tD = c;\r\n } else {\r\n // get the closest points on the infinite lines\r\n sN = b * e - c * d;\r\n tN = a * e - b * d;\r\n if (sN < 0.0) {\r\n // sc < 0 => the s=0 edge is visible\r\n sN = 0.0;\r\n tN = e;\r\n tD = c;\r\n } else if (sN > sD) {\r\n // sc > 1 => the s=1 edge is visible\r\n sN = sD;\r\n tN = e + b;\r\n tD = c;\r\n }\r\n }\r\n\r\n if (tN < 0.0) {\r\n // tc < 0 => the t=0 edge is visible\r\n tN = 0.0;\r\n // recompute sc for this edge\r\n if (-d < 0.0) {\r\n sN = 0.0;\r\n } else if (-d > a) {\r\n sN = sD;\r\n } else {\r\n sN = -d;\r\n sD = a;\r\n }\r\n } else if (tN > tD) {\r\n // tc > 1 => the t=1 edge is visible\r\n tN = tD;\r\n // recompute sc for this edge\r\n if (-d + b < 0.0) {\r\n sN = 0;\r\n } else if (-d + b > a) {\r\n sN = sD;\r\n } else {\r\n sN = -d + b;\r\n sD = a;\r\n }\r\n }\r\n // finally do the division to get sc and tc\r\n const sc = Math.abs(sN) < Ray._Smallnum ? 0.0 : sN / sD;\r\n const tc = Math.abs(tN) < Ray._Smallnum ? 0.0 : tN / tD;\r\n\r\n // get the difference of the two closest points\r\n const qtc = TmpVectors.Vector3[4];\r\n v.scaleToRef(tc, qtc);\r\n const qsc = TmpVectors.Vector3[5];\r\n u.scaleToRef(sc, qsc);\r\n qsc.addInPlace(w);\r\n const dP = TmpVectors.Vector3[6];\r\n qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)\r\n\r\n const isIntersected = tc > 0 && tc <= this.length && dP.lengthSquared() < threshold * threshold; // return intersection result\r\n\r\n if (isIntersected) {\r\n return qsc.length();\r\n }\r\n return -1;\r\n }\r\n\r\n /**\r\n * Update the ray from viewport position\r\n * @param x position\r\n * @param y y position\r\n * @param viewportWidth viewport width\r\n * @param viewportHeight viewport height\r\n * @param world world matrix\r\n * @param view view matrix\r\n * @param projection projection matrix\r\n * @param enableDistantPicking defines if picking should handle large values for mesh position/scaling (false by default)\r\n * @returns this ray updated\r\n */\r\n public update(\r\n x: number,\r\n y: number,\r\n viewportWidth: number,\r\n viewportHeight: number,\r\n world: DeepImmutable<Matrix>,\r\n view: DeepImmutable<Matrix>,\r\n projection: DeepImmutable<Matrix>,\r\n enableDistantPicking: boolean = false\r\n ): Ray {\r\n if (enableDistantPicking) {\r\n // With world matrices having great values (like 8000000000 on 1 or more scaling or position axis),\r\n // multiplying view/projection/world and doing invert will result in loss of float precision in the matrix.\r\n // One way to fix it is to compute the ray with world at identity then transform the ray in object space.\r\n // This is slower (2 matrix inverts instead of 1) but precision is preserved.\r\n // This is hidden behind `EnableDistantPicking` flag (default is false)\r\n if (!Ray._RayDistant) {\r\n Ray._RayDistant = Ray.Zero();\r\n }\r\n\r\n Ray._RayDistant.unprojectRayToRef(x, y, viewportWidth, viewportHeight, Matrix.IdentityReadOnly, view, projection);\r\n\r\n const tm = TmpVectors.Matrix[0];\r\n world.invertToRef(tm);\r\n Ray.TransformToRef(Ray._RayDistant, tm, this);\r\n } else {\r\n this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n // Statics\r\n /**\r\n * Creates a ray with origin and direction of 0,0,0\r\n * @returns the new ray\r\n */\r\n public static Zero(): Ray {\r\n return new Ray(Vector3.Zero(), Vector3.Zero());\r\n }\r\n\r\n /**\r\n * Creates a new ray from screen space and viewport\r\n * @param x position\r\n * @param y y position\r\n * @param viewportWidth viewport width\r\n * @param viewportHeight viewport height\r\n * @param world world matrix\r\n * @param view view matrix\r\n * @param projection projection matrix\r\n * @returns new ray\r\n */\r\n public static CreateNew(\r\n x: number,\r\n y: number,\r\n viewportWidth: number,\r\n viewportHeight: number,\r\n world: DeepImmutable<Matrix>,\r\n view: DeepImmutable<Matrix>,\r\n projection: DeepImmutable<Matrix>\r\n ): Ray {\r\n const result = Ray.Zero();\r\n\r\n return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);\r\n }\r\n\r\n /**\r\n * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be\r\n * transformed to the given world matrix.\r\n * @param origin The origin point\r\n * @param end The end point\r\n * @param world a matrix to transform the ray to. Default is the identity matrix.\r\n * @returns the new ray\r\n */\r\n public static CreateNewFromTo(origin: Vector3, end: Vector3, world: DeepImmutable<Matrix> = Matrix.IdentityReadOnly): Ray {\r\n const direction = end.subtract(origin);\r\n const length = Math.sqrt(direction.x * direction.x + direction.y * direction.y + direction.z * direction.z);\r\n direction.normalize();\r\n\r\n return Ray.Transform(new Ray(origin, direction, length), world);\r\n }\r\n\r\n /**\r\n * Transforms a ray by a matrix\r\n * @param ray ray to transform\r\n * @param matrix matrix to apply\r\n * @returns the resulting new ray\r\n */\r\n public static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray {\r\n const result = new Ray(new Vector3(0, 0, 0), new Vector3(0, 0, 0));\r\n Ray.TransformToRef(ray, matrix, result);\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Transforms a ray by a matrix\r\n * @param ray ray to transform\r\n * @param matrix matrix to apply\r\n * @param result ray to store result in\r\n */\r\n public static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void {\r\n Vector3.TransformCoordinatesToRef(ray.origin, matrix, result.origin);\r\n Vector3.TransformNormalToRef(ray.direction, matrix, result.direction);\r\n result.length = ray.length;\r\n\r\n const dir = result.direction;\r\n const len = dir.length();\r\n\r\n if (!(len === 0 || len === 1)) {\r\n const num = 1.0 / len;\r\n dir.x *= num;\r\n dir.y *= num;\r\n dir.z *= num;\r\n result.length *= len;\r\n }\r\n }\r\n\r\n /**\r\n * Unproject a ray from screen space to object space\r\n * @param sourceX defines the screen space x coordinate to use\r\n * @param sourceY defines the screen space y coordinate to use\r\n * @param viewportWidth defines the current width of the viewport\r\n * @param viewportHeight defines the current height of the viewport\r\n * @param world defines the world matrix to use (can be set to Identity to go to world space)\r\n * @param view defines the view matrix to use\r\n * @param projection defines the projection matrix to use\r\n */\r\n public unprojectRayToRef(\r\n sourceX: float,\r\n sourceY: float,\r\n viewportWidth: number,\r\n viewportHeight: number,\r\n world: DeepImmutable<Matrix>,\r\n view: DeepImmutable<Matrix>,\r\n projection: DeepImmutable<Matrix>\r\n ): void {\r\n const matrix = TmpVectors.Matrix[0];\r\n world.multiplyToRef(view, matrix);\r\n matrix.multiplyToRef(projection, matrix);\r\n matrix.invert();\r\n\r\n const nearScreenSource = TmpVectors.Vector3[0];\r\n nearScreenSource.x = (sourceX / viewportWidth) * 2 - 1;\r\n nearScreenSource.y = -((sourceY / viewportHeight) * 2 - 1);\r\n nearScreenSource.z = EngineStore.LastCreatedEngine?.isNDCHalfZRange ? 0 : -1;\r\n\r\n // far Z need to be close but < to 1 or camera projection matrix with maxZ = 0 will NaN\r\n const farScreenSource = TmpVectors.Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0 - 1e-8);\r\n const nearVec3 = TmpVectors.Vector3[2];\r\n const farVec3 = TmpVectors.Vector3[3];\r\n Vector3._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);\r\n Vector3._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);\r\n\r\n this.origin.copyFrom(nearVec3);\r\n farVec3.subtractToRef(nearVec3, this.direction);\r\n this.direction.normalize();\r\n }\r\n}\r\n\r\n// Picking\r\n/**\r\n * Type used to define predicate used to select faces when a mesh intersection is detected\r\n */\r\nexport type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;\r\n\r\ndeclare module \"../scene\" {\r\n export interface Scene {\r\n /** @hidden */\r\n _tempPickingRay: Nullable<Ray>;\r\n\r\n /** @hidden */\r\n _cachedRayForTransform: Ray;\r\n\r\n /** @hidden */\r\n _pickWithRayInverseMatrix: Matrix;\r\n\r\n /** @hidden */\r\n _internalPick(\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n fastCheck?: boolean,\r\n onlyBoundingInfo?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n ): Nullable<PickingInfo>;\r\n\r\n /** @hidden */\r\n _internalMultiPick(\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n ): Nullable<PickingInfo[]>;\r\n\r\n /** @hidden */\r\n _internalPickForMesh(\r\n pickingInfo: Nullable<PickingInfo>,\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n mesh: AbstractMesh,\r\n world: Matrix,\r\n fastCheck?: boolean,\r\n onlyBoundingInfo?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate,\r\n skipBoundingInfo?: boolean\r\n ): Nullable<PickingInfo>;\r\n }\r\n}\r\n\r\nScene.prototype.createPickingRay = function (x: number, y: number, world: Nullable<Matrix>, camera: Nullable<Camera>, cameraViewSpace = false): Ray {\r\n const result = Ray.Zero();\r\n\r\n this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);\r\n\r\n return result;\r\n};\r\n\r\nScene.prototype.createPickingRayToRef = function (\r\n x: number,\r\n y: number,\r\n world: Nullable<Matrix>,\r\n result: Ray,\r\n camera: Nullable<Camera>,\r\n cameraViewSpace = false,\r\n enableDistantPicking = false\r\n): Scene {\r\n const engine = this.getEngine();\r\n\r\n if (!camera) {\r\n if (!this.activeCamera) {\r\n return this;\r\n }\r\n\r\n camera = this.activeCamera;\r\n }\r\n\r\n const cameraViewport = camera.viewport;\r\n const viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());\r\n\r\n // Moving coordinates to local viewport world\r\n x = x / engine.getHardwareScalingLevel() - viewport.x;\r\n y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);\r\n\r\n result.update(\r\n x,\r\n y,\r\n viewport.width,\r\n viewport.height,\r\n world ? world : Matrix.IdentityReadOnly,\r\n cameraViewSpace ? Matrix.IdentityReadOnly : camera.getViewMatrix(),\r\n camera.getProjectionMatrix(),\r\n enableDistantPicking\r\n );\r\n return this;\r\n};\r\n\r\nScene.prototype.createPickingRayInCameraSpace = function (x: number, y: number, camera?: Camera): Ray {\r\n const result = Ray.Zero();\r\n\r\n this.createPickingRayInCameraSpaceToRef(x, y, result, camera);\r\n\r\n return result;\r\n};\r\n\r\nScene.prototype.createPickingRayInCameraSpaceToRef = function (x: number, y: number, result: Ray, camera?: Camera): Scene {\r\n if (!PickingInfo) {\r\n return this;\r\n }\r\n\r\n const engine = this.getEngine();\r\n\r\n if (!camera) {\r\n if (!this.activeCamera) {\r\n throw new Error(\"Active camera not set\");\r\n }\r\n\r\n camera = this.activeCamera;\r\n }\r\n\r\n const cameraViewport = camera.viewport;\r\n const viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());\r\n const identity = Matrix.Identity();\r\n\r\n // Moving coordinates to local viewport world\r\n x = x / engine.getHardwareScalingLevel() - viewport.x;\r\n y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);\r\n result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());\r\n return this;\r\n};\r\n\r\nScene.prototype._internalPickForMesh = function (\r\n pickingInfo: Nullable<PickingInfo>,\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n mesh: AbstractMesh,\r\n world: Matrix,\r\n fastCheck?: boolean,\r\n onlyBoundingInfo?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate,\r\n skipBoundingInfo?: boolean\r\n) {\r\n const ray = rayFunction(world, mesh.enableDistantPicking);\r\n\r\n const result = mesh.intersects(ray, fastCheck, trianglePredicate, onlyBoundingInfo, world, skipBoundingInfo);\r\n if (!result || !result.hit) {\r\n return null;\r\n }\r\n\r\n if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {\r\n return null;\r\n }\r\n\r\n return result;\r\n};\r\n\r\nScene.prototype._internalPick = function (\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n fastCheck?: boolean,\r\n onlyBoundingInfo?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n): Nullable<PickingInfo> {\r\n if (!PickingInfo) {\r\n return null;\r\n }\r\n\r\n let pickingInfo = null;\r\n\r\n for (let meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {\r\n const mesh = this.meshes[meshIndex];\r\n\r\n if (predicate) {\r\n if (!predicate(mesh)) {\r\n continue;\r\n }\r\n } else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {\r\n continue;\r\n }\r\n\r\n const world = mesh.getWorldMatrix();\r\n\r\n if (mesh.hasThinInstances && (mesh as Mesh).thinInstanceEnablePicking) {\r\n // first check if the ray intersects the whole bounding box/sphere of the mesh\r\n const result = this._internalPickForMesh(pickingInfo, rayFunction, mesh, world, true, true, trianglePredicate);\r\n if (result) {\r\n if (onlyBoundingInfo) {\r\n // the user only asked for a bounding info check so we can return\r\n return result;\r\n }\r\n const tmpMatrix = TmpVectors.Matrix[1];\r\n const thinMatrices = (mesh as Mesh).thinInstanceGetWorldMatrices();\r\n for (let index = 0; index < thinMatrices.length; index++) {\r\n const thinMatrix = thinMatrices[index];\r\n thinMatrix.multiplyToRef(world, tmpMatrix);\r\n const result = this._internalPickForMesh(pickingInfo, rayFunction, mesh, tmpMatrix, fastCheck, onlyBoundingInfo, trianglePredicate, true);\r\n\r\n if (result) {\r\n pickingInfo = result;\r\n pickingInfo.thinInstanceIndex = index;\r\n\r\n if (fastCheck) {\r\n return pickingInfo;\r\n }\r\n }\r\n }\r\n }\r\n } else {\r\n const result = this._internalPickForMesh(pickingInfo, rayFunction, mesh, world, fastCheck, onlyBoundingInfo, trianglePredicate);\r\n\r\n if (result) {\r\n pickingInfo = result;\r\n\r\n if (fastCheck) {\r\n return pickingInfo;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return pickingInfo || new PickingInfo();\r\n};\r\n\r\nScene.prototype._internalMultiPick = function (\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n): Nullable<PickingInfo[]> {\r\n if (!PickingInfo) {\r\n return null;\r\n }\r\n const pickingInfos = new Array<PickingInfo>();\r\n\r\n for (let meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {\r\n const mesh = this.meshes[meshIndex];\r\n\r\n if (predicate) {\r\n if (!predicate(mesh)) {\r\n continue;\r\n }\r\n } else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {\r\n continue;\r\n }\r\n\r\n const world = mesh.getWorldMatrix();\r\n\r\n if (mesh.hasThinInstances && (mesh as Mesh).thinInstanceEnablePicking) {\r\n const result = this._internalPickForMesh(null, rayFunction, mesh, world, true, true, trianglePredicate);\r\n if (result) {\r\n const tmpMatrix = TmpVectors.Matrix[1];\r\n const thinMatrices = (mesh as Mesh).thinInstanceGetWorldMatrices();\r\n for (let index = 0; index < thinMatrices.length; index++) {\r\n const thinMatrix = thinMatrices[index];\r\n thinMatrix.multiplyToRef(world, tmpMatrix);\r\n const result = this._internalPickForMesh(null, rayFunction, mesh, tmpMatrix, false, false, trianglePredicate, true);\r\n\r\n if (result) {\r\n result.thinInstanceIndex = index;\r\n pickingInfos.push(result);\r\n }\r\n }\r\n }\r\n } else {\r\n const result = this._internalPickForMesh(null, rayFunction, mesh, world, false, false, trianglePredicate);\r\n\r\n if (result) {\r\n pickingInfos.push(result);\r\n }\r\n }\r\n }\r\n\r\n return pickingInfos;\r\n};\r\n\r\nScene.prototype.pickWithBoundingInfo = function (\r\n x: number,\r\n y: number,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n fastCheck?: boolean,\r\n camera?: Nullable<Camera>\r\n): Nullable<PickingInfo> {\r\n if (!PickingInfo) {\r\n return null;\r\n }\r\n const result = this._internalPick(\r\n (world) => {\r\n if (!this._tempPickingRay) {\r\n this._tempPickingRay = Ray.Zero();\r\n }\r\n\r\n this.createPickingRayToRef(x, y, world, this._tempPickingRay, camera || null);\r\n return this._tempPickingRay;\r\n },\r\n predicate,\r\n fastCheck,\r\n true\r\n );\r\n if (result) {\r\n result.ray = this.createPickingRay(x, y, Matrix.Identity(), camera || null);\r\n }\r\n return result;\r\n};\r\n\r\nScene.prototype.pick = function (\r\n x: number,\r\n y: number,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n fastCheck?: boolean,\r\n camera?: Nullable<Camera>,\r\n trianglePredicate?: TrianglePickingPredicate,\r\n _enableDistantPicking = false\r\n): Nullable<PickingInfo> {\r\n if (!PickingInfo) {\r\n return null;\r\n }\r\n const result = this._internalPick(\r\n (world, enableDistantPicking) => {\r\n if (!this._tempPickingRay) {\r\n this._tempPickingRay = Ray.Zero();\r\n }\r\n\r\n this.createPickingRayToRef(x, y, world, this._tempPickingRay, camera || null, false, enableDistantPicking);\r\n return this._tempPickingRay;\r\n },\r\n predicate,\r\n fastCheck,\r\n false,\r\n trianglePredicate\r\n );\r\n if (result) {\r\n result.ray = this.createPickingRay(x, y, Matrix.Identity(), camera || null);\r\n }\r\n return result;\r\n};\r\n\r\nScene.prototype.pickWithRay = function (\r\n ray: Ray,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n fastCheck?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n): Nullable<PickingInfo> {\r\n const result = this._internalPick(\r\n (world) => {\r\n if (!this._pickWithRayInverseMatrix) {\r\n this._pickWithRayInverseMatrix = Matrix.Identity();\r\n }\r\n world.invertToRef(this._pickWithRayInverseMatrix);\r\n\r\n if (!this._cachedRayForTransform) {\r\n this._cachedRayForTransform = Ray.Zero();\r\n }\r\n\r\n Ray.TransformToRef(ray, this._pickWithRayInverseMatrix, this._cachedRayForTransform);\r\n return this._cachedRayForTransform;\r\n },\r\n predicate,\r\n fastCheck,\r\n false,\r\n trianglePredicate\r\n );\r\n if (result) {\r\n result.ray = ray;\r\n }\r\n return result;\r\n};\r\n\r\nScene.prototype.multiPick = function (\r\n x: number,\r\n y: number,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n camera?: Camera,\r\n trianglePredicate?: TrianglePickingPredicate\r\n): Nullable<PickingInfo[]> {\r\n return this._internalMultiPick((world) => this.createPickingRay(x, y, world, camera || null), predicate, trianglePredicate);\r\n};\r\n\r\nScene.prototype.multiPickWithRay = function (ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]> {\r\n return this._internalMultiPick(\r\n (world) => {\r\n if (!this._pickWithRayInverseMatrix) {\r\n this._pickWithRayInverseMatrix = Matrix.Identity();\r\n }\r\n world.invertToRef(this._pickWithRayInverseMatrix);\r\n\r\n if (!this._cachedRayForTransform) {\r\n this._cachedRayForTransform = Ray.Zero();\r\n }\r\n\r\n Ray.TransformToRef(ray, this._pickWithRayInverseMatrix, this._cachedRayForTransform);\r\n return this._cachedRayForTransform;\r\n },\r\n predicate,\r\n trianglePredicate\r\n );\r\n};\r\n\r\nCamera.prototype.getForwardRay = function (length = 100, transform?: Matrix, origin?: Vector3): Ray {\r\n return this.getForwardRayToRef(new Ray(Vector3.Zero(), Vector3.Zero(), length), length, transform, origin);\r\n};\r\n\r\nCamera.prototype.getForwardRayToRef = function (refRay: Ray, length = 100, transform?: Matrix, origin?: Vector3): Ray {\r\n if (!transform) {\r\n transform = this.getWorldMatrix();\r\n }\r\n refRay.length = length;\r\n\r\n if (!origin) {\r\n refRay.origin.copyFrom(this.position);\r\n } else {\r\n refRay.origin.copyFrom(origin);\r\n }\r\n TmpVectors.Vector3[2].set(0, 0, this._scene.useRightHandedSystem ? -1 : 1);\r\n Vector3.TransformNormalToRef(TmpVectors.Vector3[2], transform, TmpVectors.Vector3[3]);\r\n\r\n Vector3.NormalizeToRef(TmpVectors.Vector3[3], refRay.direction);\r\n\r\n return refRay;\r\n};\r\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Nullable } from "../types";
|
|
2
2
|
import type { Effect } from "../Materials/effect";
|
|
3
|
-
import type { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "../Maths/math.like";
|
|
3
|
+
import type { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like, IQuaternionLike } from "../Maths/math.like";
|
|
4
4
|
/**
|
|
5
5
|
* Class used to store and describe the pipeline context associated with an effect
|
|
6
6
|
*/
|
|
@@ -172,6 +172,12 @@ export interface IPipelineContext {
|
|
|
172
172
|
* @param vector4 Value to be set.
|
|
173
173
|
*/
|
|
174
174
|
setVector4(uniformName: string, vector4: IVector4Like): void;
|
|
175
|
+
/**
|
|
176
|
+
* Sets a Quaternion on a uniform variable.
|
|
177
|
+
* @param uniformName Name of the variable.
|
|
178
|
+
* @param quaternion Value to be set.
|
|
179
|
+
*/
|
|
180
|
+
setQuaternion(uniformName: string, quaternion: IQuaternionLike): void;
|
|
175
181
|
/**
|
|
176
182
|
* Sets a float4 on a uniform variable.
|
|
177
183
|
* @param uniformName Name of the variable.
|