@babylonjs/core 7.37.1 → 7.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/Buffers/buffer.d.ts +3 -1
  2. package/Buffers/buffer.js +20 -122
  3. package/Buffers/buffer.js.map +1 -1
  4. package/Buffers/bufferUtils.d.ts +32 -1
  5. package/Buffers/bufferUtils.js +221 -10
  6. package/Buffers/bufferUtils.js.map +1 -1
  7. package/Engines/abstractEngine.js +2 -2
  8. package/Engines/abstractEngine.js.map +1 -1
  9. package/Engines/engine.js +0 -4
  10. package/Engines/engine.js.map +1 -1
  11. package/Engines/thinEngine.js +2 -2
  12. package/Engines/thinEngine.js.map +1 -1
  13. package/FrameGraph/Node/nodeRenderGraphBlock.js +1 -0
  14. package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
  15. package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.d.ts +2 -0
  16. package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js +3 -1
  17. package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js.map +1 -1
  18. package/Inputs/scene.inputManager.js +2 -0
  19. package/Inputs/scene.inputManager.js.map +1 -1
  20. package/Lights/IES/iesLoader.d.ts +19 -0
  21. package/Lights/IES/iesLoader.js +150 -0
  22. package/Lights/IES/iesLoader.js.map +1 -0
  23. package/Lights/index.d.ts +1 -0
  24. package/Lights/index.js +1 -0
  25. package/Lights/index.js.map +1 -1
  26. package/Materials/GreasedLine/greasedLineSimpleMaterial.d.ts +4 -2
  27. package/Materials/GreasedLine/greasedLineSimpleMaterial.js +45 -25
  28. package/Materials/GreasedLine/greasedLineSimpleMaterial.js.map +1 -1
  29. package/Materials/Node/nodeMaterialBlock.js +1 -0
  30. package/Materials/Node/nodeMaterialBlock.js.map +1 -1
  31. package/Materials/Node/nodeMaterialBlockConnectionPoint.d.ts +2 -0
  32. package/Materials/Node/nodeMaterialBlockConnectionPoint.js +4 -1
  33. package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
  34. package/Materials/Textures/Loaders/iesTextureLoader.d.ts +23 -0
  35. package/Materials/Textures/Loaders/iesTextureLoader.js +40 -0
  36. package/Materials/Textures/Loaders/iesTextureLoader.js.map +1 -0
  37. package/Materials/Textures/Loaders/index.d.ts +1 -0
  38. package/Materials/Textures/Loaders/index.js +1 -0
  39. package/Materials/Textures/Loaders/index.js.map +1 -1
  40. package/Materials/Textures/Loaders/textureLoaderManager.js +3 -0
  41. package/Materials/Textures/Loaders/textureLoaderManager.js.map +1 -1
  42. package/Materials/index.d.ts +4 -0
  43. package/Materials/index.js +5 -0
  44. package/Materials/index.js.map +1 -1
  45. package/Meshes/Node/Blocks/geometryInputBlock.d.ts +4 -0
  46. package/Meshes/Node/Blocks/geometryInputBlock.js +8 -0
  47. package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
  48. package/Meshes/Node/nodeGeometryBlock.js +1 -0
  49. package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
  50. package/Meshes/Node/nodeGeometryBlockConnectionPoint.d.ts +2 -0
  51. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js +3 -1
  52. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
  53. package/Misc/deepMerger.d.ts +6 -0
  54. package/Misc/deepMerger.js +26 -0
  55. package/Misc/deepMerger.js.map +1 -0
  56. package/Misc/index.d.ts +1 -0
  57. package/Misc/index.js +1 -0
  58. package/Misc/index.js.map +1 -1
  59. package/Rendering/boundingBoxRenderer.d.ts +63 -1
  60. package/Rendering/boundingBoxRenderer.js +224 -3
  61. package/Rendering/boundingBoxRenderer.js.map +1 -1
  62. package/Rendering/edgesRenderer.js +4 -1
  63. package/Rendering/edgesRenderer.js.map +1 -1
  64. package/Shaders/boundingBoxRenderer.vertex.js +7 -0
  65. package/Shaders/boundingBoxRenderer.vertex.js.map +1 -1
  66. package/ShadersWGSL/boundingBoxRenderer.vertex.js +9 -1
  67. package/ShadersWGSL/boundingBoxRenderer.vertex.js.map +1 -1
  68. package/ShadersWGSL/greasedLine.fragment.d.ts +5 -0
  69. package/ShadersWGSL/greasedLine.fragment.js +25 -0
  70. package/ShadersWGSL/greasedLine.fragment.js.map +1 -0
  71. package/ShadersWGSL/greasedLine.vertex.d.ts +9 -0
  72. package/ShadersWGSL/greasedLine.vertex.js +43 -0
  73. package/ShadersWGSL/greasedLine.vertex.js.map +1 -0
  74. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iesLoader.js","sourceRoot":"","sources":["../../../../../dev/core/src/Lights/IES/iesLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,6CAAyC;AA4BxD,SAAS,WAAW,CAAC,IAAY;IAC7B,OAAO,IAAI;SACN,KAAK,CAAC,GAAG,CAAC;SACV,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;SACvB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,SAAS,CAAC,WAAyB,EAAE,KAAa,EAAE,WAAqB;IAC9E,OAAO,WAAW,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;QAClC,MAAM,IAAI,GAAG,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACjE,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IAC9B,CAAC;AACL,CAAC;AAED,SAAS,wBAAwB,CAAC,IAAc,EAAE,GAAW,EAAE,KAAa;IACxE,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,QAAQ,GAAG,CAAC,CAAC;I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AM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC;QAEtC,WAAW;QACX,IAAI,QAAQ,GAAG,UAAU,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,UAAU,IAAI,KAAK,IAAI,QAAQ,CAAC,EAAE,CAAC;YAC3E,KAAK,IAAI,QAAQ,GAAG,CAAC,CAAC;YACtB,IAAI,KAAK,GAAG,QAAQ,EAAE,CAAC;gBACnB,KAAK,GAAG,QAAQ,GAAG,CAAC,GAAG,KAAK,CAAC;YACjC,CAAC;QACL,CAAC;QAED,WAAW,CAAC,GAAG,GAAG,KAAK,GAAG,MAAM,CAAC,GAAG,wBAAwB,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACnF,CAAC;IAED,sJAAsJ;IACtJ,OAAO;QACH,KAAK,EAAE,KAAK,GAAG,CAAC;QAChB,MAAM,EAAE,CAAC;QACT,IAAI,EAAE,WAAW;KACpB,CAAC;AACN,CAAC","sourcesContent":["import { Lerp } from \"core/Maths/math.scalar.functions\";\r\n\r\ninterface IIESData {\r\n version: string;\r\n tilt?: {};\r\n numberOfLights?: number;\r\n lumensPerLamp?: number;\r\n candelaMultiplier?: number;\r\n numberOfVerticalAngles: number;\r\n numberOfHorizontalAngles: number;\r\n horizontalAngles: number[];\r\n verticalAngles: number[];\r\n photometricType?: number;\r\n unitsType?: number;\r\n width?: number;\r\n length?: number;\r\n height?: number;\r\n ballastFactor?: number;\r\n fileGenerationType?: number;\r\n inputWatts?: number;\r\n candelaValues: number[][];\r\n}\r\n\r\ninterface IDataPointer {\r\n lines: string[];\r\n index: number;\r\n}\r\n\r\nfunction lineToArray(line: string): number[] {\r\n return line\r\n .split(\" \")\r\n .filter((x) => x !== \"\")\r\n .map((x) => parseFloat(x));\r\n}\r\n\r\nfunction readArray(dataPointer: IDataPointer, count: number, targetArray: number[]) {\r\n while (targetArray.length !== count) {\r\n const line = lineToArray(dataPointer.lines[dataPointer.index++]);\r\n targetArray.push(...line);\r\n }\r\n}\r\n\r\nfunction interpolateCandelaValues(data: IIESData, phi: number, theta: number): number {\r\n let phiIndex = 0;\r\n let thetaIndex = 0;\r\n let startTheta = 0;\r\n let endTheta = 0;\r\n let startPhi = 0;\r\n let endPhi = 0;\r\n\r\n // Check if the angle is outside the range\r\n for (let index = 0; index < data.numberOfHorizontalAngles - 1; index++) {\r\n if (theta < data.horizontalAngles[index + 1] || index === data.numberOfHorizontalAngles - 2) {\r\n thetaIndex = index;\r\n startTheta = data.horizontalAngles[index];\r\n endTheta = data.horizontalAngles[index + 1];\r\n\r\n break;\r\n }\r\n }\r\n\r\n for (let index = 0; index < data.numberOfVerticalAngles - 1; index++) {\r\n if (phi < data.verticalAngles[index + 1] || index === data.numberOfVerticalAngles - 2) {\r\n phiIndex = index;\r\n startPhi = data.verticalAngles[index];\r\n endPhi = data.verticalAngles[index + 1];\r\n\r\n break;\r\n }\r\n }\r\n\r\n const deltaTheta = endTheta - startTheta;\r\n const deltaPhi = endPhi - startPhi;\r\n\r\n if (deltaPhi === 0) {\r\n return 0;\r\n }\r\n\r\n // Interpolate\r\n const t1 = deltaTheta === 0 ? 0 : (theta - startTheta) / deltaTheta;\r\n const t2 = (phi - startPhi) / deltaPhi;\r\n\r\n const nextThetaIndex = deltaTheta === 0 ? thetaIndex : thetaIndex + 1;\r\n\r\n const v1 = Lerp(data.candelaValues[thetaIndex][phiIndex], data.candelaValues[nextThetaIndex][phiIndex], t1);\r\n const v2 = Lerp(data.candelaValues[thetaIndex][phiIndex + 1], data.candelaValues[nextThetaIndex][phiIndex + 1], t1);\r\n const v = Lerp(v1, v2, t2);\r\n\r\n return v;\r\n}\r\n/**\r\n * Interface for IES texture data.\r\n */\r\nexport interface IIESTextureData {\r\n /** The width of the texture */\r\n width: number;\r\n /** The height of the texture */\r\n height: number;\r\n /** The data of the texture */\r\n data: Float32Array;\r\n}\r\n\r\n/**\r\n * Generates IES data buffer from a string representing the IES data.\r\n * @param uint8Array defines the IES data\r\n * @returns the IES data buffer\r\n * @see https://ieslibrary.com/browse\r\n * #UQGPDT#1\r\n */\r\nexport function LoadIESData(uint8Array: Uint8Array): IIESTextureData {\r\n const decoder = new TextDecoder(\"utf-8\");\r\n const source = decoder.decode(uint8Array);\r\n\r\n // Read data\r\n const dataPointer: IDataPointer = {\r\n lines: source.split(\"\\n\"),\r\n index: 0,\r\n };\r\n const data: IIESData = { version: dataPointer.lines[0], candelaValues: [], horizontalAngles: [], verticalAngles: [], numberOfHorizontalAngles: 0, numberOfVerticalAngles: 0 };\r\n\r\n // Skip metadata\r\n dataPointer.index = 1;\r\n while (dataPointer.lines.length > 0 && !dataPointer.lines[dataPointer.index].includes(\"TILT=\")) {\r\n dataPointer.index++;\r\n }\r\n\r\n // Process tilt data?\r\n if (dataPointer.lines[dataPointer.index].includes(\"INCLUDE\")) {\r\n // Not supported yet as I did not manage to find an example :)\r\n }\r\n dataPointer.index++;\r\n\r\n // Header\r\n const header = lineToArray(dataPointer.lines[dataPointer.index++]);\r\n data.numberOfLights = header[0];\r\n data.lumensPerLamp = header[1];\r\n data.candelaMultiplier = header[2];\r\n data.numberOfVerticalAngles = header[3];\r\n data.numberOfHorizontalAngles = header[4];\r\n data.photometricType = header[5]; // We ignore cylindrical type for now. Will add support later if needed\r\n data.unitsType = header[6];\r\n data.width = header[7];\r\n data.length = header[8];\r\n data.height = header[9];\r\n\r\n // Additional data\r\n const additionalData = lineToArray(dataPointer.lines[dataPointer.index++]);\r\n data.ballastFactor = additionalData[0];\r\n data.fileGenerationType = additionalData[1];\r\n data.inputWatts = additionalData[2];\r\n\r\n // Prepare arrays\r\n for (let index = 0; index < data.numberOfHorizontalAngles; index++) {\r\n data.candelaValues[index] = [];\r\n }\r\n\r\n // Vertical angles\r\n readArray(dataPointer, data.numberOfVerticalAngles, data.verticalAngles);\r\n\r\n // Horizontal angles\r\n readArray(dataPointer, data.numberOfHorizontalAngles, data.horizontalAngles);\r\n\r\n // Candela values\r\n for (let index = 0; index < data.numberOfHorizontalAngles; index++) {\r\n readArray(dataPointer, data.numberOfVerticalAngles, data.candelaValues[index]);\r\n }\r\n\r\n // Evaluate candela values\r\n let maxCandela = -1;\r\n for (let index = 0; index < data.numberOfHorizontalAngles; index++) {\r\n for (let subIndex = 0; subIndex < data.numberOfVerticalAngles; subIndex++) {\r\n data.candelaValues[index][subIndex] *= data.candelaValues[index][subIndex] * data.candelaMultiplier * data.ballastFactor * data.fileGenerationType;\r\n maxCandela = Math.max(maxCandela, data.candelaValues[index][subIndex]);\r\n }\r\n }\r\n\r\n // Normalize candela values\r\n if (maxCandela > 0) {\r\n for (let index = 0; index < data.numberOfHorizontalAngles; index++) {\r\n for (let subIndex = 0; subIndex < data.numberOfVerticalAngles; subIndex++) {\r\n data.candelaValues[index][subIndex] /= maxCandela;\r\n }\r\n }\r\n }\r\n\r\n // Create the cylindrical texture\r\n const height = 180;\r\n const width = height * 2;\r\n const size = width * height;\r\n const arrayBuffer = new Float32Array(width * height);\r\n\r\n // Fill the texture\r\n const startTheta = data.horizontalAngles[0];\r\n const endTheta = data.horizontalAngles[data.numberOfHorizontalAngles - 1];\r\n for (let index = 0; index < size; index++) {\r\n let theta = index % width;\r\n const phi = Math.floor(index / width);\r\n\r\n // Symmetry\r\n if (endTheta - startTheta !== 0 && (theta < startTheta || theta >= endTheta)) {\r\n theta %= endTheta * 2;\r\n if (theta > endTheta) {\r\n theta = endTheta * 2 - theta;\r\n }\r\n }\r\n\r\n arrayBuffer[phi + theta * height] = interpolateCandelaValues(data, phi, theta);\r\n }\r\n\r\n // So far we only need the first half of the first row of the texture as we only support IES for spot light. We can add support for other types later.\r\n return {\r\n width: width / 2,\r\n height: 1,\r\n data: arrayBuffer,\r\n };\r\n}\r\n"]}
package/Lights/index.d.ts CHANGED
@@ -5,3 +5,4 @@ export * from "./directionalLight";
5
5
  export * from "./hemisphericLight";
6
6
  export * from "./pointLight";
7
7
  export * from "./spotLight";
8
+ export * from "./IES/iesLoader";
package/Lights/index.js CHANGED
@@ -6,4 +6,5 @@ export * from "./directionalLight.js";
6
6
  export * from "./hemisphericLight.js";
7
7
  export * from "./pointLight.js";
8
8
  export * from "./spotLight.js";
9
+ export * from "./IES/iesLoader.js";
9
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Lights/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./light\";\r\nexport * from \"./shadowLight\";\r\nexport * from \"./Shadows/index\";\r\nexport * from \"./directionalLight\";\r\nexport * from \"./hemisphericLight\";\r\nexport * from \"./pointLight\";\r\nexport * from \"./spotLight\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Lights/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./light\";\r\nexport * from \"./shadowLight\";\r\nexport * from \"./Shadows/index\";\r\nexport * from \"./directionalLight\";\r\nexport * from \"./hemisphericLight\";\r\nexport * from \"./pointLight\";\r\nexport * from \"./spotLight\";\r\nexport * from \"./IES/iesLoader\";\r\n"]}
@@ -4,14 +4,16 @@ import { ShaderMaterial } from "../shaderMaterial";
4
4
  import type { Nullable } from "../../types";
5
5
  import { Color3 } from "../../Maths/math.color";
6
6
  import { Vector2 } from "../../Maths/math.vector";
7
- import "../../Shaders/greasedLine.fragment";
8
- import "../../Shaders/greasedLine.vertex";
9
7
  import type { GreasedLineMaterialOptions, IGreasedLineMaterial } from "./greasedLineMaterialInterfaces";
10
8
  import { GreasedLineMeshColorDistributionType, GreasedLineMeshColorMode } from "./greasedLineMaterialInterfaces";
11
9
  /**
12
10
  * GreasedLineSimpleMaterial
13
11
  */
14
12
  export declare class GreasedLineSimpleMaterial extends ShaderMaterial implements IGreasedLineMaterial {
13
+ /**
14
+ * Force to use GLSL in WebGPU
15
+ */
16
+ static ForceGLSL: boolean;
15
17
  private _visibility;
16
18
  private _width;
17
19
  private _useDash;
@@ -2,8 +2,7 @@ import { RawTexture } from "../Textures/rawTexture.js";
2
2
  import { ShaderMaterial } from "../shaderMaterial.js";
3
3
  import { Color3 } from "../../Maths/math.color.js";
4
4
  import { Vector2 } from "../../Maths/math.vector.js";
5
- import "../../Shaders/greasedLine.fragment.js";
6
- import "../../Shaders/greasedLine.vertex.js";
5
+ import { TextureSampler } from "../Textures/textureSampler.js";
7
6
  import { GreasedLineTools } from "../../Misc/greasedLineTools.js";
8
7
  import { GreasedLineMaterialDefaults } from "./greasedLineMaterialDefaults.js";
9
8
  /**
@@ -17,6 +16,8 @@ export class GreasedLineSimpleMaterial extends ShaderMaterial {
17
16
  * @param options material options
18
17
  */
19
18
  constructor(name, scene, options) {
19
+ const engine = scene.getEngine();
20
+ const isWGSL = engine.isWebGPU && !(options.forceGLSL || GreasedLineSimpleMaterial.ForceGLSL);
20
21
  const defines = [
21
22
  `COLOR_DISTRIBUTION_TYPE_LINE ${1 /* GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_LINE */}.`,
22
23
  `COLOR_DISTRIBUTION_TYPE_SEGMENT ${0 /* GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_SEGMENT */}.`,
@@ -24,8 +25,8 @@ export class GreasedLineSimpleMaterial extends ShaderMaterial {
24
25
  `COLOR_MODE_ADD ${1 /* GreasedLineMeshColorMode.COLOR_MODE_ADD */}.`,
25
26
  `COLOR_MODE_MULTIPLY ${2 /* GreasedLineMeshColorMode.COLOR_MODE_MULTIPLY */}.`,
26
27
  ];
27
- const attributes = ["position", "grl_widths", "grl_offsets", "grl_colorPointers"];
28
28
  scene.useRightHandedSystem && defines.push("GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM");
29
+ const attributes = ["position", "grl_widths", "grl_offsets", "grl_colorPointers"];
29
30
  if (options.cameraFacing) {
30
31
  defines.push("GREASED_LINE_CAMERA_FACING");
31
32
  attributes.push("grl_previousAndSide", "grl_nextAndCounters");
@@ -34,32 +35,43 @@ export class GreasedLineSimpleMaterial extends ShaderMaterial {
34
35
  attributes.push("grl_slopes");
35
36
  attributes.push("grl_counters");
36
37
  }
38
+ const uniforms = [
39
+ "grlColorsWidth",
40
+ "grlUseColors",
41
+ "grlWidth",
42
+ "grlColor",
43
+ "grl_colorModeAndColorDistributionType",
44
+ "grlResolution",
45
+ "grlAspect",
46
+ "grlAizeAttenuation",
47
+ "grlDashArray",
48
+ "grlDashOffset",
49
+ "grlDashRatio",
50
+ "grlUseDash",
51
+ "grlVisibility",
52
+ "grlColors",
53
+ ];
54
+ if (!isWGSL) {
55
+ uniforms.push("world", "viewProjection", "view", "projection");
56
+ }
37
57
  super(name, scene, {
38
58
  vertex: "greasedLine",
39
59
  fragment: "greasedLine",
40
60
  }, {
61
+ uniformBuffers: isWGSL ? ["Scene", "Mesh"] : undefined,
41
62
  attributes,
42
- uniforms: [
43
- "world",
44
- "viewProjection",
45
- "view",
46
- "projection",
47
- "grlColorsWidth",
48
- "grlUseColors",
49
- "grlWidth",
50
- "grlColor",
51
- "grl_colorModeAndColorDistributionType",
52
- "grlResolution",
53
- "grlAspect",
54
- "grlAizeAttenuation",
55
- "grlDashArray",
56
- "grlDashOffset",
57
- "grlDashRatio",
58
- "grlUseDash",
59
- "grlVisibility",
60
- ],
61
- samplers: ["grlColors"],
63
+ uniforms,
64
+ samplers: isWGSL ? [] : ["grlColors"],
62
65
  defines,
66
+ extraInitializationsAsync: async () => {
67
+ if (isWGSL) {
68
+ await Promise.all([import("../../ShadersWGSL/greasedLine.vertex.js"), import("../../ShadersWGSL/greasedLine.fragment.js")]);
69
+ }
70
+ else {
71
+ await Promise.all([import("../../Shaders/greasedLine.vertex.js"), import("../../Shaders/greasedLine.fragment.js")]);
72
+ }
73
+ },
74
+ shaderLanguage: isWGSL ? 1 /* ShaderLanguage.WGSL */ : 0 /* ShaderLanguage.GLSL */,
63
75
  });
64
76
  this._color = Color3.White();
65
77
  this._colorsDistributionType = 0 /* GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_SEGMENT */;
@@ -67,7 +79,6 @@ export class GreasedLineSimpleMaterial extends ShaderMaterial {
67
79
  options = options || {
68
80
  color: GreasedLineMaterialDefaults.DEFAULT_COLOR,
69
81
  };
70
- const engine = scene.getEngine();
71
82
  this.visibility = options.visibility ?? 1;
72
83
  this.useDash = options.useDash ?? false;
73
84
  this.dashRatio = options.dashRatio ?? 0.5;
@@ -98,6 +109,12 @@ export class GreasedLineSimpleMaterial extends ShaderMaterial {
98
109
  this.colorsTexture = GreasedLineTools.CreateColorsTexture(`${this.name}-colors-texture`, this._colors, this.colorsSampling, scene);
99
110
  }
100
111
  }
112
+ if (isWGSL) {
113
+ const sampler = new TextureSampler();
114
+ sampler.setParameters(); // use the default values
115
+ sampler.samplingMode = this.colorsSampling;
116
+ this.setTextureSampler("grlColorsSampler", sampler);
117
+ }
101
118
  engine.onDisposeObservable.add(() => {
102
119
  GreasedLineTools.DisposeEmptyColorsTexture();
103
120
  });
@@ -389,7 +406,6 @@ export class GreasedLineSimpleMaterial extends ShaderMaterial {
389
406
  * @param _rootUrl root url for textures
390
407
  */
391
408
  parse(source, scene, _rootUrl) {
392
- // TODO: super.parse?
393
409
  const greasedLineMaterialOptions = source.greasedLineMaterialOptions;
394
410
  this._colorsTexture?.dispose();
395
411
  greasedLineMaterialOptions.color && (this.color = greasedLineMaterialOptions.color);
@@ -415,4 +431,8 @@ export class GreasedLineSimpleMaterial extends ShaderMaterial {
415
431
  this.setDefine("GREASED_LINE_CAMERA_FACING", this._cameraFacing);
416
432
  }
417
433
  }
434
+ /**
435
+ * Force to use GLSL in WebGPU
436
+ */
437
+ GreasedLineSimpleMaterial.ForceGLSL = false;
418
438
  //# sourceMappingURL=greasedLineSimpleMaterial.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"greasedLineSimpleMaterial.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/GreasedLine/greasedLineSimpleMaterial.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,OAAO,oCAAoC,CAAC;AAC5C,OAAO,kCAAkC,CAAC;AAG1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAE5E;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,cAAc;IAmBzD;;;;;OAKG;IACH,YAAY,IAAY,EAAE,KAAY,EAAE,OAAmC;QACvE,MAAM,OAAO,GAAG;YACZ,gCAAgC,yEAAiE,GAAG;YACpG,mCAAmC,4EAAoE,GAAG;YAC1G,kBAAkB,+CAAuC,GAAG;YAC5D,kBAAkB,+CAAuC,GAAG;YAC5D,uBAAuB,oDAA4C,GAAG;SACzE,CAAC;QACF,MAAM,UAAU,GAAG,CAAC,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,mBAAmB,CAAC,CAAC;QAElF,KAAK,CAAC,oBAAoB,IAAI,OAAO,CAA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CAAC;QAC1F,0BAA0B,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,0BAA0B,CAAC,SAAS,CAAC,CAAC;QAChG,0BAA0B,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,0BAA0B,CAAC,SAAS,CAAC,CAAC;QAChG,0BAA0B,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,0BAA0B,CAAC,UAAU,CAAC,CAAC;QACnG,0BAA0B,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,0BAA0B,CAAC,KAAK,CAAC,CAAC;QACpF,0BAA0B,CAAC,eAAe,IAAI,CAAC,IAAI,CAAC,eAAe,GAAG,0BAA0B,CAAC,eAAe,CAAC,CAAC;QAClH,0BAA0B,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,0BAA0B,CAAC,UAAU,CAAC,CAAC;QAEnG,IAAI,0BAA0B,CAAC,MAAM,EAAE,CAAC;YACpC,IAAI,CAAC,aAAa,GAAG,gBAAgB,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAAC,IAAI,iBAAiB,EAAE,0BAA0B,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACtK,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,aAAa,GAAG,gBAAgB,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC;QAC3E,CAAC;QAED,IAAI,CAAC,aAAa,GAAG,0BAA0B,CAAC,YAAY,IAAI,IAAI,CAAC;QACrE,IAAI,CAAC,SAAS,CAAC,4BAA4B,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACrE,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport { RawTexture } from \"../Textures/rawTexture\";\r\n\r\nimport { ShaderMaterial } from \"../shaderMaterial\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Color3 } from \"../../Maths/math.color\";\r\nimport { Vector2 } from \"../../Maths/math.vector\";\r\n\r\nimport \"../../Shaders/greasedLine.fragment\";\r\nimport \"../../Shaders/greasedLine.vertex\";\r\nimport type { GreasedLineMaterialOptions, IGreasedLineMaterial } from \"./greasedLineMaterialInterfaces\";\r\nimport { GreasedLineMeshColorDistributionType, GreasedLineMeshColorMode } from \"./greasedLineMaterialInterfaces\";\r\nimport { GreasedLineTools } from \"../../Misc/greasedLineTools\";\r\nimport { GreasedLineMaterialDefaults } from \"./greasedLineMaterialDefaults\";\r\n\r\n/**\r\n * GreasedLineSimpleMaterial\r\n */\r\nexport class GreasedLineSimpleMaterial extends ShaderMaterial implements IGreasedLineMaterial {\r\n private _visibility: number;\r\n private _width: number;\r\n private _useDash: boolean;\r\n private _dashCount: number;\r\n private _dashArray: number;\r\n private _dashRatio: number;\r\n private _dashOffset: number;\r\n private _useColors: boolean;\r\n private _color: Color3 = Color3.White();\r\n private _colors: Nullable<Color3[]>;\r\n private _colorsDistributionType: GreasedLineMeshColorDistributionType = GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_SEGMENT;\r\n private _colorMode: GreasedLineMeshColorMode;\r\n private _colorsSampling: number;\r\n private _resolution: Vector2;\r\n private _sizeAttenuation: boolean;\r\n private _colorsTexture: Nullable<RawTexture> = null;\r\n private _cameraFacing: boolean;\r\n\r\n /**\r\n * GreasedLineSimple material constructor\r\n * @param name material name\r\n * @param scene the scene\r\n * @param options material options\r\n */\r\n constructor(name: string, scene: Scene, options: GreasedLineMaterialOptions) {\r\n const defines = [\r\n `COLOR_DISTRIBUTION_TYPE_LINE ${GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_LINE}.`,\r\n `COLOR_DISTRIBUTION_TYPE_SEGMENT ${GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_SEGMENT}.`,\r\n `COLOR_MODE_SET ${GreasedLineMeshColorMode.COLOR_MODE_SET}.`,\r\n `COLOR_MODE_ADD ${GreasedLineMeshColorMode.COLOR_MODE_ADD}.`,\r\n `COLOR_MODE_MULTIPLY ${GreasedLineMeshColorMode.COLOR_MODE_MULTIPLY}.`,\r\n ];\r\n const attributes = [\"position\", \"grl_widths\", \"grl_offsets\", \"grl_colorPointers\"];\r\n\r\n scene.useRightHandedSystem && defines.push(\"GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM\");\r\n\r\n if (options.cameraFacing) {\r\n defines.push(\"GREASED_LINE_CAMERA_FACING\");\r\n attributes.push(\"grl_previousAndSide\", \"grl_nextAndCounters\");\r\n } else {\r\n attributes.push(\"grl_slopes\");\r\n attributes.push(\"grl_counters\");\r\n }\r\n\r\n super(\r\n name,\r\n scene,\r\n {\r\n vertex: \"greasedLine\",\r\n fragment: \"greasedLine\",\r\n },\r\n {\r\n attributes,\r\n uniforms: [\r\n \"world\",\r\n \"viewProjection\",\r\n \"view\",\r\n \"projection\",\r\n \"grlColorsWidth\",\r\n \"grlUseColors\",\r\n \"grlWidth\",\r\n \"grlColor\",\r\n \"grl_colorModeAndColorDistributionType\",\r\n \"grlResolution\",\r\n \"grlAspect\",\r\n \"grlAizeAttenuation\",\r\n \"grlDashArray\",\r\n \"grlDashOffset\",\r\n \"grlDashRatio\",\r\n \"grlUseDash\",\r\n \"grlVisibility\",\r\n ],\r\n samplers: [\"grlColors\"],\r\n defines,\r\n }\r\n );\r\n options = options || {\r\n color: GreasedLineMaterialDefaults.DEFAULT_COLOR,\r\n };\r\n\r\n const engine = scene.getEngine();\r\n\r\n this.visibility = options.visibility ?? 1;\r\n this.useDash = options.useDash ?? false;\r\n this.dashRatio = options.dashRatio ?? 0.5;\r\n this.dashOffset = options.dashOffset ?? 0;\r\n this.dashCount = options.dashCount ?? 1; // calculate the _dashArray value, call the setter\r\n this.width = options.width\r\n ? options.width\r\n : options.sizeAttenuation && options.cameraFacing\r\n ? GreasedLineMaterialDefaults.DEFAULT_WIDTH_ATTENUATED\r\n : GreasedLineMaterialDefaults.DEFAULT_WIDTH;\r\n this.sizeAttenuation = options.sizeAttenuation ?? false;\r\n this.color = options.color ?? Color3.White();\r\n this.useColors = options.useColors ?? false;\r\n this.colorsDistributionType = options.colorDistributionType ?? GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_SEGMENT;\r\n this.colorsSampling = options.colorsSampling ?? RawTexture.NEAREST_NEAREST;\r\n this.colorMode = options.colorMode ?? GreasedLineMeshColorMode.COLOR_MODE_SET;\r\n this._colors = options.colors ?? null;\r\n this._cameraFacing = options.cameraFacing ?? true;\r\n this.resolution = options.resolution ?? new Vector2(engine.getRenderWidth(), engine.getRenderHeight()); // calculate aspect call the setter\r\n\r\n if (options.colorsTexture) {\r\n this.colorsTexture = options.colorsTexture;\r\n } else {\r\n this.colorsTexture = GreasedLineTools.PrepareEmptyColorsTexture(scene);\r\n }\r\n\r\n if (this._colors) {\r\n if (this.useColors) {\r\n this.colorsTexture = GreasedLineTools.CreateColorsTexture(`${this.name}-colors-texture`, this._colors, this.colorsSampling, scene);\r\n }\r\n }\r\n\r\n engine.onDisposeObservable.add(() => {\r\n GreasedLineTools.DisposeEmptyColorsTexture();\r\n });\r\n }\r\n\r\n /**\r\n * Disposes the plugin material.\r\n */\r\n public override dispose(): void {\r\n this._colorsTexture?.dispose();\r\n super.dispose();\r\n }\r\n\r\n private _setColorModeAndColorDistributionType() {\r\n this.setVector2(\"grl_colorModeAndColorDistributionType\", new Vector2(this._colorMode, this._colorsDistributionType));\r\n }\r\n\r\n /**\r\n * Updates the material. Use when material created in lazy mode.\r\n */\r\n public updateLazy() {\r\n if (this._colors) {\r\n this.setColors(this._colors, false, true);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the colors used to colorize the line\r\n */\r\n get colors() {\r\n return this._colors;\r\n }\r\n\r\n /**\r\n * Sets the colors used to colorize the line\r\n */\r\n set colors(value: Nullable<Color3[]>) {\r\n this.setColors(value);\r\n }\r\n\r\n /**\r\n * Creates or updates the colors texture\r\n * @param colors color table RGBA\r\n * @param lazy if lazy, the colors are not updated\r\n * @param forceNewTexture force creation of a new texture\r\n */\r\n public setColors(colors: Nullable<Color3[]>, lazy = false, forceNewTexture = false): void {\r\n const origColorsCount = this._colors?.length ?? 0;\r\n\r\n this._colors = colors;\r\n\r\n if (colors === null || colors.length === 0) {\r\n this._colorsTexture?.dispose();\r\n return;\r\n }\r\n\r\n if (lazy && !forceNewTexture) {\r\n return;\r\n }\r\n\r\n if (this._colorsTexture && origColorsCount === colors.length && !forceNewTexture) {\r\n const colorArray = GreasedLineTools.Color3toRGBAUint8(colors);\r\n this._colorsTexture.update(colorArray);\r\n } else {\r\n this._colorsTexture?.dispose();\r\n this.colorsTexture = GreasedLineTools.CreateColorsTexture(`${this.name}-colors-texture`, colors, this.colorsSampling, this.getScene());\r\n }\r\n }\r\n\r\n /**\r\n * Gets the colors texture\r\n */\r\n get colorsTexture() {\r\n return (this._colorsTexture as RawTexture) ?? null;\r\n }\r\n\r\n /**\r\n * Sets the colorsTexture\r\n */\r\n set colorsTexture(value: RawTexture) {\r\n this._colorsTexture = value;\r\n this.setFloat(\"grlColorsWidth\", this._colorsTexture.getSize().width);\r\n this.setTexture(\"grlColors\", this._colorsTexture);\r\n }\r\n\r\n /**\r\n * Line base width. At each point the line width is calculated by widths[pointIndex] * width\r\n */\r\n get width() {\r\n return this._width;\r\n }\r\n\r\n /**\r\n * Line base width. At each point the line width is calculated by widths[pointIndex] * width\r\n */\r\n set width(value: number) {\r\n this._width = value;\r\n this.setFloat(\"grlWidth\", value);\r\n }\r\n\r\n /**\r\n * Whether to use the colors option to colorize the line\r\n */\r\n get useColors() {\r\n return this._useColors;\r\n }\r\n\r\n set useColors(value: boolean) {\r\n this._useColors = value;\r\n this.setFloat(\"grlUseColors\", GreasedLineTools.BooleanToNumber(value));\r\n }\r\n\r\n /**\r\n * The type of sampling of the colors texture. The values are the same when using with textures.\r\n */\r\n get colorsSampling() {\r\n return this._colorsSampling;\r\n }\r\n\r\n /**\r\n * The type of sampling of the colors texture. The values are the same when using with textures.\r\n */\r\n set colorsSampling(value: number) {\r\n this._colorsSampling = value;\r\n }\r\n\r\n /**\r\n * Normalized value of how much of the line will be visible\r\n * 0 - 0% of the line will be visible\r\n * 1 - 100% of the line will be visible\r\n */\r\n get visibility() {\r\n return this._visibility;\r\n }\r\n\r\n set visibility(value: number) {\r\n this._visibility = value;\r\n this.setFloat(\"grlVisibility\", value);\r\n }\r\n\r\n /**\r\n * Turns on/off dash mode\r\n */\r\n get useDash() {\r\n return this._useDash;\r\n }\r\n\r\n /**\r\n * Turns on/off dash mode\r\n */\r\n set useDash(value: boolean) {\r\n this._useDash = value;\r\n this.setFloat(\"grlUseDash\", GreasedLineTools.BooleanToNumber(value));\r\n }\r\n\r\n /**\r\n * Gets the dash offset\r\n */\r\n get dashOffset() {\r\n return this._dashOffset;\r\n }\r\n\r\n /**\r\n * Sets the dash offset\r\n */\r\n set dashOffset(value: number) {\r\n this._dashOffset = value;\r\n this.setFloat(\"grlDashOffset\", value);\r\n }\r\n\r\n /**\r\n * Length of the dash. 0 to 1. 0.5 means half empty, half drawn.\r\n */\r\n get dashRatio() {\r\n return this._dashRatio;\r\n }\r\n\r\n /**\r\n * Length of the dash. 0 to 1. 0.5 means half empty, half drawn.\r\n */\r\n set dashRatio(value: number) {\r\n this._dashRatio = value;\r\n this.setFloat(\"grlDashRatio\", value);\r\n }\r\n\r\n /**\r\n * Gets the number of dashes in the line\r\n */\r\n get dashCount() {\r\n return this._dashCount;\r\n }\r\n /**\r\n * Sets the number of dashes in the line\r\n * @param value dash\r\n */\r\n set dashCount(value: number) {\r\n this._dashCount = value;\r\n this._dashArray = 1 / value;\r\n this.setFloat(\"grlDashArray\", this._dashArray);\r\n }\r\n\r\n /**\r\n * False means 1 unit in width = 1 unit on scene, true means 1 unit in width is reduced on the screen to make better looking lines\r\n */\r\n get sizeAttenuation() {\r\n return this._sizeAttenuation;\r\n }\r\n\r\n /**\r\n * Turn on/off attenuation of the width option and widths array.\r\n * @param value false means 1 unit in width = 1 unit on scene, true means 1 unit in width is reduced on the screen to make better looking lines\r\n */\r\n set sizeAttenuation(value: boolean) {\r\n this._sizeAttenuation = value;\r\n this.setFloat(\"grlSizeAttenuation\", GreasedLineTools.BooleanToNumber(value));\r\n }\r\n\r\n /**\r\n * Gets the color of the line\r\n */\r\n get color() {\r\n return this._color;\r\n }\r\n\r\n /**\r\n * Sets the color of the line\r\n * @param value Color3\r\n */\r\n set color(value: Color3) {\r\n this.setColor(value);\r\n }\r\n\r\n /**\r\n * Sets the color of the line. If set the whole line will be mixed with this color according to the colorMode option.\r\n * The simple material always needs a color to be set. If you set it to null it will set the color to the default color (GreasedLineSimpleMaterial.DEFAULT_COLOR).\r\n * @param value color\r\n */\r\n public setColor(value: Nullable<Color3>) {\r\n value = value ?? GreasedLineMaterialDefaults.DEFAULT_COLOR;\r\n this._color = value;\r\n this.setColor3(\"grlColor\", value);\r\n }\r\n\r\n /**\r\n * Gets the color distributiopn type\r\n */\r\n get colorsDistributionType() {\r\n return this._colorsDistributionType;\r\n }\r\n\r\n /**\r\n * Sets the color distribution type\r\n * @see GreasedLineMeshColorDistributionType\r\n * @param value color distribution type\r\n */\r\n set colorsDistributionType(value: GreasedLineMeshColorDistributionType) {\r\n this._colorsDistributionType = value;\r\n this._setColorModeAndColorDistributionType();\r\n }\r\n\r\n /**\r\n * Gets the mixing mode of the color and colors paramaters. Default value is GreasedLineMeshColorMode.SET.\r\n * MATERIAL_TYPE_SIMPLE mixes the color and colors of the greased line material.\r\n * @see GreasedLineMeshColorMode\r\n */\r\n get colorMode() {\r\n return this._colorMode;\r\n }\r\n\r\n /**\r\n * Sets the mixing mode of the color and colors paramaters. Default value is GreasedLineMeshColorMode.SET.\r\n * MATERIAL_TYPE_SIMPLE mixes the color and colors of the greased line material.\r\n * @see GreasedLineMeshColorMode\r\n */\r\n set colorMode(value: GreasedLineMeshColorMode) {\r\n this._colorMode = value;\r\n this._setColorModeAndColorDistributionType();\r\n }\r\n\r\n /**\r\n * Gets the resolution\r\n */\r\n get resolution() {\r\n return this._resolution;\r\n }\r\n\r\n /**\r\n * Sets the resolution\r\n * @param value resolution of the screen for GreasedLine\r\n */\r\n set resolution(value: Vector2) {\r\n this._resolution = value;\r\n this.setVector2(\"grlResolution\", value);\r\n this.setFloat(\"grlAspect\", value.x / value.y);\r\n }\r\n\r\n /**\r\n * Serializes this plugin material\r\n * @returns serializationObjec\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n const greasedLineMaterialOptions: GreasedLineMaterialOptions = {\r\n colorDistributionType: this._colorsDistributionType,\r\n colorsSampling: this._colorsSampling,\r\n colorMode: this._colorMode,\r\n color: this._color,\r\n dashCount: this._dashCount,\r\n dashOffset: this._dashOffset,\r\n dashRatio: this._dashRatio,\r\n resolution: this._resolution,\r\n sizeAttenuation: this._sizeAttenuation,\r\n useColors: this._useColors,\r\n useDash: this._useDash,\r\n visibility: this._visibility,\r\n width: this._width,\r\n cameraFacing: this._cameraFacing,\r\n };\r\n\r\n this._colors && (greasedLineMaterialOptions.colors = this._colors);\r\n\r\n serializationObject.greasedLineMaterialOptions = greasedLineMaterialOptions;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parses a serialized objects\r\n * @param source serialized object\r\n * @param scene scene\r\n * @param _rootUrl root url for textures\r\n */\r\n public parse(source: any, scene: Scene, _rootUrl: string): void {\r\n // TODO: super.parse?\r\n const greasedLineMaterialOptions = <GreasedLineMaterialOptions>source.greasedLineMaterialOptions;\r\n\r\n this._colorsTexture?.dispose();\r\n\r\n greasedLineMaterialOptions.color && (this.color = greasedLineMaterialOptions.color);\r\n greasedLineMaterialOptions.colorDistributionType && (this.colorsDistributionType = greasedLineMaterialOptions.colorDistributionType);\r\n greasedLineMaterialOptions.colorsSampling && (this.colorsSampling = greasedLineMaterialOptions.colorsSampling);\r\n greasedLineMaterialOptions.colorMode && (this.colorMode = greasedLineMaterialOptions.colorMode);\r\n greasedLineMaterialOptions.useColors && (this.useColors = greasedLineMaterialOptions.useColors);\r\n greasedLineMaterialOptions.visibility && (this.visibility = greasedLineMaterialOptions.visibility);\r\n greasedLineMaterialOptions.useDash && (this.useDash = greasedLineMaterialOptions.useDash);\r\n greasedLineMaterialOptions.dashCount && (this.dashCount = greasedLineMaterialOptions.dashCount);\r\n greasedLineMaterialOptions.dashRatio && (this.dashRatio = greasedLineMaterialOptions.dashRatio);\r\n greasedLineMaterialOptions.dashOffset && (this.dashOffset = greasedLineMaterialOptions.dashOffset);\r\n greasedLineMaterialOptions.width && (this.width = greasedLineMaterialOptions.width);\r\n greasedLineMaterialOptions.sizeAttenuation && (this.sizeAttenuation = greasedLineMaterialOptions.sizeAttenuation);\r\n greasedLineMaterialOptions.resolution && (this.resolution = greasedLineMaterialOptions.resolution);\r\n\r\n if (greasedLineMaterialOptions.colors) {\r\n this.colorsTexture = GreasedLineTools.CreateColorsTexture(`${this.name}-colors-texture`, greasedLineMaterialOptions.colors, this.colorsSampling, this.getScene());\r\n } else {\r\n this.colorsTexture = GreasedLineTools.PrepareEmptyColorsTexture(scene);\r\n }\r\n\r\n this._cameraFacing = greasedLineMaterialOptions.cameraFacing ?? true;\r\n this.setDefine(\"GREASED_LINE_CAMERA_FACING\", this._cameraFacing);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"greasedLineSimpleMaterial.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/GreasedLine/greasedLineSimpleMaterial.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAI5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,O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AAY,IAAI,IAAI,CAAC;QACrE,IAAI,CAAC,SAAS,CAAC,4BAA4B,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACrE,CAAC;;AApfD;;GAEG;AACW,mCAAS,GAAG,KAAK,AAAR,CAAS","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport { RawTexture } from \"../Textures/rawTexture\";\r\nimport { ShaderMaterial } from \"../shaderMaterial\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Color3 } from \"../../Maths/math.color\";\r\nimport { Vector2 } from \"../../Maths/math.vector\";\r\nimport { ShaderLanguage } from \"../shaderLanguage\";\r\nimport { TextureSampler } from \"../Textures/textureSampler\";\r\n\r\nimport type { GreasedLineMaterialOptions, IGreasedLineMaterial } from \"./greasedLineMaterialInterfaces\";\r\nimport { GreasedLineMeshColorDistributionType, GreasedLineMeshColorMode } from \"./greasedLineMaterialInterfaces\";\r\nimport { GreasedLineTools } from \"../../Misc/greasedLineTools\";\r\nimport { GreasedLineMaterialDefaults } from \"./greasedLineMaterialDefaults\";\r\n\r\n/**\r\n * GreasedLineSimpleMaterial\r\n */\r\nexport class GreasedLineSimpleMaterial extends ShaderMaterial implements IGreasedLineMaterial {\r\n /**\r\n * Force to use GLSL in WebGPU\r\n */\r\n public static ForceGLSL = false;\r\n\r\n private _visibility: number;\r\n private _width: number;\r\n private _useDash: boolean;\r\n private _dashCount: number;\r\n private _dashArray: number;\r\n private _dashRatio: number;\r\n private _dashOffset: number;\r\n private _useColors: boolean;\r\n private _color: Color3 = Color3.White();\r\n private _colors: Nullable<Color3[]>;\r\n private _colorsDistributionType: GreasedLineMeshColorDistributionType = GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_SEGMENT;\r\n private _colorMode: GreasedLineMeshColorMode;\r\n private _colorsSampling: number;\r\n private _resolution: Vector2;\r\n private _sizeAttenuation: boolean;\r\n private _colorsTexture: Nullable<RawTexture> = null;\r\n private _cameraFacing: boolean;\r\n\r\n /**\r\n * GreasedLineSimple material constructor\r\n * @param name material name\r\n * @param scene the scene\r\n * @param options material options\r\n */\r\n constructor(name: string, scene: Scene, options: GreasedLineMaterialOptions) {\r\n const engine = scene.getEngine();\r\n const isWGSL = engine.isWebGPU && !(options.forceGLSL || GreasedLineSimpleMaterial.ForceGLSL);\r\n\r\n const defines = [\r\n `COLOR_DISTRIBUTION_TYPE_LINE ${GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_LINE}.`,\r\n `COLOR_DISTRIBUTION_TYPE_SEGMENT ${GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_SEGMENT}.`,\r\n `COLOR_MODE_SET ${GreasedLineMeshColorMode.COLOR_MODE_SET}.`,\r\n `COLOR_MODE_ADD ${GreasedLineMeshColorMode.COLOR_MODE_ADD}.`,\r\n `COLOR_MODE_MULTIPLY ${GreasedLineMeshColorMode.COLOR_MODE_MULTIPLY}.`,\r\n ];\r\n scene.useRightHandedSystem && defines.push(\"GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM\");\r\n\r\n const attributes = [\"position\", \"grl_widths\", \"grl_offsets\", \"grl_colorPointers\"];\r\n\r\n if (options.cameraFacing) {\r\n defines.push(\"GREASED_LINE_CAMERA_FACING\");\r\n attributes.push(\"grl_previousAndSide\", \"grl_nextAndCounters\");\r\n } else {\r\n attributes.push(\"grl_slopes\");\r\n attributes.push(\"grl_counters\");\r\n }\r\n\r\n const uniforms = [\r\n \"grlColorsWidth\",\r\n \"grlUseColors\",\r\n \"grlWidth\",\r\n \"grlColor\",\r\n \"grl_colorModeAndColorDistributionType\",\r\n \"grlResolution\",\r\n \"grlAspect\",\r\n \"grlAizeAttenuation\",\r\n \"grlDashArray\",\r\n \"grlDashOffset\",\r\n \"grlDashRatio\",\r\n \"grlUseDash\",\r\n \"grlVisibility\",\r\n \"grlColors\",\r\n ];\r\n\r\n if (!isWGSL) {\r\n uniforms.push(\"world\", \"viewProjection\", \"view\", \"projection\");\r\n }\r\n\r\n super(\r\n name,\r\n scene,\r\n {\r\n vertex: \"greasedLine\",\r\n fragment: \"greasedLine\",\r\n },\r\n {\r\n uniformBuffers: isWGSL ? [\"Scene\", \"Mesh\"] : undefined,\r\n attributes,\r\n uniforms,\r\n samplers: isWGSL ? [] : [\"grlColors\"],\r\n defines,\r\n extraInitializationsAsync: async () => {\r\n if (isWGSL) {\r\n await Promise.all([import(\"../../ShadersWGSL/greasedLine.vertex\"), import(\"../../ShadersWGSL/greasedLine.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/greasedLine.vertex\"), import(\"../../Shaders/greasedLine.fragment\")]);\r\n }\r\n },\r\n shaderLanguage: isWGSL ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n }\r\n );\r\n\r\n options = options || {\r\n color: GreasedLineMaterialDefaults.DEFAULT_COLOR,\r\n };\r\n\r\n this.visibility = options.visibility ?? 1;\r\n this.useDash = options.useDash ?? false;\r\n this.dashRatio = options.dashRatio ?? 0.5;\r\n this.dashOffset = options.dashOffset ?? 0;\r\n this.dashCount = options.dashCount ?? 1; // calculate the _dashArray value, call the setter\r\n this.width = options.width\r\n ? options.width\r\n : options.sizeAttenuation && options.cameraFacing\r\n ? GreasedLineMaterialDefaults.DEFAULT_WIDTH_ATTENUATED\r\n : GreasedLineMaterialDefaults.DEFAULT_WIDTH;\r\n this.sizeAttenuation = options.sizeAttenuation ?? false;\r\n this.color = options.color ?? Color3.White();\r\n this.useColors = options.useColors ?? false;\r\n this.colorsDistributionType = options.colorDistributionType ?? GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_SEGMENT;\r\n this.colorsSampling = options.colorsSampling ?? RawTexture.NEAREST_NEAREST;\r\n this.colorMode = options.colorMode ?? GreasedLineMeshColorMode.COLOR_MODE_SET;\r\n this._colors = options.colors ?? null;\r\n this._cameraFacing = options.cameraFacing ?? true;\r\n this.resolution = options.resolution ?? new Vector2(engine.getRenderWidth(), engine.getRenderHeight()); // calculate aspect call the setter\r\n\r\n if (options.colorsTexture) {\r\n this.colorsTexture = options.colorsTexture;\r\n } else {\r\n this.colorsTexture = GreasedLineTools.PrepareEmptyColorsTexture(scene);\r\n }\r\n\r\n if (this._colors) {\r\n if (this.useColors) {\r\n this.colorsTexture = GreasedLineTools.CreateColorsTexture(`${this.name}-colors-texture`, this._colors, this.colorsSampling, scene);\r\n }\r\n }\r\n\r\n if (isWGSL) {\r\n const sampler = new TextureSampler();\r\n sampler.setParameters(); // use the default values\r\n sampler.samplingMode = this.colorsSampling;\r\n this.setTextureSampler(\"grlColorsSampler\", sampler);\r\n }\r\n\r\n engine.onDisposeObservable.add(() => {\r\n GreasedLineTools.DisposeEmptyColorsTexture();\r\n });\r\n }\r\n\r\n /**\r\n * Disposes the plugin material.\r\n */\r\n public override dispose(): void {\r\n this._colorsTexture?.dispose();\r\n super.dispose();\r\n }\r\n\r\n private _setColorModeAndColorDistributionType() {\r\n this.setVector2(\"grl_colorModeAndColorDistributionType\", new Vector2(this._colorMode, this._colorsDistributionType));\r\n }\r\n\r\n /**\r\n * Updates the material. Use when material created in lazy mode.\r\n */\r\n public updateLazy() {\r\n if (this._colors) {\r\n this.setColors(this._colors, false, true);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the colors used to colorize the line\r\n */\r\n get colors() {\r\n return this._colors;\r\n }\r\n\r\n /**\r\n * Sets the colors used to colorize the line\r\n */\r\n set colors(value: Nullable<Color3[]>) {\r\n this.setColors(value);\r\n }\r\n\r\n /**\r\n * Creates or updates the colors texture\r\n * @param colors color table RGBA\r\n * @param lazy if lazy, the colors are not updated\r\n * @param forceNewTexture force creation of a new texture\r\n */\r\n public setColors(colors: Nullable<Color3[]>, lazy = false, forceNewTexture = false): void {\r\n const origColorsCount = this._colors?.length ?? 0;\r\n\r\n this._colors = colors;\r\n\r\n if (colors === null || colors.length === 0) {\r\n this._colorsTexture?.dispose();\r\n return;\r\n }\r\n\r\n if (lazy && !forceNewTexture) {\r\n return;\r\n }\r\n\r\n if (this._colorsTexture && origColorsCount === colors.length && !forceNewTexture) {\r\n const colorArray = GreasedLineTools.Color3toRGBAUint8(colors);\r\n this._colorsTexture.update(colorArray);\r\n } else {\r\n this._colorsTexture?.dispose();\r\n this.colorsTexture = GreasedLineTools.CreateColorsTexture(`${this.name}-colors-texture`, colors, this.colorsSampling, this.getScene());\r\n }\r\n }\r\n\r\n /**\r\n * Gets the colors texture\r\n */\r\n get colorsTexture() {\r\n return (this._colorsTexture as RawTexture) ?? null;\r\n }\r\n\r\n /**\r\n * Sets the colorsTexture\r\n */\r\n set colorsTexture(value: RawTexture) {\r\n this._colorsTexture = value;\r\n this.setFloat(\"grlColorsWidth\", this._colorsTexture.getSize().width);\r\n this.setTexture(\"grlColors\", this._colorsTexture);\r\n }\r\n\r\n /**\r\n * Line base width. At each point the line width is calculated by widths[pointIndex] * width\r\n */\r\n get width() {\r\n return this._width;\r\n }\r\n\r\n /**\r\n * Line base width. At each point the line width is calculated by widths[pointIndex] * width\r\n */\r\n set width(value: number) {\r\n this._width = value;\r\n this.setFloat(\"grlWidth\", value);\r\n }\r\n\r\n /**\r\n * Whether to use the colors option to colorize the line\r\n */\r\n get useColors() {\r\n return this._useColors;\r\n }\r\n\r\n set useColors(value: boolean) {\r\n this._useColors = value;\r\n this.setFloat(\"grlUseColors\", GreasedLineTools.BooleanToNumber(value));\r\n }\r\n\r\n /**\r\n * The type of sampling of the colors texture. The values are the same when using with textures.\r\n */\r\n get colorsSampling() {\r\n return this._colorsSampling;\r\n }\r\n\r\n /**\r\n * The type of sampling of the colors texture. The values are the same when using with textures.\r\n */\r\n set colorsSampling(value: number) {\r\n this._colorsSampling = value;\r\n }\r\n\r\n /**\r\n * Normalized value of how much of the line will be visible\r\n * 0 - 0% of the line will be visible\r\n * 1 - 100% of the line will be visible\r\n */\r\n get visibility() {\r\n return this._visibility;\r\n }\r\n\r\n set visibility(value: number) {\r\n this._visibility = value;\r\n this.setFloat(\"grlVisibility\", value);\r\n }\r\n\r\n /**\r\n * Turns on/off dash mode\r\n */\r\n get useDash() {\r\n return this._useDash;\r\n }\r\n\r\n /**\r\n * Turns on/off dash mode\r\n */\r\n set useDash(value: boolean) {\r\n this._useDash = value;\r\n this.setFloat(\"grlUseDash\", GreasedLineTools.BooleanToNumber(value));\r\n }\r\n\r\n /**\r\n * Gets the dash offset\r\n */\r\n get dashOffset() {\r\n return this._dashOffset;\r\n }\r\n\r\n /**\r\n * Sets the dash offset\r\n */\r\n set dashOffset(value: number) {\r\n this._dashOffset = value;\r\n this.setFloat(\"grlDashOffset\", value);\r\n }\r\n\r\n /**\r\n * Length of the dash. 0 to 1. 0.5 means half empty, half drawn.\r\n */\r\n get dashRatio() {\r\n return this._dashRatio;\r\n }\r\n\r\n /**\r\n * Length of the dash. 0 to 1. 0.5 means half empty, half drawn.\r\n */\r\n set dashRatio(value: number) {\r\n this._dashRatio = value;\r\n this.setFloat(\"grlDashRatio\", value);\r\n }\r\n\r\n /**\r\n * Gets the number of dashes in the line\r\n */\r\n get dashCount() {\r\n return this._dashCount;\r\n }\r\n /**\r\n * Sets the number of dashes in the line\r\n * @param value dash\r\n */\r\n set dashCount(value: number) {\r\n this._dashCount = value;\r\n this._dashArray = 1 / value;\r\n this.setFloat(\"grlDashArray\", this._dashArray);\r\n }\r\n\r\n /**\r\n * False means 1 unit in width = 1 unit on scene, true means 1 unit in width is reduced on the screen to make better looking lines\r\n */\r\n get sizeAttenuation() {\r\n return this._sizeAttenuation;\r\n }\r\n\r\n /**\r\n * Turn on/off attenuation of the width option and widths array.\r\n * @param value false means 1 unit in width = 1 unit on scene, true means 1 unit in width is reduced on the screen to make better looking lines\r\n */\r\n set sizeAttenuation(value: boolean) {\r\n this._sizeAttenuation = value;\r\n this.setFloat(\"grlSizeAttenuation\", GreasedLineTools.BooleanToNumber(value));\r\n }\r\n\r\n /**\r\n * Gets the color of the line\r\n */\r\n get color() {\r\n return this._color;\r\n }\r\n\r\n /**\r\n * Sets the color of the line\r\n * @param value Color3\r\n */\r\n set color(value: Color3) {\r\n this.setColor(value);\r\n }\r\n\r\n /**\r\n * Sets the color of the line. If set the whole line will be mixed with this color according to the colorMode option.\r\n * The simple material always needs a color to be set. If you set it to null it will set the color to the default color (GreasedLineSimpleMaterial.DEFAULT_COLOR).\r\n * @param value color\r\n */\r\n public setColor(value: Nullable<Color3>) {\r\n value = value ?? GreasedLineMaterialDefaults.DEFAULT_COLOR;\r\n this._color = value;\r\n this.setColor3(\"grlColor\", value);\r\n }\r\n\r\n /**\r\n * Gets the color distributiopn type\r\n */\r\n get colorsDistributionType() {\r\n return this._colorsDistributionType;\r\n }\r\n\r\n /**\r\n * Sets the color distribution type\r\n * @see GreasedLineMeshColorDistributionType\r\n * @param value color distribution type\r\n */\r\n set colorsDistributionType(value: GreasedLineMeshColorDistributionType) {\r\n this._colorsDistributionType = value;\r\n this._setColorModeAndColorDistributionType();\r\n }\r\n\r\n /**\r\n * Gets the mixing mode of the color and colors paramaters. Default value is GreasedLineMeshColorMode.SET.\r\n * MATERIAL_TYPE_SIMPLE mixes the color and colors of the greased line material.\r\n * @see GreasedLineMeshColorMode\r\n */\r\n get colorMode() {\r\n return this._colorMode;\r\n }\r\n\r\n /**\r\n * Sets the mixing mode of the color and colors paramaters. Default value is GreasedLineMeshColorMode.SET.\r\n * MATERIAL_TYPE_SIMPLE mixes the color and colors of the greased line material.\r\n * @see GreasedLineMeshColorMode\r\n */\r\n set colorMode(value: GreasedLineMeshColorMode) {\r\n this._colorMode = value;\r\n this._setColorModeAndColorDistributionType();\r\n }\r\n\r\n /**\r\n * Gets the resolution\r\n */\r\n get resolution() {\r\n return this._resolution;\r\n }\r\n\r\n /**\r\n * Sets the resolution\r\n * @param value resolution of the screen for GreasedLine\r\n */\r\n set resolution(value: Vector2) {\r\n this._resolution = value;\r\n this.setVector2(\"grlResolution\", value);\r\n this.setFloat(\"grlAspect\", value.x / value.y);\r\n }\r\n\r\n /**\r\n * Serializes this plugin material\r\n * @returns serializationObjec\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n const greasedLineMaterialOptions: GreasedLineMaterialOptions = {\r\n colorDistributionType: this._colorsDistributionType,\r\n colorsSampling: this._colorsSampling,\r\n colorMode: this._colorMode,\r\n color: this._color,\r\n dashCount: this._dashCount,\r\n dashOffset: this._dashOffset,\r\n dashRatio: this._dashRatio,\r\n resolution: this._resolution,\r\n sizeAttenuation: this._sizeAttenuation,\r\n useColors: this._useColors,\r\n useDash: this._useDash,\r\n visibility: this._visibility,\r\n width: this._width,\r\n cameraFacing: this._cameraFacing,\r\n };\r\n\r\n this._colors && (greasedLineMaterialOptions.colors = this._colors);\r\n\r\n serializationObject.greasedLineMaterialOptions = greasedLineMaterialOptions;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parses a serialized objects\r\n * @param source serialized object\r\n * @param scene scene\r\n * @param _rootUrl root url for textures\r\n */\r\n public parse(source: any, scene: Scene, _rootUrl: string): void {\r\n const greasedLineMaterialOptions = <GreasedLineMaterialOptions>source.greasedLineMaterialOptions;\r\n\r\n this._colorsTexture?.dispose();\r\n\r\n greasedLineMaterialOptions.color && (this.color = greasedLineMaterialOptions.color);\r\n greasedLineMaterialOptions.colorDistributionType && (this.colorsDistributionType = greasedLineMaterialOptions.colorDistributionType);\r\n greasedLineMaterialOptions.colorsSampling && (this.colorsSampling = greasedLineMaterialOptions.colorsSampling);\r\n greasedLineMaterialOptions.colorMode && (this.colorMode = greasedLineMaterialOptions.colorMode);\r\n greasedLineMaterialOptions.useColors && (this.useColors = greasedLineMaterialOptions.useColors);\r\n greasedLineMaterialOptions.visibility && (this.visibility = greasedLineMaterialOptions.visibility);\r\n greasedLineMaterialOptions.useDash && (this.useDash = greasedLineMaterialOptions.useDash);\r\n greasedLineMaterialOptions.dashCount && (this.dashCount = greasedLineMaterialOptions.dashCount);\r\n greasedLineMaterialOptions.dashRatio && (this.dashRatio = greasedLineMaterialOptions.dashRatio);\r\n greasedLineMaterialOptions.dashOffset && (this.dashOffset = greasedLineMaterialOptions.dashOffset);\r\n greasedLineMaterialOptions.width && (this.width = greasedLineMaterialOptions.width);\r\n greasedLineMaterialOptions.sizeAttenuation && (this.sizeAttenuation = greasedLineMaterialOptions.sizeAttenuation);\r\n greasedLineMaterialOptions.resolution && (this.resolution = greasedLineMaterialOptions.resolution);\r\n\r\n if (greasedLineMaterialOptions.colors) {\r\n this.colorsTexture = GreasedLineTools.CreateColorsTexture(`${this.name}-colors-texture`, greasedLineMaterialOptions.colors, this.colorsSampling, this.getScene());\r\n } else {\r\n this.colorsTexture = GreasedLineTools.PrepareEmptyColorsTexture(scene);\r\n }\r\n\r\n this._cameraFacing = greasedLineMaterialOptions.cameraFacing ?? true;\r\n this.setDefine(\"GREASED_LINE_CAMERA_FACING\", this._cameraFacing);\r\n }\r\n}\r\n"]}
@@ -463,6 +463,7 @@ export class NodeMaterialBlock {
463
463
  }
464
464
  else {
465
465
  this._inputs[inputIndex0]._linkedConnectionSource = this._inputs[inputIndex1];
466
+ this._inputs[inputIndex0]._isMainLinkSource = true;
466
467
  }
467
468
  this._inputs[inputIndex1]._linkedConnectionSource = this._inputs[inputIndex0];
468
469
  }