Explorar el Código

Basketball game: add music

customisations
alemart hace 8 meses
padre
commit
2258d49ba2

+ 401
- 1
demos/basketball/NOTICE.html Ver fichero

@@ -41,7 +41,7 @@
41 41
                 <a href="https://schteppe.github.io/cannon.js" target="_blank" rel="external">https://schteppe.github.io/cannon.js</a>
42 42
             </li>
43 43
         </ol>
44
-        <p>This game also contains 3D models and 2D artwork created by <a href="https://github.com/alemart" target="_blank" rel="external">Alexandre Martins</a>, as well as sound effects released by <a href="https://www.kenney.nl" target="_blank" rel="external">Kenney</a>, all made available under the <a href="#cc0">Creative Commons Zero 1.0 Universal</a>.</p>
44
+        <p>This game also contains 3D models and 2D artwork created by <a href="https://github.com/alemart" target="_blank" rel="external">Alexandre Martins</a>, as well as sound effects released by <a href="https://www.kenney.nl" target="_blank" rel="external">Kenney</a>, all made available under the <a href="#cc0">Creative Commons Zero 1.0 Universal</a>. In addition, it plays music "Gang$tazz", composed by <a href="https://www.youtube.com/@AlexandrZhelanovsMusic" target="_blank" rel="external">Alexandr Zhelanov</a> and licensed under the <a href="#cc-by-4.0">Creative Commons Attribution 4.0 International</a>.</p>
45 45
         <hr>
46 46
 
47 47
         <h2 id="lgpl">GNU Lesser General Public License</h2>
@@ -1250,5 +1250,405 @@ express Statement of Purpose.
1250 1250
     this CC0 or use of the Work.
1251 1251
         </pre>
1252 1252
         <a href="#top">&uarr; Top</a>
1253
+
1254
+        <h2 id="cc-by-4.0">Creative Commons Attribution 4.0 International</h2>
1255
+        <pre>
1256
+Attribution 4.0 International
1257
+
1258
+=======================================================================
1259
+
1260
+Creative Commons Corporation ("Creative Commons") is not a law firm and
1261
+does not provide legal services or legal advice. Distribution of
1262
+Creative Commons public licenses does not create a lawyer-client or
1263
+other relationship. Creative Commons makes its licenses and related
1264
+information available on an "as-is" basis. Creative Commons gives no
1265
+warranties regarding its licenses, any material licensed under their
1266
+terms and conditions, or any related information. Creative Commons
1267
+disclaims all liability for damages resulting from their use to the
1268
+fullest extent possible.
1269
+
1270
+Using Creative Commons Public Licenses
1271
+
1272
+Creative Commons public licenses provide a standard set of terms and
1273
+conditions that creators and other rights holders may use to share
1274
+original works of authorship and other material subject to copyright
1275
+and certain other rights specified in the public license below. The
1276
+following considerations are for informational purposes only, are not
1277
+exhaustive, and do not form part of our licenses.
1278
+
1279
+     Considerations for licensors: Our public licenses are
1280
+     intended for use by those authorized to give the public
1281
+     permission to use material in ways otherwise restricted by
1282
+     copyright and certain other rights. Our licenses are
1283
+     irrevocable. Licensors should read and understand the terms
1284
+     and conditions of the license they choose before applying it.
1285
+     Licensors should also secure all rights necessary before
1286
+     applying our licenses so that the public can reuse the
1287
+     material as expected. Licensors should clearly mark any
1288
+     material not subject to the license. This includes other CC-
1289
+     licensed material, or material used under an exception or
1290
+     limitation to copyright. More considerations for licensors:
1291
+    wiki.creativecommons.org/Considerations_for_licensors
1292
+
1293
+     Considerations for the public: By using one of our public
1294
+     licenses, a licensor grants the public permission to use the
1295
+     licensed material under specified terms and conditions. If
1296
+     the licensor's permission is not necessary for any reason--for
1297
+     example, because of any applicable exception or limitation to
1298
+     copyright--then that use is not regulated by the license. Our
1299
+     licenses grant only permissions under copyright and certain
1300
+     other rights that a licensor has authority to grant. Use of
1301
+     the licensed material may still be restricted for other
1302
+     reasons, including because others have copyright or other
1303
+     rights in the material. A licensor may make special requests,
1304
+     such as asking that all changes be marked or described.
1305
+     Although not required by our licenses, you are encouraged to
1306
+     respect those requests where reasonable. More considerations
1307
+     for the public:
1308
+    wiki.creativecommons.org/Considerations_for_licensees
1309
+
1310
+=======================================================================
1311
+
1312
+Creative Commons Attribution 4.0 International Public License
1313
+
1314
+By exercising the Licensed Rights (defined below), You accept and agree
1315
+to be bound by the terms and conditions of this Creative Commons
1316
+Attribution 4.0 International Public License ("Public License"). To the
1317
+extent this Public License may be interpreted as a contract, You are
1318
+granted the Licensed Rights in consideration of Your acceptance of
1319
+these terms and conditions, and the Licensor grants You such rights in
1320
+consideration of benefits the Licensor receives from making the
1321
+Licensed Material available under these terms and conditions.
1322
+
1323
+
1324
+Section 1 -- Definitions.
1325
+
1326
+  a. Adapted Material means material subject to Copyright and Similar
1327
+     Rights that is derived from or based upon the Licensed Material
1328
+     and in which the Licensed Material is translated, altered,
1329
+     arranged, transformed, or otherwise modified in a manner requiring
1330
+     permission under the Copyright and Similar Rights held by the
1331
+     Licensor. For purposes of this Public License, where the Licensed
1332
+     Material is a musical work, performance, or sound recording,
1333
+     Adapted Material is always produced where the Licensed Material is
1334
+     synched in timed relation with a moving image.
1335
+
1336
+  b. Adapter's License means the license You apply to Your Copyright
1337
+     and Similar Rights in Your contributions to Adapted Material in
1338
+     accordance with the terms and conditions of this Public License.
1339
+
1340
+  c. Copyright and Similar Rights means copyright and/or similar rights
1341
+     closely related to copyright including, without limitation,
1342
+     performance, broadcast, sound recording, and Sui Generis Database
1343
+     Rights, without regard to how the rights are labeled or
1344
+     categorized. For purposes of this Public License, the rights
1345
+     specified in Section 2(b)(1)-(2) are not Copyright and Similar
1346
+     Rights.
1347
+
1348
+  d. Effective Technological Measures means those measures that, in the
1349
+     absence of proper authority, may not be circumvented under laws
1350
+     fulfilling obligations under Article 11 of the WIPO Copyright
1351
+     Treaty adopted on December 20, 1996, and/or similar international
1352
+     agreements.
1353
+
1354
+  e. Exceptions and Limitations means fair use, fair dealing, and/or
1355
+     any other exception or limitation to Copyright and Similar Rights
1356
+     that applies to Your use of the Licensed Material.
1357
+
1358
+  f. Licensed Material means the artistic or literary work, database,
1359
+     or other material to which the Licensor applied this Public
1360
+     License.
1361
+
1362
+  g. Licensed Rights means the rights granted to You subject to the
1363
+     terms and conditions of this Public License, which are limited to
1364
+     all Copyright and Similar Rights that apply to Your use of the
1365
+     Licensed Material and that the Licensor has authority to license.
1366
+
1367
+  h. Licensor means the individual(s) or entity(ies) granting rights
1368
+     under this Public License.
1369
+
1370
+  i. Share means to provide material to the public by any means or
1371
+     process that requires permission under the Licensed Rights, such
1372
+     as reproduction, public display, public performance, distribution,
1373
+     dissemination, communication, or importation, and to make material
1374
+     available to the public including in ways that members of the
1375
+     public may access the material from a place and at a time
1376
+     individually chosen by them.
1377
+
1378
+  j. Sui Generis Database Rights means rights other than copyright
1379
+     resulting from Directive 96/9/EC of the European Parliament and of
1380
+     the Council of 11 March 1996 on the legal protection of databases,
1381
+     as amended and/or succeeded, as well as other essentially
1382
+     equivalent rights anywhere in the world.
1383
+
1384
+  k. You means the individual or entity exercising the Licensed Rights
1385
+     under this Public License. Your has a corresponding meaning.
1386
+
1387
+
1388
+Section 2 -- Scope.
1389
+
1390
+  a. License grant.
1391
+
1392
+       1. Subject to the terms and conditions of this Public License,
1393
+          the Licensor hereby grants You a worldwide, royalty-free,
1394
+          non-sublicensable, non-exclusive, irrevocable license to
1395
+          exercise the Licensed Rights in the Licensed Material to:
1396
+
1397
+            a. reproduce and Share the Licensed Material, in whole or
1398
+               in part; and
1399
+
1400
+            b. produce, reproduce, and Share Adapted Material.
1401
+
1402
+       2. Exceptions and Limitations. For the avoidance of doubt, where
1403
+          Exceptions and Limitations apply to Your use, this Public
1404
+          License does not apply, and You do not need to comply with
1405
+          its terms and conditions.
1406
+
1407
+       3. Term. The term of this Public License is specified in Section
1408
+          6(a).
1409
+
1410
+       4. Media and formats; technical modifications allowed. The
1411
+          Licensor authorizes You to exercise the Licensed Rights in
1412
+          all media and formats whether now known or hereafter created,
1413
+          and to make technical modifications necessary to do so. The
1414
+          Licensor waives and/or agrees not to assert any right or
1415
+          authority to forbid You from making technical modifications
1416
+          necessary to exercise the Licensed Rights, including
1417
+          technical modifications necessary to circumvent Effective
1418
+          Technological Measures. For purposes of this Public License,
1419
+          simply making modifications authorized by this Section 2(a)
1420
+          (4) never produces Adapted Material.
1421
+
1422
+       5. Downstream recipients.
1423
+
1424
+            a. Offer from the Licensor -- Licensed Material. Every
1425
+               recipient of the Licensed Material automatically
1426
+               receives an offer from the Licensor to exercise the
1427
+               Licensed Rights under the terms and conditions of this
1428
+               Public License.
1429
+
1430
+            b. No downstream restrictions. You may not offer or impose
1431
+               any additional or different terms or conditions on, or
1432
+               apply any Effective Technological Measures to, the
1433
+               Licensed Material if doing so restricts exercise of the
1434
+               Licensed Rights by any recipient of the Licensed
1435
+               Material.
1436
+
1437
+       6. No endorsement. Nothing in this Public License constitutes or
1438
+          may be construed as permission to assert or imply that You
1439
+          are, or that Your use of the Licensed Material is, connected
1440
+          with, or sponsored, endorsed, or granted official status by,
1441
+          the Licensor or others designated to receive attribution as
1442
+          provided in Section 3(a)(1)(A)(i).
1443
+
1444
+  b. Other rights.
1445
+
1446
+       1. Moral rights, such as the right of integrity, are not
1447
+          licensed under this Public License, nor are publicity,
1448
+          privacy, and/or other similar personality rights; however, to
1449
+          the extent possible, the Licensor waives and/or agrees not to
1450
+          assert any such rights held by the Licensor to the limited
1451
+          extent necessary to allow You to exercise the Licensed
1452
+          Rights, but not otherwise.
1453
+
1454
+       2. Patent and trademark rights are not licensed under this
1455
+          Public License.
1456
+
1457
+       3. To the extent possible, the Licensor waives any right to
1458
+          collect royalties from You for the exercise of the Licensed
1459
+          Rights, whether directly or through a collecting society
1460
+          under any voluntary or waivable statutory or compulsory
1461
+          licensing scheme. In all other cases the Licensor expressly
1462
+          reserves any right to collect such royalties.
1463
+
1464
+
1465
+Section 3 -- License Conditions.
1466
+
1467
+Your exercise of the Licensed Rights is expressly made subject to the
1468
+following conditions.
1469
+
1470
+  a. Attribution.
1471
+
1472
+       1. If You Share the Licensed Material (including in modified
1473
+          form), You must:
1474
+
1475
+            a. retain the following if it is supplied by the Licensor
1476
+               with the Licensed Material:
1477
+
1478
+                 i. identification of the creator(s) of the Licensed
1479
+                    Material and any others designated to receive
1480
+                    attribution, in any reasonable manner requested by
1481
+                    the Licensor (including by pseudonym if
1482
+                    designated);
1483
+
1484
+                ii. a copyright notice;
1485
+
1486
+               iii. a notice that refers to this Public License;
1487
+
1488
+                iv. a notice that refers to the disclaimer of
1489
+                    warranties;
1490
+
1491
+                 v. a URI or hyperlink to the Licensed Material to the
1492
+                    extent reasonably practicable;
1493
+
1494
+            b. indicate if You modified the Licensed Material and
1495
+               retain an indication of any previous modifications; and
1496
+
1497
+            c. indicate the Licensed Material is licensed under this
1498
+               Public License, and include the text of, or the URI or
1499
+               hyperlink to, this Public License.
1500
+
1501
+       2. You may satisfy the conditions in Section 3(a)(1) in any
1502
+          reasonable manner based on the medium, means, and context in
1503
+          which You Share the Licensed Material. For example, it may be
1504
+          reasonable to satisfy the conditions by providing a URI or
1505
+          hyperlink to a resource that includes the required
1506
+          information.
1507
+
1508
+       3. If requested by the Licensor, You must remove any of the
1509
+          information required by Section 3(a)(1)(A) to the extent
1510
+          reasonably practicable.
1511
+
1512
+       4. If You Share Adapted Material You produce, the Adapter's
1513
+          License You apply must not prevent recipients of the Adapted
1514
+          Material from complying with this Public License.
1515
+
1516
+
1517
+Section 4 -- Sui Generis Database Rights.
1518
+
1519
+Where the Licensed Rights include Sui Generis Database Rights that
1520
+apply to Your use of the Licensed Material:
1521
+
1522
+  a. for the avoidance of doubt, Section 2(a)(1) grants You the right
1523
+     to extract, reuse, reproduce, and Share all or a substantial
1524
+     portion of the contents of the database;
1525
+
1526
+  b. if You include all or a substantial portion of the database
1527
+     contents in a database in which You have Sui Generis Database
1528
+     Rights, then the database in which You have Sui Generis Database
1529
+     Rights (but not its individual contents) is Adapted Material; and
1530
+
1531
+  c. You must comply with the conditions in Section 3(a) if You Share
1532
+     all or a substantial portion of the contents of the database.
1533
+
1534
+For the avoidance of doubt, this Section 4 supplements and does not
1535
+replace Your obligations under this Public License where the Licensed
1536
+Rights include other Copyright and Similar Rights.
1537
+
1538
+
1539
+Section 5 -- Disclaimer of Warranties and Limitation of Liability.
1540
+
1541
+  a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
1542
+     EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
1543
+     AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
1544
+     ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
1545
+     IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
1546
+     WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
1547
+     PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
1548
+     ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
1549
+     KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
1550
+     ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
1551
+
1552
+  b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
1553
+     TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
1554
+     NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
1555
+     INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
1556
+     COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
1557
+     USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
1558
+     ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
1559
+     DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
1560
+     IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
1561
+
1562
+  c. The disclaimer of warranties and limitation of liability provided
1563
+     above shall be interpreted in a manner that, to the extent
1564
+     possible, most closely approximates an absolute disclaimer and
1565
+     waiver of all liability.
1566
+
1567
+
1568
+Section 6 -- Term and Termination.
1569
+
1570
+  a. This Public License applies for the term of the Copyright and
1571
+     Similar Rights licensed here. However, if You fail to comply with
1572
+     this Public License, then Your rights under this Public License
1573
+     terminate automatically.
1574
+
1575
+  b. Where Your right to use the Licensed Material has terminated under
1576
+     Section 6(a), it reinstates:
1577
+
1578
+       1. automatically as of the date the violation is cured, provided
1579
+          it is cured within 30 days of Your discovery of the
1580
+          violation; or
1581
+
1582
+       2. upon express reinstatement by the Licensor.
1583
+
1584
+     For the avoidance of doubt, this Section 6(b) does not affect any
1585
+     right the Licensor may have to seek remedies for Your violations
1586
+     of this Public License.
1587
+
1588
+  c. For the avoidance of doubt, the Licensor may also offer the
1589
+     Licensed Material under separate terms or conditions or stop
1590
+     distributing the Licensed Material at any time; however, doing so
1591
+     will not terminate this Public License.
1592
+
1593
+  d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
1594
+     License.
1595
+
1596
+
1597
+Section 7 -- Other Terms and Conditions.
1598
+
1599
+  a. The Licensor shall not be bound by any additional or different
1600
+     terms or conditions communicated by You unless expressly agreed.
1601
+
1602
+  b. Any arrangements, understandings, or agreements regarding the
1603
+     Licensed Material not stated herein are separate from and
1604
+     independent of the terms and conditions of this Public License.
1605
+
1606
+
1607
+Section 8 -- Interpretation.
1608
+
1609
+  a. For the avoidance of doubt, this Public License does not, and
1610
+     shall not be interpreted to, reduce, limit, restrict, or impose
1611
+     conditions on any use of the Licensed Material that could lawfully
1612
+     be made without permission under this Public License.
1613
+
1614
+  b. To the extent possible, if any provision of this Public License is
1615
+     deemed unenforceable, it shall be automatically reformed to the
1616
+     minimum extent necessary to make it enforceable. If the provision
1617
+     cannot be reformed, it shall be severed from this Public License
1618
+     without affecting the enforceability of the remaining terms and
1619
+     conditions.
1620
+
1621
+  c. No term or condition of this Public License will be waived and no
1622
+     failure to comply consented to unless expressly agreed to by the
1623
+     Licensor.
1624
+
1625
+  d. Nothing in this Public License constitutes or may be interpreted
1626
+     as a limitation upon, or waiver of, any privileges and immunities
1627
+     that apply to the Licensor or You, including from the legal
1628
+     processes of any jurisdiction or authority.
1629
+
1630
+
1631
+=======================================================================
1632
+
1633
+Creative Commons is not a party to its public
1634
+licenses. Notwithstanding, Creative Commons may elect to apply one of
1635
+its public licenses to material it publishes and in those instances
1636
+will be considered the “Licensor.” The text of the Creative Commons
1637
+public licenses is dedicated to the public domain under the CC0 Public
1638
+Domain Dedication. Except for the limited purpose of indicating that
1639
+material is shared under a Creative Commons public license or as
1640
+otherwise permitted by the Creative Commons policies published at
1641
+creativecommons.org/policies, Creative Commons does not authorize the
1642
+use of the trademark "Creative Commons" or any other trademark or logo
1643
+of Creative Commons without its prior written consent including,
1644
+without limitation, in connection with any unauthorized modifications
1645
+to any of its public licenses or any other arrangements,
1646
+understandings, or agreements concerning use of licensed material. For
1647
+the avoidance of doubt, this paragraph does not form part of the
1648
+public licenses.
1649
+
1650
+Creative Commons may be contacted at creativecommons.org.
1651
+        </pre>
1652
+        <a href="#top">&uarr; Top</a>
1253 1653
     </body>
1254 1654
 </html>

BIN
demos/basketball/assets/music.mp3 Ver fichero


+ 2
- 1
demos/basketball/src/core/asset-list.js Ver fichero

@@ -20,7 +20,8 @@ export const ASSET_LIST = Object.freeze([
20 20
     // 2D artwork
21 21
     'atlas.png',
22 22
 
23
-    // sounds
23
+    // sounds & music
24
+    'music.mp3',
24 25
     'backboard.wav',
25 26
     'bounce.wav',
26 27
     'basket.wav',

+ 2
- 0
demos/basketball/src/entities/gui/tutorial-overlay.js Ver fichero

@@ -8,6 +8,7 @@
8 8
  */
9 9
 
10 10
 import { GUIControl } from './gui-control.js';
11
+import { GameEvent } from '../../core/events.js';
11 12
 
12 13
 /** Duration of the swipe animation, in seconds */
13 14
 const ANIMATION_DURATION = 1.5;
@@ -88,6 +89,7 @@ export class TutorialOverlay extends GUIControl
88 89
             if(pointer.phase == 'began') {
89 90
                 container.isVisible = false;
90 91
                 this._enabled = false;
92
+                this._broadcast(new GameEvent('started'));
91 93
                 return;
92 94
             }
93 95
         }

+ 56
- 15
demos/basketball/src/entities/jukebox.js Ver fichero

@@ -24,6 +24,8 @@ export class Jukebox extends Entity
24 24
     {
25 25
         super(game);
26 26
         this._sound = new Map();
27
+        this._music = null;
28
+        this._gameStarted = false;
27 29
     }
28 30
 
29 31
     /**
@@ -32,16 +34,8 @@ export class Jukebox extends Entity
32 34
      */
33 35
     init()
34 36
     {
35
-        const soundFiles = ASSET_LIST.filter(asset => asset.endsWith('.wav'));
36
-
37
-        for(const filepath of soundFiles) {
38
-            const url = this._game.assetManager.url(filepath);
39
-            const soundName = filepath.substring(0, filepath.length - 4);
40
-            const sound = new BABYLON.Sound(soundName, url);
41
-
42
-            this._sound.set(soundName, sound);
43
-        }
44
-
37
+        this._loadSounds();
38
+        this._loadMusic();
45 39
         BABYLON.Engine.audioEngine.useCustomUnlockedButton = true;
46 40
     }
47 41
 
@@ -59,7 +53,15 @@ export class Jukebox extends Entity
59 53
                     this._play('bonus');
60 54
                 break;
61 55
 
56
+            case 'ballbounced':
57
+                if(event.detail.material == 'backboard')
58
+                    this._play('backboard', event.detail.position);
59
+                else
60
+                    this._play('bounce', event.detail.position);
61
+                break;
62
+
62 63
             case 'gameover':
64
+                this._music.setVolume(0.2);
63 65
                 if(/^[AS]/.test(event.detail.rank))
64 66
                     this._play('win');
65 67
                 else if(event.detail.rank == 'B+')
@@ -68,11 +70,23 @@ export class Jukebox extends Entity
68 70
                     this._play('lose');
69 71
                 break;
70 72
 
71
-            case 'ballbounced':
72
-                if(event.detail.material == 'backboard')
73
-                    this._play('backboard', event.detail.position);
74
-                else
75
-                    this._play('bounce', event.detail.position);
73
+            case 'restarted':
74
+                this._music.setVolume(0.5);
75
+                break;
76
+
77
+            case 'started':
78
+                this._gameStarted = true;
79
+                this._music.setVolume(0.5);
80
+                this._music.play();
81
+                break;
82
+
83
+            case 'targetfound':
84
+                if(this._gameStarted)
85
+                    this._music.play();
86
+                break;
87
+
88
+            case 'targetlost':
89
+                this._music.stop();
76 90
                 break;
77 91
 
78 92
             case 'unmuted':
@@ -87,6 +101,33 @@ export class Jukebox extends Entity
87 101
     }
88 102
 
89 103
     /**
104
+     * Load the sound effects
105
+     * @returns {void}
106
+     */
107
+    _loadSounds()
108
+    {
109
+        const soundFiles = ASSET_LIST.filter(asset => asset.endsWith('.wav'));
110
+
111
+        for(const filepath of soundFiles) {
112
+            const url = this._game.assetManager.url(filepath);
113
+            const soundName = filepath.substring(0, filepath.length - 4);
114
+            const sound = new BABYLON.Sound(soundName, url);
115
+
116
+            this._sound.set(soundName, sound);
117
+        }
118
+    }
119
+
120
+    /**
121
+     * Load the music
122
+     * @returns {void}
123
+     */
124
+    _loadMusic()
125
+    {
126
+        const url = this._game.assetManager.url('music.mp3');
127
+        this._music = new BABYLON.Sound('music', url, this.ar.scene, null, { loop: true });
128
+    }
129
+
130
+    /**
90 131
      * Play a sound
91 132
      * @param {string} soundName
92 133
      * @param {BABYLON.Vector3|null} [position]

Loading…
Cancelar
Guardar