[page:Object3D] → [page:Audio] →

[name]

تقوم بإنشاء كائن صوتي موضعي (positional).

يستخدم هذا [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API Web Audio API].

مثال التعليمة البرمجية

// create an AudioListener and add it to the camera const listener = new THREE.AudioListener(); camera.add( listener ); // create the PositionalAudio object (passing in the listener) const sound = new THREE.PositionalAudio( listener ); // load a sound and set it as the PositionalAudio object's buffer const audioLoader = new THREE.AudioLoader(); audioLoader.load( 'sounds/song.ogg', function( buffer ) { sound.setBuffer( buffer ); sound.setRefDistance( 20 ); sound.play(); }); // create an object for the sound to play from const sphere = new THREE.SphereGeometry( 20, 32, 16 ); const material = new THREE.MeshPhongMaterial( { color: 0xff2200 } ); const mesh = new THREE.Mesh( sphere, material ); scene.add( mesh ); // finally add the sound to the mesh mesh.add( sound );

أمثلة (Examples)

[example:webaudio_orientation webaudio / orientation ]
[example:webaudio_sandbox webaudio / sandbox ]
[example:webaudio_timing webaudio / timing ]

المنشئ (Constructor)

[name]( [param:AudioListener listener] )

listener — (ضرورية) كائن [page:AudioListener AudioListener] .

الخصائص (Properties)

تراجع فئة [page:Audio Audio] من أجل الخصائص الموروثة.

[property:PannerNode panner]

خاصية [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode PannerNode] التابعة لـ*PositionalAudio*.

الوظائف (Methods)

راجع فئة [page:Audio Audio] من أجل الوظائف الموروثة.

[method:PannerNode getOutput]()

ترجع الـ[page:PositionalAudio.panner panner].

[method:Float getRefDistance]()

تُرجع القيمة [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/refDistance panner.refDistance].

[method:this setRefDistance]( [param:Float value] )

يضبط قيمة [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/refDistance panner.refDistance].

[method:Float getRolloffFactor]()

تُرجع القيمة [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/rolloffFactor panner.rolloffFactor].

[method:this setRolloffFactor]( [param:Float value] )

يضبط قيمة [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/rolloffFactor panner.rolloffFactor].

[method:String getDistanceModel]()

تُرجع القيمة [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel panner.distanceModel].

[method:this setDistanceModel]( [param:String value] )

يضبط قيمة [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel panner.distanceModel].

[method:Float getMaxDistance]()

تُرجع القيمة [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/maxDistance panner.maxDistance].

[method:this setMaxDistance]( [param:Float value] )

يضبط قيمة [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/maxDistance panner.maxDistance].

[method:this setDirectionalCone]( [param:Float coneInnerAngle], [param:Float coneOuterAngle], [param:Float coneOuterGain] )

يمكن استخدام هذه الطريقة لتحويل الصوت متعدد الاتجاهات إلى [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode directional sound].

المصدر (Source)

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]