@onerjs/serializers 8.53.4 → 8.53.6

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 (197) hide show
  1. package/3MF/core/model/3mf.js +666 -270
  2. package/3MF/core/model/3mf.js.map +1 -1
  3. package/3MF/core/model/3mf.opc.js +142 -62
  4. package/3MF/core/model/3mf.opc.js.map +1 -1
  5. package/3MF/core/model/pure.d.ts +8 -0
  6. package/3MF/core/model/pure.js +9 -0
  7. package/3MF/core/model/pure.js.map +1 -0
  8. package/3MF/core/pure.d.ts +3 -0
  9. package/3MF/core/pure.js +5 -0
  10. package/3MF/core/pure.js.map +1 -0
  11. package/3MF/core/xml/pure.d.ts +7 -0
  12. package/3MF/core/xml/pure.js +8 -0
  13. package/3MF/core/xml/pure.js.map +1 -0
  14. package/3MF/core/xml/xml.interfaces.d.ts +52 -11
  15. package/3MF/core/xml/xml.interfaces.js +24 -8
  16. package/3MF/core/xml/xml.interfaces.js.map +1 -1
  17. package/3MF/pure.d.ts +4 -0
  18. package/3MF/pure.js +6 -0
  19. package/3MF/pure.js.map +1 -0
  20. package/BVH/pure.d.ts +2 -0
  21. package/BVH/pure.js +3 -0
  22. package/BVH/pure.js.map +1 -0
  23. package/OBJ/objSerializer.d.ts +2 -1
  24. package/OBJ/objSerializer.js +3 -2
  25. package/OBJ/objSerializer.js.map +1 -1
  26. package/OBJ/pure.d.ts +2 -0
  27. package/OBJ/pure.js +3 -0
  28. package/OBJ/pure.js.map +1 -0
  29. package/USDZ/pure.d.ts +2 -0
  30. package/USDZ/pure.js +4 -0
  31. package/USDZ/pure.js.map +1 -0
  32. package/glTF/2.0/Extensions/EXT_lights_area.d.ts +3 -37
  33. package/glTF/2.0/Extensions/EXT_lights_area.js +5 -130
  34. package/glTF/2.0/Extensions/EXT_lights_area.js.map +1 -1
  35. package/glTF/2.0/Extensions/EXT_lights_area.pure.d.ts +44 -0
  36. package/glTF/2.0/Extensions/EXT_lights_area.pure.js +145 -0
  37. package/glTF/2.0/Extensions/EXT_lights_area.pure.js.map +1 -0
  38. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +4 -38
  39. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +6 -138
  40. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
  41. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.pure.d.ts +44 -0
  42. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.pure.js +151 -0
  43. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.pure.js.map +1 -0
  44. package/glTF/2.0/Extensions/EXT_texture_avif.d.ts +3 -15
  45. package/glTF/2.0/Extensions/EXT_texture_avif.js +5 -38
  46. package/glTF/2.0/Extensions/EXT_texture_avif.js.map +1 -1
  47. package/glTF/2.0/Extensions/EXT_texture_avif.pure.d.ts +27 -0
  48. package/glTF/2.0/Extensions/EXT_texture_avif.pure.js +58 -0
  49. package/glTF/2.0/Extensions/EXT_texture_avif.pure.js.map +1 -0
  50. package/glTF/2.0/Extensions/EXT_texture_webp.d.ts +3 -14
  51. package/glTF/2.0/Extensions/EXT_texture_webp.js +5 -37
  52. package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
  53. package/glTF/2.0/Extensions/EXT_texture_webp.pure.d.ts +26 -0
  54. package/glTF/2.0/Extensions/EXT_texture_webp.pure.js +57 -0
  55. package/glTF/2.0/Extensions/EXT_texture_webp.pure.js.map +1 -0
  56. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.d.ts +3 -30
  57. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +5 -128
  58. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
  59. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.pure.d.ts +37 -0
  60. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.pure.js +143 -0
  61. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.pure.js.map +1 -0
  62. package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +3 -37
  63. package/glTF/2.0/Extensions/KHR_lights_punctual.js +5 -142
  64. package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
  65. package/glTF/2.0/Extensions/KHR_lights_punctual.pure.d.ts +44 -0
  66. package/glTF/2.0/Extensions/KHR_lights_punctual.pure.js +157 -0
  67. package/glTF/2.0/Extensions/KHR_lights_punctual.pure.js.map +1 -0
  68. package/glTF/2.0/Extensions/KHR_materials_anisotropy.d.ts +3 -30
  69. package/glTF/2.0/Extensions/KHR_materials_anisotropy.js +5 -177
  70. package/glTF/2.0/Extensions/KHR_materials_anisotropy.js.map +1 -1
  71. package/glTF/2.0/Extensions/KHR_materials_anisotropy.pure.d.ts +37 -0
  72. package/glTF/2.0/Extensions/KHR_materials_anisotropy.pure.js +192 -0
  73. package/glTF/2.0/Extensions/KHR_materials_anisotropy.pure.js.map +1 -0
  74. package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +3 -30
  75. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +5 -251
  76. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
  77. package/glTF/2.0/Extensions/KHR_materials_clearcoat.pure.d.ts +37 -0
  78. package/glTF/2.0/Extensions/KHR_materials_clearcoat.pure.js +266 -0
  79. package/glTF/2.0/Extensions/KHR_materials_clearcoat.pure.js.map +1 -0
  80. package/glTF/2.0/Extensions/KHR_materials_coat.d.ts +3 -30
  81. package/glTF/2.0/Extensions/KHR_materials_coat.js +5 -380
  82. package/glTF/2.0/Extensions/KHR_materials_coat.js.map +1 -1
  83. package/glTF/2.0/Extensions/KHR_materials_coat.pure.d.ts +37 -0
  84. package/glTF/2.0/Extensions/KHR_materials_coat.pure.js +395 -0
  85. package/glTF/2.0/Extensions/KHR_materials_coat.pure.js.map +1 -0
  86. package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.d.ts +3 -22
  87. package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.js +5 -75
  88. package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.js.map +1 -1
  89. package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.pure.d.ts +29 -0
  90. package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.pure.js +90 -0
  91. package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.pure.js.map +1 -0
  92. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.d.ts +3 -38
  93. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js +5 -115
  94. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js.map +1 -1
  95. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.pure.d.ts +45 -0
  96. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.pure.js +130 -0
  97. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.pure.js.map +1 -0
  98. package/glTF/2.0/Extensions/KHR_materials_dispersion.d.ts +3 -29
  99. package/glTF/2.0/Extensions/KHR_materials_dispersion.js +5 -60
  100. package/glTF/2.0/Extensions/KHR_materials_dispersion.js.map +1 -1
  101. package/glTF/2.0/Extensions/KHR_materials_dispersion.pure.d.ts +36 -0
  102. package/glTF/2.0/Extensions/KHR_materials_dispersion.pure.js +75 -0
  103. package/glTF/2.0/Extensions/KHR_materials_dispersion.pure.js.map +1 -0
  104. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +3 -25
  105. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +5 -54
  106. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
  107. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.pure.d.ts +32 -0
  108. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.pure.js +69 -0
  109. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.pure.js.map +1 -0
  110. package/glTF/2.0/Extensions/KHR_materials_fuzz.d.ts +3 -30
  111. package/glTF/2.0/Extensions/KHR_materials_fuzz.js +5 -191
  112. package/glTF/2.0/Extensions/KHR_materials_fuzz.js.map +1 -1
  113. package/glTF/2.0/Extensions/KHR_materials_fuzz.pure.d.ts +37 -0
  114. package/glTF/2.0/Extensions/KHR_materials_fuzz.pure.js +206 -0
  115. package/glTF/2.0/Extensions/KHR_materials_fuzz.pure.js.map +1 -0
  116. package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +3 -27
  117. package/glTF/2.0/Extensions/KHR_materials_ior.js +5 -67
  118. package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
  119. package/glTF/2.0/Extensions/KHR_materials_ior.pure.d.ts +34 -0
  120. package/glTF/2.0/Extensions/KHR_materials_ior.pure.js +81 -0
  121. package/glTF/2.0/Extensions/KHR_materials_ior.pure.js.map +1 -0
  122. package/glTF/2.0/Extensions/KHR_materials_iridescence.d.ts +3 -22
  123. package/glTF/2.0/Extensions/KHR_materials_iridescence.js +5 -100
  124. package/glTF/2.0/Extensions/KHR_materials_iridescence.js.map +1 -1
  125. package/glTF/2.0/Extensions/KHR_materials_iridescence.pure.d.ts +29 -0
  126. package/glTF/2.0/Extensions/KHR_materials_iridescence.pure.js +115 -0
  127. package/glTF/2.0/Extensions/KHR_materials_iridescence.pure.js.map +1 -0
  128. package/glTF/2.0/Extensions/KHR_materials_openpbr.d.ts +3 -25
  129. package/glTF/2.0/Extensions/KHR_materials_openpbr.js +5 -41
  130. package/glTF/2.0/Extensions/KHR_materials_openpbr.js.map +1 -1
  131. package/glTF/2.0/Extensions/KHR_materials_openpbr.pure.d.ts +32 -0
  132. package/glTF/2.0/Extensions/KHR_materials_openpbr.pure.js +56 -0
  133. package/glTF/2.0/Extensions/KHR_materials_openpbr.pure.js.map +1 -0
  134. package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +3 -22
  135. package/glTF/2.0/Extensions/KHR_materials_sheen.js +5 -63
  136. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
  137. package/glTF/2.0/Extensions/KHR_materials_sheen.pure.d.ts +29 -0
  138. package/glTF/2.0/Extensions/KHR_materials_sheen.pure.js +78 -0
  139. package/glTF/2.0/Extensions/KHR_materials_sheen.pure.js.map +1 -0
  140. package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +3 -39
  141. package/glTF/2.0/Extensions/KHR_materials_specular.js +5 -123
  142. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
  143. package/glTF/2.0/Extensions/KHR_materials_specular.pure.d.ts +46 -0
  144. package/glTF/2.0/Extensions/KHR_materials_specular.pure.js +138 -0
  145. package/glTF/2.0/Extensions/KHR_materials_specular.pure.js.map +1 -0
  146. package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +3 -38
  147. package/glTF/2.0/Extensions/KHR_materials_transmission.js +5 -145
  148. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
  149. package/glTF/2.0/Extensions/KHR_materials_transmission.pure.d.ts +45 -0
  150. package/glTF/2.0/Extensions/KHR_materials_transmission.pure.js +160 -0
  151. package/glTF/2.0/Extensions/KHR_materials_transmission.pure.js.map +1 -0
  152. package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +3 -18
  153. package/glTF/2.0/Extensions/KHR_materials_unlit.js +5 -43
  154. package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
  155. package/glTF/2.0/Extensions/KHR_materials_unlit.pure.d.ts +25 -0
  156. package/glTF/2.0/Extensions/KHR_materials_unlit.pure.js +58 -0
  157. package/glTF/2.0/Extensions/KHR_materials_unlit.pure.js.map +1 -0
  158. package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +3 -38
  159. package/glTF/2.0/Extensions/KHR_materials_volume.js +5 -169
  160. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
  161. package/glTF/2.0/Extensions/KHR_materials_volume.pure.d.ts +45 -0
  162. package/glTF/2.0/Extensions/KHR_materials_volume.pure.js +184 -0
  163. package/glTF/2.0/Extensions/KHR_materials_volume.pure.js.map +1 -0
  164. package/glTF/2.0/Extensions/KHR_materials_volume_scatter.d.ts +3 -38
  165. package/glTF/2.0/Extensions/KHR_materials_volume_scatter.js +5 -130
  166. package/glTF/2.0/Extensions/KHR_materials_volume_scatter.js.map +1 -1
  167. package/glTF/2.0/Extensions/KHR_materials_volume_scatter.pure.d.ts +45 -0
  168. package/glTF/2.0/Extensions/KHR_materials_volume_scatter.pure.js +145 -0
  169. package/glTF/2.0/Extensions/KHR_materials_volume_scatter.pure.js.map +1 -0
  170. package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +3 -14
  171. package/glTF/2.0/Extensions/KHR_texture_basisu.js +5 -37
  172. package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
  173. package/glTF/2.0/Extensions/KHR_texture_basisu.pure.d.ts +26 -0
  174. package/glTF/2.0/Extensions/KHR_texture_basisu.pure.js +57 -0
  175. package/glTF/2.0/Extensions/KHR_texture_basisu.pure.js.map +1 -0
  176. package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +3 -19
  177. package/glTF/2.0/Extensions/KHR_texture_transform.js +5 -90
  178. package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
  179. package/glTF/2.0/Extensions/KHR_texture_transform.pure.d.ts +26 -0
  180. package/glTF/2.0/Extensions/KHR_texture_transform.pure.js +105 -0
  181. package/glTF/2.0/Extensions/KHR_texture_transform.pure.js.map +1 -0
  182. package/glTF/2.0/Extensions/pure.d.ts +26 -0
  183. package/glTF/2.0/Extensions/pure.js +27 -0
  184. package/glTF/2.0/Extensions/pure.js.map +1 -0
  185. package/glTF/2.0/pure.d.ts +5 -0
  186. package/glTF/2.0/pure.js +7 -0
  187. package/glTF/2.0/pure.js.map +1 -0
  188. package/glTF/pure.d.ts +3 -0
  189. package/glTF/pure.js +5 -0
  190. package/glTF/pure.js.map +1 -0
  191. package/package.json +3 -3
  192. package/pure.d.ts +7 -0
  193. package/pure.js +9 -0
  194. package/pure.js.map +1 -0
  195. package/stl/pure.d.ts +2 -0
  196. package/stl/pure.js +3 -0
  197. package/stl/pure.js.map +1 -0
@@ -1,39 +1,5 @@
1
- import { type Nullable } from "@onerjs/core/types.js";
2
- import { type Node } from "@onerjs/core/node.js";
3
- import { type INode } from "babylonjs-gltf2interface";
4
- import { type IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
5
- import { GLTFExporter } from "../glTFExporter.js";
6
1
  /**
7
- * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
2
+ * Re-exports the pure implementation and applies the runtime registration side effect.
3
+ * Import "./KHR_lights_punctual.pure" for tree-shakeable, side-effect-free usage.
8
4
  */
9
- export declare class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
10
- /** The name of this extension. */
11
- readonly name = "KHR_lights_punctual";
12
- /** Defines whether this extension is enabled. */
13
- enabled: boolean;
14
- /** Defines whether this extension is required */
15
- required: boolean;
16
- /** Reference to the glTF exporter */
17
- private _exporter;
18
- private _lights;
19
- /**
20
- * @internal
21
- */
22
- constructor(exporter: GLTFExporter);
23
- /** @internal */
24
- dispose(): void;
25
- /** @internal */
26
- get wasUsed(): boolean;
27
- /** @internal */
28
- onExporting(): void;
29
- /**
30
- * Define this method to modify the default behavior when exporting a node
31
- * @param context The context when exporting the node
32
- * @param node glTF node
33
- * @param babylonNode BabylonJS node
34
- * @param nodeMap Node mapping of babylon node to glTF node index
35
- * @param convertToRightHanded Flag to convert the values to right-handed
36
- * @returns nullable INode promise
37
- */
38
- postExportNodeAsync(context: string, node: INode, babylonNode: Node, nodeMap: Map<Node, number>, convertToRightHanded: boolean): Promise<Nullable<INode>>;
39
- }
5
+ export * from "./KHR_lights_punctual.pure.js";
@@ -1,145 +1,8 @@
1
- import { Vector3, Quaternion, TmpVectors } from "@onerjs/core/Maths/math.vector.js";
2
- import { Light } from "@onerjs/core/Lights/light.js";
3
- import { ShadowLight } from "@onerjs/core/Lights/shadowLight.js";
4
- import { GLTFExporter } from "../glTFExporter.js";
5
- import { Logger } from "@onerjs/core/Misc/logger.js";
6
- import { ConvertToRightHandedPosition, OmitDefaultValues, CollapseChildIntoParent, IsChildCollapsible } from "../glTFUtilities.js";
7
- const NAME = "KHR_lights_punctual";
8
- const DEFAULTS = {
9
- name: "",
10
- color: [1, 1, 1],
11
- intensity: 1,
12
- range: Number.MAX_VALUE,
13
- };
14
- const SPOTDEFAULTS = {
15
- innerConeAngle: 0,
16
- outerConeAngle: Math.PI / 4.0,
17
- };
18
- const LIGHTDIRECTION = Vector3.Backward();
19
1
  /**
20
- * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
2
+ * Re-exports the pure implementation and applies the runtime registration side effect.
3
+ * Import "./KHR_lights_punctual.pure" for tree-shakeable, side-effect-free usage.
21
4
  */
22
- // eslint-disable-next-line @typescript-eslint/naming-convention
23
- export class KHR_lights_punctual {
24
- /**
25
- * @internal
26
- */
27
- constructor(exporter) {
28
- /** The name of this extension. */
29
- this.name = NAME;
30
- /** Defines whether this extension is enabled. */
31
- this.enabled = true;
32
- /** Defines whether this extension is required */
33
- this.required = false;
34
- this._exporter = exporter;
35
- }
36
- /** @internal */
37
- dispose() {
38
- this._lights = null;
39
- }
40
- /** @internal */
41
- get wasUsed() {
42
- return !!this._lights;
43
- }
44
- /** @internal */
45
- onExporting() {
46
- this._exporter._glTF.extensions[NAME] = this._lights;
47
- }
48
- /**
49
- * Define this method to modify the default behavior when exporting a node
50
- * @param context The context when exporting the node
51
- * @param node glTF node
52
- * @param babylonNode BabylonJS node
53
- * @param nodeMap Node mapping of babylon node to glTF node index
54
- * @param convertToRightHanded Flag to convert the values to right-handed
55
- * @returns nullable INode promise
56
- */
57
- async postExportNodeAsync(context, node, babylonNode, nodeMap, convertToRightHanded) {
58
- return await new Promise((resolve) => {
59
- if (!(babylonNode instanceof Light)) {
60
- resolve(node);
61
- return;
62
- }
63
- const lightType = babylonNode.getTypeID() == Light.LIGHTTYPEID_POINTLIGHT
64
- ? "point" /* KHRLightsPunctual_LightType.POINT */
65
- : babylonNode.getTypeID() == Light.LIGHTTYPEID_DIRECTIONALLIGHT
66
- ? "directional" /* KHRLightsPunctual_LightType.DIRECTIONAL */
67
- : babylonNode.getTypeID() == Light.LIGHTTYPEID_SPOTLIGHT
68
- ? "spot" /* KHRLightsPunctual_LightType.SPOT */
69
- : null;
70
- if (!lightType || !(babylonNode instanceof ShadowLight)) {
71
- Logger.Warn(`${context}: Light ${babylonNode.name} is not supported in ${NAME}`);
72
- resolve(node);
73
- return;
74
- }
75
- if (babylonNode.falloffType !== Light.FALLOFF_GLTF) {
76
- Logger.Warn(`${context}: Light falloff for ${babylonNode.name} does not match the ${NAME} specification!`);
77
- }
78
- // Set the node's translation and rotation here, since lights are not handled in exportNodeAsync
79
- if (!babylonNode.position.equalsToFloats(0, 0, 0)) {
80
- const translation = TmpVectors.Vector3[0].copyFrom(babylonNode.position);
81
- if (convertToRightHanded) {
82
- ConvertToRightHandedPosition(translation);
83
- }
84
- node.translation = translation.asArray();
85
- }
86
- // Represent the Babylon light's direction as a quaternion
87
- // relative to glTF lights' forward direction, (0, 0, -1).
88
- if (lightType !== "point" /* KHRLightsPunctual_LightType.POINT */) {
89
- const direction = babylonNode.direction.normalizeToRef(TmpVectors.Vector3[0]);
90
- if (convertToRightHanded) {
91
- ConvertToRightHandedPosition(direction);
92
- }
93
- const lightRotationQuaternion = Quaternion.FromUnitVectorsToRef(LIGHTDIRECTION, direction, TmpVectors.Quaternion[0]);
94
- if (!Quaternion.IsIdentity(lightRotationQuaternion)) {
95
- node.rotation = lightRotationQuaternion.asArray();
96
- }
97
- }
98
- const light = {
99
- type: lightType,
100
- name: babylonNode.name,
101
- color: babylonNode.diffuse.asArray(),
102
- intensity: babylonNode.intensity,
103
- range: babylonNode.range,
104
- };
105
- OmitDefaultValues(light, DEFAULTS);
106
- // Separately handle the required 'spot' field for spot lights
107
- if (lightType === "spot" /* KHRLightsPunctual_LightType.SPOT */) {
108
- const babylonSpotLight = babylonNode;
109
- light.spot = {
110
- innerConeAngle: babylonSpotLight.innerAngle / 2.0,
111
- outerConeAngle: babylonSpotLight.angle / 2.0,
112
- };
113
- OmitDefaultValues(light.spot, SPOTDEFAULTS);
114
- }
115
- this._lights || (this._lights = {
116
- lights: [],
117
- });
118
- this._lights.lights.push(light);
119
- const lightReference = {
120
- light: this._lights.lights.length - 1,
121
- };
122
- // Assign the light to its parent node, if possible, to condense the glTF
123
- // Why and when: the glTF loader generates a new parent TransformNode for each light node, which we should undo on export
124
- const parentBabylonNode = babylonNode.parent;
125
- if (parentBabylonNode && IsChildCollapsible(babylonNode, parentBabylonNode)) {
126
- const parentNodeIndex = nodeMap.get(parentBabylonNode);
127
- if (parentNodeIndex) {
128
- // Combine the light's transformation with the parent's
129
- const parentNode = this._exporter._nodes[parentNodeIndex];
130
- CollapseChildIntoParent(node, parentNode);
131
- parentNode.extensions || (parentNode.extensions = {});
132
- parentNode.extensions[NAME] = lightReference;
133
- // Do not export the original node
134
- resolve(null);
135
- return;
136
- }
137
- }
138
- node.extensions || (node.extensions = {});
139
- node.extensions[NAME] = lightReference;
140
- resolve(node);
141
- });
142
- }
143
- }
144
- GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_lights_punctual(exporter));
5
+ export * from "./KHR_lights_punctual.pure.js";
6
+ import { RegisterKHR_lights_punctual } from "./KHR_lights_punctual.pure.js";
7
+ RegisterKHR_lights_punctual();
145
8
  //# sourceMappingURL=KHR_lights_punctual.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_lights_punctual.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_lights_punctual.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,C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AAC","sourcesContent":["import { type SpotLight } from \"core/Lights/spotLight\";\r\nimport { type Nullable } from \"core/types\";\r\nimport { Vector3, Quaternion, TmpVectors } from \"core/Maths/math.vector\";\r\nimport { Light } from \"core/Lights/light\";\r\nimport { type Node } from \"core/node\";\r\nimport { ShadowLight } from \"core/Lights/shadowLight\";\r\nimport { type INode, type IKHRLightsPunctual_LightReference, type IKHRLightsPunctual_Light, type IKHRLightsPunctual, KHRLightsPunctual_LightType } from \"babylonjs-gltf2interface\";\r\nimport { type IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { GLTFExporter } from \"../glTFExporter\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { ConvertToRightHandedPosition, OmitDefaultValues, CollapseChildIntoParent, IsChildCollapsible } from \"../glTFUtilities\";\r\n\r\nconst NAME = \"KHR_lights_punctual\";\r\nconst DEFAULTS: Omit<IKHRLightsPunctual_Light, \"type\"> = {\r\n name: \"\",\r\n color: [1, 1, 1],\r\n intensity: 1,\r\n range: Number.MAX_VALUE,\r\n};\r\nconst SPOTDEFAULTS: NonNullable<IKHRLightsPunctual_Light[\"spot\"]> = {\r\n innerConeAngle: 0,\r\n outerConeAngle: Math.PI / 4.0,\r\n};\r\nconst LIGHTDIRECTION = Vector3.Backward();\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_lights_punctual implements IGLTFExporterExtensionV2 {\r\n /** The name of this extension. */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled. */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n /** Reference to the glTF exporter */\r\n private _exporter: GLTFExporter;\r\n\r\n private _lights: IKHRLightsPunctual;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(exporter: GLTFExporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._lights as any) = null;\r\n }\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return !!this._lights;\r\n }\r\n\r\n /** @internal */\r\n public onExporting(): void {\r\n this._exporter._glTF.extensions![NAME] = this._lights;\r\n }\r\n /**\r\n * Define this method to modify the default behavior when exporting a node\r\n * @param context The context when exporting the node\r\n * @param node glTF node\r\n * @param babylonNode BabylonJS node\r\n * @param nodeMap Node mapping of babylon node to glTF node index\r\n * @param convertToRightHanded Flag to convert the values to right-handed\r\n * @returns nullable INode promise\r\n */\r\n public async postExportNodeAsync(context: string, node: INode, babylonNode: Node, nodeMap: Map<Node, number>, convertToRightHanded: boolean): Promise<Nullable<INode>> {\r\n return await new Promise((resolve) => {\r\n if (!(babylonNode instanceof Light)) {\r\n resolve(node);\r\n return;\r\n }\r\n\r\n const lightType =\r\n babylonNode.getTypeID() == Light.LIGHTTYPEID_POINTLIGHT\r\n ? KHRLightsPunctual_LightType.POINT\r\n : babylonNode.getTypeID() == Light.LIGHTTYPEID_DIRECTIONALLIGHT\r\n ? KHRLightsPunctual_LightType.DIRECTIONAL\r\n : babylonNode.getTypeID() == Light.LIGHTTYPEID_SPOTLIGHT\r\n ? KHRLightsPunctual_LightType.SPOT\r\n : null;\r\n if (!lightType || !(babylonNode instanceof ShadowLight)) {\r\n Logger.Warn(`${context}: Light ${babylonNode.name} is not supported in ${NAME}`);\r\n resolve(node);\r\n return;\r\n }\r\n\r\n if (babylonNode.falloffType !== Light.FALLOFF_GLTF) {\r\n Logger.Warn(`${context}: Light falloff for ${babylonNode.name} does not match the ${NAME} specification!`);\r\n }\r\n\r\n // Set the node's translation and rotation here, since lights are not handled in exportNodeAsync\r\n if (!babylonNode.position.equalsToFloats(0, 0, 0)) {\r\n const translation = TmpVectors.Vector3[0].copyFrom(babylonNode.position);\r\n if (convertToRightHanded) {\r\n ConvertToRightHandedPosition(translation);\r\n }\r\n node.translation = translation.asArray();\r\n }\r\n\r\n // Represent the Babylon light's direction as a quaternion\r\n // relative to glTF lights' forward direction, (0, 0, -1).\r\n if (lightType !== KHRLightsPunctual_LightType.POINT) {\r\n const direction = babylonNode.direction.normalizeToRef(TmpVectors.Vector3[0]);\r\n if (convertToRightHanded) {\r\n ConvertToRightHandedPosition(direction);\r\n }\r\n\r\n const lightRotationQuaternion = Quaternion.FromUnitVectorsToRef(LIGHTDIRECTION, direction, TmpVectors.Quaternion[0]);\r\n if (!Quaternion.IsIdentity(lightRotationQuaternion)) {\r\n node.rotation = lightRotationQuaternion.asArray();\r\n }\r\n }\r\n\r\n const light: IKHRLightsPunctual_Light = {\r\n type: lightType,\r\n name: babylonNode.name,\r\n color: babylonNode.diffuse.asArray(),\r\n intensity: babylonNode.intensity,\r\n range: babylonNode.range,\r\n };\r\n OmitDefaultValues(light, DEFAULTS);\r\n\r\n // Separately handle the required 'spot' field for spot lights\r\n if (lightType === KHRLightsPunctual_LightType.SPOT) {\r\n const babylonSpotLight = babylonNode as SpotLight;\r\n light.spot = {\r\n innerConeAngle: babylonSpotLight.innerAngle / 2.0,\r\n outerConeAngle: babylonSpotLight.angle / 2.0,\r\n };\r\n OmitDefaultValues(light.spot, SPOTDEFAULTS);\r\n }\r\n\r\n this._lights ||= {\r\n lights: [],\r\n };\r\n this._lights.lights.push(light);\r\n\r\n const lightReference: IKHRLightsPunctual_LightReference = {\r\n light: this._lights.lights.length - 1,\r\n };\r\n\r\n // Assign the light to its parent node, if possible, to condense the glTF\r\n // Why and when: the glTF loader generates a new parent TransformNode for each light node, which we should undo on export\r\n const parentBabylonNode = babylonNode.parent;\r\n\r\n if (parentBabylonNode && IsChildCollapsible(babylonNode, parentBabylonNode)) {\r\n const parentNodeIndex = nodeMap.get(parentBabylonNode);\r\n if (parentNodeIndex) {\r\n // Combine the light's transformation with the parent's\r\n const parentNode = this._exporter._nodes[parentNodeIndex];\r\n CollapseChildIntoParent(node, parentNode);\r\n parentNode.extensions ||= {};\r\n parentNode.extensions[NAME] = lightReference;\r\n\r\n // Do not export the original node\r\n resolve(null);\r\n return;\r\n }\r\n }\r\n\r\n node.extensions ||= {};\r\n node.extensions[NAME] = lightReference;\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\nGLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_lights_punctual(exporter));\r\n"]}
1
+ {"version":3,"file":"KHR_lights_punctual.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_lights_punctual.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,4BAA4B,CAAC;AAE3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,2BAA2B,EAAE,CAAC","sourcesContent":["/**\r\n * Re-exports the pure implementation and applies the runtime registration side effect.\r\n * Import \"./KHR_lights_punctual.pure\" for tree-shakeable, side-effect-free usage.\r\n */\r\nexport * from \"./KHR_lights_punctual.pure\";\r\n\r\nimport { RegisterKHR_lights_punctual } from \"./KHR_lights_punctual.pure\";\r\nRegisterKHR_lights_punctual();\r\n"]}
@@ -0,0 +1,44 @@
1
+ import { type Nullable } from "@onerjs/core/types.js";
2
+ import { type Node } from "@onerjs/core/node.js";
3
+ import { type INode } from "babylonjs-gltf2interface";
4
+ import { type IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
5
+ import { GLTFExporter } from "../glTFExporter.js";
6
+ /**
7
+ * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
8
+ */
9
+ export declare class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
10
+ /** The name of this extension. */
11
+ readonly name = "KHR_lights_punctual";
12
+ /** Defines whether this extension is enabled. */
13
+ enabled: boolean;
14
+ /** Defines whether this extension is required */
15
+ required: boolean;
16
+ /** Reference to the glTF exporter */
17
+ private _exporter;
18
+ private _lights;
19
+ /**
20
+ * @internal
21
+ */
22
+ constructor(exporter: GLTFExporter);
23
+ /** @internal */
24
+ dispose(): void;
25
+ /** @internal */
26
+ get wasUsed(): boolean;
27
+ /** @internal */
28
+ onExporting(): void;
29
+ /**
30
+ * Define this method to modify the default behavior when exporting a node
31
+ * @param context The context when exporting the node
32
+ * @param node glTF node
33
+ * @param babylonNode BabylonJS node
34
+ * @param nodeMap Node mapping of babylon node to glTF node index
35
+ * @param convertToRightHanded Flag to convert the values to right-handed
36
+ * @returns nullable INode promise
37
+ */
38
+ postExportNodeAsync(context: string, node: INode, babylonNode: Node, nodeMap: Map<Node, number>, convertToRightHanded: boolean): Promise<Nullable<INode>>;
39
+ }
40
+ /**
41
+ * Registers the KHR_lights_punctual glTF serializer extension with the {@link GLTFExporter}.
42
+ * Safe to call multiple times; only the first call has an effect.
43
+ */
44
+ export declare function RegisterKHR_lights_punctual(): void;
@@ -0,0 +1,157 @@
1
+ import { Vector3, Quaternion, TmpVectors } from "@onerjs/core/Maths/math.vector.pure.js";
2
+ import { Light } from "@onerjs/core/Lights/light.js";
3
+ import { ShadowLight } from "@onerjs/core/Lights/shadowLight.js";
4
+ import { GLTFExporter } from "../glTFExporter.js";
5
+ import { Logger } from "@onerjs/core/Misc/logger.js";
6
+ import { ConvertToRightHandedPosition, OmitDefaultValues, CollapseChildIntoParent, IsChildCollapsible } from "../glTFUtilities.js";
7
+ const NAME = "KHR_lights_punctual";
8
+ const DEFAULTS = {
9
+ name: "",
10
+ color: [1, 1, 1],
11
+ intensity: 1,
12
+ range: Number.MAX_VALUE,
13
+ };
14
+ const SPOTDEFAULTS = {
15
+ innerConeAngle: 0,
16
+ outerConeAngle: Math.PI / 4.0,
17
+ };
18
+ const LIGHTDIRECTION = /*#__PURE__*/ Vector3.Backward();
19
+ /**
20
+ * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
21
+ */
22
+ // eslint-disable-next-line @typescript-eslint/naming-convention
23
+ export class KHR_lights_punctual {
24
+ /**
25
+ * @internal
26
+ */
27
+ constructor(exporter) {
28
+ /** The name of this extension. */
29
+ this.name = NAME;
30
+ /** Defines whether this extension is enabled. */
31
+ this.enabled = true;
32
+ /** Defines whether this extension is required */
33
+ this.required = false;
34
+ this._exporter = exporter;
35
+ }
36
+ /** @internal */
37
+ dispose() {
38
+ this._lights = null;
39
+ }
40
+ /** @internal */
41
+ get wasUsed() {
42
+ return !!this._lights;
43
+ }
44
+ /** @internal */
45
+ onExporting() {
46
+ this._exporter._glTF.extensions[NAME] = this._lights;
47
+ }
48
+ /**
49
+ * Define this method to modify the default behavior when exporting a node
50
+ * @param context The context when exporting the node
51
+ * @param node glTF node
52
+ * @param babylonNode BabylonJS node
53
+ * @param nodeMap Node mapping of babylon node to glTF node index
54
+ * @param convertToRightHanded Flag to convert the values to right-handed
55
+ * @returns nullable INode promise
56
+ */
57
+ async postExportNodeAsync(context, node, babylonNode, nodeMap, convertToRightHanded) {
58
+ return await new Promise((resolve) => {
59
+ if (!(babylonNode instanceof Light)) {
60
+ resolve(node);
61
+ return;
62
+ }
63
+ const lightType = babylonNode.getTypeID() == Light.LIGHTTYPEID_POINTLIGHT
64
+ ? "point" /* KHRLightsPunctual_LightType.POINT */
65
+ : babylonNode.getTypeID() == Light.LIGHTTYPEID_DIRECTIONALLIGHT
66
+ ? "directional" /* KHRLightsPunctual_LightType.DIRECTIONAL */
67
+ : babylonNode.getTypeID() == Light.LIGHTTYPEID_SPOTLIGHT
68
+ ? "spot" /* KHRLightsPunctual_LightType.SPOT */
69
+ : null;
70
+ if (!lightType || !(babylonNode instanceof ShadowLight)) {
71
+ Logger.Warn(`${context}: Light ${babylonNode.name} is not supported in ${NAME}`);
72
+ resolve(node);
73
+ return;
74
+ }
75
+ if (babylonNode.falloffType !== Light.FALLOFF_GLTF) {
76
+ Logger.Warn(`${context}: Light falloff for ${babylonNode.name} does not match the ${NAME} specification!`);
77
+ }
78
+ // Set the node's translation and rotation here, since lights are not handled in exportNodeAsync
79
+ if (!babylonNode.position.equalsToFloats(0, 0, 0)) {
80
+ const translation = TmpVectors.Vector3[0].copyFrom(babylonNode.position);
81
+ if (convertToRightHanded) {
82
+ ConvertToRightHandedPosition(translation);
83
+ }
84
+ node.translation = translation.asArray();
85
+ }
86
+ // Represent the Babylon light's direction as a quaternion
87
+ // relative to glTF lights' forward direction, (0, 0, -1).
88
+ if (lightType !== "point" /* KHRLightsPunctual_LightType.POINT */) {
89
+ const direction = babylonNode.direction.normalizeToRef(TmpVectors.Vector3[0]);
90
+ if (convertToRightHanded) {
91
+ ConvertToRightHandedPosition(direction);
92
+ }
93
+ const lightRotationQuaternion = Quaternion.FromUnitVectorsToRef(LIGHTDIRECTION, direction, TmpVectors.Quaternion[0]);
94
+ if (!Quaternion.IsIdentity(lightRotationQuaternion)) {
95
+ node.rotation = lightRotationQuaternion.asArray();
96
+ }
97
+ }
98
+ const light = {
99
+ type: lightType,
100
+ name: babylonNode.name,
101
+ color: babylonNode.diffuse.asArray(),
102
+ intensity: babylonNode.intensity,
103
+ range: babylonNode.range,
104
+ };
105
+ OmitDefaultValues(light, DEFAULTS);
106
+ // Separately handle the required 'spot' field for spot lights
107
+ if (lightType === "spot" /* KHRLightsPunctual_LightType.SPOT */) {
108
+ const babylonSpotLight = babylonNode;
109
+ light.spot = {
110
+ innerConeAngle: babylonSpotLight.innerAngle / 2.0,
111
+ outerConeAngle: babylonSpotLight.angle / 2.0,
112
+ };
113
+ OmitDefaultValues(light.spot, SPOTDEFAULTS);
114
+ }
115
+ this._lights || (this._lights = {
116
+ lights: [],
117
+ });
118
+ this._lights.lights.push(light);
119
+ const lightReference = {
120
+ light: this._lights.lights.length - 1,
121
+ };
122
+ // Assign the light to its parent node, if possible, to condense the glTF
123
+ // Why and when: the glTF loader generates a new parent TransformNode for each light node, which we should undo on export
124
+ const parentBabylonNode = babylonNode.parent;
125
+ if (parentBabylonNode && IsChildCollapsible(babylonNode, parentBabylonNode)) {
126
+ const parentNodeIndex = nodeMap.get(parentBabylonNode);
127
+ if (parentNodeIndex) {
128
+ // Combine the light's transformation with the parent's
129
+ const parentNode = this._exporter._nodes[parentNodeIndex];
130
+ CollapseChildIntoParent(node, parentNode);
131
+ parentNode.extensions || (parentNode.extensions = {});
132
+ parentNode.extensions[NAME] = lightReference;
133
+ // Do not export the original node
134
+ resolve(null);
135
+ return;
136
+ }
137
+ }
138
+ node.extensions || (node.extensions = {});
139
+ node.extensions[NAME] = lightReference;
140
+ resolve(node);
141
+ });
142
+ }
143
+ }
144
+ let _Registered = false;
145
+ /**
146
+ * Registers the KHR_lights_punctual glTF serializer extension with the {@link GLTFExporter}.
147
+ * Safe to call multiple times; only the first call has an effect.
148
+ */
149
+ // eslint-disable-next-line @typescript-eslint/naming-convention
150
+ export function RegisterKHR_lights_punctual() {
151
+ if (_Registered) {
152
+ return;
153
+ }
154
+ _Registered = true;
155
+ GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_lights_punctual(exporter));
156
+ }
157
+ //# sourceMappingURL=KHR_lights_punctual.pure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KHR_lights_punctual.pure.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_lights_punctual.pure.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,4BAA4B,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEhI,MAAM,IAAI,GAAG,qBAAqB,CAAC;AACnC,MAAM,QAAQ,GAA2C;IACrD,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAA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iB,GAAG,WAAW,CAAC,MAAM,CAAC;YAE7C,IAAI,iBAAiB,IAAI,kBAAkB,CAAC,WAAW,EAAE,iBAAiB,CAAC,EAAE,CAAC;gBAC1E,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;gBACvD,IAAI,eAAe,EAAE,CAAC;oBAClB,uDAAuD;oBACvD,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;oBAC1D,uBAAuB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;oBAC1C,UAAU,CAAC,UAAU,KAArB,UAAU,CAAC,UAAU,GAAK,EAAE,EAAC;oBAC7B,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC;oBAE7C,kCAAkC;oBAClC,OAAO,CAAC,IAAI,CAAC,CAAC;oBACd,OAAO;gBACX,CAAC;YACL,CAAC;YAED,IAAI,CAAC,UAAU,KAAf,IAAI,CAAC,UAAU,GAAK,EAAE,EAAC;YACvB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,gEAAgE;AAChE,MAAM,UAAU,2BAA2B;IACvC,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,YAAY,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["import { type SpotLight } from \"core/Lights/spotLight\";\r\nimport { type Nullable } from \"core/types\";\r\nimport { Vector3, Quaternion, TmpVectors } from \"core/Maths/math.vector.pure\";\r\nimport { Light } from \"core/Lights/light\";\r\nimport { type Node } from \"core/node\";\r\nimport { ShadowLight } from \"core/Lights/shadowLight\";\r\nimport { type INode, type IKHRLightsPunctual_LightReference, type IKHRLightsPunctual_Light, type IKHRLightsPunctual, KHRLightsPunctual_LightType } from \"babylonjs-gltf2interface\";\r\nimport { type IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { GLTFExporter } from \"../glTFExporter\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { ConvertToRightHandedPosition, OmitDefaultValues, CollapseChildIntoParent, IsChildCollapsible } from \"../glTFUtilities\";\r\n\r\nconst NAME = \"KHR_lights_punctual\";\r\nconst DEFAULTS: Omit<IKHRLightsPunctual_Light, \"type\"> = {\r\n name: \"\",\r\n color: [1, 1, 1],\r\n intensity: 1,\r\n range: Number.MAX_VALUE,\r\n};\r\nconst SPOTDEFAULTS: NonNullable<IKHRLightsPunctual_Light[\"spot\"]> = {\r\n innerConeAngle: 0,\r\n outerConeAngle: Math.PI / 4.0,\r\n};\r\nconst LIGHTDIRECTION = /*#__PURE__*/ Vector3.Backward();\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_lights_punctual implements IGLTFExporterExtensionV2 {\r\n /** The name of this extension. */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled. */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n /** Reference to the glTF exporter */\r\n private _exporter: GLTFExporter;\r\n\r\n private _lights: IKHRLightsPunctual;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(exporter: GLTFExporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._lights as any) = null;\r\n }\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return !!this._lights;\r\n }\r\n\r\n /** @internal */\r\n public onExporting(): void {\r\n this._exporter._glTF.extensions![NAME] = this._lights;\r\n }\r\n /**\r\n * Define this method to modify the default behavior when exporting a node\r\n * @param context The context when exporting the node\r\n * @param node glTF node\r\n * @param babylonNode BabylonJS node\r\n * @param nodeMap Node mapping of babylon node to glTF node index\r\n * @param convertToRightHanded Flag to convert the values to right-handed\r\n * @returns nullable INode promise\r\n */\r\n public async postExportNodeAsync(context: string, node: INode, babylonNode: Node, nodeMap: Map<Node, number>, convertToRightHanded: boolean): Promise<Nullable<INode>> {\r\n return await new Promise((resolve) => {\r\n if (!(babylonNode instanceof Light)) {\r\n resolve(node);\r\n return;\r\n }\r\n\r\n const lightType =\r\n babylonNode.getTypeID() == Light.LIGHTTYPEID_POINTLIGHT\r\n ? KHRLightsPunctual_LightType.POINT\r\n : babylonNode.getTypeID() == Light.LIGHTTYPEID_DIRECTIONALLIGHT\r\n ? KHRLightsPunctual_LightType.DIRECTIONAL\r\n : babylonNode.getTypeID() == Light.LIGHTTYPEID_SPOTLIGHT\r\n ? KHRLightsPunctual_LightType.SPOT\r\n : null;\r\n if (!lightType || !(babylonNode instanceof ShadowLight)) {\r\n Logger.Warn(`${context}: Light ${babylonNode.name} is not supported in ${NAME}`);\r\n resolve(node);\r\n return;\r\n }\r\n\r\n if (babylonNode.falloffType !== Light.FALLOFF_GLTF) {\r\n Logger.Warn(`${context}: Light falloff for ${babylonNode.name} does not match the ${NAME} specification!`);\r\n }\r\n\r\n // Set the node's translation and rotation here, since lights are not handled in exportNodeAsync\r\n if (!babylonNode.position.equalsToFloats(0, 0, 0)) {\r\n const translation = TmpVectors.Vector3[0].copyFrom(babylonNode.position);\r\n if (convertToRightHanded) {\r\n ConvertToRightHandedPosition(translation);\r\n }\r\n node.translation = translation.asArray();\r\n }\r\n\r\n // Represent the Babylon light's direction as a quaternion\r\n // relative to glTF lights' forward direction, (0, 0, -1).\r\n if (lightType !== KHRLightsPunctual_LightType.POINT) {\r\n const direction = babylonNode.direction.normalizeToRef(TmpVectors.Vector3[0]);\r\n if (convertToRightHanded) {\r\n ConvertToRightHandedPosition(direction);\r\n }\r\n\r\n const lightRotationQuaternion = Quaternion.FromUnitVectorsToRef(LIGHTDIRECTION, direction, TmpVectors.Quaternion[0]);\r\n if (!Quaternion.IsIdentity(lightRotationQuaternion)) {\r\n node.rotation = lightRotationQuaternion.asArray();\r\n }\r\n }\r\n\r\n const light: IKHRLightsPunctual_Light = {\r\n type: lightType,\r\n name: babylonNode.name,\r\n color: babylonNode.diffuse.asArray(),\r\n intensity: babylonNode.intensity,\r\n range: babylonNode.range,\r\n };\r\n OmitDefaultValues(light, DEFAULTS);\r\n\r\n // Separately handle the required 'spot' field for spot lights\r\n if (lightType === KHRLightsPunctual_LightType.SPOT) {\r\n const babylonSpotLight = babylonNode as SpotLight;\r\n light.spot = {\r\n innerConeAngle: babylonSpotLight.innerAngle / 2.0,\r\n outerConeAngle: babylonSpotLight.angle / 2.0,\r\n };\r\n OmitDefaultValues(light.spot, SPOTDEFAULTS);\r\n }\r\n\r\n this._lights ||= {\r\n lights: [],\r\n };\r\n this._lights.lights.push(light);\r\n\r\n const lightReference: IKHRLightsPunctual_LightReference = {\r\n light: this._lights.lights.length - 1,\r\n };\r\n\r\n // Assign the light to its parent node, if possible, to condense the glTF\r\n // Why and when: the glTF loader generates a new parent TransformNode for each light node, which we should undo on export\r\n const parentBabylonNode = babylonNode.parent;\r\n\r\n if (parentBabylonNode && IsChildCollapsible(babylonNode, parentBabylonNode)) {\r\n const parentNodeIndex = nodeMap.get(parentBabylonNode);\r\n if (parentNodeIndex) {\r\n // Combine the light's transformation with the parent's\r\n const parentNode = this._exporter._nodes[parentNodeIndex];\r\n CollapseChildIntoParent(node, parentNode);\r\n parentNode.extensions ||= {};\r\n parentNode.extensions[NAME] = lightReference;\r\n\r\n // Do not export the original node\r\n resolve(null);\r\n return;\r\n }\r\n }\r\n\r\n node.extensions ||= {};\r\n node.extensions[NAME] = lightReference;\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Registers the KHR_lights_punctual glTF serializer extension with the {@link GLTFExporter}.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function RegisterKHR_lights_punctual(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_lights_punctual(exporter));\r\n}\r\n"]}
@@ -1,32 +1,5 @@
1
- import { type IMaterial } from "babylonjs-gltf2interface";
2
- import { type IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
3
- import { GLTFExporter } from "../glTFExporter.js";
4
- import { type Material } from "@onerjs/core/Materials/material.js";
5
- import { type BaseTexture } from "@onerjs/core/Materials/Textures/baseTexture.js";
6
1
  /**
7
- * @internal
2
+ * Re-exports the pure implementation and applies the runtime registration side effect.
3
+ * Import "./KHR_materials_anisotropy.pure" for tree-shakeable, side-effect-free usage.
8
4
  */
9
- export declare class KHR_materials_anisotropy implements IGLTFExporterExtensionV2 {
10
- /** Name of this extension */
11
- readonly name = "KHR_materials_anisotropy";
12
- /** Defines whether this extension is enabled */
13
- enabled: boolean;
14
- /** Defines whether this extension is required */
15
- required: boolean;
16
- private _exporter;
17
- private _wasUsed;
18
- private _anisoTexturesMap;
19
- constructor(exporter: GLTFExporter);
20
- dispose(): void;
21
- /** @internal */
22
- get wasUsed(): boolean;
23
- /**
24
- * After exporting a material, deal with the additional textures
25
- * @param context GLTF context of the material
26
- * @param node exported GLTF node
27
- * @param babylonMaterial corresponding babylon material
28
- * @returns array of additional textures to export
29
- */
30
- postExportMaterialAdditionalTexturesAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]>;
31
- postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
32
- }
5
+ export * from "./KHR_materials_anisotropy.pure.js";