|
| 1 | +const expect = chai.expect; |
| 2 | + |
| 3 | +describe('p5.Listener3D', function () { |
| 4 | + let listener3d; |
| 5 | + it('can be created', function () { |
| 6 | + listener3d = new p5.Listener3D(); |
| 7 | + console.log(listener3d); |
| 8 | + expect(listener3d).to.have.property('ac'); |
| 9 | + expect(listener3d.listener).to.have.property('forwardX'); |
| 10 | + expect(listener3d.listener).to.have.property('positionY'); |
| 11 | + expect(listener3d.listener).to.have.property('upZ'); |
| 12 | + }); |
| 13 | + |
| 14 | + it('can be connected to a source', function () { |
| 15 | + let gain = new p5.Gain(); |
| 16 | + listener3d = new p5.Listener3D(); |
| 17 | + listener3d.process(gain); |
| 18 | + }); |
| 19 | + |
| 20 | + describe('methods', function () { |
| 21 | + describe('position', function () { |
| 22 | + it('can set positionX, positionY, positionZ without a delay', function () { |
| 23 | + listener3d = new p5.Listener3D(); |
| 24 | + expect(listener3d.positionX()).to.equal(0); |
| 25 | + expect(listener3d.positionX(-100)).to.equal(-100); |
| 26 | + expect(listener3d.positionY()).to.equal(0); |
| 27 | + expect(listener3d.positionY(300)).to.equal(300); |
| 28 | + expect(listener3d.positionZ()).to.equal(0); |
| 29 | + expect(listener3d.positionZ(200)).to.equal(200); |
| 30 | + }); |
| 31 | + it('can set positionX, positionY, positionZ with a delay', function () { |
| 32 | + //TODO |
| 33 | + }); |
| 34 | + it('can set positionX, positionY, positionZ using position function without a delay', function () { |
| 35 | + listener3d = new p5.Listener3D(); |
| 36 | + expect(listener3d.position(10, 500, 100)).to.deep.equal([10, 500, 100]); |
| 37 | + expect(listener3d.positionX()).to.equal(10); |
| 38 | + expect(listener3d.positionY()).to.equal(500); |
| 39 | + expect(listener3d.positionZ()).to.equal(100); |
| 40 | + }); |
| 41 | + it('can set positionX, positionY, positionZ using position function with a delay', function () { |
| 42 | + //TODO |
| 43 | + }); |
| 44 | + }); |
| 45 | + |
| 46 | + describe('orientation forward', function () { |
| 47 | + it('can set forwardX, forwardY, forwardZ without a delay', function () { |
| 48 | + listener3d = new p5.Listener3D(); |
| 49 | + expect(listener3d.forwardX()).to.equal(0); |
| 50 | + expect(listener3d.forwardX(400)).to.equal(400); |
| 51 | + expect(listener3d.forwardY()).to.equal(0); |
| 52 | + expect(listener3d.forwardY(700)).to.equal(700); |
| 53 | + expect(listener3d.forwardZ()).to.equal(-1); |
| 54 | + expect(listener3d.forwardZ(-800)).to.equal(-800); |
| 55 | + }); |
| 56 | + it('can set forwardX, forwardY, forwardZ with a delay', function () { |
| 57 | + //TODO |
| 58 | + }); |
| 59 | + it('can set forwardX, forwardY, forwardZ using orientForward function without a delay', function () { |
| 60 | + listener3d = new p5.Listener3D(); |
| 61 | + listener3d.orientForward(-100, 100, 300); |
| 62 | + expect(listener3d.forwardX()).to.equal(-100); |
| 63 | + expect(listener3d.forwardY()).to.equal(100); |
| 64 | + expect(listener3d.forwardZ()).to.equal(300); |
| 65 | + }); |
| 66 | + it('can set forwardX, forwardY, forwardZ using orientForward function without a delay', function () { |
| 67 | + //TODO |
| 68 | + }); |
| 69 | + }); |
| 70 | + |
| 71 | + describe('orientation up', function () { |
| 72 | + it('can set upX, forwardY, upZ without a delay', function () { |
| 73 | + listener3d = new p5.Listener3D(); |
| 74 | + expect(listener3d.upX()).to.equal(0); |
| 75 | + expect(listener3d.upX(900)).to.equal(900); |
| 76 | + expect(listener3d.upY()).to.equal(1); |
| 77 | + expect(listener3d.upY(250)).to.equal(250); |
| 78 | + expect(listener3d.upZ()).to.equal(0); |
| 79 | + expect(listener3d.upZ(-100)).to.equal(-100); |
| 80 | + }); |
| 81 | + it('can set upX, forwardY, upZ with a delay', function () { |
| 82 | + //TODO |
| 83 | + }); |
| 84 | + it('can set upX, forwardY, upZ using orientup function without a delay', function () { |
| 85 | + listener3d = new p5.Listener3D(); |
| 86 | + listener3d.orientUp(-1000, 700, 300); |
| 87 | + expect(listener3d.upX()).to.equal(-1000); |
| 88 | + expect(listener3d.upY()).to.equal(700); |
| 89 | + expect(listener3d.upZ()).to.equal(300); |
| 90 | + }); |
| 91 | + it('can set upX, forwardY, upZ using orientup function without a delay', function () { |
| 92 | + //TODO |
| 93 | + }); |
| 94 | + }); |
| 95 | + |
| 96 | + describe('orientation', function () { |
| 97 | + it('can set forward orientations by passing 3 params to orient function (without delay) ', function () { |
| 98 | + listener3d = new p5.Listener3D(); |
| 99 | + expect(listener3d.orient(450, -987, 123)).to.include(450, -987, 123); |
| 100 | + expect(listener3d.forwardX()).to.equal(450); |
| 101 | + expect(listener3d.forwardY()).to.equal(-987); |
| 102 | + expect(listener3d.forwardZ()).to.equal(123); |
| 103 | + }); |
| 104 | + it('can set forward orientations by passing 4 params to orient function (with delay) ', function () { |
| 105 | + //TODO |
| 106 | + }); |
| 107 | + it('can set all orientations using orient function without a delay', function () { |
| 108 | + listener3d = new p5.Listener3D(); |
| 109 | + listener3d.orient(-300, -200, -100, 0, 100, 200); |
| 110 | + expect(listener3d.forwardX()).to.equal(-300); |
| 111 | + expect(listener3d.forwardY()).to.equal(-200); |
| 112 | + expect(listener3d.forwardZ()).to.equal(-100); |
| 113 | + expect(listener3d.upX()).to.equal(0); |
| 114 | + expect(listener3d.upY()).to.equal(100); |
| 115 | + expect(listener3d.upZ()).to.equal(200); |
| 116 | + }); |
| 117 | + it('can set forwardX, forwardY, forwardZ using orientForward function without a delay', function () { |
| 118 | + //TODO |
| 119 | + }); |
| 120 | + }); |
| 121 | + }); |
| 122 | +}); |
0 commit comments