From 3cb4995845e9f9469a84376d0bb7c71708f446a9 Mon Sep 17 00:00:00 2001 From: benjaminluck Date: Thu, 11 May 2017 01:59:16 +0200 Subject: [PATCH 1/2] Scroll to rotate instead of mouse drag --- js/controls/OrbitControls.js | 11 +++++++++-- page.js | 36 +++++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/js/controls/OrbitControls.js b/js/controls/OrbitControls.js index 45d1b41..2096ee8 100755 --- a/js/controls/OrbitControls.js +++ b/js/controls/OrbitControls.js @@ -277,6 +277,11 @@ THREE.OrbitControls = function ( object, domElement ) { } + this.rotate = function(ang){ + rotateLeft(ang); + scope.update(); + } + function rotateLeft( angle ) { sphericalDelta.theta -= angle; @@ -499,7 +504,9 @@ THREE.OrbitControls = function ( object, domElement ) { function handleMouseWheel( event ) { - //console.log( 'handleMouseWheel' ); + console.log( 'handleMouseWheel' ); + + this.rotL(0.0001); var delta = 0; @@ -892,7 +899,7 @@ THREE.OrbitControls = function ( object, domElement ) { scope.domElement.addEventListener( 'contextmenu', onContextMenu, false ); - scope.domElement.addEventListener( 'mousedown', onMouseDown, false ); + //scope.domElement.addEventListener( 'mousedown', onMouseDown, false ); scope.domElement.addEventListener( 'mousewheel', onMouseWheel, false ); scope.domElement.addEventListener( 'MozMousePixelScroll', onMouseWheel, false ); // firefox diff --git a/page.js b/page.js index a5f6c1f..1884c8a 100644 --- a/page.js +++ b/page.js @@ -1,20 +1,20 @@ window.addEventListener('load',function(){ // var obj = { // number : 0, - // range: [0,Math.PI], - // string : 'minPolarAngle' + // range: [Math.PI * -1,Math.PI], + // string : 'X' // }; // var obj2 = { // number : 0, - // range: [0,Math.PI], - // string : 'maxPolarAngle' + // range: [Math.PI * -1,Math.PI], + // string : 'Y' // }; // var controlKit = new ControlKit(); // controlKit.addPanel() // .addGroup() // .addSubGroup() - // .addSlider(obj,'number', 'range', { label: obj.string, onChange: function(evt){ console.log(window.controls.minPolarAngle = obj.number); }}) - // .addSlider(obj2,'number', 'range', { label: obj2.string, onChange: function(evt){ console.log(window.controls.maxPolarAngle = obj.number); }}) + // .addSlider(obj,'number', 'range', { label: obj.string, onChange: function(evt){ console.log(window.camera.position.x = obj.number); }}) + // .addSlider(obj2,'number', 'range', { label: obj2.string, onChange: function(evt){ console.log(window.camera.position.y = obj.number); }}) // .addStringInput(obj,'string'); }); @@ -41,9 +41,11 @@ loader.load( 'assets/scene100-red.dae', function ( collada ) { loadTextFile('shaders/fragmentShader.glsl', function(fragShader){ fragmentShader = fragShader; dae = collada.scene; - var symbolMeshMaterial = new THREE.MeshNormalMaterial( ) ; //3 - var symbolMeshMaterial = new THREE.MeshPhongMaterial( { color: 0xdddddd, shininess: 10, shading: THREE.SmoothShading, opacity: 0.5, transparent: true } ); var invisMaterial = new THREE.MeshNormalMaterial( ) ; //3 + var invisMaterial = new THREE.MeshPhongMaterial( { color: 0xdddddd, shininess: 10, shading: THREE.SmoothShading, opacity: 0.5, transparent: true } ); + // var symbolMeshMaterial = new THREE.MeshPhongMaterial( { color: 0xdddddd, shininess: 10, shading: THREE.SmoothShading, opacity: 0.5, transparent: true } ); + + var symbolMeshMaterial = new THREE.MeshNormalMaterial( ) dae.children.forEach(function(item){ if(item.name.indexOf('invis_') != -1){ item.children.forEach(function(mesh){ @@ -52,7 +54,7 @@ loader.load( 'assets/scene100-red.dae', function ( collada ) { }); }else{ item.children.forEach(function(mesh){ - mesh.material = symbolMeshMaterial; + mesh.children[0].children[0].material = symbolMeshMaterial; }); } @@ -125,7 +127,7 @@ function init() { tShine: { type: "t", value: THREE.ImageUtils.loadTexture( 'assets/dev004_sphere_bg.jpg' ) }, time: { type: "f", value: 1 }, weight: { type: "f", value: 0.001 }, - pitchMod: { type: "f", value: 5 } + pitchMod: { type: "f", value: 1 } }, vertexShader: vertexShader, fragmentShader: fragmentShader @@ -167,6 +169,7 @@ function init() { controls.enableZoom = false; controls.minPolarAngle = 1.55; controls.maxPolarAngle = 2.10; + controls.reset(); } window.addEventListener( 'resize', onWindowResize, false ); @@ -174,6 +177,7 @@ function init() { window.addEventListener( 'touchstart', onTouchStart, false ); window.addEventListener( 'touchend', onTouchEnd, false ); window.addEventListener( 'mousemove', onMouseMove, false ); + window.addEventListener( 'mousewheel', onMouseWheel, false ); } function onWindowResize() { @@ -182,6 +186,11 @@ function onWindowResize() { renderer.setSize( window.innerWidth, window.innerHeight ); } +function onMouseWheel(event){ + console.log(event); + controls.rotate(0.001 * event.deltaY); +} + function onMouseMove( event ) { // calculate mouse position in normalized device coordinates // (-1 to +1) for both components @@ -270,9 +279,10 @@ var clock = new THREE.Clock(); var start = Date.now(); function render() { - perlinMaterial.uniforms[ 'time' ].value = .00025 * ( Date.now() - start ); - perlinMaterial.uniforms[ 'weight' ].value = 10.0 * ( .5 + .5 * Math.sin( .00025 * ( Date.now() - start ) ) ); - perlinMaterial.uniforms[ 'weight' ].value = 10.0; + perlinMaterial.uniforms[ 'time' ].value = .0005 * ( Date.now() - start ); + perlinMaterial.uniforms[ 'pitchMod' ].value = .0005 * ( Date.now() - start ); + perlinMaterial.uniforms[ 'weight' ].value = 1.0 * ( .5 + .5 * Math.sin( .00025 * ( Date.now() - start ) ) ); + //perlinMaterial.uniforms[ 'weight' ].value = 10.0; var timer = Date.now() * 0.0005; radious = 1; camera.updateMatrix(); From aedda78fc96e32e9f327cb7f922524ed3545360e Mon Sep 17 00:00:00 2001 From: benjaminluck Date: Sat, 13 May 2017 03:32:56 +0200 Subject: [PATCH 2/2] Working sound playback via the SoundCloud Widget API. Very hack and slash: embeds and hides the widget iframe and uses the JavaScript API to play() and next() tracks. Seems to be the only working solution for both desktop / mobile (read iOS) after several failed attempts to use the regular SC.stream() method available in the SoundCloud JS SDK. --- index.php | 6 ++++++ js/audioplayer.js | 45 ++++++++++++++++++++++++++++++++++++++++++++- page.js | 8 ++++++-- 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index 178f20e..0380bb0 100644 --- a/index.php +++ b/index.php @@ -13,6 +13,8 @@ + + @@ -44,6 +46,10 @@ ?> + +