@babylonjs/core 7.6.2 → 7.7.1
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.nonFloatVertexBuffers.d.ts +12 -0
- package/Buffers/buffer.nonFloatVertexBuffers.js +81 -0
- package/Buffers/buffer.nonFloatVertexBuffers.js.map +1 -0
- package/Culling/boundingBox.d.ts +2 -2
- package/Culling/boundingBox.js +2 -2
- package/Culling/boundingBox.js.map +1 -1
- package/DeviceInput/webDeviceInputSystem.js +8 -2
- package/DeviceInput/webDeviceInputSystem.js.map +1 -1
- package/Engines/IPipelineContext.d.ts +7 -0
- package/Engines/IPipelineContext.js.map +1 -1
- package/Engines/Native/nativePipelineContext.d.ts +6 -1
- package/Engines/Native/nativePipelineContext.js +3 -1
- package/Engines/Native/nativePipelineContext.js.map +1 -1
- package/Engines/Native/nativeShaderProcessingContext.d.ts +13 -0
- package/Engines/Native/nativeShaderProcessingContext.js +11 -0
- package/Engines/Native/nativeShaderProcessingContext.js.map +1 -0
- package/Engines/Native/nativeShaderProcessors.d.ts +15 -0
- package/Engines/Native/nativeShaderProcessors.js +75 -0
- package/Engines/Native/nativeShaderProcessors.js.map +1 -0
- package/Engines/Processors/shaderProcessingOptions.d.ts +3 -0
- package/Engines/Processors/shaderProcessingOptions.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.d.ts +0 -2
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js +4 -59
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessingContext.d.ts +3 -0
- package/Engines/WebGPU/webgpuShaderProcessingContext.js +1 -0
- package/Engines/WebGPU/webgpuShaderProcessingContext.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessor.d.ts +0 -4
- package/Engines/WebGPU/webgpuShaderProcessor.js +0 -26
- package/Engines/WebGPU/webgpuShaderProcessor.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js +4 -3
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +7 -7
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engine.d.ts +1 -1
- package/Engines/engineFeatures.d.ts +2 -0
- package/Engines/engineFeatures.js.map +1 -1
- package/Engines/nativeEngine.d.ts +7 -1
- package/Engines/nativeEngine.js +26 -8
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.d.ts +4 -0
- package/Engines/nullEngine.js +4 -0
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.js +1 -0
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +1 -0
- package/Engines/webgpuEngine.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +4 -2
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js +8 -6
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +15 -12
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
- package/Materials/Node/Blocks/voronoiNoiseBlock.js +17 -21
- package/Materials/Node/Blocks/voronoiNoiseBlock.js.map +1 -1
- package/Materials/effect.d.ts +2 -2
- package/Materials/effect.js +2 -2
- package/Materials/effect.js.map +1 -1
- package/Meshes/mesh.js +6 -1
- package/Meshes/mesh.js.map +1 -1
- package/Misc/codeStringParsingTools.d.ts +11 -0
- package/Misc/codeStringParsingTools.js +31 -0
- package/Misc/codeStringParsingTools.js.map +1 -1
- package/Misc/pressureObserverWrapper.js +1 -1
- package/Misc/pressureObserverWrapper.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +3 -3
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Nullable } from "../types";
|
|
2
|
+
import type { Effect } from "../Materials/effect";
|
|
3
|
+
import { VertexBuffer } from "../Meshes/buffer";
|
|
4
|
+
/**
|
|
5
|
+
* Checks whether some vertex buffers that should be of type float are of a different type (int, byte...).
|
|
6
|
+
* If so, trigger a shader recompilation to give the shader processor the opportunity to update the code accordingly.
|
|
7
|
+
* @param vertexBuffers List of vertex buffers to check
|
|
8
|
+
* @param effect The effect (shaders) that should be recompiled if needed
|
|
9
|
+
*/
|
|
10
|
+
export declare function checkNonFloatVertexBuffers(vertexBuffers: {
|
|
11
|
+
[key: string]: Nullable<VertexBuffer>;
|
|
12
|
+
}, effect: Effect): void;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { VertexBuffer } from "../Meshes/buffer.js";
|
|
2
|
+
const vertexBufferKindForNonFloatProcessing = {
|
|
3
|
+
[VertexBuffer.PositionKind]: true,
|
|
4
|
+
[VertexBuffer.NormalKind]: true,
|
|
5
|
+
[VertexBuffer.TangentKind]: true,
|
|
6
|
+
[VertexBuffer.UVKind]: true,
|
|
7
|
+
[VertexBuffer.UV2Kind]: true,
|
|
8
|
+
[VertexBuffer.UV3Kind]: true,
|
|
9
|
+
[VertexBuffer.UV4Kind]: true,
|
|
10
|
+
[VertexBuffer.UV5Kind]: true,
|
|
11
|
+
[VertexBuffer.UV6Kind]: true,
|
|
12
|
+
[VertexBuffer.ColorKind]: true,
|
|
13
|
+
[VertexBuffer.ColorInstanceKind]: true,
|
|
14
|
+
[VertexBuffer.MatricesIndicesKind]: true,
|
|
15
|
+
[VertexBuffer.MatricesWeightsKind]: true,
|
|
16
|
+
[VertexBuffer.MatricesIndicesExtraKind]: true,
|
|
17
|
+
[VertexBuffer.MatricesWeightsExtraKind]: true,
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Indicates if the type is a signed or unsigned type
|
|
21
|
+
* @param type Type to check
|
|
22
|
+
* @returns True if it is a signed type
|
|
23
|
+
*/
|
|
24
|
+
function isSignedType(type) {
|
|
25
|
+
switch (type) {
|
|
26
|
+
case VertexBuffer.BYTE:
|
|
27
|
+
case VertexBuffer.SHORT:
|
|
28
|
+
case VertexBuffer.INT:
|
|
29
|
+
case VertexBuffer.FLOAT:
|
|
30
|
+
return true;
|
|
31
|
+
case VertexBuffer.UNSIGNED_BYTE:
|
|
32
|
+
case VertexBuffer.UNSIGNED_SHORT:
|
|
33
|
+
case VertexBuffer.UNSIGNED_INT:
|
|
34
|
+
return false;
|
|
35
|
+
default:
|
|
36
|
+
throw new Error(`Invalid type '${type}'`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Checks whether some vertex buffers that should be of type float are of a different type (int, byte...).
|
|
41
|
+
* If so, trigger a shader recompilation to give the shader processor the opportunity to update the code accordingly.
|
|
42
|
+
* @param vertexBuffers List of vertex buffers to check
|
|
43
|
+
* @param effect The effect (shaders) that should be recompiled if needed
|
|
44
|
+
*/
|
|
45
|
+
export function checkNonFloatVertexBuffers(vertexBuffers, effect) {
|
|
46
|
+
const engine = effect.getEngine();
|
|
47
|
+
const pipelineContext = effect._pipelineContext;
|
|
48
|
+
if (!pipelineContext?.vertexBufferKindToType) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
let shaderProcessingContext = null;
|
|
52
|
+
for (const kind in vertexBuffers) {
|
|
53
|
+
const currentVertexBuffer = vertexBuffers[kind];
|
|
54
|
+
if (!currentVertexBuffer || !vertexBufferKindForNonFloatProcessing[kind]) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const currentVertexBufferType = currentVertexBuffer.normalized ? VertexBuffer.FLOAT : currentVertexBuffer.type;
|
|
58
|
+
const vertexBufferType = pipelineContext.vertexBufferKindToType[kind];
|
|
59
|
+
if ((currentVertexBufferType !== VertexBuffer.FLOAT && vertexBufferType === undefined) ||
|
|
60
|
+
(vertexBufferType !== undefined && vertexBufferType !== currentVertexBufferType)) {
|
|
61
|
+
if (!shaderProcessingContext) {
|
|
62
|
+
shaderProcessingContext = engine._getShaderProcessingContext(effect.shaderLanguage);
|
|
63
|
+
}
|
|
64
|
+
pipelineContext.vertexBufferKindToType[kind] = currentVertexBufferType;
|
|
65
|
+
if (currentVertexBufferType !== VertexBuffer.FLOAT) {
|
|
66
|
+
shaderProcessingContext.vertexBufferKindToNumberOfComponents[kind] = VertexBuffer.DeduceStride(kind);
|
|
67
|
+
if (isSignedType(currentVertexBufferType)) {
|
|
68
|
+
shaderProcessingContext.vertexBufferKindToNumberOfComponents[kind] *= -1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (shaderProcessingContext) {
|
|
74
|
+
// We temporarily disable parallel compilation of shaders because we want new shaders to be compiled after the _processShaderCode call, so that they are in effect for the rest of the frame.
|
|
75
|
+
const parallelShaderCompile = engine._caps.parallelShaderCompile;
|
|
76
|
+
engine._caps.parallelShaderCompile = undefined;
|
|
77
|
+
effect._processShaderCode(null, engine._features._checkNonFloatVertexBuffersDontRecreatePipelineContext, shaderProcessingContext);
|
|
78
|
+
engine._caps.parallelShaderCompile = parallelShaderCompile;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=buffer.nonFloatVertexBuffers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer.nonFloatVertexBuffers.js","sourceRoot":"","sources":["../../../../dev/core/src/Buffers/buffer.nonFloatVertexBuffers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,qCAAqC,GAAgC;IACvE,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,IAAI;IACjC,CAAC,YAAY,CAAC,UAAU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AAM,qBAAqB,GAAG,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC;QACjE,MAAM,CAAC,KAAK,CAAC,qBAAqB,GAAG,SAAS,CAAC;QAE/C,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,sDAAsD,EAAE,uBAAuB,CAAC,CAAC;QAElI,MAAM,CAAC,KAAK,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;KAC9D;AACL,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { ShaderProcessingContext } from \"../Engines/Processors/shaderProcessingOptions\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { VertexBuffer } from \"../Meshes/buffer\";\r\n\r\nconst vertexBufferKindForNonFloatProcessing: { [kind: string]: boolean } = {\r\n [VertexBuffer.PositionKind]: true,\r\n [VertexBuffer.NormalKind]: true,\r\n [VertexBuffer.TangentKind]: true,\r\n [VertexBuffer.UVKind]: true,\r\n [VertexBuffer.UV2Kind]: true,\r\n [VertexBuffer.UV3Kind]: true,\r\n [VertexBuffer.UV4Kind]: true,\r\n [VertexBuffer.UV5Kind]: true,\r\n [VertexBuffer.UV6Kind]: true,\r\n [VertexBuffer.ColorKind]: true,\r\n [VertexBuffer.ColorInstanceKind]: true,\r\n [VertexBuffer.MatricesIndicesKind]: true,\r\n [VertexBuffer.MatricesWeightsKind]: true,\r\n [VertexBuffer.MatricesIndicesExtraKind]: true,\r\n [VertexBuffer.MatricesWeightsExtraKind]: true,\r\n};\r\n\r\n/**\r\n * Indicates if the type is a signed or unsigned type\r\n * @param type Type to check\r\n * @returns True if it is a signed type\r\n */\r\nfunction isSignedType(type: number): boolean {\r\n switch (type) {\r\n case VertexBuffer.BYTE:\r\n case VertexBuffer.SHORT:\r\n case VertexBuffer.INT:\r\n case VertexBuffer.FLOAT:\r\n return true;\r\n case VertexBuffer.UNSIGNED_BYTE:\r\n case VertexBuffer.UNSIGNED_SHORT:\r\n case VertexBuffer.UNSIGNED_INT:\r\n return false;\r\n default:\r\n throw new Error(`Invalid type '${type}'`);\r\n }\r\n}\r\n\r\n/**\r\n * Checks whether some vertex buffers that should be of type float are of a different type (int, byte...).\r\n * If so, trigger a shader recompilation to give the shader processor the opportunity to update the code accordingly.\r\n * @param vertexBuffers List of vertex buffers to check\r\n * @param effect The effect (shaders) that should be recompiled if needed\r\n */\r\nexport function checkNonFloatVertexBuffers(vertexBuffers: { [key: string]: Nullable<VertexBuffer> }, effect: Effect): void {\r\n const engine = effect.getEngine();\r\n const pipelineContext = effect._pipelineContext;\r\n\r\n if (!pipelineContext?.vertexBufferKindToType) {\r\n return;\r\n }\r\n\r\n let shaderProcessingContext: Nullable<ShaderProcessingContext> = null;\r\n\r\n for (const kind in vertexBuffers) {\r\n const currentVertexBuffer = vertexBuffers[kind];\r\n\r\n if (!currentVertexBuffer || !vertexBufferKindForNonFloatProcessing[kind]) {\r\n continue;\r\n }\r\n\r\n const currentVertexBufferType = currentVertexBuffer.normalized ? VertexBuffer.FLOAT : currentVertexBuffer.type;\r\n const vertexBufferType = pipelineContext.vertexBufferKindToType[kind];\r\n\r\n if (\r\n (currentVertexBufferType !== VertexBuffer.FLOAT && vertexBufferType === undefined) ||\r\n (vertexBufferType !== undefined && vertexBufferType !== currentVertexBufferType)\r\n ) {\r\n if (!shaderProcessingContext) {\r\n shaderProcessingContext = engine._getShaderProcessingContext(effect.shaderLanguage)!;\r\n }\r\n pipelineContext.vertexBufferKindToType[kind] = currentVertexBufferType;\r\n if (currentVertexBufferType !== VertexBuffer.FLOAT) {\r\n shaderProcessingContext.vertexBufferKindToNumberOfComponents![kind] = VertexBuffer.DeduceStride(kind);\r\n if (isSignedType(currentVertexBufferType)) {\r\n shaderProcessingContext.vertexBufferKindToNumberOfComponents![kind] *= -1;\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (shaderProcessingContext) {\r\n // We temporarily disable parallel compilation of shaders because we want new shaders to be compiled after the _processShaderCode call, so that they are in effect for the rest of the frame.\r\n const parallelShaderCompile = engine._caps.parallelShaderCompile;\r\n engine._caps.parallelShaderCompile = undefined;\r\n\r\n effect._processShaderCode(null, engine._features._checkNonFloatVertexBuffersDontRecreatePipelineContext, shaderProcessingContext);\r\n\r\n engine._caps.parallelShaderCompile = parallelShaderCompile;\r\n }\r\n}\r\n"]}
|
package/Culling/boundingBox.d.ts
CHANGED
|
@@ -21,11 +21,11 @@ export declare class BoundingBox implements ICullable {
|
|
|
21
21
|
*/
|
|
22
22
|
readonly centerWorld: Vector3;
|
|
23
23
|
/**
|
|
24
|
-
* Gets the
|
|
24
|
+
* Gets half the size of the extent in local space. Multiply by 2 to obtain the full size of the box!
|
|
25
25
|
*/
|
|
26
26
|
readonly extendSize: Vector3;
|
|
27
27
|
/**
|
|
28
|
-
* Gets the
|
|
28
|
+
* Gets half the size of the extent in world space. Multiply by 2 to obtain the full size of the box!
|
|
29
29
|
*/
|
|
30
30
|
readonly extendSizeWorld: Vector3;
|
|
31
31
|
/**
|
package/Culling/boundingBox.js
CHANGED
|
@@ -25,11 +25,11 @@ export class BoundingBox {
|
|
|
25
25
|
*/
|
|
26
26
|
this.centerWorld = Vector3.Zero();
|
|
27
27
|
/**
|
|
28
|
-
* Gets the
|
|
28
|
+
* Gets half the size of the extent in local space. Multiply by 2 to obtain the full size of the box!
|
|
29
29
|
*/
|
|
30
30
|
this.extendSize = Vector3.Zero();
|
|
31
31
|
/**
|
|
32
|
-
* Gets the
|
|
32
|
+
* Gets half the size of the extent in world space. Multiply by 2 to obtain the full size of the box!
|
|
33
33
|
*/
|
|
34
34
|
this.extendSizeWorld = Vector3.Zero();
|
|
35
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boundingBox.js","sourceRoot":"","sources":["../../../../dev/core/src/Culling/boundingBox.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB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Aa,CAAC,CAAC,CAAC,CAAC;YACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;gBACxB,IAAI,YAAY,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;oBACpD,OAAO,KAAK,CAAC;iBAChB;aACJ;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,WAAW,CAAC,eAA8C,EAAE,aAA0C;QAChH,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;YACxB,IAAI,cAAc,GAAG,IAAI,CAAC;YAC1B,MAAM,YAAY,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;YACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;gBACxB,IAAI,YAAY,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE;oBACrD,cAAc,GAAG,KAAK,CAAC;oBACvB,MAAM;iBACT;aACJ;YACD,IAAI,cAAc,EAAE;gBAChB,OAAO,KAAK,CAAC;aAChB;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;;AA9SuB,uBAAW,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,AAAzC,CAA0C","sourcesContent":["import type { DeepImmutable, Nullable } from \"../types\";\r\nimport { ArrayTools } from \"../Misc/arrayTools\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport type { BoundingSphere } from \"../Culling/boundingSphere\";\r\n\r\nimport type { ICullable } from \"./boundingInfo\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\n\r\nimport type { DrawWrapper } from \"../Materials/drawWrapper\";\r\n\r\n/**\r\n * Class used to store bounding box information\r\n */\r\nexport class BoundingBox implements ICullable {\r\n /**\r\n * Gets the 8 vectors representing the bounding box in local space\r\n */\r\n public readonly vectors: Vector3[] = ArrayTools.BuildArray(8, Vector3.Zero);\r\n /**\r\n * Gets the center of the bounding box in local space\r\n */\r\n public readonly center: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the center of the bounding box in world space\r\n */\r\n public readonly centerWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the extend size in local space\r\n */\r\n public readonly extendSize: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the extend size in world space\r\n */\r\n public readonly extendSizeWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the OBB (object bounding box) directions\r\n */\r\n public readonly directions: Vector3[] = ArrayTools.BuildArray(3, Vector3.Zero);\r\n /**\r\n * Gets the 8 vectors representing the bounding box in world space\r\n */\r\n public readonly vectorsWorld: Vector3[] = ArrayTools.BuildArray(8, Vector3.Zero);\r\n /**\r\n * Gets the minimum vector in world space\r\n */\r\n public readonly minimumWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the maximum vector in world space\r\n */\r\n public readonly maximumWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the minimum vector in local space\r\n */\r\n public readonly minimum: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the maximum vector in local space\r\n */\r\n public readonly maximum: Vector3 = Vector3.Zero();\r\n\r\n private _worldMatrix: DeepImmutable<Matrix>;\r\n private static readonly _TmpVector3 = ArrayTools.BuildArray(3, Vector3.Zero);\r\n\r\n /**\r\n * @internal\r\n */\r\n public _tag: number;\r\n\r\n /** @internal */\r\n public _drawWrapperFront: Nullable<DrawWrapper> = null;\r\n /** @internal */\r\n public _drawWrapperBack: Nullable<DrawWrapper> = null;\r\n\r\n /**\r\n * Creates a new bounding box\r\n * @param min defines the minimum vector (in local space)\r\n * @param max defines the maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.reConstruct(min, max, worldMatrix);\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Recreates the entire bounding box from scratch as if we call the constructor in place\r\n * @param min defines the new minimum vector (in local space)\r\n * @param max defines the new maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n public reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n const vectors = this.vectors;\r\n\r\n this.minimum.copyFromFloats(minX, minY, minZ);\r\n this.maximum.copyFromFloats(maxX, maxY, maxZ);\r\n vectors[0].copyFromFloats(minX, minY, minZ);\r\n vectors[1].copyFromFloats(maxX, maxY, maxZ);\r\n vectors[2].copyFromFloats(maxX, minY, minZ);\r\n vectors[3].copyFromFloats(minX, maxY, minZ);\r\n vectors[4].copyFromFloats(minX, minY, maxZ);\r\n vectors[5].copyFromFloats(maxX, maxY, minZ);\r\n vectors[6].copyFromFloats(minX, maxY, maxZ);\r\n vectors[7].copyFromFloats(maxX, minY, maxZ);\r\n\r\n // OBB\r\n max.addToRef(min, this.center).scaleInPlace(0.5);\r\n max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);\r\n\r\n this._worldMatrix = worldMatrix || Matrix.IdentityReadOnly;\r\n\r\n this._update(this._worldMatrix);\r\n }\r\n\r\n /**\r\n * Scale the current bounding box by applying a scale factor\r\n * @param factor defines the scale factor to apply\r\n * @returns the current bounding box\r\n */\r\n public scale(factor: number): BoundingBox {\r\n const tmpVectors = BoundingBox._TmpVector3;\r\n const diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);\r\n const len = diff.length();\r\n diff.normalizeFromLength(len);\r\n const distance = len * factor;\r\n const newRadius = diff.scaleInPlace(distance * 0.5);\r\n\r\n const min = this.center.subtractToRef(newRadius, tmpVectors[1]);\r\n const max = this.center.addToRef(newRadius, tmpVectors[2]);\r\n\r\n this.reConstruct(min, max, this._worldMatrix);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets the world matrix of the bounding box\r\n * @returns a matrix\r\n */\r\n public getWorldMatrix(): DeepImmutable<Matrix> {\r\n return this._worldMatrix;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _update(world: DeepImmutable<Matrix>): void {\r\n const minWorld = this.minimumWorld;\r\n const maxWorld = this.maximumWorld;\r\n const directions = this.directions;\r\n const vectorsWorld = this.vectorsWorld;\r\n const vectors = this.vectors;\r\n\r\n if (!world.isIdentity()) {\r\n minWorld.setAll(Number.MAX_VALUE);\r\n maxWorld.setAll(-Number.MAX_VALUE);\r\n\r\n for (let index = 0; index < 8; ++index) {\r\n const v = vectorsWorld[index];\r\n Vector3.TransformCoordinatesToRef(vectors[index], world, v);\r\n minWorld.minimizeInPlace(v);\r\n maxWorld.maximizeInPlace(v);\r\n }\r\n\r\n // Extend\r\n maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);\r\n maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);\r\n } else {\r\n minWorld.copyFrom(this.minimum);\r\n maxWorld.copyFrom(this.maximum);\r\n for (let index = 0; index < 8; ++index) {\r\n vectorsWorld[index].copyFrom(vectors[index]);\r\n }\r\n\r\n // Extend\r\n this.extendSizeWorld.copyFrom(this.extendSize);\r\n this.centerWorld.copyFrom(this.center);\r\n }\r\n\r\n Vector3.FromArrayToRef(world.m, 0, directions[0]);\r\n Vector3.FromArrayToRef(world.m, 4, directions[1]);\r\n Vector3.FromArrayToRef(world.m, 8, directions[2]);\r\n\r\n this._worldMatrix = world;\r\n }\r\n\r\n /**\r\n * Tests if the bounding box is intersecting the frustum planes\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an intersection\r\n */\r\n public isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);\r\n }\r\n\r\n /**\r\n * Tests if the bounding box is entirely inside the frustum planes\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an inclusion\r\n */\r\n public isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);\r\n }\r\n\r\n /**\r\n * Tests if a point is inside the bounding box\r\n * @param point defines the point to test\r\n * @returns true if the point is inside the bounding box\r\n */\r\n public intersectsPoint(point: DeepImmutable<Vector3>): boolean {\r\n const min = this.minimumWorld;\r\n const max = this.maximumWorld;\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n const pointX = point.x,\r\n pointY = point.y,\r\n pointZ = point.z;\r\n const delta = -Epsilon;\r\n\r\n if (maxX - pointX < delta || delta > pointX - minX) {\r\n return false;\r\n }\r\n\r\n if (maxY - pointY < delta || delta > pointY - minY) {\r\n return false;\r\n }\r\n\r\n if (maxZ - pointZ < delta || delta > pointZ - minZ) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if the bounding box intersects with a bounding sphere\r\n * @param sphere defines the sphere to test\r\n * @returns true if there is an intersection\r\n */\r\n public intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean {\r\n return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);\r\n }\r\n\r\n /**\r\n * Tests if the bounding box intersects with a box defined by a min and max vectors\r\n * @param min defines the min vector to use\r\n * @param max defines the max vector to use\r\n * @returns true if there is an intersection\r\n */\r\n public intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean {\r\n const myMin = this.minimumWorld;\r\n const myMax = this.maximumWorld;\r\n const myMinX = myMin.x,\r\n myMinY = myMin.y,\r\n myMinZ = myMin.z,\r\n myMaxX = myMax.x,\r\n myMaxY = myMax.y,\r\n myMaxZ = myMax.z;\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n if (myMaxX < minX || myMinX > maxX) {\r\n return false;\r\n }\r\n\r\n if (myMaxY < minY || myMinY > maxY) {\r\n return false;\r\n }\r\n\r\n if (myMaxZ < minZ || myMinZ > maxZ) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Disposes the resources of the class\r\n */\r\n public dispose(): void {\r\n this._drawWrapperFront?.dispose();\r\n this._drawWrapperBack?.dispose();\r\n }\r\n\r\n // Statics\r\n\r\n /**\r\n * Tests if two bounding boxes are intersections\r\n * @param box0 defines the first box to test\r\n * @param box1 defines the second box to test\r\n * @returns true if there is an intersection\r\n */\r\n public static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean {\r\n return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defines by a min/max vectors intersects a sphere\r\n * @param minPoint defines the minimum vector of the bounding box\r\n * @param maxPoint defines the maximum vector of the bounding box\r\n * @param sphereCenter defines the sphere center\r\n * @param sphereRadius defines the sphere radius\r\n * @returns true if there is an intersection\r\n */\r\n public static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean {\r\n const vector = BoundingBox._TmpVector3[0];\r\n Vector3.ClampToRef(sphereCenter, minPoint, maxPoint, vector);\r\n const num = Vector3.DistanceSquared(sphereCenter, vector);\r\n return num <= sphereRadius * sphereRadius;\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes\r\n * @param boundingVectors defines an array of 8 vectors representing a bounding box\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an inclusion\r\n */\r\n public static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n for (let p = 0; p < 6; ++p) {\r\n const frustumPlane = frustumPlanes[p];\r\n for (let i = 0; i < 8; ++i) {\r\n if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defined with 8 vectors intersects frustum planes\r\n * @param boundingVectors defines an array of 8 vectors representing a bounding box\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an intersection\r\n */\r\n public static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n for (let p = 0; p < 6; ++p) {\r\n let canReturnFalse = true;\r\n const frustumPlane = frustumPlanes[p];\r\n for (let i = 0; i < 8; ++i) {\r\n if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {\r\n canReturnFalse = false;\r\n break;\r\n }\r\n }\r\n if (canReturnFalse) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"boundingBox.js","sourceRoot":"","sources":["../../../../dev/core/src/Culling/boundingBox.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAIvD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAKlD;;GAEG;AACH,MAAM,OAAO,WAAW;IA2DpB;;;;;OAKG;IACH,YAAY,GAA2B,EAAE,GAA2B,EAAE,WAAmC;QAhEzG;;WAEG;QACa,YAAO,GAAc,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAC5E;;WAEG;QACa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IAED;;;;;OAKG;IACI,MAAM,CAAC,WAAW,CAAC,eAA8C,EAAE,aAA0C;QAChH,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;YACxB,IAAI,cAAc,GAAG,IAAI,CAAC;YAC1B,MAAM,YAAY,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;YACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;gBACxB,IAAI,YAAY,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE;oBACrD,cAAc,GAAG,KAAK,CAAC;oBACvB,MAAM;iBACT;aACJ;YACD,IAAI,cAAc,EAAE;gBAChB,OAAO,KAAK,CAAC;aAChB;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;;AA9SuB,uBAAW,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,AAAzC,CAA0C","sourcesContent":["import type { DeepImmutable, Nullable } from \"../types\";\r\nimport { ArrayTools } from \"../Misc/arrayTools\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport type { BoundingSphere } from \"../Culling/boundingSphere\";\r\n\r\nimport type { ICullable } from \"./boundingInfo\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\n\r\nimport type { DrawWrapper } from \"../Materials/drawWrapper\";\r\n\r\n/**\r\n * Class used to store bounding box information\r\n */\r\nexport class BoundingBox implements ICullable {\r\n /**\r\n * Gets the 8 vectors representing the bounding box in local space\r\n */\r\n public readonly vectors: Vector3[] = ArrayTools.BuildArray(8, Vector3.Zero);\r\n /**\r\n * Gets the center of the bounding box in local space\r\n */\r\n public readonly center: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the center of the bounding box in world space\r\n */\r\n public readonly centerWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets half the size of the extent in local space. Multiply by 2 to obtain the full size of the box!\r\n */\r\n public readonly extendSize: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets half the size of the extent in world space. Multiply by 2 to obtain the full size of the box!\r\n */\r\n public readonly extendSizeWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the OBB (object bounding box) directions\r\n */\r\n public readonly directions: Vector3[] = ArrayTools.BuildArray(3, Vector3.Zero);\r\n /**\r\n * Gets the 8 vectors representing the bounding box in world space\r\n */\r\n public readonly vectorsWorld: Vector3[] = ArrayTools.BuildArray(8, Vector3.Zero);\r\n /**\r\n * Gets the minimum vector in world space\r\n */\r\n public readonly minimumWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the maximum vector in world space\r\n */\r\n public readonly maximumWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the minimum vector in local space\r\n */\r\n public readonly minimum: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the maximum vector in local space\r\n */\r\n public readonly maximum: Vector3 = Vector3.Zero();\r\n\r\n private _worldMatrix: DeepImmutable<Matrix>;\r\n private static readonly _TmpVector3 = ArrayTools.BuildArray(3, Vector3.Zero);\r\n\r\n /**\r\n * @internal\r\n */\r\n public _tag: number;\r\n\r\n /** @internal */\r\n public _drawWrapperFront: Nullable<DrawWrapper> = null;\r\n /** @internal */\r\n public _drawWrapperBack: Nullable<DrawWrapper> = null;\r\n\r\n /**\r\n * Creates a new bounding box\r\n * @param min defines the minimum vector (in local space)\r\n * @param max defines the maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.reConstruct(min, max, worldMatrix);\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Recreates the entire bounding box from scratch as if we call the constructor in place\r\n * @param min defines the new minimum vector (in local space)\r\n * @param max defines the new maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n public reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n const vectors = this.vectors;\r\n\r\n this.minimum.copyFromFloats(minX, minY, minZ);\r\n this.maximum.copyFromFloats(maxX, maxY, maxZ);\r\n vectors[0].copyFromFloats(minX, minY, minZ);\r\n vectors[1].copyFromFloats(maxX, maxY, maxZ);\r\n vectors[2].copyFromFloats(maxX, minY, minZ);\r\n vectors[3].copyFromFloats(minX, maxY, minZ);\r\n vectors[4].copyFromFloats(minX, minY, maxZ);\r\n vectors[5].copyFromFloats(maxX, maxY, minZ);\r\n vectors[6].copyFromFloats(minX, maxY, maxZ);\r\n vectors[7].copyFromFloats(maxX, minY, maxZ);\r\n\r\n // OBB\r\n max.addToRef(min, this.center).scaleInPlace(0.5);\r\n max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);\r\n\r\n this._worldMatrix = worldMatrix || Matrix.IdentityReadOnly;\r\n\r\n this._update(this._worldMatrix);\r\n }\r\n\r\n /**\r\n * Scale the current bounding box by applying a scale factor\r\n * @param factor defines the scale factor to apply\r\n * @returns the current bounding box\r\n */\r\n public scale(factor: number): BoundingBox {\r\n const tmpVectors = BoundingBox._TmpVector3;\r\n const diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);\r\n const len = diff.length();\r\n diff.normalizeFromLength(len);\r\n const distance = len * factor;\r\n const newRadius = diff.scaleInPlace(distance * 0.5);\r\n\r\n const min = this.center.subtractToRef(newRadius, tmpVectors[1]);\r\n const max = this.center.addToRef(newRadius, tmpVectors[2]);\r\n\r\n this.reConstruct(min, max, this._worldMatrix);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets the world matrix of the bounding box\r\n * @returns a matrix\r\n */\r\n public getWorldMatrix(): DeepImmutable<Matrix> {\r\n return this._worldMatrix;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _update(world: DeepImmutable<Matrix>): void {\r\n const minWorld = this.minimumWorld;\r\n const maxWorld = this.maximumWorld;\r\n const directions = this.directions;\r\n const vectorsWorld = this.vectorsWorld;\r\n const vectors = this.vectors;\r\n\r\n if (!world.isIdentity()) {\r\n minWorld.setAll(Number.MAX_VALUE);\r\n maxWorld.setAll(-Number.MAX_VALUE);\r\n\r\n for (let index = 0; index < 8; ++index) {\r\n const v = vectorsWorld[index];\r\n Vector3.TransformCoordinatesToRef(vectors[index], world, v);\r\n minWorld.minimizeInPlace(v);\r\n maxWorld.maximizeInPlace(v);\r\n }\r\n\r\n // Extend\r\n maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);\r\n maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);\r\n } else {\r\n minWorld.copyFrom(this.minimum);\r\n maxWorld.copyFrom(this.maximum);\r\n for (let index = 0; index < 8; ++index) {\r\n vectorsWorld[index].copyFrom(vectors[index]);\r\n }\r\n\r\n // Extend\r\n this.extendSizeWorld.copyFrom(this.extendSize);\r\n this.centerWorld.copyFrom(this.center);\r\n }\r\n\r\n Vector3.FromArrayToRef(world.m, 0, directions[0]);\r\n Vector3.FromArrayToRef(world.m, 4, directions[1]);\r\n Vector3.FromArrayToRef(world.m, 8, directions[2]);\r\n\r\n this._worldMatrix = world;\r\n }\r\n\r\n /**\r\n * Tests if the bounding box is intersecting the frustum planes\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an intersection\r\n */\r\n public isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);\r\n }\r\n\r\n /**\r\n * Tests if the bounding box is entirely inside the frustum planes\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an inclusion\r\n */\r\n public isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);\r\n }\r\n\r\n /**\r\n * Tests if a point is inside the bounding box\r\n * @param point defines the point to test\r\n * @returns true if the point is inside the bounding box\r\n */\r\n public intersectsPoint(point: DeepImmutable<Vector3>): boolean {\r\n const min = this.minimumWorld;\r\n const max = this.maximumWorld;\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n const pointX = point.x,\r\n pointY = point.y,\r\n pointZ = point.z;\r\n const delta = -Epsilon;\r\n\r\n if (maxX - pointX < delta || delta > pointX - minX) {\r\n return false;\r\n }\r\n\r\n if (maxY - pointY < delta || delta > pointY - minY) {\r\n return false;\r\n }\r\n\r\n if (maxZ - pointZ < delta || delta > pointZ - minZ) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if the bounding box intersects with a bounding sphere\r\n * @param sphere defines the sphere to test\r\n * @returns true if there is an intersection\r\n */\r\n public intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean {\r\n return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);\r\n }\r\n\r\n /**\r\n * Tests if the bounding box intersects with a box defined by a min and max vectors\r\n * @param min defines the min vector to use\r\n * @param max defines the max vector to use\r\n * @returns true if there is an intersection\r\n */\r\n public intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean {\r\n const myMin = this.minimumWorld;\r\n const myMax = this.maximumWorld;\r\n const myMinX = myMin.x,\r\n myMinY = myMin.y,\r\n myMinZ = myMin.z,\r\n myMaxX = myMax.x,\r\n myMaxY = myMax.y,\r\n myMaxZ = myMax.z;\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n if (myMaxX < minX || myMinX > maxX) {\r\n return false;\r\n }\r\n\r\n if (myMaxY < minY || myMinY > maxY) {\r\n return false;\r\n }\r\n\r\n if (myMaxZ < minZ || myMinZ > maxZ) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Disposes the resources of the class\r\n */\r\n public dispose(): void {\r\n this._drawWrapperFront?.dispose();\r\n this._drawWrapperBack?.dispose();\r\n }\r\n\r\n // Statics\r\n\r\n /**\r\n * Tests if two bounding boxes are intersections\r\n * @param box0 defines the first box to test\r\n * @param box1 defines the second box to test\r\n * @returns true if there is an intersection\r\n */\r\n public static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean {\r\n return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defines by a min/max vectors intersects a sphere\r\n * @param minPoint defines the minimum vector of the bounding box\r\n * @param maxPoint defines the maximum vector of the bounding box\r\n * @param sphereCenter defines the sphere center\r\n * @param sphereRadius defines the sphere radius\r\n * @returns true if there is an intersection\r\n */\r\n public static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean {\r\n const vector = BoundingBox._TmpVector3[0];\r\n Vector3.ClampToRef(sphereCenter, minPoint, maxPoint, vector);\r\n const num = Vector3.DistanceSquared(sphereCenter, vector);\r\n return num <= sphereRadius * sphereRadius;\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes\r\n * @param boundingVectors defines an array of 8 vectors representing a bounding box\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an inclusion\r\n */\r\n public static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n for (let p = 0; p < 6; ++p) {\r\n const frustumPlane = frustumPlanes[p];\r\n for (let i = 0; i < 8; ++i) {\r\n if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defined with 8 vectors intersects frustum planes\r\n * @param boundingVectors defines an array of 8 vectors representing a bounding box\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an intersection\r\n */\r\n public static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n for (let p = 0; p < 6; ++p) {\r\n let canReturnFalse = true;\r\n const frustumPlane = frustumPlanes[p];\r\n for (let i = 0; i < 8; ++i) {\r\n if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {\r\n canReturnFalse = false;\r\n break;\r\n }\r\n }\r\n if (canReturnFalse) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n}\r\n"]}
|
|
@@ -341,7 +341,7 @@ export class WebDeviceInputSystem {
|
|
|
341
341
|
this._pointerMoveEvent = (evt) => {
|
|
342
342
|
const deviceType = this._getPointerType(evt);
|
|
343
343
|
let deviceSlot = deviceType === DeviceType.Mouse ? 0 : this._activeTouchIds.indexOf(evt.pointerId);
|
|
344
|
-
// In the event that we're
|
|
344
|
+
// In the event that we're getting pointermove events from touch inputs that we aren't tracking,
|
|
345
345
|
// look for an available slot and retroactively connect it.
|
|
346
346
|
if (deviceType === DeviceType.Touch && deviceSlot === -1) {
|
|
347
347
|
const idx = this._activeTouchIds.indexOf(-1);
|
|
@@ -389,7 +389,13 @@ export class WebDeviceInputSystem {
|
|
|
389
389
|
const deviceType = this._getPointerType(evt);
|
|
390
390
|
let deviceSlot = deviceType === DeviceType.Mouse ? 0 : evt.pointerId;
|
|
391
391
|
if (deviceType === DeviceType.Touch) {
|
|
392
|
-
|
|
392
|
+
// See if this pointerId is already using an existing slot
|
|
393
|
+
// (possible on some devices which raise the pointerMove event before the pointerDown event, e.g. when using a pen)
|
|
394
|
+
let idx = this._activeTouchIds.indexOf(evt.pointerId);
|
|
395
|
+
if (idx === -1) {
|
|
396
|
+
// If the pointerId wasn't already using a slot, find an open one
|
|
397
|
+
idx = this._activeTouchIds.indexOf(-1);
|
|
398
|
+
}
|
|
393
399
|
if (idx >= 0) {
|
|
394
400
|
deviceSlot = idx;
|
|
395
401
|
this._activeTouchIds[idx] = evt.pointerId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webDeviceInputSystem.js","sourceRoot":"","sources":["../../../../dev/core/src/DeviceInput/webDeviceInputSystem.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAGtE,gEAAgE;AAChE,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,gEAAgE;AAChE,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AAEhE,gBAAgB;AAChB,MAAM,OAAO,oBAAoB;IA2D7B;;;;;;OAMG;IACH,YACI,MAAsB,EACtB,iBAAuE,EACvE,oBAA0E,EAC1E,cAAyF;QArE7F,kBAAkB;QACV,YAAO,GAAmD,EAAE,CAAC;QAE7D,oBAAe,GAAY,KAAK,CAAC;QACjC,mBAAc,GAAY,KAAK,CAAC;QAIvB,iBAAY,GAAY,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC1D,8DAA8D;QAC9D,0HAA0H;QACzG,gBAAW,GAAY,oBAAoB,EAAE,IAAI,yBAAyB,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAMrH,6DAA6D;QACrD,uBAAkB,GAAG,CAAC,GAAQ,EAAE,EAAE,GAAE,CAAC,CAAC;QAC9C,6DAA6D;QACrD,qBA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,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC;SACjC;QAED,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ","sourcesContent":["import type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport type { IPointerEvent, IUIEvent } from \"../Events/deviceInputEvents\";\r\nimport { IsNavigatorAvailable } from \"../Misc/domManagement\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport { Tools } from \"../Misc/tools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { DeviceEventFactory } from \"./eventFactory\";\r\nimport { DeviceType, PointerInput } from \"./InputDevices/deviceEnums\";\r\nimport type { IDeviceInputSystem } from \"./inputInterfaces\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nconst MAX_KEYCODES = 255;\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nconst MAX_POINTER_INPUTS = Object.keys(PointerInput).length / 2;\r\n\r\n/** @internal */\r\nexport class WebDeviceInputSystem implements IDeviceInputSystem {\r\n // Private Members\r\n private _inputs: Array<{ [deviceSlot: number]: Array<number> }> = [];\r\n private _gamepads: Array<DeviceType>;\r\n private _keyboardActive: boolean = false;\r\n private _pointerActive: boolean = false;\r\n private _elementToAttachTo: HTMLElement;\r\n private _metaKeys: Array<number>;\r\n private readonly _engine: AbstractEngine;\r\n private readonly _usingSafari: boolean = Tools.IsSafari();\r\n // Found solution for determining if MacOS is being used here:\r\n // https://stackoverflow.com/questions/10527983/best-way-to-detect-mac-os-x-or-windows-computers-with-javascript-or-jquery\r\n private readonly _usingMacOS: boolean = IsNavigatorAvailable() && /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);\r\n\r\n private _onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n private _onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n private _onInputChanged: (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => void;\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _keyboardDownEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _keyboardUpEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _keyboardBlurEvent = (evt: any) => {};\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _pointerMoveEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _pointerDownEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _pointerUpEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _pointerCancelEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _pointerWheelEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _pointerBlurEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _pointerMacOSChromeOutEvent = (evt: any) => {};\r\n private _wheelEventName: string;\r\n private _eventsAttached: boolean = false;\r\n\r\n private _mouseId = -1;\r\n private readonly _isUsingFirefox = IsNavigatorAvailable() && navigator.userAgent && navigator.userAgent.indexOf(\"Firefox\") !== -1;\r\n private readonly _isUsingChromium = IsNavigatorAvailable() && navigator.userAgent && navigator.userAgent.indexOf(\"Chrome\") !== -1;\r\n\r\n // Array to store active Pointer ID values; prevents issues with negative pointerIds\r\n private _activeTouchIds: Array<number>;\r\n private _maxTouchPoints: number = 0;\r\n\r\n private _pointerInputClearObserver: Nullable<Observer<AbstractEngine>> = null;\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _gamepadConnectedEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _gamepadDisconnectedEvent = (evt: any) => {};\r\n\r\n private _eventPrefix: string;\r\n\r\n /**\r\n * Constructor for the WebDeviceInputSystem\r\n * @param engine Engine to reference\r\n * @param onDeviceConnected Callback to execute when device is connected\r\n * @param onDeviceDisconnected Callback to execute when device is disconnected\r\n * @param onInputChanged Callback to execute when input changes on device\r\n */\r\n constructor(\r\n engine: AbstractEngine,\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onInputChanged: (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => void\r\n ) {\r\n this._eventPrefix = Tools.GetPointerPrefix(engine);\r\n this._engine = engine;\r\n\r\n this._onDeviceConnected = onDeviceConnected;\r\n this._onDeviceDisconnected = onDeviceDisconnected;\r\n this._onInputChanged = onInputChanged;\r\n\r\n // If we need a pointerId, set one for future use\r\n this._mouseId = this._isUsingFirefox ? 0 : 1;\r\n\r\n this._enableEvents();\r\n\r\n if (this._usingMacOS) {\r\n this._metaKeys = [];\r\n }\r\n\r\n // Set callback to enable event handler switching when inputElement changes\r\n if (!this._engine._onEngineViewChanged) {\r\n this._engine._onEngineViewChanged = () => {\r\n this._enableEvents();\r\n };\r\n }\r\n }\r\n\r\n // Public functions\r\n /**\r\n * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.\r\n * @param deviceType Enum specifying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @returns Current value of input\r\n */\r\n public pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number {\r\n const device = this._inputs[deviceType][deviceSlot];\r\n\r\n if (!device) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw `Unable to find device ${DeviceType[deviceType]}`;\r\n }\r\n\r\n if (deviceType >= DeviceType.DualShock && deviceType <= DeviceType.DualSense) {\r\n this._updateDevice(deviceType, deviceSlot, inputIndex);\r\n }\r\n\r\n const currentValue = device[inputIndex];\r\n if (currentValue === undefined) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw `Unable to find input ${inputIndex} for device ${DeviceType[deviceType]} in slot ${deviceSlot}`;\r\n }\r\n\r\n if (inputIndex === PointerInput.Move) {\r\n Tools.Warn(`Unable to provide information for PointerInput.Move. Try using PointerInput.Horizontal or PointerInput.Vertical for move data.`);\r\n }\r\n\r\n return currentValue;\r\n }\r\n\r\n /**\r\n * Check for a specific device in the DeviceInputSystem\r\n * @param deviceType Type of device to check for\r\n * @returns bool with status of device's existence\r\n */\r\n public isDeviceAvailable(deviceType: DeviceType): boolean {\r\n return this._inputs[deviceType] !== undefined;\r\n }\r\n\r\n /**\r\n * Dispose of all the eventlisteners\r\n */\r\n public dispose(): void {\r\n // Callbacks\r\n this._onDeviceConnected = () => {};\r\n this._onDeviceDisconnected = () => {};\r\n this._onInputChanged = () => {};\r\n delete this._engine._onEngineViewChanged;\r\n\r\n if (this._elementToAttachTo) {\r\n this._disableEvents();\r\n }\r\n }\r\n\r\n /**\r\n * Enable listening for user input events\r\n */\r\n private _enableEvents(): void {\r\n const inputElement = this?._engine.getInputElement();\r\n if (inputElement && (!this._eventsAttached || this._elementToAttachTo !== inputElement)) {\r\n // Remove events before adding to avoid double events or simultaneous events on multiple canvases\r\n this._disableEvents();\r\n\r\n // If the inputs array has already been created, zero it out to before setting up events\r\n if (this._inputs) {\r\n for (const inputs of this._inputs) {\r\n if (inputs) {\r\n for (const deviceSlotKey in inputs) {\r\n const deviceSlot = +deviceSlotKey;\r\n const device = inputs[deviceSlot];\r\n if (device) {\r\n for (let inputIndex = 0; inputIndex < device.length; inputIndex++) {\r\n device[inputIndex] = 0;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n this._elementToAttachTo = inputElement;\r\n // Set tab index for the inputElement to the engine's canvasTabIndex, if and only if the element's tab index is -1\r\n this._elementToAttachTo.tabIndex = this._elementToAttachTo.tabIndex !== -1 ? this._elementToAttachTo.tabIndex : this._engine.canvasTabIndex;\r\n this._handleKeyActions();\r\n this._handlePointerActions();\r\n this._handleGamepadActions();\r\n this._eventsAttached = true;\r\n\r\n // Check for devices that are already connected but aren't registered. Currently, only checks for gamepads and mouse\r\n this._checkForConnectedDevices();\r\n }\r\n }\r\n\r\n /**\r\n * Disable listening for user input events\r\n */\r\n private _disableEvents(): void {\r\n if (this._elementToAttachTo) {\r\n // Blur Events\r\n this._elementToAttachTo.removeEventListener(\"blur\", this._keyboardBlurEvent);\r\n this._elementToAttachTo.removeEventListener(\"blur\", this._pointerBlurEvent);\r\n\r\n // Keyboard Events\r\n this._elementToAttachTo.removeEventListener(\"keydown\", this._keyboardDownEvent);\r\n this._elementToAttachTo.removeEventListener(\"keyup\", this._keyboardUpEvent);\r\n\r\n // Pointer Events\r\n this._elementToAttachTo.removeEventListener(this._eventPrefix + \"move\", this._pointerMoveEvent);\r\n this._elementToAttachTo.removeEventListener(this._eventPrefix + \"down\", this._pointerDownEvent);\r\n this._elementToAttachTo.removeEventListener(this._eventPrefix + \"up\", this._pointerUpEvent);\r\n this._elementToAttachTo.removeEventListener(this._eventPrefix + \"cancel\", this._pointerCancelEvent);\r\n this._elementToAttachTo.removeEventListener(this._wheelEventName, this._pointerWheelEvent);\r\n if (this._usingMacOS && this._isUsingChromium) {\r\n this._elementToAttachTo.removeEventListener(\"lostpointercapture\", this._pointerMacOSChromeOutEvent);\r\n }\r\n\r\n // Gamepad Events\r\n window.removeEventListener(\"gamepadconnected\", this._gamepadConnectedEvent);\r\n window.removeEventListener(\"gamepaddisconnected\", this._gamepadDisconnectedEvent);\r\n }\r\n\r\n if (this._pointerInputClearObserver) {\r\n this._engine.onEndFrameObservable.remove(this._pointerInputClearObserver);\r\n }\r\n\r\n this._eventsAttached = false;\r\n }\r\n\r\n /**\r\n * Checks for existing connections to devices and register them, if necessary\r\n * Currently handles gamepads and mouse\r\n */\r\n private _checkForConnectedDevices(): void {\r\n if (navigator.getGamepads) {\r\n const gamepads = navigator.getGamepads();\r\n\r\n for (const gamepad of gamepads) {\r\n if (gamepad) {\r\n this._addGamePad(gamepad);\r\n }\r\n }\r\n }\r\n\r\n // If the device in use has mouse capabilities, pre-register mouse\r\n if (typeof matchMedia === \"function\" && matchMedia(\"(pointer:fine)\").matches) {\r\n // This will provide a dummy value for the cursor position and is expected to be overridden when the first mouse event happens.\r\n // There isn't any good way to get the current position outside of a pointer event so that's why this was done.\r\n this._addPointerDevice(DeviceType.Mouse, 0, 0, 0);\r\n }\r\n }\r\n\r\n // Private functions\r\n /**\r\n * Add a gamepad to the DeviceInputSystem\r\n * @param gamepad A single DOM Gamepad object\r\n */\r\n private _addGamePad(gamepad: any): void {\r\n const deviceType = this._getGamepadDeviceType(gamepad.id);\r\n const deviceSlot = gamepad.index;\r\n\r\n this._gamepads = this._gamepads || new Array<DeviceType>(gamepad.index + 1);\r\n this._registerDevice(deviceType, deviceSlot, gamepad.buttons.length + gamepad.axes.length);\r\n\r\n this._gamepads[deviceSlot] = deviceType;\r\n }\r\n\r\n /**\r\n * Add pointer device to DeviceInputSystem\r\n * @param deviceType Type of Pointer to add\r\n * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)\r\n * @param currentX Current X at point of adding\r\n * @param currentY Current Y at point of adding\r\n */\r\n private _addPointerDevice(deviceType: DeviceType, deviceSlot: number, currentX: number, currentY: number): void {\r\n if (!this._pointerActive) {\r\n this._pointerActive = true;\r\n }\r\n this._registerDevice(deviceType, deviceSlot, MAX_POINTER_INPUTS);\r\n const pointer = this._inputs[deviceType][deviceSlot]; /* initialize our pointer position immediately after registration */\r\n pointer[0] = currentX;\r\n pointer[1] = currentY;\r\n }\r\n\r\n /**\r\n * Add device and inputs to device array\r\n * @param deviceType Enum specifying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param numberOfInputs Number of input entries to create for given device\r\n */\r\n private _registerDevice(deviceType: DeviceType, deviceSlot: number, numberOfInputs: number): void {\r\n if (deviceSlot === undefined) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw `Unable to register device ${DeviceType[deviceType]} to undefined slot.`;\r\n }\r\n\r\n if (!this._inputs[deviceType]) {\r\n this._inputs[deviceType] = {};\r\n }\r\n\r\n if (!this._inputs[deviceType][deviceSlot]) {\r\n const device = new Array<number>(numberOfInputs);\r\n\r\n device.fill(0);\r\n\r\n this._inputs[deviceType][deviceSlot] = device;\r\n this._onDeviceConnected(deviceType, deviceSlot);\r\n }\r\n }\r\n\r\n /**\r\n * Given a specific device name, remove that device from the device map\r\n * @param deviceType Enum specifying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n */\r\n private _unregisterDevice(deviceType: DeviceType, deviceSlot: number): void {\r\n if (this._inputs[deviceType][deviceSlot]) {\r\n delete this._inputs[deviceType][deviceSlot];\r\n this._onDeviceDisconnected(deviceType, deviceSlot);\r\n }\r\n }\r\n\r\n /**\r\n * Handle all actions that come from keyboard interaction\r\n */\r\n private _handleKeyActions(): void {\r\n this._keyboardDownEvent = (evt) => {\r\n if (!this._keyboardActive) {\r\n this._keyboardActive = true;\r\n this._registerDevice(DeviceType.Keyboard, 0, MAX_KEYCODES);\r\n }\r\n\r\n const kbKey = this._inputs[DeviceType.Keyboard][0];\r\n if (kbKey) {\r\n kbKey[evt.keyCode] = 1;\r\n\r\n const deviceEvent = evt as IUIEvent;\r\n deviceEvent.inputIndex = evt.keyCode;\r\n\r\n if (this._usingMacOS && evt.metaKey && evt.key !== \"Meta\") {\r\n if (!this._metaKeys.includes(evt.keyCode)) {\r\n this._metaKeys.push(evt.keyCode);\r\n }\r\n }\r\n\r\n this._onInputChanged(DeviceType.Keyboard, 0, deviceEvent);\r\n }\r\n };\r\n\r\n this._keyboardUpEvent = (evt) => {\r\n if (!this._keyboardActive) {\r\n this._keyboardActive = true;\r\n this._registerDevice(DeviceType.Keyboard, 0, MAX_KEYCODES);\r\n }\r\n\r\n const kbKey = this._inputs[DeviceType.Keyboard][0];\r\n if (kbKey) {\r\n kbKey[evt.keyCode] = 0;\r\n\r\n const deviceEvent = evt as IUIEvent;\r\n deviceEvent.inputIndex = evt.keyCode;\r\n\r\n if (this._usingMacOS && evt.key === \"Meta\" && this._metaKeys.length > 0) {\r\n for (const keyCode of this._metaKeys) {\r\n const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Keyboard, 0, keyCode, 0, this, this._elementToAttachTo);\r\n kbKey[keyCode] = 0;\r\n this._onInputChanged(DeviceType.Keyboard, 0, deviceEvent);\r\n }\r\n this._metaKeys.splice(0, this._metaKeys.length);\r\n }\r\n\r\n this._onInputChanged(DeviceType.Keyboard, 0, deviceEvent);\r\n }\r\n };\r\n\r\n this._keyboardBlurEvent = () => {\r\n if (this._keyboardActive) {\r\n const kbKey = this._inputs[DeviceType.Keyboard][0];\r\n\r\n for (let i = 0; i < kbKey.length; i++) {\r\n if (kbKey[i] !== 0) {\r\n kbKey[i] = 0;\r\n\r\n const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Keyboard, 0, i, 0, this, this._elementToAttachTo);\r\n\r\n this._onInputChanged(DeviceType.Keyboard, 0, deviceEvent);\r\n }\r\n }\r\n if (this._usingMacOS) {\r\n this._metaKeys.splice(0, this._metaKeys.length);\r\n }\r\n }\r\n };\r\n\r\n this._elementToAttachTo.addEventListener(\"keydown\", this._keyboardDownEvent);\r\n this._elementToAttachTo.addEventListener(\"keyup\", this._keyboardUpEvent);\r\n this._elementToAttachTo.addEventListener(\"blur\", this._keyboardBlurEvent);\r\n }\r\n\r\n /**\r\n * Handle all actions that come from pointer interaction\r\n */\r\n private _handlePointerActions(): void {\r\n // If maxTouchPoints is defined, use that value. Otherwise, allow for a minimum for supported gestures like pinch\r\n this._maxTouchPoints = (IsNavigatorAvailable() && navigator.maxTouchPoints) || 2;\r\n if (!this._activeTouchIds) {\r\n this._activeTouchIds = new Array<number>(this._maxTouchPoints);\r\n }\r\n\r\n for (let i = 0; i < this._maxTouchPoints; i++) {\r\n this._activeTouchIds[i] = -1;\r\n }\r\n\r\n this._pointerMoveEvent = (evt) => {\r\n const deviceType = this._getPointerType(evt);\r\n let deviceSlot = deviceType === DeviceType.Mouse ? 0 : this._activeTouchIds.indexOf(evt.pointerId);\r\n\r\n // In the event that we're gettting pointermove events from touch inputs that we aren't tracking,\r\n // look for an available slot and retroactively connect it.\r\n if (deviceType === DeviceType.Touch && deviceSlot === -1) {\r\n const idx = this._activeTouchIds.indexOf(-1);\r\n\r\n if (idx >= 0) {\r\n deviceSlot = idx;\r\n this._activeTouchIds[idx] = evt.pointerId;\r\n // Because this is a \"new\" input, inform the connected callback\r\n this._onDeviceConnected(deviceType, deviceSlot);\r\n } else {\r\n // We can't find an open slot to store new pointer so just return (can only support max number of touches)\r\n Tools.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);\r\n return;\r\n }\r\n }\r\n\r\n if (!this._inputs[deviceType]) {\r\n this._inputs[deviceType] = {};\r\n }\r\n\r\n if (!this._inputs[deviceType][deviceSlot]) {\r\n this._addPointerDevice(deviceType, deviceSlot, evt.clientX, evt.clientY);\r\n }\r\n\r\n const pointer = this._inputs[deviceType][deviceSlot];\r\n if (pointer) {\r\n const deviceEvent = evt as IPointerEvent;\r\n deviceEvent.inputIndex = PointerInput.Move;\r\n\r\n pointer[PointerInput.Horizontal] = evt.clientX;\r\n pointer[PointerInput.Vertical] = evt.clientY;\r\n\r\n // For touches that aren't started with a down, we need to set the button state to 1\r\n if (deviceType === DeviceType.Touch && pointer[PointerInput.LeftClick] === 0) {\r\n pointer[PointerInput.LeftClick] = 1;\r\n }\r\n\r\n if (evt.pointerId === undefined) {\r\n evt.pointerId = this._mouseId;\r\n }\r\n\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n\r\n // Lets Propagate the event for move with same position.\r\n if (!this._usingSafari && evt.button !== -1) {\r\n deviceEvent.inputIndex = evt.button + 2;\r\n pointer[evt.button + 2] = pointer[evt.button + 2] ? 0 : 1; // Reverse state of button if evt.button has value\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n }\r\n }\r\n };\r\n\r\n this._pointerDownEvent = (evt) => {\r\n const deviceType = this._getPointerType(evt);\r\n let deviceSlot = deviceType === DeviceType.Mouse ? 0 : evt.pointerId;\r\n\r\n if (deviceType === DeviceType.Touch) {\r\n const idx = this._activeTouchIds.indexOf(-1);\r\n\r\n if (idx >= 0) {\r\n deviceSlot = idx;\r\n this._activeTouchIds[idx] = evt.pointerId;\r\n } else {\r\n // We can't find an open slot to store new pointer so just return (can only support max number of touches)\r\n Tools.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);\r\n return;\r\n }\r\n }\r\n\r\n if (!this._inputs[deviceType]) {\r\n this._inputs[deviceType] = {};\r\n }\r\n\r\n if (!this._inputs[deviceType][deviceSlot]) {\r\n this._addPointerDevice(deviceType, deviceSlot, evt.clientX, evt.clientY);\r\n } else if (deviceType === DeviceType.Touch) {\r\n this._onDeviceConnected(deviceType, deviceSlot);\r\n }\r\n\r\n const pointer = this._inputs[deviceType][deviceSlot];\r\n if (pointer) {\r\n const previousHorizontal = pointer[PointerInput.Horizontal];\r\n const previousVertical = pointer[PointerInput.Vertical];\r\n\r\n if (deviceType === DeviceType.Mouse) {\r\n // Mouse; Set pointerId if undefined\r\n if (evt.pointerId === undefined) {\r\n evt.pointerId = this._mouseId;\r\n }\r\n\r\n if (!document.pointerLockElement) {\r\n try {\r\n this._elementToAttachTo.setPointerCapture(this._mouseId);\r\n } catch (e) {\r\n // DO NOTHING\r\n }\r\n }\r\n } else {\r\n // Touch; Since touches are dynamically assigned, only set capture if we have an id\r\n if (evt.pointerId && !document.pointerLockElement) {\r\n try {\r\n this._elementToAttachTo.setPointerCapture(evt.pointerId);\r\n } catch (e) {\r\n // DO NOTHING\r\n }\r\n }\r\n }\r\n\r\n pointer[PointerInput.Horizontal] = evt.clientX;\r\n pointer[PointerInput.Vertical] = evt.clientY;\r\n pointer[evt.button + 2] = 1;\r\n\r\n const deviceEvent = evt as IUIEvent;\r\n\r\n // NOTE: The +2 used here to is because PointerInput has the same value progression for its mouse buttons as PointerEvent.button\r\n // However, we have our X and Y values front-loaded to group together the touch inputs but not break this progression\r\n // EG. ([X, Y, Left-click], Middle-click, etc...)\r\n deviceEvent.inputIndex = evt.button + 2;\r\n\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n\r\n if (previousHorizontal !== evt.clientX || previousVertical !== evt.clientY) {\r\n deviceEvent.inputIndex = PointerInput.Move;\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n }\r\n }\r\n };\r\n\r\n this._pointerUpEvent = (evt) => {\r\n const deviceType = this._getPointerType(evt);\r\n const deviceSlot = deviceType === DeviceType.Mouse ? 0 : this._activeTouchIds.indexOf(evt.pointerId);\r\n\r\n if (deviceType === DeviceType.Touch) {\r\n // If we're getting a pointerup event for a touch that isn't active, just return.\r\n if (deviceSlot === -1) {\r\n return;\r\n } else {\r\n this._activeTouchIds[deviceSlot] = -1;\r\n }\r\n }\r\n\r\n const pointer = this._inputs[deviceType]?.[deviceSlot];\r\n if (pointer && pointer[evt.button + 2] !== 0) {\r\n const previousHorizontal = pointer[PointerInput.Horizontal];\r\n const previousVertical = pointer[PointerInput.Vertical];\r\n\r\n pointer[PointerInput.Horizontal] = evt.clientX;\r\n pointer[PointerInput.Vertical] = evt.clientY;\r\n pointer[evt.button + 2] = 0;\r\n\r\n const deviceEvent = evt as IUIEvent;\r\n\r\n if (evt.pointerId === undefined) {\r\n evt.pointerId = this._mouseId;\r\n }\r\n\r\n if (previousHorizontal !== evt.clientX || previousVertical !== evt.clientY) {\r\n deviceEvent.inputIndex = PointerInput.Move;\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n }\r\n\r\n // NOTE: The +2 used here to is because PointerInput has the same value progression for its mouse buttons as PointerEvent.button\r\n // However, we have our X and Y values front-loaded to group together the touch inputs but not break this progression\r\n // EG. ([X, Y, Left-click], Middle-click, etc...)\r\n deviceEvent.inputIndex = evt.button + 2;\r\n\r\n if (deviceType === DeviceType.Mouse && this._mouseId >= 0 && this._elementToAttachTo.hasPointerCapture?.(this._mouseId)) {\r\n this._elementToAttachTo.releasePointerCapture(this._mouseId);\r\n } else if (evt.pointerId && this._elementToAttachTo.hasPointerCapture?.(evt.pointerId)) {\r\n this._elementToAttachTo.releasePointerCapture(evt.pointerId);\r\n }\r\n\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n\r\n if (deviceType === DeviceType.Touch) {\r\n this._onDeviceDisconnected(deviceType, deviceSlot);\r\n }\r\n }\r\n };\r\n\r\n this._pointerCancelEvent = (evt) => {\r\n if (evt.pointerType === \"mouse\") {\r\n const pointer = this._inputs[DeviceType.Mouse][0];\r\n\r\n if (this._mouseId >= 0 && this._elementToAttachTo.hasPointerCapture?.(this._mouseId)) {\r\n this._elementToAttachTo.releasePointerCapture(this._mouseId);\r\n }\r\n\r\n for (let inputIndex = PointerInput.LeftClick; inputIndex <= PointerInput.BrowserForward; inputIndex++) {\r\n if (pointer[inputIndex] === 1) {\r\n pointer[inputIndex] = 0;\r\n\r\n const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Mouse, 0, inputIndex, 0, this, this._elementToAttachTo);\r\n\r\n this._onInputChanged(DeviceType.Mouse, 0, deviceEvent);\r\n }\r\n }\r\n } else {\r\n const deviceSlot = this._activeTouchIds.indexOf(evt.pointerId);\r\n\r\n // If we're getting a pointercancel event for a touch that isn't active, just return\r\n if (deviceSlot === -1) {\r\n return;\r\n }\r\n\r\n if (this._elementToAttachTo.hasPointerCapture?.(evt.pointerId)) {\r\n this._elementToAttachTo.releasePointerCapture(evt.pointerId);\r\n }\r\n\r\n this._inputs[DeviceType.Touch][deviceSlot][PointerInput.LeftClick] = 0;\r\n\r\n const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(\r\n DeviceType.Touch,\r\n deviceSlot,\r\n PointerInput.LeftClick,\r\n 0,\r\n this,\r\n this._elementToAttachTo,\r\n evt.pointerId\r\n );\r\n\r\n this._onInputChanged(DeviceType.Touch, deviceSlot, deviceEvent);\r\n\r\n this._activeTouchIds[deviceSlot] = -1;\r\n this._onDeviceDisconnected(DeviceType.Touch, deviceSlot);\r\n }\r\n };\r\n\r\n // Set Wheel Event Name, code originally from scene.inputManager\r\n this._wheelEventName =\r\n \"onwheel\" in document.createElement(\"div\")\r\n ? \"wheel\" // Modern browsers support \"wheel\"\r\n : (<any>document).onmousewheel !== undefined\r\n ? \"mousewheel\" // Webkit and IE support at least \"mousewheel\"\r\n : \"DOMMouseScroll\"; // let's assume that remaining browsers are older Firefox\r\n\r\n // Code originally in scene.inputManager.ts\r\n // Chrome reports warning in console if wheel listener doesn't set an explicit passive option.\r\n // IE11 only supports captureEvent:boolean, not options:object, and it defaults to false.\r\n // Feature detection technique copied from: https://github.com/github/eventlistener-polyfill (MIT license)\r\n let passiveSupported = false;\r\n const noop = function () {};\r\n\r\n try {\r\n const options = Object.defineProperty({}, \"passive\", {\r\n get: function () {\r\n passiveSupported = true;\r\n },\r\n });\r\n\r\n this._elementToAttachTo.addEventListener(\"test\", noop, options);\r\n this._elementToAttachTo.removeEventListener(\"test\", noop, options);\r\n } catch (e) {\r\n /* */\r\n }\r\n\r\n this._pointerBlurEvent = () => {\r\n // Handle mouse buttons\r\n if (this.isDeviceAvailable(DeviceType.Mouse)) {\r\n const pointer = this._inputs[DeviceType.Mouse][0];\r\n\r\n if (this._mouseId >= 0 && this._elementToAttachTo.hasPointerCapture?.(this._mouseId)) {\r\n this._elementToAttachTo.releasePointerCapture(this._mouseId);\r\n }\r\n\r\n for (let inputIndex = PointerInput.LeftClick; inputIndex <= PointerInput.BrowserForward; inputIndex++) {\r\n if (pointer[inputIndex] === 1) {\r\n pointer[inputIndex] = 0;\r\n\r\n const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Mouse, 0, inputIndex, 0, this, this._elementToAttachTo);\r\n\r\n this._onInputChanged(DeviceType.Mouse, 0, deviceEvent);\r\n }\r\n }\r\n }\r\n\r\n // Handle Active Touches\r\n if (this.isDeviceAvailable(DeviceType.Touch)) {\r\n const pointer = this._inputs[DeviceType.Touch];\r\n\r\n for (let deviceSlot = 0; deviceSlot < this._activeTouchIds.length; deviceSlot++) {\r\n const pointerId = this._activeTouchIds[deviceSlot];\r\n\r\n if (this._elementToAttachTo.hasPointerCapture?.(pointerId)) {\r\n this._elementToAttachTo.releasePointerCapture(pointerId);\r\n }\r\n\r\n if (pointerId !== -1 && pointer[deviceSlot]?.[PointerInput.LeftClick] === 1) {\r\n pointer[deviceSlot][PointerInput.LeftClick] = 0;\r\n\r\n const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(\r\n DeviceType.Touch,\r\n deviceSlot,\r\n PointerInput.LeftClick,\r\n 0,\r\n this,\r\n this._elementToAttachTo,\r\n pointerId\r\n );\r\n\r\n this._onInputChanged(DeviceType.Touch, deviceSlot, deviceEvent);\r\n\r\n this._activeTouchIds[deviceSlot] = -1;\r\n this._onDeviceDisconnected(DeviceType.Touch, deviceSlot);\r\n }\r\n }\r\n }\r\n };\r\n\r\n this._pointerWheelEvent = (evt) => {\r\n const deviceType = DeviceType.Mouse;\r\n const deviceSlot = 0;\r\n\r\n if (!this._inputs[deviceType]) {\r\n this._inputs[deviceType] = [];\r\n }\r\n\r\n if (!this._inputs[deviceType][deviceSlot]) {\r\n this._pointerActive = true;\r\n this._registerDevice(deviceType, deviceSlot, MAX_POINTER_INPUTS);\r\n }\r\n\r\n const pointer = this._inputs[deviceType][deviceSlot];\r\n if (pointer) {\r\n pointer[PointerInput.MouseWheelX] = evt.deltaX || 0;\r\n pointer[PointerInput.MouseWheelY] = evt.deltaY || evt.wheelDelta || 0;\r\n pointer[PointerInput.MouseWheelZ] = evt.deltaZ || 0;\r\n\r\n const deviceEvent = evt as IUIEvent;\r\n // By default, there is no pointerId for mouse wheel events so we'll add one here\r\n // This logic was originally in the InputManager but was added here to make the\r\n // InputManager more platform-agnostic\r\n if (evt.pointerId === undefined) {\r\n evt.pointerId = this._mouseId;\r\n }\r\n\r\n if (pointer[PointerInput.MouseWheelX] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelX;\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n }\r\n if (pointer[PointerInput.MouseWheelY] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelY;\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n }\r\n if (pointer[PointerInput.MouseWheelZ] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelZ;\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n }\r\n }\r\n };\r\n\r\n // Workaround for MacOS Chromium Browsers for lost pointer capture bug\r\n if (this._usingMacOS && this._isUsingChromium) {\r\n this._pointerMacOSChromeOutEvent = (evt) => {\r\n if (evt.buttons > 1) {\r\n this._pointerCancelEvent(evt);\r\n }\r\n };\r\n this._elementToAttachTo.addEventListener(\"lostpointercapture\", this._pointerMacOSChromeOutEvent);\r\n }\r\n\r\n this._elementToAttachTo.addEventListener(this._eventPrefix + \"move\", this._pointerMoveEvent);\r\n this._elementToAttachTo.addEventListener(this._eventPrefix + \"down\", this._pointerDownEvent);\r\n this._elementToAttachTo.addEventListener(this._eventPrefix + \"up\", this._pointerUpEvent);\r\n this._elementToAttachTo.addEventListener(this._eventPrefix + \"cancel\", this._pointerCancelEvent);\r\n this._elementToAttachTo.addEventListener(\"blur\", this._pointerBlurEvent);\r\n this._elementToAttachTo.addEventListener(this._wheelEventName, this._pointerWheelEvent, passiveSupported ? { passive: false } : false);\r\n\r\n // Since there's no up or down event for mouse wheel or delta x/y, clear mouse values at end of frame\r\n this._pointerInputClearObserver = this._engine.onEndFrameObservable.add(() => {\r\n if (this.isDeviceAvailable(DeviceType.Mouse)) {\r\n const pointer = this._inputs[DeviceType.Mouse][0];\r\n pointer[PointerInput.MouseWheelX] = 0;\r\n pointer[PointerInput.MouseWheelY] = 0;\r\n pointer[PointerInput.MouseWheelZ] = 0;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Handle all actions that come from gamepad interaction\r\n */\r\n private _handleGamepadActions(): void {\r\n this._gamepadConnectedEvent = (evt: any) => {\r\n this._addGamePad(evt.gamepad);\r\n };\r\n\r\n this._gamepadDisconnectedEvent = (evt: any) => {\r\n if (this._gamepads) {\r\n const deviceType = this._getGamepadDeviceType(evt.gamepad.id);\r\n const deviceSlot = evt.gamepad.index;\r\n\r\n this._unregisterDevice(deviceType, deviceSlot);\r\n delete this._gamepads[deviceSlot];\r\n }\r\n };\r\n\r\n window.addEventListener(\"gamepadconnected\", this._gamepadConnectedEvent);\r\n window.addEventListener(\"gamepaddisconnected\", this._gamepadDisconnectedEvent);\r\n }\r\n\r\n /**\r\n * Update all non-event based devices with each frame\r\n * @param deviceType Enum specifying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n */\r\n private _updateDevice(deviceType: DeviceType, deviceSlot: number, inputIndex: number): void {\r\n // Gamepads\r\n const gp = navigator.getGamepads()[deviceSlot];\r\n\r\n if (gp && deviceType === this._gamepads[deviceSlot]) {\r\n const device = this._inputs[deviceType][deviceSlot];\r\n\r\n if (inputIndex >= gp.buttons.length) {\r\n device[inputIndex] = gp.axes[inputIndex - gp.buttons.length].valueOf();\r\n } else {\r\n device[inputIndex] = gp.buttons[inputIndex].value;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets DeviceType from the device name\r\n * @param deviceName Name of Device from DeviceInputSystem\r\n * @returns DeviceType enum value\r\n */\r\n private _getGamepadDeviceType(deviceName: string): DeviceType {\r\n if (deviceName.indexOf(\"054c\") !== -1) {\r\n // DualShock 4 Gamepad\r\n return deviceName.indexOf(\"0ce6\") !== -1 ? DeviceType.DualSense : DeviceType.DualShock;\r\n } else if (deviceName.indexOf(\"Xbox One\") !== -1 || deviceName.search(\"Xbox 360\") !== -1 || deviceName.search(\"xinput\") !== -1) {\r\n // Xbox Gamepad\r\n return DeviceType.Xbox;\r\n } else if (deviceName.indexOf(\"057e\") !== -1) {\r\n // Switch Gamepad\r\n return DeviceType.Switch;\r\n }\r\n\r\n return DeviceType.Generic;\r\n }\r\n\r\n /**\r\n * Get DeviceType from a given pointer/mouse/touch event.\r\n * @param evt PointerEvent to evaluate\r\n * @returns DeviceType interpreted from event\r\n */\r\n private _getPointerType(evt: any): DeviceType {\r\n let deviceType = DeviceType.Mouse;\r\n\r\n if (evt.pointerType === \"touch\" || evt.pointerType === \"pen\" || evt.touches) {\r\n deviceType = DeviceType.Touch;\r\n }\r\n\r\n return deviceType;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"webDeviceInputSystem.js","sourceRoot":"","sources":["../../../../dev/core/src/DeviceInput/webDeviceInputSystem.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAGtE,gEAAgE;AAChE,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,gEAAgE;AAChE,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AAEhE,gBAAgB;AAChB,MAAM,OAAO,oBAAoB;IA2D7B;;;;;;OAMG;IACH,YACI,MAAsB,EACtB,iBAAuE,EACvE,oBAA0E,EAC1E,cAAyF;QArE7F,kBAAkB;QACV,YAAO,GAAmD,EAAE,CAAC;QAE7D,oBAAe,GAAY,KAAK,CAAC;QACjC,mBAAc,GAAY,KAAK,CAAC;QAIvB,iBAAY,GAAY,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC1D,8DAA8D;QAC9D,0HAA0H;QACzG,gBAAW,GAAY,oBAAoB,EAAE,IAAI,yBAAyB,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,C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YACjB,OAAO,UAAU,CAAC,MAAM,CAAC;SAC5B;QAED,OAAO,UAAU,CAAC,OAAO,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACK,eAAe,CAAC,GAAQ;QAC5B,IAAI,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC;QAElC,IAAI,GAAG,CAAC,WAAW,KAAK,OAAO,IAAI,GAAG,CAAC,WAAW,KAAK,KAAK,IAAI,GAAG,CAAC,OAAO,EAAE;YACzE,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC;SACjC;QAED,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ","sourcesContent":["import type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport type { IPointerEvent, IUIEvent } from \"../Events/deviceInputEvents\";\r\nimport { IsNavigatorAvailable } from \"../Misc/domManagement\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport { Tools } from \"../Misc/tools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { DeviceEventFactory } from \"./eventFactory\";\r\nimport { DeviceType, PointerInput } from \"./InputDevices/deviceEnums\";\r\nimport type { IDeviceInputSystem } from \"./inputInterfaces\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nconst MAX_KEYCODES = 255;\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nconst MAX_POINTER_INPUTS = Object.keys(PointerInput).length / 2;\r\n\r\n/** @internal */\r\nexport class WebDeviceInputSystem implements IDeviceInputSystem {\r\n // Private Members\r\n private _inputs: Array<{ [deviceSlot: number]: Array<number> }> = [];\r\n private _gamepads: Array<DeviceType>;\r\n private _keyboardActive: boolean = false;\r\n private _pointerActive: boolean = false;\r\n private _elementToAttachTo: HTMLElement;\r\n private _metaKeys: Array<number>;\r\n private readonly _engine: AbstractEngine;\r\n private readonly _usingSafari: boolean = Tools.IsSafari();\r\n // Found solution for determining if MacOS is being used here:\r\n // https://stackoverflow.com/questions/10527983/best-way-to-detect-mac-os-x-or-windows-computers-with-javascript-or-jquery\r\n private readonly _usingMacOS: boolean = IsNavigatorAvailable() && /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);\r\n\r\n private _onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n private _onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n private _onInputChanged: (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => void;\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _keyboardDownEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _keyboardUpEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _keyboardBlurEvent = (evt: any) => {};\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _pointerMoveEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _pointerDownEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _pointerUpEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _pointerCancelEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _pointerWheelEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _pointerBlurEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _pointerMacOSChromeOutEvent = (evt: any) => {};\r\n private _wheelEventName: string;\r\n private _eventsAttached: boolean = false;\r\n\r\n private _mouseId = -1;\r\n private readonly _isUsingFirefox = IsNavigatorAvailable() && navigator.userAgent && navigator.userAgent.indexOf(\"Firefox\") !== -1;\r\n private readonly _isUsingChromium = IsNavigatorAvailable() && navigator.userAgent && navigator.userAgent.indexOf(\"Chrome\") !== -1;\r\n\r\n // Array to store active Pointer ID values; prevents issues with negative pointerIds\r\n private _activeTouchIds: Array<number>;\r\n private _maxTouchPoints: number = 0;\r\n\r\n private _pointerInputClearObserver: Nullable<Observer<AbstractEngine>> = null;\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _gamepadConnectedEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _gamepadDisconnectedEvent = (evt: any) => {};\r\n\r\n private _eventPrefix: string;\r\n\r\n /**\r\n * Constructor for the WebDeviceInputSystem\r\n * @param engine Engine to reference\r\n * @param onDeviceConnected Callback to execute when device is connected\r\n * @param onDeviceDisconnected Callback to execute when device is disconnected\r\n * @param onInputChanged Callback to execute when input changes on device\r\n */\r\n constructor(\r\n engine: AbstractEngine,\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onInputChanged: (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => void\r\n ) {\r\n this._eventPrefix = Tools.GetPointerPrefix(engine);\r\n this._engine = engine;\r\n\r\n this._onDeviceConnected = onDeviceConnected;\r\n this._onDeviceDisconnected = onDeviceDisconnected;\r\n this._onInputChanged = onInputChanged;\r\n\r\n // If we need a pointerId, set one for future use\r\n this._mouseId = this._isUsingFirefox ? 0 : 1;\r\n\r\n this._enableEvents();\r\n\r\n if (this._usingMacOS) {\r\n this._metaKeys = [];\r\n }\r\n\r\n // Set callback to enable event handler switching when inputElement changes\r\n if (!this._engine._onEngineViewChanged) {\r\n this._engine._onEngineViewChanged = () => {\r\n this._enableEvents();\r\n };\r\n }\r\n }\r\n\r\n // Public functions\r\n /**\r\n * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.\r\n * @param deviceType Enum specifying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @returns Current value of input\r\n */\r\n public pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number {\r\n const device = this._inputs[deviceType][deviceSlot];\r\n\r\n if (!device) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw `Unable to find device ${DeviceType[deviceType]}`;\r\n }\r\n\r\n if (deviceType >= DeviceType.DualShock && deviceType <= DeviceType.DualSense) {\r\n this._updateDevice(deviceType, deviceSlot, inputIndex);\r\n }\r\n\r\n const currentValue = device[inputIndex];\r\n if (currentValue === undefined) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw `Unable to find input ${inputIndex} for device ${DeviceType[deviceType]} in slot ${deviceSlot}`;\r\n }\r\n\r\n if (inputIndex === PointerInput.Move) {\r\n Tools.Warn(`Unable to provide information for PointerInput.Move. Try using PointerInput.Horizontal or PointerInput.Vertical for move data.`);\r\n }\r\n\r\n return currentValue;\r\n }\r\n\r\n /**\r\n * Check for a specific device in the DeviceInputSystem\r\n * @param deviceType Type of device to check for\r\n * @returns bool with status of device's existence\r\n */\r\n public isDeviceAvailable(deviceType: DeviceType): boolean {\r\n return this._inputs[deviceType] !== undefined;\r\n }\r\n\r\n /**\r\n * Dispose of all the eventlisteners\r\n */\r\n public dispose(): void {\r\n // Callbacks\r\n this._onDeviceConnected = () => {};\r\n this._onDeviceDisconnected = () => {};\r\n this._onInputChanged = () => {};\r\n delete this._engine._onEngineViewChanged;\r\n\r\n if (this._elementToAttachTo) {\r\n this._disableEvents();\r\n }\r\n }\r\n\r\n /**\r\n * Enable listening for user input events\r\n */\r\n private _enableEvents(): void {\r\n const inputElement = this?._engine.getInputElement();\r\n if (inputElement && (!this._eventsAttached || this._elementToAttachTo !== inputElement)) {\r\n // Remove events before adding to avoid double events or simultaneous events on multiple canvases\r\n this._disableEvents();\r\n\r\n // If the inputs array has already been created, zero it out to before setting up events\r\n if (this._inputs) {\r\n for (const inputs of this._inputs) {\r\n if (inputs) {\r\n for (const deviceSlotKey in inputs) {\r\n const deviceSlot = +deviceSlotKey;\r\n const device = inputs[deviceSlot];\r\n if (device) {\r\n for (let inputIndex = 0; inputIndex < device.length; inputIndex++) {\r\n device[inputIndex] = 0;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n this._elementToAttachTo = inputElement;\r\n // Set tab index for the inputElement to the engine's canvasTabIndex, if and only if the element's tab index is -1\r\n this._elementToAttachTo.tabIndex = this._elementToAttachTo.tabIndex !== -1 ? this._elementToAttachTo.tabIndex : this._engine.canvasTabIndex;\r\n this._handleKeyActions();\r\n this._handlePointerActions();\r\n this._handleGamepadActions();\r\n this._eventsAttached = true;\r\n\r\n // Check for devices that are already connected but aren't registered. Currently, only checks for gamepads and mouse\r\n this._checkForConnectedDevices();\r\n }\r\n }\r\n\r\n /**\r\n * Disable listening for user input events\r\n */\r\n private _disableEvents(): void {\r\n if (this._elementToAttachTo) {\r\n // Blur Events\r\n this._elementToAttachTo.removeEventListener(\"blur\", this._keyboardBlurEvent);\r\n this._elementToAttachTo.removeEventListener(\"blur\", this._pointerBlurEvent);\r\n\r\n // Keyboard Events\r\n this._elementToAttachTo.removeEventListener(\"keydown\", this._keyboardDownEvent);\r\n this._elementToAttachTo.removeEventListener(\"keyup\", this._keyboardUpEvent);\r\n\r\n // Pointer Events\r\n this._elementToAttachTo.removeEventListener(this._eventPrefix + \"move\", this._pointerMoveEvent);\r\n this._elementToAttachTo.removeEventListener(this._eventPrefix + \"down\", this._pointerDownEvent);\r\n this._elementToAttachTo.removeEventListener(this._eventPrefix + \"up\", this._pointerUpEvent);\r\n this._elementToAttachTo.removeEventListener(this._eventPrefix + \"cancel\", this._pointerCancelEvent);\r\n this._elementToAttachTo.removeEventListener(this._wheelEventName, this._pointerWheelEvent);\r\n if (this._usingMacOS && this._isUsingChromium) {\r\n this._elementToAttachTo.removeEventListener(\"lostpointercapture\", this._pointerMacOSChromeOutEvent);\r\n }\r\n\r\n // Gamepad Events\r\n window.removeEventListener(\"gamepadconnected\", this._gamepadConnectedEvent);\r\n window.removeEventListener(\"gamepaddisconnected\", this._gamepadDisconnectedEvent);\r\n }\r\n\r\n if (this._pointerInputClearObserver) {\r\n this._engine.onEndFrameObservable.remove(this._pointerInputClearObserver);\r\n }\r\n\r\n this._eventsAttached = false;\r\n }\r\n\r\n /**\r\n * Checks for existing connections to devices and register them, if necessary\r\n * Currently handles gamepads and mouse\r\n */\r\n private _checkForConnectedDevices(): void {\r\n if (navigator.getGamepads) {\r\n const gamepads = navigator.getGamepads();\r\n\r\n for (const gamepad of gamepads) {\r\n if (gamepad) {\r\n this._addGamePad(gamepad);\r\n }\r\n }\r\n }\r\n\r\n // If the device in use has mouse capabilities, pre-register mouse\r\n if (typeof matchMedia === \"function\" && matchMedia(\"(pointer:fine)\").matches) {\r\n // This will provide a dummy value for the cursor position and is expected to be overridden when the first mouse event happens.\r\n // There isn't any good way to get the current position outside of a pointer event so that's why this was done.\r\n this._addPointerDevice(DeviceType.Mouse, 0, 0, 0);\r\n }\r\n }\r\n\r\n // Private functions\r\n /**\r\n * Add a gamepad to the DeviceInputSystem\r\n * @param gamepad A single DOM Gamepad object\r\n */\r\n private _addGamePad(gamepad: any): void {\r\n const deviceType = this._getGamepadDeviceType(gamepad.id);\r\n const deviceSlot = gamepad.index;\r\n\r\n this._gamepads = this._gamepads || new Array<DeviceType>(gamepad.index + 1);\r\n this._registerDevice(deviceType, deviceSlot, gamepad.buttons.length + gamepad.axes.length);\r\n\r\n this._gamepads[deviceSlot] = deviceType;\r\n }\r\n\r\n /**\r\n * Add pointer device to DeviceInputSystem\r\n * @param deviceType Type of Pointer to add\r\n * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)\r\n * @param currentX Current X at point of adding\r\n * @param currentY Current Y at point of adding\r\n */\r\n private _addPointerDevice(deviceType: DeviceType, deviceSlot: number, currentX: number, currentY: number): void {\r\n if (!this._pointerActive) {\r\n this._pointerActive = true;\r\n }\r\n this._registerDevice(deviceType, deviceSlot, MAX_POINTER_INPUTS);\r\n const pointer = this._inputs[deviceType][deviceSlot]; /* initialize our pointer position immediately after registration */\r\n pointer[0] = currentX;\r\n pointer[1] = currentY;\r\n }\r\n\r\n /**\r\n * Add device and inputs to device array\r\n * @param deviceType Enum specifying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param numberOfInputs Number of input entries to create for given device\r\n */\r\n private _registerDevice(deviceType: DeviceType, deviceSlot: number, numberOfInputs: number): void {\r\n if (deviceSlot === undefined) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw `Unable to register device ${DeviceType[deviceType]} to undefined slot.`;\r\n }\r\n\r\n if (!this._inputs[deviceType]) {\r\n this._inputs[deviceType] = {};\r\n }\r\n\r\n if (!this._inputs[deviceType][deviceSlot]) {\r\n const device = new Array<number>(numberOfInputs);\r\n\r\n device.fill(0);\r\n\r\n this._inputs[deviceType][deviceSlot] = device;\r\n this._onDeviceConnected(deviceType, deviceSlot);\r\n }\r\n }\r\n\r\n /**\r\n * Given a specific device name, remove that device from the device map\r\n * @param deviceType Enum specifying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n */\r\n private _unregisterDevice(deviceType: DeviceType, deviceSlot: number): void {\r\n if (this._inputs[deviceType][deviceSlot]) {\r\n delete this._inputs[deviceType][deviceSlot];\r\n this._onDeviceDisconnected(deviceType, deviceSlot);\r\n }\r\n }\r\n\r\n /**\r\n * Handle all actions that come from keyboard interaction\r\n */\r\n private _handleKeyActions(): void {\r\n this._keyboardDownEvent = (evt) => {\r\n if (!this._keyboardActive) {\r\n this._keyboardActive = true;\r\n this._registerDevice(DeviceType.Keyboard, 0, MAX_KEYCODES);\r\n }\r\n\r\n const kbKey = this._inputs[DeviceType.Keyboard][0];\r\n if (kbKey) {\r\n kbKey[evt.keyCode] = 1;\r\n\r\n const deviceEvent = evt as IUIEvent;\r\n deviceEvent.inputIndex = evt.keyCode;\r\n\r\n if (this._usingMacOS && evt.metaKey && evt.key !== \"Meta\") {\r\n if (!this._metaKeys.includes(evt.keyCode)) {\r\n this._metaKeys.push(evt.keyCode);\r\n }\r\n }\r\n\r\n this._onInputChanged(DeviceType.Keyboard, 0, deviceEvent);\r\n }\r\n };\r\n\r\n this._keyboardUpEvent = (evt) => {\r\n if (!this._keyboardActive) {\r\n this._keyboardActive = true;\r\n this._registerDevice(DeviceType.Keyboard, 0, MAX_KEYCODES);\r\n }\r\n\r\n const kbKey = this._inputs[DeviceType.Keyboard][0];\r\n if (kbKey) {\r\n kbKey[evt.keyCode] = 0;\r\n\r\n const deviceEvent = evt as IUIEvent;\r\n deviceEvent.inputIndex = evt.keyCode;\r\n\r\n if (this._usingMacOS && evt.key === \"Meta\" && this._metaKeys.length > 0) {\r\n for (const keyCode of this._metaKeys) {\r\n const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Keyboard, 0, keyCode, 0, this, this._elementToAttachTo);\r\n kbKey[keyCode] = 0;\r\n this._onInputChanged(DeviceType.Keyboard, 0, deviceEvent);\r\n }\r\n this._metaKeys.splice(0, this._metaKeys.length);\r\n }\r\n\r\n this._onInputChanged(DeviceType.Keyboard, 0, deviceEvent);\r\n }\r\n };\r\n\r\n this._keyboardBlurEvent = () => {\r\n if (this._keyboardActive) {\r\n const kbKey = this._inputs[DeviceType.Keyboard][0];\r\n\r\n for (let i = 0; i < kbKey.length; i++) {\r\n if (kbKey[i] !== 0) {\r\n kbKey[i] = 0;\r\n\r\n const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Keyboard, 0, i, 0, this, this._elementToAttachTo);\r\n\r\n this._onInputChanged(DeviceType.Keyboard, 0, deviceEvent);\r\n }\r\n }\r\n if (this._usingMacOS) {\r\n this._metaKeys.splice(0, this._metaKeys.length);\r\n }\r\n }\r\n };\r\n\r\n this._elementToAttachTo.addEventListener(\"keydown\", this._keyboardDownEvent);\r\n this._elementToAttachTo.addEventListener(\"keyup\", this._keyboardUpEvent);\r\n this._elementToAttachTo.addEventListener(\"blur\", this._keyboardBlurEvent);\r\n }\r\n\r\n /**\r\n * Handle all actions that come from pointer interaction\r\n */\r\n private _handlePointerActions(): void {\r\n // If maxTouchPoints is defined, use that value. Otherwise, allow for a minimum for supported gestures like pinch\r\n this._maxTouchPoints = (IsNavigatorAvailable() && navigator.maxTouchPoints) || 2;\r\n if (!this._activeTouchIds) {\r\n this._activeTouchIds = new Array<number>(this._maxTouchPoints);\r\n }\r\n\r\n for (let i = 0; i < this._maxTouchPoints; i++) {\r\n this._activeTouchIds[i] = -1;\r\n }\r\n\r\n this._pointerMoveEvent = (evt) => {\r\n const deviceType = this._getPointerType(evt);\r\n let deviceSlot = deviceType === DeviceType.Mouse ? 0 : this._activeTouchIds.indexOf(evt.pointerId);\r\n\r\n // In the event that we're getting pointermove events from touch inputs that we aren't tracking,\r\n // look for an available slot and retroactively connect it.\r\n if (deviceType === DeviceType.Touch && deviceSlot === -1) {\r\n const idx = this._activeTouchIds.indexOf(-1);\r\n\r\n if (idx >= 0) {\r\n deviceSlot = idx;\r\n this._activeTouchIds[idx] = evt.pointerId;\r\n // Because this is a \"new\" input, inform the connected callback\r\n this._onDeviceConnected(deviceType, deviceSlot);\r\n } else {\r\n // We can't find an open slot to store new pointer so just return (can only support max number of touches)\r\n Tools.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);\r\n return;\r\n }\r\n }\r\n\r\n if (!this._inputs[deviceType]) {\r\n this._inputs[deviceType] = {};\r\n }\r\n\r\n if (!this._inputs[deviceType][deviceSlot]) {\r\n this._addPointerDevice(deviceType, deviceSlot, evt.clientX, evt.clientY);\r\n }\r\n\r\n const pointer = this._inputs[deviceType][deviceSlot];\r\n if (pointer) {\r\n const deviceEvent = evt as IPointerEvent;\r\n deviceEvent.inputIndex = PointerInput.Move;\r\n\r\n pointer[PointerInput.Horizontal] = evt.clientX;\r\n pointer[PointerInput.Vertical] = evt.clientY;\r\n\r\n // For touches that aren't started with a down, we need to set the button state to 1\r\n if (deviceType === DeviceType.Touch && pointer[PointerInput.LeftClick] === 0) {\r\n pointer[PointerInput.LeftClick] = 1;\r\n }\r\n\r\n if (evt.pointerId === undefined) {\r\n evt.pointerId = this._mouseId;\r\n }\r\n\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n\r\n // Lets Propagate the event for move with same position.\r\n if (!this._usingSafari && evt.button !== -1) {\r\n deviceEvent.inputIndex = evt.button + 2;\r\n pointer[evt.button + 2] = pointer[evt.button + 2] ? 0 : 1; // Reverse state of button if evt.button has value\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n }\r\n }\r\n };\r\n\r\n this._pointerDownEvent = (evt) => {\r\n const deviceType = this._getPointerType(evt);\r\n let deviceSlot = deviceType === DeviceType.Mouse ? 0 : evt.pointerId;\r\n\r\n if (deviceType === DeviceType.Touch) {\r\n // See if this pointerId is already using an existing slot\r\n // (possible on some devices which raise the pointerMove event before the pointerDown event, e.g. when using a pen)\r\n let idx = this._activeTouchIds.indexOf(evt.pointerId);\r\n if (idx === -1) {\r\n // If the pointerId wasn't already using a slot, find an open one\r\n idx = this._activeTouchIds.indexOf(-1);\r\n }\r\n\r\n if (idx >= 0) {\r\n deviceSlot = idx;\r\n this._activeTouchIds[idx] = evt.pointerId;\r\n } else {\r\n // We can't find an open slot to store new pointer so just return (can only support max number of touches)\r\n Tools.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);\r\n return;\r\n }\r\n }\r\n\r\n if (!this._inputs[deviceType]) {\r\n this._inputs[deviceType] = {};\r\n }\r\n\r\n if (!this._inputs[deviceType][deviceSlot]) {\r\n this._addPointerDevice(deviceType, deviceSlot, evt.clientX, evt.clientY);\r\n } else if (deviceType === DeviceType.Touch) {\r\n this._onDeviceConnected(deviceType, deviceSlot);\r\n }\r\n\r\n const pointer = this._inputs[deviceType][deviceSlot];\r\n if (pointer) {\r\n const previousHorizontal = pointer[PointerInput.Horizontal];\r\n const previousVertical = pointer[PointerInput.Vertical];\r\n\r\n if (deviceType === DeviceType.Mouse) {\r\n // Mouse; Set pointerId if undefined\r\n if (evt.pointerId === undefined) {\r\n evt.pointerId = this._mouseId;\r\n }\r\n\r\n if (!document.pointerLockElement) {\r\n try {\r\n this._elementToAttachTo.setPointerCapture(this._mouseId);\r\n } catch (e) {\r\n // DO NOTHING\r\n }\r\n }\r\n } else {\r\n // Touch; Since touches are dynamically assigned, only set capture if we have an id\r\n if (evt.pointerId && !document.pointerLockElement) {\r\n try {\r\n this._elementToAttachTo.setPointerCapture(evt.pointerId);\r\n } catch (e) {\r\n // DO NOTHING\r\n }\r\n }\r\n }\r\n\r\n pointer[PointerInput.Horizontal] = evt.clientX;\r\n pointer[PointerInput.Vertical] = evt.clientY;\r\n pointer[evt.button + 2] = 1;\r\n\r\n const deviceEvent = evt as IUIEvent;\r\n\r\n // NOTE: The +2 used here to is because PointerInput has the same value progression for its mouse buttons as PointerEvent.button\r\n // However, we have our X and Y values front-loaded to group together the touch inputs but not break this progression\r\n // EG. ([X, Y, Left-click], Middle-click, etc...)\r\n deviceEvent.inputIndex = evt.button + 2;\r\n\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n\r\n if (previousHorizontal !== evt.clientX || previousVertical !== evt.clientY) {\r\n deviceEvent.inputIndex = PointerInput.Move;\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n }\r\n }\r\n };\r\n\r\n this._pointerUpEvent = (evt) => {\r\n const deviceType = this._getPointerType(evt);\r\n const deviceSlot = deviceType === DeviceType.Mouse ? 0 : this._activeTouchIds.indexOf(evt.pointerId);\r\n\r\n if (deviceType === DeviceType.Touch) {\r\n // If we're getting a pointerup event for a touch that isn't active, just return.\r\n if (deviceSlot === -1) {\r\n return;\r\n } else {\r\n this._activeTouchIds[deviceSlot] = -1;\r\n }\r\n }\r\n\r\n const pointer = this._inputs[deviceType]?.[deviceSlot];\r\n if (pointer && pointer[evt.button + 2] !== 0) {\r\n const previousHorizontal = pointer[PointerInput.Horizontal];\r\n const previousVertical = pointer[PointerInput.Vertical];\r\n\r\n pointer[PointerInput.Horizontal] = evt.clientX;\r\n pointer[PointerInput.Vertical] = evt.clientY;\r\n pointer[evt.button + 2] = 0;\r\n\r\n const deviceEvent = evt as IUIEvent;\r\n\r\n if (evt.pointerId === undefined) {\r\n evt.pointerId = this._mouseId;\r\n }\r\n\r\n if (previousHorizontal !== evt.clientX || previousVertical !== evt.clientY) {\r\n deviceEvent.inputIndex = PointerInput.Move;\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n }\r\n\r\n // NOTE: The +2 used here to is because PointerInput has the same value progression for its mouse buttons as PointerEvent.button\r\n // However, we have our X and Y values front-loaded to group together the touch inputs but not break this progression\r\n // EG. ([X, Y, Left-click], Middle-click, etc...)\r\n deviceEvent.inputIndex = evt.button + 2;\r\n\r\n if (deviceType === DeviceType.Mouse && this._mouseId >= 0 && this._elementToAttachTo.hasPointerCapture?.(this._mouseId)) {\r\n this._elementToAttachTo.releasePointerCapture(this._mouseId);\r\n } else if (evt.pointerId && this._elementToAttachTo.hasPointerCapture?.(evt.pointerId)) {\r\n this._elementToAttachTo.releasePointerCapture(evt.pointerId);\r\n }\r\n\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n\r\n if (deviceType === DeviceType.Touch) {\r\n this._onDeviceDisconnected(deviceType, deviceSlot);\r\n }\r\n }\r\n };\r\n\r\n this._pointerCancelEvent = (evt) => {\r\n if (evt.pointerType === \"mouse\") {\r\n const pointer = this._inputs[DeviceType.Mouse][0];\r\n\r\n if (this._mouseId >= 0 && this._elementToAttachTo.hasPointerCapture?.(this._mouseId)) {\r\n this._elementToAttachTo.releasePointerCapture(this._mouseId);\r\n }\r\n\r\n for (let inputIndex = PointerInput.LeftClick; inputIndex <= PointerInput.BrowserForward; inputIndex++) {\r\n if (pointer[inputIndex] === 1) {\r\n pointer[inputIndex] = 0;\r\n\r\n const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Mouse, 0, inputIndex, 0, this, this._elementToAttachTo);\r\n\r\n this._onInputChanged(DeviceType.Mouse, 0, deviceEvent);\r\n }\r\n }\r\n } else {\r\n const deviceSlot = this._activeTouchIds.indexOf(evt.pointerId);\r\n\r\n // If we're getting a pointercancel event for a touch that isn't active, just return\r\n if (deviceSlot === -1) {\r\n return;\r\n }\r\n\r\n if (this._elementToAttachTo.hasPointerCapture?.(evt.pointerId)) {\r\n this._elementToAttachTo.releasePointerCapture(evt.pointerId);\r\n }\r\n\r\n this._inputs[DeviceType.Touch][deviceSlot][PointerInput.LeftClick] = 0;\r\n\r\n const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(\r\n DeviceType.Touch,\r\n deviceSlot,\r\n PointerInput.LeftClick,\r\n 0,\r\n this,\r\n this._elementToAttachTo,\r\n evt.pointerId\r\n );\r\n\r\n this._onInputChanged(DeviceType.Touch, deviceSlot, deviceEvent);\r\n\r\n this._activeTouchIds[deviceSlot] = -1;\r\n this._onDeviceDisconnected(DeviceType.Touch, deviceSlot);\r\n }\r\n };\r\n\r\n // Set Wheel Event Name, code originally from scene.inputManager\r\n this._wheelEventName =\r\n \"onwheel\" in document.createElement(\"div\")\r\n ? \"wheel\" // Modern browsers support \"wheel\"\r\n : (<any>document).onmousewheel !== undefined\r\n ? \"mousewheel\" // Webkit and IE support at least \"mousewheel\"\r\n : \"DOMMouseScroll\"; // let's assume that remaining browsers are older Firefox\r\n\r\n // Code originally in scene.inputManager.ts\r\n // Chrome reports warning in console if wheel listener doesn't set an explicit passive option.\r\n // IE11 only supports captureEvent:boolean, not options:object, and it defaults to false.\r\n // Feature detection technique copied from: https://github.com/github/eventlistener-polyfill (MIT license)\r\n let passiveSupported = false;\r\n const noop = function () {};\r\n\r\n try {\r\n const options = Object.defineProperty({}, \"passive\", {\r\n get: function () {\r\n passiveSupported = true;\r\n },\r\n });\r\n\r\n this._elementToAttachTo.addEventListener(\"test\", noop, options);\r\n this._elementToAttachTo.removeEventListener(\"test\", noop, options);\r\n } catch (e) {\r\n /* */\r\n }\r\n\r\n this._pointerBlurEvent = () => {\r\n // Handle mouse buttons\r\n if (this.isDeviceAvailable(DeviceType.Mouse)) {\r\n const pointer = this._inputs[DeviceType.Mouse][0];\r\n\r\n if (this._mouseId >= 0 && this._elementToAttachTo.hasPointerCapture?.(this._mouseId)) {\r\n this._elementToAttachTo.releasePointerCapture(this._mouseId);\r\n }\r\n\r\n for (let inputIndex = PointerInput.LeftClick; inputIndex <= PointerInput.BrowserForward; inputIndex++) {\r\n if (pointer[inputIndex] === 1) {\r\n pointer[inputIndex] = 0;\r\n\r\n const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Mouse, 0, inputIndex, 0, this, this._elementToAttachTo);\r\n\r\n this._onInputChanged(DeviceType.Mouse, 0, deviceEvent);\r\n }\r\n }\r\n }\r\n\r\n // Handle Active Touches\r\n if (this.isDeviceAvailable(DeviceType.Touch)) {\r\n const pointer = this._inputs[DeviceType.Touch];\r\n\r\n for (let deviceSlot = 0; deviceSlot < this._activeTouchIds.length; deviceSlot++) {\r\n const pointerId = this._activeTouchIds[deviceSlot];\r\n\r\n if (this._elementToAttachTo.hasPointerCapture?.(pointerId)) {\r\n this._elementToAttachTo.releasePointerCapture(pointerId);\r\n }\r\n\r\n if (pointerId !== -1 && pointer[deviceSlot]?.[PointerInput.LeftClick] === 1) {\r\n pointer[deviceSlot][PointerInput.LeftClick] = 0;\r\n\r\n const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(\r\n DeviceType.Touch,\r\n deviceSlot,\r\n PointerInput.LeftClick,\r\n 0,\r\n this,\r\n this._elementToAttachTo,\r\n pointerId\r\n );\r\n\r\n this._onInputChanged(DeviceType.Touch, deviceSlot, deviceEvent);\r\n\r\n this._activeTouchIds[deviceSlot] = -1;\r\n this._onDeviceDisconnected(DeviceType.Touch, deviceSlot);\r\n }\r\n }\r\n }\r\n };\r\n\r\n this._pointerWheelEvent = (evt) => {\r\n const deviceType = DeviceType.Mouse;\r\n const deviceSlot = 0;\r\n\r\n if (!this._inputs[deviceType]) {\r\n this._inputs[deviceType] = [];\r\n }\r\n\r\n if (!this._inputs[deviceType][deviceSlot]) {\r\n this._pointerActive = true;\r\n this._registerDevice(deviceType, deviceSlot, MAX_POINTER_INPUTS);\r\n }\r\n\r\n const pointer = this._inputs[deviceType][deviceSlot];\r\n if (pointer) {\r\n pointer[PointerInput.MouseWheelX] = evt.deltaX || 0;\r\n pointer[PointerInput.MouseWheelY] = evt.deltaY || evt.wheelDelta || 0;\r\n pointer[PointerInput.MouseWheelZ] = evt.deltaZ || 0;\r\n\r\n const deviceEvent = evt as IUIEvent;\r\n // By default, there is no pointerId for mouse wheel events so we'll add one here\r\n // This logic was originally in the InputManager but was added here to make the\r\n // InputManager more platform-agnostic\r\n if (evt.pointerId === undefined) {\r\n evt.pointerId = this._mouseId;\r\n }\r\n\r\n if (pointer[PointerInput.MouseWheelX] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelX;\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n }\r\n if (pointer[PointerInput.MouseWheelY] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelY;\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n }\r\n if (pointer[PointerInput.MouseWheelZ] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelZ;\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n }\r\n }\r\n };\r\n\r\n // Workaround for MacOS Chromium Browsers for lost pointer capture bug\r\n if (this._usingMacOS && this._isUsingChromium) {\r\n this._pointerMacOSChromeOutEvent = (evt) => {\r\n if (evt.buttons > 1) {\r\n this._pointerCancelEvent(evt);\r\n }\r\n };\r\n this._elementToAttachTo.addEventListener(\"lostpointercapture\", this._pointerMacOSChromeOutEvent);\r\n }\r\n\r\n this._elementToAttachTo.addEventListener(this._eventPrefix + \"move\", this._pointerMoveEvent);\r\n this._elementToAttachTo.addEventListener(this._eventPrefix + \"down\", this._pointerDownEvent);\r\n this._elementToAttachTo.addEventListener(this._eventPrefix + \"up\", this._pointerUpEvent);\r\n this._elementToAttachTo.addEventListener(this._eventPrefix + \"cancel\", this._pointerCancelEvent);\r\n this._elementToAttachTo.addEventListener(\"blur\", this._pointerBlurEvent);\r\n this._elementToAttachTo.addEventListener(this._wheelEventName, this._pointerWheelEvent, passiveSupported ? { passive: false } : false);\r\n\r\n // Since there's no up or down event for mouse wheel or delta x/y, clear mouse values at end of frame\r\n this._pointerInputClearObserver = this._engine.onEndFrameObservable.add(() => {\r\n if (this.isDeviceAvailable(DeviceType.Mouse)) {\r\n const pointer = this._inputs[DeviceType.Mouse][0];\r\n pointer[PointerInput.MouseWheelX] = 0;\r\n pointer[PointerInput.MouseWheelY] = 0;\r\n pointer[PointerInput.MouseWheelZ] = 0;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Handle all actions that come from gamepad interaction\r\n */\r\n private _handleGamepadActions(): void {\r\n this._gamepadConnectedEvent = (evt: any) => {\r\n this._addGamePad(evt.gamepad);\r\n };\r\n\r\n this._gamepadDisconnectedEvent = (evt: any) => {\r\n if (this._gamepads) {\r\n const deviceType = this._getGamepadDeviceType(evt.gamepad.id);\r\n const deviceSlot = evt.gamepad.index;\r\n\r\n this._unregisterDevice(deviceType, deviceSlot);\r\n delete this._gamepads[deviceSlot];\r\n }\r\n };\r\n\r\n window.addEventListener(\"gamepadconnected\", this._gamepadConnectedEvent);\r\n window.addEventListener(\"gamepaddisconnected\", this._gamepadDisconnectedEvent);\r\n }\r\n\r\n /**\r\n * Update all non-event based devices with each frame\r\n * @param deviceType Enum specifying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n */\r\n private _updateDevice(deviceType: DeviceType, deviceSlot: number, inputIndex: number): void {\r\n // Gamepads\r\n const gp = navigator.getGamepads()[deviceSlot];\r\n\r\n if (gp && deviceType === this._gamepads[deviceSlot]) {\r\n const device = this._inputs[deviceType][deviceSlot];\r\n\r\n if (inputIndex >= gp.buttons.length) {\r\n device[inputIndex] = gp.axes[inputIndex - gp.buttons.length].valueOf();\r\n } else {\r\n device[inputIndex] = gp.buttons[inputIndex].value;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets DeviceType from the device name\r\n * @param deviceName Name of Device from DeviceInputSystem\r\n * @returns DeviceType enum value\r\n */\r\n private _getGamepadDeviceType(deviceName: string): DeviceType {\r\n if (deviceName.indexOf(\"054c\") !== -1) {\r\n // DualShock 4 Gamepad\r\n return deviceName.indexOf(\"0ce6\") !== -1 ? DeviceType.DualSense : DeviceType.DualShock;\r\n } else if (deviceName.indexOf(\"Xbox One\") !== -1 || deviceName.search(\"Xbox 360\") !== -1 || deviceName.search(\"xinput\") !== -1) {\r\n // Xbox Gamepad\r\n return DeviceType.Xbox;\r\n } else if (deviceName.indexOf(\"057e\") !== -1) {\r\n // Switch Gamepad\r\n return DeviceType.Switch;\r\n }\r\n\r\n return DeviceType.Generic;\r\n }\r\n\r\n /**\r\n * Get DeviceType from a given pointer/mouse/touch event.\r\n * @param evt PointerEvent to evaluate\r\n * @returns DeviceType interpreted from event\r\n */\r\n private _getPointerType(evt: any): DeviceType {\r\n let deviceType = DeviceType.Mouse;\r\n\r\n if (evt.pointerType === \"touch\" || evt.pointerType === \"pen\" || evt.touches) {\r\n deviceType = DeviceType.Touch;\r\n }\r\n\r\n return deviceType;\r\n }\r\n}\r\n"]}
|