@babylonjs/loaders 5.0.0-beta.6 → 5.0.0-beta.8-snapshot

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. package/package.json +20 -198
  2. package/OBJ/index.d.ts +0 -4
  3. package/OBJ/index.js +0 -5
  4. package/OBJ/index.js.map +0 -1
  5. package/OBJ/mtlFileLoader.d.ts +0 -40
  6. package/OBJ/mtlFileLoader.js +0 -222
  7. package/OBJ/mtlFileLoader.js.map +0 -1
  8. package/OBJ/objFileLoader.d.ts +0 -133
  9. package/OBJ/objFileLoader.js +0 -301
  10. package/OBJ/objFileLoader.js.map +0 -1
  11. package/OBJ/objLoadingOptions.d.ts +0 -43
  12. package/OBJ/objLoadingOptions.js +0 -2
  13. package/OBJ/objLoadingOptions.js.map +0 -1
  14. package/OBJ/solidParser.d.ts +0 -153
  15. package/OBJ/solidParser.js +0 -700
  16. package/OBJ/solidParser.js.map +0 -1
  17. package/STL/index.d.ts +0 -1
  18. package/STL/index.js +0 -2
  19. package/STL/index.js.map +0 -1
  20. package/STL/stlFileLoader.d.ts +0 -71
  21. package/STL/stlFileLoader.js +0 -240
  22. package/STL/stlFileLoader.js.map +0 -1
  23. package/glTF/1.0/glTFBinaryExtension.d.ts +0 -13
  24. package/glTF/1.0/glTFBinaryExtension.js +0 -62
  25. package/glTF/1.0/glTFBinaryExtension.js.map +0 -1
  26. package/glTF/1.0/glTFLoader.d.ts +0 -106
  27. package/glTF/1.0/glTFLoader.js +0 -1697
  28. package/glTF/1.0/glTFLoader.js.map +0 -1
  29. package/glTF/1.0/glTFLoaderInterfaces.d.ts +0 -412
  30. package/glTF/1.0/glTFLoaderInterfaces.js +0 -96
  31. package/glTF/1.0/glTFLoaderInterfaces.js.map +0 -1
  32. package/glTF/1.0/glTFLoaderUtils.d.ts +0 -62
  33. package/glTF/1.0/glTFLoaderUtils.js +0 -233
  34. package/glTF/1.0/glTFLoaderUtils.js.map +0 -1
  35. package/glTF/1.0/glTFMaterialsCommonExtension.d.ts +0 -10
  36. package/glTF/1.0/glTFMaterialsCommonExtension.js +0 -128
  37. package/glTF/1.0/glTFMaterialsCommonExtension.js.map +0 -1
  38. package/glTF/1.0/index.d.ts +0 -5
  39. package/glTF/1.0/index.js +0 -6
  40. package/glTF/1.0/index.js.map +0 -1
  41. package/glTF/2.0/Extensions/EXT_lights_image_based.d.ts +0 -36
  42. package/glTF/2.0/Extensions/EXT_lights_image_based.js +0 -111
  43. package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +0 -1
  44. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +0 -27
  45. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +0 -80
  46. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +0 -1
  47. package/glTF/2.0/Extensions/EXT_meshopt_compression.d.ts +0 -27
  48. package/glTF/2.0/Extensions/EXT_meshopt_compression.js +0 -43
  49. package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +0 -1
  50. package/glTF/2.0/Extensions/EXT_texture_webp.d.ts +0 -21
  51. package/glTF/2.0/Extensions/EXT_texture_webp.js +0 -33
  52. package/glTF/2.0/Extensions/EXT_texture_webp.js.map +0 -1
  53. package/glTF/2.0/Extensions/ExtrasAsMetadata.d.ts +0 -32
  54. package/glTF/2.0/Extensions/ExtrasAsMetadata.js +0 -56
  55. package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +0 -1
  56. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.d.ts +0 -31
  57. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +0 -102
  58. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +0 -1
  59. package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +0 -28
  60. package/glTF/2.0/Extensions/KHR_lights_punctual.js +0 -82
  61. package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +0 -1
  62. package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +0 -31
  63. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +0 -87
  64. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +0 -1
  65. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +0 -30
  66. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +0 -46
  67. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +0 -1
  68. package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +0 -34
  69. package/glTF/2.0/Extensions/KHR_materials_ior.js +0 -55
  70. package/glTF/2.0/Extensions/KHR_materials_ior.js.map +0 -1
  71. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.d.ts +0 -30
  72. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +0 -73
  73. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +0 -1
  74. package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +0 -31
  75. package/glTF/2.0/Extensions/KHR_materials_sheen.js +0 -77
  76. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +0 -1
  77. package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +0 -30
  78. package/glTF/2.0/Extensions/KHR_materials_specular.js +0 -67
  79. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +0 -1
  80. package/glTF/2.0/Extensions/KHR_materials_translucency.d.ts +0 -31
  81. package/glTF/2.0/Extensions/KHR_materials_translucency.js +0 -77
  82. package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +0 -1
  83. package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +0 -30
  84. package/glTF/2.0/Extensions/KHR_materials_transmission.js +0 -278
  85. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +0 -1
  86. package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +0 -30
  87. package/glTF/2.0/Extensions/KHR_materials_unlit.js +0 -66
  88. package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +0 -1
  89. package/glTF/2.0/Extensions/KHR_materials_variants.d.ts +0 -76
  90. package/glTF/2.0/Extensions/KHR_materials_variants.js +0 -244
  91. package/glTF/2.0/Extensions/KHR_materials_variants.js.map +0 -1
  92. package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +0 -31
  93. package/glTF/2.0/Extensions/KHR_materials_volume.js +0 -79
  94. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +0 -1
  95. package/glTF/2.0/Extensions/KHR_mesh_quantization.d.ts +0 -19
  96. package/glTF/2.0/Extensions/KHR_mesh_quantization.js +0 -22
  97. package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +0 -1
  98. package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +0 -21
  99. package/glTF/2.0/Extensions/KHR_texture_basisu.js +0 -33
  100. package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +0 -1
  101. package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +0 -25
  102. package/glTF/2.0/Extensions/KHR_texture_transform.js +0 -54
  103. package/glTF/2.0/Extensions/KHR_texture_transform.js.map +0 -1
  104. package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +0 -29
  105. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +0 -47
  106. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +0 -1
  107. package/glTF/2.0/Extensions/MSFT_audio_emitter.d.ts +0 -38
  108. package/glTF/2.0/Extensions/MSFT_audio_emitter.js +0 -217
  109. package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +0 -1
  110. package/glTF/2.0/Extensions/MSFT_lod.d.ts +0 -75
  111. package/glTF/2.0/Extensions/MSFT_lod.js +0 -334
  112. package/glTF/2.0/Extensions/MSFT_lod.js.map +0 -1
  113. package/glTF/2.0/Extensions/MSFT_minecraftMesh.d.ts +0 -14
  114. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +0 -37
  115. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +0 -1
  116. package/glTF/2.0/Extensions/MSFT_sRGBFactors.d.ts +0 -14
  117. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +0 -37
  118. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +0 -1
  119. package/glTF/2.0/Extensions/index.d.ts +0 -26
  120. package/glTF/2.0/Extensions/index.js +0 -27
  121. package/glTF/2.0/Extensions/index.js.map +0 -1
  122. package/glTF/2.0/glTFLoader.d.ts +0 -355
  123. package/glTF/2.0/glTFLoader.js +0 -2184
  124. package/glTF/2.0/glTFLoader.js.map +0 -1
  125. package/glTF/2.0/glTFLoaderExtension.d.ts +0 -152
  126. package/glTF/2.0/glTFLoaderExtension.js +0 -2
  127. package/glTF/2.0/glTFLoaderExtension.js.map +0 -1
  128. package/glTF/2.0/glTFLoaderInterfaces.d.ts +0 -212
  129. package/glTF/2.0/glTFLoaderInterfaces.js +0 -2
  130. package/glTF/2.0/glTFLoaderInterfaces.js.map +0 -1
  131. package/glTF/2.0/index.d.ts +0 -4
  132. package/glTF/2.0/index.js +0 -5
  133. package/glTF/2.0/index.js.map +0 -1
  134. package/glTF/glTFFileLoader.d.ts +0 -364
  135. package/glTF/glTFFileLoader.js +0 -865
  136. package/glTF/glTFFileLoader.js.map +0 -1
  137. package/glTF/glTFValidation.d.ts +0 -29
  138. package/glTF/glTFValidation.js +0 -122
  139. package/glTF/glTFValidation.js.map +0 -1
  140. package/glTF/index.d.ts +0 -5
  141. package/glTF/index.js +0 -6
  142. package/glTF/index.js.map +0 -1
  143. package/index.d.ts +0 -3
  144. package/index.js.map +0 -1
  145. package/legacy/legacy-glTF.d.ts +0 -2
  146. package/legacy/legacy-glTF.js +0 -19
  147. package/legacy/legacy-glTF.js.map +0 -1
  148. package/legacy/legacy-glTF1.d.ts +0 -2
  149. package/legacy/legacy-glTF1.js +0 -15
  150. package/legacy/legacy-glTF1.js.map +0 -1
  151. package/legacy/legacy-glTF1FileLoader.d.ts +0 -2
  152. package/legacy/legacy-glTF1FileLoader.js +0 -3
  153. package/legacy/legacy-glTF1FileLoader.js.map +0 -1
  154. package/legacy/legacy-glTF2.d.ts +0 -2
  155. package/legacy/legacy-glTF2.js +0 -33
  156. package/legacy/legacy-glTF2.js.map +0 -1
  157. package/legacy/legacy-glTF2FileLoader.d.ts +0 -2
  158. package/legacy/legacy-glTF2FileLoader.js +0 -3
  159. package/legacy/legacy-glTF2FileLoader.js.map +0 -1
  160. package/legacy/legacy-glTFFileLoader.d.ts +0 -3
  161. package/legacy/legacy-glTFFileLoader.js +0 -4
  162. package/legacy/legacy-glTFFileLoader.js.map +0 -1
  163. package/legacy/legacy-objFileLoader.d.ts +0 -1
  164. package/legacy/legacy-objFileLoader.js +0 -13
  165. package/legacy/legacy-objFileLoader.js.map +0 -1
  166. package/legacy/legacy-stlFileLoader.d.ts +0 -1
  167. package/legacy/legacy-stlFileLoader.js +0 -13
  168. package/legacy/legacy-stlFileLoader.js.map +0 -1
  169. package/legacy/legacy.d.ts +0 -6
  170. package/legacy/legacy.js +0 -7
  171. package/legacy/legacy.js.map +0 -1
  172. package/readme.md +0 -24
@@ -1,217 +0,0 @@
1
- import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
2
- import { Tools } from "@babylonjs/core/Misc/tools.js";
3
- import { AnimationEvent } from "@babylonjs/core/Animations/animationEvent.js";
4
- import { Sound } from "@babylonjs/core/Audio/sound.js";
5
- import { WeightedSound } from "@babylonjs/core/Audio/weightedsound.js";
6
- import { GLTFLoader, ArrayItem } from "../glTFLoader.js";
7
- var NAME = "MSFT_audio_emitter";
8
- /**
9
- * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
10
- */
11
- var MSFT_audio_emitter = /** @class */ (function () {
12
- /** @hidden */
13
- function MSFT_audio_emitter(loader) {
14
- /**
15
- * The name of this extension.
16
- */
17
- this.name = NAME;
18
- this._loader = loader;
19
- this.enabled = this._loader.isExtensionUsed(NAME);
20
- }
21
- /** @hidden */
22
- MSFT_audio_emitter.prototype.dispose = function () {
23
- this._loader = null;
24
- this._clips = null;
25
- this._emitters = null;
26
- };
27
- /** @hidden */
28
- MSFT_audio_emitter.prototype.onLoading = function () {
29
- var extensions = this._loader.gltf.extensions;
30
- if (extensions && extensions[this.name]) {
31
- var extension = extensions[this.name];
32
- this._clips = extension.clips;
33
- this._emitters = extension.emitters;
34
- ArrayItem.Assign(this._clips);
35
- ArrayItem.Assign(this._emitters);
36
- }
37
- };
38
- /** @hidden */
39
- MSFT_audio_emitter.prototype.loadSceneAsync = function (context, scene) {
40
- var _this = this;
41
- return GLTFLoader.LoadExtensionAsync(context, scene, this.name, function (extensionContext, extension) {
42
- var promises = new Array();
43
- promises.push(_this._loader.loadSceneAsync(context, scene));
44
- for (var _i = 0, _a = extension.emitters; _i < _a.length; _i++) {
45
- var emitterIndex = _a[_i];
46
- var emitter = ArrayItem.Get("".concat(extensionContext, "/emitters"), _this._emitters, emitterIndex);
47
- if (emitter.refDistance != undefined || emitter.maxDistance != undefined || emitter.rolloffFactor != undefined ||
48
- emitter.distanceModel != undefined || emitter.innerAngle != undefined || emitter.outerAngle != undefined) {
49
- throw new Error("".concat(extensionContext, ": Direction or Distance properties are not allowed on emitters attached to a scene"));
50
- }
51
- promises.push(_this._loadEmitterAsync("".concat(extensionContext, "/emitters/").concat(emitter.index), emitter));
52
- }
53
- return Promise.all(promises).then(function () { });
54
- });
55
- };
56
- /** @hidden */
57
- MSFT_audio_emitter.prototype.loadNodeAsync = function (context, node, assign) {
58
- var _this = this;
59
- return GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) {
60
- var promises = new Array();
61
- return _this._loader.loadNodeAsync(extensionContext, node, function (babylonMesh) {
62
- var _loop_1 = function (emitterIndex) {
63
- var emitter = ArrayItem.Get("".concat(extensionContext, "/emitters"), _this._emitters, emitterIndex);
64
- promises.push(_this._loadEmitterAsync("".concat(extensionContext, "/emitters/").concat(emitter.index), emitter).then(function () {
65
- for (var _i = 0, _a = emitter._babylonSounds; _i < _a.length; _i++) {
66
- var sound = _a[_i];
67
- sound.attachToMesh(babylonMesh);
68
- if (emitter.innerAngle != undefined || emitter.outerAngle != undefined) {
69
- sound.setLocalDirectionToMesh(Vector3.Forward());
70
- sound.setDirectionalCone(2 * Tools.ToDegrees(emitter.innerAngle == undefined ? Math.PI : emitter.innerAngle), 2 * Tools.ToDegrees(emitter.outerAngle == undefined ? Math.PI : emitter.outerAngle), 0);
71
- }
72
- }
73
- }));
74
- };
75
- for (var _i = 0, _a = extension.emitters; _i < _a.length; _i++) {
76
- var emitterIndex = _a[_i];
77
- _loop_1(emitterIndex);
78
- }
79
- assign(babylonMesh);
80
- }).then(function (babylonMesh) {
81
- return Promise.all(promises).then(function () {
82
- return babylonMesh;
83
- });
84
- });
85
- });
86
- };
87
- /** @hidden */
88
- MSFT_audio_emitter.prototype.loadAnimationAsync = function (context, animation) {
89
- var _this = this;
90
- return GLTFLoader.LoadExtensionAsync(context, animation, this.name, function (extensionContext, extension) {
91
- return _this._loader.loadAnimationAsync(context, animation).then(function (babylonAnimationGroup) {
92
- var promises = new Array();
93
- ArrayItem.Assign(extension.events);
94
- for (var _i = 0, _a = extension.events; _i < _a.length; _i++) {
95
- var event_1 = _a[_i];
96
- promises.push(_this._loadAnimationEventAsync("".concat(extensionContext, "/events/").concat(event_1.index), context, animation, event_1, babylonAnimationGroup));
97
- }
98
- return Promise.all(promises).then(function () {
99
- return babylonAnimationGroup;
100
- });
101
- });
102
- });
103
- };
104
- MSFT_audio_emitter.prototype._loadClipAsync = function (context, clip) {
105
- if (clip._objectURL) {
106
- return clip._objectURL;
107
- }
108
- var promise;
109
- if (clip.uri) {
110
- promise = this._loader.loadUriAsync(context, clip, clip.uri);
111
- }
112
- else {
113
- var bufferView = ArrayItem.Get("".concat(context, "/bufferView"), this._loader.gltf.bufferViews, clip.bufferView);
114
- promise = this._loader.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView);
115
- }
116
- clip._objectURL = promise.then(function (data) {
117
- return URL.createObjectURL(new Blob([data], { type: clip.mimeType }));
118
- });
119
- return clip._objectURL;
120
- };
121
- MSFT_audio_emitter.prototype._loadEmitterAsync = function (context, emitter) {
122
- var _this = this;
123
- emitter._babylonSounds = emitter._babylonSounds || [];
124
- if (!emitter._babylonData) {
125
- var clipPromises = new Array();
126
- var name_1 = emitter.name || "emitter".concat(emitter.index);
127
- var options_1 = {
128
- loop: false,
129
- autoplay: false,
130
- volume: emitter.volume == undefined ? 1 : emitter.volume,
131
- };
132
- var _loop_2 = function (i) {
133
- var clipContext = "/extensions/".concat(this_1.name, "/clips");
134
- var clip = ArrayItem.Get(clipContext, this_1._clips, emitter.clips[i].clip);
135
- clipPromises.push(this_1._loadClipAsync("".concat(clipContext, "/").concat(emitter.clips[i].clip), clip).then(function (objectURL) {
136
- var sound = emitter._babylonSounds[i] = new Sound(name_1, objectURL, _this._loader.babylonScene, null, options_1);
137
- sound.refDistance = emitter.refDistance || 1;
138
- sound.maxDistance = emitter.maxDistance || 256;
139
- sound.rolloffFactor = emitter.rolloffFactor || 1;
140
- sound.distanceModel = emitter.distanceModel || 'exponential';
141
- }));
142
- };
143
- var this_1 = this;
144
- for (var i = 0; i < emitter.clips.length; i++) {
145
- _loop_2(i);
146
- }
147
- var promise = Promise.all(clipPromises).then(function () {
148
- var weights = emitter.clips.map(function (clip) { return clip.weight || 1; });
149
- var weightedSound = new WeightedSound(emitter.loop || false, emitter._babylonSounds, weights);
150
- if (emitter.innerAngle) {
151
- weightedSound.directionalConeInnerAngle = 2 * Tools.ToDegrees(emitter.innerAngle);
152
- }
153
- if (emitter.outerAngle) {
154
- weightedSound.directionalConeOuterAngle = 2 * Tools.ToDegrees(emitter.outerAngle);
155
- }
156
- if (emitter.volume) {
157
- weightedSound.volume = emitter.volume;
158
- }
159
- emitter._babylonData.sound = weightedSound;
160
- });
161
- emitter._babylonData = {
162
- loaded: promise
163
- };
164
- }
165
- return emitter._babylonData.loaded;
166
- };
167
- MSFT_audio_emitter.prototype._getEventAction = function (context, sound, action, time, startOffset) {
168
- switch (action) {
169
- case "play" /* play */: {
170
- return function (currentFrame) {
171
- var frameOffset = (startOffset || 0) + (currentFrame - time);
172
- sound.play(frameOffset);
173
- };
174
- }
175
- case "stop" /* stop */: {
176
- return function (currentFrame) {
177
- sound.stop();
178
- };
179
- }
180
- case "pause" /* pause */: {
181
- return function (currentFrame) {
182
- sound.pause();
183
- };
184
- }
185
- default: {
186
- throw new Error("".concat(context, ": Unsupported action ").concat(action));
187
- }
188
- }
189
- };
190
- MSFT_audio_emitter.prototype._loadAnimationEventAsync = function (context, animationContext, animation, event, babylonAnimationGroup) {
191
- var _this = this;
192
- if (babylonAnimationGroup.targetedAnimations.length == 0) {
193
- return Promise.resolve();
194
- }
195
- var babylonAnimation = babylonAnimationGroup.targetedAnimations[0];
196
- var emitterIndex = event.emitter;
197
- var emitter = ArrayItem.Get("/extensions/".concat(this.name, "/emitters"), this._emitters, emitterIndex);
198
- return this._loadEmitterAsync(context, emitter).then(function () {
199
- var sound = emitter._babylonData.sound;
200
- if (sound) {
201
- var babylonAnimationEvent = new AnimationEvent(event.time, _this._getEventAction(context, sound, event.action, event.time, event.startOffset));
202
- babylonAnimation.animation.addEvent(babylonAnimationEvent);
203
- // Make sure all started audio stops when this animation is terminated.
204
- babylonAnimationGroup.onAnimationGroupEndObservable.add(function () {
205
- sound.stop();
206
- });
207
- babylonAnimationGroup.onAnimationGroupPauseObservable.add(function () {
208
- sound.pause();
209
- });
210
- }
211
- });
212
- };
213
- return MSFT_audio_emitter;
214
- }());
215
- export { MSFT_audio_emitter };
216
- GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_audio_emitter(loader); });
217
- //# sourceMappingURL=MSFT_audio_emitter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MSFT_audio_emitter.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,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B,CAAC,6BAA6B,CAAC,GAAG,CAAC;oBACpD,KAAK,CAAC,IAAI,EAAE,CAAC;gBACjB,CAAC,CAAC,CAAC;gBACH,qBAAqB,CAAC,+BAA+B,CAAC,GAAG,CAAC;oBACtD,KAAK,CAAC,KAAK,EAAE,CAAC;gBAClB,CAAC,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IACL,yBAAC;AAAD,CAAC,AA3ND,IA2NC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,kBAAkB,CAAC,MAAM,CAAC,EAA9B,CAA8B,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { Vector3 } from \"@babylonjs/core/Maths/math.vector\";\nimport { Tools } from \"@babylonjs/core/Misc/tools\";\nimport { AnimationGroup } from \"@babylonjs/core/Animations/animationGroup\";\nimport { AnimationEvent } from \"@babylonjs/core/Animations/animationEvent\";\nimport { TransformNode } from \"@babylonjs/core/Meshes/transformNode\";\nimport { Sound } from \"@babylonjs/core/Audio/sound\";\nimport { WeightedSound } from \"@babylonjs/core/Audio/weightedsound\";\n\nimport { IArrayItem, IScene, INode, IAnimation } from \"../glTFLoaderInterfaces\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\nimport { IMSFTAudioEmitter_Clip, IMSFTAudioEmitter_Emitter, IMSFTAudioEmitter_EmittersReference, IMSFTAudioEmitter_AnimationEvent, IMSFTAudioEmitter_AnimationEventAction } from 'babylonjs-gltf2interface';\n\nconst NAME = \"MSFT_audio_emitter\";\n\ninterface ILoaderClip extends IMSFTAudioEmitter_Clip, IArrayItem {\n _objectURL?: Promise<string>;\n}\n\ninterface ILoaderEmitter extends IMSFTAudioEmitter_Emitter, IArrayItem {\n _babylonData?: {\n sound?: WeightedSound;\n loaded: Promise<void>;\n };\n _babylonSounds: Sound[];\n}\n\ninterface IMSFTAudioEmitter {\n clips: ILoaderClip[];\n emitters: ILoaderEmitter[];\n}\n\ninterface ILoaderAnimationEvent extends IMSFTAudioEmitter_AnimationEvent, IArrayItem {\n}\n\ninterface ILoaderAnimationEvents {\n events: ILoaderAnimationEvent[];\n}\n\n/**\n * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)\n */\nexport class MSFT_audio_emitter implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n private _loader: GLTFLoader;\n private _clips: Array<ILoaderClip>;\n private _emitters: Array<ILoaderEmitter>;\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n (this._clips as any) = null;\n (this._emitters as any) = null;\n }\n\n /** @hidden */\n public onLoading(): void {\n const extensions = this._loader.gltf.extensions;\n if (extensions && extensions[this.name]) {\n const extension = extensions[this.name] as IMSFTAudioEmitter;\n\n this._clips = extension.clips;\n this._emitters = extension.emitters;\n\n ArrayItem.Assign(this._clips);\n ArrayItem.Assign(this._emitters);\n }\n }\n\n /** @hidden */\n public loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>> {\n return GLTFLoader.LoadExtensionAsync<IMSFTAudioEmitter_EmittersReference>(context, scene, this.name, (extensionContext, extension) => {\n const promises = new Array<Promise<any>>();\n\n promises.push(this._loader.loadSceneAsync(context, scene));\n\n for (const emitterIndex of extension.emitters) {\n const emitter = ArrayItem.Get(`${extensionContext}/emitters`, this._emitters, emitterIndex);\n if (emitter.refDistance != undefined || emitter.maxDistance != undefined || emitter.rolloffFactor != undefined ||\n emitter.distanceModel != undefined || emitter.innerAngle != undefined || emitter.outerAngle != undefined) {\n throw new Error(`${extensionContext}: Direction or Distance properties are not allowed on emitters attached to a scene`);\n }\n\n promises.push(this._loadEmitterAsync(`${extensionContext}/emitters/${emitter.index}`, emitter));\n }\n\n return Promise.all(promises).then(() => { });\n });\n }\n\n /** @hidden */\n public loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>> {\n return GLTFLoader.LoadExtensionAsync<IMSFTAudioEmitter_EmittersReference, TransformNode>(context, node, this.name, (extensionContext, extension) => {\n const promises = new Array<Promise<any>>();\n\n return this._loader.loadNodeAsync(extensionContext, node, (babylonMesh) => {\n for (const emitterIndex of extension.emitters) {\n const emitter = ArrayItem.Get(`${extensionContext}/emitters`, this._emitters, emitterIndex);\n promises.push(this._loadEmitterAsync(`${extensionContext}/emitters/${emitter.index}`, emitter).then(() => {\n for (const sound of emitter._babylonSounds) {\n sound.attachToMesh(babylonMesh);\n if (emitter.innerAngle != undefined || emitter.outerAngle != undefined) {\n sound.setLocalDirectionToMesh(Vector3.Forward());\n sound.setDirectionalCone(\n 2 * Tools.ToDegrees(emitter.innerAngle == undefined ? Math.PI : emitter.innerAngle),\n 2 * Tools.ToDegrees(emitter.outerAngle == undefined ? Math.PI : emitter.outerAngle),\n 0);\n }\n }\n }));\n }\n\n assign(babylonMesh);\n }).then((babylonMesh) => {\n return Promise.all(promises).then(() => {\n return babylonMesh;\n });\n });\n });\n }\n\n /** @hidden */\n public loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>> {\n return GLTFLoader.LoadExtensionAsync<ILoaderAnimationEvents, AnimationGroup>(context, animation, this.name, (extensionContext, extension) => {\n return this._loader.loadAnimationAsync(context, animation).then((babylonAnimationGroup) => {\n const promises = new Array<Promise<any>>();\n\n ArrayItem.Assign(extension.events);\n for (const event of extension.events) {\n promises.push(this._loadAnimationEventAsync(`${extensionContext}/events/${event.index}`, context, animation, event, babylonAnimationGroup));\n }\n\n return Promise.all(promises).then(() => {\n return babylonAnimationGroup;\n });\n });\n });\n }\n\n private _loadClipAsync(context: string, clip: ILoaderClip): Promise<string> {\n if (clip._objectURL) {\n return clip._objectURL;\n }\n\n let promise: Promise<ArrayBufferView>;\n if (clip.uri) {\n promise = this._loader.loadUriAsync(context, clip, clip.uri);\n }\n else {\n const bufferView = ArrayItem.Get(`${context}/bufferView`, this._loader.gltf.bufferViews, clip.bufferView);\n promise = this._loader.loadBufferViewAsync(`/bufferViews/${bufferView.index}`, bufferView);\n }\n\n clip._objectURL = promise.then((data) => {\n return URL.createObjectURL(new Blob([data], { type: clip.mimeType }));\n });\n\n return clip._objectURL;\n }\n\n private _loadEmitterAsync(context: string, emitter: ILoaderEmitter): Promise<void> {\n emitter._babylonSounds = emitter._babylonSounds || [];\n if (!emitter._babylonData) {\n const clipPromises = new Array<Promise<any>>();\n const name = emitter.name || `emitter${emitter.index}`;\n const options = {\n loop: false,\n autoplay: false,\n volume: emitter.volume == undefined ? 1 : emitter.volume,\n };\n\n for (let i = 0; i < emitter.clips.length; i++) {\n const clipContext = `/extensions/${this.name}/clips`;\n const clip = ArrayItem.Get(clipContext, this._clips, emitter.clips[i].clip);\n clipPromises.push(this._loadClipAsync(`${clipContext}/${emitter.clips[i].clip}`, clip).then((objectURL: string) => {\n const sound = emitter._babylonSounds[i] = new Sound(name, objectURL, this._loader.babylonScene, null, options);\n sound.refDistance = emitter.refDistance || 1;\n sound.maxDistance = emitter.maxDistance || 256;\n sound.rolloffFactor = emitter.rolloffFactor || 1;\n sound.distanceModel = emitter.distanceModel || 'exponential';\n }));\n }\n\n const promise = Promise.all(clipPromises).then(() => {\n const weights = emitter.clips.map((clip) => { return clip.weight || 1; });\n const weightedSound = new WeightedSound(emitter.loop || false, emitter._babylonSounds, weights);\n if (emitter.innerAngle) { weightedSound.directionalConeInnerAngle = 2 * Tools.ToDegrees(emitter.innerAngle); }\n if (emitter.outerAngle) { weightedSound.directionalConeOuterAngle = 2 * Tools.ToDegrees(emitter.outerAngle); }\n if (emitter.volume) { weightedSound.volume = emitter.volume; }\n emitter._babylonData!.sound = weightedSound;\n });\n\n emitter._babylonData = {\n loaded: promise\n };\n }\n\n return emitter._babylonData.loaded;\n }\n\n private _getEventAction(context: string, sound: WeightedSound, action: IMSFTAudioEmitter_AnimationEventAction, time: number, startOffset?: number): (currentFrame: number) => void {\n switch (action) {\n case IMSFTAudioEmitter_AnimationEventAction.play: {\n return (currentFrame: number) => {\n const frameOffset = (startOffset || 0) + (currentFrame - time);\n sound.play(frameOffset);\n };\n }\n case IMSFTAudioEmitter_AnimationEventAction.stop: {\n return (currentFrame: number) => {\n sound.stop();\n };\n }\n case IMSFTAudioEmitter_AnimationEventAction.pause: {\n return (currentFrame: number) => {\n sound.pause();\n };\n }\n default: {\n throw new Error(`${context}: Unsupported action ${action}`);\n }\n }\n }\n\n private _loadAnimationEventAsync(context: string, animationContext: string, animation: IAnimation, event: ILoaderAnimationEvent, babylonAnimationGroup: AnimationGroup): Promise<void> {\n if (babylonAnimationGroup.targetedAnimations.length == 0) {\n return Promise.resolve();\n }\n const babylonAnimation = babylonAnimationGroup.targetedAnimations[0];\n const emitterIndex = event.emitter;\n const emitter = ArrayItem.Get(`/extensions/${this.name}/emitters`, this._emitters, emitterIndex);\n return this._loadEmitterAsync(context, emitter).then(() => {\n const sound = emitter._babylonData!.sound;\n if (sound) {\n var babylonAnimationEvent = new AnimationEvent(event.time, this._getEventAction(context, sound, event.action, event.time, event.startOffset));\n babylonAnimation.animation.addEvent(babylonAnimationEvent);\n // Make sure all started audio stops when this animation is terminated.\n babylonAnimationGroup.onAnimationGroupEndObservable.add(() => {\n sound.stop();\n });\n babylonAnimationGroup.onAnimationGroupPauseObservable.add(() => {\n sound.pause();\n });\n }\n });\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new MSFT_audio_emitter(loader));"]}
@@ -1,75 +0,0 @@
1
- import { Nullable } from "@babylonjs/core/types";
2
- import { Observable } from "@babylonjs/core/Misc/observable";
3
- import { Material } from "@babylonjs/core/Materials/material";
4
- import { TransformNode } from "@babylonjs/core/Meshes/transformNode";
5
- import { Mesh } from "@babylonjs/core/Meshes/mesh";
6
- import { INode, IMaterial, IBuffer, IScene } from "../glTFLoaderInterfaces";
7
- import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
8
- import { GLTFLoader } from "../glTFLoader";
9
- import { IProperty } from "babylonjs-gltf2interface";
10
- /**
11
- * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
12
- */
13
- export declare class MSFT_lod implements IGLTFLoaderExtension {
14
- /**
15
- * The name of this extension.
16
- */
17
- readonly name = "MSFT_lod";
18
- /**
19
- * Defines whether this extension is enabled.
20
- */
21
- enabled: boolean;
22
- /**
23
- * Defines a number that determines the order the extensions are applied.
24
- */
25
- order: number;
26
- /**
27
- * Maximum number of LODs to load, starting from the lowest LOD.
28
- */
29
- maxLODsToLoad: number;
30
- /**
31
- * Observable raised when all node LODs of one level are loaded.
32
- * The event data is the index of the loaded LOD starting from zero.
33
- * Dispose the loader to cancel the loading of the next level of LODs.
34
- */
35
- onNodeLODsLoadedObservable: Observable<number>;
36
- /**
37
- * Observable raised when all material LODs of one level are loaded.
38
- * The event data is the index of the loaded LOD starting from zero.
39
- * Dispose the loader to cancel the loading of the next level of LODs.
40
- */
41
- onMaterialLODsLoadedObservable: Observable<number>;
42
- private _loader;
43
- private _bufferLODs;
44
- private _nodeIndexLOD;
45
- private _nodeSignalLODs;
46
- private _nodePromiseLODs;
47
- private _nodeBufferLODs;
48
- private _materialIndexLOD;
49
- private _materialSignalLODs;
50
- private _materialPromiseLODs;
51
- private _materialBufferLODs;
52
- /** @hidden */
53
- constructor(loader: GLTFLoader);
54
- /** @hidden */
55
- dispose(): void;
56
- /** @hidden */
57
- onReady(): void;
58
- /** @hidden */
59
- loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
60
- /** @hidden */
61
- loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
62
- /** @hidden */
63
- _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
64
- /** @hidden */
65
- _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
66
- /** @hidden */
67
- loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
68
- private _loadBufferLOD;
69
- /**
70
- * Gets an array of LOD properties from lowest to highest.
71
- */
72
- private _getLODs;
73
- private _disposeTransformNode;
74
- private _disposeMaterials;
75
- }