SpacePirates icon indicating copy to clipboard operation
SpacePirates copied to clipboard

No Sound with babylonjs 8.16.2

Open petrospap opened this issue 7 months ago • 2 comments

Hello, I am totally new to babylonjs. I try your game just to learn :) BTW thank you!!!

So, default installation is not working due "recursive-install" problems. So i changed a bit as following, under Windows 11, npm version: 11.4.2, firefox: 140.0.4 (64-bit)

root package.json changed: [concurrently]: to 9.2.0 [recursive-install]: to npm-recursive-runner: 1.0.2

{
  "name": "proving_ground",
  "version": "1.0.0",
  "description": "",
  "private": "true",
  "scripts": {
    "install": "npm-recursive-install --skip-root",
    "dev": "concurrently \"npm --prefix ./app_package run dev\" \"npm --prefix ./test_package run dev\"",
    "build": "npm --prefix ./app_package run build && npm --prefix ./test_package run build"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "concurrently": "^9.2.0",
    "npm-recursive-runner": "^1.0.2"
  }
}

test_package package.json changed: webpack* latest

{
  "name": "test_package",
  "version": "1.0.0",
  "description": "",
  "private": true,
  "scripts": {
    "build": "webpack --config webpack.build.config.js",
    "dev": "webpack-dev-server --config webpack.dev.config.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "html-webpack-plugin": "^5.6.3",
    "webpack": "^5.100.2",
    "webpack-cli": "^6.0.1",
    "webpack-dev-server": "^5.2.2"
  },
  "dependencies": {
    "app_package": "file:../app_package"
  }
}

app_package package.json changed: babylonjs*, ammojs-typed, cannon-es, earcut: latest

{
  "name": "app_package",
  "version": "1.0.0",
  "description": "",
  "main": "lib/index.js",
  "types": "lib",
  "scripts": {
    "build": "tsc -p .",
    "dev": "tsc --watch -p ."
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "typescript": "^5.8.3"
  },
  "dependencies": {
    "@babylonjs/core": "8.16.2",
    "@babylonjs/gui": "8.16.2",
    "@babylonjs/loaders": "8.16.2",
    "@babylonjs/materials": "8.16.2",
    "@babylonjs/post-processes": "8.16.2",
    "@babylonjs/procedural-textures": "8.16.2",
    "@babylonjs/serializers": "8.16.2",
    "ammojs-typed": "^1.0.6",
    "cannon-es": "^0.20.0",
    "earcut": "^3.0.1"
  }
}

NOTHING ELSE CHANGED && NO ERRORS

install game:

npm install > NO ERRORS

Start Game: npm run dev >

1:42:42 pm. - Starting compilation in watch mode...
[0]
[1] <i> [webpack-dev-server] Project is running at:
[1] <i> [webpack-dev-server] Loopback: http://localhost:8080/, http://[::1]:8080/
[1] <i> [webpack-dev-server] On Your Network (IPv4): http://192.168.1.100:8080/
[1] <i> [webpack-dev-server] Content not from webpack is served from 'C:\DevNpm\SpacePirates\test_package\public' directory
[1] <i> [webpack-dev-middleware] wait until bundle finished: /
[0] src/Playground/Game.ts(179,32): error TS2345: Argument of type 'AbstractEngine' is not assignable to parameter of type 'Engine'.
[0]   Type 'AbstractEngine' is missing the following properties from type 'Engine': customAnimationFrameRequester, _rescalePostProcess, _supportsHardwareTextureRescaling, _measureFps, and 183 more.
[0] src/Playground/Inputs/Input.ts(164,24): error TS2551: Property 'mozRequestPointerLock' does not exist on type 'HTMLCanvasElement'. Did you mean 'requestPointerLock'?
[0] src/Playground/Inputs/Input.ts(165,24): error TS2551: Property 'webkitRequestPointerLock' does not exist on type 'HTMLCanvasElement'. Did you mean 'requestPointerLock'?
[0] src/Playground/Ship.ts(195,20): error TS2511: Cannot create an instance of an abstract class.
[0] src/Playground/Ship.ts(227,56): error TS2345: Argument of type 'Nullable<AbstractMesh>' is not assignable to parameter of type 'AbstractMesh'.
[0]   Type 'null' is not assignable to type 'AbstractMesh'.
[0] src/playgroundRunner.ts(76,21): error TS2322: Type '"depth24unorm-stencil8"' is not assignable to type 'GPUFeatureName'.
[0] src/playgroundRunner.ts(95,41): error TS2345: Argument of type 'Engine | WebGPUEngine | NativeEngine' is not assignable to parameter of type 'Engine'.
[0]   Type 'WebGPUEngine' is missing the following properties from type 'Engine': customAnimationFrameRequester, _rescalePostProcess, _supportsHardwareTextureRescaling, _initGLContext, and 161 more.
[0] src/playgroundRunner.ts(96,36): error TS2345: Argument of type 'Engine | WebGPUEngine | NativeEngine' is not assignable to parameter of type 'Engine'.
[0]   Type 'WebGPUEngine' is missing the following properties from type 'Engine': customAnimationFrameRequester, _rescalePostProcess, _supportsHardwareTextureRescaling, _initGLContext, and 161 more.
[0] src/playgroundRunner.ts(104,40): error TS2345: Argument of type 'Engine | WebGPUEngine | NativeEngine' is not assignable to parameter of type 'Engine'.
[0]   Type 'WebGPUEngine' is missing the following properties from type 'Engine': customAnimationFrameRequester, _rescalePostProcess, _supportsHardwareTextureRescaling, _initGLContext, and 161 more.
[0]
[0] 1:42:46 pm. - Found 9 errors. Watching for file changes.
[1] asset bundle.js 22.5 MiB [emitted] (name: main)
[1] asset index.html 235 bytes [emitted]
[1] runtime modules 27.4 KiB 12 modules
[1] modules by path ../app_package/node_modules/@babylonjs/core/ 14.3 MiB 1980 modules
[1] modules by path ../app_package/node_modules/@babylonjs/gui/ 1.11 MiB
[1]   modules by path ../app_package/node_modules/@babylonjs/gui/3D/ 494 KiB 67 modules
[1]   modules by path ../app_package/node_modules/@babylonjs/gui/2D/ 641 KiB 47 modules
[1]   ../app_package/node_modules/@babylonjs/gui/index.js 157 bytes [built] [code generated]
[1] modules by path ../app_package/node_modules/@babylonjs/loaders/glTF/ 586 KiB 61 modules
[1] modules by path ../app_package/lib/ 262 KiB
[1]   modules by path ../app_package/lib/Playground/ 256 KiB 33 modules
[1]   modules by path ../app_package/lib/*.js 6.21 KiB 3 modules
[1] modules by path ./ 110 KiB
[1]   modules by path ./node_modules/webpack-dev-server/client/ 84.8 KiB 8 modules
[1]   modules by path ./node_modules/webpack/hot/*.js 5.17 KiB 4 modules
[1]   + 3 modules
[1] webpack 5.100.2 compiled successfully in 3511 ms
[1] <i> [webpack-dev-middleware] wait until bundle finished: /bundle.js
[1] assets by status 235 bytes [cached] 1 asset
[1] assets by path *.js 22.5 MiB
[1]   asset bundle.js 22.5 MiB [emitted] (name: main)
[1]   asset main.d5951bdeee3265b5014d.hot-update.js 855 bytes [emitted] [immutable] [hmr] (name: main)
[1] asset main.d5951bdeee3265b5014d.hot-update.json 28 bytes [emitted] [immutable] [hmr]
[1] Entrypoint main 22.5 MiB = bundle.js 22.5 MiB main.d5951bdeee3265b5014d.hot-update.js 855 bytes
[1] cached modules 16.1 MiB [cached] 2171 modules
[1] runtime modules 27.4 KiB 12 modules
[1] javascript modules 262 KiB
[1]   modules by path ../app_package/lib/Playground/ 256 KiB
[1]     modules by path ../app_package/lib/Playground/States/*.js 68 KiB 13 modules
[1]     modules by path ../app_package/lib/Playground/*.js 134 KiB 12 modules
[1]     modules by path ../app_package/lib/Playground/FX/*.js 20.6 KiB 4 modules
[1]     modules by path ../app_package/lib/Playground/Inputs/*.js 19 KiB
[1]       ../app_package/lib/Playground/Inputs/Input.js 6.81 KiB [built]
[1]       + 2 modules
[1]     ../app_package/lib/Playground/Recorder/Recorder.js 14.2 KiB [built]
[1]   modules by path ../app_package/lib/*.js 6.21 KiB
[1]     ../app_package/lib/index.js 844 bytes [built]
[1]     ../app_package/lib/playgroundRunner.js 4.55 KiB [built]
[1]     ../app_package/lib/Settings.js 850 bytes [built]
[1] webpack 5.100.2 compiled successfully in 413 ms

Game run and is playable, seems like everything is working, except sound!! except the above errors/notices NO other errors display

from console seems like all working:

Minimal asset loading done > Assets.js:106:33
gui created > Diorama.js:80:17
AudioAssets loaded > Assets.js:227:17
enableAudio > Assets.js:189:53
Complete asset loading done > Assets.js:200:49

As totally new in Babylon is not easy to find what I have to change.. OR where the problem is.. some things I tried..


/app_package/src/Playground/Assets.ts

In function soundReady() this.ready never return true!!


/app_package/src/Playground/ship.ts

In function _tickEndOfLife()

if (ship.explosionSfx) {
    ship.explosionSfx[rand].play();
	// view explosionSfx
	console.log('_tickEndOfLife play??');
	console.dir(ship.explosionSfx);
}

results >

_tickEndOfLife play??
Array [ {…}, {…} ]
0: Object { autoplay: false, _loop: false, useCustomAttenuation: false, … }
_coneInnerAngle: 360
_coneOuterAngle: 360
_coneOuterGain: 0
_currentTime: 0
_customAttenuationFunction: function _customAttenuationFunction(currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor)
_isDirectional: false
_isOutputConnected: false
_isReadyToPlay: false
_length: undefined
_localDirection: Object { _isDirty: true, _x: 1, _y: 0, … }
_loop: false
_offset: undefined
_panningModel: "equalpower"
_playbackRate: 1
_position: Object { _isDirty: true, _x: 0, _y: 0, … }
_readyToPlayCallback: null
_scene: Object { _isScene: true, _blockEntityCollection: false, autoClear: true, … }
_spatialSound: true
_startTime: 0
_streaming: false
_urlType: "Unknown"
_volume: 2
autoplay: false
distanceModel: "exponential"
isPaused: false
isPlaying: false
maxDistance: 100
metadata: null
name: "explosion_cloned"
onEndedObservable: Object { notifyIfTriggered: false, _numObserversMarkedAsDeleted: 0, _hasNotified: false, … }
refDistance: 1
rolloffFactor: 0.2
soundTrackId: -1
useCustomAttenuation: false
<prototype>: Object { … }
​
1: Object { autoplay: false, _loop: false, useCustomAttenuation: false, … }
_coneInnerAngle: 360
_coneOuterAngle: 360
_coneOuterGain: 0
_currentTime: 0
_customAttenuationFunction: function _customAttenuationFunction(currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor)
_isDirectional: false
_isOutputConnected: false
_isReadyToPlay: false
_length: undefined
_localDirection: Object { _isDirty: true, _x: 1, _y: 0, … }
_loop: false
_offset: undefined
_panningModel: "equalpower"
_playbackRate: 1
_position: Object { _isDirty: true, _x: 0, _y: 0, … }
_readyToPlayCallback: null
_scene: Object { _isScene: true, _blockEntityCollection: false, autoClear: true, … }
_spatialSound: true
_startTime: 0
_streaming: false
_urlType: "Unknown"
_volume: 2
autoplay: false
distanceModel: "exponential"
isPaused: false
isPlaying: false
maxDistance: 100
metadata: null
name: "explosion_cloned"
onEndedObservable: Object { notifyIfTriggered: false, _numObserversMarkedAsDeleted: 0, _hasNotified: false, … }
refDistance: 1
rolloffFactor: 0.2
soundTrackId: -1
useCustomAttenuation: false
<prototype>: Object { … }
length: 2

Thank you, for any help!!

petrospap avatar Jul 17 '25 12:07 petrospap