@onerjs/core 8.27.14 → 8.28.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.
Files changed (55) hide show
  1. package/Behaviors/Meshes/handConstraintBehavior.js.map +1 -1
  2. package/Buffers/bufferUtils.d.ts +1 -2
  3. package/Buffers/bufferUtils.js +3 -4
  4. package/Buffers/bufferUtils.js.map +1 -1
  5. package/Engines/abstractEngine.js +2 -2
  6. package/Engines/abstractEngine.js.map +1 -1
  7. package/Materials/Textures/texture.js +9 -2
  8. package/Materials/Textures/texture.js.map +1 -1
  9. package/Meshes/Compression/dracoEncoder.js +1 -1
  10. package/Meshes/Compression/dracoEncoder.js.map +1 -1
  11. package/Meshes/geometry.js +1 -1
  12. package/Meshes/geometry.js.map +1 -1
  13. package/Particles/gpuParticleSystem.js +2 -1
  14. package/Particles/gpuParticleSystem.js.map +1 -1
  15. package/Particles/thinParticleSystem.js +4 -3
  16. package/Particles/thinParticleSystem.js.map +1 -1
  17. package/Physics/v2/physicsAggregate.d.ts +5 -0
  18. package/Physics/v2/physicsAggregate.js +26 -0
  19. package/Physics/v2/physicsAggregate.js.map +1 -1
  20. package/Rendering/geometryBufferRenderer.js +6 -1
  21. package/Rendering/geometryBufferRenderer.js.map +1 -1
  22. package/Shaders/geometry.fragment.js +3 -1
  23. package/Shaders/geometry.fragment.js.map +1 -1
  24. package/Shaders/geometry.vertex.js +10 -2
  25. package/Shaders/geometry.vertex.js.map +1 -1
  26. package/ShadersWGSL/geometry.fragment.js +3 -1
  27. package/ShadersWGSL/geometry.fragment.js.map +1 -1
  28. package/ShadersWGSL/geometry.vertex.js +10 -2
  29. package/ShadersWGSL/geometry.vertex.js.map +1 -1
  30. package/XR/features/WebXRAnchorSystem.d.ts +1 -1
  31. package/XR/features/WebXRBackgroundRemover.d.ts +1 -1
  32. package/XR/features/WebXRControllerMovement.d.ts +1 -1
  33. package/XR/features/WebXRControllerPhysics.d.ts +1 -1
  34. package/XR/features/WebXRControllerPointerSelection.d.ts +1 -1
  35. package/XR/features/WebXRControllerTeleportation.d.ts +1 -1
  36. package/XR/features/WebXRDOMOverlay.d.ts +1 -1
  37. package/XR/features/WebXRDepthSensing.d.ts +1 -1
  38. package/XR/features/WebXREyeTracking.d.ts +1 -1
  39. package/XR/features/WebXRFeaturePointSystem.d.ts +1 -1
  40. package/XR/features/WebXRHandTracking.d.ts +1 -1
  41. package/XR/features/WebXRHitTest.d.ts +1 -1
  42. package/XR/features/WebXRHitTestLegacy.d.ts +1 -1
  43. package/XR/features/WebXRImageTracking.d.ts +1 -1
  44. package/XR/features/WebXRLayers.d.ts +1 -1
  45. package/XR/features/WebXRLightEstimation.d.ts +1 -1
  46. package/XR/features/WebXRMeshDetector.d.ts +1 -1
  47. package/XR/features/WebXRNearInteraction.d.ts +1 -1
  48. package/XR/features/WebXRPlaneDetector.d.ts +1 -1
  49. package/XR/features/WebXRRawCameraAccess.d.ts +1 -1
  50. package/XR/features/WebXRSpaceWarp.d.ts +1 -1
  51. package/XR/webXRDefaultExperience.js +1 -1
  52. package/XR/webXRDefaultExperience.js.map +1 -1
  53. package/XR/webXRFeaturesManager.d.ts +116 -27
  54. package/XR/webXRFeaturesManager.js.map +1 -1
  55. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"handConstraintBehavior.js","sourceRoot":"","sources":["../../../../../dev/core/src/Behaviors/Meshes/handConstraintBehavior.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AASjE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAE1E,OAAO,EAAE,KAAK,EAAE,4BAAwB;AAExC;;GAEG;AACH,MAAM,CAAN,IAAkB,kBAiBjB;AAjBD,WAAkB,kBAAkB;IAChC;;OAEG;IACH,qFAAiB,CAAA;IACjB;;OAEG;IACH,yEAAW,CAAA;IACX;;OAEG;IACH,uEAAU,CAAA;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L,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,IAAI,WAAW,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACI,MAAM;QACT,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAC3E,CAAC;IAED;;;OAGG;IACI,kBAAkB,CAAC,EAAgD;QACtE,MAAM,eAAe,GAA0B,EAA4B,CAAC,eAAe,CAAC,CAAC,CAAE,EAA4B,CAAC,eAAe,CAAC,CAAC,CAAE,EAA2B,CAAC;QAC3K,IAAI,CAAC,eAAe,EAAE,CAAC;YACnB,KAAK,CAAC,KAAK,CAAC,sFAAsF,CAAC,CAAC;QACxG,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC;gBACD,IAAI,CAAC,YAAY,GAAG,eAAe,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,YAAY,CAAqB,CAAC;YAC7G,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;YAEV,IAAI,CAAC;gBACD,IAAI,CAAC,aAAa,GAAG,eAAe,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,aAAa,CAAsB,CAAC;YAChH,CAAC;YAAC,MAAM,CAAC;gBACL,KAAK,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAC;YAC3E,CAAC;QACL,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { WebXRFeatureName } from \"../../XR/webXRFeaturesManager\";\r\nimport type { WebXRFeaturesManager } from \"../../XR/webXRFeaturesManager\";\r\nimport type { WebXREyeTracking } from \"../../XR/features/WebXREyeTracking\";\r\nimport type { WebXRHandTracking } from \"../../XR/features/WebXRHandTracking\";\r\nimport { WebXRHandJoint } from \"../../XR/features/WebXRHandTracking\";\r\nimport type { WebXRExperienceHelper } from \"../../XR/webXRExperienceHelper\";\r\nimport type { Behavior } from \"../behavior\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Quaternion, TmpVectors, Vector3 } from \"../../Maths/math.vector\";\r\nimport type { Ray } from \"../../Culling/ray\";\r\nimport { Tools } from \"core/Misc/tools\";\r\n\r\n/**\r\n * Zones around the hand\r\n */\r\nexport const enum HandConstraintZone {\r\n /**\r\n * Above finger tips\r\n */\r\n ABOVE_FINGER_TIPS,\r\n /**\r\n * Next to the thumb\r\n */\r\n RADIAL_SIDE,\r\n /**\r\n * Next to the pinky finger\r\n */\r\n ULNAR_SIDE,\r\n /**\r\n * Below the wrist\r\n */\r\n BELOW_WRIST,\r\n}\r\n\r\n/**\r\n * Orientations for the hand zones and for the attached node\r\n */\r\nexport const enum HandConstraintOrientation {\r\n /**\r\n * Orientation is towards the camera\r\n */\r\n LOOK_AT_CAMERA,\r\n /**\r\n * Orientation is determined by the rotation of the palm\r\n */\r\n HAND_ROTATION,\r\n}\r\n\r\n/**\r\n * Orientations for the hand zones and for the attached node\r\n */\r\nexport const enum HandConstraintVisibility {\r\n /**\r\n * Constraint is always visible\r\n */\r\n ALWAYS_VISIBLE,\r\n /**\r\n * Constraint is only visible when the palm is up\r\n */\r\n PALM_UP,\r\n /**\r\n * Constraint is only visible when the user is looking at the constraint.\r\n * Uses XR Eye Tracking if enabled/available, otherwise uses camera direction\r\n */\r\n GAZE_FOCUS,\r\n /**\r\n * Constraint is only visible when the palm is up and the user is looking at it\r\n */\r\n PALM_AND_GAZE,\r\n}\r\n\r\ntype HandPoseInfo = {\r\n position: Vector3;\r\n quaternion: Quaternion;\r\n id: string;\r\n};\r\n\r\n/**\r\n * Hand constraint behavior that makes the attached `TransformNode` follow hands in XR experiences.\r\n * @since 5.0.0\r\n */\r\nexport class HandConstraintBehavior implements Behavior<TransformNode> {\r\n private _scene: Scene;\r\n private _node: TransformNode;\r\n private _eyeTracking: Nullable<WebXREyeTracking>;\r\n private _handTracking: Nullable<WebXRHandTracking>;\r\n private _sceneRenderObserver: Nullable<Observer<Scene>> = null;\r\n private _zoneAxis: { [id: number]: Vector3 } = {};\r\n\r\n /**\r\n * Sets the HandConstraintVisibility level for the hand constraint\r\n */\r\n public handConstraintVisibility: HandConstraintVisibility = HandConstraintVisibility.PALM_AND_GAZE;\r\n\r\n /**\r\n * A number from 0.0 to 1.0, marking how restricted the direction the palm faces is for the attached node to be enabled.\r\n * A 1 means the palm must be directly facing the user before the node is enabled, a 0 means it is always enabled.\r\n * Used with HandConstraintVisibility.PALM_UP\r\n */\r\n public palmUpStrictness: number = 0.95;\r\n\r\n /**\r\n * The radius in meters around the center of the hand that the user must gaze inside for the attached node to be enabled and appear.\r\n * Used with HandConstraintVisibility.GAZE_FOCUS\r\n */\r\n public gazeProximityRadius: number = 0.15;\r\n\r\n /**\r\n * Offset distance from the hand in meters\r\n */\r\n public targetOffset: number = 0.1;\r\n\r\n /**\r\n * Where to place the node regarding the center of the hand.\r\n */\r\n public targetZone: HandConstraintZone = HandConstraintZone.ULNAR_SIDE;\r\n\r\n /**\r\n * Orientation mode of the 4 zones around the hand\r\n */\r\n public zoneOrientationMode: HandConstraintOrientation = HandConstraintOrientation.HAND_ROTATION;\r\n /**\r\n * Orientation mode of the node attached to this behavior\r\n */\r\n public nodeOrientationMode: HandConstraintOrientation = HandConstraintOrientation.HAND_ROTATION;\r\n\r\n /**\r\n * Set the hand this behavior should follow. If set to \"none\", it will follow any visible hand (prioritising the left one).\r\n */\r\n public handedness: XRHandedness = \"none\";\r\n\r\n /**\r\n * Rate of interpolation of position and rotation of the attached node.\r\n * Higher values will give a slower interpolation.\r\n */\r\n public lerpTime = 100;\r\n\r\n /**\r\n * Builds a hand constraint behavior\r\n */\r\n constructor() {\r\n // For a right hand\r\n this._zoneAxis[HandConstraintZone.ABOVE_FINGER_TIPS] = new Vector3(0, 1, 0);\r\n this._zoneAxis[HandConstraintZone.RADIAL_SIDE] = new Vector3(-1, 0, 0);\r\n this._zoneAxis[HandConstraintZone.ULNAR_SIDE] = new Vector3(1, 0, 0);\r\n this._zoneAxis[HandConstraintZone.BELOW_WRIST] = new Vector3(0, -1, 0);\r\n }\r\n\r\n /** gets or sets behavior's name */\r\n public get name() {\r\n return \"HandConstraint\";\r\n }\r\n\r\n /** Enable the behavior */\r\n public enable() {\r\n this._node.setEnabled(true);\r\n }\r\n\r\n /** Disable the behavior */\r\n public disable() {\r\n this._node.setEnabled(false);\r\n }\r\n\r\n private _getHandPose(): Nullable<HandPoseInfo> {\r\n if (!this._handTracking) {\r\n return null;\r\n }\r\n\r\n // Retrieve any available hand, starting by the left\r\n let hand;\r\n if (this.handedness === \"none\") {\r\n hand = this._handTracking.getHandByHandedness(\"left\") || this._handTracking.getHandByHandedness(\"right\");\r\n } else {\r\n hand = this._handTracking.getHandByHandedness(this.handedness);\r\n }\r\n\r\n if (hand) {\r\n const pinkyMetacarpal = hand.getJointMesh(WebXRHandJoint.PINKY_FINGER_METACARPAL);\r\n const middleMetacarpal = hand.getJointMesh(WebXRHandJoint.MIDDLE_FINGER_METACARPAL);\r\n const wrist = hand.getJointMesh(WebXRHandJoint.WRIST);\r\n\r\n if (wrist && middleMetacarpal && pinkyMetacarpal) {\r\n const handPose: HandPoseInfo = { position: middleMetacarpal.absolutePosition, quaternion: new Quaternion(), id: hand.xrController.uniqueId };\r\n\r\n // palm forward\r\n const up = TmpVectors.Vector3[0];\r\n const forward = TmpVectors.Vector3[1];\r\n const left = TmpVectors.Vector3[2];\r\n up.copyFrom(middleMetacarpal.absolutePosition).subtractInPlace(wrist.absolutePosition).normalize();\r\n forward.copyFrom(pinkyMetacarpal.absolutePosition).subtractInPlace(middleMetacarpal.absolutePosition).normalize();\r\n\r\n // Create vectors for a rotation quaternion, where forward points out from the palm\r\n Vector3.CrossToRef(up, forward, forward);\r\n Vector3.CrossToRef(forward, up, left);\r\n\r\n Quaternion.FromLookDirectionLHToRef(forward, up, handPose.quaternion);\r\n\r\n return handPose;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Initializes the hand constraint behavior\r\n */\r\n public init() {}\r\n\r\n /**\r\n * Attaches the hand constraint to a `TransformNode`\r\n * @param node defines the node to attach the behavior to\r\n */\r\n public attach(node: TransformNode): void {\r\n this._node = node;\r\n this._scene = node.getScene();\r\n\r\n if (!this._node.rotationQuaternion) {\r\n this._node.rotationQuaternion = Quaternion.RotationYawPitchRoll(this._node.rotation.y, this._node.rotation.x, this._node.rotation.z);\r\n }\r\n\r\n let lastTick = Date.now();\r\n this._sceneRenderObserver = this._scene.onBeforeRenderObservable.add(() => {\r\n const pose = this._getHandPose();\r\n\r\n this._node.reservedDataStore = this._node.reservedDataStore || {};\r\n this._node.reservedDataStore.nearInteraction = this._node.reservedDataStore.nearInteraction || {};\r\n this._node.reservedDataStore.nearInteraction.excludedControllerId = null;\r\n\r\n if (pose) {\r\n const zoneOffset = TmpVectors.Vector3[0];\r\n const camera = this._scene.activeCamera;\r\n\r\n zoneOffset.copyFrom(this._zoneAxis[this.targetZone]);\r\n\r\n const cameraLookAtQuaternion = TmpVectors.Quaternion[0];\r\n if (camera && (this.zoneOrientationMode === HandConstraintOrientation.LOOK_AT_CAMERA || this.nodeOrientationMode === HandConstraintOrientation.LOOK_AT_CAMERA)) {\r\n const toCamera = TmpVectors.Vector3[1];\r\n toCamera.copyFrom(camera.position).subtractInPlace(pose.position).normalize();\r\n if (this._scene.useRightHandedSystem) {\r\n Quaternion.FromLookDirectionRHToRef(toCamera, Vector3.UpReadOnly, cameraLookAtQuaternion);\r\n } else {\r\n Quaternion.FromLookDirectionLHToRef(toCamera, Vector3.UpReadOnly, cameraLookAtQuaternion);\r\n }\r\n }\r\n\r\n if (this.zoneOrientationMode === HandConstraintOrientation.HAND_ROTATION) {\r\n pose.quaternion.toRotationMatrix(TmpVectors.Matrix[0]);\r\n } else {\r\n cameraLookAtQuaternion.toRotationMatrix(TmpVectors.Matrix[0]);\r\n }\r\n\r\n Vector3.TransformNormalToRef(zoneOffset, TmpVectors.Matrix[0], zoneOffset);\r\n zoneOffset.scaleInPlace(this.targetOffset);\r\n\r\n const targetPosition = TmpVectors.Vector3[2];\r\n const targetRotation = TmpVectors.Quaternion[1];\r\n targetPosition.copyFrom(pose.position).addInPlace(zoneOffset);\r\n\r\n if (this.nodeOrientationMode === HandConstraintOrientation.HAND_ROTATION) {\r\n targetRotation.copyFrom(pose.quaternion);\r\n } else {\r\n targetRotation.copyFrom(cameraLookAtQuaternion);\r\n }\r\n\r\n const elapsed = Date.now() - lastTick;\r\n\r\n Vector3.SmoothToRef(this._node.position, targetPosition, elapsed, this.lerpTime, this._node.position);\r\n Quaternion.SmoothToRef(this._node.rotationQuaternion!, targetRotation, elapsed, this.lerpTime, this._node.rotationQuaternion!);\r\n\r\n this._node.reservedDataStore.nearInteraction.excludedControllerId = pose.id;\r\n }\r\n\r\n this._setVisibility(pose);\r\n\r\n lastTick = Date.now();\r\n });\r\n }\r\n\r\n private _setVisibility(pose: Nullable<HandPoseInfo>) {\r\n let palmVisible = true;\r\n let gazeVisible = true;\r\n const camera = this._scene.activeCamera;\r\n\r\n if (camera) {\r\n const cameraForward = camera.getForwardRay();\r\n\r\n if (this.handConstraintVisibility === HandConstraintVisibility.GAZE_FOCUS || this.handConstraintVisibility === HandConstraintVisibility.PALM_AND_GAZE) {\r\n gazeVisible = false;\r\n let gaze: Ray | undefined;\r\n if (this._eyeTracking) {\r\n gaze = this._eyeTracking.getEyeGaze()!;\r\n }\r\n\r\n gaze = gaze || cameraForward;\r\n\r\n const gazeToBehavior = TmpVectors.Vector3[0];\r\n if (pose) {\r\n pose.position.subtractToRef(gaze.origin, gazeToBehavior);\r\n } else {\r\n this._node.getAbsolutePosition().subtractToRef(gaze.origin, gazeToBehavior);\r\n }\r\n\r\n const projectedDistance = Vector3.Dot(gazeToBehavior, gaze.direction);\r\n const projectedSquared = projectedDistance * projectedDistance;\r\n\r\n if (projectedDistance > 0) {\r\n const radiusSquared = gazeToBehavior.lengthSquared() - projectedSquared;\r\n if (radiusSquared < this.gazeProximityRadius * this.gazeProximityRadius) {\r\n gazeVisible = true;\r\n }\r\n }\r\n }\r\n\r\n if (this.handConstraintVisibility === HandConstraintVisibility.PALM_UP || this.handConstraintVisibility === HandConstraintVisibility.PALM_AND_GAZE) {\r\n palmVisible = false;\r\n\r\n if (pose) {\r\n const palmDirection = TmpVectors.Vector3[0];\r\n Vector3.LeftHandedForwardReadOnly.rotateByQuaternionToRef(pose.quaternion, palmDirection);\r\n\r\n if (Vector3.Dot(palmDirection, cameraForward.direction) > this.palmUpStrictness * 2 - 1) {\r\n palmVisible = true;\r\n }\r\n }\r\n }\r\n }\r\n\r\n this._node.setEnabled(palmVisible && gazeVisible);\r\n }\r\n\r\n /**\r\n * Detaches the behavior from the `TransformNode`\r\n */\r\n public detach(): void {\r\n this._scene.onBeforeRenderObservable.remove(this._sceneRenderObserver);\r\n }\r\n\r\n /**\r\n * Links the behavior to the XR experience in which to retrieve hand transform information.\r\n * @param xr xr experience\r\n */\r\n public linkToXRExperience(xr: WebXRExperienceHelper | WebXRFeaturesManager) {\r\n const featuresManager: WebXRFeaturesManager = (xr as WebXRExperienceHelper).featuresManager ? (xr as WebXRExperienceHelper).featuresManager : (xr as WebXRFeaturesManager);\r\n if (!featuresManager) {\r\n Tools.Error(\"XR features manager must be available or provided directly for the Hand Menu to work\");\r\n } else {\r\n try {\r\n this._eyeTracking = featuresManager.getEnabledFeature(WebXRFeatureName.EYE_TRACKING) as WebXREyeTracking;\r\n } catch {}\r\n\r\n try {\r\n this._handTracking = featuresManager.getEnabledFeature(WebXRFeatureName.HAND_TRACKING) as WebXRHandTracking;\r\n } catch {\r\n Tools.Error(\"Hand tracking must be enabled for the Hand Menu to work\");\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"handConstraintBehavior.js","sourceRoot":"","sources":["../../../../../dev/core/src/Behaviors/Meshes/handConstraintBehavior.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B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,CAAC,yBAAyB,CAAC,uBAAuB,CAAC,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;oBAE1F,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,aAAa,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,gBAAgB,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;wBACtF,WAAW,GAAG,IAAI,CAAC;oBACvB,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,IAAI,WAAW,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACI,MAAM;QACT,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAC3E,CAAC;IAED;;;OAGG;IACI,kBAAkB,CAAC,EAAgD;QACtE,MAAM,eAAe,GAA0B,EAA4B,CAAC,eAAe,CAAC,CAAC,CAAE,EAA4B,CAAC,eAAe,CAAC,CAAC,CAAE,EAA2B,CAAC;QAC3K,IAAI,CAAC,eAAe,EAAE,CAAC;YACnB,KAAK,CAAC,KAAK,CAAC,sFAAsF,CAAC,CAAC;QACxG,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC;gBACD,IAAI,CAAC,YAAY,GAAG,eAAe,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;YACzF,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;YAEV,IAAI,CAAC;gBACD,IAAI,CAAC,aAAa,GAAG,eAAe,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;YAC3F,CAAC;YAAC,MAAM,CAAC;gBACL,KAAK,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAC;YAC3E,CAAC;QACL,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { WebXRFeatureName } from \"../../XR/webXRFeaturesManager\";\r\nimport type { WebXRFeaturesManager } from \"../../XR/webXRFeaturesManager\";\r\nimport type { WebXREyeTracking } from \"../../XR/features/WebXREyeTracking\";\r\nimport type { WebXRHandTracking } from \"../../XR/features/WebXRHandTracking\";\r\nimport { WebXRHandJoint } from \"../../XR/features/WebXRHandTracking\";\r\nimport type { WebXRExperienceHelper } from \"../../XR/webXRExperienceHelper\";\r\nimport type { Behavior } from \"../behavior\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Quaternion, TmpVectors, Vector3 } from \"../../Maths/math.vector\";\r\nimport type { Ray } from \"../../Culling/ray\";\r\nimport { Tools } from \"core/Misc/tools\";\r\n\r\n/**\r\n * Zones around the hand\r\n */\r\nexport const enum HandConstraintZone {\r\n /**\r\n * Above finger tips\r\n */\r\n ABOVE_FINGER_TIPS,\r\n /**\r\n * Next to the thumb\r\n */\r\n RADIAL_SIDE,\r\n /**\r\n * Next to the pinky finger\r\n */\r\n ULNAR_SIDE,\r\n /**\r\n * Below the wrist\r\n */\r\n BELOW_WRIST,\r\n}\r\n\r\n/**\r\n * Orientations for the hand zones and for the attached node\r\n */\r\nexport const enum HandConstraintOrientation {\r\n /**\r\n * Orientation is towards the camera\r\n */\r\n LOOK_AT_CAMERA,\r\n /**\r\n * Orientation is determined by the rotation of the palm\r\n */\r\n HAND_ROTATION,\r\n}\r\n\r\n/**\r\n * Orientations for the hand zones and for the attached node\r\n */\r\nexport const enum HandConstraintVisibility {\r\n /**\r\n * Constraint is always visible\r\n */\r\n ALWAYS_VISIBLE,\r\n /**\r\n * Constraint is only visible when the palm is up\r\n */\r\n PALM_UP,\r\n /**\r\n * Constraint is only visible when the user is looking at the constraint.\r\n * Uses XR Eye Tracking if enabled/available, otherwise uses camera direction\r\n */\r\n GAZE_FOCUS,\r\n /**\r\n * Constraint is only visible when the palm is up and the user is looking at it\r\n */\r\n PALM_AND_GAZE,\r\n}\r\n\r\ntype HandPoseInfo = {\r\n position: Vector3;\r\n quaternion: Quaternion;\r\n id: string;\r\n};\r\n\r\n/**\r\n * Hand constraint behavior that makes the attached `TransformNode` follow hands in XR experiences.\r\n * @since 5.0.0\r\n */\r\nexport class HandConstraintBehavior implements Behavior<TransformNode> {\r\n private _scene: Scene;\r\n private _node: TransformNode;\r\n private _eyeTracking: Nullable<WebXREyeTracking>;\r\n private _handTracking: Nullable<WebXRHandTracking>;\r\n private _sceneRenderObserver: Nullable<Observer<Scene>> = null;\r\n private _zoneAxis: { [id: number]: Vector3 } = {};\r\n\r\n /**\r\n * Sets the HandConstraintVisibility level for the hand constraint\r\n */\r\n public handConstraintVisibility: HandConstraintVisibility = HandConstraintVisibility.PALM_AND_GAZE;\r\n\r\n /**\r\n * A number from 0.0 to 1.0, marking how restricted the direction the palm faces is for the attached node to be enabled.\r\n * A 1 means the palm must be directly facing the user before the node is enabled, a 0 means it is always enabled.\r\n * Used with HandConstraintVisibility.PALM_UP\r\n */\r\n public palmUpStrictness: number = 0.95;\r\n\r\n /**\r\n * The radius in meters around the center of the hand that the user must gaze inside for the attached node to be enabled and appear.\r\n * Used with HandConstraintVisibility.GAZE_FOCUS\r\n */\r\n public gazeProximityRadius: number = 0.15;\r\n\r\n /**\r\n * Offset distance from the hand in meters\r\n */\r\n public targetOffset: number = 0.1;\r\n\r\n /**\r\n * Where to place the node regarding the center of the hand.\r\n */\r\n public targetZone: HandConstraintZone = HandConstraintZone.ULNAR_SIDE;\r\n\r\n /**\r\n * Orientation mode of the 4 zones around the hand\r\n */\r\n public zoneOrientationMode: HandConstraintOrientation = HandConstraintOrientation.HAND_ROTATION;\r\n /**\r\n * Orientation mode of the node attached to this behavior\r\n */\r\n public nodeOrientationMode: HandConstraintOrientation = HandConstraintOrientation.HAND_ROTATION;\r\n\r\n /**\r\n * Set the hand this behavior should follow. If set to \"none\", it will follow any visible hand (prioritising the left one).\r\n */\r\n public handedness: XRHandedness = \"none\";\r\n\r\n /**\r\n * Rate of interpolation of position and rotation of the attached node.\r\n * Higher values will give a slower interpolation.\r\n */\r\n public lerpTime = 100;\r\n\r\n /**\r\n * Builds a hand constraint behavior\r\n */\r\n constructor() {\r\n // For a right hand\r\n this._zoneAxis[HandConstraintZone.ABOVE_FINGER_TIPS] = new Vector3(0, 1, 0);\r\n this._zoneAxis[HandConstraintZone.RADIAL_SIDE] = new Vector3(-1, 0, 0);\r\n this._zoneAxis[HandConstraintZone.ULNAR_SIDE] = new Vector3(1, 0, 0);\r\n this._zoneAxis[HandConstraintZone.BELOW_WRIST] = new Vector3(0, -1, 0);\r\n }\r\n\r\n /** gets or sets behavior's name */\r\n public get name() {\r\n return \"HandConstraint\";\r\n }\r\n\r\n /** Enable the behavior */\r\n public enable() {\r\n this._node.setEnabled(true);\r\n }\r\n\r\n /** Disable the behavior */\r\n public disable() {\r\n this._node.setEnabled(false);\r\n }\r\n\r\n private _getHandPose(): Nullable<HandPoseInfo> {\r\n if (!this._handTracking) {\r\n return null;\r\n }\r\n\r\n // Retrieve any available hand, starting by the left\r\n let hand;\r\n if (this.handedness === \"none\") {\r\n hand = this._handTracking.getHandByHandedness(\"left\") || this._handTracking.getHandByHandedness(\"right\");\r\n } else {\r\n hand = this._handTracking.getHandByHandedness(this.handedness);\r\n }\r\n\r\n if (hand) {\r\n const pinkyMetacarpal = hand.getJointMesh(WebXRHandJoint.PINKY_FINGER_METACARPAL);\r\n const middleMetacarpal = hand.getJointMesh(WebXRHandJoint.MIDDLE_FINGER_METACARPAL);\r\n const wrist = hand.getJointMesh(WebXRHandJoint.WRIST);\r\n\r\n if (wrist && middleMetacarpal && pinkyMetacarpal) {\r\n const handPose: HandPoseInfo = { position: middleMetacarpal.absolutePosition, quaternion: new Quaternion(), id: hand.xrController.uniqueId };\r\n\r\n // palm forward\r\n const up = TmpVectors.Vector3[0];\r\n const forward = TmpVectors.Vector3[1];\r\n const left = TmpVectors.Vector3[2];\r\n up.copyFrom(middleMetacarpal.absolutePosition).subtractInPlace(wrist.absolutePosition).normalize();\r\n forward.copyFrom(pinkyMetacarpal.absolutePosition).subtractInPlace(middleMetacarpal.absolutePosition).normalize();\r\n\r\n // Create vectors for a rotation quaternion, where forward points out from the palm\r\n Vector3.CrossToRef(up, forward, forward);\r\n Vector3.CrossToRef(forward, up, left);\r\n\r\n Quaternion.FromLookDirectionLHToRef(forward, up, handPose.quaternion);\r\n\r\n return handPose;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Initializes the hand constraint behavior\r\n */\r\n public init() {}\r\n\r\n /**\r\n * Attaches the hand constraint to a `TransformNode`\r\n * @param node defines the node to attach the behavior to\r\n */\r\n public attach(node: TransformNode): void {\r\n this._node = node;\r\n this._scene = node.getScene();\r\n\r\n if (!this._node.rotationQuaternion) {\r\n this._node.rotationQuaternion = Quaternion.RotationYawPitchRoll(this._node.rotation.y, this._node.rotation.x, this._node.rotation.z);\r\n }\r\n\r\n let lastTick = Date.now();\r\n this._sceneRenderObserver = this._scene.onBeforeRenderObservable.add(() => {\r\n const pose = this._getHandPose();\r\n\r\n this._node.reservedDataStore = this._node.reservedDataStore || {};\r\n this._node.reservedDataStore.nearInteraction = this._node.reservedDataStore.nearInteraction || {};\r\n this._node.reservedDataStore.nearInteraction.excludedControllerId = null;\r\n\r\n if (pose) {\r\n const zoneOffset = TmpVectors.Vector3[0];\r\n const camera = this._scene.activeCamera;\r\n\r\n zoneOffset.copyFrom(this._zoneAxis[this.targetZone]);\r\n\r\n const cameraLookAtQuaternion = TmpVectors.Quaternion[0];\r\n if (camera && (this.zoneOrientationMode === HandConstraintOrientation.LOOK_AT_CAMERA || this.nodeOrientationMode === HandConstraintOrientation.LOOK_AT_CAMERA)) {\r\n const toCamera = TmpVectors.Vector3[1];\r\n toCamera.copyFrom(camera.position).subtractInPlace(pose.position).normalize();\r\n if (this._scene.useRightHandedSystem) {\r\n Quaternion.FromLookDirectionRHToRef(toCamera, Vector3.UpReadOnly, cameraLookAtQuaternion);\r\n } else {\r\n Quaternion.FromLookDirectionLHToRef(toCamera, Vector3.UpReadOnly, cameraLookAtQuaternion);\r\n }\r\n }\r\n\r\n if (this.zoneOrientationMode === HandConstraintOrientation.HAND_ROTATION) {\r\n pose.quaternion.toRotationMatrix(TmpVectors.Matrix[0]);\r\n } else {\r\n cameraLookAtQuaternion.toRotationMatrix(TmpVectors.Matrix[0]);\r\n }\r\n\r\n Vector3.TransformNormalToRef(zoneOffset, TmpVectors.Matrix[0], zoneOffset);\r\n zoneOffset.scaleInPlace(this.targetOffset);\r\n\r\n const targetPosition = TmpVectors.Vector3[2];\r\n const targetRotation = TmpVectors.Quaternion[1];\r\n targetPosition.copyFrom(pose.position).addInPlace(zoneOffset);\r\n\r\n if (this.nodeOrientationMode === HandConstraintOrientation.HAND_ROTATION) {\r\n targetRotation.copyFrom(pose.quaternion);\r\n } else {\r\n targetRotation.copyFrom(cameraLookAtQuaternion);\r\n }\r\n\r\n const elapsed = Date.now() - lastTick;\r\n\r\n Vector3.SmoothToRef(this._node.position, targetPosition, elapsed, this.lerpTime, this._node.position);\r\n Quaternion.SmoothToRef(this._node.rotationQuaternion!, targetRotation, elapsed, this.lerpTime, this._node.rotationQuaternion!);\r\n\r\n this._node.reservedDataStore.nearInteraction.excludedControllerId = pose.id;\r\n }\r\n\r\n this._setVisibility(pose);\r\n\r\n lastTick = Date.now();\r\n });\r\n }\r\n\r\n private _setVisibility(pose: Nullable<HandPoseInfo>) {\r\n let palmVisible = true;\r\n let gazeVisible = true;\r\n const camera = this._scene.activeCamera;\r\n\r\n if (camera) {\r\n const cameraForward = camera.getForwardRay();\r\n\r\n if (this.handConstraintVisibility === HandConstraintVisibility.GAZE_FOCUS || this.handConstraintVisibility === HandConstraintVisibility.PALM_AND_GAZE) {\r\n gazeVisible = false;\r\n let gaze: Ray | undefined;\r\n if (this._eyeTracking) {\r\n gaze = this._eyeTracking.getEyeGaze()!;\r\n }\r\n\r\n gaze = gaze || cameraForward;\r\n\r\n const gazeToBehavior = TmpVectors.Vector3[0];\r\n if (pose) {\r\n pose.position.subtractToRef(gaze.origin, gazeToBehavior);\r\n } else {\r\n this._node.getAbsolutePosition().subtractToRef(gaze.origin, gazeToBehavior);\r\n }\r\n\r\n const projectedDistance = Vector3.Dot(gazeToBehavior, gaze.direction);\r\n const projectedSquared = projectedDistance * projectedDistance;\r\n\r\n if (projectedDistance > 0) {\r\n const radiusSquared = gazeToBehavior.lengthSquared() - projectedSquared;\r\n if (radiusSquared < this.gazeProximityRadius * this.gazeProximityRadius) {\r\n gazeVisible = true;\r\n }\r\n }\r\n }\r\n\r\n if (this.handConstraintVisibility === HandConstraintVisibility.PALM_UP || this.handConstraintVisibility === HandConstraintVisibility.PALM_AND_GAZE) {\r\n palmVisible = false;\r\n\r\n if (pose) {\r\n const palmDirection = TmpVectors.Vector3[0];\r\n Vector3.LeftHandedForwardReadOnly.rotateByQuaternionToRef(pose.quaternion, palmDirection);\r\n\r\n if (Vector3.Dot(palmDirection, cameraForward.direction) > this.palmUpStrictness * 2 - 1) {\r\n palmVisible = true;\r\n }\r\n }\r\n }\r\n }\r\n\r\n this._node.setEnabled(palmVisible && gazeVisible);\r\n }\r\n\r\n /**\r\n * Detaches the behavior from the `TransformNode`\r\n */\r\n public detach(): void {\r\n this._scene.onBeforeRenderObservable.remove(this._sceneRenderObserver);\r\n }\r\n\r\n /**\r\n * Links the behavior to the XR experience in which to retrieve hand transform information.\r\n * @param xr xr experience\r\n */\r\n public linkToXRExperience(xr: WebXRExperienceHelper | WebXRFeaturesManager) {\r\n const featuresManager: WebXRFeaturesManager = (xr as WebXRExperienceHelper).featuresManager ? (xr as WebXRExperienceHelper).featuresManager : (xr as WebXRFeaturesManager);\r\n if (!featuresManager) {\r\n Tools.Error(\"XR features manager must be available or provided directly for the Hand Menu to work\");\r\n } else {\r\n try {\r\n this._eyeTracking = featuresManager.getEnabledFeature(WebXRFeatureName.EYE_TRACKING);\r\n } catch {}\r\n\r\n try {\r\n this._handTracking = featuresManager.getEnabledFeature(WebXRFeatureName.HAND_TRACKING);\r\n } catch {\r\n Tools.Error(\"Hand tracking must be enabled for the Hand Menu to work\");\r\n }\r\n }\r\n }\r\n}\r\n"]}
@@ -48,12 +48,11 @@ export declare function GetFloatData(data: DataArray, size: number, type: number
48
48
  * @param type the component type
49
49
  * @param byteOffset the byte offset of the data
50
50
  * @param byteStride the byte stride of the data
51
- * @param normalized whether the data is normalized
52
51
  * @param totalVertices number of vertices in the buffer to take into account
53
52
  * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
54
53
  * @returns a typed array containing vertex data
55
54
  */
56
- export declare function GetTypedArrayData(data: DataArray, size: number, type: number, byteOffset: number, byteStride: number, normalized: boolean, totalVertices: number, forceCopy?: boolean): VertexDataTypedArray;
55
+ export declare function GetTypedArrayData(data: DataArray, size: number, type: number, byteOffset: number, byteStride: number, totalVertices: number, forceCopy?: boolean): VertexDataTypedArray;
57
56
  /**
58
57
  * Copies the given data array to the given float array.
59
58
  * @param input the input data array
@@ -243,12 +243,11 @@ export function GetFloatData(data, size, type, byteOffset, byteStride, normalize
243
243
  * @param type the component type
244
244
  * @param byteOffset the byte offset of the data
245
245
  * @param byteStride the byte stride of the data
246
- * @param normalized whether the data is normalized
247
246
  * @param totalVertices number of vertices in the buffer to take into account
248
247
  * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
249
248
  * @returns a typed array containing vertex data
250
249
  */
251
- export function GetTypedArrayData(data, size, type, byteOffset, byteStride, normalized, totalVertices, forceCopy) {
250
+ export function GetTypedArrayData(data, size, type, byteOffset, byteStride, totalVertices, forceCopy) {
252
251
  const typeByteLength = GetTypeByteLength(type);
253
252
  const constructor = GetTypedArrayConstructor(type);
254
253
  const count = totalVertices * size;
@@ -268,7 +267,7 @@ export function GetTypedArrayData(data, size, type, byteOffset, byteStride, norm
268
267
  }
269
268
  if (stride !== size) {
270
269
  const copy = new constructor(count);
271
- EnumerateFloatValues(data, byteOffset, byteStride, size, type, count, normalized, (values, index) => {
270
+ EnumerateFloatValues(data, byteOffset, byteStride, size, type, count, false, (values, index) => {
272
271
  for (let i = 0; i < size; i++) {
273
272
  copy[index + i] = values[i];
274
273
  }
@@ -297,7 +296,7 @@ export function GetTypedArrayData(data, size, type, byteOffset, byteStride, norm
297
296
  }
298
297
  if (byteStride !== tightlyPackedByteStride) {
299
298
  const copy = new constructor(count);
300
- EnumerateFloatValues(buffer, adjustedByteOffset, byteStride, size, type, count, normalized, (values, index) => {
299
+ EnumerateFloatValues(buffer, adjustedByteOffset, byteStride, size, type, count, false, (values, index) => {
301
300
  for (let i = 0; i < size; i++) {
302
301
  copy[index + i] = values[i];
303
302
  }
@@ -1 +1 @@
1
- {"version":3,"file":"bufferUtils.js","sourceRoot":"","sources":["../../../../dev/core/src/Buffers/bufferUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAQxC,SAAS,aAAa,CAAC,QAAkB,EAAE,IAAY,EAAE,UAAkB,EAAE,UAAmB;IAC5F,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YAClB,IAAI,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YACzC,IAAI,UAAU,EAAE,CAAC;gBACb,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;YACtC,CAAC;YACD,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,KAAK,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;YAC3B,IAAI,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;YAC1C,IAAI,UAAU,EAAE,CAAC;gBACb,KAAK,GAAG,KAAK,GAAG,GAAG,CAAC;YACxB,CAAC;YACD,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,KAAK,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,CAAC;QACvB,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC;IAED,QAAQ,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAE/B,MAAM,aAAa,GAAG,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;IAEhD,OAAO,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import { Constants } from \"../Engines/constants\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { DataArray, FloatArray, IndicesArray, TypedArray, TypedArrayConstructor } from \"../types\";\r\n\r\n/**\r\n * Union of TypedArrays that can be used for vertex data.\r\n */\r\nexport type VertexDataTypedArray = Exclude<TypedArray, Float64Array | BigInt64Array | BigUint64Array>;\r\n\r\nfunction GetFloatValue(dataView: DataView, type: number, byteOffset: number, normalized: boolean): number {\r\n switch (type) {\r\n case Constants.BYTE: {\r\n let value = dataView.getInt8(byteOffset);\r\n if (normalized) {\r\n value = Math.max(value / 127, -1);\r\n }\r\n return value;\r\n }\r\n case Constants.UNSIGNED_BYTE: {\r\n let value = dataView.getUint8(byteOffset);\r\n if (normalized) {\r\n value = value / 255;\r\n }\r\n return value;\r\n }\r\n case Constants.SHORT: {\r\n let value = dataView.getInt16(byteOffset, true);\r\n if (normalized) {\r\n value = Math.max(value / 32767, -1);\r\n }\r\n return value;\r\n }\r\n case Constants.UNSIGNED_SHORT: {\r\n let value = dataView.getUint16(byteOffset, true);\r\n if (normalized) {\r\n value = value / 65535;\r\n }\r\n return value;\r\n }\r\n case Constants.INT: {\r\n return dataView.getInt32(byteOffset, true);\r\n }\r\n case Constants.UNSIGNED_INT: {\r\n return dataView.getUint32(byteOffset, true);\r\n }\r\n case Constants.FLOAT: {\r\n return dataView.getFloat32(byteOffset, true);\r\n }\r\n default: {\r\n throw new Error(`Invalid component type ${type}`);\r\n }\r\n }\r\n}\r\n\r\nfunction SetFloatValue(dataView: DataView, type: number, byteOffset: number, normalized: boolean, value: number): void {\r\n switch (type) {\r\n case Constants.BYTE: {\r\n if (normalized) {\r\n value = Math.round(value * 127.0);\r\n }\r\n dataView.setInt8(byteOffset, value);\r\n break;\r\n }\r\n case Constants.UNSIGNED_BYTE: {\r\n if (normalized) {\r\n value = Math.round(value * 255);\r\n }\r\n dataView.setUint8(byteOffset, value);\r\n break;\r\n }\r\n case Constants.SHORT: {\r\n if (normalized) {\r\n value = Math.round(value * 32767);\r\n }\r\n dataView.setInt16(byteOffset, value, true);\r\n break;\r\n }\r\n case Constants.UNSIGNED_SHORT: {\r\n if (normalized) {\r\n value = Math.round(value * 65535);\r\n }\r\n dataView.setUint16(byteOffset, value, true);\r\n break;\r\n }\r\n case Constants.INT: {\r\n dataView.setInt32(byteOffset, value, true);\r\n break;\r\n }\r\n case Constants.UNSIGNED_INT: {\r\n dataView.setUint32(byteOffset, value, true);\r\n break;\r\n }\r\n case Constants.FLOAT: {\r\n dataView.setFloat32(byteOffset, value, true);\r\n break;\r\n }\r\n default: {\r\n throw new Error(`Invalid component type ${type}`);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Gets the byte length of the given type.\r\n * @param type the type\r\n * @returns the number of bytes\r\n */\r\nexport function GetTypeByteLength(type: number): number {\r\n switch (type) {\r\n case Constants.BYTE:\r\n case Constants.UNSIGNED_BYTE:\r\n return 1;\r\n case Constants.SHORT:\r\n case Constants.UNSIGNED_SHORT:\r\n return 2;\r\n case Constants.INT:\r\n case Constants.UNSIGNED_INT:\r\n case Constants.FLOAT:\r\n return 4;\r\n default:\r\n throw new Error(`Invalid type '${type}'`);\r\n }\r\n}\r\n\r\n/**\r\n * Gets the appropriate TypedArray constructor for the given component type.\r\n * @param componentType the component type\r\n * @returns the constructor object\r\n */\r\nexport function GetTypedArrayConstructor(componentType: number): TypedArrayConstructor<VertexDataTypedArray> {\r\n switch (componentType) {\r\n case Constants.BYTE:\r\n return Int8Array;\r\n case Constants.UNSIGNED_BYTE:\r\n return Uint8Array;\r\n case Constants.SHORT:\r\n return Int16Array;\r\n case Constants.UNSIGNED_SHORT:\r\n return Uint16Array;\r\n case Constants.INT:\r\n return Int32Array;\r\n case Constants.UNSIGNED_INT:\r\n return Uint32Array;\r\n case Constants.FLOAT:\r\n return Float32Array;\r\n default:\r\n throw new Error(`Invalid component type '${componentType}'`);\r\n }\r\n}\r\n\r\n/**\r\n * Enumerates each value of the data array and calls the given callback.\r\n * @param data the data to enumerate\r\n * @param byteOffset the byte offset of the data\r\n * @param byteStride the byte stride of the data\r\n * @param componentCount the number of components per element\r\n * @param componentType the type of the component\r\n * @param count the number of values to enumerate\r\n * @param normalized whether the data is normalized\r\n * @param callback the callback function called for each group of component values\r\n */\r\nexport function EnumerateFloatValues(\r\n data: DataArray,\r\n byteOffset: number,\r\n byteStride: number,\r\n componentCount: number,\r\n componentType: number,\r\n count: number,\r\n normalized: boolean,\r\n callback: (values: number[], index: number) => void\r\n): void {\r\n const oldValues = new Array<number>(componentCount);\r\n const newValues = new Array<number>(componentCount);\r\n\r\n if (data instanceof Array) {\r\n let offset = byteOffset / 4;\r\n const stride = byteStride / 4;\r\n for (let index = 0; index < count; index += componentCount) {\r\n for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {\r\n oldValues[componentIndex] = newValues[componentIndex] = data[offset + componentIndex];\r\n }\r\n\r\n callback(newValues, index);\r\n\r\n for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {\r\n if (oldValues[componentIndex] !== newValues[componentIndex]) {\r\n data[offset + componentIndex] = newValues[componentIndex];\r\n }\r\n }\r\n\r\n offset += stride;\r\n }\r\n } else {\r\n const dataView = !ArrayBuffer.isView(data) ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);\r\n const componentByteLength = GetTypeByteLength(componentType);\r\n for (let index = 0; index < count; index += componentCount) {\r\n for (let componentIndex = 0, componentByteOffset = byteOffset; componentIndex < componentCount; componentIndex++, componentByteOffset += componentByteLength) {\r\n oldValues[componentIndex] = newValues[componentIndex] = GetFloatValue(dataView, componentType, componentByteOffset, normalized);\r\n }\r\n\r\n callback(newValues, index);\r\n\r\n for (let componentIndex = 0, componentByteOffset = byteOffset; componentIndex < componentCount; componentIndex++, componentByteOffset += componentByteLength) {\r\n if (oldValues[componentIndex] !== newValues[componentIndex]) {\r\n SetFloatValue(dataView, componentType, componentByteOffset, normalized, newValues[componentIndex]);\r\n }\r\n }\r\n\r\n byteOffset += byteStride;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Gets the given data array as a float array. Float data is constructed if the data array cannot be returned directly.\r\n * @param data the input data array\r\n * @param size the number of components\r\n * @param type the component type\r\n * @param byteOffset the byte offset of the data\r\n * @param byteStride the byte stride of the data\r\n * @param normalized whether the data is normalized\r\n * @param totalVertices number of vertices in the buffer to take into account\r\n * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it\r\n * @returns a float array containing vertex data\r\n */\r\nexport function GetFloatData(\r\n data: DataArray,\r\n size: number,\r\n type: number,\r\n byteOffset: number,\r\n byteStride: number,\r\n normalized: boolean,\r\n totalVertices: number,\r\n forceCopy?: boolean\r\n): FloatArray {\r\n const tightlyPackedByteStride = size * GetTypeByteLength(type);\r\n const count = totalVertices * size;\r\n\r\n if (type !== Constants.FLOAT || byteStride !== tightlyPackedByteStride) {\r\n const copy = new Float32Array(count);\r\n EnumerateFloatValues(data, byteOffset, byteStride, size, type, count, normalized, (values, index) => {\r\n for (let i = 0; i < size; i++) {\r\n copy[index + i] = values[i];\r\n }\r\n });\r\n return copy;\r\n }\r\n\r\n if (!(data instanceof Array || data instanceof Float32Array) || byteOffset !== 0 || data.length !== count) {\r\n if (data instanceof Array) {\r\n const offset = byteOffset / 4;\r\n return data.slice(offset, offset + count);\r\n } else if (data instanceof ArrayBuffer) {\r\n return new Float32Array(data, byteOffset, count);\r\n } else {\r\n const offset = data.byteOffset + byteOffset;\r\n if ((offset & 3) !== 0) {\r\n Logger.Warn(\"Float array must be aligned to 4-bytes border\");\r\n forceCopy = true;\r\n }\r\n\r\n if (forceCopy) {\r\n return new Float32Array(data.buffer.slice(offset, offset + count * Float32Array.BYTES_PER_ELEMENT));\r\n } else {\r\n return new Float32Array(data.buffer, offset, count);\r\n }\r\n }\r\n }\r\n\r\n if (forceCopy) {\r\n return data.slice();\r\n }\r\n\r\n return data;\r\n}\r\n\r\n/**\r\n * Gets the given data array as a typed array that matches the component type. If the data cannot be used directly, a copy is made to support the new typed array.\r\n * If the data is number[], byteOffset and byteStride must be a multiple of 4, as data will be treated like a list of floats.\r\n * @param data the input data array\r\n * @param size the number of components\r\n * @param type the component type\r\n * @param byteOffset the byte offset of the data\r\n * @param byteStride the byte stride of the data\r\n * @param normalized whether the data is normalized\r\n * @param totalVertices number of vertices in the buffer to take into account\r\n * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it\r\n * @returns a typed array containing vertex data\r\n */\r\nexport function GetTypedArrayData(\r\n data: DataArray,\r\n size: number,\r\n type: number,\r\n byteOffset: number,\r\n byteStride: number,\r\n normalized: boolean,\r\n totalVertices: number,\r\n forceCopy?: boolean\r\n): VertexDataTypedArray {\r\n const typeByteLength = GetTypeByteLength(type);\r\n const constructor = GetTypedArrayConstructor(type);\r\n const count = totalVertices * size;\r\n\r\n // Handle number[]\r\n if (Array.isArray(data)) {\r\n if ((byteOffset & 3) !== 0 || (byteStride & 3) !== 0) {\r\n throw new Error(\"byteOffset and byteStride must be a multiple of 4 for number[] data.\");\r\n }\r\n\r\n const offset = byteOffset / 4;\r\n const stride = byteStride / 4;\r\n\r\n const lastIndex = offset + (totalVertices - 1) * stride + size;\r\n if (lastIndex > data.length) {\r\n throw new Error(\"Last accessed index is out of bounds.\");\r\n }\r\n\r\n if (stride < size) {\r\n throw new Error(\"Data stride cannot be smaller than the component size.\");\r\n }\r\n if (stride !== size) {\r\n const copy = new constructor(count);\r\n EnumerateFloatValues(data, byteOffset, byteStride, size, type, count, normalized, (values, index) => {\r\n for (let i = 0; i < size; i++) {\r\n copy[index + i] = values[i];\r\n }\r\n });\r\n return copy;\r\n }\r\n\r\n return new constructor(data.slice(offset, offset + count));\r\n }\r\n\r\n // Handle ArrayBuffer and ArrayBufferView\r\n let buffer: ArrayBuffer;\r\n let adjustedByteOffset = byteOffset;\r\n\r\n if (data instanceof ArrayBuffer) {\r\n buffer = data;\r\n } else {\r\n buffer = data.buffer;\r\n adjustedByteOffset += data.byteOffset;\r\n }\r\n\r\n const lastByteOffset = adjustedByteOffset + (totalVertices - 1) * byteStride + size * typeByteLength;\r\n if (lastByteOffset > buffer.byteLength) {\r\n throw new Error(\"Last accessed byte is out of bounds.\");\r\n }\r\n\r\n const tightlyPackedByteStride = size * typeByteLength;\r\n if (byteStride < tightlyPackedByteStride) {\r\n throw new Error(\"Byte stride cannot be smaller than the component's byte size.\");\r\n }\r\n if (byteStride !== tightlyPackedByteStride) {\r\n const copy = new constructor(count);\r\n EnumerateFloatValues(buffer, adjustedByteOffset, byteStride, size, type, count, normalized, (values, index) => {\r\n for (let i = 0; i < size; i++) {\r\n copy[index + i] = values[i];\r\n }\r\n });\r\n return copy;\r\n }\r\n\r\n if (typeByteLength !== 1 && (adjustedByteOffset & (typeByteLength - 1)) !== 0) {\r\n Logger.Warn(\"Array must be aligned to border of element size. Data will be copied.\");\r\n forceCopy = true;\r\n }\r\n\r\n if (forceCopy) {\r\n return new constructor(buffer.slice(adjustedByteOffset, adjustedByteOffset + count * typeByteLength));\r\n }\r\n\r\n return new constructor(buffer, adjustedByteOffset, count);\r\n}\r\n\r\n/**\r\n * Copies the given data array to the given float array.\r\n * @param input the input data array\r\n * @param size the number of components\r\n * @param type the component type\r\n * @param byteOffset the byte offset of the data\r\n * @param byteStride the byte stride of the data\r\n * @param normalized whether the data is normalized\r\n * @param totalVertices number of vertices in the buffer to take into account\r\n * @param output the output float array\r\n */\r\nexport function CopyFloatData(\r\n input: DataArray,\r\n size: number,\r\n type: number,\r\n byteOffset: number,\r\n byteStride: number,\r\n normalized: boolean,\r\n totalVertices: number,\r\n output: Float32Array\r\n): void {\r\n const tightlyPackedByteStride = size * GetTypeByteLength(type);\r\n const count = totalVertices * size;\r\n\r\n if (output.length !== count) {\r\n throw new Error(\"Output length is not valid\");\r\n }\r\n\r\n if (type !== Constants.FLOAT || byteStride !== tightlyPackedByteStride) {\r\n EnumerateFloatValues(input, byteOffset, byteStride, size, type, count, normalized, (values, index) => {\r\n for (let i = 0; i < size; i++) {\r\n output[index + i] = values[i];\r\n }\r\n });\r\n return;\r\n }\r\n\r\n if (input instanceof Array) {\r\n const offset = byteOffset / 4;\r\n output.set(input, offset);\r\n } else if (input instanceof ArrayBuffer) {\r\n const floatData = new Float32Array(input, byteOffset, count);\r\n output.set(floatData);\r\n } else {\r\n const offset = input.byteOffset + byteOffset;\r\n if ((offset & 3) !== 0) {\r\n Logger.Warn(\"Float array must be aligned to 4-bytes border\");\r\n output.set(new Float32Array(input.buffer.slice(offset, offset + count * Float32Array.BYTES_PER_ELEMENT)));\r\n return;\r\n }\r\n\r\n const floatData = new Float32Array(input.buffer, offset, count);\r\n output.set(floatData);\r\n }\r\n}\r\n\r\n/**\r\n * Utility function to determine if an IndicesArray is an Uint32Array. If indices is an Array, determines whether at least one index is 32 bits.\r\n * @param indices The IndicesArray to check.\r\n * @param count The number of indices. Only used if indices is an Array.\r\n * @param start The offset to start at (default: 0). Only used if indices is an Array.\r\n * @param offset The offset to substract from the indices before testing (default: 0). Only used if indices is an Array.\r\n * @returns True if the indices use 32 bits\r\n */\r\nexport function AreIndices32Bits(indices: IndicesArray, count: number, start = 0, offset = 0): boolean {\r\n if (Array.isArray(indices)) {\r\n for (let index = 0; index < count; index++) {\r\n if (indices[start + index] - offset > 65535) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n return indices.BYTES_PER_ELEMENT === 4;\r\n}\r\n\r\n/**\r\n * Creates a typed array suitable for GPU buffer operations, as some engines require CPU buffer sizes to be aligned to specific boundaries (e.g., 4 bytes).\r\n * The use of non-aligned arrays still works but may result in a performance penalty.\r\n * @param type The type of the array. For instance, Float32Array or Uint8Array\r\n * @param elementCount The number of elements to store in the array\r\n * @returns The aligned typed array\r\n */\r\nexport function CreateAlignedTypedArray<T extends TypedArray>(type: TypedArrayConstructor<T>, elementCount: number): T {\r\n let byteSize = elementCount * type.BYTES_PER_ELEMENT;\r\n\r\n if ((byteSize & 3) === 0) {\r\n return new type(elementCount);\r\n }\r\n\r\n byteSize = (byteSize + 3) & ~3;\r\n\r\n const backingBuffer = new ArrayBuffer(byteSize);\r\n\r\n return new type(backingBuffer, 0, elementCount);\r\n}\r\n"]}
1
+ {"version":3,"file":"bufferUtils.js","sourceRoot":"","sources":["../../../../dev/core/src/Buffers/bufferUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAQxC,SAAS,aAAa,CAAC,QAAkB,EAAE,IAAY,EAAE,UAAkB,EAAE,UAAmB;IAC5F,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YAClB,IAAI,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YACzC,IAAI,UAAU,EAAE,CAAC;gBACb,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;YACtC,CAAC;YACD,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,KAAK,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;YAC3B,IAAI,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;YAC1C,IAAI,UAAU,EAAE,CAAC;gBACb,KAAK,GAAG,KAAK,GAAG,GAAG,CAAC;YACxB,CAAC;YACD,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC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CAAC,CAAC;IAClC,CAAC;IAED,QAAQ,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAE/B,MAAM,aAAa,GAAG,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;IAEhD,OAAO,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import { Constants } from \"../Engines/constants\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { DataArray, FloatArray, IndicesArray, TypedArray, TypedArrayConstructor } from \"../types\";\r\n\r\n/**\r\n * Union of TypedArrays that can be used for vertex data.\r\n */\r\nexport type VertexDataTypedArray = Exclude<TypedArray, Float64Array | BigInt64Array | BigUint64Array>;\r\n\r\nfunction GetFloatValue(dataView: DataView, type: number, byteOffset: number, normalized: boolean): number {\r\n switch (type) {\r\n case Constants.BYTE: {\r\n let value = dataView.getInt8(byteOffset);\r\n if (normalized) {\r\n value = Math.max(value / 127, -1);\r\n }\r\n return value;\r\n }\r\n case Constants.UNSIGNED_BYTE: {\r\n let value = dataView.getUint8(byteOffset);\r\n if (normalized) {\r\n value = value / 255;\r\n }\r\n return value;\r\n }\r\n case Constants.SHORT: {\r\n let value = dataView.getInt16(byteOffset, true);\r\n if (normalized) {\r\n value = Math.max(value / 32767, -1);\r\n }\r\n return value;\r\n }\r\n case Constants.UNSIGNED_SHORT: {\r\n let value = dataView.getUint16(byteOffset, true);\r\n if (normalized) {\r\n value = value / 65535;\r\n }\r\n return value;\r\n }\r\n case Constants.INT: {\r\n return dataView.getInt32(byteOffset, true);\r\n }\r\n case Constants.UNSIGNED_INT: {\r\n return dataView.getUint32(byteOffset, true);\r\n }\r\n case Constants.FLOAT: {\r\n return dataView.getFloat32(byteOffset, true);\r\n }\r\n default: {\r\n throw new Error(`Invalid component type ${type}`);\r\n }\r\n }\r\n}\r\n\r\nfunction SetFloatValue(dataView: DataView, type: number, byteOffset: number, normalized: boolean, value: number): void {\r\n switch (type) {\r\n case Constants.BYTE: {\r\n if (normalized) {\r\n value = Math.round(value * 127.0);\r\n }\r\n dataView.setInt8(byteOffset, value);\r\n break;\r\n }\r\n case Constants.UNSIGNED_BYTE: {\r\n if (normalized) {\r\n value = Math.round(value * 255);\r\n }\r\n dataView.setUint8(byteOffset, value);\r\n break;\r\n }\r\n case Constants.SHORT: {\r\n if (normalized) {\r\n value = Math.round(value * 32767);\r\n }\r\n dataView.setInt16(byteOffset, value, true);\r\n break;\r\n }\r\n case Constants.UNSIGNED_SHORT: {\r\n if (normalized) {\r\n value = Math.round(value * 65535);\r\n }\r\n dataView.setUint16(byteOffset, value, true);\r\n break;\r\n }\r\n case Constants.INT: {\r\n dataView.setInt32(byteOffset, value, true);\r\n break;\r\n }\r\n case Constants.UNSIGNED_INT: {\r\n dataView.setUint32(byteOffset, value, true);\r\n break;\r\n }\r\n case Constants.FLOAT: {\r\n dataView.setFloat32(byteOffset, value, true);\r\n break;\r\n }\r\n default: {\r\n throw new Error(`Invalid component type ${type}`);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Gets the byte length of the given type.\r\n * @param type the type\r\n * @returns the number of bytes\r\n */\r\nexport function GetTypeByteLength(type: number): number {\r\n switch (type) {\r\n case Constants.BYTE:\r\n case Constants.UNSIGNED_BYTE:\r\n return 1;\r\n case Constants.SHORT:\r\n case Constants.UNSIGNED_SHORT:\r\n return 2;\r\n case Constants.INT:\r\n case Constants.UNSIGNED_INT:\r\n case Constants.FLOAT:\r\n return 4;\r\n default:\r\n throw new Error(`Invalid type '${type}'`);\r\n }\r\n}\r\n\r\n/**\r\n * Gets the appropriate TypedArray constructor for the given component type.\r\n * @param componentType the component type\r\n * @returns the constructor object\r\n */\r\nexport function GetTypedArrayConstructor(componentType: number): TypedArrayConstructor<VertexDataTypedArray> {\r\n switch (componentType) {\r\n case Constants.BYTE:\r\n return Int8Array;\r\n case Constants.UNSIGNED_BYTE:\r\n return Uint8Array;\r\n case Constants.SHORT:\r\n return Int16Array;\r\n case Constants.UNSIGNED_SHORT:\r\n return Uint16Array;\r\n case Constants.INT:\r\n return Int32Array;\r\n case Constants.UNSIGNED_INT:\r\n return Uint32Array;\r\n case Constants.FLOAT:\r\n return Float32Array;\r\n default:\r\n throw new Error(`Invalid component type '${componentType}'`);\r\n }\r\n}\r\n\r\n/**\r\n * Enumerates each value of the data array and calls the given callback.\r\n * @param data the data to enumerate\r\n * @param byteOffset the byte offset of the data\r\n * @param byteStride the byte stride of the data\r\n * @param componentCount the number of components per element\r\n * @param componentType the type of the component\r\n * @param count the number of values to enumerate\r\n * @param normalized whether the data is normalized\r\n * @param callback the callback function called for each group of component values\r\n */\r\nexport function EnumerateFloatValues(\r\n data: DataArray,\r\n byteOffset: number,\r\n byteStride: number,\r\n componentCount: number,\r\n componentType: number,\r\n count: number,\r\n normalized: boolean,\r\n callback: (values: number[], index: number) => void\r\n): void {\r\n const oldValues = new Array<number>(componentCount);\r\n const newValues = new Array<number>(componentCount);\r\n\r\n if (data instanceof Array) {\r\n let offset = byteOffset / 4;\r\n const stride = byteStride / 4;\r\n for (let index = 0; index < count; index += componentCount) {\r\n for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {\r\n oldValues[componentIndex] = newValues[componentIndex] = data[offset + componentIndex];\r\n }\r\n\r\n callback(newValues, index);\r\n\r\n for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {\r\n if (oldValues[componentIndex] !== newValues[componentIndex]) {\r\n data[offset + componentIndex] = newValues[componentIndex];\r\n }\r\n }\r\n\r\n offset += stride;\r\n }\r\n } else {\r\n const dataView = !ArrayBuffer.isView(data) ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);\r\n const componentByteLength = GetTypeByteLength(componentType);\r\n for (let index = 0; index < count; index += componentCount) {\r\n for (let componentIndex = 0, componentByteOffset = byteOffset; componentIndex < componentCount; componentIndex++, componentByteOffset += componentByteLength) {\r\n oldValues[componentIndex] = newValues[componentIndex] = GetFloatValue(dataView, componentType, componentByteOffset, normalized);\r\n }\r\n\r\n callback(newValues, index);\r\n\r\n for (let componentIndex = 0, componentByteOffset = byteOffset; componentIndex < componentCount; componentIndex++, componentByteOffset += componentByteLength) {\r\n if (oldValues[componentIndex] !== newValues[componentIndex]) {\r\n SetFloatValue(dataView, componentType, componentByteOffset, normalized, newValues[componentIndex]);\r\n }\r\n }\r\n\r\n byteOffset += byteStride;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Gets the given data array as a float array. Float data is constructed if the data array cannot be returned directly.\r\n * @param data the input data array\r\n * @param size the number of components\r\n * @param type the component type\r\n * @param byteOffset the byte offset of the data\r\n * @param byteStride the byte stride of the data\r\n * @param normalized whether the data is normalized\r\n * @param totalVertices number of vertices in the buffer to take into account\r\n * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it\r\n * @returns a float array containing vertex data\r\n */\r\nexport function GetFloatData(\r\n data: DataArray,\r\n size: number,\r\n type: number,\r\n byteOffset: number,\r\n byteStride: number,\r\n normalized: boolean,\r\n totalVertices: number,\r\n forceCopy?: boolean\r\n): FloatArray {\r\n const tightlyPackedByteStride = size * GetTypeByteLength(type);\r\n const count = totalVertices * size;\r\n\r\n if (type !== Constants.FLOAT || byteStride !== tightlyPackedByteStride) {\r\n const copy = new Float32Array(count);\r\n EnumerateFloatValues(data, byteOffset, byteStride, size, type, count, normalized, (values, index) => {\r\n for (let i = 0; i < size; i++) {\r\n copy[index + i] = values[i];\r\n }\r\n });\r\n return copy;\r\n }\r\n\r\n if (!(data instanceof Array || data instanceof Float32Array) || byteOffset !== 0 || data.length !== count) {\r\n if (data instanceof Array) {\r\n const offset = byteOffset / 4;\r\n return data.slice(offset, offset + count);\r\n } else if (data instanceof ArrayBuffer) {\r\n return new Float32Array(data, byteOffset, count);\r\n } else {\r\n const offset = data.byteOffset + byteOffset;\r\n if ((offset & 3) !== 0) {\r\n Logger.Warn(\"Float array must be aligned to 4-bytes border\");\r\n forceCopy = true;\r\n }\r\n\r\n if (forceCopy) {\r\n return new Float32Array(data.buffer.slice(offset, offset + count * Float32Array.BYTES_PER_ELEMENT));\r\n } else {\r\n return new Float32Array(data.buffer, offset, count);\r\n }\r\n }\r\n }\r\n\r\n if (forceCopy) {\r\n return data.slice();\r\n }\r\n\r\n return data;\r\n}\r\n\r\n/**\r\n * Gets the given data array as a typed array that matches the component type. If the data cannot be used directly, a copy is made to support the new typed array.\r\n * If the data is number[], byteOffset and byteStride must be a multiple of 4, as data will be treated like a list of floats.\r\n * @param data the input data array\r\n * @param size the number of components\r\n * @param type the component type\r\n * @param byteOffset the byte offset of the data\r\n * @param byteStride the byte stride of the data\r\n * @param totalVertices number of vertices in the buffer to take into account\r\n * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it\r\n * @returns a typed array containing vertex data\r\n */\r\nexport function GetTypedArrayData(\r\n data: DataArray,\r\n size: number,\r\n type: number,\r\n byteOffset: number,\r\n byteStride: number,\r\n totalVertices: number,\r\n forceCopy?: boolean\r\n): VertexDataTypedArray {\r\n const typeByteLength = GetTypeByteLength(type);\r\n const constructor = GetTypedArrayConstructor(type);\r\n const count = totalVertices * size;\r\n\r\n // Handle number[]\r\n if (Array.isArray(data)) {\r\n if ((byteOffset & 3) !== 0 || (byteStride & 3) !== 0) {\r\n throw new Error(\"byteOffset and byteStride must be a multiple of 4 for number[] data.\");\r\n }\r\n\r\n const offset = byteOffset / 4;\r\n const stride = byteStride / 4;\r\n\r\n const lastIndex = offset + (totalVertices - 1) * stride + size;\r\n if (lastIndex > data.length) {\r\n throw new Error(\"Last accessed index is out of bounds.\");\r\n }\r\n\r\n if (stride < size) {\r\n throw new Error(\"Data stride cannot be smaller than the component size.\");\r\n }\r\n if (stride !== size) {\r\n const copy = new constructor(count);\r\n EnumerateFloatValues(data, byteOffset, byteStride, size, type, count, false, (values, index) => {\r\n for (let i = 0; i < size; i++) {\r\n copy[index + i] = values[i];\r\n }\r\n });\r\n return copy;\r\n }\r\n\r\n return new constructor(data.slice(offset, offset + count));\r\n }\r\n\r\n // Handle ArrayBuffer and ArrayBufferView\r\n let buffer: ArrayBuffer;\r\n let adjustedByteOffset = byteOffset;\r\n\r\n if (data instanceof ArrayBuffer) {\r\n buffer = data;\r\n } else {\r\n buffer = data.buffer;\r\n adjustedByteOffset += data.byteOffset;\r\n }\r\n\r\n const lastByteOffset = adjustedByteOffset + (totalVertices - 1) * byteStride + size * typeByteLength;\r\n if (lastByteOffset > buffer.byteLength) {\r\n throw new Error(\"Last accessed byte is out of bounds.\");\r\n }\r\n\r\n const tightlyPackedByteStride = size * typeByteLength;\r\n if (byteStride < tightlyPackedByteStride) {\r\n throw new Error(\"Byte stride cannot be smaller than the component's byte size.\");\r\n }\r\n if (byteStride !== tightlyPackedByteStride) {\r\n const copy = new constructor(count);\r\n EnumerateFloatValues(buffer, adjustedByteOffset, byteStride, size, type, count, false, (values, index) => {\r\n for (let i = 0; i < size; i++) {\r\n copy[index + i] = values[i];\r\n }\r\n });\r\n return copy;\r\n }\r\n\r\n if (typeByteLength !== 1 && (adjustedByteOffset & (typeByteLength - 1)) !== 0) {\r\n Logger.Warn(\"Array must be aligned to border of element size. Data will be copied.\");\r\n forceCopy = true;\r\n }\r\n\r\n if (forceCopy) {\r\n return new constructor(buffer.slice(adjustedByteOffset, adjustedByteOffset + count * typeByteLength));\r\n }\r\n\r\n return new constructor(buffer, adjustedByteOffset, count);\r\n}\r\n\r\n/**\r\n * Copies the given data array to the given float array.\r\n * @param input the input data array\r\n * @param size the number of components\r\n * @param type the component type\r\n * @param byteOffset the byte offset of the data\r\n * @param byteStride the byte stride of the data\r\n * @param normalized whether the data is normalized\r\n * @param totalVertices number of vertices in the buffer to take into account\r\n * @param output the output float array\r\n */\r\nexport function CopyFloatData(\r\n input: DataArray,\r\n size: number,\r\n type: number,\r\n byteOffset: number,\r\n byteStride: number,\r\n normalized: boolean,\r\n totalVertices: number,\r\n output: Float32Array\r\n): void {\r\n const tightlyPackedByteStride = size * GetTypeByteLength(type);\r\n const count = totalVertices * size;\r\n\r\n if (output.length !== count) {\r\n throw new Error(\"Output length is not valid\");\r\n }\r\n\r\n if (type !== Constants.FLOAT || byteStride !== tightlyPackedByteStride) {\r\n EnumerateFloatValues(input, byteOffset, byteStride, size, type, count, normalized, (values, index) => {\r\n for (let i = 0; i < size; i++) {\r\n output[index + i] = values[i];\r\n }\r\n });\r\n return;\r\n }\r\n\r\n if (input instanceof Array) {\r\n const offset = byteOffset / 4;\r\n output.set(input, offset);\r\n } else if (input instanceof ArrayBuffer) {\r\n const floatData = new Float32Array(input, byteOffset, count);\r\n output.set(floatData);\r\n } else {\r\n const offset = input.byteOffset + byteOffset;\r\n if ((offset & 3) !== 0) {\r\n Logger.Warn(\"Float array must be aligned to 4-bytes border\");\r\n output.set(new Float32Array(input.buffer.slice(offset, offset + count * Float32Array.BYTES_PER_ELEMENT)));\r\n return;\r\n }\r\n\r\n const floatData = new Float32Array(input.buffer, offset, count);\r\n output.set(floatData);\r\n }\r\n}\r\n\r\n/**\r\n * Utility function to determine if an IndicesArray is an Uint32Array. If indices is an Array, determines whether at least one index is 32 bits.\r\n * @param indices The IndicesArray to check.\r\n * @param count The number of indices. Only used if indices is an Array.\r\n * @param start The offset to start at (default: 0). Only used if indices is an Array.\r\n * @param offset The offset to substract from the indices before testing (default: 0). Only used if indices is an Array.\r\n * @returns True if the indices use 32 bits\r\n */\r\nexport function AreIndices32Bits(indices: IndicesArray, count: number, start = 0, offset = 0): boolean {\r\n if (Array.isArray(indices)) {\r\n for (let index = 0; index < count; index++) {\r\n if (indices[start + index] - offset > 65535) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n return indices.BYTES_PER_ELEMENT === 4;\r\n}\r\n\r\n/**\r\n * Creates a typed array suitable for GPU buffer operations, as some engines require CPU buffer sizes to be aligned to specific boundaries (e.g., 4 bytes).\r\n * The use of non-aligned arrays still works but may result in a performance penalty.\r\n * @param type The type of the array. For instance, Float32Array or Uint8Array\r\n * @param elementCount The number of elements to store in the array\r\n * @returns The aligned typed array\r\n */\r\nexport function CreateAlignedTypedArray<T extends TypedArray>(type: TypedArrayConstructor<T>, elementCount: number): T {\r\n let byteSize = elementCount * type.BYTES_PER_ELEMENT;\r\n\r\n if ((byteSize & 3) === 0) {\r\n return new type(elementCount);\r\n }\r\n\r\n byteSize = (byteSize + 3) & ~3;\r\n\r\n const backingBuffer = new ArrayBuffer(byteSize);\r\n\r\n return new type(backingBuffer, 0, elementCount);\r\n}\r\n"]}
@@ -794,13 +794,13 @@ export class AbstractEngine {
794
794
  */
795
795
  // Not mixed with Version for tooling purpose.
796
796
  static get NpmPackage() {
797
- return "babylonjs@8.31.0";
797
+ return "babylonjs@8.31.2";
798
798
  }
799
799
  /**
800
800
  * Returns the current version of the framework
801
801
  */
802
802
  static get Version() {
803
- return "8.31.0";
803
+ return "8.31.2";
804
804
  }
805
805
  /**
806
806
  * Gets the HTML canvas attached with the current webGL context