@babylonjs/core 7.7.0 → 7.7.2

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 (86) hide show
  1. package/Animations/animatable.js +1 -1
  2. package/Animations/animatable.js.map +1 -1
  3. package/Animations/runtimeAnimation.d.ts +2 -1
  4. package/Animations/runtimeAnimation.js +3 -2
  5. package/Animations/runtimeAnimation.js.map +1 -1
  6. package/Buffers/buffer.nonFloatVertexBuffers.d.ts +12 -0
  7. package/Buffers/buffer.nonFloatVertexBuffers.js +81 -0
  8. package/Buffers/buffer.nonFloatVertexBuffers.js.map +1 -0
  9. package/Culling/boundingBox.d.ts +2 -2
  10. package/Culling/boundingBox.js +2 -2
  11. package/Culling/boundingBox.js.map +1 -1
  12. package/DeviceInput/webDeviceInputSystem.js +8 -2
  13. package/DeviceInput/webDeviceInputSystem.js.map +1 -1
  14. package/Engines/IPipelineContext.d.ts +12 -5
  15. package/Engines/IPipelineContext.js.map +1 -1
  16. package/Engines/Native/nativeInterfaces.d.ts +6 -1
  17. package/Engines/Native/nativeInterfaces.js.map +1 -1
  18. package/Engines/Native/nativePipelineContext.d.ts +6 -1
  19. package/Engines/Native/nativePipelineContext.js +3 -1
  20. package/Engines/Native/nativePipelineContext.js.map +1 -1
  21. package/Engines/Native/nativeShaderProcessingContext.d.ts +13 -0
  22. package/Engines/Native/nativeShaderProcessingContext.js +11 -0
  23. package/Engines/Native/nativeShaderProcessingContext.js.map +1 -0
  24. package/Engines/Native/nativeShaderProcessors.d.ts +15 -0
  25. package/Engines/Native/nativeShaderProcessors.js +75 -0
  26. package/Engines/Native/nativeShaderProcessors.js.map +1 -0
  27. package/Engines/Processors/shaderProcessingOptions.d.ts +3 -0
  28. package/Engines/Processors/shaderProcessingOptions.js.map +1 -1
  29. package/Engines/WebGPU/webgpuCacheRenderPipeline.d.ts +0 -2
  30. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +4 -59
  31. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  32. package/Engines/WebGPU/webgpuShaderProcessingContext.d.ts +3 -0
  33. package/Engines/WebGPU/webgpuShaderProcessingContext.js +1 -0
  34. package/Engines/WebGPU/webgpuShaderProcessingContext.js.map +1 -1
  35. package/Engines/WebGPU/webgpuShaderProcessor.d.ts +0 -4
  36. package/Engines/WebGPU/webgpuShaderProcessor.js +0 -26
  37. package/Engines/WebGPU/webgpuShaderProcessor.js.map +1 -1
  38. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js +4 -3
  39. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
  40. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +1 -1
  41. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +7 -7
  42. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  43. package/Engines/abstractEngine.js +2 -2
  44. package/Engines/abstractEngine.js.map +1 -1
  45. package/Engines/engine.d.ts +1 -1
  46. package/Engines/engineFeatures.d.ts +2 -0
  47. package/Engines/engineFeatures.js.map +1 -1
  48. package/Engines/nativeEngine.d.ts +7 -1
  49. package/Engines/nativeEngine.js +30 -9
  50. package/Engines/nativeEngine.js.map +1 -1
  51. package/Engines/nullEngine.d.ts +4 -0
  52. package/Engines/nullEngine.js +4 -0
  53. package/Engines/nullEngine.js.map +1 -1
  54. package/Engines/thinEngine.d.ts +4 -4
  55. package/Engines/thinEngine.js +1 -0
  56. package/Engines/thinEngine.js.map +1 -1
  57. package/Engines/webgpuEngine.js +1 -0
  58. package/Engines/webgpuEngine.js.map +1 -1
  59. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +4 -2
  60. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  61. package/Materials/Node/Blocks/Vertex/lightInformationBlock.js +8 -6
  62. package/Materials/Node/Blocks/Vertex/lightInformationBlock.js.map +1 -1
  63. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +15 -12
  64. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
  65. package/Materials/Node/Blocks/voronoiNoiseBlock.js +17 -21
  66. package/Materials/Node/Blocks/voronoiNoiseBlock.js.map +1 -1
  67. package/Materials/effect.d.ts +2 -2
  68. package/Materials/effect.js +2 -2
  69. package/Materials/effect.js.map +1 -1
  70. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  71. package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
  72. package/Meshes/mesh.js +6 -1
  73. package/Meshes/mesh.js.map +1 -1
  74. package/Misc/codeStringParsingTools.d.ts +11 -0
  75. package/Misc/codeStringParsingTools.js +31 -0
  76. package/Misc/codeStringParsingTools.js.map +1 -1
  77. package/Misc/pressureObserverWrapper.js +1 -1
  78. package/Misc/pressureObserverWrapper.js.map +1 -1
  79. package/Particles/solidParticleSystem.d.ts +5 -5
  80. package/Particles/solidParticleSystem.js.map +1 -1
  81. package/Shaders/gaussianSplatting.vertex.js +3 -3
  82. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  83. package/assets/Draco/draco_decoder.js +2 -0
  84. package/assets/Draco/draco_wasm_wrapper.js +1 -1
  85. package/assets/Draco/draco_wasm_wrapper_gltf.js +1 -1
  86. package/package.json +1 -1
@@ -41,3 +41,14 @@ export declare function FindBackward(s: string, index: number, c: string, c2?: s
41
41
  * @returns escaped string
42
42
  */
43
43
  export declare function EscapeRegExp(s: string): string;
44
+ /**
45
+ * Injects code at the beginning and/or end of a function.
46
+ * The function is identified by "mainFuncDecl". The starting code is injected just after the first "\{" found after the mainFuncDecl.
47
+ * The ending code is injected just before the last "\}" of the whole block of code (so, it is assumed that the function is the last of the block of code).
48
+ * @param code code to inject into
49
+ * @param mainFuncDecl Function declaration to find in the code (for eg: "void main")
50
+ * @param startingCode The code to inject at the beginning of the function
51
+ * @param endingCode The code to inject at the end of the function
52
+ * @returns The code with the injected code
53
+ */
54
+ export declare function InjectStartingAndEndingCode(code: string, mainFuncDecl: string, startingCode?: string, endingCode?: string): string;
@@ -172,4 +172,35 @@ export function FindBackward(s, index, c, c2) {
172
172
  export function EscapeRegExp(s) {
173
173
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
174
174
  }
175
+ /**
176
+ * Injects code at the beginning and/or end of a function.
177
+ * The function is identified by "mainFuncDecl". The starting code is injected just after the first "\{" found after the mainFuncDecl.
178
+ * The ending code is injected just before the last "\}" of the whole block of code (so, it is assumed that the function is the last of the block of code).
179
+ * @param code code to inject into
180
+ * @param mainFuncDecl Function declaration to find in the code (for eg: "void main")
181
+ * @param startingCode The code to inject at the beginning of the function
182
+ * @param endingCode The code to inject at the end of the function
183
+ * @returns The code with the injected code
184
+ */
185
+ export function InjectStartingAndEndingCode(code, mainFuncDecl, startingCode, endingCode) {
186
+ let idx = code.indexOf(mainFuncDecl);
187
+ if (idx < 0) {
188
+ return code;
189
+ }
190
+ if (startingCode) {
191
+ // eslint-disable-next-line no-empty
192
+ while (idx++ < code.length && code.charAt(idx) != "{") { }
193
+ if (idx < code.length) {
194
+ const part1 = code.substring(0, idx + 1);
195
+ const part2 = code.substring(idx + 1);
196
+ code = part1 + startingCode + part2;
197
+ }
198
+ }
199
+ if (endingCode) {
200
+ const lastClosingCurly = code.lastIndexOf("}");
201
+ code = code.substring(0, lastClosingCurly);
202
+ code += endingCode + "\n}";
203
+ }
204
+ return code;
205
+ }
175
206
  //# sourceMappingURL=codeStringParsingTools.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"codeStringParsingTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/codeStringParsingTools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAAkB,EAAE,WAAmB,EAAE,KAAa,EAAE,UAAkB;IAC5G,IAAI,OAAO,GAAG,UAAU,EACpB,WAAW,GAAG,CAAC,EACf,WAAW,GAAG,EAAE,CAAC;IAErB,OAAO,OAAO,GAAG,KAAK,CAAC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AE;gBAC/E,KAAK,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC,CAAC;gBACxD,IAAI,WAAW,KAAK,EAAE,EAAE;oBACpB,UAAU,GAAG,KAAK,CAAC;oBACnB,OAAO,EAAE,CAAC;iBACb;aACJ;iBAAM;gBACH,IAAI,CAAC,UAAU,EAAE;oBACb,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;iBACpB;aACJ;SACJ;QAED,OAAO,EAAE,CAAC;KACb;IAED,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACtB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,CAAS,EAAE,KAAa,EAAE,CAAS,EAAE,EAAW;IACzE,OAAO,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE;QAC3E,KAAK,EAAE,CAAC;KACX;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,CAAS;IAClC,OAAO,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACpD,CAAC","sourcesContent":["/**\r\n * Extracts the characters between two markers (for eg, between \"(\" and \")\"). The function handles nested markers as well as markers inside strings (delimited by \", ' or `) and comments\r\n * @param markerOpen opening marker\r\n * @param markerClose closing marker\r\n * @param block code block to parse\r\n * @param startIndex starting index in block where the extraction must start. The character at block[startIndex] should be the markerOpen character!\r\n * @returns index of the last character for the extraction (or -1 if the string is invalid - no matching closing marker found). The string to extract (without the markers) is the string between startIndex + 1 and the returned value (exclusive)\r\n */\r\nexport function ExtractBetweenMarkers(markerOpen: string, markerClose: string, block: string, startIndex: number): number {\r\n let currPos = startIndex,\r\n openMarkers = 0,\r\n waitForChar = \"\";\r\n\r\n while (currPos < block.length) {\r\n const currChar = block.charAt(currPos);\r\n\r\n if (!waitForChar) {\r\n switch (currChar) {\r\n case markerOpen:\r\n openMarkers++;\r\n break;\r\n case markerClose:\r\n openMarkers--;\r\n break;\r\n case '\"':\r\n case \"'\":\r\n case \"`\":\r\n waitForChar = currChar;\r\n break;\r\n case \"/\":\r\n if (currPos + 1 < block.length) {\r\n const nextChar = block.charAt(currPos + 1);\r\n if (nextChar === \"/\") {\r\n waitForChar = \"\\n\";\r\n } else if (nextChar === \"*\") {\r\n waitForChar = \"*/\";\r\n }\r\n }\r\n break;\r\n }\r\n } else {\r\n if (currChar === waitForChar) {\r\n if (waitForChar === '\"' || waitForChar === \"'\") {\r\n block.charAt(currPos - 1) !== \"\\\\\" && (waitForChar = \"\");\r\n } else {\r\n waitForChar = \"\";\r\n }\r\n } else if (waitForChar === \"*/\" && currChar === \"*\" && currPos + 1 < block.length) {\r\n block.charAt(currPos + 1) === \"/\" && (waitForChar = \"\");\r\n if (waitForChar === \"\") {\r\n currPos++;\r\n }\r\n }\r\n }\r\n\r\n currPos++;\r\n if (openMarkers === 0) {\r\n break;\r\n }\r\n }\r\n\r\n return openMarkers === 0 ? currPos - 1 : -1;\r\n}\r\n\r\n/**\r\n * Parses a string and skip whitespaces\r\n * @param s string to parse\r\n * @param index index where to start parsing\r\n * @returns the index after all whitespaces have been skipped\r\n */\r\nexport function SkipWhitespaces(s: string, index: number): number {\r\n while (index < s.length) {\r\n const c = s[index];\r\n if (c !== \" \" && c !== \"\\n\" && c !== \"\\r\" && c !== \"\\t\" && c !== \"\\u000a\" && c !== \"\\u00a0\") {\r\n break;\r\n }\r\n index++;\r\n }\r\n\r\n return index;\r\n}\r\n\r\n/**\r\n * Checks if a character is an identifier character (meaning, if it is 0-9, A-Z, a-z or _)\r\n * @param c character to check\r\n * @returns true if the character is an identifier character\r\n */\r\nexport function IsIdentifierChar(c: string): boolean {\r\n const v = c.charCodeAt(0);\r\n return (\r\n (v >= 48 && v <= 57) || // 0-9\r\n (v >= 65 && v <= 90) || // A-Z\r\n (v >= 97 && v <= 122) || // a-z\r\n v == 95\r\n ); // _\r\n}\r\n\r\n/**\r\n * Removes the comments of a code block\r\n * @param block code block to parse\r\n * @returns block with the comments removed\r\n */\r\nexport function RemoveComments(block: string): string {\r\n let currPos = 0,\r\n waitForChar = \"\",\r\n inComments = false;\r\n const s = [];\r\n\r\n while (currPos < block.length) {\r\n const currChar = block.charAt(currPos);\r\n\r\n if (!waitForChar) {\r\n switch (currChar) {\r\n case '\"':\r\n case \"'\":\r\n case \"`\":\r\n waitForChar = currChar;\r\n break;\r\n case \"/\":\r\n if (currPos + 1 < block.length) {\r\n const nextChar = block.charAt(currPos + 1);\r\n if (nextChar === \"/\") {\r\n waitForChar = \"\\n\";\r\n inComments = true;\r\n } else if (nextChar === \"*\") {\r\n waitForChar = \"*/\";\r\n inComments = true;\r\n }\r\n }\r\n break;\r\n }\r\n if (!inComments) {\r\n s.push(currChar);\r\n }\r\n } else {\r\n if (currChar === waitForChar) {\r\n if (waitForChar === '\"' || waitForChar === \"'\") {\r\n block.charAt(currPos - 1) !== \"\\\\\" && (waitForChar = \"\");\r\n s.push(currChar);\r\n } else {\r\n waitForChar = \"\";\r\n inComments = false;\r\n }\r\n } else if (waitForChar === \"*/\" && currChar === \"*\" && currPos + 1 < block.length) {\r\n block.charAt(currPos + 1) === \"/\" && (waitForChar = \"\");\r\n if (waitForChar === \"\") {\r\n inComments = false;\r\n currPos++;\r\n }\r\n } else {\r\n if (!inComments) {\r\n s.push(currChar);\r\n }\r\n }\r\n }\r\n\r\n currPos++;\r\n }\r\n\r\n return s.join(\"\");\r\n}\r\n\r\n/**\r\n * Finds the first occurrence of a character in a string going backward\r\n * @param s the string to parse\r\n * @param index starting index in the string\r\n * @param c the character to find\r\n * @param c2 an optional second character to find\r\n * @returns the index of the character if found, else -1\r\n */\r\nexport function FindBackward(s: string, index: number, c: string, c2?: string): number {\r\n while (index >= 0 && s.charAt(index) !== c && (!c2 || s.charAt(index) !== c2)) {\r\n index--;\r\n }\r\n\r\n return index;\r\n}\r\n\r\n/**\r\n * Escapes a string so that it is usable as a regular expression\r\n * @param s string to escape\r\n * @returns escaped string\r\n */\r\nexport function EscapeRegExp(s: string): string {\r\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\r\n}\r\n"]}
1
+ {"version":3,"file":"codeStringParsingTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/codeStringParsingTools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAAkB,EAAE,WAAmB,EAAE,KAAa,EAAE,UAAkB;IAC5G,IAAI,OAAO,GAAG,UAAU,EACpB,WAAW,GAAG,CAAC,EACf,WAAW,GAAG,EAAE,CAAC;IAErB,OAAO,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE;QAC3B,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEvC,IAAI,CAAC,WAAW,EAAE;YACd,QAAQ,QAAQ,EAAE;gBACd,KAAK,UAAU;oBACX,WAAW,EAAE,CAAC;oBACd,MAAM;gBACV,KAAK,WAAW;oBACZ,WAAW,EAAE,CAAC;oBACd,MAAM;gBACV,KAAK,GAAG,CAAC;gBACT,KAAK,GAAG,CAAC;gBACT,KAAK,GAAG;oBACJ,WAAW,GAAG,QAAQ,CAAC;oBACvB,MAAM;gBACV,KAAK,GAAG;oBACJ,IAAI,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE;wBAC5B,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;wBAC3C,IAAI,QAAQ,KAAK,GAAG,EAAE;4BAClB,WAAW,GAAG,IAAI,CAAC;yBACtB;6BAAM,IAAI,QAAQ,KAAK,GAAG,EAAE;4BACzB,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,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE;QAC3E,KAAK,EAAE,CAAC;KACX;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,CAAS;IAClC,OAAO,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACpD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,2BAA2B,CAAC,IAAY,EAAE,YAAoB,EAAE,YAAqB,EAAE,UAAmB;IACtH,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACrC,IAAI,GAAG,GAAG,CAAC,EAAE;QACT,OAAO,IAAI,CAAC;KACf;IACD,IAAI,YAAY,EAAE;QACd,oCAAoC;QACpC,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE,GAAE;QACzD,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE;YACnB,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;YACzC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;YACtC,IAAI,GAAG,KAAK,GAAG,YAAY,GAAG,KAAK,CAAC;SACvC;KACJ;IAED,IAAI,UAAU,EAAE;QACZ,MAAM,gBAAgB,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC/C,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC;QAC3C,IAAI,IAAI,UAAU,GAAG,KAAK,CAAC;KAC9B;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["/**\r\n * Extracts the characters between two markers (for eg, between \"(\" and \")\"). The function handles nested markers as well as markers inside strings (delimited by \", ' or `) and comments\r\n * @param markerOpen opening marker\r\n * @param markerClose closing marker\r\n * @param block code block to parse\r\n * @param startIndex starting index in block where the extraction must start. The character at block[startIndex] should be the markerOpen character!\r\n * @returns index of the last character for the extraction (or -1 if the string is invalid - no matching closing marker found). The string to extract (without the markers) is the string between startIndex + 1 and the returned value (exclusive)\r\n */\r\nexport function ExtractBetweenMarkers(markerOpen: string, markerClose: string, block: string, startIndex: number): number {\r\n let currPos = startIndex,\r\n openMarkers = 0,\r\n waitForChar = \"\";\r\n\r\n while (currPos < block.length) {\r\n const currChar = block.charAt(currPos);\r\n\r\n if (!waitForChar) {\r\n switch (currChar) {\r\n case markerOpen:\r\n openMarkers++;\r\n break;\r\n case markerClose:\r\n openMarkers--;\r\n break;\r\n case '\"':\r\n case \"'\":\r\n case \"`\":\r\n waitForChar = currChar;\r\n break;\r\n case \"/\":\r\n if (currPos + 1 < block.length) {\r\n const nextChar = block.charAt(currPos + 1);\r\n if (nextChar === \"/\") {\r\n waitForChar = \"\\n\";\r\n } else if (nextChar === \"*\") {\r\n waitForChar = \"*/\";\r\n }\r\n }\r\n break;\r\n }\r\n } else {\r\n if (currChar === waitForChar) {\r\n if (waitForChar === '\"' || waitForChar === \"'\") {\r\n block.charAt(currPos - 1) !== \"\\\\\" && (waitForChar = \"\");\r\n } else {\r\n waitForChar = \"\";\r\n }\r\n } else if (waitForChar === \"*/\" && currChar === \"*\" && currPos + 1 < block.length) {\r\n block.charAt(currPos + 1) === \"/\" && (waitForChar = \"\");\r\n if (waitForChar === \"\") {\r\n currPos++;\r\n }\r\n }\r\n }\r\n\r\n currPos++;\r\n if (openMarkers === 0) {\r\n break;\r\n }\r\n }\r\n\r\n return openMarkers === 0 ? currPos - 1 : -1;\r\n}\r\n\r\n/**\r\n * Parses a string and skip whitespaces\r\n * @param s string to parse\r\n * @param index index where to start parsing\r\n * @returns the index after all whitespaces have been skipped\r\n */\r\nexport function SkipWhitespaces(s: string, index: number): number {\r\n while (index < s.length) {\r\n const c = s[index];\r\n if (c !== \" \" && c !== \"\\n\" && c !== \"\\r\" && c !== \"\\t\" && c !== \"\\u000a\" && c !== \"\\u00a0\") {\r\n break;\r\n }\r\n index++;\r\n }\r\n\r\n return index;\r\n}\r\n\r\n/**\r\n * Checks if a character is an identifier character (meaning, if it is 0-9, A-Z, a-z or _)\r\n * @param c character to check\r\n * @returns true if the character is an identifier character\r\n */\r\nexport function IsIdentifierChar(c: string): boolean {\r\n const v = c.charCodeAt(0);\r\n return (\r\n (v >= 48 && v <= 57) || // 0-9\r\n (v >= 65 && v <= 90) || // A-Z\r\n (v >= 97 && v <= 122) || // a-z\r\n v == 95\r\n ); // _\r\n}\r\n\r\n/**\r\n * Removes the comments of a code block\r\n * @param block code block to parse\r\n * @returns block with the comments removed\r\n */\r\nexport function RemoveComments(block: string): string {\r\n let currPos = 0,\r\n waitForChar = \"\",\r\n inComments = false;\r\n const s = [];\r\n\r\n while (currPos < block.length) {\r\n const currChar = block.charAt(currPos);\r\n\r\n if (!waitForChar) {\r\n switch (currChar) {\r\n case '\"':\r\n case \"'\":\r\n case \"`\":\r\n waitForChar = currChar;\r\n break;\r\n case \"/\":\r\n if (currPos + 1 < block.length) {\r\n const nextChar = block.charAt(currPos + 1);\r\n if (nextChar === \"/\") {\r\n waitForChar = \"\\n\";\r\n inComments = true;\r\n } else if (nextChar === \"*\") {\r\n waitForChar = \"*/\";\r\n inComments = true;\r\n }\r\n }\r\n break;\r\n }\r\n if (!inComments) {\r\n s.push(currChar);\r\n }\r\n } else {\r\n if (currChar === waitForChar) {\r\n if (waitForChar === '\"' || waitForChar === \"'\") {\r\n block.charAt(currPos - 1) !== \"\\\\\" && (waitForChar = \"\");\r\n s.push(currChar);\r\n } else {\r\n waitForChar = \"\";\r\n inComments = false;\r\n }\r\n } else if (waitForChar === \"*/\" && currChar === \"*\" && currPos + 1 < block.length) {\r\n block.charAt(currPos + 1) === \"/\" && (waitForChar = \"\");\r\n if (waitForChar === \"\") {\r\n inComments = false;\r\n currPos++;\r\n }\r\n } else {\r\n if (!inComments) {\r\n s.push(currChar);\r\n }\r\n }\r\n }\r\n\r\n currPos++;\r\n }\r\n\r\n return s.join(\"\");\r\n}\r\n\r\n/**\r\n * Finds the first occurrence of a character in a string going backward\r\n * @param s the string to parse\r\n * @param index starting index in the string\r\n * @param c the character to find\r\n * @param c2 an optional second character to find\r\n * @returns the index of the character if found, else -1\r\n */\r\nexport function FindBackward(s: string, index: number, c: string, c2?: string): number {\r\n while (index >= 0 && s.charAt(index) !== c && (!c2 || s.charAt(index) !== c2)) {\r\n index--;\r\n }\r\n\r\n return index;\r\n}\r\n\r\n/**\r\n * Escapes a string so that it is usable as a regular expression\r\n * @param s string to escape\r\n * @returns escaped string\r\n */\r\nexport function EscapeRegExp(s: string): string {\r\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\r\n}\r\n\r\n/**\r\n * Injects code at the beginning and/or end of a function.\r\n * The function is identified by \"mainFuncDecl\". The starting code is injected just after the first \"\\{\" found after the mainFuncDecl.\r\n * The ending code is injected just before the last \"\\}\" of the whole block of code (so, it is assumed that the function is the last of the block of code).\r\n * @param code code to inject into\r\n * @param mainFuncDecl Function declaration to find in the code (for eg: \"void main\")\r\n * @param startingCode The code to inject at the beginning of the function\r\n * @param endingCode The code to inject at the end of the function\r\n * @returns The code with the injected code\r\n */\r\nexport function InjectStartingAndEndingCode(code: string, mainFuncDecl: string, startingCode?: string, endingCode?: string): string {\r\n let idx = code.indexOf(mainFuncDecl);\r\n if (idx < 0) {\r\n return code;\r\n }\r\n if (startingCode) {\r\n // eslint-disable-next-line no-empty\r\n while (idx++ < code.length && code.charAt(idx) != \"{\") {}\r\n if (idx < code.length) {\r\n const part1 = code.substring(0, idx + 1);\r\n const part2 = code.substring(idx + 1);\r\n code = part1 + startingCode + part2;\r\n }\r\n }\r\n\r\n if (endingCode) {\r\n const lastClosingCurly = code.lastIndexOf(\"}\");\r\n code = code.substring(0, lastClosingCurly);\r\n code += endingCode + \"\\n}\";\r\n }\r\n\r\n return code;\r\n}\r\n"]}
@@ -26,7 +26,7 @@ export class PressureObserverWrapper {
26
26
  * Returns true if PressureObserver is available for use, false otherwise.
27
27
  */
28
28
  static get IsAvailable() {
29
- return typeof PressureObserver !== "undefined" && PressureObserver.supportedSources.includes("cpu");
29
+ return typeof PressureObserver !== "undefined" && PressureObserver.knownSources && PressureObserver.knownSources.includes("cpu");
30
30
  }
31
31
  /**
32
32
  * Method that must be called to begin observing changes, and triggering callbacks.
@@ -1 +1 @@
1
- {"version":3,"file":"pressureObserverWrapper.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/pressureObserverWrapper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAM,OAAO,uBAAuB;IAUhC;;;OAGG;IACH,YAAY,OAAiC;QAbrC,cAAS,GAA+B,IAAI,CAAC;QAC7C,kBAAa,GAAqB,EAAE,CAAC;QAE7C;;;WAGG;QACI,sBAAiB,GAAG,IAAI,UAAU,EAAoB,CAAC;QAO1D,IAAI,uBAAuB,CAAC,WAAW,EAAE;YACrC,IAAI,CAAC,SAAS,GAAG,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,EAAE;gBAC7C,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC;gBAC5B,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;YACnD,CAAC,EAAE,OAAO,CAAC,CAAC;SACf;IACL,CAAC;IAED;;OAEG;IACI,MAAM,KAAK,WAAW;QACzB,OAAO,OAAO,gBAAgB,KAAK,WAAW,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxG,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,MAAsB;QAC1B,IAAI;YACA,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YAChC,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;SAC9D;QAAC,MAAM;YACJ,eAAe;SAClB;IACL,CAAC;IAED;;;OAGG;IACH,SAAS,CAAC,MAAsB;QAC5B,IAAI;YACA,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;SACrC;QAAC,MAAM;YACJ,eAAe;SAClB;IACL,CAAC;IAED;;OAEG;IACH,OAAO;QACH,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;IACnC,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport { Observable } from \"./observable\";\r\n\r\n/**\r\n * A wrapper for the experimental pressure api which allows a callback to be called whenever certain thresholds are met.\r\n */\r\nexport class PressureObserverWrapper {\r\n private _observer: Nullable<PressureObserver> = null;\r\n private _currentState: PressureRecord[] = [];\r\n\r\n /**\r\n * An event triggered when the cpu usage/speed meets certain thresholds.\r\n * Note: pressure is an experimental API.\r\n */\r\n public onPressureChanged = new Observable<PressureRecord[]>();\r\n\r\n /**\r\n * A pressure observer will call this callback, whenever these thresholds are met.\r\n * @param options An object containing the thresholds used to decide what value to to return for each update property (average of start and end of a threshold boundary).\r\n */\r\n constructor(options?: PressureObserverOptions) {\r\n if (PressureObserverWrapper.IsAvailable) {\r\n this._observer = new PressureObserver((update) => {\r\n this._currentState = update;\r\n this.onPressureChanged.notifyObservers(update);\r\n }, options);\r\n }\r\n }\r\n\r\n /**\r\n * Returns true if PressureObserver is available for use, false otherwise.\r\n */\r\n public static get IsAvailable() {\r\n return typeof PressureObserver !== \"undefined\" && PressureObserver.supportedSources.includes(\"cpu\");\r\n }\r\n\r\n /**\r\n * Method that must be called to begin observing changes, and triggering callbacks.\r\n * @param source defines the source to observe\r\n */\r\n observe(source: PressureSource): void {\r\n try {\r\n this._observer?.observe(source);\r\n this.onPressureChanged.notifyObservers(this._currentState);\r\n } catch {\r\n // Ignore error\r\n }\r\n }\r\n\r\n /**\r\n * Method that must be called to stop observing changes and triggering callbacks (cleanup function).\r\n * @param source defines the source to unobserve\r\n */\r\n unobserve(source: PressureSource): void {\r\n try {\r\n this._observer?.unobserve(source);\r\n } catch {\r\n // Ignore error\r\n }\r\n }\r\n\r\n /**\r\n * Release the associated resources.\r\n */\r\n dispose() {\r\n this._observer?.disconnect();\r\n this._observer = null;\r\n this.onPressureChanged.clear();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"pressureObserverWrapper.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/pressureObserverWrapper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAM,OAAO,uBAAuB;IAUhC;;;OAGG;IACH,YAAY,OAAiC;QAbrC,cAAS,GAA+B,IAAI,CAAC;QAC7C,kBAAa,GAAqB,EAAE,CAAC;QAE7C;;;WAGG;QACI,sBAAiB,GAAG,IAAI,UAAU,EAAoB,CAAC;QAO1D,IAAI,uBAAuB,CAAC,WAAW,EAAE;YACrC,IAAI,CAAC,SAAS,GAAG,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,EAAE;gBAC7C,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC;gBAC5B,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;YACnD,CAAC,EAAE,OAAO,CAAC,CAAC;SACf;IACL,CAAC;IAED;;OAEG;IACI,MAAM,KAAK,WAAW;QACzB,OAAO,OAAO,gBAAgB,KAAK,WAAW,IAAI,gBAAgB,CAAC,YAAY,IAAI,gBAAgB,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACrI,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,MAAsB;QAC1B,IAAI;YACA,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YAChC,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;SAC9D;QAAC,MAAM;YACJ,eAAe;SAClB;IACL,CAAC;IAED;;;OAGG;IACH,SAAS,CAAC,MAAsB;QAC5B,IAAI;YACA,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;SACrC;QAAC,MAAM;YACJ,eAAe;SAClB;IACL,CAAC;IAED;;OAEG;IACH,OAAO;QACH,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;IACnC,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport { Observable } from \"./observable\";\r\n\r\n/**\r\n * A wrapper for the experimental pressure api which allows a callback to be called whenever certain thresholds are met.\r\n */\r\nexport class PressureObserverWrapper {\r\n private _observer: Nullable<PressureObserver> = null;\r\n private _currentState: PressureRecord[] = [];\r\n\r\n /**\r\n * An event triggered when the cpu usage/speed meets certain thresholds.\r\n * Note: pressure is an experimental API.\r\n */\r\n public onPressureChanged = new Observable<PressureRecord[]>();\r\n\r\n /**\r\n * A pressure observer will call this callback, whenever these thresholds are met.\r\n * @param options An object containing the thresholds used to decide what value to to return for each update property (average of start and end of a threshold boundary).\r\n */\r\n constructor(options?: PressureObserverOptions) {\r\n if (PressureObserverWrapper.IsAvailable) {\r\n this._observer = new PressureObserver((update) => {\r\n this._currentState = update;\r\n this.onPressureChanged.notifyObservers(update);\r\n }, options);\r\n }\r\n }\r\n\r\n /**\r\n * Returns true if PressureObserver is available for use, false otherwise.\r\n */\r\n public static get IsAvailable() {\r\n return typeof PressureObserver !== \"undefined\" && PressureObserver.knownSources && PressureObserver.knownSources.includes(\"cpu\");\r\n }\r\n\r\n /**\r\n * Method that must be called to begin observing changes, and triggering callbacks.\r\n * @param source defines the source to observe\r\n */\r\n observe(source: PressureSource): void {\r\n try {\r\n this._observer?.observe(source);\r\n this.onPressureChanged.notifyObservers(this._currentState);\r\n } catch {\r\n // Ignore error\r\n }\r\n }\r\n\r\n /**\r\n * Method that must be called to stop observing changes and triggering callbacks (cleanup function).\r\n * @param source defines the source to unobserve\r\n */\r\n unobserve(source: PressureSource): void {\r\n try {\r\n this._observer?.unobserve(source);\r\n } catch {\r\n // Ignore error\r\n }\r\n }\r\n\r\n /**\r\n * Release the associated resources.\r\n */\r\n dispose() {\r\n this._observer?.disconnect();\r\n this._observer = null;\r\n this.onPressureChanged.clear();\r\n }\r\n}\r\n"]}
@@ -1,4 +1,4 @@
1
- import type { Nullable, IndicesArray } from "../types";
1
+ import type { Nullable, IndicesArray, FloatArray } from "../types";
2
2
  import { Vector3 } from "../Maths/math.vector";
3
3
  import { Color4 } from "../Maths/math.color";
4
4
  import { Mesh } from "../Meshes/mesh";
@@ -251,21 +251,21 @@ export declare class SolidParticleSystem implements IDisposable {
251
251
  * @model the particle model
252
252
  * @internal
253
253
  */
254
- protected _meshBuilder(p: number, ind: number, shape: Vector3[], positions: number[], meshInd: IndicesArray, indices: number[], meshUV: number[] | Float32Array, uvs: number[], meshCol: number[] | Float32Array, colors: number[], meshNor: number[] | Float32Array, normals: number[], idx: number, idxInShape: number, options: any, model: ModelShape): SolidParticle;
254
+ protected _meshBuilder(p: number, ind: number, shape: Vector3[], positions: number[], meshInd: IndicesArray, indices: number[], meshUV: FloatArray, uvs: number[], meshCol: FloatArray, colors: number[], meshNor: FloatArray, normals: number[], idx: number, idxInShape: number, options: any, model: ModelShape): SolidParticle;
255
255
  /**
256
256
  * Returns a shape Vector3 array from positions float array
257
257
  * @param positions float array
258
258
  * @returns a vector3 array
259
259
  * @internal
260
260
  */
261
- protected _posToShape(positions: number[] | Float32Array): Vector3[];
261
+ protected _posToShape(positions: FloatArray): Vector3[];
262
262
  /**
263
263
  * Returns a shapeUV array from a float uvs (array deep copy)
264
264
  * @param uvs as a float array
265
265
  * @returns a shapeUV array
266
266
  * @internal
267
267
  */
268
- protected _uvsToShapeUV(uvs: number[] | Float32Array): number[];
268
+ protected _uvsToShapeUV(uvs: FloatArray): number[];
269
269
  /**
270
270
  * Adds a new particle object in the particles array
271
271
  * @param idx particle index in particles array
@@ -344,7 +344,7 @@ export declare class SolidParticleSystem implements IDisposable {
344
344
  * @options addShape() passed options
345
345
  * @internal
346
346
  */
347
- protected _insertNewParticle(idx: number, i: number, modelShape: ModelShape, shape: Vector3[], meshInd: IndicesArray, meshUV: number[] | Float32Array, meshCol: number[] | Float32Array, meshNor: number[] | Float32Array, bbInfo: Nullable<BoundingInfo>, storage: Nullable<[]>, options: any): Nullable<SolidParticle>;
347
+ protected _insertNewParticle(idx: number, i: number, modelShape: ModelShape, shape: Vector3[], meshInd: IndicesArray, meshUV: FloatArray, meshCol: FloatArray, meshNor: FloatArray, bbInfo: Nullable<BoundingInfo>, storage: Nullable<[]>, options: any): Nullable<SolidParticle>;
348
348
  /**
349
349
  * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
350
350
  * This method calls `updateParticle()` for each particle of the SPS.