Skip to content

Commit

Permalink
Add webaudio_visualizer to example testing (#530)
Browse files Browse the repository at this point in the history
* Add examples

* Update Camera

* Update patch
  • Loading branch information
Methuselah96 authored Jul 5, 2023
1 parent 70715c7 commit d238a05
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 7 deletions.
46 changes: 46 additions & 0 deletions examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1936,6 +1936,52 @@ index 7504966..acac149 100644
audio.play(); // play audio with perfect timing when ball hits the surface
ball.userData.down = false;
}
diff --git a/examples-testing/examples/webaudio_visualizer.ts b/examples-testing/examples/webaudio_visualizer.ts
index 545694e..4aba18c 100644
--- a/examples-testing/examples/webaudio_visualizer.ts
+++ b/examples-testing/examples/webaudio_visualizer.ts
@@ -1,8 +1,13 @@
import * as THREE from 'three';
+import { IUniform } from 'three';

-let scene, camera, renderer, analyser, uniforms;
+let scene: THREE.Scene,
+ camera: THREE.Camera,
+ renderer: THREE.WebGLRenderer,
+ analyser: THREE.AudioAnalyser,
+ uniforms: { [uniform: string]: IUniform };

-const startButton = document.getElementById('startButton');
+const startButton = document.getElementById('startButton')!;
startButton.addEventListener('click', init);

function init() {
@@ -10,12 +15,12 @@ function init() {

//

- const overlay = document.getElementById('overlay');
+ const overlay = document.getElementById('overlay')!;
overlay.remove();

//

- const container = document.getElementById('container');
+ const container = document.getElementById('container')!;

renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
@@ -59,8 +64,8 @@ function init() {

const material = new THREE.ShaderMaterial({
uniforms: uniforms,
- vertexShader: document.getElementById('vertexShader').textContent,
- fragmentShader: document.getElementById('fragmentShader').textContent,
+ vertexShader: document.getElementById('vertexShader')!.textContent!,
+ fragmentShader: document.getElementById('fragmentShader')!.textContent!,
});

const geometry = new THREE.PlaneGeometry(1, 1);
diff --git a/examples-testing/examples/webgl_furnace_test.ts b/examples-testing/examples/webgl_furnace_test.ts
index a819541..46230b4 100644
--- a/examples-testing/examples/webgl_furnace_test.ts
Expand Down
7 changes: 1 addition & 6 deletions examples-testing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,7 @@ const files = {
// 'webgpu_skinning_points',
// 'webgpu_sprites',
],
webaudio: [
'webaudio_orientation',
'webaudio_sandbox',
'webaudio_timing',
// 'webaudio_visualizer',
],
webaudio: ['webaudio_orientation', 'webaudio_sandbox', 'webaudio_timing', 'webaudio_visualizer'],
webxr: [
// 'webxr_ar_cones',
// 'webxr_ar_hittest',
Expand Down
2 changes: 1 addition & 1 deletion types/three/src/cameras/Camera.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { CoordinateSystem } from '../constants';
* @see {@link https://threejs.org/docs/index.html#api/en/cameras/Camera | Official Documentation}
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/cameras/Camera.js | Source}
*/
export abstract class Camera extends Object3D {
export class Camera extends Object3D {
/**
* @remarks
* Note that this class is not intended to be called directly; you probably want a
Expand Down

0 comments on commit d238a05

Please sign in to comment.