@babylonjs/core 5.0.0-beta.6 → 5.0.0-beta.7

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 (39) hide show
  1. package/DeviceInput/Helpers/eventFactory.js +1 -4
  2. package/DeviceInput/Helpers/eventFactory.js.map +1 -1
  3. package/DeviceInput/InputDevices/deviceEnums.d.ts +4 -2
  4. package/DeviceInput/InputDevices/deviceEnums.js +3 -1
  5. package/DeviceInput/InputDevices/deviceEnums.js.map +1 -1
  6. package/DeviceInput/InputDevices/nativeDeviceInputSystem.js +3 -2
  7. package/DeviceInput/InputDevices/nativeDeviceInputSystem.js.map +1 -1
  8. package/DeviceInput/InputDevices/webDeviceInputSystem.js +6 -52
  9. package/DeviceInput/InputDevices/webDeviceInputSystem.js.map +1 -1
  10. package/Engines/Extensions/engine.cubeTexture.js +2 -1
  11. package/Engines/Extensions/engine.cubeTexture.js.map +1 -1
  12. package/Engines/WebGPU/Extensions/engine.cubeTexture.js +4 -1
  13. package/Engines/WebGPU/Extensions/engine.cubeTexture.js.map +1 -1
  14. package/Engines/WebGPU/webgpuTextureHelper.js +9 -2
  15. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  16. package/Engines/nativeEngine.js +1 -1
  17. package/Engines/nativeEngine.js.map +1 -1
  18. package/Engines/renderTargetWrapper.d.ts +8 -0
  19. package/Engines/renderTargetWrapper.js +20 -0
  20. package/Engines/renderTargetWrapper.js.map +1 -1
  21. package/Engines/thinEngine.d.ts +7 -0
  22. package/Engines/thinEngine.js +19 -2
  23. package/Engines/thinEngine.js.map +1 -1
  24. package/Inputs/scene.inputManager.js +1 -4
  25. package/Inputs/scene.inputManager.js.map +1 -1
  26. package/Materials/Textures/internalTexture.d.ts +2 -0
  27. package/Materials/Textures/internalTexture.js +2 -0
  28. package/Materials/Textures/internalTexture.js.map +1 -1
  29. package/Materials/material.js +1 -1
  30. package/Materials/material.js.map +1 -1
  31. package/Materials/materialHelper.js +5 -0
  32. package/Materials/materialHelper.js.map +1 -1
  33. package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js +6 -12
  34. package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js.map +1 -1
  35. package/Shaders/geometry.vertex.js +1 -1
  36. package/Shaders/geometry.vertex.js.map +1 -1
  37. package/Shaders/pbr.vertex.js +1 -1
  38. package/Shaders/pbr.vertex.js.map +1 -1
  39. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"webDeviceInputSystem.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/webDeviceInputSystem.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGzD,IAAM,YAAY,GAAG,GAAG,CAAC;AACzB,IAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AAEhE,cAAc;AACd;IA8DI,8BAAY,MAAc;QApC1B,kBAAkB;QACV,YAAO,GAAmD,EAAE,CAAC;QAE7D,oBAAe,GAAY,KAAK,CAAC;QACjC,mBAAc,GAAY,KAAK,CAAC;QAGvB,iBAAY,GAAY,KAAK,CAAC,QAAQ,EAAE,CAAC;QAIlD,uBAAkB,GAAG,UAAC,GAAQ,IAAO,CAAC,CAAC;QACvC,qBAAgB,GAAG,UAAC,GAAQ,IAAO,CAAC,CAAC;QACrC,uBAAkB,GAAG,UAAC,GAAQ,IAAO,CAAC,CAAC;QAEvC,sBAAiB,GAAG,UAAC,GAAQ,IAAO,CAAC,CAAC;QACtC,sBAAiB,GAAG,UAAC,GAAQ,IAAO,CAAC,CAAC;QACtC,oBAAe,GAAG,U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IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC7E,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAE5E,kBAAkB;QAClB,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAChF,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAE5E,iBAAiB;QACjB,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,IAAI,CAAC,YAAY,GAAG,MAAM,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAChG,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,IAAI,CAAC,YAAY,GAAG,MAAM,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAChG,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,IAAI,CAAC,YAAY,GAAG,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QAC5F,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAE3F,IAAI,IAAI,CAAC,0BAA0B,EAAE;YACjC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;SAC7E;IACL,CAAC;IACL,2BAAC;AAAD,CAAC,AA7yBD,IA6yBC","sourcesContent":["import { Engine } from \"../../Engines/engine\";\r\nimport { IEvent } from \"../../Events/deviceInputEvents\";\r\nimport { DomManagement } from \"../../Misc/domManagement\";\r\nimport { Observer } from \"../../Misc/observable\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { Nullable } from \"../../types\";\r\nimport { DeviceEventFactory } from \"../Helpers/eventFactory\";\r\nimport { DeviceType, PointerInput } from \"./deviceEnums\";\r\nimport { IDeviceEvent, IDeviceInputSystem } from \"./inputInterfaces\";\r\n\r\nconst MAX_KEYCODES = 255;\r\nconst MAX_POINTER_INPUTS = Object.keys(PointerInput).length / 2;\r\n\r\n/** @hidden */\r\nexport class WebDeviceInputSystem implements IDeviceInputSystem {\r\n /** onDeviceConnected property */\r\n public set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void) {\r\n this._onDeviceConnected = callback;\r\n\r\n // Iterate through each active device and rerun new callback\r\n for (let deviceType = 0; deviceType < this._inputs.length; deviceType++) {\r\n const inputs = this._inputs[deviceType];\r\n if (inputs) {\r\n for (const deviceSlotKey in inputs) {\r\n const deviceSlot = +deviceSlotKey;\r\n if (this._inputs[deviceType][deviceSlot]) {\r\n this._onDeviceConnected(deviceType, deviceSlot);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n public get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void {\r\n return this._onDeviceConnected;\r\n }\r\n\r\n public onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n public onInputChanged: (deviceEvent: IDeviceEvent) => void;\r\n\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 readonly _engine: Engine;\r\n private readonly _usingSafari: boolean = Tools.IsSafari();\r\n\r\n private _onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n\r\n private _keyboardDownEvent = (evt: any) => { };\r\n private _keyboardUpEvent = (evt: any) => { };\r\n private _keyboardBlurEvent = (evt: any) => { };\r\n\r\n private _pointerMoveEvent = (evt: any) => { };\r\n private _pointerDownEvent = (evt: any) => { };\r\n private _pointerUpEvent = (evt: any) => { };\r\n private _pointerWheelEvent = (evt: any) => { };\r\n private _pointerBlurEvent = (evt: any) => { };\r\n private _wheelEventName: string;\r\n\r\n private _mouseId = -1;\r\n private readonly _isUsingFirefox = DomManagement.IsNavigatorAvailable() && navigator.userAgent && navigator.userAgent.indexOf(\"Firefox\") !== -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<Engine>> = null;\r\n\r\n private _gamepadConnectedEvent = (evt: any) => { };\r\n private _gamepadDisconnectedEvent = (evt: any) => { };\r\n\r\n private _eventPrefix: string;\r\n\r\n constructor(engine: Engine) {\r\n this._eventPrefix = Tools.GetPointerPrefix(engine);\r\n this._engine = engine;\r\n\r\n this.onDeviceConnected = (deviceType: DeviceType, deviceSlot: number) => { };\r\n this.onDeviceDisconnected = (deviceType: DeviceType, deviceSlot: number) => { };\r\n this.onInputChanged = (deviceEvent: IDeviceEvent) => { };\r\n\r\n this._configureEvents();\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 specifiying 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 throw `Unable to find device ${DeviceType[deviceType]}`;\r\n }\r\n\r\n if (deviceType >= DeviceType.DualShock && deviceType <= DeviceType.DualSense && navigator.getGamepads) {\r\n this._updateDevice(deviceType, deviceSlot, inputIndex);\r\n }\r\n\r\n const currentValue = device[inputIndex];\r\n if (currentValue === undefined) {\r\n throw `Unable to find input ${inputIndex} for device ${DeviceType[deviceType]} in slot ${deviceSlot}`;\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 // Observables\r\n this.onDeviceConnected = () => { };\r\n this.onDeviceDisconnected = () => { };\r\n this.onInputChanged = () => { };\r\n\r\n if (this._elementToAttachTo) {\r\n this._removeEvents();\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\r\n /**\r\n * Configures events to work with an engine's active element\r\n */\r\n private _configureEvents(): void {\r\n const inputElement = this._engine.getInputElement();\r\n if (inputElement && this._elementToAttachTo !== inputElement) {\r\n // If the engine's input element has changed, unregister events from previous element\r\n if (this._elementToAttachTo) {\r\n this._removeEvents();\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\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 * 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 (matchMedia('(pointer:fine)').matches) {\r\n // This will provide a dummy value for the cursor position and is expected to be overriden 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 specifiying 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 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 for (let i = 0; i < numberOfInputs; i++) {\r\n device[i] = 0; /* set device input as unpressed */\r\n }\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 specifiying 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 let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = DeviceType.Keyboard;\r\n deviceEvent.deviceSlot = 0;\r\n deviceEvent.inputIndex = evt.keyCode;\r\n deviceEvent.previousState = 0;\r\n deviceEvent.currentState = kbKey[evt.keyCode];\r\n\r\n this.onInputChanged(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 let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = DeviceType.Keyboard;\r\n deviceEvent.deviceSlot = 0;\r\n deviceEvent.inputIndex = evt.keyCode;\r\n deviceEvent.previousState = 1;\r\n deviceEvent.currentState = kbKey[evt.keyCode];\r\n\r\n this.onInputChanged(deviceEvent);\r\n }\r\n });\r\n\r\n this._keyboardBlurEvent = ((evt) => {\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 evt: IEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Keyboard, 0, i, 1, this, this._elementToAttachTo);\r\n const deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = DeviceType.Keyboard;\r\n deviceEvent.deviceSlot = 0;\r\n deviceEvent.inputIndex = i;\r\n deviceEvent.currentState = 0;\r\n deviceEvent.previousState = 1;\r\n this.onInputChanged(deviceEvent);\r\n }\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 this._maxTouchPoints = (DomManagement.IsNavigatorAvailable() && navigator.maxTouchPoints) || 0;\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 const deviceSlot = (deviceType === DeviceType.Mouse) ? 0 : this._activeTouchIds.indexOf(evt.pointerId);\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 // Store previous values for event\r\n const previousHorizontal = pointer[PointerInput.Horizontal];\r\n const previousVertical = pointer[PointerInput.Vertical];\r\n const previousDeltaHorizontal = pointer[PointerInput.DeltaHorizontal];\r\n const previousDeltaVertical = pointer[PointerInput.DeltaVertical];\r\n\r\n pointer[PointerInput.Horizontal] = evt.clientX;\r\n pointer[PointerInput.Vertical] = evt.clientY;\r\n pointer[PointerInput.DeltaHorizontal] = evt.movementX;\r\n pointer[PointerInput.DeltaVertical] = evt.movementY;\r\n\r\n let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = deviceType;\r\n deviceEvent.deviceSlot = deviceSlot;\r\n\r\n // The browser might use a move event in case\r\n // of simultaneous mouse buttons click for instance. So\r\n // in this case we stil need to propagate it.\r\n if (previousHorizontal !== evt.clientX) {\r\n deviceEvent.inputIndex = PointerInput.Horizontal;\r\n deviceEvent.previousState = previousHorizontal;\r\n deviceEvent.currentState = pointer[PointerInput.Horizontal];\r\n\r\n this.onInputChanged(deviceEvent);\r\n }\r\n if (previousVertical !== evt.clientY) {\r\n deviceEvent.inputIndex = PointerInput.Vertical;\r\n deviceEvent.previousState = previousVertical;\r\n deviceEvent.currentState = pointer[PointerInput.Vertical];\r\n\r\n this.onInputChanged(deviceEvent);\r\n }\r\n if (pointer[PointerInput.DeltaHorizontal] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.DeltaHorizontal;\r\n deviceEvent.previousState = previousDeltaHorizontal;\r\n deviceEvent.currentState = pointer[PointerInput.DeltaHorizontal];\r\n\r\n this.onInputChanged(deviceEvent);\r\n }\r\n if (pointer[PointerInput.DeltaVertical] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.DeltaVertical;\r\n deviceEvent.previousState = previousDeltaVertical;\r\n deviceEvent.currentState = pointer[PointerInput.DeltaVertical];\r\n\r\n this.onInputChanged(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 deviceEvent.previousState = pointer[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 deviceEvent.currentState = pointer[evt.button + 2];\r\n this.onInputChanged(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 }\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 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 const previousButton = pointer[evt.button + 2];\r\n\r\n if (deviceType === DeviceType.Mouse) { // Mouse; Among supported browsers, value is either 1 or 0 for mouse\r\n if (this._mouseId === -1) {\r\n if (evt.pointerId === undefined) { // If there is no pointerId (eg. manually dispatched MouseEvent)\r\n this._mouseId = this._isUsingFirefox ? 0 : 1;\r\n }\r\n else {\r\n this._mouseId = evt.pointerId;\r\n }\r\n }\r\n\r\n if (!document.pointerLockElement && this._elementToAttachTo.hasPointerCapture) {\r\n try {\r\n this._elementToAttachTo.setPointerCapture(this._mouseId);\r\n }\r\n catch (e) {\r\n // DO NOTHING\r\n }\r\n }\r\n }\r\n else { // Touch; Since touches are dynamically assigned, only set capture if we have an id\r\n if (evt.pointerId && !document.pointerLockElement && this._elementToAttachTo.hasPointerCapture) {\r\n try {\r\n this._elementToAttachTo.setPointerCapture(evt.pointerId);\r\n }\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 let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = deviceType;\r\n deviceEvent.deviceSlot = deviceSlot;\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 deviceEvent.previousState = previousButton;\r\n deviceEvent.currentState = pointer[deviceEvent.inputIndex];\r\n this.onInputChanged(deviceEvent);\r\n\r\n if (previousHorizontal !== evt.clientX) {\r\n deviceEvent.inputIndex = PointerInput.Horizontal;\r\n deviceEvent.previousState = previousHorizontal;\r\n deviceEvent.currentState = pointer[PointerInput.Horizontal];\r\n\r\n this.onInputChanged(deviceEvent);\r\n }\r\n if (previousVertical !== evt.clientY) {\r\n deviceEvent.inputIndex = PointerInput.Vertical;\r\n deviceEvent.previousState = previousVertical;\r\n deviceEvent.currentState = pointer[PointerInput.Vertical];\r\n\r\n this.onInputChanged(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 (deviceSlot === -1) {\r\n return;\r\n }\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 const previousButton = pointer[evt.button + 2];\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 let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = deviceType;\r\n deviceEvent.deviceSlot = deviceSlot;\r\n\r\n if (previousHorizontal !== evt.clientX) {\r\n deviceEvent.inputIndex = PointerInput.Horizontal;\r\n deviceEvent.previousState = previousHorizontal;\r\n deviceEvent.currentState = pointer[PointerInput.Horizontal];\r\n\r\n this.onInputChanged(deviceEvent);\r\n }\r\n if (previousVertical !== evt.clientY) {\r\n deviceEvent.inputIndex = PointerInput.Vertical;\r\n deviceEvent.previousState = previousVertical;\r\n deviceEvent.currentState = pointer[PointerInput.Vertical];\r\n\r\n this.onInputChanged(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 deviceEvent.previousState = previousButton;\r\n deviceEvent.currentState = pointer[deviceEvent.inputIndex];\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 }\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(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 // Set Wheel Event Name, code originally from scene.inputManager\r\n this._wheelEventName = \"onwheel\" in document.createElement(\"div\") ? \"wheel\" : // Modern browsers support \"wheel\"\r\n (<any>document).onmousewheel !== undefined ? \"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 = {\r\n passive: {\r\n get: function () {\r\n passiveSupported = true;\r\n }\r\n }\r\n };\r\n\r\n this._elementToAttachTo.addEventListener(\"test\", noop, options);\r\n this._elementToAttachTo.removeEventListener(\"test\", noop, options);\r\n }\r\n catch (e) {\r\n /* */\r\n }\r\n\r\n this._pointerBlurEvent = ((evt) => {\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 i = 0; i <= PointerInput.BrowserForward; i++) {\r\n if (pointer[i + 2] === 1) {\r\n pointer[i + 2] = 0;\r\n\r\n const evt: IEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Mouse, 0, i + 2, 1, this, this._elementToAttachTo);\r\n const deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = DeviceType.Mouse;\r\n deviceEvent.deviceSlot = 0;\r\n deviceEvent.inputIndex = i + 2;\r\n deviceEvent.currentState = pointer[i + 2];\r\n deviceEvent.previousState = 1;\r\n this.onInputChanged(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 evt: IEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Touch, deviceSlot, PointerInput.LeftClick, 1, this, this._elementToAttachTo);\r\n const deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = DeviceType.Touch;\r\n deviceEvent.deviceSlot = deviceSlot;\r\n deviceEvent.inputIndex = PointerInput.LeftClick;\r\n deviceEvent.currentState = pointer[deviceSlot][PointerInput.LeftClick];\r\n deviceEvent.previousState = 1;\r\n this.onInputChanged(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 // Store previous values for event\r\n let previousWheelScrollX = pointer[PointerInput.MouseWheelX];\r\n let previousWheelScrollY = pointer[PointerInput.MouseWheelY];\r\n let previousWheelScrollZ = pointer[PointerInput.MouseWheelZ];\r\n\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 let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = deviceType;\r\n deviceEvent.deviceSlot = deviceSlot;\r\n\r\n if (pointer[PointerInput.MouseWheelX] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelX;\r\n deviceEvent.previousState = previousWheelScrollX;\r\n deviceEvent.currentState = pointer[PointerInput.MouseWheelX];\r\n this.onInputChanged(deviceEvent);\r\n }\r\n if (pointer[PointerInput.MouseWheelY] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelY;\r\n deviceEvent.previousState = previousWheelScrollY;\r\n deviceEvent.currentState = pointer[PointerInput.MouseWheelY];\r\n this.onInputChanged(deviceEvent);\r\n }\r\n if (pointer[PointerInput.MouseWheelZ] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelZ;\r\n deviceEvent.previousState = previousWheelScrollZ;\r\n deviceEvent.currentState = pointer[PointerInput.MouseWheelZ];\r\n this.onInputChanged(deviceEvent);\r\n }\r\n }\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(\"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 pointer[PointerInput.DeltaHorizontal] = 0;\r\n pointer[PointerInput.DeltaVertical] = 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 specifiying 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 }\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) { // DualShock 4 Gamepad\r\n return (deviceName.indexOf(\"0ce6\") !== -1 ? DeviceType.DualSense : DeviceType.DualShock);\r\n }\r\n else if (deviceName.indexOf(\"Xbox One\") !== -1 || deviceName.search(\"Xbox 360\") !== -1 || deviceName.search(\"xinput\") !== -1) { // Xbox Gamepad\r\n return DeviceType.Xbox;\r\n }\r\n else if (deviceName.indexOf(\"057e\") !== -1) { // 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 /**\r\n * Remove events from active input element\r\n */\r\n private _removeEvents(): void {\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._wheelEventName, this._pointerWheelEvent);\r\n\r\n if (this._pointerInputClearObserver) {\r\n this._engine.onEndFrameObservable.remove(this._pointerInputClearObserver);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"webDeviceInputSystem.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/webDeviceInputSystem.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,EAA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C,kBAAkB,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAChF,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAE5E,iBAAiB;QACjB,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,IAAI,CAAC,YAAY,GAAG,MAAM,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAChG,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,IAAI,CAAC,YAAY,GAAG,MAAM,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAChG,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,IAAI,CAAC,YAAY,GAAG,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QAC5F,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAE3F,IAAI,IAAI,CAAC,0BAA0B,EAAE;YACjC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;SAC7E;IACL,CAAC;IACL,2BAAC;AAAD,CAAC,AAzvBD,IAyvBC","sourcesContent":["import { Engine } from \"../../Engines/engine\";\r\nimport { IEvent } from \"../../Events/deviceInputEvents\";\r\nimport { DomManagement } from \"../../Misc/domManagement\";\r\nimport { Observer } from \"../../Misc/observable\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { Nullable } from \"../../types\";\r\nimport { DeviceEventFactory } from \"../Helpers/eventFactory\";\r\nimport { DeviceType, PointerInput } from \"./deviceEnums\";\r\nimport { IDeviceEvent, IDeviceInputSystem } from \"./inputInterfaces\";\r\n\r\nconst MAX_KEYCODES = 255;\r\nconst MAX_POINTER_INPUTS = Object.keys(PointerInput).length / 2;\r\n\r\n/** @hidden */\r\nexport class WebDeviceInputSystem implements IDeviceInputSystem {\r\n /** onDeviceConnected property */\r\n public set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void) {\r\n this._onDeviceConnected = callback;\r\n\r\n // Iterate through each active device and rerun new callback\r\n for (let deviceType = 0; deviceType < this._inputs.length; deviceType++) {\r\n const inputs = this._inputs[deviceType];\r\n if (inputs) {\r\n for (const deviceSlotKey in inputs) {\r\n const deviceSlot = +deviceSlotKey;\r\n if (this._inputs[deviceType][deviceSlot]) {\r\n this._onDeviceConnected(deviceType, deviceSlot);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n public get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void {\r\n return this._onDeviceConnected;\r\n }\r\n\r\n public onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n public onInputChanged: (deviceEvent: IDeviceEvent) => void;\r\n\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 readonly _engine: Engine;\r\n private readonly _usingSafari: boolean = Tools.IsSafari();\r\n\r\n private _onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n\r\n private _keyboardDownEvent = (evt: any) => { };\r\n private _keyboardUpEvent = (evt: any) => { };\r\n private _keyboardBlurEvent = (evt: any) => { };\r\n\r\n private _pointerMoveEvent = (evt: any) => { };\r\n private _pointerDownEvent = (evt: any) => { };\r\n private _pointerUpEvent = (evt: any) => { };\r\n private _pointerWheelEvent = (evt: any) => { };\r\n private _pointerBlurEvent = (evt: any) => { };\r\n private _wheelEventName: string;\r\n\r\n private _mouseId = -1;\r\n private readonly _isUsingFirefox = DomManagement.IsNavigatorAvailable() && navigator.userAgent && navigator.userAgent.indexOf(\"Firefox\") !== -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<Engine>> = null;\r\n\r\n private _gamepadConnectedEvent = (evt: any) => { };\r\n private _gamepadDisconnectedEvent = (evt: any) => { };\r\n\r\n private _eventPrefix: string;\r\n\r\n constructor(engine: Engine) {\r\n this._eventPrefix = Tools.GetPointerPrefix(engine);\r\n this._engine = engine;\r\n\r\n this.onDeviceConnected = (deviceType: DeviceType, deviceSlot: number) => { };\r\n this.onDeviceDisconnected = (deviceType: DeviceType, deviceSlot: number) => { };\r\n this.onInputChanged = (deviceEvent: IDeviceEvent) => { };\r\n\r\n this._configureEvents();\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 specifiying 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 throw `Unable to find device ${DeviceType[deviceType]}`;\r\n }\r\n\r\n if (deviceType >= DeviceType.DualShock && deviceType <= DeviceType.DualSense && navigator.getGamepads) {\r\n this._updateDevice(deviceType, deviceSlot, inputIndex);\r\n }\r\n\r\n const currentValue = device[inputIndex];\r\n if (currentValue === undefined) {\r\n throw `Unable to find input ${inputIndex} for device ${DeviceType[deviceType]} in slot ${deviceSlot}`;\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 // Observables\r\n this.onDeviceConnected = () => { };\r\n this.onDeviceDisconnected = () => { };\r\n this.onInputChanged = () => { };\r\n\r\n if (this._elementToAttachTo) {\r\n this._removeEvents();\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\r\n /**\r\n * Configures events to work with an engine's active element\r\n */\r\n private _configureEvents(): void {\r\n const inputElement = this._engine.getInputElement();\r\n if (inputElement && this._elementToAttachTo !== inputElement) {\r\n // If the engine's input element has changed, unregister events from previous element\r\n if (this._elementToAttachTo) {\r\n this._removeEvents();\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\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 * 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 (matchMedia('(pointer:fine)').matches) {\r\n // This will provide a dummy value for the cursor position and is expected to be overriden 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 specifiying 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 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 for (let i = 0; i < numberOfInputs; i++) {\r\n device[i] = 0; /* set device input as unpressed */\r\n }\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 specifiying 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 let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = DeviceType.Keyboard;\r\n deviceEvent.deviceSlot = 0;\r\n deviceEvent.inputIndex = evt.keyCode;\r\n deviceEvent.previousState = 0;\r\n deviceEvent.currentState = kbKey[evt.keyCode];\r\n\r\n this.onInputChanged(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 let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = DeviceType.Keyboard;\r\n deviceEvent.deviceSlot = 0;\r\n deviceEvent.inputIndex = evt.keyCode;\r\n deviceEvent.previousState = 1;\r\n deviceEvent.currentState = kbKey[evt.keyCode];\r\n\r\n this.onInputChanged(deviceEvent);\r\n }\r\n });\r\n\r\n this._keyboardBlurEvent = ((evt) => {\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 evt: IEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Keyboard, 0, i, 1, this, this._elementToAttachTo);\r\n const deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = DeviceType.Keyboard;\r\n deviceEvent.deviceSlot = 0;\r\n deviceEvent.inputIndex = i;\r\n deviceEvent.currentState = 0;\r\n deviceEvent.previousState = 1;\r\n this.onInputChanged(deviceEvent);\r\n }\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 this._maxTouchPoints = (DomManagement.IsNavigatorAvailable() && navigator.maxTouchPoints) || 0;\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 const deviceSlot = (deviceType === DeviceType.Mouse) ? 0 : this._activeTouchIds.indexOf(evt.pointerId);\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 pointer[PointerInput.Horizontal] = evt.clientX;\r\n pointer[PointerInput.Vertical] = evt.clientY;\r\n pointer[PointerInput.DeltaHorizontal] = evt.movementX;\r\n pointer[PointerInput.DeltaVertical] = evt.movementY;\r\n\r\n let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = deviceType;\r\n deviceEvent.deviceSlot = deviceSlot;\r\n deviceEvent.inputIndex = PointerInput.Move;\r\n\r\n this.onInputChanged(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 deviceEvent.previousState = pointer[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 deviceEvent.currentState = pointer[evt.button + 2];\r\n this.onInputChanged(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 }\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 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 const previousButton = pointer[evt.button + 2];\r\n\r\n if (deviceType === DeviceType.Mouse) { // Mouse; Among supported browsers, value is either 1 or 0 for mouse\r\n if (this._mouseId === -1) {\r\n if (evt.pointerId === undefined) { // If there is no pointerId (eg. manually dispatched MouseEvent)\r\n this._mouseId = this._isUsingFirefox ? 0 : 1;\r\n }\r\n else {\r\n this._mouseId = evt.pointerId;\r\n }\r\n }\r\n\r\n if (!document.pointerLockElement && this._elementToAttachTo.hasPointerCapture) {\r\n try {\r\n this._elementToAttachTo.setPointerCapture(this._mouseId);\r\n }\r\n catch (e) {\r\n // DO NOTHING\r\n }\r\n }\r\n }\r\n else { // Touch; Since touches are dynamically assigned, only set capture if we have an id\r\n if (evt.pointerId && !document.pointerLockElement && this._elementToAttachTo.hasPointerCapture) {\r\n try {\r\n this._elementToAttachTo.setPointerCapture(evt.pointerId);\r\n }\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 let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = deviceType;\r\n deviceEvent.deviceSlot = deviceSlot;\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 deviceEvent.previousState = previousButton;\r\n deviceEvent.currentState = pointer[deviceEvent.inputIndex];\r\n this.onInputChanged(deviceEvent);\r\n\r\n if (previousHorizontal !== evt.clientX || previousVertical !== evt.clientY) {\r\n deviceEvent.inputIndex = PointerInput.Move;\r\n\r\n this.onInputChanged(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 (deviceSlot === -1) {\r\n return;\r\n }\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 const previousButton = pointer[evt.button + 2];\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 let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = deviceType;\r\n deviceEvent.deviceSlot = deviceSlot;\r\n\r\n if (previousHorizontal !== evt.clientX || previousVertical !== evt.clientY) {\r\n deviceEvent.inputIndex = PointerInput.Move;\r\n\r\n this.onInputChanged(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 deviceEvent.previousState = previousButton;\r\n deviceEvent.currentState = pointer[deviceEvent.inputIndex];\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 }\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(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 // Set Wheel Event Name, code originally from scene.inputManager\r\n this._wheelEventName = \"onwheel\" in document.createElement(\"div\") ? \"wheel\" : // Modern browsers support \"wheel\"\r\n (<any>document).onmousewheel !== undefined ? \"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 = {\r\n passive: {\r\n get: function () {\r\n passiveSupported = true;\r\n }\r\n }\r\n };\r\n\r\n this._elementToAttachTo.addEventListener(\"test\", noop, options);\r\n this._elementToAttachTo.removeEventListener(\"test\", noop, options);\r\n }\r\n catch (e) {\r\n /* */\r\n }\r\n\r\n this._pointerBlurEvent = ((evt) => {\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 i = 0; i <= PointerInput.BrowserForward; i++) {\r\n if (pointer[i + 2] === 1) {\r\n pointer[i + 2] = 0;\r\n\r\n const evt: IEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Mouse, 0, i + 2, 1, this, this._elementToAttachTo);\r\n const deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = DeviceType.Mouse;\r\n deviceEvent.deviceSlot = 0;\r\n deviceEvent.inputIndex = i + 2;\r\n deviceEvent.currentState = pointer[i + 2];\r\n deviceEvent.previousState = 1;\r\n this.onInputChanged(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 evt: IEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Touch, deviceSlot, PointerInput.LeftClick, 1, this, this._elementToAttachTo);\r\n const deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = DeviceType.Touch;\r\n deviceEvent.deviceSlot = deviceSlot;\r\n deviceEvent.inputIndex = PointerInput.LeftClick;\r\n deviceEvent.currentState = pointer[deviceSlot][PointerInput.LeftClick];\r\n deviceEvent.previousState = 1;\r\n this.onInputChanged(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 // Store previous values for event\r\n let previousWheelScrollX = pointer[PointerInput.MouseWheelX];\r\n let previousWheelScrollY = pointer[PointerInput.MouseWheelY];\r\n let previousWheelScrollZ = pointer[PointerInput.MouseWheelZ];\r\n\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 let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = deviceType;\r\n deviceEvent.deviceSlot = deviceSlot;\r\n\r\n if (pointer[PointerInput.MouseWheelX] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelX;\r\n deviceEvent.previousState = previousWheelScrollX;\r\n deviceEvent.currentState = pointer[PointerInput.MouseWheelX];\r\n this.onInputChanged(deviceEvent);\r\n }\r\n if (pointer[PointerInput.MouseWheelY] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelY;\r\n deviceEvent.previousState = previousWheelScrollY;\r\n deviceEvent.currentState = pointer[PointerInput.MouseWheelY];\r\n this.onInputChanged(deviceEvent);\r\n }\r\n if (pointer[PointerInput.MouseWheelZ] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelZ;\r\n deviceEvent.previousState = previousWheelScrollZ;\r\n deviceEvent.currentState = pointer[PointerInput.MouseWheelZ];\r\n this.onInputChanged(deviceEvent);\r\n }\r\n }\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(\"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 pointer[PointerInput.DeltaHorizontal] = 0;\r\n pointer[PointerInput.DeltaVertical] = 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 specifiying 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 }\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) { // DualShock 4 Gamepad\r\n return (deviceName.indexOf(\"0ce6\") !== -1 ? DeviceType.DualSense : DeviceType.DualShock);\r\n }\r\n else if (deviceName.indexOf(\"Xbox One\") !== -1 || deviceName.search(\"Xbox 360\") !== -1 || deviceName.search(\"xinput\") !== -1) { // Xbox Gamepad\r\n return DeviceType.Xbox;\r\n }\r\n else if (deviceName.indexOf(\"057e\") !== -1) { // 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 /**\r\n * Remove events from active input element\r\n */\r\n private _removeEvents(): void {\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._wheelEventName, this._pointerWheelEvent);\r\n\r\n if (this._pointerInputClearObserver) {\r\n this._engine.onEndFrameObservable.remove(this._pointerInputClearObserver);\r\n }\r\n }\r\n}\r\n"]}
@@ -95,8 +95,9 @@ ThinEngine.prototype._setCubeMapTextureParams = function (texture, loadMipmap, m
95
95
  gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
96
96
  gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
97
97
  texture.samplingMode = loadMipmap ? 3 : 2;
98
- if (loadMipmap && this.getCaps().textureMaxLevel && maxLevel > 0) {
98
+ if (loadMipmap && this.getCaps().textureMaxLevel && maxLevel !== undefined && maxLevel > 0) {
99
99
  gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAX_LEVEL, maxLevel);
100
+ texture._maxLodLevel = maxLevel;
100
101
  }
101
102
  this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
102
103
  };
@@ -1 +1 @@
1
- {"version":3,"file":"engine.cubeTexture.js","sourceRoot":"","sources":["../../../../sourceES6/core/Engines/Extensions/engine.cubeTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAClG,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAI3C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAoG7C,UAAU,CAAC,SAAS,CAAC,8BAA8B,GAAG,UAAU,IAAY,EAAE,OAAoC,EAAE,SAA8B;IAC9I,IAAI,eAAe,GAAG,IAAI,eAAe,CAAC,IAAI,EAAE,qBAAqB,CAAC,YAAY,CAAC,CAAC;IACpF,eAAe,CAAC,MAAM,GAAG,IAAI,CAAC;IAE9B,IAAI,IAAI,CAAC,YAAY,KAAK,CAAC,EAAE;QACzB,MAAM,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC;QAChE,OAAO,eAAe,CAAC;KAC1B;IAED,IAAI,eAAe,cACf,iBAAiB,EAAE,KAAK,EACxB,kBAAkB,EAAE,CAAC,EACrB,eAAe,EAAE,KAAK,IACnB,OAAO,CACb,CAAC;IAEF,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC;IAClB,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC,gBAAgB,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC;IAEtE,IAAI,CAAC,yBAAyB,CAAC,eAAe,EAAE,IAAI,EAAE,eAAe,CAAC,eAAe,EAAE,eAAe,CA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AE,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;gBAC9G,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,cAAc,EAAE,WAAW,EAAE,EAAE,CAAC,aAAa,EAAE,KAAI,CAAC,cAAgC,CAAC,CAAC;aACxH;iBAAM;gBACH,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,cAAc,EAAE,WAAW,EAAE,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;aAC9F;SACJ;QAED,IAAI,CAAC,QAAQ,EAAE;YACX,EAAE,CAAC,cAAc,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC;SAC1C;QAED,KAAI,CAAC,wBAAwB,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC;QAElD,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;QACtB,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;QACxB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;QACvB,IAAI,MAAM,EAAE;YACR,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;SAC3B;QAED,OAAO,CAAC,kBAAkB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACpD,OAAO,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;QAEnC,IAAI,MAAM,EAAE;YACR,MAAM,EAAE,CAAC;SACZ;IACL,CAAC,EAAE,CAAC,CAAC,aAAa,CACrB,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { ThinEngine } from \"../../Engines/thinEngine\";\r\nimport { InternalTexture, InternalTextureSource } from '../../Materials/Textures/internalTexture';\r\nimport { Logger } from '../../Misc/logger';\r\nimport { Nullable } from '../../types';\r\nimport { Scene } from '../../scene';\r\nimport { IInternalTextureLoader } from '../../Materials/Textures/internalTextureLoader';\r\nimport { LoadImage } from '../../Misc/fileTools';\r\nimport { RandomGUID } from '../../Misc/guid';\r\nimport { IWebRequest } from '../../Misc/interfaces/iWebRequest';\r\n\r\nimport { DepthTextureCreationOptions } from \"../../Materials/Textures/textureCreationOptions\";\r\nimport { RenderTargetWrapper } from \"../renderTargetWrapper\";\r\n\r\ndeclare module \"../../Engines/thinEngine\" {\r\n export interface ThinEngine {\r\n /**\r\n * Creates a depth stencil cube texture.\r\n * This is only available in WebGL 2.\r\n * @param size The size of face edge in the cube texture.\r\n * @param options The options defining the cube texture.\r\n * @param rtWrapper The render target wrapper for which the depth/stencil texture must be created\r\n * @returns The cube texture\r\n */\r\n _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions, rtWrapper: RenderTargetWrapper): InternalTexture;\r\n\r\n /**\r\n * Creates a cube texture\r\n * @param rootUrl defines the url where the files to load is located\r\n * @param scene defines the current scene\r\n * @param files defines the list of files to load (1 per face)\r\n * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)\r\n * @param onLoad defines an optional callback raised when the texture is loaded\r\n * @param onError defines an optional callback raised if there is an issue to load the texture\r\n * @param format defines the format of the data\r\n * @param forcedExtension defines the extension to use to pick the right loader\r\n * @param createPolynomials if a polynomial sphere should be created for the cube texture\r\n * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness\r\n * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness\r\n * @param fallback defines texture to use while falling back when (compressed) texture file not found.\r\n * @param loaderOptions options to be passed to the loader\r\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\r\n * @returns the cube texture as an InternalTexture\r\n */\r\n createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined,\r\n onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>,\r\n format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any, useSRGBBuffer: boolean): InternalTexture;\r\n\r\n /**\r\n * Creates a cube texture\r\n * @param rootUrl defines the url where the files to load is located\r\n * @param scene defines the current scene\r\n * @param files defines the list of files to load (1 per face)\r\n * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)\r\n * @param onLoad defines an optional callback raised when the texture is loaded\r\n * @param onError defines an optional callback raised if there is an issue to load the texture\r\n * @param format defines the format of the data\r\n * @param forcedExtension defines the extension to use to pick the right loader\r\n * @returns the cube texture as an InternalTexture\r\n */\r\n createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean,\r\n onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>,\r\n format: number | undefined, forcedExtension: any): InternalTexture;\r\n\r\n /**\r\n * Creates a cube texture\r\n * @param rootUrl defines the url where the files to load is located\r\n * @param scene defines the current scene\r\n * @param files defines the list of files to load (1 per face)\r\n * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)\r\n * @param onLoad defines an optional callback raised when the texture is loaded\r\n * @param onError defines an optional callback raised if there is an issue to load the texture\r\n * @param format defines the format of the data\r\n * @param forcedExtension defines the extension to use to pick the right loader\r\n * @param createPolynomials if a polynomial sphere should be created for the cube texture\r\n * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness\r\n * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness\r\n * @returns the cube texture as an InternalTexture\r\n */\r\n createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean,\r\n onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>,\r\n format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;\r\n\r\n /** @hidden */\r\n createCubeTextureBase(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean,\r\n onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>,\r\n format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>,\r\n beforeLoadCubeDataCallback: Nullable<(texture: InternalTexture, data: ArrayBufferView | ArrayBufferView[]) => void>, imageHandler: Nullable<(texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => void>, useSRGBBuffer: boolean): InternalTexture;\r\n\r\n /** @hidden */\r\n _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;\r\n\r\n /** @hidden */\r\n _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;\r\n\r\n /** @hidden */\r\n _cascadeLoadImgs(scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;\r\n\r\n /** @hidden */\r\n _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[] | ImageBitmap[], scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;\r\n\r\n /**\r\n * @hidden\r\n */\r\n _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean, maxLevel?: number): void;\r\n }\r\n}\r\n\r\nThinEngine.prototype._createDepthStencilCubeTexture = function (size: number, options: DepthTextureCreationOptions, rtWrapper: RenderTargetWrapper): InternalTexture {\r\n var internalTexture = new InternalTexture(this, InternalTextureSource.DepthStencil);\r\n internalTexture.isCube = true;\r\n\r\n if (this.webGLVersion === 1) {\r\n Logger.Error(\"Depth cube texture is not supported by WebGL 1.\");\r\n return internalTexture;\r\n }\r\n\r\n var internalOptions = {\r\n bilinearFiltering: false,\r\n comparisonFunction: 0,\r\n generateStencil: false,\r\n ...options\r\n };\r\n\r\n var gl = this._gl;\r\n this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);\r\n\r\n this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);\r\n\r\n rtWrapper._depthStencilTexture = internalTexture;\r\n rtWrapper._depthStencilTextureWithStencil = internalOptions.generateStencil;\r\n\r\n // Create the depth/stencil buffer\r\n for (var face = 0; face < 6; face++) {\r\n if (internalOptions.generateStencil) {\r\n gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH24_STENCIL8, size, size, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);\r\n }\r\n else {\r\n gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);\r\n }\r\n }\r\n\r\n this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);\r\n\r\n this._internalTexturesCache.push(internalTexture);\r\n\r\n return internalTexture;\r\n};\r\n\r\nThinEngine.prototype._partialLoadFile = function (url: string, index: number, loadedFiles: ArrayBuffer[],\r\n onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void> = null): void {\r\n var onload = (data: ArrayBuffer) => {\r\n loadedFiles[index] = data;\r\n (<any>loadedFiles)._internalCount++;\r\n\r\n if ((<any>loadedFiles)._internalCount === 6) {\r\n onfinish(loadedFiles);\r\n }\r\n };\r\n\r\n const onerror = (request?: IWebRequest, exception?: any) => {\r\n if (onErrorCallBack && request) {\r\n onErrorCallBack(request.status + \" \" + request.statusText, exception);\r\n }\r\n };\r\n\r\n this._loadFile(url, onload as (data: string | ArrayBuffer) => void, undefined, undefined, true, onerror);\r\n};\r\n\r\nThinEngine.prototype._cascadeLoadFiles = function (scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void> = null): void {\r\n var loadedFiles: ArrayBuffer[] = [];\r\n (<any>loadedFiles)._internalCount = 0;\r\n\r\n for (let index = 0; index < 6; index++) {\r\n this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);\r\n }\r\n};\r\n\r\nThinEngine.prototype._cascadeLoadImgs = function (scene: Nullable<Scene>, texture: InternalTexture,\r\n onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, files: string[], onError: Nullable<(message?: string, exception?: any) => void> = null, mimeType?: string) {\r\n\r\n var loadedImages: HTMLImageElement[] | ImageBitmap[] = [];\r\n (<any>loadedImages)._internalCount = 0;\r\n\r\n for (let index = 0; index < 6; index++) {\r\n this._partialLoadImg(files[index], index, loadedImages, scene, texture, onfinish, onError, mimeType);\r\n }\r\n};\r\n\r\nThinEngine.prototype._partialLoadImg = function (url: string, index: number, loadedImages: HTMLImageElement[] | ImageBitmap[], scene: Nullable<Scene>, texture: InternalTexture,\r\n onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, onErrorCallBack: Nullable<(message?: string, exception?: any) => void> = null, mimeType?: string) {\r\n\r\n var tokenPendingData = RandomGUID();\r\n\r\n var onload = (img: HTMLImageElement | ImageBitmap) => {\r\n loadedImages[index] = img;\r\n (<any>loadedImages)._internalCount++;\r\n\r\n if (scene) {\r\n scene._removePendingData(tokenPendingData);\r\n }\r\n\r\n if ((<any>loadedImages)._internalCount === 6 && onfinish) {\r\n onfinish(texture, loadedImages);\r\n }\r\n };\r\n\r\n var onerror = (message?: string, exception?: any) => {\r\n if (scene) {\r\n scene._removePendingData(tokenPendingData);\r\n }\r\n\r\n if (onErrorCallBack) {\r\n onErrorCallBack(message, exception);\r\n }\r\n };\r\n\r\n LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null, mimeType);\r\n if (scene) {\r\n scene._addPendingData(tokenPendingData);\r\n }\r\n};\r\n\r\nThinEngine.prototype._setCubeMapTextureParams = function (texture: InternalTexture, loadMipmap: boolean, maxLevel: number): void {\r\n var gl = this._gl;\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\r\n texture.samplingMode = loadMipmap ? 3 : 2;\r\n\r\n if (loadMipmap && this.getCaps().textureMaxLevel && maxLevel > 0) {\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAX_LEVEL, maxLevel);\r\n }\r\n\r\n this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);\r\n};\r\n\r\nThinEngine.prototype.createCubeTextureBase = function (rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad: Nullable<(data?: any) => void> = null,\r\n onError: Nullable<(message?: string, exception?: any) => void> = null, format?: number, forcedExtension: any = null, createPolynomials: boolean = false, lodScale: number = 0, lodOffset: number = 0,\r\n fallback: Nullable<InternalTexture> = null, beforeLoadCubeDataCallback: Nullable<(texture: InternalTexture, data: ArrayBufferView | ArrayBufferView[]) => void> = null,\r\n imageHandler: Nullable<(texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => void> = null, useSRGBBuffer = false): InternalTexture {\r\n const texture = fallback ? fallback : new InternalTexture(this, InternalTextureSource.Cube);\r\n texture.isCube = true;\r\n texture.url = rootUrl;\r\n texture.generateMipMaps = !noMipmap;\r\n texture._lodGenerationScale = lodScale;\r\n texture._lodGenerationOffset = lodOffset;\r\n texture._useSRGBBuffer = !!useSRGBBuffer && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU || !!noMipmap);\r\n\r\n if (!this._doNotHandleContextLost) {\r\n texture._extension = forcedExtension;\r\n texture._files = files;\r\n }\r\n\r\n const originalRootUrl = rootUrl;\r\n if (this._transformTextureUrl && !fallback) {\r\n rootUrl = this._transformTextureUrl(rootUrl);\r\n }\r\n\r\n const lastDot = rootUrl.lastIndexOf('.');\r\n const extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : \"\");\r\n\r\n let loader: Nullable<IInternalTextureLoader> = null;\r\n for (let availableLoader of ThinEngine._TextureLoaders) {\r\n if (availableLoader.canLoad(extension)) {\r\n loader = availableLoader;\r\n break;\r\n }\r\n }\r\n\r\n const onInternalError = (request?: IWebRequest, exception?: any) => {\r\n if (rootUrl === originalRootUrl) {\r\n if (onError && request) {\r\n onError(request.status + \" \" + request.statusText, exception);\r\n }\r\n }\r\n else {\r\n // fall back to the original url if the transformed url fails to load\r\n Logger.Warn(`Failed to load ${rootUrl}, falling back to the ${originalRootUrl}`);\r\n this.createCubeTextureBase(originalRootUrl, scene, files, !!noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, texture, beforeLoadCubeDataCallback, imageHandler, useSRGBBuffer);\r\n }\r\n };\r\n\r\n if (loader) {\r\n const onloaddata = (data: ArrayBufferView | ArrayBufferView[]) => {\r\n if (beforeLoadCubeDataCallback) {\r\n beforeLoadCubeDataCallback(texture, data);\r\n }\r\n loader!.loadCubeData(data, texture, createPolynomials, onLoad, onError);\r\n };\r\n if (files && files.length === 6) {\r\n if (loader.supportCascades) {\r\n this._cascadeLoadFiles(scene, (images) => onloaddata(images.map((image) => new Uint8Array(image))), files, onError);\r\n }\r\n else {\r\n if (onError) {\r\n onError(\"Textures type does not support cascades.\");\r\n } else {\r\n Logger.Warn(\"Texture loader does not support cascades.\");\r\n }\r\n }\r\n }\r\n else {\r\n this._loadFile(rootUrl, (data) => onloaddata(new Uint8Array(data as ArrayBuffer)), undefined, undefined, true, onInternalError);\r\n }\r\n }\r\n else {\r\n if (!files) {\r\n throw new Error(\"Cannot load cubemap because files were not defined\");\r\n }\r\n\r\n this._cascadeLoadImgs(scene, texture, (texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => {\r\n if (imageHandler) {\r\n imageHandler(texture, imgs);\r\n }\r\n }, files, onError);\r\n }\r\n\r\n this._internalTexturesCache.push(texture);\r\n\r\n return texture;\r\n};\r\n\r\nThinEngine.prototype.createCubeTexture = function (rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad: Nullable<(data?: any) => void> = null,\r\n onError: Nullable<(message?: string, exception?: any) => void> = null, format?: number, forcedExtension: any = null, createPolynomials: boolean = false, lodScale: number = 0, lodOffset: number = 0,\r\n fallback: Nullable<InternalTexture> = null, loaderOptions?: any, useSRGBBuffer = false): InternalTexture {\r\n const gl = this._gl;\r\n\r\n return this.createCubeTextureBase(\r\n rootUrl, scene, files, !!noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback,\r\n (texture: InternalTexture, data: ArrayBufferView | ArrayBufferView[]) => this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true),\r\n (texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => {\r\n const width = this.needPOTTextures ? ThinEngine.GetExponentOfTwo(imgs[0].width, this._caps.maxCubemapTextureSize) : imgs[0].width;\r\n const height = width;\r\n\r\n const faces = [\r\n gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,\r\n gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z\r\n ];\r\n\r\n this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);\r\n this._unpackFlipY(false);\r\n\r\n const internalFormat = format ? this._getInternalFormat(format, texture._useSRGBBuffer) : (texture._useSRGBBuffer ? gl.SRGB8_ALPHA8 : gl.RGBA);\r\n let texelFormat = format ? this._getInternalFormat(format) : gl.RGBA;\r\n\r\n if (texture._useSRGBBuffer && this.webGLVersion === 1) {\r\n texelFormat = internalFormat;\r\n }\r\n\r\n for (var index = 0; index < faces.length; index++) {\r\n if (imgs[index].width !== width || imgs[index].height !== height) {\r\n\r\n this._prepareWorkingCanvas();\r\n\r\n if (!this._workingCanvas || !this._workingContext) {\r\n Logger.Warn(\"Cannot create canvas to resize texture.\");\r\n return;\r\n }\r\n this._workingCanvas.width = width;\r\n this._workingCanvas.height = height;\r\n\r\n this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);\r\n gl.texImage2D(faces[index], 0, internalFormat, texelFormat, gl.UNSIGNED_BYTE, this._workingCanvas as TexImageSource);\r\n } else {\r\n gl.texImage2D(faces[index], 0, internalFormat, texelFormat, gl.UNSIGNED_BYTE, imgs[index]);\r\n }\r\n }\r\n\r\n if (!noMipmap) {\r\n gl.generateMipmap(gl.TEXTURE_CUBE_MAP);\r\n }\r\n\r\n this._setCubeMapTextureParams(texture, !noMipmap);\r\n\r\n texture.width = width;\r\n texture.height = height;\r\n texture.isReady = true;\r\n if (format) {\r\n texture.format = format;\r\n }\r\n\r\n texture.onLoadedObservable.notifyObservers(texture);\r\n texture.onLoadedObservable.clear();\r\n\r\n if (onLoad) {\r\n onLoad();\r\n }\r\n }, !!useSRGBBuffer\r\n );\r\n};\r\n"]}
1
+ {"version":3,"file":"engine.cubeTexture.js","sourceRoot":"","sources":["../../../../sourceES6/core/Engines/Extensions/engine.cubeTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU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AAC,cAAgC,CAAC,CAAC;aACxH;iBAAM;gBACH,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,cAAc,EAAE,WAAW,EAAE,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;aAC9F;SACJ;QAED,IAAI,CAAC,QAAQ,EAAE;YACX,EAAE,CAAC,cAAc,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC;SAC1C;QAED,KAAI,CAAC,wBAAwB,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC;QAElD,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;QACtB,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;QACxB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;QACvB,IAAI,MAAM,EAAE;YACR,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;SAC3B;QAED,OAAO,CAAC,kBAAkB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACpD,OAAO,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;QAEnC,IAAI,MAAM,EAAE;YACR,MAAM,EAAE,CAAC;SACZ;IACL,CAAC,EAAE,CAAC,CAAC,aAAa,CACrB,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { ThinEngine } from \"../../Engines/thinEngine\";\r\nimport { InternalTexture, InternalTextureSource } from '../../Materials/Textures/internalTexture';\r\nimport { Logger } from '../../Misc/logger';\r\nimport { Nullable } from '../../types';\r\nimport { Scene } from '../../scene';\r\nimport { IInternalTextureLoader } from '../../Materials/Textures/internalTextureLoader';\r\nimport { LoadImage } from '../../Misc/fileTools';\r\nimport { RandomGUID } from '../../Misc/guid';\r\nimport { IWebRequest } from '../../Misc/interfaces/iWebRequest';\r\n\r\nimport { DepthTextureCreationOptions } from \"../../Materials/Textures/textureCreationOptions\";\r\nimport { RenderTargetWrapper } from \"../renderTargetWrapper\";\r\n\r\ndeclare module \"../../Engines/thinEngine\" {\r\n export interface ThinEngine {\r\n /**\r\n * Creates a depth stencil cube texture.\r\n * This is only available in WebGL 2.\r\n * @param size The size of face edge in the cube texture.\r\n * @param options The options defining the cube texture.\r\n * @param rtWrapper The render target wrapper for which the depth/stencil texture must be created\r\n * @returns The cube texture\r\n */\r\n _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions, rtWrapper: RenderTargetWrapper): InternalTexture;\r\n\r\n /**\r\n * Creates a cube texture\r\n * @param rootUrl defines the url where the files to load is located\r\n * @param scene defines the current scene\r\n * @param files defines the list of files to load (1 per face)\r\n * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)\r\n * @param onLoad defines an optional callback raised when the texture is loaded\r\n * @param onError defines an optional callback raised if there is an issue to load the texture\r\n * @param format defines the format of the data\r\n * @param forcedExtension defines the extension to use to pick the right loader\r\n * @param createPolynomials if a polynomial sphere should be created for the cube texture\r\n * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness\r\n * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness\r\n * @param fallback defines texture to use while falling back when (compressed) texture file not found.\r\n * @param loaderOptions options to be passed to the loader\r\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\r\n * @returns the cube texture as an InternalTexture\r\n */\r\n createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined,\r\n onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>,\r\n format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any, useSRGBBuffer: boolean): InternalTexture;\r\n\r\n /**\r\n * Creates a cube texture\r\n * @param rootUrl defines the url where the files to load is located\r\n * @param scene defines the current scene\r\n * @param files defines the list of files to load (1 per face)\r\n * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)\r\n * @param onLoad defines an optional callback raised when the texture is loaded\r\n * @param onError defines an optional callback raised if there is an issue to load the texture\r\n * @param format defines the format of the data\r\n * @param forcedExtension defines the extension to use to pick the right loader\r\n * @returns the cube texture as an InternalTexture\r\n */\r\n createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean,\r\n onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>,\r\n format: number | undefined, forcedExtension: any): InternalTexture;\r\n\r\n /**\r\n * Creates a cube texture\r\n * @param rootUrl defines the url where the files to load is located\r\n * @param scene defines the current scene\r\n * @param files defines the list of files to load (1 per face)\r\n * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)\r\n * @param onLoad defines an optional callback raised when the texture is loaded\r\n * @param onError defines an optional callback raised if there is an issue to load the texture\r\n * @param format defines the format of the data\r\n * @param forcedExtension defines the extension to use to pick the right loader\r\n * @param createPolynomials if a polynomial sphere should be created for the cube texture\r\n * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness\r\n * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness\r\n * @returns the cube texture as an InternalTexture\r\n */\r\n createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean,\r\n onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>,\r\n format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;\r\n\r\n /** @hidden */\r\n createCubeTextureBase(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean,\r\n onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>,\r\n format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>,\r\n beforeLoadCubeDataCallback: Nullable<(texture: InternalTexture, data: ArrayBufferView | ArrayBufferView[]) => void>, imageHandler: Nullable<(texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => void>, useSRGBBuffer: boolean): InternalTexture;\r\n\r\n /** @hidden */\r\n _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;\r\n\r\n /** @hidden */\r\n _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;\r\n\r\n /** @hidden */\r\n _cascadeLoadImgs(scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;\r\n\r\n /** @hidden */\r\n _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[] | ImageBitmap[], scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;\r\n\r\n /**\r\n * @hidden\r\n */\r\n _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean, maxLevel?: number): void;\r\n }\r\n}\r\n\r\nThinEngine.prototype._createDepthStencilCubeTexture = function (size: number, options: DepthTextureCreationOptions, rtWrapper: RenderTargetWrapper): InternalTexture {\r\n var internalTexture = new InternalTexture(this, InternalTextureSource.DepthStencil);\r\n internalTexture.isCube = true;\r\n\r\n if (this.webGLVersion === 1) {\r\n Logger.Error(\"Depth cube texture is not supported by WebGL 1.\");\r\n return internalTexture;\r\n }\r\n\r\n var internalOptions = {\r\n bilinearFiltering: false,\r\n comparisonFunction: 0,\r\n generateStencil: false,\r\n ...options\r\n };\r\n\r\n var gl = this._gl;\r\n this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);\r\n\r\n this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);\r\n\r\n rtWrapper._depthStencilTexture = internalTexture;\r\n rtWrapper._depthStencilTextureWithStencil = internalOptions.generateStencil;\r\n\r\n // Create the depth/stencil buffer\r\n for (var face = 0; face < 6; face++) {\r\n if (internalOptions.generateStencil) {\r\n gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH24_STENCIL8, size, size, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);\r\n }\r\n else {\r\n gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);\r\n }\r\n }\r\n\r\n this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);\r\n\r\n this._internalTexturesCache.push(internalTexture);\r\n\r\n return internalTexture;\r\n};\r\n\r\nThinEngine.prototype._partialLoadFile = function (url: string, index: number, loadedFiles: ArrayBuffer[],\r\n onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void> = null): void {\r\n var onload = (data: ArrayBuffer) => {\r\n loadedFiles[index] = data;\r\n (<any>loadedFiles)._internalCount++;\r\n\r\n if ((<any>loadedFiles)._internalCount === 6) {\r\n onfinish(loadedFiles);\r\n }\r\n };\r\n\r\n const onerror = (request?: IWebRequest, exception?: any) => {\r\n if (onErrorCallBack && request) {\r\n onErrorCallBack(request.status + \" \" + request.statusText, exception);\r\n }\r\n };\r\n\r\n this._loadFile(url, onload as (data: string | ArrayBuffer) => void, undefined, undefined, true, onerror);\r\n};\r\n\r\nThinEngine.prototype._cascadeLoadFiles = function (scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void> = null): void {\r\n var loadedFiles: ArrayBuffer[] = [];\r\n (<any>loadedFiles)._internalCount = 0;\r\n\r\n for (let index = 0; index < 6; index++) {\r\n this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);\r\n }\r\n};\r\n\r\nThinEngine.prototype._cascadeLoadImgs = function (scene: Nullable<Scene>, texture: InternalTexture,\r\n onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, files: string[], onError: Nullable<(message?: string, exception?: any) => void> = null, mimeType?: string) {\r\n\r\n var loadedImages: HTMLImageElement[] | ImageBitmap[] = [];\r\n (<any>loadedImages)._internalCount = 0;\r\n\r\n for (let index = 0; index < 6; index++) {\r\n this._partialLoadImg(files[index], index, loadedImages, scene, texture, onfinish, onError, mimeType);\r\n }\r\n};\r\n\r\nThinEngine.prototype._partialLoadImg = function (url: string, index: number, loadedImages: HTMLImageElement[] | ImageBitmap[], scene: Nullable<Scene>, texture: InternalTexture,\r\n onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, onErrorCallBack: Nullable<(message?: string, exception?: any) => void> = null, mimeType?: string) {\r\n\r\n var tokenPendingData = RandomGUID();\r\n\r\n var onload = (img: HTMLImageElement | ImageBitmap) => {\r\n loadedImages[index] = img;\r\n (<any>loadedImages)._internalCount++;\r\n\r\n if (scene) {\r\n scene._removePendingData(tokenPendingData);\r\n }\r\n\r\n if ((<any>loadedImages)._internalCount === 6 && onfinish) {\r\n onfinish(texture, loadedImages);\r\n }\r\n };\r\n\r\n var onerror = (message?: string, exception?: any) => {\r\n if (scene) {\r\n scene._removePendingData(tokenPendingData);\r\n }\r\n\r\n if (onErrorCallBack) {\r\n onErrorCallBack(message, exception);\r\n }\r\n };\r\n\r\n LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null, mimeType);\r\n if (scene) {\r\n scene._addPendingData(tokenPendingData);\r\n }\r\n};\r\n\r\nThinEngine.prototype._setCubeMapTextureParams = function (texture: InternalTexture, loadMipmap: boolean, maxLevel?: number): void {\r\n var gl = this._gl;\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\r\n texture.samplingMode = loadMipmap ? 3 : 2;\r\n\r\n if (loadMipmap && this.getCaps().textureMaxLevel && maxLevel !== undefined && maxLevel > 0) {\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAX_LEVEL, maxLevel);\r\n texture._maxLodLevel = maxLevel;\r\n }\r\n\r\n this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);\r\n};\r\n\r\nThinEngine.prototype.createCubeTextureBase = function (rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad: Nullable<(data?: any) => void> = null,\r\n onError: Nullable<(message?: string, exception?: any) => void> = null, format?: number, forcedExtension: any = null, createPolynomials: boolean = false, lodScale: number = 0, lodOffset: number = 0,\r\n fallback: Nullable<InternalTexture> = null, beforeLoadCubeDataCallback: Nullable<(texture: InternalTexture, data: ArrayBufferView | ArrayBufferView[]) => void> = null,\r\n imageHandler: Nullable<(texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => void> = null, useSRGBBuffer = false): InternalTexture {\r\n const texture = fallback ? fallback : new InternalTexture(this, InternalTextureSource.Cube);\r\n texture.isCube = true;\r\n texture.url = rootUrl;\r\n texture.generateMipMaps = !noMipmap;\r\n texture._lodGenerationScale = lodScale;\r\n texture._lodGenerationOffset = lodOffset;\r\n texture._useSRGBBuffer = !!useSRGBBuffer && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU || !!noMipmap);\r\n\r\n if (!this._doNotHandleContextLost) {\r\n texture._extension = forcedExtension;\r\n texture._files = files;\r\n }\r\n\r\n const originalRootUrl = rootUrl;\r\n if (this._transformTextureUrl && !fallback) {\r\n rootUrl = this._transformTextureUrl(rootUrl);\r\n }\r\n\r\n const lastDot = rootUrl.lastIndexOf('.');\r\n const extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : \"\");\r\n\r\n let loader: Nullable<IInternalTextureLoader> = null;\r\n for (let availableLoader of ThinEngine._TextureLoaders) {\r\n if (availableLoader.canLoad(extension)) {\r\n loader = availableLoader;\r\n break;\r\n }\r\n }\r\n\r\n const onInternalError = (request?: IWebRequest, exception?: any) => {\r\n if (rootUrl === originalRootUrl) {\r\n if (onError && request) {\r\n onError(request.status + \" \" + request.statusText, exception);\r\n }\r\n }\r\n else {\r\n // fall back to the original url if the transformed url fails to load\r\n Logger.Warn(`Failed to load ${rootUrl}, falling back to the ${originalRootUrl}`);\r\n this.createCubeTextureBase(originalRootUrl, scene, files, !!noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, texture, beforeLoadCubeDataCallback, imageHandler, useSRGBBuffer);\r\n }\r\n };\r\n\r\n if (loader) {\r\n const onloaddata = (data: ArrayBufferView | ArrayBufferView[]) => {\r\n if (beforeLoadCubeDataCallback) {\r\n beforeLoadCubeDataCallback(texture, data);\r\n }\r\n loader!.loadCubeData(data, texture, createPolynomials, onLoad, onError);\r\n };\r\n if (files && files.length === 6) {\r\n if (loader.supportCascades) {\r\n this._cascadeLoadFiles(scene, (images) => onloaddata(images.map((image) => new Uint8Array(image))), files, onError);\r\n }\r\n else {\r\n if (onError) {\r\n onError(\"Textures type does not support cascades.\");\r\n } else {\r\n Logger.Warn(\"Texture loader does not support cascades.\");\r\n }\r\n }\r\n }\r\n else {\r\n this._loadFile(rootUrl, (data) => onloaddata(new Uint8Array(data as ArrayBuffer)), undefined, undefined, true, onInternalError);\r\n }\r\n }\r\n else {\r\n if (!files) {\r\n throw new Error(\"Cannot load cubemap because files were not defined\");\r\n }\r\n\r\n this._cascadeLoadImgs(scene, texture, (texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => {\r\n if (imageHandler) {\r\n imageHandler(texture, imgs);\r\n }\r\n }, files, onError);\r\n }\r\n\r\n this._internalTexturesCache.push(texture);\r\n\r\n return texture;\r\n};\r\n\r\nThinEngine.prototype.createCubeTexture = function (rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad: Nullable<(data?: any) => void> = null,\r\n onError: Nullable<(message?: string, exception?: any) => void> = null, format?: number, forcedExtension: any = null, createPolynomials: boolean = false, lodScale: number = 0, lodOffset: number = 0,\r\n fallback: Nullable<InternalTexture> = null, loaderOptions?: any, useSRGBBuffer = false): InternalTexture {\r\n const gl = this._gl;\r\n\r\n return this.createCubeTextureBase(\r\n rootUrl, scene, files, !!noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback,\r\n (texture: InternalTexture, data: ArrayBufferView | ArrayBufferView[]) => this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true),\r\n (texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => {\r\n const width = this.needPOTTextures ? ThinEngine.GetExponentOfTwo(imgs[0].width, this._caps.maxCubemapTextureSize) : imgs[0].width;\r\n const height = width;\r\n\r\n const faces = [\r\n gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,\r\n gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z\r\n ];\r\n\r\n this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);\r\n this._unpackFlipY(false);\r\n\r\n const internalFormat = format ? this._getInternalFormat(format, texture._useSRGBBuffer) : (texture._useSRGBBuffer ? gl.SRGB8_ALPHA8 : gl.RGBA);\r\n let texelFormat = format ? this._getInternalFormat(format) : gl.RGBA;\r\n\r\n if (texture._useSRGBBuffer && this.webGLVersion === 1) {\r\n texelFormat = internalFormat;\r\n }\r\n\r\n for (var index = 0; index < faces.length; index++) {\r\n if (imgs[index].width !== width || imgs[index].height !== height) {\r\n\r\n this._prepareWorkingCanvas();\r\n\r\n if (!this._workingCanvas || !this._workingContext) {\r\n Logger.Warn(\"Cannot create canvas to resize texture.\");\r\n return;\r\n }\r\n this._workingCanvas.width = width;\r\n this._workingCanvas.height = height;\r\n\r\n this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);\r\n gl.texImage2D(faces[index], 0, internalFormat, texelFormat, gl.UNSIGNED_BYTE, this._workingCanvas as TexImageSource);\r\n } else {\r\n gl.texImage2D(faces[index], 0, internalFormat, texelFormat, gl.UNSIGNED_BYTE, imgs[index]);\r\n }\r\n }\r\n\r\n if (!noMipmap) {\r\n gl.generateMipmap(gl.TEXTURE_CUBE_MAP);\r\n }\r\n\r\n this._setCubeMapTextureParams(texture, !noMipmap);\r\n\r\n texture.width = width;\r\n texture.height = height;\r\n texture.isReady = true;\r\n if (format) {\r\n texture.format = format;\r\n }\r\n\r\n texture.onLoadedObservable.notifyObservers(texture);\r\n texture.onLoadedObservable.clear();\r\n\r\n if (onLoad) {\r\n onLoad();\r\n }\r\n }, !!useSRGBBuffer\r\n );\r\n};\r\n"]}
@@ -41,9 +41,12 @@ WebGPUEngine.prototype.createCubeTexture = function (rootUrl, scene, files, noMi
41
41
  }
42
42
  }, !!useSRGBBuffer);
43
43
  };
44
- WebGPUEngine.prototype._setCubeMapTextureParams = function (texture, loadMipmap) {
44
+ WebGPUEngine.prototype._setCubeMapTextureParams = function (texture, loadMipmap, maxLevel) {
45
45
  texture.samplingMode = loadMipmap ? 3 : 2;
46
46
  texture._cachedWrapU = 0;
47
47
  texture._cachedWrapV = 0;
48
+ if (maxLevel) {
49
+ texture._maxLodLevel = maxLevel;
50
+ }
48
51
  };
49
52
  //# sourceMappingURL=engine.cubeTexture.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine.cubeTexture.js","sourceRoot":"","sources":["../../../../../sourceES6/core/Engines/WebGPU/Extensions/engine.cubeTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAIrG,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIlD,YAAY,CAAC,SAAS,CAAC,8BAA8B,GAAG,UAAU,IAAY,EAAE,OAAoC;IAChH,IAAM,eAAe,GAAG,IAAI,eAAe,CAAC,IAAI,EAAE,qBAAqB,CAAC,YAAY,CAAC,CAAC;IAEtF,eAAe,CAAC,MAAM,GAAG,IAAI,CAAC;IAE9B,IAAM,eAAe,cACjB,iBAAiB,EAAE,KAAK,EACxB,kBAAkB,EAAE,CAAC,EACrB,eAAe,EAAE,KAAK,EACtB,OAAO,EAAE,CAAC,IACP,OAAO,CACb,CAAC;IAEF,0CAA0C;IAC1C,eAAe,CAAC,MAAM,GAAG,eAAe,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAEnE,IAAI,CAAC,yBAAyB,CAAC,eAAe,EAAE,IAAI,EAAE,eAAe,CAAC,eAAe,EAAE,eAAe,CAAC,iBAAiB,EAAE,eAAe,CAAC,kBAAkB,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IAEvL,IAAI,CAAC,cAAc,CAAC,kCAAkC,CAAC,eAAe,CAAC,CAAC;IAExE,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAElD,OAAO,eAAe,CAAC;AAC3B,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,iBAAiB,GAAG,UAAU,OAAe,EAAE,KAAsB,EAAE,KAAyB,EAAE,QAAkB,EAAE,MAA6C,EACtL,O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AC,gBAAgB,CAAC,OAAO,EAAE,KAAI,CAAC,cAAc,CAAC,CAAC;SACvD;QAED,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;QAEvB,OAAO,CAAC,kBAAkB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACpD,OAAO,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;QAEnC,IAAI,MAAM,EAAE;YACR,MAAM,EAAE,CAAC;SACZ;IACL,CAAC,EAAE,CAAC,CAAC,aAAa,CACrB,CAAC;AACN,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,wBAAwB,GAAG,UAAU,OAAwB,EAAE,UAAmB;IACrG,OAAO,CAAC,YAAY,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,OAAO,CAAC,YAAY,GAAG,CAAC,CAAC;IACzB,OAAO,CAAC,YAAY,GAAG,CAAC,CAAC;AAC7B,CAAC,CAAC","sourcesContent":["import { InternalTexture, InternalTextureSource } from \"../../../Materials/Textures/internalTexture\";\r\nimport { Nullable } from \"../../../types\";\r\n\r\nimport { DepthTextureCreationOptions } from \"../../../Materials/Textures/textureCreationOptions\";\r\nimport { WebGPUEngine } from \"../../webgpuEngine\";\r\n\r\ndeclare type Scene = import(\"../../../scene\").Scene;\r\n\r\nWebGPUEngine.prototype._createDepthStencilCubeTexture = function (size: number, options: DepthTextureCreationOptions): InternalTexture {\r\n const internalTexture = new InternalTexture(this, InternalTextureSource.DepthStencil);\r\n\r\n internalTexture.isCube = true;\r\n\r\n const internalOptions = {\r\n bilinearFiltering: false,\r\n comparisonFunction: 0,\r\n generateStencil: false,\r\n samples: 1,\r\n ...options\r\n };\r\n\r\n // TODO WEBGPU allow to choose the format?\r\n internalTexture.format = internalOptions.generateStencil ? 13 : 14;\r\n\r\n this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction, internalOptions.samples);\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(internalTexture);\r\n\r\n this._internalTexturesCache.push(internalTexture);\r\n\r\n return internalTexture;\r\n};\r\n\r\nWebGPUEngine.prototype.createCubeTexture = function (rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad: Nullable<(data?: any) => void> = null,\r\n onError: Nullable<(message?: string, exception?: any) => void> = null, format?: number, forcedExtension: any = null, createPolynomials: boolean = false, lodScale: number = 0, lodOffset: number = 0,\r\n fallback: Nullable<InternalTexture> = null, useSRGBBuffer = false): InternalTexture {\r\n return this.createCubeTextureBase(\r\n rootUrl, scene, files, !!noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback,\r\n null,\r\n (texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => {\r\n const imageBitmaps = imgs as ImageBitmap[]; // we will always get an ImageBitmap array in WebGPU\r\n const width = imageBitmaps[0].width;\r\n const height = width;\r\n\r\n this._setCubeMapTextureParams(texture, !noMipmap);\r\n texture.format = format ?? -1;\r\n\r\n const gpuTextureWrapper = this._textureHelper.createGPUTextureForInternalTexture(texture, width, height);\r\n\r\n this._textureHelper.updateCubeTextures(imageBitmaps, gpuTextureWrapper.underlyingResource!, width, height, gpuTextureWrapper.format, false, false, 0, 0);\r\n\r\n if (!noMipmap) {\r\n this._generateMipmaps(texture, this._uploadEncoder);\r\n }\r\n\r\n texture.isReady = true;\r\n\r\n texture.onLoadedObservable.notifyObservers(texture);\r\n texture.onLoadedObservable.clear();\r\n\r\n if (onLoad) {\r\n onLoad();\r\n }\r\n }, !!useSRGBBuffer\r\n );\r\n};\r\n\r\nWebGPUEngine.prototype._setCubeMapTextureParams = function (texture: InternalTexture, loadMipmap: boolean) {\r\n texture.samplingMode = loadMipmap ? 3 : 2;\r\n texture._cachedWrapU = 0;\r\n texture._cachedWrapV = 0;\r\n};\r\n"]}
1
+ {"version":3,"file":"engine.cubeTexture.js","sourceRoot":"","sources":["../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eAAe,CAAC,OAAO,CAAC,CAAC;QACpD,OAAO,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;QAEnC,IAAI,MAAM,EAAE;YACR,MAAM,EAAE,CAAC;SACZ;IACL,CAAC,EAAE,CAAC,CAAC,aAAa,CACrB,CAAC;AACN,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,wBAAwB,GAAG,UAAU,OAAwB,EAAE,UAAmB,EAAE,QAAiB;IACxH,OAAO,CAAC,YAAY,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,OAAO,CAAC,YAAY,GAAG,CAAC,CAAC;IACzB,OAAO,CAAC,YAAY,GAAG,CAAC,CAAC;IACzB,IAAI,QAAQ,EAAE;QACV,OAAO,CAAC,YAAY,GAAG,QAAQ,CAAC;KACnC;AACL,CAAC,CAAC","sourcesContent":["import { InternalTexture, InternalTextureSource } from \"../../../Materials/Textures/internalTexture\";\r\nimport { Nullable } from \"../../../types\";\r\n\r\nimport { DepthTextureCreationOptions } from \"../../../Materials/Textures/textureCreationOptions\";\r\nimport { WebGPUEngine } from \"../../webgpuEngine\";\r\n\r\ndeclare type Scene = import(\"../../../scene\").Scene;\r\n\r\nWebGPUEngine.prototype._createDepthStencilCubeTexture = function (size: number, options: DepthTextureCreationOptions): InternalTexture {\r\n const internalTexture = new InternalTexture(this, InternalTextureSource.DepthStencil);\r\n\r\n internalTexture.isCube = true;\r\n\r\n const internalOptions = {\r\n bilinearFiltering: false,\r\n comparisonFunction: 0,\r\n generateStencil: false,\r\n samples: 1,\r\n ...options\r\n };\r\n\r\n // TODO WEBGPU allow to choose the format?\r\n internalTexture.format = internalOptions.generateStencil ? 13 : 14;\r\n\r\n this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction, internalOptions.samples);\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(internalTexture);\r\n\r\n this._internalTexturesCache.push(internalTexture);\r\n\r\n return internalTexture;\r\n};\r\n\r\nWebGPUEngine.prototype.createCubeTexture = function (rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad: Nullable<(data?: any) => void> = null,\r\n onError: Nullable<(message?: string, exception?: any) => void> = null, format?: number, forcedExtension: any = null, createPolynomials: boolean = false, lodScale: number = 0, lodOffset: number = 0,\r\n fallback: Nullable<InternalTexture> = null, useSRGBBuffer = false): InternalTexture {\r\n return this.createCubeTextureBase(\r\n rootUrl, scene, files, !!noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback,\r\n null,\r\n (texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => {\r\n const imageBitmaps = imgs as ImageBitmap[]; // we will always get an ImageBitmap array in WebGPU\r\n const width = imageBitmaps[0].width;\r\n const height = width;\r\n\r\n this._setCubeMapTextureParams(texture, !noMipmap);\r\n texture.format = format ?? -1;\r\n\r\n const gpuTextureWrapper = this._textureHelper.createGPUTextureForInternalTexture(texture, width, height);\r\n\r\n this._textureHelper.updateCubeTextures(imageBitmaps, gpuTextureWrapper.underlyingResource!, width, height, gpuTextureWrapper.format, false, false, 0, 0);\r\n\r\n if (!noMipmap) {\r\n this._generateMipmaps(texture, this._uploadEncoder);\r\n }\r\n\r\n texture.isReady = true;\r\n\r\n texture.onLoadedObservable.notifyObservers(texture);\r\n texture.onLoadedObservable.clear();\r\n\r\n if (onLoad) {\r\n onLoad();\r\n }\r\n }, !!useSRGBBuffer\r\n );\r\n};\r\n\r\nWebGPUEngine.prototype._setCubeMapTextureParams = function (texture: InternalTexture, loadMipmap: boolean, maxLevel?: number) {\r\n texture.samplingMode = loadMipmap ? 3 : 2;\r\n texture._cachedWrapU = 0;\r\n texture._cachedWrapV = 0;\r\n if (maxLevel) {\r\n texture._maxLodLevel = maxLevel;\r\n }\r\n};\r\n"]}
@@ -1131,13 +1131,20 @@ var WebGPUTextureHelper = /** @class */ (function () {
1131
1131
  gpuTextureWrapper.textureAdditionalUsages = isStorageTexture ? WebGPUConstants.TextureUsage.StorageBinding : 0;
1132
1132
  var hasMipMaps = texture.generateMipMaps;
1133
1133
  var layerCount = depth || 1;
1134
+ var mipmapCount;
1135
+ if (texture._maxLodLevel !== null) {
1136
+ mipmapCount = texture._maxLodLevel;
1137
+ }
1138
+ else {
1139
+ mipmapCount = hasMipMaps ? WebGPUTextureHelper.ComputeNumMipmapLevels(width, height) : 1;
1140
+ }
1134
1141
  if (texture.isCube) {
1135
1142
  var gpuTexture = this.createCubeTexture({ width: width, height: height }, texture.generateMipMaps, texture.generateMipMaps, texture.invertY, false, gpuTextureWrapper.format, 1, this._commandEncoderForCreation, gpuTextureWrapper.textureUsages, gpuTextureWrapper.textureAdditionalUsages);
1136
1143
  gpuTextureWrapper.set(gpuTexture);
1137
1144
  gpuTextureWrapper.createView({
1138
1145
  format: gpuTextureWrapper.format,
1139
1146
  dimension: WebGPUConstants.TextureViewDimension.Cube,
1140
- mipLevelCount: hasMipMaps ? WebGPUTextureHelper.ComputeNumMipmapLevels(width, height) : 1,
1147
+ mipLevelCount: mipmapCount,
1141
1148
  baseArrayLayer: 0,
1142
1149
  baseMipLevel: 0,
1143
1150
  arrayLayerCount: 6,
@@ -1150,7 +1157,7 @@ var WebGPUTextureHelper = /** @class */ (function () {
1150
1157
  gpuTextureWrapper.createView({
1151
1158
  format: gpuTextureWrapper.format,
1152
1159
  dimension: texture.is2DArray ? WebGPUConstants.TextureViewDimension.E2dArray : texture.is3D ? WebGPUConstants.TextureDimension.E3d : WebGPUConstants.TextureViewDimension.E2d,
1153
- mipLevelCount: hasMipMaps ? WebGPUTextureHelper.ComputeNumMipmapLevels(width, height) : 1,
1160
+ mipLevelCount: mipmapCount,
1154
1161
  baseArrayLayer: 0,
1155
1162
  baseMipLevel: 0,
1156
1163
  arrayLayerCount: texture.is3D ? 1 : layerCount,